diff --git a/config/auth0.php b/config/auth0.php index f403e40..3795939 100644 --- a/config/auth0.php +++ b/config/auth0.php @@ -55,4 +55,13 @@ Configuration::CONFIG_TRANSIENT_STORAGE_ID => Configuration::get(Configuration::CONFIG_TRANSIENT_STORAGE_ID), ], ], + + 'routes' => [ + Configuration::CONFIG_ROUTE_INDEX => Configuration::get(Configuration::CONFIG_ROUTE_INDEX, '/'), + Configuration::CONFIG_ROUTE_CALLBACK => Configuration::get(Configuration::CONFIG_ROUTE_CALLBACK, '/callback'), + Configuration::CONFIG_ROUTE_LOGIN => Configuration::get(Configuration::CONFIG_ROUTE_LOGIN, '/login'), + Configuration::CONFIG_ROUTE_AFTER_LOGIN => Configuration::get(Configuration::CONFIG_ROUTE_AFTER_LOGIN, '/'), + Configuration::CONFIG_ROUTE_LOGOUT => Configuration::get(Configuration::CONFIG_ROUTE_LOGOUT, '/logout'), + Configuration::CONFIG_ROUTE_AFTER_LOGOUT => Configuration::get(Configuration::CONFIG_ROUTE_AFTER_LOGOUT, '/'), + ], ]; diff --git a/rector.php b/rector.php index 4ee383c..7c84d38 100644 --- a/rector.php +++ b/rector.php @@ -4,11 +4,11 @@ use Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector; use Rector\Arguments\Rector\FuncCall\FunctionArgumentDefaultValueReplacerRector; -use Rector\Arguments\Rector\MethodCall\SwapMethodCallArgumentsRector; use Rector\Arguments\ValueObject\{ArgumentAdder, ReplaceFuncCallArgumentDefaultValue}; use Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector; -use Rector\CodeQuality\Rector\Assign\CombinedAssignRector; +use Rector\CodeQuality\Rector\Assign\{CombinedAssignRector, + SplitListAssignToSeparateLineRector}; use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector; use Rector\CodeQuality\Rector\BooleanNot\{ReplaceMultipleBooleanNotRector, SimplifyDeMorganBinaryRector}; @@ -16,6 +16,7 @@ use Rector\CodeQuality\Rector\Class_\{CompleteDynamicPropertiesRector, InlineConstructorDefaultToPropertyRector}; use Rector\CodeQuality\Rector\ClassMethod\{InlineArrayReturnAssignRector, + NarrowUnionTypeDocRector, OptionalParametersAfterRequiredRector, ReturnTypeFromStrictScalarReturnExprRector}; use Rector\CodeQuality\Rector\Concat\JoinStringConcatRector; @@ -23,13 +24,15 @@ use Rector\CodeQuality\Rector\Equal\UseIdenticalOverEqualWithSameTypeRector; use Rector\CodeQuality\Rector\Expression\{InlineIfToExplicitIfRector, TernaryFalseExpressionToIfRector}; -use Rector\CodeQuality\Rector\For_\ForRepeatedCountToOwnVariableRector; +use Rector\CodeQuality\Rector\For_\{ForRepeatedCountToOwnVariableRector, + ForToForeachRector}; use Rector\CodeQuality\Rector\Foreach_\{ForeachItemsAssignToEmptyArrayToAssignRector, ForeachToInArrayRector, SimplifyForeachToArrayFilterRector, SimplifyForeachToCoalescingRector, UnusedForeachValueToArrayKeysRector}; -use Rector\CodeQuality\Rector\FuncCall\{ArrayKeysAndInArrayToArrayKeyExistsRector, +use Rector\CodeQuality\Rector\FuncCall\{AddPregQuoteDelimiterRector, + ArrayKeysAndInArrayToArrayKeyExistsRector, ArrayMergeOfNonArraysToSimpleArrayRector, BoolvalToTypeCastRector, CallUserFuncWithArrowFunctionToInlineRector, @@ -49,6 +52,7 @@ StrvalToTypeCastRector, UnwrapSprintfOneArgumentRector}; use Rector\CodeQuality\Rector\FunctionLike\{RemoveAlwaysTrueConditionSetInConstructorRector, + SimplifyUselessLastVariableAssignRector, SimplifyUselessVariableRector}; use Rector\CodeQuality\Rector\Identical\{BooleanNotIdenticalToNotIdenticalRector, FlipTypeControlToUseExclusiveTypeRector, @@ -62,6 +66,7 @@ ExplicitBoolCompareRector, ShortenElseIfRector, SimplifyIfElseToTernaryRector, + SimplifyIfExactValueReturnValueRector, SimplifyIfNotNullReturnRector, SimplifyIfNullableReturnRector, SimplifyIfReturnBoolRector}; @@ -71,7 +76,7 @@ LogicalToBooleanRector}; use Rector\CodeQuality\Rector\New_\NewStaticToNewSelfRector; use Rector\CodeQuality\Rector\NotEqual\CommonNotEqualRector; -use Rector\CodeQuality\Rector\NullsafeMethodCall\CleanupUnneededNullsafeOperatorRector; +use Rector\CodeQuality\Rector\PropertyFetch\ExplicitMethodCallOverMagicGetSetRector; use Rector\CodeQuality\Rector\Switch_\SingularSwitchToIfRector; use Rector\CodeQuality\Rector\Ternary\{ArrayKeyExistsTernaryThenValueToCoalescingRector, SimplifyTautologyTernaryRector, @@ -83,14 +88,15 @@ use Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector; use Rector\CodingStyle\Rector\Class_\AddArrayDefaultToArrayPropertyRector; use Rector\CodingStyle\Rector\ClassConst\{RemoveFinalFromConstRector, SplitGroupedClassConstantsRector, VarConstantCommentRector}; -use Rector\CodingStyle\Rector\ClassMethod\{FuncGetArgsToVariadicParamRector, MakeInheritedMethodVisibilitySameAsParentRector, NewlineBeforeNewAssignSetRector, UnSpreadOperatorRector}; +use Rector\CodingStyle\Rector\ClassMethod\{FuncGetArgsToVariadicParamRector, MakeInheritedMethodVisibilitySameAsParentRector, NewlineBeforeNewAssignSetRector, RemoveDoubleUnderscoreInMethodNameRector, UnSpreadOperatorRector}; use Rector\CodingStyle\Rector\Closure\StaticClosureRector; use Rector\CodingStyle\Rector\Encapsed\{EncapsedStringsToSprintfRector, WrapEncapsedVariableInCurlyBracesRector}; -use Rector\CodingStyle\Rector\FuncCall\{CallUserFuncArrayToVariadicRector, CallUserFuncToMethodCallRector, ConsistentImplodeRector, CountArrayToEmptyArrayComparisonRector, StrictArraySearchRector, VersionCompareFuncCallToConstantRector}; +use Rector\CodingStyle\Rector\FuncCall\{CallUserFuncArrayToVariadicRector, CallUserFuncToMethodCallRector, ConsistentImplodeRector, ConsistentPregDelimiterRector, CountArrayToEmptyArrayComparisonRector, StrictArraySearchRector, VersionCompareFuncCallToConstantRector}; use Rector\CodingStyle\Rector\If_\NullableCompareToNullRector; use Rector\CodingStyle\Rector\Plus\UseIncrementAssignRector; use Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector; -use Rector\CodingStyle\Rector\Property\SplitGroupedPropertiesRector; +use Rector\CodingStyle\Rector\Property\{AddFalseDefaultToBoolPropertyRector, SplitGroupedPropertiesRector}; +use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector; use Rector\CodingStyle\Rector\String_\{SymplifyQuoteEscapeRector, UseClassKeywordForClassNameResolutionRector}; use Rector\CodingStyle\Rector\Switch_\BinarySwitchToIfElseRector; use Rector\CodingStyle\Rector\Ternary\TernaryConditionVariableAssignmentRector; @@ -99,7 +105,9 @@ use Rector\DeadCode\Rector\Array_\RemoveDuplicatedArrayKeyRector; use Rector\DeadCode\Rector\Assign\{RemoveDoubleAssignRector, RemoveUnusedVariableAssignRector}; +use Rector\DeadCode\Rector\BinaryOp\RemoveDuplicatedInstanceOfRector; use Rector\DeadCode\Rector\BooleanAnd\RemoveAndTrueRector; +use Rector\DeadCode\Rector\Cast\RecastingRemovalRector; use Rector\DeadCode\Rector\ClassConst\RemoveUnusedPrivateClassConstantRector; use Rector\DeadCode\Rector\ClassMethod\{RemoveDelegatingParentCallRector, RemoveEmptyClassMethodRector, @@ -108,17 +116,23 @@ RemoveUnusedPrivateMethodParameterRector, RemoveUnusedPrivateMethodRector, RemoveUnusedPromotedPropertyRector, + RemoveUselessParamTagRector, RemoveUselessReturnTagRector}; +use Rector\DeadCode\Rector\Concat\RemoveConcatAutocastRector; use Rector\DeadCode\Rector\Expression\{RemoveDeadStmtRector, SimplifyMirrorAssignRector}; use Rector\DeadCode\Rector\For_\{RemoveDeadContinueRector, RemoveDeadIfForeachForRector, RemoveDeadLoopRector}; use Rector\DeadCode\Rector\Foreach_\RemoveUnusedForeachKeyRector; -use Rector\DeadCode\Rector\FunctionLike\RemoveDeadReturnRector; -use Rector\DeadCode\Rector\If_\{RemoveUnusedNonEmptyArrayBeforeForeachRector, +use Rector\DeadCode\Rector\FunctionLike\{RemoveDeadReturnRector, + RemoveDuplicatedIfReturnRector}; +use Rector\DeadCode\Rector\If_\{RemoveAlwaysTrueIfConditionRector, + RemoveDeadInstanceOfRector, + RemoveUnusedNonEmptyArrayBeforeForeachRector, SimplifyIfElseWithSameContentRector, UnwrapFutureCompatibleIfPhpVersionRector}; +use Rector\DeadCode\Rector\MethodCall\RemoveEmptyMethodCallRector; use Rector\DeadCode\Rector\Node\RemoveNonExistingVarAnnotationRector; use Rector\DeadCode\Rector\Plus\RemoveDeadZeroAndOneOperationRector; use Rector\DeadCode\Rector\Property\{RemoveUnusedPrivatePropertyRector, @@ -134,18 +148,24 @@ use Rector\DeadCode\Rector\TryCatch\RemoveDeadTryCatchRector; use Rector\DependencyInjection\Rector\Class_\ActionInjectionToConstructorInjectionRector; use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector; -use Rector\EarlyReturn\Rector\If_\{ChangeIfElseValueAssignToEarlyReturnRector, +use Rector\EarlyReturn\Rector\If_\{ChangeAndIfToEarlyReturnRector, + ChangeIfElseValueAssignToEarlyReturnRector, ChangeNestedIfsToEarlyReturnRector, ChangeOrIfContinueToMultiContinueRector, + ChangeOrIfReturnToEarlyReturnRector, RemoveAlwaysElseRector}; use Rector\EarlyReturn\Rector\Return_\{PreparedValueToEarlyReturnRector, ReturnBinaryAndToEarlyReturnRector, ReturnBinaryOrToEarlyReturnRector}; use Rector\EarlyReturn\Rector\StmtsAwareInterface\ReturnEarlyIfVariableRector; +use Rector\Naming\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector; +use Rector\Naming\Rector\Class_\RenamePropertyToMatchTypeRector; +use Rector\Naming\Rector\ClassMethod\{RenameParamToMatchTypeRector, + RenameVariableToMatchNewTypeRector}; use Rector\Naming\Rector\Foreach_\{RenameForeachValueVariableToMatchExprVariableRector, RenameForeachValueVariableToMatchMethodCallReturnTypeRector}; use Rector\Php52\Rector\Property\VarToPublicPropertyRector; -use Rector\Php70\Rector\StmtsAwareInterface\IfIssetToCoalescingRector; +use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector; use Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector; use Rector\Php80\Rector\Class_\{ClassPropertyAssignToConstructorPromotionRector, @@ -155,7 +175,10 @@ FinalPrivateToPrivateVisibilityRector, SetStateToStaticRector}; use Rector\Php80\Rector\FuncCall\{ClassOnObjectRector, - Php8ResourceReturnToObjectRector}; + Php8ResourceReturnToObjectRector, + TokenGetAllToObjectRector}; +use Rector\Php80\Rector\FunctionLike\{MixedTypeRector, + UnionTypesRector}; use Rector\Php80\Rector\Identical\{StrEndsWithRector, StrStartsWithRector}; use Rector\Php80\Rector\NotIdentical\StrContainsRector; @@ -163,9 +186,12 @@ use Rector\Php80\Rector\Ternary\GetDebugTypeRector; use Rector\PHPUnit\Rector\ClassMethod\RemoveEmptyTestMethodRector; use Rector\Privatization\Rector\Class_\{ChangeGlobalVariablesToPropertiesRector, + ChangeReadOnlyVariableWithDefaultValueToConstantRector, FinalizeClassesWithoutChildrenRector}; use Rector\Privatization\Rector\ClassMethod\PrivatizeFinalClassMethodRector; -use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector; +use Rector\Privatization\Rector\MethodCall\PrivatizeLocalGetterToPropertyRector; +use Rector\Privatization\Rector\Property\{ChangeReadOnlyPropertyWithDefaultValueToConstantRector, + PrivatizeFinalClassPropertyRector}; use Rector\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector; use Rector\PSR4\Rector\Namespace_\MultipleClassFileToPsr4ClassesRector; use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; @@ -177,10 +203,11 @@ ReturnTypeFromStrictTernaryRector}; use Rector\TypeDeclaration\Rector\ClassMethod\{AddMethodCallBasedStrictParamTypeRector, AddParamTypeBasedOnPHPUnitDataProviderRector, + AddParamTypeFromPropertyTypeRector, AddReturnTypeDeclarationBasedOnParentClassMethodRector, AddVoidReturnTypeWhereNoReturnRector, ArrayShapeFromConstantArrayReturnRector, - BoolReturnTypeFromStrictScalarReturnsRector, + ParamAnnotationIncorrectNullableRector, ParamTypeByMethodCallTypeRector, ParamTypeByParentCallTypeRector, ReturnAnnotationIncorrectNullableRector, @@ -213,27 +240,27 @@ $rectorConfig->ruleWithConfiguration( RenameFunctionRector::class, [ - 'chop' => 'rtrim', - 'doubleval' => 'floatval', - 'fputs' => 'fwrite', - 'gzputs' => 'gzwrites', - 'ini_alter' => 'ini_set', - 'is_double' => 'is_float', - 'is_integer' => 'is_int', - 'is_long' => 'is_int', - 'is_real' => 'is_float', + 'chop' => 'rtrim', + 'doubleval' => 'floatval', + 'fputs' => 'fwrite', + 'gzputs' => 'gzwrites', + 'ini_alter' => 'ini_set', + 'is_double' => 'is_float', + 'is_integer' => 'is_int', + 'is_long' => 'is_int', + 'is_real' => 'is_float', 'is_writeable' => 'is_writable', - 'join' => 'implode', - 'key_exists' => 'array_key_exists', - 'mbstrcut' => 'mb_strcut', - 'mbstrlen' => 'mb_strlen', - 'mbstrpos' => 'mb_strpos', - 'mbstrrpos' => 'mb_strrpos', - 'mbsubstr' => 'mb_substr', - 'pos' => 'current', - 'sizeof' => 'count', - 'split' => 'explode', - 'strchr' => 'strstr', + 'join' => 'implode', + 'key_exists' => 'array_key_exists', + 'mbstrcut' => 'mb_strcut', + 'mbstrlen' => 'mb_strlen', + 'mbstrpos' => 'mb_strpos', + 'mbstrrpos' => 'mb_strrpos', + 'mbsubstr' => 'mb_substr', + 'pos' => 'current', + 'sizeof' => 'count', + 'split' => 'explode', + 'strchr' => 'strstr', ], ); @@ -254,30 +281,30 @@ $rectorConfig->ruleWithConfiguration( RenameFunctionRector::class, [ - 'pg_clientencoding' => 'pg_client_encoding', - 'pg_cmdtuples' => 'pg_affected_rows', - 'pg_errormessage' => 'pg_last_error', - 'pg_fieldisnull' => 'pg_field_is_null', - 'pg_fieldname' => 'pg_field_name', - 'pg_fieldnum' => 'pg_field_num', - 'pg_fieldprtlen' => 'pg_field_prtlen', - 'pg_fieldsize' => 'pg_field_size', - 'pg_fieldtype' => 'pg_field_type', - 'pg_freeresult' => 'pg_free_result', - 'pg_getlastoid' => 'pg_last_oid', - 'pg_loclose' => 'pg_lo_close', - 'pg_locreate' => 'pg_lo_create', - 'pg_loexport' => 'pg_lo_export', - 'pg_loimport' => 'pg_lo_import', - 'pg_loopen' => 'pg_lo_open', - 'pg_loread' => 'pg_lo_read', - 'pg_loreadall' => 'pg_lo_read_all', - 'pg_lounlink' => 'pg_lo_unlink', - 'pg_lowrite' => 'pg_lo_write', - 'pg_numfields' => 'pg_num_fields', - 'pg_numrows' => 'pg_num_rows', - 'pg_result' => 'pg_fetch_result', - 'pg_setclientencoding' => 'pg_set_client_encoding', + 'pg_clientencoding' => 'pg_client_encoding', + 'pg_cmdtuples' => 'pg_affected_rows', + 'pg_errormessage' => 'pg_last_error', + 'pg_fieldisnull' => 'pg_field_is_null', + 'pg_fieldname' => 'pg_field_name', + 'pg_fieldnum' => 'pg_field_num', + 'pg_fieldprtlen' => 'pg_field_prtlen', + 'pg_fieldsize' => 'pg_field_size', + 'pg_fieldtype' => 'pg_field_type', + 'pg_freeresult' => 'pg_free_result', + 'pg_getlastoid' => 'pg_last_oid', + 'pg_loclose' => 'pg_lo_close', + 'pg_locreate' => 'pg_lo_create', + 'pg_loexport' => 'pg_lo_export', + 'pg_loimport' => 'pg_lo_import', + 'pg_loopen' => 'pg_lo_open', + 'pg_loread' => 'pg_lo_read', + 'pg_loreadall' => 'pg_lo_read_all', + 'pg_lounlink' => 'pg_lo_unlink', + 'pg_lowrite' => 'pg_lo_write', + 'pg_numfields' => 'pg_num_fields', + 'pg_numrows' => 'pg_num_rows', + 'pg_result' => 'pg_fetch_result', + 'pg_setclientencoding' => 'pg_set_client_encoding' ], ); @@ -292,7 +319,7 @@ new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'l', 'lt'), new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'gte', 'ge'), new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'lte', 'le'), - new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'n', 'ne'), + new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'n', 'ne') ], ); @@ -300,43 +327,46 @@ FuncCallToConstFetchRector::class, [ 'php_sapi_name' => 'PHP_SAPI', - 'pi' => 'M_PI', + 'pi' => 'M_PI' ], ); $rectorConfig->rules([ AbsolutizeRequireAndIncludePathRector::class, - ActionInjectionToConstructorInjectionRector::class, + // ActionInjectionToConstructorInjectionRector::class, AddArrayDefaultToArrayPropertyRector::class, AddArrowFunctionReturnTypeRector::class, AddClosureReturnTypeRector::class, + // AddFalseDefaultToBoolPropertyRector::class, AddMethodCallBasedStrictParamTypeRector::class, AddParamBasedOnParentClassMethodRector::class, AddParamTypeBasedOnPHPUnitDataProviderRector::class, AddParamTypeSplFixedArrayRector::class, + // AddPregQuoteDelimiterRector::class, AddReturnTypeDeclarationBasedOnParentClassMethodRector::class, AddReturnTypeDeclarationFromYieldsRector::class, AddVoidReturnTypeWhereNoReturnRector::class, AndAssignsToSeparateLinesRector::class, ArrayKeyExistsTernaryThenValueToCoalescingRector::class, - ArrayKeysAndInArrayToArrayKeyExistsRector::class, + // ArrayKeysAndInArrayToArrayKeyExistsRector::class, ArrayMergeOfNonArraysToSimpleArrayRector::class, - ArrayShapeFromConstantArrayReturnRector::class, + // ArrayShapeFromConstantArrayReturnRector::class, BinarySwitchToIfElseRector::class, BooleanNotIdenticalToNotIdenticalRector::class, BoolvalToTypeCastRector::class, CallableThisArrayToAnonymousFunctionRector::class, CallUserFuncArrayToVariadicRector::class, CallUserFuncToMethodCallRector::class, - CallUserFuncToMethodCallRector::class, CallUserFuncWithArrowFunctionToInlineRector::class, CatchExceptionNameMatchingTypeRector::class, ChangeArrayPushToArrayAssignRector::class, - ChangeGlobalVariablesToPropertiesRector::class, + // ChangeGlobalVariablesToPropertiesRector::class, ChangeIfElseValueAssignToEarlyReturnRector::class, ChangeNestedForeachIfsToEarlyContinueRector::class, ChangeNestedIfsToEarlyReturnRector::class, ChangeOrIfContinueToMultiContinueRector::class, + // ChangeReadOnlyPropertyWithDefaultValueToConstantRector::class, + // ChangeReadOnlyVariableWithDefaultValueToConstantRector::class, ChangeSwitchToMatchRector::class, ClassOnObjectRector::class, ClassOnThisVariableObjectRector::class, @@ -348,11 +378,12 @@ CompleteDynamicPropertiesRector::class, ConsecutiveNullCompareReturnsToNullCoalesceQueueRector::class, ConsistentImplodeRector::class, - CountArrayToEmptyArrayComparisonRector::class, + // ConsistentPregDelimiterRector::class, CountArrayToEmptyArrayComparisonRector::class, EmptyOnNullableObjectToInstanceOfRector::class, EncapsedStringsToSprintfRector::class, ExplicitBoolCompareRector::class, + // ExplicitMethodCallOverMagicGetSetRector::class, FinalizeClassesWithoutChildrenRector::class, FinalPrivateToPrivateVisibilityRector::class, FlipTypeControlToUseExclusiveTypeRector::class, @@ -360,7 +391,7 @@ ForeachItemsAssignToEmptyArrayToAssignRector::class, ForeachToInArrayRector::class, ForRepeatedCountToOwnVariableRector::class, - FuncGetArgsToVariadicParamRector::class, + // ForToForeachRector::class, FuncGetArgsToVariadicParamRector::class, GetClassToInstanceOfRector::class, GetDebugTypeRector::class, @@ -374,24 +405,24 @@ JoinStringConcatRector::class, LogicalToBooleanRector::class, MakeInheritedMethodVisibilitySameAsParentRector::class, - MultipleClassFileToPsr4ClassesRector::class, + // MultipleClassFileToPsr4ClassesRector::class, + // NarrowUnionTypeDocRector::class, NewlineBeforeNewAssignSetRector::class, NewStaticToNewSelfRector::class, - NormalizeNamespaceByPSR4ComposerAutoloadRector::class, + // NormalizeNamespaceByPSR4ComposerAutoloadRector::class, NullableCompareToNullRector::class, OptionalParametersAfterRequiredRector::class, - OptionalParametersAfterRequiredRector::class, + // ParamAnnotationIncorrectNullableRector::class, ParamTypeByMethodCallTypeRector::class, ParamTypeByParentCallTypeRector::class, ParamTypeFromStrictTypedPropertyRector::class, - Php8ResourceReturnToObjectRector::class, + // Php8ResourceReturnToObjectRector::class, PostIncDecToPreIncDecRector::class, - PreparedValueToEarlyReturnRector::class, PrivatizeFinalClassMethodRector::class, PrivatizeFinalClassPropertyRector::class, PropertyTypeFromStrictSetterGetterRector::class, RemoveAlwaysElseRector::class, - RemoveAlwaysTrueConditionSetInConstructorRector::class, + // RemoveAlwaysTrueConditionSetInConstructorRector::class, RemoveAndTrueRector::class, RemoveDeadConditionAboveReturnRector::class, RemoveDeadContinueRector::class, @@ -401,20 +432,24 @@ RemoveDeadStmtRector::class, RemoveDeadTryCatchRector::class, RemoveDeadZeroAndOneOperationRector::class, - RemoveDelegatingParentCallRector::class, + // RemoveDelegatingParentCallRector::class, RemoveDoubleAssignRector::class, + // RemoveDoubleUnderscoreInMethodNameRector::class, RemoveDuplicatedArrayKeyRector::class, RemoveDuplicatedCaseInSwitchRector::class, + // RemoveDuplicatedIfReturnRector::class, + // RemoveDuplicatedInstanceOfRector::class, RemoveEmptyClassMethodRector::class, - RemoveEmptyTestMethodRector::class, + // RemoveEmptyMethodCallRector::class, + // RemoveEmptyTestMethodRector::class, RemoveExtraParametersRector::class, RemoveFinalFromConstRector::class, RemoveJustPropertyFetchForAssignRector::class, - RemoveJustVariableAssignRector::class, - RemoveLastReturnRector::class, + // RemoveJustVariableAssignRector::class, + // RemoveLastReturnRector::class, + // RemoveNonExistingVarAnnotationRector::class, RemoveNullPropertyInitializationRector::class, RemoveParentCallWithoutParentRector::class, - RemoveParentCallWithoutParentRector::class, RemoveSoleValueSprintfRector::class, RemoveUnreachableStatementRector::class, RemoveUnusedConstructorParamRector::class, @@ -422,7 +457,6 @@ RemoveUnusedNonEmptyArrayBeforeForeachRector::class, RemoveUnusedPrivateClassConstantRector::class, RemoveUnusedPrivateMethodParameterRector::class, - RemoveUnusedPrivateMethodRector::class, RemoveUnusedPrivatePropertyRector::class, RemoveUnusedPromotedPropertyRector::class, RemoveUnusedVariableAssignRector::class, @@ -433,7 +467,7 @@ RenameForeachValueVariableToMatchMethodCallReturnTypeRector::class, ReplaceMultipleBooleanNotRector::class, ReturnAnnotationIncorrectNullableRector::class, - ReturnBinaryAndToEarlyReturnRector::class, + // ReturnBinaryAndToEarlyReturnRector::class, ReturnBinaryOrToEarlyReturnRector::class, ReturnEarlyIfVariableRector::class, ReturnNeverTypeRector::class, @@ -444,7 +478,6 @@ ReturnTypeFromStrictNativeCallRector::class, ReturnTypeFromStrictNewArrayRector::class, ReturnTypeFromStrictScalarReturnExprRector::class, - ReturnTypeFromStrictScalarReturnExprRector::class, ReturnTypeFromStrictTernaryRector::class, ReturnTypeFromStrictTypedCallRector::class, ReturnTypeFromStrictTypedPropertyRector::class, @@ -458,11 +491,12 @@ SimplifyDeMorganBinaryRector::class, SimplifyEmptyArrayCheckRector::class, SimplifyEmptyCheckOnEmptyArrayRector::class, - SimplifyForeachToArrayFilterRector::class, + // SimplifyForeachToArrayFilterRector::class, SimplifyForeachToCoalescingRector::class, SimplifyFuncGetArgsCountRector::class, SimplifyIfElseToTernaryRector::class, SimplifyIfElseWithSameContentRector::class, + // SimplifyIfExactValueReturnValueRector::class, SimplifyIfNotNullReturnRector::class, SimplifyIfNullableReturnRector::class, SimplifyIfReturnBoolRector::class, @@ -471,12 +505,14 @@ SimplifyRegexPatternRector::class, SimplifyStrposLowerRector::class, SimplifyTautologyTernaryRector::class, + // SimplifyUselessLastVariableAssignRector::class, SimplifyUselessVariableRector::class, SingleInArrayToCompareRector::class, SingularSwitchToIfRector::class, SplitDoubleAssignRector::class, SplitGroupedClassConstantsRector::class, SplitGroupedPropertiesRector::class, + // SplitListAssignToSeparateLineRector::class, StaticArrowFunctionRector::class, StaticClosureRector::class, StrContainsRector::class, @@ -493,6 +529,7 @@ TernaryFalseExpressionToIfRector::class, TernaryToBooleanOrFalseToBooleanAndRector::class, ThrowWithPreviousExceptionRector::class, + // TokenGetAllToObjectRector::class, TypedPropertyFromAssignsRector::class, TypedPropertyFromStrictConstructorRector::class, TypedPropertyFromStrictGetterMethodReturnTypeRector::class, @@ -505,13 +542,10 @@ UseClassKeywordForClassNameResolutionRector::class, UseIdenticalOverEqualWithSameTypeRector::class, UseIncrementAssignRector::class, - VarAnnotationIncorrectNullableRector::class, - VarConstantCommentRector::class, + // VarAnnotationIncorrectNullableRector::class, + // VarConstantCommentRector::class, VarToPublicPropertyRector::class, VersionCompareFuncCallToConstantRector::class, WrapEncapsedVariableInCurlyBracesRector::class, - IfIssetToCoalescingRector::class, - CleanupUnneededNullsafeOperatorRector::class, - BoolReturnTypeFromStrictScalarReturnsRector::class, ]); }; diff --git a/src/Configuration.php b/src/Configuration.php index 479bf2d..2180095 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -148,6 +148,16 @@ final class Configuration implements ConfigurationContract */ public const CONFIG_MANAGEMENT_TOKEN_CACHE = 'managementTokenCache'; + /** + * @var string + */ + public const CONFIG_NAMESPACE = 'auth0.'; + + /** + * @var string + */ + public const CONFIG_NAMESPACE_ROUTES = 'auth0.routes.'; + /** * @var string */ @@ -173,6 +183,41 @@ final class Configuration implements ConfigurationContract */ public const CONFIG_RESPONSE_TYPE = 'responseType'; + /** + * @var string + */ + public const CONFIG_ROUTE_AFTER_LOGIN = 'afterLogin'; + + /** + * @var string + */ + public const CONFIG_ROUTE_AFTER_LOGOUT = 'afterLogout'; + + /** + * @var string + */ + public const CONFIG_ROUTE_BACKCHANNEL = 'backchannel'; + + /** + * @var string + */ + public const CONFIG_ROUTE_CALLBACK = 'callback'; + + /** + * @var string + */ + public const CONFIG_ROUTE_INDEX = 'index'; + + /** + * @var string + */ + public const CONFIG_ROUTE_LOGIN = 'login'; + + /** + * @var string + */ + public const CONFIG_ROUTE_LOGOUT = 'logout'; + /** * @var string */ @@ -435,6 +480,17 @@ public static function getPath(): string return self::$path; } + public static function string(string $key, ?string $default = null): ?string + { + $value = config($key, $default); + + if (is_string($value)) { + return $value; + } + + return null; + } + public static function stringOrIntToIntOrNull( int | string $value, int | null $default = null, diff --git a/src/Controllers/CallbackControllerAbstract.php b/src/Controllers/CallbackControllerAbstract.php index 4670a6a..bd9a461 100644 --- a/src/Controllers/CallbackControllerAbstract.php +++ b/src/Controllers/CallbackControllerAbstract.php @@ -6,11 +6,11 @@ use Auth0\Laravel\Auth\Guard; use Auth0\Laravel\Entities\CredentialEntityContract; -use Auth0\Laravel\Events; use Auth0\Laravel\Events\{AuthenticationFailed, AuthenticationSucceeded}; use Auth0\Laravel\Exceptions\ControllerException; use Auth0\Laravel\Exceptions\Controllers\CallbackControllerException; use Auth0\Laravel\Guards\GuardAbstract; +use Auth0\Laravel\{Configuration, Events}; use Illuminate\Auth\Events\{Attempting, Authenticated, Failed, Validated}; use Illuminate\Contracts\Auth\Authenticatable; use Illuminate\Http\Request; @@ -115,7 +115,7 @@ public function __invoke( } if (! $success) { - return redirect()->intended('/login'); + return redirect()->intended(config(Configuration::CONFIG_NAMESPACE_ROUTES . Configuration::CONFIG_ROUTE_LOGIN, '/login')); } $credential = ($guard instanceof Guard) ? $guard->find(Guard::SOURCE_SESSION) : $guard->find(); @@ -140,6 +140,6 @@ public function __invoke( } } - return redirect()->intended('/'); + return redirect()->intended(config(Configuration::CONFIG_NAMESPACE_ROUTES . Configuration::CONFIG_ROUTE_AFTER_LOGIN, config(Configuration::CONFIG_NAMESPACE_ROUTES . Configuration::CONFIG_ROUTE_INDEX, '/'))); } } diff --git a/src/Controllers/LoginControllerAbstract.php b/src/Controllers/LoginControllerAbstract.php index 3d3c5da..7c558d2 100644 --- a/src/Controllers/LoginControllerAbstract.php +++ b/src/Controllers/LoginControllerAbstract.php @@ -6,10 +6,10 @@ use Auth0\Laravel\Auth\Guard; use Auth0\Laravel\Entities\CredentialEntityContract; -use Auth0\Laravel\Events; use Auth0\Laravel\Events\LoginAttempting; use Auth0\Laravel\Exceptions\ControllerException; use Auth0\Laravel\Guards\GuardAbstract; +use Auth0\Laravel\{Configuration, Events}; use Illuminate\Http\Request; use Symfony\Component\HttpFoundation\Response; @@ -40,7 +40,15 @@ public function __invoke( $loggedIn ??= (($guard instanceof Guard) ? $guard->find(Guard::SOURCE_SESSION) : $guard->find()) instanceof CredentialEntityContract; if ($loggedIn) { - return redirect()->intended('/'); + return redirect()->intended( + config( + Configuration::CONFIG_NAMESPACE_ROUTES . Configuration::CONFIG_ROUTE_AFTER_LOGIN, + config( + Configuration::CONFIG_NAMESPACE_ROUTES . Configuration::CONFIG_ROUTE_INDEX, + '/', + ), + ), + ); } session()->regenerate(true); diff --git a/src/Controllers/LogoutControllerAbstract.php b/src/Controllers/LogoutControllerAbstract.php index 4acb096..c5d81f6 100644 --- a/src/Controllers/LogoutControllerAbstract.php +++ b/src/Controllers/LogoutControllerAbstract.php @@ -5,6 +5,7 @@ namespace Auth0\Laravel\Controllers; use Auth0\Laravel\Auth\Guard; +use Auth0\Laravel\Configuration; use Auth0\Laravel\Entities\CredentialEntityContract; use Auth0\Laravel\Exceptions\ControllerException; use Auth0\Laravel\Guards\GuardAbstract; @@ -37,16 +38,20 @@ public function __invoke( $loggedIn = $guard->check() ? true : null; $loggedIn ??= (($guard instanceof Guard) ? $guard->find(Guard::SOURCE_SESSION) : $guard->find()) instanceof CredentialEntityContract; + $landing = Configuration::string(Configuration::CONFIG_NAMESPACE_ROUTES . Configuration::CONFIG_ROUTE_AFTER_LOGOUT); + $landing ??= Configuration::string(Configuration::CONFIG_NAMESPACE_ROUTES . Configuration::CONFIG_ROUTE_INDEX); + $landing ??= '/'; + if ($loggedIn) { session()->invalidate(); $guard->logout(); /** @phpstan-ignore-line */ - $route = (string) url('/'); /** @phpstan-ignore-line */ + $route = (string) url($landing); /** @phpstan-ignore-line */ $url = $guard->sdk()->authentication()->getLogoutLink($route); return redirect()->away($url); } - return redirect()->intended('/'); + return redirect()->intended($landing); } } diff --git a/src/ServiceAbstract.php b/src/ServiceAbstract.php index 4bc9e0a..c11dfc2 100644 --- a/src/ServiceAbstract.php +++ b/src/ServiceAbstract.php @@ -55,9 +55,9 @@ final public static function routes( string $authenticationGuard = 'auth0-session', ): void { Route::group(['middleware' => ['web', 'guard:' . $authenticationGuard]], static function (): void { - Route::get('/login', LoginController::class)->name('login'); - Route::get('/logout', LogoutController::class)->name('logout'); - Route::get('/callback', CallbackController::class)->name('callback'); + Route::get(Configuration::string(Configuration::CONFIG_NAMESPACE_ROUTES . Configuration::CONFIG_ROUTE_LOGIN) ?? '/login', LoginController::class)->name('login'); + Route::get(Configuration::string(Configuration::CONFIG_NAMESPACE_ROUTES . Configuration::CONFIG_ROUTE_LOGOUT) ?? '/logout', LogoutController::class)->name('logout'); + Route::get(Configuration::string(Configuration::CONFIG_NAMESPACE_ROUTES . Configuration::CONFIG_ROUTE_CALLBACK) ?? '/callback', CallbackController::class)->name('callback'); }); } } diff --git a/src/ServiceProviderAbstract.php b/src/ServiceProviderAbstract.php index c3b48b2..51770e4 100644 --- a/src/ServiceProviderAbstract.php +++ b/src/ServiceProviderAbstract.php @@ -220,9 +220,9 @@ final public function registerRoutes(): void { if (true === config('auth0.registerAuthenticationRoutes')) { Route::group(['middleware' => 'web'], static function (): void { - Route::get('/login', LoginController::class)->name('login'); - Route::get('/logout', LogoutController::class)->name('logout'); - Route::get('/callback', CallbackController::class)->name('callback'); + Route::get(Configuration::string(Configuration::CONFIG_NAMESPACE_ROUTES . Configuration::CONFIG_ROUTE_LOGIN) ?? '/login', LoginController::class)->name('login'); + Route::get(Configuration::string(Configuration::CONFIG_NAMESPACE_ROUTES . Configuration::CONFIG_ROUTE_LOGOUT) ?? '/logout', LogoutController::class)->name('logout'); + Route::get(Configuration::string(Configuration::CONFIG_NAMESPACE_ROUTES . Configuration::CONFIG_ROUTE_CALLBACK) ?? '/callback', CallbackController::class)->name('callback'); }); } } diff --git a/tests/Unit/ConfigurationTest.php b/tests/Unit/ConfigurationTest.php index f654d5c..795b709 100644 --- a/tests/Unit/ConfigurationTest.php +++ b/tests/Unit/ConfigurationTest.php @@ -148,3 +148,19 @@ ->toBeInt() ->toEqual(123); }); + +test('string() behaves as expected', function (): void { + config(['test2' => [ + 'testInteger' => 123, + 'testString' => '123', + ]]); + + define('AUTH0_OVERRIDE_CONFIGURATION_STRING_METHOD', 'test2'); + + expect(Configuration::string('test2.testInteger')) + ->toBeNull(); + + expect(Configuration::string('test2.testString')) + ->toBeString() + ->toEqual('123'); +});