diff --git a/.github/workflows/code_analysis.yaml b/.github/workflows/code_analysis.yaml index e9db40390..b5971cf93 100644 --- a/.github/workflows/code_analysis.yaml +++ b/.github/workflows/code_analysis.yaml @@ -20,9 +20,23 @@ jobs: name: 'Active Classes' run: vendor/bin/class-leak check config src rules --ansi --skip-suffix "Rector" --skip-type "\Rector\Set\Contract\SetProviderInterface" + - + name: "Finalize Classes" + run: vendor/bin/swiss-knife finalize config src tests rules rules-tests --ansi + + - + name: 'Composer Validate' + run: composer validate + + - + name: 'PHPStan' + run: vendor/bin/phpstan + name: ${{ matrix.actions.name }} + runs-on: ubuntu-latest - timeout-minutes: 10 + + timeout-minutes: 5 steps: - uses: actions/checkout@v4 @@ -30,7 +44,7 @@ jobs: - uses: shivammathur/setup-php@v2 with: - php-version: 8.2 + php-version: 8.3 coverage: none - uses: "ramsey/composer-install@v2" diff --git a/.github/workflows/code_analysis_reusable.yaml b/.github/workflows/code_analysis_reusable.yaml deleted file mode 100644 index 7ff5c927c..000000000 --- a/.github/workflows/code_analysis_reusable.yaml +++ /dev/null @@ -1,19 +0,0 @@ -name: Code Analysis Reusable - -on: - pull_request: null - push: - branches: - - main - -jobs: - code_analysis_reusable: - # see https://github.com/rectorphp/reusable-workflows - uses: rectorphp/reusable-workflows/.github/workflows/code_analysis.yaml@main - - rector: - # run only on main repository, not on the forks without access - if: github.repository == 'rectorphp/rector-downgrade-php' - - # see https://github.com/rectorphp/reusable-workflows - uses: rectorphp/reusable-workflows/.github/workflows/rector.yaml@main diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 75011db6e..a281116db 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -21,7 +21,7 @@ jobs: - uses: shivammathur/setup-php@v2 with: - php-version: 8.2 + php-version: 8.3 coverage: none - uses: "ramsey/composer-install@v2" diff --git a/composer.json b/composer.json index a6cd886c6..7233ff042 100644 --- a/composer.json +++ b/composer.json @@ -4,18 +4,19 @@ "license": "MIT", "description": "Rector upgrades rules for Symfony Framework", "require": { - "php": ">=8.2", + "php": ">=8.3", "ext-xml": "*" }, "require-dev": { - "phpecs/phpecs": "^2.2", + "symplify/easy-coding-standard": "^13.0.4", "phpstan/extension-installer": "^1.4", "phpstan/phpstan": "^2.1.32", "phpstan/phpstan-deprecation-rules": "^2.0", "phpstan/phpstan-webmozart-assert": "^2.0", "phpunit/phpunit": "^11.5", - "rector/jack": "^0.4", + "rector/jack": "^0.5", "rector/rector-src": "dev-main", + "rector/swiss-knife": "^2.3", "rector/type-perfect": "^2.1", "symfony/config": "^6.4", "symfony/dependency-injection": "^6.4", @@ -30,7 +31,7 @@ "symplify/vendor-patches": "^11.5", "tomasvotruba/class-leak": "^2.1", "tomasvotruba/type-coverage": "^2.1", - "tomasvotruba/unused-public": "^2.1", + "tomasvotruba/unused-public": "^2.2", "tracy/tracy": "^2.11" }, "autoload": { diff --git a/phpstan.neon b/phpstan.neon index 1b740fbcf..b057d4674 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,7 +1,6 @@ -# @todo enable -#includes: -# - vendor/symplify/phpstan-rules/config/symplify-rules.neon -# - vendor/symplify/phpstan-rules/config/rector-rules.neon +includes: + - vendor/symplify/phpstan-rules/config/symplify-rules.neon + - vendor/symplify/phpstan-rules/config/rector-rules.neon rules: - Symplify\PHPStanRules\Rules\StringFileAbsolutePathExistsRule @@ -14,7 +13,7 @@ parameters: typeAliases: StmtsAware: \PhpParser\Node\Stmt\Block | \PhpParser\Node\Expr\Closure | \PhpParser\Node\Stmt\Case_ | \PhpParser\Node\Stmt\Catch_ | \PhpParser\Node\Stmt\ClassMethod | \PhpParser\Node\Stmt\Do_ | \PhpParser\Node\Stmt\Else_ | \PhpParser\Node\Stmt\ElseIf_ | \PhpParser\Node\Stmt\Finally_ | \PhpParser\Node\Stmt\For_ | \PhpParser\Node\Stmt\Foreach_ | \PhpParser\Node\Stmt\Function_ | \PhpParser\Node\Stmt\If_ | \PhpParser\Node\Stmt\Namespace_ | \PhpParser\Node\Stmt\TryCatch | \PhpParser\Node\Stmt\While_ | \Rector\PhpParser\Node\FileNode - reportUnmatchedIgnoredErrors: false + # reportUnmatchedIgnoredErrors: false treatPhpDocTypesAsCertain: false paths: @@ -50,7 +49,6 @@ parameters: # false positive - '#but class PhpParser\\Node\\Stmt\\Expression is not generic#' - - '#Access to an undefined property Rector\\Contract\\PhpParser\\Node\\StmtsAwareInterface\:\:\$stmts#' # more advanced usage, but not always working # see https://github.com/rectorphp/rector-src/actions/runs/11798721617/job/32865546672?pr=6422#step:5:110 @@ -69,9 +67,6 @@ parameters: - '#Parameter 1 should use "PHPStan\\BetterReflection\\Reflection\\Adapter\\ReflectionMethod" type as the only type passed to this method#' - # local use php 8.3 - - identifier: typeCoverage.constantTypeCoverage - # in tests - message: '#Fetching deprecated class constant SYMFONY_(.*?) of class Rector\\Symfony\\Set\\SymfonySetList#' @@ -79,3 +74,14 @@ parameters: - tests - config/sets/symfony/annotations-to-attributes.php + # using XML to load symfony config + - + path: src/ValueObjectFactory/ServiceMapFactory.php + identifier: rector.noInstanceOfStaticReflection + + - + path: src/ValueObjectFactory/ServiceMapFactory.php + message: '#"@simplexml_load_string\(\$fileContents\)" is forbidden to use#' + + + diff --git a/rector.php b/rector.php index 0c1cc82b4..10f8b6946 100644 --- a/rector.php +++ b/rector.php @@ -37,7 +37,6 @@ // marked as skipped ReturnNeverTypeRector::class => ['*/tests/*'], ]) - // @todo cleanup rest and move to enum classes ass single place for class names ->withConfiguredRule(StringClassNameToClassConstantRector::class, ['Symfony\*', 'Twig_*', 'Twig*']) ->withPhpSets() ->withPreparedSets( @@ -45,6 +44,7 @@ codeQuality: true, codingStyle: true, typeDeclarations: true, + typeDeclarationDocblocks: true, privatization: true, naming: true, rectorPreset: true, diff --git a/rules-tests/CodeQuality/Rector/ClassMethod/ResponseReturnTypeControllerActionRector/Source/CustomObject.php b/rules-tests/CodeQuality/Rector/ClassMethod/ResponseReturnTypeControllerActionRector/Source/CustomObject.php index d11bd783e..65993125c 100644 --- a/rules-tests/CodeQuality/Rector/ClassMethod/ResponseReturnTypeControllerActionRector/Source/CustomObject.php +++ b/rules-tests/CodeQuality/Rector/ClassMethod/ResponseReturnTypeControllerActionRector/Source/CustomObject.php @@ -2,7 +2,7 @@ namespace Rector\Symfony\Tests\CodeQuality\Rector\ClassMethod\ResponseReturnTypeControllerActionRector\Source; -class CustomObject +final class CustomObject { } diff --git a/rules-tests/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector/Source/IntermediateController.php b/rules-tests/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector/Source/IntermediateController.php index 77f6f1ed5..331c1e584 100644 --- a/rules-tests/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector/Source/IntermediateController.php +++ b/rules-tests/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector/Source/IntermediateController.php @@ -8,7 +8,7 @@ use Psr\Log\LoggerInterface; use Symfony\Component\Routing\Annotation\Route; -class IntermediateController extends AbstractController +final class IntermediateController extends AbstractController { #[Route('/some-action', name: 'some_action')] public function someAction(LoggerInterface $logger) diff --git a/rules-tests/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector/Source/SomeType.php b/rules-tests/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector/Source/SomeType.php index 04efd7f0d..f279c6f0e 100644 --- a/rules-tests/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector/Source/SomeType.php +++ b/rules-tests/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector/Source/SomeType.php @@ -5,6 +5,6 @@ namespace Rector\Symfony\Tests\CodeQuality\Rector\Class_\ControllerMethodInjectionToConstructorRector\Source; #[\Attribute] -class SomeType +final class SomeType { } diff --git a/rules-tests/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector/Source/SomeUser.php b/rules-tests/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector/Source/SomeUser.php index 4df024d5a..8fd8eef81 100644 --- a/rules-tests/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector/Source/SomeUser.php +++ b/rules-tests/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector/Source/SomeUser.php @@ -6,6 +6,6 @@ use Symfony\Component\Security\Core\User\UserInterface; -class SomeUser implements UserInterface +final class SomeUser implements UserInterface { } diff --git a/rules-tests/Configs/Rector/Closure/ServiceArgsToServiceNamedArgRector/Source/AnotherClassWithoutConstructor.php b/rules-tests/Configs/Rector/Closure/ServiceArgsToServiceNamedArgRector/Source/AnotherClassWithoutConstructor.php index 985946679..f42f32ba2 100644 --- a/rules-tests/Configs/Rector/Closure/ServiceArgsToServiceNamedArgRector/Source/AnotherClassWithoutConstructor.php +++ b/rules-tests/Configs/Rector/Closure/ServiceArgsToServiceNamedArgRector/Source/AnotherClassWithoutConstructor.php @@ -2,7 +2,7 @@ namespace Rector\Symfony\Tests\Configs\Rector\Closure\ServiceArgsToServiceNamedArgRector\Source; -class AnotherClassWithoutConstructor +final class AnotherClassWithoutConstructor { } diff --git a/rules-tests/Configs/Rector/Closure/ServiceArgsToServiceNamedArgRector/Source/SomeChildClassWithConstructor.php b/rules-tests/Configs/Rector/Closure/ServiceArgsToServiceNamedArgRector/Source/SomeChildClassWithConstructor.php index 2386595da..6bc828dcc 100644 --- a/rules-tests/Configs/Rector/Closure/ServiceArgsToServiceNamedArgRector/Source/SomeChildClassWithConstructor.php +++ b/rules-tests/Configs/Rector/Closure/ServiceArgsToServiceNamedArgRector/Source/SomeChildClassWithConstructor.php @@ -2,6 +2,6 @@ namespace Rector\Symfony\Tests\Configs\Rector\Closure\ServiceArgsToServiceNamedArgRector\Source; -class SomeChildClassWithConstructor extends SomeClassWithConstructor +final class SomeChildClassWithConstructor extends SomeClassWithConstructor { } diff --git a/rules-tests/Configs/Rector/Closure/ServiceArgsToServiceNamedArgRector/Source/SomeClassWithConstructor.php b/rules-tests/Configs/Rector/Closure/ServiceArgsToServiceNamedArgRector/Source/SomeClassWithConstructor.php index 13e6264a3..aa22da987 100644 --- a/rules-tests/Configs/Rector/Closure/ServiceArgsToServiceNamedArgRector/Source/SomeClassWithConstructor.php +++ b/rules-tests/Configs/Rector/Closure/ServiceArgsToServiceNamedArgRector/Source/SomeClassWithConstructor.php @@ -2,7 +2,7 @@ namespace Rector\Symfony\Tests\Configs\Rector\Closure\ServiceArgsToServiceNamedArgRector\Source; -class SomeClassWithConstructor +final class SomeClassWithConstructor { public function __construct($someCtorParameter, $anotherCtorParameter) { diff --git a/rules-tests/Configs/Rector/Closure/ServiceSettersToSettersAutodiscoveryRector/Source/FirstAutowiredClass.php b/rules-tests/Configs/Rector/Closure/ServiceSettersToSettersAutodiscoveryRector/Source/FirstAutowiredClass.php index b86fe039f..23fe2096a 100644 --- a/rules-tests/Configs/Rector/Closure/ServiceSettersToSettersAutodiscoveryRector/Source/FirstAutowiredClass.php +++ b/rules-tests/Configs/Rector/Closure/ServiceSettersToSettersAutodiscoveryRector/Source/FirstAutowiredClass.php @@ -2,7 +2,7 @@ namespace Rector\Symfony\Tests\Configs\Rector\Closure\ServiceSettersToSettersAutodiscoveryRector\Source; -class FirstAutowiredClass +final class FirstAutowiredClass { } diff --git a/rules-tests/Configs/Rector/Closure/ServiceSettersToSettersAutodiscoveryRector/Source/SecondAutowiredClass.php b/rules-tests/Configs/Rector/Closure/ServiceSettersToSettersAutodiscoveryRector/Source/SecondAutowiredClass.php index a702e4ec0..f134ca84b 100644 --- a/rules-tests/Configs/Rector/Closure/ServiceSettersToSettersAutodiscoveryRector/Source/SecondAutowiredClass.php +++ b/rules-tests/Configs/Rector/Closure/ServiceSettersToSettersAutodiscoveryRector/Source/SecondAutowiredClass.php @@ -2,7 +2,7 @@ namespace Rector\Symfony\Tests\Configs\Rector\Closure\ServiceSettersToSettersAutodiscoveryRector\Source; -class SecondAutowiredClass +final class SecondAutowiredClass { } diff --git a/rules-tests/Symfony30/Rector/ClassMethod/RemoveDefaultGetBlockPrefixRector/Source/CustomType.php b/rules-tests/Symfony30/Rector/ClassMethod/RemoveDefaultGetBlockPrefixRector/Source/CustomType.php index dd49a2602..1bd0abba9 100644 --- a/rules-tests/Symfony30/Rector/ClassMethod/RemoveDefaultGetBlockPrefixRector/Source/CustomType.php +++ b/rules-tests/Symfony30/Rector/ClassMethod/RemoveDefaultGetBlockPrefixRector/Source/CustomType.php @@ -5,7 +5,7 @@ use Symfony\Component\Form\AbstractType; -class CustomType extends AbstractType +final class CustomType extends AbstractType { public function getBlockPrefix() { diff --git a/rules-tests/Symfony30/Rector/MethodCall/FormTypeInstanceToClassConstRector/Source/AnotherFormTypeClass.php b/rules-tests/Symfony30/Rector/MethodCall/FormTypeInstanceToClassConstRector/Source/AnotherFormTypeClass.php index 0fb228249..d4793d83b 100644 --- a/rules-tests/Symfony30/Rector/MethodCall/FormTypeInstanceToClassConstRector/Source/AnotherFormTypeClass.php +++ b/rules-tests/Symfony30/Rector/MethodCall/FormTypeInstanceToClassConstRector/Source/AnotherFormTypeClass.php @@ -6,7 +6,7 @@ use Symfony\Component\Form\FormTypeInterface; -class AnotherFormTypeClass implements FormTypeInterface +final class AnotherFormTypeClass implements FormTypeInterface { } diff --git a/rules-tests/Symfony40/Rector/MethodCall/VarDumperTestTraitMethodArgsRector/Source/ClassWithVarDumperTrait.php b/rules-tests/Symfony40/Rector/MethodCall/VarDumperTestTraitMethodArgsRector/Source/ClassWithVarDumperTrait.php index f155b8774..6c4d6b472 100644 --- a/rules-tests/Symfony40/Rector/MethodCall/VarDumperTestTraitMethodArgsRector/Source/ClassWithVarDumperTrait.php +++ b/rules-tests/Symfony40/Rector/MethodCall/VarDumperTestTraitMethodArgsRector/Source/ClassWithVarDumperTrait.php @@ -6,7 +6,7 @@ use Symfony\Component\VarDumper\Test\VarDumperTestTrait; -class ClassWithVarDumperTrait +final class ClassWithVarDumperTrait { use VarDumperTestTrait; diff --git a/rules-tests/Symfony43/Rector/MethodCall/WebTestCaseAssertResponseCodeRector/Source/FixtureWebTestCase.php b/rules-tests/Symfony43/Rector/MethodCall/WebTestCaseAssertResponseCodeRector/Source/FixtureWebTestCase.php index c1dae790d..a139091d6 100644 --- a/rules-tests/Symfony43/Rector/MethodCall/WebTestCaseAssertResponseCodeRector/Source/FixtureWebTestCase.php +++ b/rules-tests/Symfony43/Rector/MethodCall/WebTestCaseAssertResponseCodeRector/Source/FixtureWebTestCase.php @@ -4,7 +4,7 @@ namespace Rector\Symfony\Tests\Symfony43\Rector\MethodCall\WebTestCaseAssertResponseCodeRector\Source; -class FixtureWebTestCase +final class FixtureWebTestCase { } diff --git a/rules-tests/Symfony44/Rector/MethodCall/AuthorizationCheckerIsGrantedExtractorRector/Source/DifferentClass.php b/rules-tests/Symfony44/Rector/MethodCall/AuthorizationCheckerIsGrantedExtractorRector/Source/DifferentClass.php index 092902d9e..56b9ed1e3 100644 --- a/rules-tests/Symfony44/Rector/MethodCall/AuthorizationCheckerIsGrantedExtractorRector/Source/DifferentClass.php +++ b/rules-tests/Symfony44/Rector/MethodCall/AuthorizationCheckerIsGrantedExtractorRector/Source/DifferentClass.php @@ -2,7 +2,7 @@ namespace Rector\Symfony\Tests\Symfony44\Rector\MethodCall\AuthorizationCheckerIsGrantedExtractorRector\Source; -class DifferentClass +final class DifferentClass { public function isGranted($args) { diff --git a/rules-tests/Symfony62/Rector/Class_/MessageHandlerInterfaceToAttributeRector/Source/SmsNotification.php b/rules-tests/Symfony62/Rector/Class_/MessageHandlerInterfaceToAttributeRector/Source/SmsNotification.php index 9d73710f4..1788aec82 100644 --- a/rules-tests/Symfony62/Rector/Class_/MessageHandlerInterfaceToAttributeRector/Source/SmsNotification.php +++ b/rules-tests/Symfony62/Rector/Class_/MessageHandlerInterfaceToAttributeRector/Source/SmsNotification.php @@ -2,6 +2,6 @@ namespace Rector\Symfony\Tests\Symfony62\Rector\Class_\MessageHandlerInterfaceToAttributeRector\Source; -class SmsNotification +final class SmsNotification { } diff --git a/rules/CodeQuality/Enum/ResponseClass.php b/rules/CodeQuality/Enum/ResponseClass.php index 830f80e0c..63f3382a4 100644 --- a/rules/CodeQuality/Enum/ResponseClass.php +++ b/rules/CodeQuality/Enum/ResponseClass.php @@ -6,28 +6,13 @@ final class ResponseClass { - /** - * @var string - */ - public const REDIRECT = 'Symfony\Component\HttpFoundation\RedirectResponse'; + public const string REDIRECT = 'Symfony\Component\HttpFoundation\RedirectResponse'; - /** - * @var string - */ - public const BINARY_FILE = 'Symfony\Component\HttpFoundation\BinaryFileResponse'; + public const string BINARY_FILE = 'Symfony\Component\HttpFoundation\BinaryFileResponse'; - /** - * @var string - */ - public const JSON = 'Symfony\Component\HttpFoundation\JsonResponse'; + public const string JSON = 'Symfony\Component\HttpFoundation\JsonResponse'; - /** - * @var string - */ - public const STREAMED = 'Symfony\Component\HttpFoundation\StreamedResponse'; + public const string STREAMED = 'Symfony\Component\HttpFoundation\StreamedResponse'; - /** - * @var string - */ - public const BASIC = 'Symfony\Component\HttpFoundation\Response'; + public const string BASIC = 'Symfony\Component\HttpFoundation\Response'; } diff --git a/rules/CodeQuality/Rector/ClassMethod/TemplateAnnotationToThisRenderRector.php b/rules/CodeQuality/Rector/ClassMethod/TemplateAnnotationToThisRenderRector.php index 9844874ea..760a32990 100644 --- a/rules/CodeQuality/Rector/ClassMethod/TemplateAnnotationToThisRenderRector.php +++ b/rules/CodeQuality/Rector/ClassMethod/TemplateAnnotationToThisRenderRector.php @@ -28,6 +28,7 @@ use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover; use Rector\Comments\NodeDocBlock\DocBlockUpdater; use Rector\Doctrine\NodeAnalyzer\AttrinationFinder; +use Rector\PhpParser\Enum\NodeGroup; use Rector\PhpParser\Node\BetterNodeFinder; use Rector\Rector\AbstractRector; use Rector\Symfony\Annotation\AnnotationAnalyzer; @@ -198,7 +199,8 @@ private function refactorClassMethod( return NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN; } - if (! property_exists($node, 'stmts')) { + // has stmts + if (! NodeGroup::isStmtAwareNode($node)) { return null; } diff --git a/rules/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector.php b/rules/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector.php index 7949bd4c2..baf9d2a71 100644 --- a/rules/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector.php +++ b/rules/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector.php @@ -37,7 +37,7 @@ final class ControllerMethodInjectionToConstructorRector extends AbstractRector /** * @var string[] */ - private const COMMON_ENTITY_CONTAINS_SUBNAMESPACES = ["\\Entity", "\\Document", "\\Model"]; + private const array COMMON_ENTITY_CONTAINS_SUBNAMESPACES = ["\\Entity", "\\Document", "\\Model"]; public function __construct( private readonly ControllerAnalyzer $controllerAnalyzer, diff --git a/rules/CodeQuality/Rector/Class_/EventListenerToEventSubscriberRector.php b/rules/CodeQuality/Rector/Class_/EventListenerToEventSubscriberRector.php index 8b14c4712..1b957a822 100644 --- a/rules/CodeQuality/Rector/Class_/EventListenerToEventSubscriberRector.php +++ b/rules/CodeQuality/Rector/Class_/EventListenerToEventSubscriberRector.php @@ -28,10 +28,9 @@ final class EventListenerToEventSubscriberRector extends AbstractRector { /** - * @var string * @changelog https://regex101.com/r/qiHZ4T/1 */ - private const LISTENER_MATCH_REGEX = '#^(.*?)(Listener)?$#'; + private const string LISTENER_MATCH_REGEX = '#^(.*?)(Listener)?$#'; /** * @var EventNameToClassAndConstant[] diff --git a/rules/CodeQuality/Rector/Class_/InlineClassRoutePrefixRector.php b/rules/CodeQuality/Rector/Class_/InlineClassRoutePrefixRector.php index d26548184..269ea6735 100644 --- a/rules/CodeQuality/Rector/Class_/InlineClassRoutePrefixRector.php +++ b/rules/CodeQuality/Rector/Class_/InlineClassRoutePrefixRector.php @@ -33,16 +33,13 @@ final class InlineClassRoutePrefixRector extends AbstractRector /** * @var string[] */ - private const FOS_REST_ANNOTATIONS = [ + private const array FOS_REST_ANNOTATIONS = [ FosAnnotation::REST_POST, FosAnnotation::REST_GET, FosAnnotation::REST_ROUTE, ]; - /** - * @var string - */ - private const PATH = 'path'; + private const string PATH = 'path'; public function __construct( private readonly PhpDocInfoFactory $phpDocInfoFactory, diff --git a/rules/CodeQuality/Rector/Class_/SplitAndSecurityAttributeToIsGrantedRector.php b/rules/CodeQuality/Rector/Class_/SplitAndSecurityAttributeToIsGrantedRector.php index ffb81bc00..c702c0228 100644 --- a/rules/CodeQuality/Rector/Class_/SplitAndSecurityAttributeToIsGrantedRector.php +++ b/rules/CodeQuality/Rector/Class_/SplitAndSecurityAttributeToIsGrantedRector.php @@ -19,6 +19,9 @@ use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +/** + * @see \Rector\Symfony\Tests\CodeQuality\Rector\Class_\SplitAndSecurityAttributeToIsGrantedRector\SplitAndSecurityAttributeToIsGrantedRectorTest + */ final class SplitAndSecurityAttributeToIsGrantedRector extends AbstractRector { public function getRuleDefinition(): RuleDefinition diff --git a/rules/Configs/NodeVisitor/CollectServiceArgumentsNodeVisitor.php b/rules/Configs/NodeVisitor/CollectServiceArgumentsNodeVisitor.php index 199d0048f..8d337c67b 100644 --- a/rules/Configs/NodeVisitor/CollectServiceArgumentsNodeVisitor.php +++ b/rules/Configs/NodeVisitor/CollectServiceArgumentsNodeVisitor.php @@ -22,15 +22,9 @@ final class CollectServiceArgumentsNodeVisitor extends NodeVisitorAbstract { - /** - * @var string - */ - private const ENVS = 'envs'; + private const string ENVS = 'envs'; - /** - * @var string - */ - private const PARAMETERS = 'parameters'; + private const string PARAMETERS = 'parameters'; /** * @var array>> diff --git a/rules/Configs/Rector/Class_/AutowireAttributeRector.php b/rules/Configs/Rector/Class_/AutowireAttributeRector.php index 6e8620bb3..9ff8310be 100644 --- a/rules/Configs/Rector/Class_/AutowireAttributeRector.php +++ b/rules/Configs/Rector/Class_/AutowireAttributeRector.php @@ -35,10 +35,7 @@ */ final class AutowireAttributeRector extends AbstractRector implements ConfigurableRectorInterface { - /** - * @var string - */ - public const CONFIGS_DIRECTORY = 'configs_directory'; + public const string CONFIGS_DIRECTORY = 'configs_directory'; private ?string $configsDirectory = null; diff --git a/rules/Configs/Rector/Closure/ServiceTagsToDefaultsAutoconfigureRector.php b/rules/Configs/Rector/Closure/ServiceTagsToDefaultsAutoconfigureRector.php index 27eedd9f3..1e51e59ec 100644 --- a/rules/Configs/Rector/Closure/ServiceTagsToDefaultsAutoconfigureRector.php +++ b/rules/Configs/Rector/Closure/ServiceTagsToDefaultsAutoconfigureRector.php @@ -23,7 +23,7 @@ final class ServiceTagsToDefaultsAutoconfigureRector extends AbstractRector /** * @var string[] */ - private const AUTOCONFIGUREABLE_TAGS = [ + private const array AUTOCONFIGUREABLE_TAGS = [ // @todo fill 'twig.extension', 'console.command', diff --git a/rules/DependencyInjection/Rector/Class_/GetBySymfonyStringToConstructorInjectionRector.php b/rules/DependencyInjection/Rector/Class_/GetBySymfonyStringToConstructorInjectionRector.php index 0a2ced0a4..f7df11327 100644 --- a/rules/DependencyInjection/Rector/Class_/GetBySymfonyStringToConstructorInjectionRector.php +++ b/rules/DependencyInjection/Rector/Class_/GetBySymfonyStringToConstructorInjectionRector.php @@ -27,7 +27,7 @@ final class GetBySymfonyStringToConstructorInjectionRector extends AbstractRecto /** * @var array */ - private const SYMFONY_NAME_TO_TYPE_MAP = [ + private const array SYMFONY_NAME_TO_TYPE_MAP = [ 'validator' => SymfonyClass::VALIDATOR_INTERFACE, 'event_dispatcher' => SymfonyClass::EVENT_DISPATCHER_INTERFACE, 'logger' => SymfonyClass::LOGGER_INTERFACE, diff --git a/rules/SwiftMailer/Rector/ClassMethod/SwiftMessageToEmailRector.php b/rules/SwiftMailer/Rector/ClassMethod/SwiftMessageToEmailRector.php index 3d7d9bb3c..600393a8e 100644 --- a/rules/SwiftMailer/Rector/ClassMethod/SwiftMessageToEmailRector.php +++ b/rules/SwiftMailer/Rector/ClassMethod/SwiftMessageToEmailRector.php @@ -27,15 +27,9 @@ */ final class SwiftMessageToEmailRector extends AbstractRector { - /** - * @var string - */ - private const EMAIL_FQN = 'Symfony\Component\Mime\Email'; + private const string EMAIL_FQN = 'Symfony\Component\Mime\Email'; - /** - * @var string - */ - private const SWIFT_MESSAGE_FQN = 'Swift_Message'; + private const string SWIFT_MESSAGE_FQN = 'Swift_Message'; /** * @var array diff --git a/rules/Symfony27/Rector/MethodCall/ChangeCollectionTypeOptionNameFromTypeToEntryTypeRector.php b/rules/Symfony27/Rector/MethodCall/ChangeCollectionTypeOptionNameFromTypeToEntryTypeRector.php index ac0bbf11e..bd24ec6ce 100644 --- a/rules/Symfony27/Rector/MethodCall/ChangeCollectionTypeOptionNameFromTypeToEntryTypeRector.php +++ b/rules/Symfony27/Rector/MethodCall/ChangeCollectionTypeOptionNameFromTypeToEntryTypeRector.php @@ -28,7 +28,7 @@ final class ChangeCollectionTypeOptionNameFromTypeToEntryTypeRector extends Abst /** * @var array */ - private const OLD_TO_NEW_OPTION_NAME = [ + private const array OLD_TO_NEW_OPTION_NAME = [ 'type' => 'entry_type', 'options' => 'entry_options', ]; diff --git a/rules/Symfony28/Rector/StaticCall/ParseFileRector.php b/rules/Symfony28/Rector/StaticCall/ParseFileRector.php index e8f8e571c..1b4b2a262 100644 --- a/rules/Symfony28/Rector/StaticCall/ParseFileRector.php +++ b/rules/Symfony28/Rector/StaticCall/ParseFileRector.php @@ -24,22 +24,19 @@ final class ParseFileRector extends AbstractRector { /** - * @var string * @changelog https://regex101.com/r/ZaY42i/1 */ - private const YAML_SUFFIX_IN_QUOTE_REGEX = '#\.(yml|yaml)(\'|\")$#'; + private const string YAML_SUFFIX_IN_QUOTE_REGEX = '#\.(yml|yaml)(\'|\")$#'; /** - * @var string * @changelog https://regex101.com/r/YHA05g/1 */ - private const FILE_SUFFIX_REGEX = '#File$#'; + private const string FILE_SUFFIX_REGEX = '#File$#'; /** - * @var string * @changelog https://regex101.com/r/JmNhZj/1 */ - private const YAML_SUFFIX_REGEX = '#\.(yml|yaml)$#'; + private const string YAML_SUFFIX_REGEX = '#\.(yml|yaml)$#'; public function __construct( private readonly BetterStandardPrinter $betterStandardPrinter diff --git a/rules/Symfony30/Rector/ClassMethod/FormTypeGetParentRector.php b/rules/Symfony30/Rector/ClassMethod/FormTypeGetParentRector.php index 2ca140990..41c3fb75c 100644 --- a/rules/Symfony30/Rector/ClassMethod/FormTypeGetParentRector.php +++ b/rules/Symfony30/Rector/ClassMethod/FormTypeGetParentRector.php @@ -12,6 +12,7 @@ use PhpParser\Node\Stmt\Return_; use PHPStan\Type\ObjectType; use Rector\Rector\AbstractRector; +use Rector\Symfony\Enum\SymfonyClass; use Rector\Symfony\FormHelper\FormTypeStringToTypeProvider; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; @@ -119,7 +120,13 @@ public function refactor(Node $node): ?Node return null; } - $this->replaceStringWIthFormTypeClassConstIfFound($node->expr->value, $node, $hasChanged); + $formClass = $this->formTypeStringToTypeProvider->matchClassForNameWithPrefix($node->expr->value); + if ($formClass === null) { + return null; + } + + $node->expr = $this->nodeFactory->createClassConstReference($formClass); + $hasChanged = true; return $node; }); @@ -135,27 +142,13 @@ public function refactor(Node $node): ?Node private function isClassAndMethodMatch(Class_ $class, ClassMethod $classMethod): bool { if ($this->isName($classMethod->name, 'getParent')) { - return $this->isObjectType($class, new ObjectType('Symfony\Component\Form\AbstractType')); + return $this->isObjectType($class, new ObjectType(SymfonyClass::ABSTRACT_TYPE)); } if ($this->isName($classMethod->name, 'getExtendedType')) { - return $this->isObjectType($class, new ObjectType('Symfony\Component\Form\AbstractTypeExtension')); + return $this->isObjectType($class, new ObjectType(SymfonyClass::ABSTRACT_TYPE_EXTENSION)); } return false; } - - private function replaceStringWIthFormTypeClassConstIfFound( - string $stringValue, - Return_ $return, - bool &$hasChanged - ): void { - $formClass = $this->formTypeStringToTypeProvider->matchClassForNameWithPrefix($stringValue); - if ($formClass === null) { - return; - } - - $return->expr = $this->nodeFactory->createClassConstReference($formClass); - $hasChanged = true; - } } diff --git a/rules/Symfony30/Rector/MethodCall/OptionNameRector.php b/rules/Symfony30/Rector/MethodCall/OptionNameRector.php index 5b691890a..3ffadaf7a 100644 --- a/rules/Symfony30/Rector/MethodCall/OptionNameRector.php +++ b/rules/Symfony30/Rector/MethodCall/OptionNameRector.php @@ -23,7 +23,7 @@ final class OptionNameRector extends AbstractRector /** * @var array */ - private const OLD_TO_NEW_OPTION = [ + private const array OLD_TO_NEW_OPTION = [ 'precision' => 'scale', 'virtual' => 'inherit_data', ]; diff --git a/rules/Symfony30/Rector/MethodCall/StringFormTypeToClassRector.php b/rules/Symfony30/Rector/MethodCall/StringFormTypeToClassRector.php index 8f89dc9b5..bc7f0f3fc 100644 --- a/rules/Symfony30/Rector/MethodCall/StringFormTypeToClassRector.php +++ b/rules/Symfony30/Rector/MethodCall/StringFormTypeToClassRector.php @@ -21,10 +21,7 @@ */ final class StringFormTypeToClassRector extends AbstractRector { - /** - * @var string - */ - private const DESCRIPTION = 'Turns string Form Type references to their CONSTANT alternatives in FormTypes in Form in Symfony. To enable custom types, add link to your container XML dump in "$rectorConfig->symfonyContainerXml(...)"'; + private const string DESCRIPTION = 'Turns string Form Type references to their CONSTANT alternatives in FormTypes in Form in Symfony. To enable custom types, add link to your container XML dump in "$rectorConfig->symfonyContainerXml(...)"'; public function __construct( private readonly FormAddMethodCallAnalyzer $formAddMethodCallAnalyzer, diff --git a/rules/Symfony34/Rector/ClassMethod/ReplaceSensioRouteAnnotationWithSymfonyRector.php b/rules/Symfony34/Rector/ClassMethod/ReplaceSensioRouteAnnotationWithSymfonyRector.php index 438ac0c85..4eed82287 100644 --- a/rules/Symfony34/Rector/ClassMethod/ReplaceSensioRouteAnnotationWithSymfonyRector.php +++ b/rules/Symfony34/Rector/ClassMethod/ReplaceSensioRouteAnnotationWithSymfonyRector.php @@ -28,10 +28,7 @@ */ final class ReplaceSensioRouteAnnotationWithSymfonyRector extends AbstractRector { - /** - * @var string - */ - private const SENSIO_ROUTE_NAME = 'Sensio\Bundle\FrameworkExtraBundle\Configuration\Route'; + private const string SENSIO_ROUTE_NAME = 'Sensio\Bundle\FrameworkExtraBundle\Configuration\Route'; public function __construct( private readonly SymfonyRouteTagValueNodeFactory $symfonyRouteTagValueNodeFactory, @@ -137,7 +134,7 @@ public function refactor(Node $node): ?Node } /** - * @param mixed[] $values + * @param ArrayItemNode[] $values */ private function isEmptySensioRoute(array $values): bool { diff --git a/rules/Symfony40/Rector/ConstFetch/ConstraintUrlOptionRector.php b/rules/Symfony40/Rector/ConstFetch/ConstraintUrlOptionRector.php index 31c568ae0..47efd84fc 100644 --- a/rules/Symfony40/Rector/ConstFetch/ConstraintUrlOptionRector.php +++ b/rules/Symfony40/Rector/ConstFetch/ConstraintUrlOptionRector.php @@ -22,10 +22,7 @@ */ final class ConstraintUrlOptionRector extends AbstractRector { - /** - * @var string - */ - private const URL_CONSTRAINT_CLASS = 'Symfony\Component\Validator\Constraints\Url'; + private const string URL_CONSTRAINT_CLASS = 'Symfony\Component\Validator\Constraints\Url'; public function __construct( private readonly ValueResolver $valueResolver diff --git a/rules/Symfony40/Rector/MethodCall/FormIsValidRector.php b/rules/Symfony40/Rector/MethodCall/FormIsValidRector.php index 4e7f2bc05..d676e2b18 100644 --- a/rules/Symfony40/Rector/MethodCall/FormIsValidRector.php +++ b/rules/Symfony40/Rector/MethodCall/FormIsValidRector.php @@ -10,6 +10,7 @@ use PhpParser\Node\Expr\Variable; use PhpParser\Node\Stmt\If_; use PHPStan\Type\ObjectType; +use Rector\PhpParser\NodeTraverser\SimpleNodeTraverser; use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; @@ -27,11 +28,13 @@ public function getRuleDefinition(): RuleDefinition new CodeSample( <<<'CODE_SAMPLE' if ($form->isValid()) { + // ... } CODE_SAMPLE , <<<'CODE_SAMPLE' if ($form->isSubmitted() && $form->isValid()) { + // ... } CODE_SAMPLE ), @@ -63,11 +66,7 @@ public function refactor(Node $node): ?Node // mark child calls with known is submitted if ($this->isName($methodCall->name, 'isSubmitted')) { - $this->traverseNodesWithCallable($node->stmts, static function (Node $node): null { - $node->setAttribute('has_is_submitted', true); - return null; - }); - + SimpleNodeTraverser::decorateWithAttributeValue($node->stmts, 'has_is_submitted', true); return null; } diff --git a/rules/Symfony42/Rector/New_/StringToArrayArgumentProcessRector.php b/rules/Symfony42/Rector/New_/StringToArrayArgumentProcessRector.php index cc1349c6d..e6bd5f3e7 100644 --- a/rules/Symfony42/Rector/New_/StringToArrayArgumentProcessRector.php +++ b/rules/Symfony42/Rector/New_/StringToArrayArgumentProcessRector.php @@ -32,7 +32,12 @@ final class StringToArrayArgumentProcessRector extends AbstractRector /** * @var string[] */ - private const EXCLUDED_PROCESS_METHOD_CALLS = ['setWorkingDirectory', 'addOutput', 'addErrorOutput', 'setInput']; + private const array EXCLUDED_PROCESS_METHOD_CALLS = [ + 'setWorkingDirectory', + 'addOutput', + 'addErrorOutput', + 'setInput', + ]; public function __construct( private readonly NodeTransformer $nodeTransformer diff --git a/rules/Symfony52/Rector/MethodCall/FormBuilderSetDataMapperRector.php b/rules/Symfony52/Rector/MethodCall/FormBuilderSetDataMapperRector.php index 46f653355..7e2c32721 100644 --- a/rules/Symfony52/Rector/MethodCall/FormBuilderSetDataMapperRector.php +++ b/rules/Symfony52/Rector/MethodCall/FormBuilderSetDataMapperRector.php @@ -20,15 +20,9 @@ */ final class FormBuilderSetDataMapperRector extends AbstractRector { - /** - * @var string - */ - private const DATAMAPPER_INTERFACE = 'Symfony\Component\Form\DataMapperInterface'; + private const string DATAMAPPER_INTERFACE = 'Symfony\Component\Form\DataMapperInterface'; - /** - * @var string - */ - private const DATAMAPPER_CLASS = 'Symfony\Component\Form\Extension\Core\DataMapper\DataMapper'; + private const string DATAMAPPER_CLASS = 'Symfony\Component\Form\Extension\Core\DataMapper\DataMapper'; private readonly ObjectType $objectType; diff --git a/rules/Symfony52/Rector/MethodCall/ReflectionExtractorEnableMagicCallExtractorRector.php b/rules/Symfony52/Rector/MethodCall/ReflectionExtractorEnableMagicCallExtractorRector.php index 50a55df8f..3f5dfcded 100644 --- a/rules/Symfony52/Rector/MethodCall/ReflectionExtractorEnableMagicCallExtractorRector.php +++ b/rules/Symfony52/Rector/MethodCall/ReflectionExtractorEnableMagicCallExtractorRector.php @@ -23,20 +23,14 @@ */ final class ReflectionExtractorEnableMagicCallExtractorRector extends AbstractRector { - /** - * @var string - */ - private const OLD_OPTION_NAME = 'enable_magic_call_extraction'; + private const string OLD_OPTION_NAME = 'enable_magic_call_extraction'; - /** - * @var string - */ - private const NEW_OPTION_NAME = 'enable_magic_methods_extraction'; + private const string NEW_OPTION_NAME = 'enable_magic_methods_extraction'; /** * @var string[] */ - private const METHODS_WITH_OPTION = ['getWriteInfo', 'getReadInfo']; + private const array METHODS_WITH_OPTION = ['getWriteInfo', 'getReadInfo']; public function __construct( private readonly ValueResolver $valueResolver diff --git a/rules/Symfony61/Rector/Class_/CommandConfigureToAttributeRector.php b/rules/Symfony61/Rector/Class_/CommandConfigureToAttributeRector.php index d502952dd..916ec9178 100644 --- a/rules/Symfony61/Rector/Class_/CommandConfigureToAttributeRector.php +++ b/rules/Symfony61/Rector/Class_/CommandConfigureToAttributeRector.php @@ -37,7 +37,7 @@ final class CommandConfigureToAttributeRector extends AbstractRector implements /** * @var array */ - private const METHODS_TO_ATTRIBUTE_NAMES = [ + private const array METHODS_TO_ATTRIBUTE_NAMES = [ 'setName' => 'name', 'setDescription' => 'description', 'setAliases' => 'aliases', diff --git a/rules/Symfony62/Rector/Class_/MessageSubscriberInterfaceToAttributeRector.php b/rules/Symfony62/Rector/Class_/MessageSubscriberInterfaceToAttributeRector.php index e241acd2b..484807163 100644 --- a/rules/Symfony62/Rector/Class_/MessageSubscriberInterfaceToAttributeRector.php +++ b/rules/Symfony62/Rector/Class_/MessageSubscriberInterfaceToAttributeRector.php @@ -5,7 +5,6 @@ namespace Rector\Symfony\Symfony62\Rector\Class_; use PhpParser\Node; -use PhpParser\Node\Expr; use PhpParser\Node\Expr\Array_; use PhpParser\Node\Expr\ClassConstFetch; use PhpParser\Node\Expr\Yield_; @@ -131,16 +130,16 @@ public function refactor(Node $node): ?Node continue; } - $getHandledMessagesClassMethod = $classStmt; - - $stmts = (array) $getHandledMessagesClassMethod->stmts; + $stmts = (array) $classStmt->stmts; if ($stmts === []) { return null; } - $this->handleYields($node, $getHandledMessagesClassMethod); + $this->handleYields($node, $classStmt); $this->classManipulator->removeImplements($node, [MessengerHelper::MESSAGE_SUBSCRIBER_INTERFACE]); + + // remove method unset($node->stmts[$key]); return $node; @@ -152,22 +151,20 @@ public function refactor(Node $node): ?Node private function handleYields(Class_ $class, ClassMethod $getHandledMessagesClassMethod): void { foreach ((array) $getHandledMessagesClassMethod->stmts as $stmt) { - if (! $stmt instanceof Expression || ! $stmt->expr instanceof Yield_ - ) { + if (! $stmt instanceof Expression || ! $stmt->expr instanceof Yield_) { continue; } - $method = MethodName::INVOKE; - $arguments = []; - if ($stmt->expr->key instanceof ClassConstFetch) { $array = $stmt->expr->value; if (! $array instanceof Array_) { continue; } - $arguments = $this->parseArguments($array, $method); - $this->addAttribute($class, $method, $arguments); + $arguments = $this->parseArguments($array); + $methodName = $this->resolveMethodName($array); + + $this->addAttribute($class, $methodName, $arguments); continue; } @@ -181,24 +178,33 @@ private function handleYields(Class_ $class, ClassMethod $getHandledMessagesClas $classParts = $value->class->getParts(); $this->newInvokeMethodName = 'handle' . end($classParts); - $this->addAttribute($class, $method, $arguments); + + $this->addAttribute($class, MethodName::INVOKE, []); + } + } + + private function resolveMethodName(Array_ $array): string + { + foreach ($array->items as $arrayItem) { + $key = (string) $this->valueResolver->getValue($arrayItem->key); + $value = $this->valueResolver->getValue($arrayItem->value); + if ($key === 'method') { + return $value; + } } + + return MethodName::INVOKE; } /** * @return array */ - private function parseArguments(Array_ $array, string &$method): array + private function parseArguments(Array_ $array): array { - foreach ($array->items as $item) { - if (! $item->value instanceof Expr) { - continue; - } - - $key = (string) $this->valueResolver->getValue($item->key); - $value = $this->valueResolver->getValue($item->value); + foreach ($array->items as $arrayItem) { + $key = (string) $this->valueResolver->getValue($arrayItem->key); + $value = $this->valueResolver->getValue($arrayItem->value); if ($key === 'method') { - $method = $value; continue; } diff --git a/rules/Symfony62/Rector/Class_/SecurityAttributeToIsGrantedAttributeRector.php b/rules/Symfony62/Rector/Class_/SecurityAttributeToIsGrantedAttributeRector.php index 48c2a5d83..67b8b49ba 100644 --- a/rules/Symfony62/Rector/Class_/SecurityAttributeToIsGrantedAttributeRector.php +++ b/rules/Symfony62/Rector/Class_/SecurityAttributeToIsGrantedAttributeRector.php @@ -33,16 +33,14 @@ final class SecurityAttributeToIsGrantedAttributeRector extends AbstractRector implements MinPhpVersionInterface { /** - * @var string * @see https://regex101.com/r/Si1sDz/1 */ - private const SOLE_IS_GRANTED_REGEX = '#^is_granted\((\"|\')(?[\w]+)(\"|\')\)$#'; + private const string SOLE_IS_GRANTED_REGEX = '#^is_granted\((\"|\')(?[\w]+)(\"|\')\)$#'; /** - * @var string * @see https://regex101.com/r/NYRPrx/1 */ - private const IS_GRANTED_AND_SUBJECT_REGEX = '#^is_granted\((\"|\')(?[\w]+)(\"|\'),\s+(?\w+)\)$#'; + private const string IS_GRANTED_AND_SUBJECT_REGEX = '#^is_granted\((\"|\')(?[\w]+)(\"|\'),\s+(?\w+)\)$#'; public function __construct( private readonly ReflectionProvider $reflectionProvider, diff --git a/rules/Symfony63/Rector/Class_/ParamAndEnvAttributeRector.php b/rules/Symfony63/Rector/Class_/ParamAndEnvAttributeRector.php index 28869b58e..5c0a5fcda 100644 --- a/rules/Symfony63/Rector/Class_/ParamAndEnvAttributeRector.php +++ b/rules/Symfony63/Rector/Class_/ParamAndEnvAttributeRector.php @@ -25,16 +25,14 @@ final class ParamAndEnvAttributeRector extends AbstractRector { /** - * @var string * @see https://regex101.com/r/7vwGbH/1 */ - private const PARAMETER_REGEX = '#%(?[\w\.]+)%$#'; + private const string PARAMETER_REGEX = '#%(?[\w\.]+)%$#'; /** - * @var string * @see https://regex101.com/r/7xpVRP/1 */ - private const ENV_REGEX = '#%env\((?\w+)\)%$#'; + private const string ENV_REGEX = '#%env\((?\w+)\)%$#'; public function getRuleDefinition(): RuleDefinition { diff --git a/rules/Symfony73/GetMethodToAsTwigAttributeTransformer.php b/rules/Symfony73/GetMethodToAsTwigAttributeTransformer.php index a8d98f0be..0e7d68c78 100644 --- a/rules/Symfony73/GetMethodToAsTwigAttributeTransformer.php +++ b/rules/Symfony73/GetMethodToAsTwigAttributeTransformer.php @@ -29,7 +29,7 @@ */ final readonly class GetMethodToAsTwigAttributeTransformer { - private const OPTION_TO_NAMED_ARG = [ + private const array OPTION_TO_NAMED_ARG = [ 'is_safe' => 'isSafe', 'needs_environment' => 'needsEnvironment', 'needs_context' => 'needsContext', diff --git a/rules/Symfony73/NodeTransformer/CommandUnusedInputOutputRemover.php b/rules/Symfony73/NodeTransformer/CommandUnusedInputOutputRemover.php index 844a018f3..70778c155 100644 --- a/rules/Symfony73/NodeTransformer/CommandUnusedInputOutputRemover.php +++ b/rules/Symfony73/NodeTransformer/CommandUnusedInputOutputRemover.php @@ -14,7 +14,7 @@ /** * @var string[] */ - private const VARIABLE_NAMES = ['input', 'output']; + private const array VARIABLE_NAMES = ['input', 'output']; public function __construct( private NodeNameResolver $nodeNameResolver, diff --git a/rules/Symfony73/Rector/Class_/InvokableCommandInputAttributeRector.php b/rules/Symfony73/Rector/Class_/InvokableCommandInputAttributeRector.php index bc3a416cc..b7d5b5bc1 100644 --- a/rules/Symfony73/Rector/Class_/InvokableCommandInputAttributeRector.php +++ b/rules/Symfony73/Rector/Class_/InvokableCommandInputAttributeRector.php @@ -39,7 +39,7 @@ */ final class InvokableCommandInputAttributeRector extends AbstractRector { - private const MIGRATED_CONFIGURE_CALLS = ['addArgument', 'addOption']; + private const array MIGRATED_CONFIGURE_CALLS = ['addArgument', 'addOption']; public function __construct( private readonly AttributeFinder $attributeFinder, diff --git a/rules/Twig134/Rector/Return_/SimpleFunctionAndFilterRector.php b/rules/Twig134/Rector/Return_/SimpleFunctionAndFilterRector.php index ce97ac00a..e80c4663b 100644 --- a/rules/Twig134/Rector/Return_/SimpleFunctionAndFilterRector.php +++ b/rules/Twig134/Rector/Return_/SimpleFunctionAndFilterRector.php @@ -33,7 +33,7 @@ final class SimpleFunctionAndFilterRector extends AbstractRector /** * @var array */ - private const OLD_TO_NEW_CLASSES = [ + private const array OLD_TO_NEW_CLASSES = [ 'Twig_Function_Method' => 'Twig_SimpleFunction', 'Twig_Filter_Method' => 'Twig_SimpleFilter', ]; @@ -129,7 +129,11 @@ public function refactor(Node $node): ?Node } $newObjectType = $this->nodeTypeResolver->getType($node->value); - $this->processArrayItem($node, $newObjectType, $hasChanged); + + $hasArrayItemChanged = $this->processArrayItem($node, $newObjectType); + if ($hasArrayItemChanged) { + $hasChanged = true; + } return $node; }); @@ -158,8 +162,10 @@ private function shouldSkip(ClassMethod $classMethod): bool return ! $this->isNames($classMethod, ['getFunctions', 'getFilters']); } - private function processArrayItem(ArrayItem $arrayItem, Type $newNodeType, bool &$hasChanged): void + private function processArrayItem(ArrayItem $arrayItem, Type $newNodeType): bool { + $hasChanged = false; + foreach (self::OLD_TO_NEW_CLASSES as $oldClass => $newClass) { $oldClassObjectType = new ObjectType($oldClass); if (! $oldClassObjectType->equals($newNodeType)) { @@ -187,6 +193,8 @@ private function processArrayItem(ArrayItem $arrayItem, Type $newNodeType, bool $hasChanged = true; break; } + + return $hasChanged; } /** diff --git a/src/ApplicationMetadata/ListenerServiceDefinitionProvider.php b/src/ApplicationMetadata/ListenerServiceDefinitionProvider.php index 47ea57f47..f1b861eba 100644 --- a/src/ApplicationMetadata/ListenerServiceDefinitionProvider.php +++ b/src/ApplicationMetadata/ListenerServiceDefinitionProvider.php @@ -12,10 +12,9 @@ final class ListenerServiceDefinitionProvider { /** - * @var string * @see https://regex101.com/r/j6SAga/1 */ - private const SYMFONY_FAMILY_REGEX = '#^(Symfony|Sensio|Doctrine)\b#'; + private const string SYMFONY_FAMILY_REGEX = '#^(Symfony|Sensio|Doctrine)\b#'; private bool $areListenerClassesLoaded = false; diff --git a/src/Enum/CommandMethodName.php b/src/Enum/CommandMethodName.php index e276426c3..bc49118b8 100644 --- a/src/Enum/CommandMethodName.php +++ b/src/Enum/CommandMethodName.php @@ -6,11 +6,11 @@ final class CommandMethodName { - public const CONFIGURE = 'configure'; + public const string CONFIGURE = 'configure'; - public const EXECUTE = 'execute'; + public const string EXECUTE = 'execute'; - public const INTERACT = 'interact'; + public const string INTERACT = 'interact'; - public const INITIALIZE = 'initialize'; + public const string INITIALIZE = 'initialize'; } diff --git a/src/Enum/FosAnnotation.php b/src/Enum/FosAnnotation.php index 9679e5870..e3c22ac92 100644 --- a/src/Enum/FosAnnotation.php +++ b/src/Enum/FosAnnotation.php @@ -6,18 +6,9 @@ final class FosAnnotation { - /** - * @var string - */ - public const REST_GET = 'FOS\RestBundle\Controller\Annotations\Get'; + public const string REST_GET = 'FOS\RestBundle\Controller\Annotations\Get'; - /** - * @var string - */ - public const REST_POST = 'FOS\RestBundle\Controller\Annotations\Post'; + public const string REST_POST = 'FOS\RestBundle\Controller\Annotations\Post'; - /** - * @var string - */ - public const REST_ROUTE = 'FOS\RestBundle\Controller\Annotations\Route'; + public const string REST_ROUTE = 'FOS\RestBundle\Controller\Annotations\Route'; } diff --git a/src/Enum/FosClass.php b/src/Enum/FosClass.php index 4e9bffdba..5499b6d4c 100644 --- a/src/Enum/FosClass.php +++ b/src/Enum/FosClass.php @@ -6,8 +6,5 @@ final class FosClass { - /** - * @var string - */ - public const PARAM_FETCHER = 'FOS\RestBundle\Request\ParamFetcher'; + public const string PARAM_FETCHER = 'FOS\RestBundle\Request\ParamFetcher'; } diff --git a/src/Enum/JMSAnnotation.php b/src/Enum/JMSAnnotation.php index 962529549..c549b66f2 100644 --- a/src/Enum/JMSAnnotation.php +++ b/src/Enum/JMSAnnotation.php @@ -6,7 +6,7 @@ final class JMSAnnotation { - public const ACCESS_TYPE = 'JMS\Serializer\Annotation\AccessType'; + public const string ACCESS_TYPE = 'JMS\Serializer\Annotation\AccessType'; - public const ACCESSOR = 'JMS\Serializer\Annotation\Accessor'; + public const string ACCESSOR = 'JMS\Serializer\Annotation\Accessor'; } diff --git a/src/Enum/SensioAttribute.php b/src/Enum/SensioAttribute.php index 033216dde..4edc98fbb 100644 --- a/src/Enum/SensioAttribute.php +++ b/src/Enum/SensioAttribute.php @@ -6,33 +6,15 @@ final class SensioAttribute { - /** - * @var string - */ - public const PARAM_CONVERTER = 'Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter'; - - /** - * @var string - */ - public const ENTITY = 'Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Entity'; - - /** - * @var string - */ - public const METHOD = 'Sensio\Bundle\FrameworkExtraBundle\Configuration\Method'; - - /** - * @var string - */ - public const TEMPLATE = 'Sensio\Bundle\FrameworkExtraBundle\Configuration\Template'; - - /** - * @var string - */ - public const IS_GRANTED = 'Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted'; - - /** - * @var string - */ - public const SECURITY = 'Sensio\Bundle\FrameworkExtraBundle\Configuration\Security'; + public const string PARAM_CONVERTER = 'Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter'; + + public const string ENTITY = 'Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Entity'; + + public const string METHOD = 'Sensio\Bundle\FrameworkExtraBundle\Configuration\Method'; + + public const string TEMPLATE = 'Sensio\Bundle\FrameworkExtraBundle\Configuration\Template'; + + public const string IS_GRANTED = 'Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted'; + + public const string SECURITY = 'Sensio\Bundle\FrameworkExtraBundle\Configuration\Security'; } diff --git a/src/Enum/SymfonyAnnotation.php b/src/Enum/SymfonyAnnotation.php index 2b03f502a..0ebcb09d4 100644 --- a/src/Enum/SymfonyAnnotation.php +++ b/src/Enum/SymfonyAnnotation.php @@ -6,23 +6,11 @@ final class SymfonyAnnotation { - /** - * @var string - */ - public const ROUTE = 'Symfony\Component\Routing\Annotation\Route'; + public const string ROUTE = 'Symfony\Component\Routing\Annotation\Route'; - /** - * @var string - */ - public const TWIG_TEMPLATE = 'Symfony\Bridge\Twig\Attribute\Template'; + public const string TWIG_TEMPLATE = 'Symfony\Bridge\Twig\Attribute\Template'; - /** - * @var string - */ - public const MAP_ENTITY = 'Symfony\Bridge\Doctrine\Attribute\MapEntity'; + public const string MAP_ENTITY = 'Symfony\Bridge\Doctrine\Attribute\MapEntity'; - /** - * @var string - */ - public const TEMPLATE = 'Sensio\Bundle\FrameworkExtraBundle\Configuration\Template'; + public const string TEMPLATE = 'Sensio\Bundle\FrameworkExtraBundle\Configuration\Template'; } diff --git a/src/Enum/SymfonyAttribute.php b/src/Enum/SymfonyAttribute.php index 8471bfb4b..6ee0b0d40 100644 --- a/src/Enum/SymfonyAttribute.php +++ b/src/Enum/SymfonyAttribute.php @@ -6,43 +6,19 @@ final class SymfonyAttribute { - /** - * @var string - */ - public const AUTOWIRE = 'Symfony\Component\DependencyInjection\Attribute\Autowire'; - - /** - * @var string - */ - public const AS_COMMAND = 'Symfony\Component\Console\Attribute\AsCommand'; - - /** - * @var string - */ - public const COMMAND_OPTION = 'Symfony\Component\Console\Attribute\Option'; - - /** - * @var string - */ - public const COMMAND_ARGUMENT = 'Symfony\Component\Console\Attribute\Argument'; - - /** - * @var string - */ - public const AS_EVENT_LISTENER = 'Symfony\Component\EventDispatcher\Attribute\AsEventListener'; - - /** - * @var string - */ - public const ROUTE = 'Symfony\Component\Routing\Attribute\Route'; - - /** - * @var string - */ - public const IS_GRANTED = 'Symfony\Component\Security\Http\Attribute\IsGranted'; - - /** - * @var string - */ - public const REQUIRED = 'Symfony\Contracts\Service\Attribute\Required'; + public const string AUTOWIRE = 'Symfony\Component\DependencyInjection\Attribute\Autowire'; + + public const string AS_COMMAND = 'Symfony\Component\Console\Attribute\AsCommand'; + + public const string COMMAND_OPTION = 'Symfony\Component\Console\Attribute\Option'; + + public const string COMMAND_ARGUMENT = 'Symfony\Component\Console\Attribute\Argument'; + + public const string AS_EVENT_LISTENER = 'Symfony\Component\EventDispatcher\Attribute\AsEventListener'; + + public const string ROUTE = 'Symfony\Component\Routing\Attribute\Route'; + + public const string IS_GRANTED = 'Symfony\Component\Security\Http\Attribute\IsGranted'; + + public const string REQUIRED = 'Symfony\Contracts\Service\Attribute\Required'; } diff --git a/src/Enum/SymfonyClass.php b/src/Enum/SymfonyClass.php index 8b6187f52..4c02cac1b 100644 --- a/src/Enum/SymfonyClass.php +++ b/src/Enum/SymfonyClass.php @@ -6,226 +6,101 @@ final class SymfonyClass { - /** - * @var string - */ - public const CONTROLLER = 'Symfony\Bundle\FrameworkBundle\Controller\Controller'; - - /** - * @var string - */ - public const RESPONSE = 'Symfony\Component\HttpFoundation\Response'; - - /** - * @var string - */ - public const COMMAND = 'Symfony\Component\Console\Command\Command'; - - /** - * @var string - */ - public const CONTAINER_AWARE_COMMAND = 'Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand'; - - /** - * @var string - */ - public const EVENT_DISPATCHER_INTERFACE = 'Symfony\Contracts\EventDispatcher\EventDispatcherInterface'; - - /** - * @var string - */ - public const VALIDATOR_INTERFACE = 'Symfony\Component\Validator\Validator\ValidatorInterface'; - - /** - * @var string - */ - public const LOGGER_INTERFACE = 'Psr\Log\LoggerInterface'; - - /** - * @var string - */ - public const JMS_SERIALIZER_INTERFACE = 'JMS\Serializer\SerializerInterface'; - - /** - * @var string - */ - public const KERNEL_EVENTS_CLASS = 'Symfony\Component\HttpKernel\KernelEvents'; - - /** - * @var string - */ - public const CONSOLE_EVENTS_CLASS = 'Symfony\Component\Console\ConsoleEvents'; - - /** - * @var string - */ - public const EVENT_SUBSCRIBER_INTERFACE = 'Symfony\Component\EventDispatcher\EventSubscriberInterface'; - - /** - * @var string - */ - public const TRANSLATOR_INTERFACE = 'Symfony\Contracts\Translation\TranslatorInterface'; - - /** - * @var string - */ - public const SERVICE_CONFIGURATOR = 'Symfony\Component\DependencyInjection\Loader\Configurator\ServiceConfigurator'; - - /** - * @var string - */ - public const SESSION_INTERFACRE = 'Symfony\Component\HttpFoundation\Session\SessionInterface'; - - /** - * @var string - */ - public const TOKEN_STORAGE_INTERFACE = 'Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'; - - /** - * @var string - */ - public const HTTP_KERNEL_INTERFACE = 'Symfony\Component\HttpKernel\HttpKernelInterface'; - - /** - * @var string - */ - public const HTTP_KERNEL = 'Symfony\Component\HttpKernel\HttpKernel'; - - /** - * @var string - */ - public const REQUEST = 'Symfony\Component\HttpFoundation\Request'; - - /** - * @var string - */ - public const ABSTRACT_CONTROLLER = 'Symfony\Bundle\FrameworkBundle\Controller\AbstractController'; - - /** - * @var string - */ - public const CONTROLLER_TRAIT = 'Symfony\Bundle\FrameworkBundle\Controller\ControllerTrait'; - - /** - * @var string - */ - public const AUTHORIZATION_CHECKER = 'Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'; - - /** - * @var string - */ - public const REQUEST_STACK = 'Symfony\Component\HttpFoundation\RequestStack'; - - /** - * @var string - */ - public const ABSTRACT_BROWSER = 'Symfony\Component\BrowserKit\AbstractBrowser'; - - /** - * @var string - */ - public const HTTP_CLIENT = 'Symfony\Component\HttpKernel\Client'; - - /** - * @var string - */ - public const KERNEL_BROWSER = 'Symfony\Bundle\FrameworkBundle\KernelBrowser'; - - /** - * @var string - */ - public const FORM_BUILDER = 'Symfony\Component\Form\FormBuilderInterface'; - - /** - * @var string - */ - public const CONTAINER_CONFIGURATOR = 'Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator'; - - /** - * @var string - */ - public const PARAMETER_BAG = 'Symfony\Component\HttpFoundation\ParameterBag'; - - /** - * @var string - */ - public const PARAMETER_BAG_INTERFACE = 'Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface'; - - /** - * @var string - */ - public const SYMFONY_STYLE = 'Symfony\Component\Console\Style\SymfonyStyle'; - - /** - * @var string - */ - public const LOGOUT_EVENT = 'Symfony\Component\Security\Http\Event\LogoutEvent'; - - /** - * @var string - */ - public const LOGOUT_HANDLER_INTERFACE = 'Symfony\Component\Security\Http\Logout\LogoutHandlerInterface'; - - /** - * @var string - */ - public const LOGOUT_SUCCESS_HANDLER = 'Symfony\Component\Security\Http\Logout\LogoutSuccessHandlerInterface'; - - /** - * @var string - */ - public const SYMFONY_VALIDATOR_CONSTRAINTS_COLLECTION = 'Symfony\Component\Validator\Constraints\Collection'; - - /** - * @var string - */ - public const VALIDATOR_CONSTRAINT = 'Symfony\Component\Validator\Constraint'; - - /** - * @var string - */ - public const SERVICES_CONFIGURATOR = 'Symfony\Component\DependencyInjection\Loader\Configurator\ServicesConfigurator'; - - /** - * @var string - */ - public const ARGUMENT_RESOLVER_INTERFACE = 'Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface'; - - /** - * @var string - */ - public const VALUE_RESOLVER_INTERFACE = 'Symfony\Component\HttpKernel\Controller\ValueResolverInterface'; - - /** - * @var string - */ - public const VOTER_INTERFACE = 'Symfony\Component\Security\Core\Authorization\Voter\VoterInterface'; - - /** - * @var string - */ - public const VOTER_CLASS = 'Symfony\Component\Security\Core\Authorization\Voter\Voter'; - - /** - * @var string - */ - public const VOTE_CLASS = 'Symfony\Component\Security\Core\Authorization\Voter\Vote'; - - /** - * @var string - */ - public const USER_INTERFACE = 'Symfony\Component\Security\Core\User\UserInterface'; - - /** - * @var string - */ - public const UUID = 'Symfony\Component\Uid\Uuid'; - - public const ROUTE_COLLECTION_BUILDER = 'Symfony\Component\Routing\RouteCollectionBuilder'; - - public const ROUTING_CONFIGURATOR = 'Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator'; - - public const KERNEL = 'Symfony\Component\HttpKernel\Kernel'; - - public const CONTAINER = 'Symfony\Component\DependencyInjection\Container'; + public const string CONTROLLER = 'Symfony\Bundle\FrameworkBundle\Controller\Controller'; + + public const string RESPONSE = 'Symfony\Component\HttpFoundation\Response'; + + public const string COMMAND = 'Symfony\Component\Console\Command\Command'; + + public const string CONTAINER_AWARE_COMMAND = 'Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand'; + + public const string EVENT_DISPATCHER_INTERFACE = 'Symfony\Contracts\EventDispatcher\EventDispatcherInterface'; + + public const string VALIDATOR_INTERFACE = 'Symfony\Component\Validator\Validator\ValidatorInterface'; + + public const string LOGGER_INTERFACE = 'Psr\Log\LoggerInterface'; + + public const string JMS_SERIALIZER_INTERFACE = 'JMS\Serializer\SerializerInterface'; + + public const string KERNEL_EVENTS_CLASS = 'Symfony\Component\HttpKernel\KernelEvents'; + + public const string CONSOLE_EVENTS_CLASS = 'Symfony\Component\Console\ConsoleEvents'; + + public const string EVENT_SUBSCRIBER_INTERFACE = 'Symfony\Component\EventDispatcher\EventSubscriberInterface'; + + public const string TRANSLATOR_INTERFACE = 'Symfony\Contracts\Translation\TranslatorInterface'; + + public const string SERVICE_CONFIGURATOR = 'Symfony\Component\DependencyInjection\Loader\Configurator\ServiceConfigurator'; + + public const string SESSION_INTERFACRE = 'Symfony\Component\HttpFoundation\Session\SessionInterface'; + + public const string TOKEN_STORAGE_INTERFACE = 'Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'; + + public const string HTTP_KERNEL_INTERFACE = 'Symfony\Component\HttpKernel\HttpKernelInterface'; + + public const string HTTP_KERNEL = 'Symfony\Component\HttpKernel\HttpKernel'; + + public const string REQUEST = 'Symfony\Component\HttpFoundation\Request'; + + public const string ABSTRACT_CONTROLLER = 'Symfony\Bundle\FrameworkBundle\Controller\AbstractController'; + + public const string CONTROLLER_TRAIT = 'Symfony\Bundle\FrameworkBundle\Controller\ControllerTrait'; + + public const string AUTHORIZATION_CHECKER = 'Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'; + + public const string REQUEST_STACK = 'Symfony\Component\HttpFoundation\RequestStack'; + + public const string ABSTRACT_BROWSER = 'Symfony\Component\BrowserKit\AbstractBrowser'; + + public const string HTTP_CLIENT = 'Symfony\Component\HttpKernel\Client'; + + public const string KERNEL_BROWSER = 'Symfony\Bundle\FrameworkBundle\KernelBrowser'; + + public const string FORM_BUILDER = 'Symfony\Component\Form\FormBuilderInterface'; + + public const string CONTAINER_CONFIGURATOR = 'Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator'; + + public const string PARAMETER_BAG = 'Symfony\Component\HttpFoundation\ParameterBag'; + + public const string PARAMETER_BAG_INTERFACE = 'Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface'; + + public const string SYMFONY_STYLE = 'Symfony\Component\Console\Style\SymfonyStyle'; + + public const string LOGOUT_EVENT = 'Symfony\Component\Security\Http\Event\LogoutEvent'; + + public const string LOGOUT_HANDLER_INTERFACE = 'Symfony\Component\Security\Http\Logout\LogoutHandlerInterface'; + + public const string LOGOUT_SUCCESS_HANDLER = 'Symfony\Component\Security\Http\Logout\LogoutSuccessHandlerInterface'; + + public const string SYMFONY_VALIDATOR_CONSTRAINTS_COLLECTION = 'Symfony\Component\Validator\Constraints\Collection'; + + public const string VALIDATOR_CONSTRAINT = 'Symfony\Component\Validator\Constraint'; + + public const string SERVICES_CONFIGURATOR = 'Symfony\Component\DependencyInjection\Loader\Configurator\ServicesConfigurator'; + + public const string ARGUMENT_RESOLVER_INTERFACE = 'Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface'; + + public const string VALUE_RESOLVER_INTERFACE = 'Symfony\Component\HttpKernel\Controller\ValueResolverInterface'; + + public const string VOTER_INTERFACE = 'Symfony\Component\Security\Core\Authorization\Voter\VoterInterface'; + + public const string VOTER_CLASS = 'Symfony\Component\Security\Core\Authorization\Voter\Voter'; + + public const string VOTE_CLASS = 'Symfony\Component\Security\Core\Authorization\Voter\Vote'; + + public const string USER_INTERFACE = 'Symfony\Component\Security\Core\User\UserInterface'; + + public const string UUID = 'Symfony\Component\Uid\Uuid'; + + public const string ROUTE_COLLECTION_BUILDER = 'Symfony\Component\Routing\RouteCollectionBuilder'; + + public const string ROUTING_CONFIGURATOR = 'Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator'; + + public const string KERNEL = 'Symfony\Component\HttpKernel\Kernel'; + + public const string CONTAINER = 'Symfony\Component\DependencyInjection\Container'; + + public const string ABSTRACT_TYPE_EXTENSION = 'Symfony\Component\Form\AbstractTypeExtension'; + + public const string ABSTRACT_TYPE = 'Symfony\Component\Form\AbstractType'; } diff --git a/src/Enum/SymfonyFunctionName.php b/src/Enum/SymfonyFunctionName.php index 92778dca9..c3ce3e0da 100644 --- a/src/Enum/SymfonyFunctionName.php +++ b/src/Enum/SymfonyFunctionName.php @@ -6,13 +6,7 @@ final class SymfonyFunctionName { - /** - * @var string - */ - public const REF = 'Symfony\Component\DependencyInjection\Loader\Configurator\ref'; + public const string REF = 'Symfony\Component\DependencyInjection\Loader\Configurator\ref'; - /** - * @var string - */ - public const SERVICE = 'Symfony\Component\DependencyInjection\Loader\Configurator\service'; + public const string SERVICE = 'Symfony\Component\DependencyInjection\Loader\Configurator\service'; } diff --git a/src/Enum/TwigClass.php b/src/Enum/TwigClass.php index 778a551b9..76fb5d3f6 100644 --- a/src/Enum/TwigClass.php +++ b/src/Enum/TwigClass.php @@ -6,23 +6,11 @@ final class TwigClass { - /** - * @var string - */ - public const TWIG_EXTENSION = 'Twig\Extension\AbstractExtension'; + public const string TWIG_EXTENSION = 'Twig\Extension\AbstractExtension'; - /** - * @var string - */ - public const AS_TWIG_FILTER_ATTRIBUTE = 'Twig\Attribute\AsTwigFilter'; + public const string AS_TWIG_FILTER_ATTRIBUTE = 'Twig\Attribute\AsTwigFilter'; - /** - * @var string - */ - public const AS_TWIG_FUNCTION_ATTRIBUTE = 'Twig\Attribute\AsTwigFunction'; + public const string AS_TWIG_FUNCTION_ATTRIBUTE = 'Twig\Attribute\AsTwigFunction'; - /** - * @var string - */ - public const EXTENSION_INTERFACE = 'Twig\Extension\ExtensionInterface'; + public const string EXTENSION_INTERFACE = 'Twig\Extension\ExtensionInterface'; } diff --git a/src/FormHelper/FormTypeStringToTypeProvider.php b/src/FormHelper/FormTypeStringToTypeProvider.php index 64e074b9f..228ea30d4 100644 --- a/src/FormHelper/FormTypeStringToTypeProvider.php +++ b/src/FormHelper/FormTypeStringToTypeProvider.php @@ -13,7 +13,7 @@ final class FormTypeStringToTypeProvider /** * @var array */ - private const SYMFONY_CORE_NAME_TO_TYPE_MAP = [ + private const array SYMFONY_CORE_NAME_TO_TYPE_MAP = [ 'form' => 'Symfony\Component\Form\Extension\Core\Type\FormType', 'birthday' => 'Symfony\Component\Form\Extension\Core\Type\BirthdayType', 'checkbox' => 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', diff --git a/src/Helper/MessengerHelper.php b/src/Helper/MessengerHelper.php index c54eb126b..58245196b 100644 --- a/src/Helper/MessengerHelper.php +++ b/src/Helper/MessengerHelper.php @@ -16,11 +16,11 @@ final class MessengerHelper { - public const MESSAGE_HANDLER_INTERFACE = 'Symfony\Component\Messenger\Handler\MessageHandlerInterface'; + public const string MESSAGE_HANDLER_INTERFACE = 'Symfony\Component\Messenger\Handler\MessageHandlerInterface'; - public const MESSAGE_SUBSCRIBER_INTERFACE = 'Symfony\Component\Messenger\Handler\MessageSubscriberInterface'; + public const string MESSAGE_SUBSCRIBER_INTERFACE = 'Symfony\Component\Messenger\Handler\MessageSubscriberInterface'; - public const AS_MESSAGE_HANDLER_ATTRIBUTE = 'Symfony\Component\Messenger\Attribute\AsMessageHandler'; + public const string AS_MESSAGE_HANDLER_ATTRIBUTE = 'Symfony\Component\Messenger\Attribute\AsMessageHandler'; private string $messengerTagName = 'messenger.message_handler'; diff --git a/src/Helper/TemplateGuesser.php b/src/Helper/TemplateGuesser.php index a7cdbe02b..e8e48fda3 100644 --- a/src/Helper/TemplateGuesser.php +++ b/src/Helper/TemplateGuesser.php @@ -19,34 +19,29 @@ final readonly class TemplateGuesser { /** - * @var string * @see https://regex101.com/r/yZAUAC/1 */ - private const BUNDLE_SUFFIX_REGEX = '#Bundle$#'; + private const string BUNDLE_SUFFIX_REGEX = '#Bundle$#'; /** - * @var string * @see https://regex101.com/r/T6ItFG/1 */ - private const BUNDLE_NAME_MATCHING_REGEX = '#(?[\w]*Bundle)#'; + private const string BUNDLE_NAME_MATCHING_REGEX = '#(?[\w]*Bundle)#'; /** - * @var string * @see https://regex101.com/r/5dNkCC/2 */ - private const SMALL_LETTER_BIG_LETTER_REGEX = '#([a-z\d])([A-Z])#'; + private const string SMALL_LETTER_BIG_LETTER_REGEX = '#([a-z\d])([A-Z])#'; /** - * @var string * @see https://regex101.com/r/YUrmAD/1 */ - private const CONTROLLER_NAME_MATCH_REGEX = '#Controller\\\(?.+)Controller$#'; + private const string CONTROLLER_NAME_MATCH_REGEX = '#Controller\\\(?.+)Controller$#'; /** - * @var string * @see https://regex101.com/r/nj8Ojf/1 */ - private const ACTION_MATCH_REGEX = '#Action$#'; + private const string ACTION_MATCH_REGEX = '#Action$#'; public function __construct( private BundleClassResolver $bundleClassResolver, diff --git a/src/NodeFactory/GetSubscribedEventsClassMethodFactory.php b/src/NodeFactory/GetSubscribedEventsClassMethodFactory.php index a17cae786..f411eaa58 100644 --- a/src/NodeFactory/GetSubscribedEventsClassMethodFactory.php +++ b/src/NodeFactory/GetSubscribedEventsClassMethodFactory.php @@ -32,10 +32,7 @@ final readonly class GetSubscribedEventsClassMethodFactory { - /** - * @var string - */ - private const GET_SUBSCRIBED_EVENTS_METHOD_NAME = 'getSubscribedEvents'; + private const string GET_SUBSCRIBED_EVENTS_METHOD_NAME = 'getSubscribedEvents'; public function __construct( private NodeFactory $nodeFactory, diff --git a/src/NodeFactory/OnLogoutClassMethodFactory.php b/src/NodeFactory/OnLogoutClassMethodFactory.php index ad7eaf094..f5fdfbb84 100644 --- a/src/NodeFactory/OnLogoutClassMethodFactory.php +++ b/src/NodeFactory/OnLogoutClassMethodFactory.php @@ -19,7 +19,7 @@ /** * @var array */ - private const PARAMETER_TO_GETTER_NAMES = [ + private const array PARAMETER_TO_GETTER_NAMES = [ 'request' => 'getRequest', 'response' => 'getResponse', 'token' => 'getToken', diff --git a/src/NodeFactory/OnSuccessLogoutClassMethodFactory.php b/src/NodeFactory/OnSuccessLogoutClassMethodFactory.php index 062a3d9ae..873252408 100644 --- a/src/NodeFactory/OnSuccessLogoutClassMethodFactory.php +++ b/src/NodeFactory/OnSuccessLogoutClassMethodFactory.php @@ -21,10 +21,7 @@ final readonly class OnSuccessLogoutClassMethodFactory { - /** - * @var string - */ - private const LOGOUT_EVENT = 'logoutEvent'; + private const string LOGOUT_EVENT = 'logoutEvent'; public function __construct( private NodeFactory $nodeFactory, diff --git a/src/Set/SwiftMailerSetList.php b/src/Set/SwiftMailerSetList.php index db9f6294b..14eb85f24 100644 --- a/src/Set/SwiftMailerSetList.php +++ b/src/Set/SwiftMailerSetList.php @@ -9,8 +9,5 @@ */ final class SwiftMailerSetList { - /** - * @var string - */ - public const SWIFT_TO_SYMFONY = __DIR__ . '/../../config/sets/swiftmailer/swiftmailer-to-symfony-mailer.php'; + public const string SWIFT_TO_SYMFONY = __DIR__ . '/../../config/sets/swiftmailer/swiftmailer-to-symfony-mailer.php'; } diff --git a/src/Set/SymfonyInternalSetList.php b/src/Set/SymfonyInternalSetList.php index 2eb9287a0..c64b3d5c1 100644 --- a/src/Set/SymfonyInternalSetList.php +++ b/src/Set/SymfonyInternalSetList.php @@ -10,18 +10,9 @@ */ final class SymfonyInternalSetList { - /** - * @var string - */ - public const JMS_ANNOTATIONS_TO_ATTRIBUTES = __DIR__ . '/../../config/sets/jms/annotations-to-attributes.php'; + public const string JMS_ANNOTATIONS_TO_ATTRIBUTES = __DIR__ . '/../../config/sets/jms/annotations-to-attributes.php'; - /** - * @var string - */ - public const FOS_REST_ANNOTATIONS_TO_ATTRIBUTES = __DIR__ . '/../../config/sets/fosrest/annotations-to-attributes.php'; + public const string FOS_REST_ANNOTATIONS_TO_ATTRIBUTES = __DIR__ . '/../../config/sets/fosrest/annotations-to-attributes.php'; - /** - * @var string - */ - public const SENSIOLABS_ANNOTATIONS_TO_ATTRIBUTES = __DIR__ . '/../../config/sets/sensiolabs/annotations-to-attributes.php'; + public const string SENSIOLABS_ANNOTATIONS_TO_ATTRIBUTES = __DIR__ . '/../../config/sets/sensiolabs/annotations-to-attributes.php'; } diff --git a/src/Set/SymfonySetList.php b/src/Set/SymfonySetList.php index ee38b74d1..5f0ceda3a 100644 --- a/src/Set/SymfonySetList.php +++ b/src/Set/SymfonySetList.php @@ -9,216 +9,174 @@ */ final class SymfonySetList { - /** - * @var string - */ - public const CONFIGS = __DIR__ . '/../../config/sets/symfony/configs.php'; + public const string CONFIGS = __DIR__ . '/../../config/sets/symfony/configs.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_25 = __DIR__ . '/../../config/sets/symfony/symfony25.php'; + public const string SYMFONY_25 = __DIR__ . '/../../config/sets/symfony/symfony25.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_26 = __DIR__ . '/../../config/sets/symfony/symfony26.php'; + public const string SYMFONY_26 = __DIR__ . '/../../config/sets/symfony/symfony26.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_27 = __DIR__ . '/../../config/sets/symfony/symfony27.php'; + public const string SYMFONY_27 = __DIR__ . '/../../config/sets/symfony/symfony27.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_28 = __DIR__ . '/../../config/sets/symfony/symfony28.php'; + public const string SYMFONY_28 = __DIR__ . '/../../config/sets/symfony/symfony28.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_30 = __DIR__ . '/../../config/sets/symfony/symfony3/symfony30.php'; + public const string SYMFONY_30 = __DIR__ . '/../../config/sets/symfony/symfony3/symfony30.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_31 = __DIR__ . '/../../config/sets/symfony/symfony3/symfony31.php'; + public const string SYMFONY_31 = __DIR__ . '/../../config/sets/symfony/symfony3/symfony31.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_32 = __DIR__ . '/../../config/sets/symfony/symfony3/symfony32.php'; + public const string SYMFONY_32 = __DIR__ . '/../../config/sets/symfony/symfony3/symfony32.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_33 = __DIR__ . '/../../config/sets/symfony/symfony3/symfony33.php'; + public const string SYMFONY_33 = __DIR__ . '/../../config/sets/symfony/symfony3/symfony33.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_34 = __DIR__ . '/../../config/sets/symfony/symfony3/symfony34.php'; + public const string SYMFONY_34 = __DIR__ . '/../../config/sets/symfony/symfony3/symfony34.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_40 = __DIR__ . '/../../config/sets/symfony/symfony4/symfony40.php'; + public const string SYMFONY_40 = __DIR__ . '/../../config/sets/symfony/symfony4/symfony40.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_41 = __DIR__ . '/../../config/sets/symfony/symfony4/symfony41.php'; + public const string SYMFONY_41 = __DIR__ . '/../../config/sets/symfony/symfony4/symfony41.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_42 = __DIR__ . '/../../config/sets/symfony/symfony4/symfony42.php'; + public const string SYMFONY_42 = __DIR__ . '/../../config/sets/symfony/symfony4/symfony42.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_43 = __DIR__ . '/../../config/sets/symfony/symfony4/symfony43.php'; + public const string SYMFONY_43 = __DIR__ . '/../../config/sets/symfony/symfony4/symfony43.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_44 = __DIR__ . '/../../config/sets/symfony/symfony4/symfony44.php'; + public const string SYMFONY_44 = __DIR__ . '/../../config/sets/symfony/symfony4/symfony44.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_50 = __DIR__ . '/../../config/sets/symfony/symfony5/symfony50.php'; + public const string SYMFONY_50 = __DIR__ . '/../../config/sets/symfony/symfony5/symfony50.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_50_TYPES = __DIR__ . '/../../config/sets/symfony/symfony5/symfony50/symfony50-types.php'; + public const string SYMFONY_50_TYPES = __DIR__ . '/../../config/sets/symfony/symfony5/symfony50/symfony50-types.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_51 = __DIR__ . '/../../config/sets/symfony/symfony5/symfony51.php'; + public const string SYMFONY_51 = __DIR__ . '/../../config/sets/symfony/symfony5/symfony51.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_52 = __DIR__ . '/../../config/sets/symfony/symfony5/symfony52.php'; + public const string SYMFONY_52 = __DIR__ . '/../../config/sets/symfony/symfony5/symfony52.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_53 = __DIR__ . '/../../config/sets/symfony/symfony5/symfony53.php'; + public const string SYMFONY_53 = __DIR__ . '/../../config/sets/symfony/symfony5/symfony53.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_54 = __DIR__ . '/../../config/sets/symfony/symfony5/symfony54.php'; + public const string SYMFONY_54 = __DIR__ . '/../../config/sets/symfony/symfony5/symfony54.php'; /** * @deprecated Use ->withAttributesSets(symfony: true) in rector.php config instead - * @var string */ - public const SYMFONY_52_VALIDATOR_ATTRIBUTES = __DIR__ . '/../../config/sets/symfony/symfony5/symfony52-validator-attributes.php'; + public const string SYMFONY_52_VALIDATOR_ATTRIBUTES = __DIR__ . '/../../config/sets/symfony/symfony5/symfony52-validator-attributes.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_60 = __DIR__ . '/../../config/sets/symfony/symfony6/symfony60.php'; + public const string SYMFONY_60 = __DIR__ . '/../../config/sets/symfony/symfony6/symfony60.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_61 = __DIR__ . '/../../config/sets/symfony/symfony6/symfony61.php'; + public const string SYMFONY_61 = __DIR__ . '/../../config/sets/symfony/symfony6/symfony61.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_62 = __DIR__ . '/../../config/sets/symfony/symfony6/symfony62.php'; + public const string SYMFONY_62 = __DIR__ . '/../../config/sets/symfony/symfony6/symfony62.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_63 = __DIR__ . '/../../config/sets/symfony/symfony6/symfony63.php'; + public const string SYMFONY_63 = __DIR__ . '/../../config/sets/symfony/symfony6/symfony63.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_64 = __DIR__ . '/../../config/sets/symfony/symfony6/symfony64.php'; + public const string SYMFONY_64 = __DIR__ . '/../../config/sets/symfony/symfony6/symfony64.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_70 = __DIR__ . '/../../config/sets/symfony/symfony7/symfony70.php'; + public const string SYMFONY_70 = __DIR__ . '/../../config/sets/symfony/symfony7/symfony70.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_71 = __DIR__ . '/../../config/sets/symfony/symfony7/symfony71.php'; + public const string SYMFONY_71 = __DIR__ . '/../../config/sets/symfony/symfony7/symfony71.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_72 = __DIR__ . '/../../config/sets/symfony/symfony7/symfony72.php'; + public const string SYMFONY_72 = __DIR__ . '/../../config/sets/symfony/symfony7/symfony72.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_73 = __DIR__ . '/../../config/sets/symfony/symfony7/symfony73.php'; + public const string SYMFONY_73 = __DIR__ . '/../../config/sets/symfony/symfony7/symfony73.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_74 = __DIR__ . '/../../config/sets/symfony/symfony7/symfony74.php'; + public const string SYMFONY_74 = __DIR__ . '/../../config/sets/symfony/symfony7/symfony74.php'; /** * @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead - * @var string */ - public const SYMFONY_80 = __DIR__ . '/../../config/sets/symfony/symfony8/symfony80.php'; + public const string SYMFONY_80 = __DIR__ . '/../../config/sets/symfony/symfony8/symfony80.php'; - /** - * @var string - */ - public const SYMFONY_CODE_QUALITY = __DIR__ . '/../../config/sets/symfony/symfony-code-quality.php'; + public const string SYMFONY_CODE_QUALITY = __DIR__ . '/../../config/sets/symfony/symfony-code-quality.php'; - /** - * @var string - */ - public const SYMFONY_CONSTRUCTOR_INJECTION = __DIR__ . '/../../config/sets/symfony/symfony-constructor-injection.php'; + public const string SYMFONY_CONSTRUCTOR_INJECTION = __DIR__ . '/../../config/sets/symfony/symfony-constructor-injection.php'; /** * @deprecated Use ->withAttributesSets(symfony: true) in rector.php config instead - * @var string */ - public const ANNOTATIONS_TO_ATTRIBUTES = __DIR__ . '/../../config/sets/symfony/annotations-to-attributes.php'; + public const string ANNOTATIONS_TO_ATTRIBUTES = __DIR__ . '/../../config/sets/symfony/annotations-to-attributes.php'; } diff --git a/src/Set/TwigSetList.php b/src/Set/TwigSetList.php index 7e646fb48..5e6844216 100644 --- a/src/Set/TwigSetList.php +++ b/src/Set/TwigSetList.php @@ -9,38 +9,17 @@ */ final class TwigSetList { - /** - * @var string - */ - public const TWIG_112 = __DIR__ . '/../../config/sets/twig/twig112.php'; - - /** - * @var string - */ - public const TWIG_127 = __DIR__ . '/../../config/sets/twig/twig127.php'; - - /** - * @var string - */ - public const TWIG_134 = __DIR__ . '/../../config/sets/twig/twig134.php'; - - /** - * @var string - */ - public const TWIG_140 = __DIR__ . '/../../config/sets/twig/twig140.php'; - - /** - * @var string - */ - public const TWIG_20 = __DIR__ . '/../../config/sets/twig/twig20.php'; - - /** - * @var string - */ - public const TWIG_24 = __DIR__ . '/../../config/sets/twig/twig24.php'; - - /** - * @var string - */ - public const TWIG_UNDERSCORE_TO_NAMESPACE = __DIR__ . '/../../config/sets/twig/twig-underscore-to-namespace.php'; + public const string TWIG_112 = __DIR__ . '/../../config/sets/twig/twig112.php'; + + public const string TWIG_127 = __DIR__ . '/../../config/sets/twig/twig127.php'; + + public const string TWIG_134 = __DIR__ . '/../../config/sets/twig/twig134.php'; + + public const string TWIG_140 = __DIR__ . '/../../config/sets/twig/twig140.php'; + + public const string TWIG_20 = __DIR__ . '/../../config/sets/twig/twig20.php'; + + public const string TWIG_24 = __DIR__ . '/../../config/sets/twig/twig24.php'; + + public const string TWIG_UNDERSCORE_TO_NAMESPACE = __DIR__ . '/../../config/sets/twig/twig-underscore-to-namespace.php'; } diff --git a/src/ValueObject/ConstantMap/SymfonyCommandConstantMap.php b/src/ValueObject/ConstantMap/SymfonyCommandConstantMap.php index 85469aa57..cf50af107 100644 --- a/src/ValueObject/ConstantMap/SymfonyCommandConstantMap.php +++ b/src/ValueObject/ConstantMap/SymfonyCommandConstantMap.php @@ -11,7 +11,7 @@ final class SymfonyCommandConstantMap * * @var array */ - public const RETURN_TO_CONST = [ + public const array RETURN_TO_CONST = [ 0 => 'SUCCESS', 1 => 'FAILURE', 2 => 'INVALID', diff --git a/src/ValueObject/ConstantMap/SymfonyRequestConstantMap.php b/src/ValueObject/ConstantMap/SymfonyRequestConstantMap.php index 204502d4a..ffc44ca4b 100644 --- a/src/ValueObject/ConstantMap/SymfonyRequestConstantMap.php +++ b/src/ValueObject/ConstantMap/SymfonyRequestConstantMap.php @@ -11,7 +11,7 @@ final class SymfonyRequestConstantMap * * @var array */ - public const METHOD_TO_CONST = [ + public const array METHOD_TO_CONST = [ 'GET' => 'METHOD_GET', 'POST' => 'METHOD_POST', 'HEAD' => 'METHOD_HEAD', diff --git a/src/ValueObject/ConstantMap/SymfonyResponseConstantMap.php b/src/ValueObject/ConstantMap/SymfonyResponseConstantMap.php index b0378093e..6cb12cd4f 100644 --- a/src/ValueObject/ConstantMap/SymfonyResponseConstantMap.php +++ b/src/ValueObject/ConstantMap/SymfonyResponseConstantMap.php @@ -11,7 +11,7 @@ final class SymfonyResponseConstantMap * * @var array */ - public const CODE_TO_CONST = [ + public const array CODE_TO_CONST = [ 100 => 'HTTP_CONTINUE', 101 => 'HTTP_SWITCHING_PROTOCOLS', 102 => 'HTTP_PROCESSING', diff --git a/src/ValueObjectFactory/ServiceMapFactory.php b/src/ValueObjectFactory/ServiceMapFactory.php index 18db8d735..a51eb6d60 100644 --- a/src/ValueObjectFactory/ServiceMapFactory.php +++ b/src/ValueObjectFactory/ServiceMapFactory.php @@ -16,10 +16,7 @@ final class ServiceMapFactory { - /** - * @var string - */ - private const TAG = 'tag'; + private const string TAG = 'tag'; public function createFromFileContent(string $configFilePath): ServiceMap { @@ -70,7 +67,7 @@ public function createEmpty(): ServiceMap } /** - * @param mixed[] $def + * @param array $def * @return mixed[] */ private function createTagFromXmlElement(array $def): array diff --git a/tests/Bridge/Symfony/Fixture/Service1.php b/tests/Bridge/Symfony/Fixture/Service1.php index 25e6adc1f..94a624835 100644 --- a/tests/Bridge/Symfony/Fixture/Service1.php +++ b/tests/Bridge/Symfony/Fixture/Service1.php @@ -4,7 +4,7 @@ namespace Rector\Symfony\Tests\Bridge\Symfony\Fixture; -class Service1 +final class Service1 { } diff --git a/tests/Bridge/Symfony/Fixture/Service2.php b/tests/Bridge/Symfony/Fixture/Service2.php index c96fea2a8..482c4146d 100644 --- a/tests/Bridge/Symfony/Fixture/Service2.php +++ b/tests/Bridge/Symfony/Fixture/Service2.php @@ -4,7 +4,7 @@ namespace Rector\Symfony\Tests\Bridge\Symfony\Fixture; -class Service2 +final class Service2 { }