Compare commits

...

355 Commits
0.19.7 ... main

Author SHA1 Message Date
Tomas Votruba 4cadabfe9a Updated Rector to commit 1fd156bddbfece24ad48f83e2a65fb44ccb5392d
1fd156bddb Convert DateTimeImmutable to CarbonImmutable (#5895)
2024-05-19 02:09:52 +00:00
Tomas Votruba 3f56884569 Updated Rector to commit b2ec1f0b413e16760c41707b74c936f7445e13ab
b2ec1f0b41 [Carbon] Skip first class callable on DateTimeMethodCallToCarbonRector (#5893)
2024-05-18 14:48:45 +00:00
Tomas Votruba 22d3d1949d Updated Rector to commit 6ebfa15e733ac340249418057ed3f7615e717ac1
6ebfa15e73 Bump to react/promise 3.1 (#5892)
2024-05-18 13:49:01 +00:00
Tomas Votruba 62a900a1c0 Updated Rector to commit 56d55d0d1e7c064f0859c54d5afc05b5d15d6e9a
56d55d0d1e cs
2024-05-18 13:31:16 +00:00
Tomas Votruba b98d0a8754 Updated Rector to commit 575921d2bca4a0ef36d55c6fa4ebf1ea01bacc4d
575921d2bc [Carbon] Init set to migrate DateTime to Carbon (#5868)
2024-05-18 13:30:48 +00:00
Tomas Votruba 7ac6f7bf7e Updated Rector to commit 5df95d9a955523a1737442a26f4a412cafc41226
5df95d9a95 Update unit test config to avoid using TypeCombinator::addNull() (#5891)
2024-05-18 12:49:12 +00:00
Tomas Votruba 556509e2dc Rector 1.1.0 2024-05-18 09:40:27 +00:00
Tomas Votruba dfaafdbd3a Updated Rector to commit 8e4e8823f227290fb6b014c79b48ce211c2376b5
8e4e8823f2 Bump to PHPStan 1.11 (#5883)
2024-05-18 08:00:27 +00:00
Tomas Votruba dd1dd510f5 Updated Rector to commit 4f301f2335b0fef2934ddaf53471ebd961de1f71
4f301f2335 [Configuration] Add missing LevelSetList::UP_TO_PHP_84 on PhpLevelSetResolver::resolveFromPhpVersion() (#5890)
2024-05-18 07:39:08 +00:00
Tomas Votruba c6998bfca9 Updated Rector to commit 19863767c63503e19aed359d849fa55bbf3a1df9
19863767c6 [TypeDeclaration] Skip unitialized property on EmptyOnNullableObjectToInstanceOfRector (#5889)
2024-05-17 02:56:57 +00:00
Tomas Votruba 264e16fdae Updated Rector to commit 2deccac9b501bc1aa09ba7e8bfe6271b73e5b8dc
2deccac9b5 [PHPStan] Fix missingType.generics notice on phpstan.neon on PHPStan 1.11 (#5888)
2024-05-16 14:47:37 +00:00
Tomas Votruba 1931c635c0 Updated Rector to commit b938e0797f8c3e30f527d1dabad384e4623140de
b938e0797f [TypeDeclaration] Add test for nullable object usage on AddReturnTypeDeclarationRector (#5887)
2024-05-16 14:03:35 +00:00
Tomas Votruba df8a377557 Updated Rector to commit 16d1df9be8cdbdf6e5b67f97fa225731ac0c9675
16d1df9be8 [NodeTypeResolver] No need to resolve class name on anonymous classes (#5886)
2024-05-16 13:22:30 +00:00
Tomas Votruba 6372b90b19 Updated Rector to commit db213ee986c942d58e397b3713564349541e8de5
db213ee986 [PHPStan] Handle PHPStan internal ShouldNotHappenException on FamilyRelationsAnalyzer and PHPStanNodeScopeResolver (#5885)
2024-05-16 12:51:40 +00:00
Tomas Votruba 6cf705918e Updated Rector to commit 6a5f6c53f3637b23b4488cab81ec90a0d1bef053
6a5f6c53f3 [TypeDeclaration] Handle crash on interface Mixin on ReturnTypeFromStrictConstantReturnRector (#5884)
2024-05-16 11:45:24 +00:00
Tomas Votruba 3c1e41f006 Updated Rector to commit 6bd2b871c4e9741928fb48df3ca8e899be42be81
6bd2b871c4 [NodeTypeResolver] No need json_decode/json_encode for cache class name collection (#5881)
2024-05-15 02:19:05 +00:00
Tomas Votruba 7d70c5853e Updated Rector to commit 3cf5b1a2b89979dc375701d88608bc03d6a4a7dd
3cf5b1a2b8 [NodeTypeResolver] Clean up resolve cache class name key (#5880)
2024-05-15 02:04:07 +00:00
Tomas Votruba 049336a81a Updated Rector to commit 8ab5e979db19845b9dd3c39bec566830870845dc
8ab5e979db [Performance] Call cached class names collection on FamilyRelationsAnalyzer (#5879)
2024-05-15 01:48:39 +00:00
Tomas Votruba efe89cff77 Updated Rector to commit 50407e2f2d1c2eb7f67c1f59e8db777e6f0bd081
50407e2f2d [Performance] Ensure call $reflector->reflectAllClasses() once on Worker take 3 (#5878)
2024-05-14 19:26:23 +00:00
Tomas Votruba 89f91b63be Updated Rector to commit a5bf80cb2fdd49d64777cf13250e7205ddd0a3be
a5bf80cb2f [TypeDeclaration] Skip possible array on StrictStringParamConcatRector (#5876)
2024-05-14 13:50:22 +00:00
Tomas Votruba 5dfd1c664c Updated Rector to commit 7182e19c4b0696ee48ff8c828afe47fd34d36d1c
7182e19c4b [TypeDeclaration] Skip array by doc with different assign on ReturnTypeFromStrictNewArrayRector (#5875)
2024-05-14 13:14:40 +00:00
Tomas Votruba 4bcc8bbea0 Updated Rector to commit 8f59d4e23ed974bf9eba52a075ef4d1e2604c80d
8f59d4e23e [Php80] Skip remove non-mixed type doc on MixedTypeRector (#5874)
2024-05-14 08:30:55 +00:00
Tomas Votruba faba2d1971 Updated Rector to commit 035e7bdb76a5496c65b1c112933e4afe06ddc6f8
035e7bdb76 [NodeTypeResolver] Clean up "this" from NameTypeResolver, as not from Name node (#5873)
2024-05-13 12:23:37 +00:00
Tomas Votruba c74c9ca74f Updated Rector to commit 419480a0c415b5814065953e0ee8b90a785323a2
419480a0c4 [NodeTypeResolver] Clean up array check on NameTypeResolver (#5872)
2024-05-13 10:38:52 +00:00
Tomas Votruba b5b172a4b9 Updated Rector to commit eea59bf3b2d52aa7553cfa3d36ea0de69221abe5
eea59bf3b2 Fix "method x was not found in reflection of class" (#5871)
2024-05-13 07:24:53 +00:00
Tomas Votruba 49d837e2a6 Updated Rector to commit e2a184cb16dfe1964feecbe44f7d7cc6130ac010
e2a184cb16 [NodeTypeResolver] Using built int ->isArray()->yes() on ArrayTypeAnalyzer::isArrayType() (#5870)
2024-05-12 15:56:38 +00:00
Tomas Votruba af81b5db1b Updated Rector to commit b18da7d458c2d240dd50682b31670e134f2b1ed3
b18da7d458 [CodeQuality] Skip on property and class const on CallableThisArrayToAnonymousFunctionRector (#5869)
2024-05-12 07:34:26 +00:00
Tomas Votruba 5ca50de6b7 Updated Rector to commit b18da7d458c2d240dd50682b31670e134f2b1ed3
b18da7d458 [CodeQuality] Skip on property and class const on CallableThisArrayToAnonymousFunctionRector (#5869)
2024-05-11 18:18:48 +00:00
Tomas Votruba efb3c476c7 Updated Rector to commit ca2988edc997d76a1d7d4b2c6a4f7226478cac7c
ca2988edc9 [CodeQuality] Skip increment variable on else on TernaryFalseExpressionToIfRector (#5867)
2024-05-10 09:40:07 +00:00
Tomas Votruba 73eb63e4f9 Rector 1.0.5 2024-05-10 05:31:15 +00:00
Tomas Votruba 322f3ad55c Updated Rector to commit 48fc55d89350f24521a197c04b5512452a3b50fc
48fc55d893 [StaticTypeMapper] Clean up NameNodeMapper check Scalar and class exists (#5865)
2024-05-10 03:29:37 +00:00
Tomas Votruba fe891363d5 Updated Rector to commit 558f44d5939be4314d76f4850a34be3590e65bfd
558f44d593 [TypeDeclaration] Skip more detailed type on AddMethodCallBasedStrictParamTypeRector (#5866)
2024-05-10 03:14:36 +00:00
Tomas Votruba f7723ed647 Updated Rector to commit ef84a1a722c39839de1bcd79e0d3558b3e7d935d
ef84a1a722 [PHPStanStaticTypeMapper] Clean up Intersection type check on UnionTypeMapper (#5864)
2024-05-09 01:12:15 +00:00
Tomas Votruba ed1310b8dc Updated Rector to commit acb0b5d3ad760e7253fb6f49b4047ec6226384d4
acb0b5d3ad [PHPStanStaticTypeMapper] Clean up UnionTypeMapper: remove unused TypeFactory usage (#5863)
2024-05-08 23:53:57 +00:00
Tomas Votruba 9da012cd97 Updated Rector to commit bb90e0bbafee5e47720d9fda8f7e46fad5bd90a2
bb90e0bbaf [PHPStanStaticTypeMapper] Clean up non-Node type check on UnionTypeMapper (#5862)
2024-05-08 14:07:50 +00:00
Tomas Votruba dcdff77130 Updated Rector to commit 8371040f72445fda4e96f29783b5de5351524c8a
8371040f72 [TypeDeclaration] Handle array with index assigned on TypedPropertyFromAssignsRector (#5861)
2024-05-08 13:00:27 +00:00
Tomas Votruba 582a864f33 Updated Rector to commit 650dcc6394c6df206772350e525311f8080e5077
650dcc6394 [automated] Apply Coding Standard (#5860)
2024-05-05 00:32:34 +00:00
Tomas Votruba 2dc9d28496 Updated Rector to commit 6649713eb98b016d5503163cd8cbea534ae61f2e
6649713eb9 [automated] Re-Generate Nodes/Rectors Documentation (#5859)
2024-05-05 00:31:57 +00:00
Tomas Votruba 5c55f54e78 Updated Rector to commit 4789b516d98b619f2e04900ab0ae442eb94a5348
4789b516d9 Clean up exclude paths from config-downgrade.php (#5858)
2024-05-05 00:02:51 +00:00
Tomas Votruba 87c26777cb Updated Rector to commit 28e84d24d0f618a8a7e0ff6ea561f1aade554df9
28e84d24d0  [EarlyReturn] Skip with AssignOp on PreparedValueToEarlyReturnRector  (#5857)
2024-05-03 14:46:34 +00:00
Tomas Votruba 19b93eeeab Updated Rector to commit 10558a8d5fb68c0564f995a008b4c666ff932a03
10558a8d5f [NodeTypeResolver] Use existing DefaultReflector::reflectAllClasses() method on DynamicSourceLocatorProvider (#5856)
2024-05-02 19:23:28 +00:00
Tomas Votruba fb4bddec05 Updated Rector to commit 10558a8d5fb68c0564f995a008b4c666ff932a03
10558a8d5f [NodeTypeResolver] Use existing DefaultReflector::reflectAllClasses() method on DynamicSourceLocatorProvider (#5856)
2024-05-02 11:03:58 +00:00
Tomas Votruba ee17c27a72 Updated Rector to commit d8f262aa6252740d3a3f17d1f429b7dcf2cc760a
d8f262aa62 [CodeQuality] Skip dynamic second arg or has uppercase second arg on SimplifyStrposLowerRector (#5855)
2024-05-02 09:08:24 +00:00
Tomas Votruba 346b5723b4 Updated Rector to commit 6525345f4d3e594311a7186982087ec17ef8b0ee
6525345f4d [CodeQuality] Fix tautology transformation on identical check on SimplifyTautologyTernaryRector (#5854)
2024-05-02 08:08:51 +00:00
Tomas Votruba 029097acda Updated Rector to commit c7d2ca3f1f2b9153fb05f0ad974b1d4a403be9c3
c7d2ca3f1f Early-return NullSafeMethodCall in NodeNameResolver (#5840)
2024-05-02 07:40:52 +00:00
Tomas Votruba 12c115e6f6 Updated Rector to commit 5193d43b644f9d059d9964ebcc6820181a7bca18
5193d43b64 [NodeTypeResolver] Remove unnecessary loop SourceLocator collection on DynamicSourceLocatorProvider (#5852)
2024-05-02 02:21:56 +00:00
Tomas Votruba b70df4cb6b Updated Rector to commit 0526417dd6b68191708cff8d636afeeb710c4827
0526417dd6 [Printer] Handle Strip left spaces from opening tags on namespaced PHP + HTML content (#5851)
2024-04-30 22:14:48 +00:00
Tomas Votruba 78e3d54584 Updated Rector to commit 57275efac450b9b0466e9dc934d3c07e2e9a1e43
57275efac4 [TypeDeclarations] Add IncreaseDeclareStrictTypesRector to raise level of declare() coverage (#5849)
2024-04-30 13:26:50 +00:00
Tomas Votruba c747b603a3 Updated Rector to commit ce1033d8e6434f3111307dd274dec753eb6481b1
ce1033d8e6 Fixes typo in FinalizeTestCaseClassRector.php (#5850)
2024-04-30 12:43:57 +00:00
Tomas Votruba aff937886f Updated Rector to commit cc4b63fe261a39b55b621e426d87346042412741
cc4b63fe26 CI: take utils/ into account in class-leak (#5847)
2024-04-29 07:35:23 +00:00
Tomas Votruba 343a691722 Updated Rector to commit de41aaf486222ce8a11d645d03ae25cd5678a31f
de41aaf486 Remove "packages" from Rector CI run (#5846)
2024-04-27 02:47:31 +00:00
Tomas Votruba e9ca0b2469 Updated Rector to commit 9bcded03ea2db7b01183aad2407e3f7490be9531
9bcded03ea [Experiment] Rework child classes detection on DynamicSourceLocatorProvider (#5735)
2024-04-25 08:24:53 +00:00
Tomas Votruba 7141ae6e56 Updated Rector to commit 8281a06bc8432d9d7f8e20842e3961df99a277bc
8281a06bc8 [PHP 7.2] Add error suppres support to each() rule (#5844)
2024-04-24 08:56:31 +00:00
Tomas Votruba d5e203a6e9 Updated Rector to commit d5069f0fccf649646eeea05b5291c0ac34e511d6
d5069f0fcc [Php83] Handle default native constant on AddTypeToConstRector (#5843)
2024-04-23 12:10:57 +00:00
Tomas Votruba a3b725126c Updated Rector to commit 775916c6416e68507e846421f04e2cabbfa2d737
775916c641 [Naming] Skip DateTime as individual in name resolver (#5842)
2024-04-23 09:06:40 +00:00
Tomas Votruba 09acbdda13 Updated Rector to commit 6eac87db32eff9308a037fb32ce973ccf905fc92
6eac87db32 Ignore phpdoc type in RecastingRemovalRector (#5841)
2024-04-22 20:26:54 +00:00
Tomas Votruba fdfd07f062 Updated Rector to commit 6eac87db32eff9308a037fb32ce973ccf905fc92
6eac87db32 Ignore phpdoc type in RecastingRemovalRector (#5841)
2024-04-22 09:35:50 +00:00
Tomas Votruba c041415e42 Updated Rector to commit 71c6dd929f07d6491847ee9004224441265d0197
71c6dd929f Support NullSafeProperty fetches in unused-code analysis (#5839)
2024-04-21 19:25:07 +00:00
Tomas Votruba 3e1d355024 Updated Rector to commit 4cd2622ccbe9989cdf76a16aa6d282b5ba73adb0
4cd2622ccb Support NullSafeMethod calls in unused-code analysis (#5838)
2024-04-21 19:23:11 +00:00
Tomas Votruba 6cbc8ec497 Updated Rector to commit 068799f59b289bef06b9c1f384df4301b19e726e
068799f59b [Performance] Early skip func call name on ClassRenamer (#5837)
2024-04-21 13:28:31 +00:00
Tomas Votruba 1c323223b2 Updated Rector to commit 068799f59b289bef06b9c1f384df4301b19e726e
068799f59b [Performance] Early skip func call name on ClassRenamer (#5837)
2024-04-21 12:45:15 +00:00
Tomas Votruba 655c2aa498 Updated Rector to commit 068799f59b289bef06b9c1f384df4301b19e726e
068799f59b [Performance] Early skip func call name on ClassRenamer (#5837)
2024-04-21 12:39:04 +00:00
Tomas Votruba 584e892a51 Updated Rector to commit 068799f59b289bef06b9c1f384df4301b19e726e
068799f59b [Performance] Early skip func call name on ClassRenamer (#5837)
2024-04-20 20:05:57 +00:00
Tomas Votruba b9839a24cb Updated Rector to commit 068799f59b289bef06b9c1f384df4301b19e726e
068799f59b [Performance] Early skip func call name on ClassRenamer (#5837)
2024-04-20 19:29:23 +00:00
Tomas Votruba 1e8aeb3de9 Updated Rector to commit 9ce6af83b6996631fe2a13cca64d25142dc9fb15
9ce6af83b6 [Performance] Early skip NativeFunctionReflection on OptionalParametersAfterRequiredRector (#5836)
2024-04-20 19:24:39 +00:00
Tomas Votruba 8aefc5e967 Updated Rector to commit 1374e15d742f4f36f0bef45db9f8920a589865b3
1374e15d74 [CodeQuality] Add Function_ and FuncCall support on OptionalParametersAfterRequiredRector (#5835)
2024-04-20 11:01:46 +00:00
Tomas Votruba 6db496ec6b Updated Rector to commit b81ef2f28aee9da0861eb67d90d134ec1c537786
b81ef2f28a [Renaming] Skip func call name on RenameClassRector (#5833)
2024-04-19 21:54:58 +00:00
Tomas Votruba 24418026e3 Updated Rector to commit 5e213e66ed72dede6bb43315dbaa2c8d86d449c9
5e213e66ed Revert "Faster FileInfoMatcher (#5830)" (#5831)
2024-04-19 12:41:40 +00:00
Tomas Votruba e01fd7276e Updated Rector to commit 38b3c20c5b36f1a821d3f38dfef63f547bb1b918
38b3c20c5b Faster FileInfoMatcher (#5830)
2024-04-19 11:48:23 +00:00
Tomas Votruba 61037dab6c Updated Rector to commit 25c1b437061df8d1361f457c603dcd17b10a29c4
25c1b43706 [Php81] Use PHPStan ParametersAcceptor to detect allowed argument types on NullToStrictStringFuncCallArgRector (#5829)
2024-04-18 07:39:11 +00:00
Tomas Votruba f42da12667 Updated Rector to commit 56e2031ba3eb1886f534e87d6fb533f8b24f6889
56e2031ba3 [CodeQuality] Skip $counter variable exists on ForRepeatedCountToOwnVariableRector (#5828)
2024-04-17 21:03:14 +00:00
Tomas Votruba 83bfbc18b8 Updated Rector to commit d67342e4e23b577a259e2d2af0ed64461db9968b
d67342e4e2 Fix original quotes in PregReplaceEModifierRector (#5827)
2024-04-17 10:04:21 +00:00
Tomas Votruba b7b08c4396 Updated Rector to commit 7574abd469cbfe569dd47dd9ae9e6aa668a0cf1b
7574abd469 [Php81] Skip mixed type on ArrayDimFetch on NullToStrictStringFuncCallArgRector (#5826)
2024-04-17 09:30:28 +00:00
Tomas Votruba 4f94d24171 Updated Rector to commit 18f482fad0993dbf0b55c628557297610256d87d
18f482fad0 cleanup (#5825)
2024-04-17 09:15:48 +00:00
Tomas Votruba 59f76a0fe3 Updated Rector to commit 33b1f2f39ce2e1f3c42c33749cf65e5c3b780e2c
33b1f2f39c clean up comment autowire on ConditionalTypeMapper (#5824)
2024-04-17 09:12:55 +00:00
Tomas Votruba ea0464beb9 Updated Rector to commit 8cf4340f3e9ace06e20827147e1065cfd5182efa
8cf4340f3e [TypeDeclaration] Handle crash on @mixin usage on ReturnTypeFromStrictTypedCallRector (#5823)
2024-04-17 08:35:57 +00:00
Tomas Votruba f3e4fee4bc Updated Rector to commit 2b811afb584aa7a3c569a2ce23d78edbf126d556
2b811afb58 [Php81] Skip always string if else DomElement on NullToStrictStringFuncCallArgRector (#5822)
2024-04-17 07:18:31 +00:00
Tomas Votruba 284531ceed Updated Rector to commit 2b811afb584aa7a3c569a2ce23d78edbf126d556
2b811afb58 [Php81] Skip always string if else DomElement on NullToStrictStringFuncCallArgRector (#5822)
2024-04-15 12:27:37 +00:00
Tomas Votruba 2b9acd03a1 Updated Rector to commit 86eb512e4f78f909856b90bc18e41704b48ee57a
86eb512e4f [automated] Apply Coding Standard (#5821)
2024-04-14 10:00:50 +00:00
Tomas Votruba 885a3f6ed3 Updated Rector to commit 86eb512e4f78f909856b90bc18e41704b48ee57a
86eb512e4f [automated] Apply Coding Standard (#5821)
2024-04-14 08:36:05 +00:00
Tomas Votruba 7d4734bb64 Updated Rector to commit 86eb512e4f78f909856b90bc18e41704b48ee57a
86eb512e4f [automated] Apply Coding Standard (#5821)
2024-04-14 00:31:32 +00:00
Tomas Votruba 7f89a08ca2 Updated Rector to commit 5f212992965828f07b001bf5e3176bcff784bab3
5f21299296 [Util] Register AddCoversClassAttributeRector as by guessing class detection (#5820)
2024-04-13 20:38:29 +00:00
Tomas Votruba 51fa5a731d Updated Rector to commit 3df5a626e5ae8e13aaef8abfc41a136dbf1f367e
3df5a626e5 Clean up SafeLeftTypeBooleanAndOrAnalyzer (#5819)
2024-04-13 07:48:52 +00:00
Tomas Votruba 3a03381bf8 Updated Rector to commit 3df5a626e5ae8e13aaef8abfc41a136dbf1f367e
3df5a626e5 Clean up SafeLeftTypeBooleanAndOrAnalyzer (#5819)
2024-04-12 09:51:06 +00:00
Tomas Votruba 6059061e25 Updated Rector to commit ec59456217e4e2c212c0486cd0ee33221e5ab86c
ec59456217 [DeadCode] Skip $this in trait on RemoveDeadInstanceOfRector (#5818)
2024-04-12 09:47:55 +00:00
Tomas Votruba f2cac5e2a0 Updated Rector to commit 7d69fc226cab739ec6c47b09bfdd784a24445fe1
7d69fc226c [DeadCode] Skip $this instanceof in Trait on RemoveAlwaysTrueIfConditionRector (#5817)
2024-04-12 09:19:41 +00:00
Tomas Votruba 76a58d63f0 Updated Rector to commit 879a36b44d6b43e4c4d268a3d7e96e0830cac478
879a36b44d [Php81] Skip __invoke() usage from non-class code on FirstClassCallableRector (#5816)
2024-04-11 20:55:59 +00:00
Tomas Votruba 0c2b95ea62 Updated Rector to commit de7b0526ad03b6e2ecc47d28eb8c8e0e5224152a
de7b0526ad [TypeDeclaration] Handle return by array shape type on AddArrowFunctionReturnTypeRector (#5815)
2024-04-10 10:22:01 +00:00
Tomas Votruba f53efcffe8 Updated Rector to commit 1d2d51e20ce11d0f603e42bd8869c1ab6d2a52cc
1d2d51e20c [Nette] Replace deprecated Json::FORCE_ARRAY and Json::PRETTY on Nette\Utils\Json usage (#5814)
2024-04-09 22:43:38 +00:00
Tomas Votruba 67791a9582 Updated Rector to commit 1d2d51e20ce11d0f603e42bd8869c1ab6d2a52cc
1d2d51e20c [Nette] Replace deprecated Json::FORCE_ARRAY and Json::PRETTY on Nette\Utils\Json usage (#5814)
2024-04-09 21:01:48 +00:00
Tomas Votruba 9427cdb84c Updated Rector to commit 1d2d51e20ce11d0f603e42bd8869c1ab6d2a52cc
1d2d51e20c [Nette] Replace deprecated Json::FORCE_ARRAY and Json::PRETTY on Nette\Utils\Json usage (#5814)
2024-04-09 20:37:51 +00:00
Tomas Votruba d495dc4fe7 Updated Rector to commit a67952f6d15ef954da70898c58aa10567b51c11e
a67952f6d1 [Php81] Skip on property and class const on FirstClassCallableRector (#5813)
2024-04-08 13:35:12 +00:00
Tomas Votruba e56fb5adb0 Updated Rector to commit 1bbb3faaed01bd234f8e53564d1686529551e75a
1bbb3faaed [TypeDeclaration] Skip maybe not returned on while on ReturnUnionTypeRector (#5812)
2024-04-08 13:19:12 +00:00
Tomas Votruba 415f0bbf34 Updated Rector to commit 54e2e110d506d6e06e45cb808ce87824306ddd4f
54e2e110d5 [CodeQuality] Skip while(true) always returned on ExplicitReturnNullRector (#5810)
2024-04-08 12:23:14 +00:00
Tomas Votruba 8fba5b95f7 Updated Rector to commit b292010edec6f45b5a48d1f001edce95e05162f3
b292010ede [Performance][TypeDeclaration] Avoid double loop on SilentVoidResolver use NeverFuncCallAnalyzer (#5809)
2024-04-08 09:44:15 +00:00
Tomas Votruba 53fb366ec6 Updated Rector to commit 9939ced45eb3479a1d8b2b9339512398118b92d9
9939ced45e [CodeQuality] Skip never type on default switch on ExplicitReturnNullRector (#5808)
2024-04-08 09:20:15 +00:00
Tomas Votruba 6fb3352189 Updated Rector to commit 690fe892750028e239a01f1b13cd252359994522
690fe89275 [CodeQuality] Skip Always return in try catch with finally on ExplicitReturnNullRector (#5807)
2024-04-07 09:15:50 +00:00
Tomas Votruba 530c01c201 Updated Rector to commit 145b616765b9c534e5ebe4203caa0c0f4dd3b7fc
145b616765 [automated] Apply Coding Standard (#5806)
2024-04-07 00:31:48 +00:00
Tomas Votruba 707e3d8942 Updated Rector to commit 467e971b79acab35e7bb0937166ab2e23bffd245
467e971b79 Make Compatible with phpstan 1.11.x code (#5804)
2024-04-05 22:38:12 +00:00
Tomas Votruba b8bbd024cd Updated Rector to commit c860b0cd3976acfd4b05d6929f446a7b50454b52
c860b0cd39 Update docs for AddTypeToConstRector (#5803)
2024-04-05 18:05:20 +00:00
Tomas Votruba 6678ca05d4 Updated Rector to commit 4a77565302216f6fde71232600cd175422a00965
4a77565302 ExplicitReturnNullRector should skip never return (#5802)
2024-04-05 18:04:27 +00:00
Tomas Votruba 6e04d0eb08 Rector 1.0.4 2024-04-05 09:01:07 +00:00
Tomas Votruba d59efe6a88 Updated Rector to commit a16a04d0bc90df11918efd4b7fc117a9e3dcc1c3
a16a04d0bc composer-dependency-analyser: fix dependency issues (#5777)
2024-04-04 14:00:19 +00:00
Tomas Votruba e004423e08 Updated Rector to commit 8e022d170a2e88d66e12631536f298de8b22d42d
8e022d170a ArgumentRemoverRectorTest: replace symfony\yaml reference with dummy (#5799)
2024-04-03 16:42:28 +00:00
Tomas Votruba f81fa92915 Updated Rector to commit a43f37190db97fb8807cb08f4e7171a338625387
a43f37190d [CodeQuality] Handle Switch maybe return on ExplicitReturnNullRector (#5801)
2024-04-03 15:10:32 +00:00
Tomas Votruba d36c8ad1a5 Updated Rector to commit 0348124a5535b99712da4debc136d2e73647b97a
0348124a55 [CodeQuality] Skip Switch_ always returned on ExplicitReturnNullRector (#5800)
2024-04-03 14:37:39 +00:00
Tomas Votruba b352c8473a Updated Rector to commit 0348124a5535b99712da4debc136d2e73647b97a
0348124a55 [CodeQuality] Skip Switch_ always returned on ExplicitReturnNullRector (#5800)
2024-04-03 14:17:43 +00:00
Tomas Votruba 6e65fef1e7 Updated Rector to commit 88648d1e6fe18bcc67ea76ebdc76c1d1e6d1fe6f
88648d1e6f [DeadCode] Skip @param true on native bool type on RemoveUselessParamTagRector (#5798)
2024-04-03 13:39:09 +00:00
Tomas Votruba 81fd362a59 Updated Rector to commit 91ed251a8c450a776ec4b739c735b4bd6f9bf8d5
91ed251a8c [DeadCode] Skip property fetch on cond as may be overridden on RemoveAlwaysTrueIfConditionRector (#5796)
2024-04-03 12:13:43 +00:00
Tomas Votruba a210882e56 Updated Rector to commit e5037921c408b717756a3997e8111ae3729aef08
e5037921c4 Cleanup: use hasByName() over getTagsByName() (#5797)
2024-04-03 12:05:35 +00:00
Tomas Votruba 77aab2e2a3 Updated Rector to commit 3f1ccb3ea131997a435fc2211620e968c6732220
3f1ccb3ea1  Support @immutable phpdoc in RestoreDefaultNullToNullableTypePropertyRector (#5795)
2024-04-03 11:21:35 +00:00
Tomas Votruba d4fd813b33 Updated Rector to commit f889e416d94cbfcf3734bb2fd4daf678aa11f8a9
f889e416d9 [DeadCode] Remove union with interface on RemoveUselessParamTagRector to make it consistent (#5794)
2024-04-03 07:05:33 +00:00
Tomas Votruba 36ab30b476 Updated Rector to commit 8bce42424e3418ee287fe34b1004b1f66449b923
8bce42424e [NodeTypeResolver] Move UnionType doc vs FullyQualified native type as not equal to TypeComparator (#5793)
2024-04-03 06:36:42 +00:00
Tomas Votruba 3fdaba944f Updated Rector to commit 52aa64ffe2cc0add4cbffede6ce36cbec576ef2f
52aa64ffe2 [DeadCode] Clean up TypeHasher on Union Type (#5792)
2024-04-03 06:21:54 +00:00
Tomas Votruba dc2feca4d5 Updated Rector to commit ef333de3d58a4649558971b19f4814fd92823abe
ef333de3d5 [DeadCode] Add RemoveUselessReadOnlyTagRector (#5790)
2024-04-03 05:38:43 +00:00
Tomas Votruba 717507e265 Updated Rector to commit 717e3e00ca93c371f8633f6ea17ea1b5e686657a
717e3e00ca [Php81] Remove @readonly doc on transformation to native readonly on ReadOnlyPropertyRector (#5789)
2024-04-03 05:38:25 +00:00
Tomas Votruba 9f2e48fa07 Updated Rector to commit 9b4ad93acd680c5da9a3bab4d5e1f46ad5905b7f
9b4ad93acd Fix removal of useless @param tag when string|null insteadof ?string is used. (#5684)
2024-04-03 05:02:11 +00:00
Tomas Votruba bc02e10427 Updated Rector to commit b925e54b913863053e57e628ea95b2fd612e128e
b925e54b91 [Performance][Php81] Early property promotion and readonly param check before changeable check on ReadOnlyPropertyRector (#5791)
2024-04-03 04:19:15 +00:00
Tomas Votruba dc2205094c Updated Rector to commit 724899c28307e4cb1f8a7366ebb76756430da754
724899c283 [TypeDeclaration] Do not use Required::class reference on AutowiredClassMethodOrPropertyAnalyzer (#5788)
2024-04-01 17:58:30 +00:00
Tomas Votruba 664f4e3a6b Updated Rector to commit 0f1987b0faa8dc1c5e086c9b95457d6018b2cd82
0f1987b0fa Adds a link to the PHP Static Analysis Attributes rector rules (#5787)
2024-04-01 16:51:34 +00:00
Tomas Votruba 755e0f4a8c Updated Rector to commit 35c1bf45b0bed6351e0db6e3a44a452f3713b155
35c1bf45b0 [TypeDeclaration] Handle with inner function on AddParamTypeBasedOnPHPUnitDataProviderRector (#5786)
2024-03-31 20:47:44 +00:00
Tomas Votruba 9369a862b6 Updated Rector to commit d86930657fc80c2db725391d1bb8f3ad6a61d96a
d86930657f [TypeDeclaration] Handle in inner function on ReturnTypeFromStrictTernaryRector (#5785)
2024-03-31 19:48:39 +00:00
Tomas Votruba 9b731daab1 Updated Rector to commit 4c40eb60ca984574eea3fa75e8ac59e9c8e07e5e
4c40eb60ca [TypeDeclaration] Handle initialized on getter on ReturnTypeFromStrictTypedPropertyRector (#5784)
2024-03-31 19:07:37 +00:00
Tomas Votruba 0a7d532276 Updated Rector to commit 93e025900b640f8182b267812a08c364d42590ef
93e025900b [automated] Apply Coding Standard (#5782)
2024-03-31 00:30:04 +00:00
Tomas Votruba f2feb272ed Updated Rector to commit aa706a152c2cb0ece154edab3bc89bad8c2f7208
aa706a152c [Php82] Add VariableInStringInterpolationFixerRector (#5781)
2024-03-29 21:39:12 +00:00
Tomas Votruba 42078c4127 Updated Rector to commit 08d73a1af5ebc77bf37e9854fc1aca76cd5fcbcb
08d73a1af5 [Printer] Apply configurable multiline on Fluent Method Call on print after method call created/re-printed (#5779)
2024-03-28 16:05:42 +00:00
Tomas Votruba 7af3ed15e0 Updated Rector to commit 3122ef482389945d97c26bb3ff5c2b0b3faf867b
3122ef4823 [NodeCollector] Fix non-string value on ArrayCallableMethodMatcher::resolveClassContextType() (#5780)
2024-03-28 09:11:42 +00:00
Tomas Votruba 30adaf3fc0 Updated Rector to commit eb525ca9fe04a8bc074cf49b5cf25991014fff5f
eb525ca9fe [DeadCode] Skip Array Callable dynamic method using __CLASS__ with constructor (no default args) on RemoveUnusedPrivateMethodRector (#5774)
2024-03-28 08:14:50 +00:00
Tomas Votruba c23b2384d3 Updated Rector to commit 3e6a4923d463e2a2d104ac283dae04343ee2a2d0
3e6a4923d4 [DeadCode] Skip implements interface on RemoveUnusedConstructorParamRector (#5778)
2024-03-27 15:29:07 +00:00
Tomas Votruba e538a96c9b Updated Rector to commit cd23b1fa90343d4f4b1c8f0d606c0eba8d194597
cd23b1fa90 Clean up scope skip scope check on ExprScopeFromStmtNodeVisitor (#5776)
2024-03-26 20:18:31 +00:00
Tomas Votruba 045db2fd56 Updated Rector to commit f254215a5ac2877d4fb99dbf7f7ab44c070f1333
f254215a5a [Scope] Fix resolve Scope from fluent call (#5743)
2024-03-26 19:25:47 +00:00
Tomas Votruba 014254f0df Updated Rector to commit 83046fcc340c19fc65bc09db25bbc018b01d6f30
83046fcc34 Add `rector` test suite to `phpunit.xml` or `phpunit.xml.dist` (#5717)
2024-03-26 09:28:34 +00:00
Tomas Votruba 4c2b400cdb Updated Rector to commit ff0705b18b7f2e8e7e9062d0d4fd87a4c5c1b20e
ff0705b18b [CodeQuality] Add Goto_ possible return null on SilentVoidResolver under Do_ (#5773)
2024-03-25 15:52:31 +00:00
Tomas Votruba cc37bbf217 Updated Rector to commit 82d71724f2e2fff036a859e3fe2589fa82adb633
82d71724f2 [TypeDeclaration] Ensure always return with Expr on maybe continued in next stmt on SilentVoidResolver (#5771)
2024-03-25 08:45:48 +00:00
Tomas Votruba be393d497b Updated Rector to commit fc250dd8da281cb79f5657d2f5d6c6c0053e54d1
fc250dd8da [DeadCode] Fix array callable with constructor args (#5770)
2024-03-24 14:10:21 +00:00
Tomas Votruba 078e4b92d7 Updated Rector to commit 25f3af626f841f7e62606a3a9aa64789a460f74c
25f3af626f [automated] Apply Coding Standard (#5769)
2024-03-24 00:29:59 +00:00
Tomas Votruba ca1cc37af8 Updated Rector to commit 087f07ae43a3842cf06b257b0ac69e20cac5a14a
087f07ae43 [automated] Re-Generate preload.php (#5768)
2024-03-24 00:29:17 +00:00
Tomas Votruba 5d8e196d67 Updated Rector to commit 11ce9fcc2ca9283af47d2aee343befc111a4e595
11ce9fcc2c More fixture on Do_ maybe returned (#5767)
2024-03-23 20:38:12 +00:00
Tomas Votruba 52addb1dde Updated Rector to commit 879feb8931f1465fa463d539e9ce99ebfae4e948
879feb8931 [CodeQuality] Handle do { } while maybe returned on ExplicitReturnNullRector (#5766)
2024-03-23 20:33:11 +00:00
Tomas Votruba e14c8a528b Updated Rector to commit aac889be3d845974d3ab924ff7ad22784b9e3cb5
aac889be3d [AutoImport] Remove unused compare removed use on FullyQualifiedNameClassNameImportSkipVoter (#5764)
2024-03-23 16:49:42 +00:00
Tomas Votruba bb8b99d70c Updated Rector to commit e3e741edd3ca55fc2c24c040f43c8974bda7e953
e3e741edd3 [AutoImport] Allow auto import same namespace with sub use with docblock short name (#5763)
2024-03-23 14:36:19 +00:00
Tomas Votruba 0e57251e46 Updated Rector to commit c45f0e2cef30cb0b3090d51fd14dc6ffaa1fc095
c45f0e2cef [CodeQuality] Add Function_ support on ExplicitReturnNullRector (#5762)
2024-03-23 06:38:28 +00:00
Tomas Votruba e18e5ef364 Updated Rector to commit 97e2433a8378ccc6666c67d4a01ace3abc97589f
97e2433a83 [CodeQuality] Allow transform return; to return null; when there is other return with Expr on ExplicitReturnNullRector (#5761)
2024-03-23 06:28:38 +00:00
Tomas Votruba 74b8ed7cd4 Updated Rector to commit cae06912ed7d7274d900fdc996448f100be2ed34
cae06912ed [CodeQuality] Skip do { } while always returned on ExplicitReturnNullRector (#5760)
2024-03-23 05:12:50 +00:00
Tomas Votruba e6bfc79aa2 Updated Rector to commit 8874f25347004e0c19043e8b97b69470193f0941
8874f25347 [CodeQuality] Move Yield_ and YieldFrom check to SilentVoidResolver (#5759)
2024-03-22 20:34:36 +00:00
Tomas Votruba 024ebc62a1 Updated Rector to commit b042152eae866b5578ea15cb38e27ce493937001
b042152eae [CodeQuality] Skip __construct() method on ExplicitReturnNullRector (#5758)
2024-03-22 19:55:35 +00:00
Tomas Votruba e10d636f62 Updated Rector to commit 61c7e9288885218b76a4a9431bba33a37059dea5
61c7e92888 [CodeQuality] No need to re-update doc when already union null doc on ExplicitReturnNullRector (#5757)
2024-03-22 18:09:58 +00:00
Tomas Votruba ce9cc3aafc Updated Rector to commit 576198cf701684dd85ed42530bcb8c54b6c41a02
576198cf70 [CodeQuality] Transform type|void docblock to type|null as well on ExplicitReturnNullRector after add return null (#5756)
2024-03-22 17:50:28 +00:00
Tomas Votruba dd51f7ceed Updated Rector to commit 32bf5c7e7a8da2100f12cbef185c958655d4292d
32bf5c7e7a [CodeQuality] Skip if else return on ExplicitReturnNullRector (#5755)
2024-03-22 16:53:50 +00:00
Tomas Votruba 11b9220a05 Updated Rector to commit b4eb883e9110f50607ce2eed629c237b5e7e7356
b4eb883e91 [DeadCode] Skip isset() from property fetch from docblock on RemoveAlwaysTrueIfConditionRector (#5754)
2024-03-22 00:10:36 +00:00
Tomas Votruba 9811962c70 Updated Rector to commit b4eb883e9110f50607ce2eed629c237b5e7e7356
b4eb883e91 [DeadCode] Skip isset() from property fetch from docblock on RemoveAlwaysTrueIfConditionRector (#5754)
2024-03-21 18:38:10 +00:00
Tomas Votruba de2b2cf2b4 Updated Rector to commit dc69b1a963dc78ea9fe4ab07b70bc0716e1be341
dc69b1a963 [CodeQuality] Add new rule - ExplicitReturnNullRector (#5753)
2024-03-21 14:39:02 +00:00
Tomas Votruba 1a710b92cc Updated Rector to commit f32dff3ddb3bb8062fced070984017352f2b653a
f32dff3ddb [DeadCode] Skip From docblock on ReduceAlwaysFalseIfOrRector (#5752)
2024-03-21 11:54:51 +00:00
Tomas Votruba c1338c4c07 Updated Rector to commit aaf006c8f534230b1bbc4c4fb3747cd660305718
aaf006c8f5 [DeadCode] Skip use docblock on BooleanAnd check on RemoveDeadInstanceOfRector (#5751)
2024-03-21 11:37:34 +00:00
Tomas Votruba 50c2e61f1d Updated Rector to commit 0dd1a43904e7d12c76e810b1bbd87d99a0f835c3
0dd1a43904 [DeadCode] Add new rule - ReduceAlwaysFalseIfOrRector (#5750)
2024-03-21 11:36:43 +00:00
Tomas Votruba 7a69e542ca Updated Rector to commit 98a2a6fd6c6d1e2db5c0143e3e66e8421904b428
98a2a6fd6c Add test fixture on boolean && in RemoveAlwaysTrueIfConditionRector (#5749)
2024-03-21 11:23:24 +00:00
Tomas Votruba c950e4d97b Updated Rector to commit da67bb97a141fd0feb2ab90f5576138489f2f67d
da67bb97a1 Add boolean and support to RemoveDeadInstanceOfRector (#5748)
2024-03-21 11:05:56 +00:00
Tomas Votruba 00697fa4b6 Updated Rector to commit 0c177409ed477e978433597639335fb2a78bc331
0c177409ed Add support for getOneOrNullResult() method in ChildDoctrineRepositoryClassTypeRector (#5747)
2024-03-21 10:03:58 +00:00
Tomas Votruba 817ab2f7cb Updated Rector to commit f4070bb2b2f5c8f7a11063ce35549364c437a9cf
f4070bb2b2 Fix ChildDoctrineRepositoryClassTypeRector for generic type (#5746)
2024-03-21 09:55:11 +00:00
Tomas Votruba b38b8f3e85 Updated Rector to commit 26890958bc539e9a2234f1457a81d37f5972bf79
26890958bc [Php80] Use identical compare on PromotedPropertyCandidateResolver (#5745)
2024-03-20 14:21:32 +00:00
Tomas Votruba e94ff85194 Updated Rector to commit 765338ec5a4a725ce9b6788582372f24c09a3f82
765338ec5a [Php80] Skip var property usage on ClassPropertyAssignToConstructorPromotionRector (#5744)
2024-03-20 14:11:05 +00:00
Tomas Votruba 5ac9de7a83 Updated Rector to commit 685ba8a63e904c776033ba85c13f8903952e73e4
685ba8a63e [Renaming][AutoImport] Handle after change annotation to attribute with rename on AnnotationToAttributeRector + RenameClassRector with auto import (#5741)
2024-03-19 14:48:00 +00:00
Tomas Votruba ceff1cad27 Updated Rector to commit 1bf3947959e10f213a04e4eb626fc2ce428add60
1bf3947959 [CodingStyle] Remove usage of Reflection::expandClassName() from nette/utils 4.0 as cause bug on downgrade (#5740)
2024-03-19 10:36:18 +00:00
Tomas Votruba ac990f2560 Updated Rector to commit a78fb1b970be42619495215a2612d032a6ecdbee
a78fb1b970 Fix scoper (#5739)
2024-03-19 09:26:21 +00:00
Tomas Votruba dac0717196 Updated Rector to commit a78fb1b970be42619495215a2612d032a6ecdbee
a78fb1b970 Fix scoper (#5739)
2024-03-19 02:28:26 +00:00
Tomas Votruba d028a05e61 Updated Rector to commit b052ed9ca971f97105ac93712853ea5b897d4dd3
b052ed9ca9 Handle readonly class with attrs (#5736)
2024-03-19 01:20:27 +00:00
Tomas Votruba b1eb18f499 Updated Rector to commit b71d0fea8eaf051d6d55aee74c9eece0028e2165
b71d0fea8e Bump rule-doc-generator to prefixed version (#5737)
2024-03-18 22:09:15 +00:00
Tomas Votruba 0268ca2b1c Updated Rector to commit bf856e2ffa55c669e018e773341d7c05794f075e
bf856e2ffa Bump to php-parser ^4.19.1 (#5734)
2024-03-17 08:46:45 +00:00
Tomas Votruba 8d1aee03a3 Updated Rector to commit 560172463933f21b51b8ef306a068dc299f742e5
5601724639 [Dep] Temporary pin to use nikic/php-parser 4.18.0 (#5733)
2024-03-17 07:47:19 +00:00
Tomas Votruba 51090bc214 Updated Rector to commit ac2bd3f825b11233c07235a195f442be4113d99c
ac2bd3f825 [Php81] Skip $this::class on trait on NullToStrictStringFuncCallArgRector (#5732)
2024-03-17 07:10:56 +00:00
Tomas Votruba b50605a40a Updated Rector to commit 1764c19455ce55ee49ec1d678d422c788e7c4fff
1764c19455 [Configuration] Do not sets, skip, rules on empty array on RectorConfigBuilder (#5731)
2024-03-17 01:39:59 +00:00
Tomas Votruba 2bf9bab235 Updated Rector to commit a94605a3c00447f1f3348b66d0719652cb2aa8ce
a94605a3c0 [automated] Apply Coding Standard (#5730)
2024-03-17 00:29:09 +00:00
Tomas Votruba 29535d04eb Updated Rector to commit 0a07bf39b8c3852a0bd289280ee6e60080561447
0a07bf39b8 [automated] Re-Generate Nodes/Rectors Documentation (#5729)
2024-03-17 00:28:32 +00:00
Tomas Votruba dd371cdca2 Updated Rector to commit 6477094d5af502e65c75c30af7ce59ef3b8cc2d7
6477094d5a Update ArrayDimFetchToMethodCall to use ObjectType (#5728)
2024-03-16 10:32:26 +00:00
Tomas Votruba d5d197b9bf Updated Rector to commit d9b64c78e33ef461605ac08578c8159b01839c98
d9b64c78e3 Fixes for ArrayDimFetchToMethodCallRector (#5727)
2024-03-16 09:11:08 +00:00
Tomas Votruba 9ab2b8bc07 Updated Rector to commit d1ed5f03202cb9325f861ac7b8c1976173b45826
d1ed5f0320 [php84] Clean up contains null check type on ExplicitNullableParamTypeRector (#5726)
2024-03-16 08:29:12 +00:00
Tomas Votruba ae50c0e5a3 Updated Rector to commit cdde425c2224a1357d70d6784936fe47fe3ffee0
cdde425c22 [Transform] Adds ArrayDimFetchToMethodCallRector rule (#5723)
2024-03-15 19:25:11 +00:00
Tomas Votruba d3357ab3eb Updated Rector to commit a844e40a3f84f120866198401f9b3640575f7c06
a844e40a3f [Composer] Fix double / on illuminate-container-container-php.patch url on extra:patches config (#5725)
2024-03-15 14:15:54 +00:00
Tomas Votruba c0820093ad Updated Rector to commit ff32c0c08a89f27ea34187d00cf707734a7e39c8
ff32c0c08a [Php84] Add ExplicitNullableParamTypeRector (#5724)
2024-03-15 10:45:55 +00:00
Tomas Votruba edd8901ea0 Updated Rector to commit 23e3da2d6eee90e4f2a31c31062aabaeba77ba69
23e3da2d6e [CodeQuality] Remove BoolvalToTypeCastRector and FloatvalToTypeCastRector as well from code-quality set (#5722)
2024-03-14 20:16:36 +00:00
Tomas Votruba d7faacd4a0 Updated Rector to commit ea0f1c1351b68e3a0863d8460e2abea06099df87
ea0f1c1351 [code-quality] Remove intval/strval from sets, as no clear difference and personal preference (#5721)
2024-03-14 15:05:15 +00:00
Tomas Votruba c59507a909 Rector 1.0.3 2024-03-14 15:04:18 +00:00
Tomas Votruba e293557ea0 Updated Rector to commit b870d8f434c4ff0718c970620285dbb7088c5d86
b870d8f434 Remove --skip-type Rector\Core\Rector\AbstractCollectorRector on composer docs command as no longer exists (#5720)
2024-03-14 08:53:16 +00:00
Tomas Votruba ea97f93f74 Updated Rector to commit fbba8606a56e0643a7b3d1ae9af5fded082eea06
fbba8606a5  [Php80] Skip ObjectType on ChangeSwitchToMatchRector  (#5719)
2024-03-14 08:27:29 +00:00
Tomas Votruba d9fea10f3e Updated Rector to commit d01d16e9d8c7225e5a45cb2534b1b338f93e5740
d01d16e9d8 [CodeQuality] Skip compare string with stringable object on UseIdenticalOverEqualWithSameTypeRector (#5718)
2024-03-14 03:13:41 +00:00
Tomas Votruba 03f122a600 Updated Rector to commit c390eabeb2b2f77f755bfadc1d51b000da0d5ade
c390eabeb2 Skip mixed in ParamTypeByMethodCallTypeRector as not specific (#5715)
2024-03-12 16:22:51 +00:00
Tomas Votruba 4be56b3640 Updated Rector to commit a775c65eeccc0c6ed106adbe836ab114f37c5da4
a775c65eec [CodeQuality] Skip throw after foreach with return in loop on SimplifyForeachToCoalescingRector (#5714)
2024-03-11 11:19:03 +00:00
Tomas Votruba 3e8c19254e Updated Rector to commit 01c460ee526f057b6a4d48835ac19536a857c347
01c460ee52 Clean up skip config on rector.php (#5713)
2024-03-11 05:30:34 +00:00
Tomas Votruba ecd615137e Updated Rector to commit 861a8808e7516c74b7e41a884076eac35f60a14f
861a8808e7 [Php82] Skip usage of already RecursiveDirectoryIterator::SKIP_DOTS on FilesystemIteratorSkipDotsRector (#5712)
2024-03-11 03:08:10 +00:00
Tomas Votruba 7660d5730f Updated Rector to commit 8ade0b9e46aff3e6f755a9561579cdc0c9eb9b0e
8ade0b9e46 [EarlyReturn] Clena up equal node check on IfAndAnalyzer::isIfStmtExprUsedInNextReturn() (#5710)
2024-03-11 02:23:45 +00:00
Tomas Votruba 4026ff15b0 Updated Rector to commit 2adeacc410de9304137574d2e80cf97c9f67dfa5
2adeacc410 [Performance]EarlyReturn] Reduce repetitive findFirst() on IfAndAnalyzer::isIfStmtExprUsedInNextReturn() (#5709)
2024-03-11 02:12:38 +00:00
Tomas Votruba 8201d0fc9b Updated Rector to commit 57894303baab2e24a24387b48c5e94963e78ad26
57894303ba [Performance][CodingStyle] Check public method only for verify override interface (#5708)
2024-03-11 00:12:12 +00:00
Tomas Votruba d8f1371a76 Updated Rector to commit c0be2b455e4c83c3da737969f40f57dc6a7e6320
c0be2b455e [CodingStyle] Skip implements interface on MakeInheritedMethodVisibilitySameAsParentRector (#5707)
2024-03-10 23:50:43 +00:00
Tomas Votruba 0b4029ea85 Updated Rector to commit bdc09071abc58550a41fdd8a4af515206e022f4c
bdc09071ab fix: Strip left spaces from opening tags when comparing output for changes (#5701)
2024-03-10 09:23:51 +00:00
Tomas Votruba 2ede0d9e01 Updated Rector to commit e4b6ee63140c90c18f1fa51156ccffa569f1062c
e4b6ee6314 [automated] Apply Coding Standard (#5706)
2024-03-10 00:29:37 +00:00
Tomas Votruba d018e755ec Updated Rector to commit 569b9199017e5e09715acf406df15dc6175d9cc1
569b919901 [automated] Re-Generate Nodes/Rectors Documentation (#5705)
2024-03-10 00:28:56 +00:00
Tomas Votruba 309ceb4ee6 Updated Rector to commit 3d02e3ec8f3a7d03adc3f23c315e57850dc8379a
3d02e3ec8f  [CodeQuality] Skip sort/ksort on TernaryFalseExpressionToIfRector  (#5703)
2024-03-09 13:24:41 +00:00
Tomas Votruba 28f5dbde13 Updated Rector to commit c14f8d45175bd4c10fef503e350d677c4a73ce29
c14f8d4517 [Php72][TypeDeclaration] Rollback tweak infinite loop handling on DeclareStrictTypesRector (#5700)
2024-03-08 06:34:02 +00:00
Tomas Votruba 2e30301381 Updated Rector to commit 13bafcba1524782c349fe6523ce9c18d0f765452
13bafcba15 [Php72][TypeDeclaration] Fix infinite loop on ParseStrWithResultArgumentRector+DeclareStrictTypesRector (#5699)
2024-03-07 21:09:46 +00:00
Tomas Votruba a9ac2b236c Updated Rector to commit 62254600d1d3f036ae3e9c502613c4ac96a8b71b
62254600d1 [CodeQuality] Add support for compare $this::class compare with string on UseIdenticalOverEqualWithSameTypeRector (#5698)
2024-03-07 16:34:25 +00:00
Tomas Votruba d1ec79d324 Updated Rector to commit 4a1880bd2976e3cda6db8b1ca27c44c2c933b9e4
4a1880bd29 [CodeQuality] Add Equal and NotEqual support on SimplifyIfReturnBoolRector (#5697)
2024-03-07 14:24:18 +00:00
Tomas Votruba 2c9529a881 Updated Rector to commit 4a1880bd2976e3cda6db8b1ca27c44c2c933b9e4
4a1880bd29 [CodeQuality] Add Equal and NotEqual support on SimplifyIfReturnBoolRector (#5697)
2024-03-07 14:03:51 +00:00
Tomas Votruba a49cabd869 Updated Rector to commit 4a1880bd2976e3cda6db8b1ca27c44c2c933b9e4
4a1880bd29 [CodeQuality] Add Equal and NotEqual support on SimplifyIfReturnBoolRector (#5697)
2024-03-07 13:46:36 +00:00
Tomas Votruba 95d5fad617 Updated Rector to commit 750713625e27e07175e4c7144802fb623422c036
750713625e Add dump_node() helper function (#5696)
2024-03-07 12:12:34 +00:00
Tomas Votruba 7da00fc128 Updated Rector to commit 750713625e27e07175e4c7144802fb623422c036
750713625e Add dump_node() helper function (#5696)
2024-03-06 20:55:59 +00:00
Tomas Votruba 5cc97f5690 Updated Rector to commit 643814dc92ceacb159adbac79c1ab6fb6e5cc2ee
643814dc92 [TypeDeclaration] Add ChildDoctrineRepositoryClassTypeRector (#5695)
2024-03-06 20:37:05 +00:00
Tomas Votruba bd3297e237 Updated Rector to commit 84639e6aa9c5daa4958121e9aa19e36b5b6bb9b6
84639e6aa9 [Php83] Add support +/- value on constant on AddTypeToConstRector (#5694)
2024-03-05 22:49:19 +00:00
Tomas Votruba ff1845ce1a Updated Rector to commit 10c7bc6a4114dddde311e49efcd9c441ea92babc
10c7bc6a41 [Performance][Php81] Ensure check readonly on param only on __construct() method (#5693)
2024-03-05 13:39:29 +00:00
Tomas Votruba daa84a6ddf Updated Rector to commit 10c7bc6a4114dddde311e49efcd9c441ea92babc
10c7bc6a41 [Performance][Php81] Ensure check readonly on param only on __construct() method (#5693)
2024-03-05 11:36:28 +00:00
Tomas Votruba ae1f64a7a0 Updated Rector to commit e29b97e4b5d6dd5a0c5ee442067cb52f7dbb7f25
e29b97e4b5  [Php81] Handle with attribute on ReadOnlyPropertyRector on property promotion (#5692)
2024-03-05 11:28:48 +00:00
Tomas Votruba b05ad66b87 Updated Rector to commit 104f656edd312203d24db4cbe60bd54b78c421f8
104f656edd [Performance] [TypeDeclaration] No need check parent method when method is private on AddVoidReturnTypeWhereNoReturnRector (#5690)
2024-03-05 01:17:56 +00:00
Tomas Votruba de9745c9cb Updated Rector to commit 7f9113531a256794a5e598663644897ba108d9a2
7f9113531a [Php80] Fix typo class name: DoctrineCoverterterAttributeDecorator -> DoctrineConverterAttributeDecorator (#5689)
2024-03-04 22:12:31 +00:00
Tomas Votruba bd2820567f Updated Rector to commit 8c52d614891043c1310fb120e0871b4183a33a53
8c52d61489 [CodingStyle] Skip anonymous class on MakeInheritedMethodVisibilitySameAsParentRector (#5688)
2024-03-04 21:33:44 +00:00
Tomas Votruba 9c449858d7 Updated Rector to commit 7df4894bc7bd1bec704f8e428efb768d101e8984
7df4894bc7 [Performance][DeadCode] Early check has private methods before find() on dynamic call checks on RemoveUnusedPrivateMethodRector (#5687)
2024-03-04 17:14:34 +00:00
Tomas Votruba 6fc08102f7 Updated Rector to commit b4212ed99d3aadc3ce6371c984b644b54252752e
b4212ed99d [Performance] Combine repetitive find() usage on RemoveUnusedVariableAssignRector (#5686)
2024-03-04 14:03:11 +00:00
Tomas Votruba 105d14818d Updated Rector to commit b523b734e052b47d756330e7deeaa68372fbd494
b523b734e0 [Configuration] Fix parallel config always replaced by next config per-default true (#5683)
2024-03-04 11:27:13 +00:00
Tomas Votruba 4fdf5d4ab4 Updated Rector to commit b523b734e052b47d756330e7deeaa68372fbd494
b523b734e0 [Configuration] Fix parallel config always replaced by next config per-default true (#5683)
2024-03-03 20:46:43 +00:00
Tomas Votruba 7596fa6da0 Rector 1.0.2 2024-03-03 12:32:31 +00:00
Tomas Votruba 3a69e0ff7b Updated Rector to commit 1ae68446ee021d88238f915bc06201559a0ec82d
1ae68446ee Update README to use the new config syntax (#5674)
2024-03-03 02:43:03 +00:00
Tomas Votruba 769ac36c32 Updated Rector to commit 1cd83bef6196e8b8913d2252a6c8a826bafcf62a
1cd83bef61 [CodeQuality] Handle array destructuring of unpack on ArrayMergeOfNonArraysToSimpleArrayRector (#5682)
2024-03-03 02:33:19 +00:00
Tomas Votruba c34bb45766 Updated Rector to commit 2846b015388fb1eb6d65941481fe9340908c1f79
2846b01538 [CodeQuality] Skip combine var with property fetch on InlineArrayReturnAssignRector (#5681)
2024-03-03 02:19:56 +00:00
Tomas Votruba 659d1a42fb Updated Rector to commit c591bd291650ab22554ffd819e76d01a1a405719
c591bd2916  [CodeQuality] Skip nested array on InlineArrayReturnAssignRector  (#5680)
2024-03-03 02:09:46 +00:00
Tomas Votruba 1dbac6e2a3 Updated Rector to commit ce70534b3c8406164f630acbe6c7a1b18623d757
ce70534b3c Fix duplicated fixture class name on StaticToSelfStaticMethodCallOnFinalClassRector test (#5679)
2024-03-03 01:08:26 +00:00
Tomas Votruba 6986e1fbdb Updated Rector to commit c9fe3caacced982e1c21d7203e9ea0f1bb2092c8
c9fe3caacc [Transform] Allow transform phpVersion() to withPhpVersion() on RectorConfigBuilderRector (#5678)
2024-03-03 01:03:16 +00:00
Tomas Votruba d31429d029 Updated Rector to commit dea2e16665cf567c20664c7ef9bac38d0d7d4f49
dea2e16665 [PHP 8.0] Fix case insenstive false positive replacement for str_ends_with (#5677)
2024-03-02 13:08:36 +00:00
Tomas Votruba 991980cf2b Updated Rector to commit 7191fae140cc8c35a699b6487117e1efa8b4d2f5
7191fae140 Test auto commit after update github actions (#5676)
2024-03-01 20:06:48 +00:00
Tomas Votruba 695c190be3 Updated Rector to commit 94b5561ca87ee6825a098c7c506b774582bf3354
94b5561ca8 chore: bump min version of github actions (fix deprecations) (#5675)
2024-03-01 20:02:28 +00:00
Tomas Votruba 39c0390278 Updated Rector to commit 827992ae9784abb4a2a5f5f3aecbe52606f3c737
827992ae97 [Performance] [DeadCode] Early check no params in __construct() on RemoveUnusedPromotedPropertyRector (#5672)
2024-02-29 13:34:04 +00:00
Tomas Votruba df81c907da Updated Rector to commit 827992ae9784abb4a2a5f5f3aecbe52606f3c737
827992ae97 [Performance] [DeadCode] Early check no params in __construct() on RemoveUnusedPromotedPropertyRector (#5672)
2024-02-29 11:39:40 +00:00
Tomas Votruba 42b37a76a2 Updated Rector to commit 827992ae9784abb4a2a5f5f3aecbe52606f3c737
827992ae97 [Performance] [DeadCode] Early check no params in __construct() on RemoveUnusedPromotedPropertyRector (#5672)
2024-02-28 15:52:40 +00:00
Tomas Votruba e7800d7a95 Updated Rector to commit c57c164bae7c97212384f5120857bddfee329a7d
c57c164bae [CodeQuality] Handle crash on named arg on deep closure on OptionalParametersAfterRequiredRector (#5671)
2024-02-28 14:45:00 +00:00
Tomas Votruba dc6d59d8bb Updated Rector to commit 4a2811d0be372ef590c253a493f49bbb6745b524
4a2811d0be [Naming] Handle crash with numeric-string doc on RenamePropertyToMatchTypeRector (#5670)
2024-02-28 12:35:38 +00:00
Tomas Votruba d148fa379c Updated Rector to commit 8b1a181c243346b1c47c50f3e4513b117ebebc9d
8b1a181c24 [DeadCode] Skip implements interface __construct() on RemoveUnusedPromotedPropertyRector (#5669)
2024-02-28 11:20:28 +00:00
Tomas Votruba e8cdd78f11 Updated Rector to commit 04e62d38cd1f1a0e01d8efc19b19b384cd8726e6
04e62d38cd Revert " [Php81] Skip execution operator on NullToStrictStringFuncCallArgRect…" (#5668)
2024-02-28 01:07:46 +00:00
Tomas Votruba 4da7518a07 Updated Rector to commit b95ff29edfb93a3f6d0abc62a89b4a5362838f17
b95ff29edf  [Php81] Skip execution operator on NullToStrictStringFuncCallArgRector  (#5667)
2024-02-27 18:31:13 +00:00
Tomas Votruba d24ee522ce Updated Rector to commit a56ee1ed01bbbdae515b49fe4d820f219208f768
a56ee1ed01 [DeadCode] Fix infinite loop on RemoveDeadStmtRector + RemoveUnusedVariableAssignRector (#5666)
2024-02-27 12:11:43 +00:00
Tomas Votruba d34d554ada Updated Rector to commit 58abec4c5663a5d92ac6cd0a2eef6aace80ab408
58abec4c56 [automated] Apply Coding Standard (#5665)
2024-02-27 11:28:02 +00:00
Tomas Votruba a958e6bf2a Updated Rector to commit 58abec4c5663a5d92ac6cd0a2eef6aace80ab408
58abec4c56 [automated] Apply Coding Standard (#5665)
2024-02-26 11:06:03 +00:00
Tomas Votruba 3240f9e962 Updated Rector to commit 58abec4c5663a5d92ac6cd0a2eef6aace80ab408
58abec4c56 [automated] Apply Coding Standard (#5665)
2024-02-25 00:28:21 +00:00
Tomas Votruba 740fedd8a5 Updated Rector to commit 74a7c51d383b8ad5c6adb10cd67fe5f7f8ff290d
74a7c51d38 [automated] Re-Generate Nodes/Rectors Documentation (#5664)
2024-02-25 00:28:09 +00:00
Tomas Votruba b02be823eb Updated Rector to commit b6f5a0392d90d8f8b7f6fc42db896fdc3562d2d8
b6f5a0392d [Php83] add type to final class constant (#5662)
2024-02-24 01:20:55 +00:00
Tomas Votruba cd427d527e Updated Rector to commit 3ef3e35c45970bce4000f45f9c1cb651f078c5a0
3ef3e35c45 [Php71] Skip re-assign as string on AssignArrayToStringRector part 2 (#5661)
2024-02-23 19:28:49 +00:00
Tomas Votruba dcd788c4dd Updated Rector to commit 2d1f468bc6e41bc84dc273c8ac94033b60761a76
2d1f468bc6 [Privatization] Skip with suffix "TestCase" on FinalizeTestCaseClassRector (#5660)
2024-02-23 13:06:33 +00:00
Tomas Votruba 94501442a5 Updated Rector to commit d754bec5f11ce2d37928901c6998e1cc62e6f20d
d754bec5f1  [Php71] Skip re-assign as string on AssignArrayToStringRector  (#5659)
2024-02-23 10:03:16 +00:00
Tomas Votruba 5f3655eae9 Updated Rector to commit f5a45a5aeb6e5e1264d546e55dbd8880046b36ce
f5a45a5aeb [BetterPhpDocParser] Clean up unnecessary create new ConstFetchNode() on ArrayItemClassNameDecorator (#5658)
2024-02-22 14:12:04 +00:00
Tomas Votruba c0bc2824b0 Updated Rector to commit b9ea5fd9961997cecbd872cb345e88de582d6aca
b9ea5fd996 [PostRector] Skip remove use statement on used in annotation on removeUnusedImports() (#5657)
2024-02-22 12:50:50 +00:00
Tomas Votruba e08ae92529 Updated Rector to commit fb312e00c38b17b096a7257151a4ec0571cd8607
fb312e00c3 [PHPStanStaticTypeMapper] Avoid double \ prefix on IntersectionTypeMapper (#5656)
2024-02-22 10:08:06 +00:00
Tomas Votruba 5c2a81061c Updated Rector to commit 18a8aecd13cbe87766c38de95dcba08673493d3a
18a8aecd13 [TypeDeclaration] Adds AddParamTypeForFunctionLikeWithinCallLikeArgDeclarationRector rule (#5547)
2024-02-22 09:09:42 +00:00
Tomas Votruba 08cec1591e Updated Rector to commit 4951accb91a39af88d3903930112f2752e497076
4951accb91 [Renaming] New Rule: RenameFunctionLikeParamWithinCallLikeArgRector (#5554)
2024-02-22 09:08:40 +00:00
Tomas Votruba adbf03fcec Updated Rector to commit f9b3312035a4e5baee7105b19715d057587e1f59
f9b3312035 [TypeDeclaration] Include MockObject&ClassName docblock with IntersectionTypeNode on TypedPropertyFromStrictSetUpRector (#5655)
2024-02-22 08:46:08 +00:00
Tomas Votruba e8568e6d97 Updated Rector to commit 8038ee15844b7753e5698bd42b62669d9ebca12b
8038ee1584 [TypeDeclaration] Skip possible returns false on ReturnTypeFromStrictNewArrayRector (#5654)
2024-02-21 20:27:59 +00:00
Tomas Votruba 9ae89c0674 Updated Rector to commit 6095e3216f057fbf8dded18cf982bfab034f8086
6095e3216f  [TypeDeclaration] Allow abs() to return int when pass int arg on ReturnTypeFromStrictTypedCallRector (#5653)
2024-02-21 19:55:12 +00:00
Tomas Votruba 283153802a Updated Rector to commit 99a79f8df18f4202f7c939b7996b9714abb78fe4
99a79f8df1 [TypeDeclaration] Fix abs() returns on ReturnTypeFromStrictTypedCallRector (#5652)
2024-02-21 16:18:55 +00:00
Tomas Votruba dc98feb11d Updated Rector to commit 290926cc8b93331dd715d7ea061847dafbc1821a
290926cc8b  [Util] Make consistent new line splitter to Util  (#5651)
2024-02-21 15:30:52 +00:00
Tomas Votruba d7100344be Updated Rector to commit 7e741fee0551af70bb6b3f45c95905fdf9d618ce
7e741fee05 Keep comments in annotations when converting them to attributes (#5650)
2024-02-21 15:17:39 +00:00
Tomas Votruba 194c0359f1 Updated Rector to commit a4445df500e51deb893319e180c3fbdf64e8dc25
a4445df500 Cleanup scope check on UnreachableStatementNodeVisitor (#5648)
2024-02-21 08:05:42 +00:00
Tomas Votruba c6cecac9f8 Updated Rector to commit 3b44873d14db5c15a33147bc6aa395e95ec17def
3b44873d14 [Renaming] Handle crash on RenameFunctionRector with die() and $_SESSION part 2 (#5647)
2024-02-21 07:47:43 +00:00
Tomas Votruba 4461c6c31d Updated Rector to commit 00876daa5dbda14d26b36b8c4365362b7e1cb7ac
00876daa5d [Renaming] Handle crash on RenameFunctionRector with die() and $_SESSION usage (#5646)
2024-02-20 20:26:25 +00:00
Tomas Votruba bf8ee68288 Updated Rector to commit 29562ce48e265fbd75bf13df5e6662af76a44846
29562ce48e [VendorLocker] Early return false on private method on ParentClassMethodTypeOverrideGuard::hasParentClassMethod() (#5644)
2024-02-20 19:00:33 +00:00
Tomas Votruba 7569719db8 Updated Rector to commit 381ecb376283095a82809fd319eae0cfd237165a
381ecb3762 Fix future note (#5643)
2024-02-20 16:24:11 +00:00
Tomas Votruba 1281d2f6ab Updated Rector to commit 522668e4edce544bcb17ba3d71182629df19fd95
522668e4ed [Performance] [VendorLocker] Early allow change return type on private method on ClassMethodReturnTypeOverrideGuard::shouldSkipClassMethod() (#5642)
2024-02-20 16:01:20 +00:00
Tomas Votruba c2f97b2f3a Updated Rector to commit 23179d00859ca75e0b2e1ceff61bba93a9558806
23179d0085 [Transform] Allow transform fileExtensions() to withFileExtensions() (#5641)
2024-02-20 15:50:51 +00:00
Tomas Votruba 7105619218 Updated Rector to commit 70b1985921960bb02afbbfe16870bee2605e43b3
70b1985921 [Transform] Allow transform disableParallel() to withoutParallel() on RectorConfigBuilderRector (#5640)
2024-02-20 14:56:13 +00:00
Tomas Votruba 8cf7f785b6 Updated Rector to commit 3eb1aa2fe0b96e96f4f56fae720159107f57e4ae
3eb1aa2fe0 move strict bool and direct returns, as safer (#5639)
2024-02-20 00:02:15 +00:00
Tomas Votruba e68f6c257d Updated Rector to commit f107b4c82435c69068a7bb93aadaa288952e9901
f107b4c824 [Rector] Allow transform sets() to withSets() on RectorConfigBuilderRector (#5638)
2024-02-19 16:14:10 +00:00
Tomas Votruba a8232e0579 Updated Rector to commit d5c3fc753e321db315a8205ce5853ccf878b9f1e
d5c3fc753e [Transform] Allow transform ruleWithConfiguration() to withConfiguredRule() on RectorConfigBuilderRector (#5637)
2024-02-19 13:23:36 +00:00
Tomas Votruba d9e08f8aaf Updated Rector to commit a3d23752b85be3fbff187337ccbe461a4fe10f74
a3d23752b8 [DX] Add error message information for include full path to load internal phpstan bleedingEdge.neon config (#5635)
2024-02-18 19:27:49 +00:00
Tomas Votruba 35b646559b Updated Rector to commit 914349ca92cb1df4463b46f541c6e249045bd4ca
914349ca92 [CodeQuality] Skip not autoloaded parent class on CompleteDynamicPropertiesRector (#5636)
2024-02-18 18:32:48 +00:00
Tomas Votruba 6c843cb4e4 Updated Rector to commit 287deb27d125f599680faab4fec715dad4e61feb
287deb27d1 [PHPStan] Clean up ignore errors (#5634)
2024-02-18 15:45:54 +00:00
Tomas Votruba b3c461facb Updated Rector to commit a8d0dbeb7191d57af0ac9068adf644730f728c83
a8d0dbeb71 Add const fetch to class const fetch rector. (#5627)
2024-02-18 09:11:32 +00:00
Tomas Votruba 2f5015d654 Updated Rector to commit a4f28525c9df28ed142eabe1cde70035715fa785
a4f28525c9 [Transform] Allow transform bootstrapFiles() to withBootstrapFiles() on RectorConfigBuilderRector (#5633)
2024-02-18 00:33:46 +00:00
Tomas Votruba abeac2bdf6 Updated Rector to commit 85aba8e39f1fdf533680074accd34ab2c1ad8fc4
85aba8e39f [automated] Apply Coding Standard (#5632)
2024-02-18 00:28:38 +00:00
Tomas Votruba 30b36b6a9d Updated Rector to commit b621800bef5b820ef28b3d90d670b3f644e0c808
b621800bef [Transform] Allow transform autoloadPaths() to withAutoloadPaths() on RectorConfigBuilderRector (#5630)
2024-02-18 00:23:41 +00:00
Tomas Votruba 476bd88e73 Updated Rector to commit a533e70fca40571ab9504fbb857205b2be2eccb6
a533e70fca [Php80] Add DoctrineCoverterterAttributeDecorator to convert "false"/"true" string to false/true on nullable arg on Doctrine\ORM\Mapping\Column (#5629)
2024-02-17 10:59:16 +00:00
Tomas Votruba 531af37084 Updated Rector to commit 2ccf2dedae865100f20bd8fb649625cabb0e4ed3
2ccf2dedae Add basic validation for skipped path (#5628)
2024-02-16 22:00:46 +00:00
Tomas Votruba 95d40d3a99 Updated Rector to commit f347c7301fcfcb4cda2b61bb4b359ed01cee7070
f347c7301f Add method RectorConfigBuilder::withSkipPath() (#5626)
2024-02-16 19:08:11 +00:00
Tomas Votruba f1e807548e Updated Rector to commit 7cd56d864dc52f88416c47845239ad897467a003
7cd56d864d RectorConfigBuilder: skip and rules can be called multiple times (#5623)
2024-02-16 16:38:11 +00:00
Tomas Votruba 7a0ac36084 Updated Rector to commit d0f0e9737dc3b7e9c39ef3b6e72a9f62aa0c7d67
d0f0e9737d Add minimal memory limit for local run phpstan without result cache (#5624)
2024-02-16 16:37:54 +00:00
Tomas Votruba 718d430b73 Updated Rector to commit f8ebe9b56b60f2cea6f5a0f6042aa8a2c844961a
f8ebe9b56b Update PHP version in CONTRIBUTING.md (#5625)
2024-02-16 16:33:51 +00:00
Tomas Votruba 0d8881ecb3 Updated Rector to commit 39d9c321b99b58ebe32131f08e42cfa4b517ed79
39d9c321b9 [Php83] Early check private method in child before check parent on AddOverrideAttributeToOverriddenMethodsRector (#5622)
2024-02-16 14:42:02 +00:00
Tomas Votruba 258b775511 Rector 1.0.1 2024-02-16 07:53:23 +00:00
Tomas Votruba faf7fee8e4 Updated Rector to commit c4dd05e2e3ae6359ff4eb57ce7d7bd7619da139d
c4dd05e2e3 [CodeQuality] Add StaticToSelfStaticMethodCallOnFinalClassRector (#5621)
2024-02-15 14:52:20 +00:00
Tomas Votruba 6ef7f81fc3 Updated Rector to commit c4dd05e2e3ae6359ff4eb57ce7d7bd7619da139d
c4dd05e2e3 [CodeQuality] Add StaticToSelfStaticMethodCallOnFinalClassRector (#5621)
2024-02-15 12:52:16 +00:00
Tomas Votruba 53742c371b Updated Rector to commit 70fa502a59dfb8f81011a46a456e1ccb4051be76
70fa502a59 [CodeQuality] Skip private static call from static:: on LocallyCalledStaticMethodToNonStaticRector (#5620)
2024-02-15 09:08:32 +00:00
Tomas Votruba b0b2790db0 Updated Rector to commit 4a3137cf6e5d0e0e71ee93e6f9b82ae9726603e6
4a3137cf6e remove cached fixture
2024-02-14 19:46:39 +00:00
Tomas Votruba 8e5eb93b0b Updated Rector to commit 4a3137cf6e5d0e0e71ee93e6f9b82ae9726603e6
4a3137cf6e remove cached fixture
2024-02-14 19:38:02 +00:00
Tomas Votruba 055cd31f66 Updated Rector to commit 2ff0f08bd7f7f6c848821bcabf0872f81a9c440b
2ff0f08bd7 [PHP 8.0] Add always class to AnnotationToAttribute to include string to ::class reference conversion (#5619)
2024-02-14 19:28:57 +00:00
Tomas Votruba a022b931b8 Updated Rector to commit 435d125053eed8764652ccf8565bde1660ee08ce
435d125053 Move StrictArrayParamDimFetchRector and StrictStringParamConcatRector to last rules on TypeDeclarationLevel (#5618)
2024-02-14 14:40:00 +00:00
Tomas Votruba 51ddee6f5c Updated Rector to commit d62be327173447695dea93ff52d67d087d9fb9d4
d62be32717 [DX] Accept Y/y for confirmation of init config (#5616)
2024-02-14 09:09:41 +00:00
Tomas Votruba 64ecb6b387 Updated Rector to commit 82d1e1b0c8b80d7a2f30aa4b0fa988a683427db9
82d1e1b0c8 [Php81] Handle nested Fqcn UniqueConstraint on NestedAnnotationToAttributeRector (#5614)
2024-02-13 14:47:21 +00:00
Tomas Votruba d85a9f8be0 Updated Rector to commit 539cfeb35c55cec4b2b5b20045cfdc4a437728f4
539cfeb35c [BetterPhpDocParser] Move split new line with @\ to regex to support windows new line (#5615)
2024-02-13 10:48:33 +00:00
Tomas Votruba adf6cdfc87 Updated Rector to commit 95f9772f17b436fce469f68b1ed09445131235ee
95f9772f17 [Php81] Handle after open parentheses on AnnotationToAttributeRector (#5613)
2024-02-13 05:08:05 +00:00
Tomas Votruba b9e54635e9 Updated Rector to commit 7afec9a02c39848257341c4d2d08e1ddf52bc58b
7afec9a02c Add unique PHP 8.1 constraints (#5612)
2024-02-13 04:45:07 +00:00
Tomas Votruba f863e8b003 Updated Rector to commit 7de77e518f7b47b7c7ba0d96152d4acdad958639
7de77e518f [TypeDeclaration] Add AddTestsVoidReturnTypeWhereNoReturnRector (#5611)
2024-02-12 22:55:41 +00:00
Tomas Votruba 1bea0c9d65 Updated Rector to commit 48e8cfab19f5572f6419876a8f5cec0109966862
48e8cfab19 [Php80] Support windows new line line DoctrineAnnotationDecorator::LONG_ANNOTATION_REGEX (#5610)
2024-02-12 17:05:47 +00:00
Tomas Votruba c64634c7d7 Updated Rector to commit 48e8cfab19f5572f6419876a8f5cec0109966862
48e8cfab19 [Php80] Support windows new line line DoctrineAnnotationDecorator::LONG_ANNOTATION_REGEX (#5610)
2024-02-12 16:56:09 +00:00
Tomas Votruba 37b8c7c87c Updated Rector to commit 48e8cfab19f5572f6419876a8f5cec0109966862
48e8cfab19 [Php80] Support windows new line line DoctrineAnnotationDecorator::LONG_ANNOTATION_REGEX (#5610)
2024-02-12 16:03:52 +00:00
Tomas Votruba d1ca847d5b Updated Rector to commit 48e8cfab19f5572f6419876a8f5cec0109966862
48e8cfab19 [Php80] Support windows new line line DoctrineAnnotationDecorator::LONG_ANNOTATION_REGEX (#5610)
2024-02-12 15:59:12 +00:00
Tomas Votruba 1d666f3abf Updated Rector to commit 6dd91df6c991f7f0d5cd8422fc22be1367563262
6dd91df6c9 [PHP 8.0] Fix annotation to attribute in case of FQN class without () (#5609)
2024-02-12 15:41:50 +00:00
Tomas Votruba a120574816 Updated Rector to commit 14eb72c7bb6edc4a6e80c73c722f54465d947531
14eb72c7bb [DeadCode] Handle used in assign return on RemoveUnusedPrivatePropertyRector (#5608)
2024-02-12 14:51:52 +00:00
Tomas Votruba 360f068804 Updated Rector to commit 5edb023974a55b0efee74dd9fe92b314dd521f2c
5edb023974 fix config for configured rule
2024-02-12 13:17:09 +00:00
Tomas Votruba 7cbf0706f9 Updated Rector to commit 5edb023974a55b0efee74dd9fe92b314dd521f2c
5edb023974 fix config for configured rule
2024-02-12 10:19:39 +00:00
Tomas Votruba 18992ab52d Updated Rector to commit 5edb023974a55b0efee74dd9fe92b314dd521f2c
5edb023974 fix config for configured rule
2024-02-12 09:34:34 +00:00
Tomas Votruba ae1e3ab8ca Updated Rector to commit 5edb023974a55b0efee74dd9fe92b314dd521f2c
5edb023974 fix config for configured rule
2024-02-12 09:14:26 +00:00
Tomas Votruba b2e06f0820 Updated Rector to commit 5edb023974a55b0efee74dd9fe92b314dd521f2c
5edb023974 fix config for configured rule
2024-02-12 09:01:02 +00:00
Tomas Votruba a14ff93dec Updated Rector to commit 5dd8a4b14f4f4d2717565b41da544775a61e350c
5dd8a4b14f remove duplicated line
2024-02-12 08:59:42 +00:00
Tomas Votruba 06f50472a3 Updated Rector to commit 6c7dbaad0ab67dd06cef9237fab3728ae4f23e9a
6c7dbaad0a config method must be static, to avoid creating rule before loading related ctor services (#5606)
2024-02-12 08:57:06 +00:00
Tomas Votruba b8be29526e Updated Rector to commit 62ba91690bda77bfa41075d5dda3d0487a869580
62ba91690b [internal] Add RelatedConfigInterface to load external services (#5605)
2024-02-12 08:46:32 +00:00
Tomas Votruba de79e08a92 Updated Rector to commit 8d524d4c3b4a8b506d558eec23caf1923e59bb81
8d524d4c3b [PostRector] Skip remove unused imports on used in multiple docs in single node (#5604)
2024-02-12 08:46:12 +00:00
Tomas Votruba 12e1b38e32 Updated Rector to commit df8d2b78edd46542e6426fec606c3ea98d712532
df8d2b78ed Copy subtype phpdoc on ClassPropertyAssignToConstructorPromotionRector (#8438) (#5603)
2024-02-11 23:33:46 +00:00
Tomas Votruba 1d69b60457 Updated Rector to commit df8d2b78edd46542e6426fec606c3ea98d712532
df8d2b78ed Copy subtype phpdoc on ClassPropertyAssignToConstructorPromotionRector (#8438) (#5603)
2024-02-11 21:30:56 +00:00
Tomas Votruba 69e22c50fb Updated Rector to commit df8d2b78edd46542e6426fec606c3ea98d712532
df8d2b78ed Copy subtype phpdoc on ClassPropertyAssignToConstructorPromotionRector (#8438) (#5603)
2024-02-11 20:35:45 +00:00
Tomas Votruba 7f9bb2ae80 Updated Rector to commit df8d2b78edd46542e6426fec606c3ea98d712532
df8d2b78ed Copy subtype phpdoc on ClassPropertyAssignToConstructorPromotionRector (#8438) (#5603)
2024-02-11 09:00:00 +00:00
Tomas Votruba 1e3b11c5e1 Updated Rector to commit 6980dc63c77d0214730c94e0c620fa729047f879
6980dc63c7 [PHPStan] clean up ignore phpstan errors (#5601)
2024-02-11 08:18:05 +00:00
Tomas Votruba 6f6fad7878 Updated Rector to commit 333f38ba4e1923e92cb2032b64363d1b170e842c
333f38ba4e [automated] Apply Coding Standard (#5600)
2024-02-11 00:29:29 +00:00
Tomas Votruba 74eb099cdd Updated Rector to commit f4c674c08210069b766058f035c1a41e833de167
f4c674c082 [automated] Re-Generate Nodes/Rectors Documentation (#5599)
2024-02-11 00:28:51 +00:00
Tomas Votruba 3899caefbf Updated Rector to commit fbc391aa82a629f07f432860b146e617156a48e3
fbc391aa82 No need normalize cwd() as only need strlen() on VendorMissAnalyseGuard (#5598)
2024-02-10 13:48:41 +00:00
Tomas Votruba f2b6b79e92 Updated Rector to commit 6d408f520f1766ba4450d057e6e10c0ffbfa9275
6d408f520f [Performance] Use strlen() early before loop on VendorMissAnalyseGuard (#5597)
2024-02-10 13:42:27 +00:00
Tomas Votruba 54904b716f Updated Rector to commit 77ec96e4e8ec9e3a1d514df878e6eadcd199feb8
77ec96e4e8 [Transform] Allow class const fetch value on rules() on RectorConfigBuilderRector (#5596)
2024-02-10 13:37:38 +00:00
Tomas Votruba 7004efd93b Updated Rector to commit 7e637860a069b8ef0f54360664b722578306b994
7e637860a0 [Config] Use RectorConfig::configure() on rules-tests (#5594)
2024-02-10 05:02:47 +00:00
Tomas Votruba 5e3115386a Updated Rector to commit fbbdd50c6214af5a0bd2b9ff3ba3766ca717cf1a
fbbdd50c62 [Config] Use RectorConfig::configure() on tests (#5593)
2024-02-10 05:01:44 +00:00
Tomas Votruba f63718b5ba Updated Rector to commit 2b913ac43c2f4031153ceb91867ef6ea44abe0db
2b913ac43c [Config] Use RectorConfig::configure() on build/config/config-downgrade.php (#5595)
2024-02-09 21:08:27 +00:00
Tomas Votruba b9b210cd79 Updated Rector to commit 8f993b57a88d299f57461169803ddfdab886a892
8f993b57a8 Update 1_Bug_report.md to use version 1.0.0 (#5592)
2024-02-09 16:49:04 +00:00
Tomas Votruba bbbbb87f7d Updated Rector to commit 88a27f43efbcdf7004b6f7b2a6c6255cc81b6fff
88a27f43ef [Config] Add registerService() method to allow container extension (#5591)
2024-02-09 12:02:07 +00:00
Tomas Votruba 5d5a36456b Updated Rector to commit 76504227a46a540c8736759103478db2459ec5ca
76504227a4 Clean up parallel-lint exclude on downgrade build (#5590)
2024-02-09 11:42:47 +00:00
Tomas Votruba a0a66ea1c7 Updated Rector to commit 76504227a46a540c8736759103478db2459ec5ca
76504227a4 Clean up parallel-lint exclude on downgrade build (#5590)
2024-02-09 08:58:21 +00:00
Tomas Votruba 3f928476d9 Updated Rector to commit 2c65489cfd178fbd0e4d2b52b504a7541e34bc59
2c65489cfd [Php81] Skip another possible cast array to string on NullToStrictStringFuncCallArgRector (#5589)
2024-02-09 08:50:13 +00:00
Tomas Votruba e32eadddc1 Updated Rector to commit a43f041278835523c96758f6df5d0e964e51ee9d
a43f041278  [DeadCode] Skip sub type false => bool on RemoveUselessVarTagRector  (#5588)
2024-02-09 08:11:26 +00:00
Tomas Votruba e5f35d1a39 Updated Rector to commit 178ce5c65a820a5c42c7928486a044b44a976436
178ce5c65a  [Php81] Skip possible array on NullToStrictStringFuncCallArgRector  (#5587)
2024-02-08 13:13:45 +00:00
Tomas Votruba 512a9f7130 Updated Rector to commit 2194c6eec73db88500a42b2f443ca6c022b7d6a1
2194c6eec7 [NodeTypeResolver] Ignore PHPStan internal error on PHPStanNodeScopeResolver on NodeScopeResolver::processNodes() (#5586)
2024-02-08 07:30:40 +00:00
Tomas Votruba 831bb7a9f7 Updated Rector to commit 2aa1c38988c58fda5ae04a5b27fad255eaa2b141
2aa1c38988 Fix undefined MHASH_* constant on running downgrade from php 8.0 (#5585)
2024-02-08 05:40:02 +00:00
Tomas Votruba e79510ae2b Updated Rector to commit 0d55791128825909273d0cdd9743470236748d75
0d55791128 Fix downgrade build: exclude vendor/symplify/easy-parallel/ecs.php on parallel lint (#5584)
2024-02-08 04:24:11 +00:00
Tomas Votruba dfd0ac8201 Updated Rector to commit 1a3ddfb9a41b2b7230a9fb8f26eb075d3a1c6c38
1a3ddfb9a4 [DX] Remove type covarege, as handled by phpstan itself (#5583)
2024-02-07 23:07:13 +00:00
Tomas Votruba e6361d01dc Updated Rector to commit c99f335e2513718afc8623bfba3902ef887e9083
c99f335e25 Remove deprecated FileInfoParser (#5581)
2024-02-07 22:53:20 +00:00
Tomas Votruba a1bb85c575 Updated Rector to commit ff8f0c19f83a3e82c74ba47cd34abe37c2d99c8b
ff8f0c19f8 [DX] Remove lines packages as not used, remove deprecations as not used (#5580)
2024-02-07 22:52:04 +00:00
Tomas Votruba dad2c8e74c Updated Rector to commit 68dc0efd77d35371caceb7a7c5772b2ea5aa4045
68dc0efd77 [DX] Remove phpstan strict rules to ease contributing (#5579)
2024-02-07 22:40:22 +00:00
Tomas Votruba 80c79c976b Updated Rector to commit 4570438319ff69196c28b13fad1e3567ca7bd1e5
4570438319 [Config] Make sure only one of type-declaration/dead-code or with*Level() is used to avoid duplicates (#5578)
2024-02-07 21:49:03 +00:00
Tomas Votruba 7bb5d0c0c4 Updated Rector to commit 5b3d656a003e72540050d47e00285341a96b5796
5b3d656a00 [Custom] Add "detect-node" command to help with writing custom rules (#5576)
2024-02-07 16:28:52 +00:00
Tomas Votruba af18c3962f Updated Rector to commit 667983116e7c8ec828a0b9b1877f90e4faf532e0
667983116e [Transform] Transform skip() to withSkip() on RectorConfigBuilderRector (#5575)
2024-02-07 13:22:56 +00:00
Tomas Votruba 0d0320e989 Updated Rector to commit 5a5ea60f6dffdd0a63e04a64f8061f53facd46b3
5a5ea60f6d [Transform] Transform paths() to withPaths() on RectorConfigBuilderRector (#5574)
2024-02-07 13:11:49 +00:00
Tomas Votruba ed0dadf714 Updated Rector to commit bd37496639378be3e1b72dec430ef906f0a6e94d
bd37496639 [DeadCode] Skip with magic __get() on RemoveUnusedPromotedPropertyRector (#5573)
2024-02-07 12:31:25 +00:00
Tomas Votruba 914c0a8e27 Updated Rector to commit af4d3db31bacab922d47b2551cec66644e3568b7
af4d3db31b [PHP81] Skip after is_string on object call on NullToStrictStringFuncCallArgRector (#5572)
2024-02-07 10:34:12 +00:00
Tomas Votruba 4483663a95 Updated Rector to commit a76ec2921c0202da145386cb2052f82952c34900
a76ec2921c Fix missing / suffix on VendorMissAnalyseGuard (#5571)
2024-02-07 00:44:34 +00:00
Tomas Votruba 9d4b461bdb Updated Rector to commit 5bf03c420e523f365ccc67eebb3f045e854caf55
5bf03c420e [Configuration] Fix detect /vendor on root project on vendor analyzed on VendorMissAnalyseGuard (#5569)
2024-02-07 00:22:31 +00:00
Tomas Votruba 1cd18a76ae Updated Rector to commit 6fe258536fc4a7fb903bea8eef548d37e1de8df5
6fe258536f Fix ArrayTypeMapper to handle arrays with UnionType items (#8225) (#5568)
2024-02-06 22:54:23 +00:00
Tomas Votruba c65d65d663 Updated Rector to commit 7976482b3b067758fc88b000794e8cb94a4b2389
7976482b3b ExplicitBoolCompareRector: skip phpdoc (#5567)
2024-02-06 14:37:09 +00:00
Tomas Votruba 362258a1f6 Rector 1.0.0 2024-02-06 13:38:07 +00:00
Tomas Votruba 64d401b643 Updated Rector to commit 9a44c19598a21aff4b6b38f9a0db3b5ca30337c6
9a44c19598 [Transform] Transform rules() to withRules() on RectorConfigBuilderRector (#5566)
2024-02-06 06:23:36 +00:00
Tomas Votruba 428336c22c Updated Rector to commit 09398c3d4f07bb6ad664a55b87cab955278a467e
09398c3d4f Decouple AddFunctionVoidReturnTypeWhereNoReturnRector to allow leveling by simple node first (#5563)
2024-02-05 16:07:43 +00:00
Tomas Votruba d00ebb838c Updated Rector to commit 56c250771518c2aa2e17bc64c9986c2dbe9b6fd8
56c2507715 Decouple AddClosureVoidReturnTypeWhereNoReturnRector to allow leveling by simple node first (#5562)
2024-02-05 15:56:19 +00:00
Tomas Votruba de3b3bb159 Rector 0.19.8 2024-02-05 10:59:13 +00:00
Tomas Votruba a5294370bd Updated Rector to commit c44e1e57dece206f94cd5896000750172ead0272
c44e1e57de Real fix paths The given paths do not match any files on RectorConfigBuilder (#5561)
2024-02-05 10:43:38 +00:00
Tomas Votruba 8be4b973f1 Updated Rector to commit c0079e3824d81ca2bd1a4b430c06acec4a5ef731
c0079e3824 Rollback RectorConfig::configure()->withRules() on privatization config set to old style config (#5560)
2024-02-05 09:59:39 +00:00
Tomas Votruba 7810dc2e74 Updated Rector to commit 487f162d53fe42f6d76557ca6cd49d93ceb911e8
487f162d53 [experimental] Add withTypeCoverageLevel() method to streamline Rector integration to new projects (#5553)
2024-02-05 08:01:59 +00:00
Tomas Votruba ad50de3844 Updated Rector to commit 70f10cb70dddf660c3b26f0e93e83248e0a07adb
70f10cb70d Cache null result on ProjectComposerJsonPhpVersionResolver (#5559)
2024-02-04 23:31:45 +00:00
1335 changed files with 18454 additions and 8048 deletions

View File

@ -10,7 +10,7 @@ about: Report errors and problems
| Subject | Details |
| :------------- | :---------------------------------------------------------------|
| Rector version | e.g. v0.19.5 (invoke `vendor/bin/rector --version`) |
| Rector version | e.g. v1.0.0 (invoke `vendor/bin/rector --version`) |
<!-- Please describe your problem here. -->

View File

@ -11,7 +11,7 @@ git clone git@github.com:<your-name>/rector-src.git
cd rector-src
```
2. We use PHP 8.1 and composer
2. We use PHP 8.2 and composer
Install dependencies and verify your local environment:

View File

@ -43,19 +43,18 @@ And modify it:
```php
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\SetList;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;
return static function (RectorConfig $rectorConfig): void {
return RectorConfig::configure()
// register single rule
$rectorConfig->rule(TypedPropertyFromStrictConstructorRector::class);
// here we can define, what sets of rules will be applied
// tip: use "SetList" class to autocomplete sets with your IDE
$rectorConfig->sets([
SetList::CODE_QUALITY
]);
};
->withRules([
TypedPropertyFromStrictConstructorRector::class
])
// here we can define, what prepared sets of rules will be applied
->withPreparedSets(
deadCode: true,
codeQuality: true
);
```
Then dry run Rector:
@ -102,6 +101,7 @@ Among there projects belong:
* [cakephp/upgrade](https://github.com/cakephp/upgrade)
* [driftingly/rector-laravel](https://github.com/driftingly/rector-laravel)
* [contao/contao-rector](https://github.com/contao/contao-rector)
* [php-static-analysis/rector-rule](https://github.com/php-static-analysis/rector-rule)
<br>

View File

@ -2,14 +2,14 @@
// this is part of downgrade build
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use RectorPrefix202402\Nette\Utils\FileSystem;
use RectorPrefix202402\Nette\Utils\Json;
use RectorPrefix202405\Nette\Utils\FileSystem;
use RectorPrefix202405\Nette\Utils\Json;
require __DIR__ . '/../vendor/autoload.php';
$composerJsonFileContents = FileSystem::read(__DIR__ . '/../composer.json');
$composerJson = Json::decode($composerJsonFileContents, Json::FORCE_ARRAY);
$composerJson = Json::decode($composerJsonFileContents, \true);
$composerJson['replace']['phpstan/phpstan'] = $composerJson['require']['phpstan/phpstan'];
$modifiedComposerJsonFileContents = Json::encode($composerJson, Json::PRETTY);
$modifiedComposerJsonFileContents = Json::encode($composerJson, \true);
FileSystem::write(__DIR__ . '/../composer.json', $modifiedComposerJsonFileContents, null);
echo 'Done!' . \PHP_EOL;

View File

@ -1,5 +1,5 @@
#!/usr/bin/env php
<?php
namespace RectorPrefix202402;
namespace RectorPrefix202405;
require_once __DIR__ . '/rector.php';

View File

@ -1,9 +1,9 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use RectorPrefix202402\Nette\Utils\Json;
use RectorPrefix202405\Nette\Utils\Json;
use Rector\Bootstrap\RectorConfigsResolver;
use Rector\ChangesReporting\Output\JsonOutputFormatter;
use Rector\Configuration\Option;
@ -11,9 +11,9 @@ use Rector\Console\Style\SymfonyStyleFactory;
use Rector\DependencyInjection\LazyContainerFactory;
use Rector\DependencyInjection\RectorContainerFactory;
use Rector\Util\Reflection\PrivatesAccessor;
use RectorPrefix202402\Symfony\Component\Console\Application;
use RectorPrefix202402\Symfony\Component\Console\Command\Command;
use RectorPrefix202402\Symfony\Component\Console\Input\ArgvInput;
use RectorPrefix202405\Symfony\Component\Console\Application;
use RectorPrefix202405\Symfony\Component\Console\Command\Command;
use RectorPrefix202405\Symfony\Component\Console\Input\ArgvInput;
// @ intentionally: continue anyway
@\ini_set('memory_limit', '-1');
// Performance boost
@ -93,7 +93,7 @@ final class AutoloadIncluder
require_once $filePath;
}
}
\class_alias('RectorPrefix202402\\AutoloadIncluder', 'AutoloadIncluder', \false);
\class_alias('RectorPrefix202405\\AutoloadIncluder', 'AutoloadIncluder', \false);
if (\file_exists(__DIR__ . '/../preload.php') && \is_dir(__DIR__ . '/../vendor')) {
require_once __DIR__ . '/../preload.php';
}

View File

@ -8,7 +8,7 @@
],
"require": {
"php": "^7.2|^8.0",
"phpstan/phpstan": "^1.10.56"
"phpstan/phpstan": "^1.11"
},
"autoload": {
"files": [
@ -22,5 +22,8 @@
"rector/rector-downgrade-php": "*"
},
"minimum-stability": "dev",
"prefer-stable": true
"prefer-stable": true,
"suggest": {
"ext-dom": "To manipulate phpunit.xml via the custom-rule command"
}
}

View File

@ -1,9 +1,9 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use RectorPrefix202402\OndraM\CiDetector\CiDetector;
use RectorPrefix202405\OndraM\CiDetector\CiDetector;
use Rector\Bootstrap\ExtensionConfigResolver;
use Rector\Caching\ValueObject\Storage\MemoryCacheStorage;
use Rector\Config\RectorConfig;
@ -31,4 +31,6 @@ return static function (RectorConfig $rectorConfig) : void {
foreach ($extensionConfigResolver->provide() as $extensionConfigFile) {
$rectorConfig->import($extensionConfigFile);
}
// use original php-parser printer to avoid BC break on fluent call
$rectorConfig->newLineOnFluentCall(\false);
};

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector;
use Rector\CodeQuality\Rector\Assign\CombinedAssignRector;
@ -12,7 +12,9 @@ use Rector\CodeQuality\Rector\BooleanNot\SimplifyDeMorganBinaryRector;
use Rector\CodeQuality\Rector\Catch_\ThrowWithPreviousExceptionRector;
use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector;
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\CodeQuality\Rector\Class_\StaticToSelfStaticMethodCallOnFinalClassRector;
use Rector\CodeQuality\Rector\ClassConstFetch\ConvertStaticPrivateConstantToSelfRector;
use Rector\CodeQuality\Rector\ClassMethod\ExplicitReturnNullRector;
use Rector\CodeQuality\Rector\ClassMethod\InlineArrayReturnAssignRector;
use Rector\CodeQuality\Rector\ClassMethod\LocallyCalledStaticMethodToNonStaticRector;
use Rector\CodeQuality\Rector\ClassMethod\OptionalParametersAfterRequiredRector;
@ -27,13 +29,10 @@ use Rector\CodeQuality\Rector\Foreach_\ForeachToInArrayRector;
use Rector\CodeQuality\Rector\Foreach_\SimplifyForeachToCoalescingRector;
use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector;
use Rector\CodeQuality\Rector\FuncCall\ArrayMergeOfNonArraysToSimpleArrayRector;
use Rector\CodeQuality\Rector\FuncCall\BoolvalToTypeCastRector;
use Rector\CodeQuality\Rector\FuncCall\CallUserFuncWithArrowFunctionToInlineRector;
use Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector;
use Rector\CodeQuality\Rector\FuncCall\CompactToVariablesRector;
use Rector\CodeQuality\Rector\FuncCall\FloatvalToTypeCastRector;
use Rector\CodeQuality\Rector\FuncCall\InlineIsAInstanceOfRector;
use Rector\CodeQuality\Rector\FuncCall\IntvalToTypeCastRector;
use Rector\CodeQuality\Rector\FuncCall\IsAWithStringWithThirdArgumentRector;
use Rector\CodeQuality\Rector\FuncCall\RemoveSoleValueSprintfRector;
use Rector\CodeQuality\Rector\FuncCall\SetTypeToCastRector;
@ -42,7 +41,6 @@ use Rector\CodeQuality\Rector\FuncCall\SimplifyInArrayValuesRector;
use Rector\CodeQuality\Rector\FuncCall\SimplifyRegexPatternRector;
use Rector\CodeQuality\Rector\FuncCall\SimplifyStrposLowerRector;
use Rector\CodeQuality\Rector\FuncCall\SingleInArrayToCompareRector;
use Rector\CodeQuality\Rector\FuncCall\StrvalToTypeCastRector;
use Rector\CodeQuality\Rector\FuncCall\UnwrapSprintfOneArgumentRector;
use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
use Rector\CodeQuality\Rector\Identical\BooleanNotIdenticalToNotIdenticalRector;
@ -110,5 +108,5 @@ return static function (RectorConfig $rectorConfig) : void {
'mbstrrpos' => 'mb_strrpos',
'mbsubstr' => 'mb_substr',
]);
$rectorConfig->rules([CombinedAssignRector::class, SimplifyEmptyArrayCheckRector::class, ReplaceMultipleBooleanNotRector::class, ForeachToInArrayRector::class, SimplifyForeachToCoalescingRector::class, SimplifyFuncGetArgsCountRector::class, SimplifyInArrayValuesRector::class, SimplifyStrposLowerRector::class, GetClassToInstanceOfRector::class, SimplifyArraySearchRector::class, SimplifyConditionsRector::class, SimplifyIfNotNullReturnRector::class, SimplifyIfReturnBoolRector::class, SimplifyUselessVariableRector::class, UnnecessaryTernaryExpressionRector::class, RemoveExtraParametersRector::class, SimplifyDeMorganBinaryRector::class, SimplifyTautologyTernaryRector::class, SingleInArrayToCompareRector::class, SimplifyIfElseToTernaryRector::class, JoinStringConcatRector::class, ConsecutiveNullCompareReturnsToNullCoalesceQueueRector::class, ExplicitBoolCompareRector::class, CombineIfRector::class, UseIdenticalOverEqualWithSameTypeRector::class, SimplifyBoolIdenticalTrueRector::class, SimplifyRegexPatternRector::class, BooleanNotIdenticalToNotIdenticalRector::class, StrvalToTypeCastRector::class, FloatvalToTypeCastRector::class, CallableThisArrayToAnonymousFunctionRector::class, AndAssignsToSeparateLinesRector::class, CompactToVariablesRector::class, CompleteDynamicPropertiesRector::class, IsAWithStringWithThirdArgumentRector::class, StrlenZeroToIdenticalEmptyStringRector::class, ThrowWithPreviousExceptionRector::class, RemoveSoleValueSprintfRector::class, ShortenElseIfRector::class, ArrayMergeOfNonArraysToSimpleArrayRector::class, IntvalToTypeCastRector::class, BoolvalToTypeCastRector::class, ArrayKeyExistsTernaryThenValueToCoalescingRector::class, AbsolutizeRequireAndIncludePathRector::class, ChangeArrayPushToArrayAssignRector::class, ForRepeatedCountToOwnVariableRector::class, ForeachItemsAssignToEmptyArrayToAssignRector::class, InlineIfToExplicitIfRector::class, UnusedForeachValueToArrayKeysRector::class, CommonNotEqualRector::class, SetTypeToCastRector::class, LogicalToBooleanRector::class, VarToPublicPropertyRector::class, IssetOnPropertyObjectToPropertyExistsRector::class, NewStaticToNewSelfRector::class, UnwrapSprintfOneArgumentRector::class, SwitchNegatedTernaryRector::class, SingularSwitchToIfRector::class, SimplifyIfNullableReturnRector::class, FuncGetArgsToVariadicParamRector::class, CallUserFuncToMethodCallRector::class, CallUserFuncWithArrowFunctionToInlineRector::class, CountArrayToEmptyArrayComparisonRector::class, FlipTypeControlToUseExclusiveTypeRector::class, InlineArrayReturnAssignRector::class, InlineIsAInstanceOfRector::class, TernaryFalseExpressionToIfRector::class, InlineConstructorDefaultToPropertyRector::class, TernaryEmptyArrayArrayDimFetchToCoalesceRector::class, OptionalParametersAfterRequiredRector::class, SimplifyEmptyCheckOnEmptyArrayRector::class, SwitchTrueToIfRector::class, CleanupUnneededNullsafeOperatorRector::class, DisallowedEmptyRuleFixerRector::class, ConvertStaticPrivateConstantToSelfRector::class, LocallyCalledStaticMethodToNonStaticRector::class, NumberCompareToMaxFuncCallRector::class, CompleteMissingIfElseBracketRector::class, RemoveUselessIsObjectCheckRector::class]);
$rectorConfig->rules([CombinedAssignRector::class, SimplifyEmptyArrayCheckRector::class, ReplaceMultipleBooleanNotRector::class, ForeachToInArrayRector::class, SimplifyForeachToCoalescingRector::class, SimplifyFuncGetArgsCountRector::class, SimplifyInArrayValuesRector::class, SimplifyStrposLowerRector::class, GetClassToInstanceOfRector::class, SimplifyArraySearchRector::class, SimplifyConditionsRector::class, SimplifyIfNotNullReturnRector::class, SimplifyIfReturnBoolRector::class, SimplifyUselessVariableRector::class, UnnecessaryTernaryExpressionRector::class, RemoveExtraParametersRector::class, SimplifyDeMorganBinaryRector::class, SimplifyTautologyTernaryRector::class, SingleInArrayToCompareRector::class, SimplifyIfElseToTernaryRector::class, JoinStringConcatRector::class, ConsecutiveNullCompareReturnsToNullCoalesceQueueRector::class, ExplicitBoolCompareRector::class, CombineIfRector::class, UseIdenticalOverEqualWithSameTypeRector::class, SimplifyBoolIdenticalTrueRector::class, SimplifyRegexPatternRector::class, BooleanNotIdenticalToNotIdenticalRector::class, CallableThisArrayToAnonymousFunctionRector::class, AndAssignsToSeparateLinesRector::class, CompactToVariablesRector::class, CompleteDynamicPropertiesRector::class, IsAWithStringWithThirdArgumentRector::class, StrlenZeroToIdenticalEmptyStringRector::class, ThrowWithPreviousExceptionRector::class, RemoveSoleValueSprintfRector::class, ShortenElseIfRector::class, ExplicitReturnNullRector::class, ArrayMergeOfNonArraysToSimpleArrayRector::class, ArrayKeyExistsTernaryThenValueToCoalescingRector::class, AbsolutizeRequireAndIncludePathRector::class, ChangeArrayPushToArrayAssignRector::class, ForRepeatedCountToOwnVariableRector::class, ForeachItemsAssignToEmptyArrayToAssignRector::class, InlineIfToExplicitIfRector::class, UnusedForeachValueToArrayKeysRector::class, CommonNotEqualRector::class, SetTypeToCastRector::class, LogicalToBooleanRector::class, VarToPublicPropertyRector::class, IssetOnPropertyObjectToPropertyExistsRector::class, NewStaticToNewSelfRector::class, UnwrapSprintfOneArgumentRector::class, SwitchNegatedTernaryRector::class, SingularSwitchToIfRector::class, SimplifyIfNullableReturnRector::class, FuncGetArgsToVariadicParamRector::class, CallUserFuncToMethodCallRector::class, CallUserFuncWithArrowFunctionToInlineRector::class, CountArrayToEmptyArrayComparisonRector::class, FlipTypeControlToUseExclusiveTypeRector::class, InlineArrayReturnAssignRector::class, InlineIsAInstanceOfRector::class, TernaryFalseExpressionToIfRector::class, InlineConstructorDefaultToPropertyRector::class, TernaryEmptyArrayArrayDimFetchToCoalesceRector::class, OptionalParametersAfterRequiredRector::class, SimplifyEmptyCheckOnEmptyArrayRector::class, SwitchTrueToIfRector::class, CleanupUnneededNullsafeOperatorRector::class, DisallowedEmptyRuleFixerRector::class, ConvertStaticPrivateConstantToSelfRector::class, LocallyCalledStaticMethodToNonStaticRector::class, NumberCompareToMaxFuncCallRector::class, CompleteMissingIfElseBracketRector::class, RemoveUselessIsObjectCheckRector::class, StaticToSelfStaticMethodCallOnFinalClassRector::class]);
};

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\CodingStyle\Rector\ArrowFunction\StaticArrowFunctionRector;
use Rector\CodingStyle\Rector\Assign\SplitDoubleAssignRector;

View File

@ -0,0 +1,12 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202405;
use Rector\Carbon\Rector\FuncCall\DateFuncCallToCarbonRector;
use Rector\Carbon\Rector\MethodCall\DateTimeMethodCallToCarbonRector;
use Rector\Carbon\Rector\New_\DateTimeInstanceToCarbonRector;
use Rector\Config\RectorConfig;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rules([DateFuncCallToCarbonRector::class, DateTimeInstanceToCarbonRector::class, DateTimeMethodCallToCarbonRector::class]);
};

View File

@ -1,93 +1,10 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
use Rector\Config\Level\DeadCodeLevel;
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\Array_\RemoveDuplicatedArrayKeyRector;
use Rector\DeadCode\Rector\Assign\RemoveDoubleAssignRector;
use Rector\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector;
use Rector\DeadCode\Rector\BooleanAnd\RemoveAndTrueRector;
use Rector\DeadCode\Rector\Cast\RecastingRemovalRector;
use Rector\DeadCode\Rector\ClassConst\RemoveUnusedPrivateClassConstantRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodParameterRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPromotedPropertyRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnExprInConstructRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector;
use Rector\DeadCode\Rector\Concat\RemoveConcatAutocastRector;
use Rector\DeadCode\Rector\ConstFetch\RemovePhpVersionIdCheckRector;
use Rector\DeadCode\Rector\Expression\RemoveDeadStmtRector;
use Rector\DeadCode\Rector\Expression\SimplifyMirrorAssignRector;
use Rector\DeadCode\Rector\For_\RemoveDeadContinueRector;
use Rector\DeadCode\Rector\For_\RemoveDeadIfForeachForRector;
use Rector\DeadCode\Rector\For_\RemoveDeadLoopRector;
use Rector\DeadCode\Rector\Foreach_\RemoveUnusedForeachKeyRector;
use Rector\DeadCode\Rector\FunctionLike\RemoveDeadReturnRector;
use Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector;
use Rector\DeadCode\Rector\If_\RemoveDeadInstanceOfRector;
use Rector\DeadCode\Rector\If_\RemoveTypedPropertyDeadInstanceOfRector;
use Rector\DeadCode\Rector\If_\RemoveUnusedNonEmptyArrayBeforeForeachRector;
use Rector\DeadCode\Rector\If_\SimplifyIfElseWithSameContentRector;
use Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfPhpVersionRector;
use Rector\DeadCode\Rector\Node\RemoveNonExistingVarAnnotationRector;
use Rector\DeadCode\Rector\Plus\RemoveDeadZeroAndOneOperationRector;
use Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector;
use Rector\DeadCode\Rector\Property\RemoveUselessVarTagRector;
use Rector\DeadCode\Rector\PropertyProperty\RemoveNullPropertyInitializationRector;
use Rector\DeadCode\Rector\Return_\RemoveDeadConditionAboveReturnRector;
use Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector;
use Rector\DeadCode\Rector\Stmt\RemoveUnreachableStatementRector;
use Rector\DeadCode\Rector\Switch_\RemoveDuplicatedCaseInSwitchRector;
use Rector\DeadCode\Rector\Ternary\TernaryToBooleanOrFalseToBooleanAndRector;
use Rector\DeadCode\Rector\TryCatch\RemoveDeadTryCatchRector;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rules([
UnwrapFutureCompatibleIfPhpVersionRector::class,
RecastingRemovalRector::class,
RemoveDeadStmtRector::class,
RemoveDuplicatedArrayKeyRector::class,
RemoveUnusedForeachKeyRector::class,
RemoveParentCallWithoutParentRector::class,
RemoveEmptyClassMethodRector::class,
RemoveDoubleAssignRector::class,
SimplifyMirrorAssignRector::class,
RemoveUnusedPrivatePropertyRector::class,
RemoveUnusedPrivateClassConstantRector::class,
RemoveUnusedPrivateMethodRector::class,
RemoveDeadReturnRector::class,
RemoveDeadContinueRector::class,
RemoveDeadIfForeachForRector::class,
RemoveAndTrueRector::class,
RemoveConcatAutocastRector::class,
SimplifyUselessVariableRector::class,
RemoveDuplicatedCaseInSwitchRector::class,
RemoveNullPropertyInitializationRector::class,
RemoveUnreachableStatementRector::class,
SimplifyIfElseWithSameContentRector::class,
TernaryToBooleanOrFalseToBooleanAndRector::class,
RemoveDeadTryCatchRector::class,
RemoveUnusedVariableAssignRector::class,
RemoveUnusedNonEmptyArrayBeforeForeachRector::class,
RemoveDeadConditionAboveReturnRector::class,
RemoveUnusedConstructorParamRector::class,
RemoveDeadInstanceOfRector::class,
RemoveTypedPropertyDeadInstanceOfRector::class,
RemoveDeadLoopRector::class,
RemoveUnusedPrivateMethodParameterRector::class,
// docblock
RemoveUselessParamTagRector::class,
RemoveUselessReturnTagRector::class,
RemoveNonExistingVarAnnotationRector::class,
RemoveUselessVarTagRector::class,
RemoveUnusedPromotedPropertyRector::class,
RemoveAlwaysTrueIfConditionRector::class,
RemoveDeadZeroAndOneOperationRector::class,
RemovePhpVersionIdCheckRector::class,
RemoveUselessReturnExprInConstructRector::class,
]);
$rectorConfig->rules(DeadCodeLevel::RULES);
};

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\CodeQuality\Rector\FuncCall\InlineIsAInstanceOfRector;
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\SetList;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

View File

@ -0,0 +1,11 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->sets([SetList::PHP_84, LevelSetList::UP_TO_PHP_83]);
};

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Naming\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Php52\Rector\Property\VarToPublicPropertyRector;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Php54\Rector\Array_\LongArrayToShortArrayRector;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Php55\Rector\Class_\ClassConstantToSelfClassRector;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Php56\Rector\FuncCall\PowToExpRector;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Php70\Rector\Assign\ListSplitStringRector;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Php71\Rector\Assign\AssignArrayToStringRector;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Php72\Rector\Assign\ListEachRector;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Php52\Rector\Switch_\ContinueToBreakInSwitchRector;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Php74\Rector\ArrayDimFetch\CurlyToSquareBracketArrayStringRector;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector;
use Rector\Arguments\Rector\FuncCall\FunctionArgumentDefaultValueReplacerRector;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Php81\Rector\Array_\FirstClassCallableRector;

View File

@ -1,12 +1,13 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Php82\Rector\Class_\ReadOnlyClassRector;
use Rector\Php82\Rector\Encapsed\VariableInStringInterpolationFixerRector;
use Rector\Php82\Rector\FuncCall\Utf8DecodeEncodeToMbConvertEncodingRector;
use Rector\Php82\Rector\New_\FilesystemIteratorSkipDotsRector;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rules([ReadOnlyClassRector::class, Utf8DecodeEncodeToMbConvertEncodingRector::class, FilesystemIteratorSkipDotsRector::class]);
$rectorConfig->rules([ReadOnlyClassRector::class, Utf8DecodeEncodeToMbConvertEncodingRector::class, FilesystemIteratorSkipDotsRector::class, VariableInStringInterpolationFixerRector::class]);
};

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Php83\Rector\ClassConst\AddTypeToConstRector;

10
config/set/php84.php Normal file
View File

@ -0,0 +1,10 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Php84\Rector\Param\ExplicitNullableParamTypeRector;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rules([ExplicitNullableParamTypeRector::class]);
};

View File

@ -1,10 +1,12 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Privatization\Rector\ClassMethod\PrivatizeFinalClassMethodRector;
use Rector\Privatization\Rector\MethodCall\PrivatizeLocalGetterToPropertyRector;
use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector;
return RectorConfig::configure()->withRules([PrivatizeLocalGetterToPropertyRector::class, PrivatizeFinalClassPropertyRector::class, PrivatizeFinalClassMethodRector::class]);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rules([PrivatizeLocalGetterToPropertyRector::class, PrivatizeFinalClassPropertyRector::class, PrivatizeFinalClassMethodRector::class]);
};

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\RectorConfig;
use Rector\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector;

View File

@ -1,43 +1,12 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
namespace RectorPrefix202405;
use Rector\Config\Level\TypeDeclarationLevel;
use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\ArrowFunction\AddArrowFunctionReturnTypeRector;
use Rector\TypeDeclaration\Rector\Class_\MergeDateTimePropertyTypeDeclarationRector;
use Rector\TypeDeclaration\Rector\Class_\PropertyTypeFromStrictSetterGetterRector;
use Rector\TypeDeclaration\Rector\Class_\ReturnTypeFromStrictTernaryRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeBasedOnPHPUnitDataProviderRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeFromPropertyTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationBasedOnParentClassMethodRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;
use Rector\TypeDeclaration\Rector\ClassMethod\BoolReturnTypeFromStrictScalarReturnsRector;
use Rector\TypeDeclaration\Rector\ClassMethod\NumericReturnTypeFromStrictScalarReturnsRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByMethodCallTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByParentCallTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnDirectArrayRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictBoolReturnExprRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictConstantReturnRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictFluentReturnRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNativeCallRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNewArrayRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictParamRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictScalarReturnExprRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedPropertyRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnUnionTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\StrictArrayParamDimFetchRector;
use Rector\TypeDeclaration\Rector\ClassMethod\StrictStringParamConcatRector;
use Rector\TypeDeclaration\Rector\Empty_\EmptyOnNullableObjectToInstanceOfRector;
use Rector\TypeDeclaration\Rector\FunctionLike\AddParamTypeSplFixedArrayRector;
use Rector\TypeDeclaration\Rector\FunctionLike\AddReturnTypeDeclarationFromYieldsRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictSetUpRector;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rules([AddArrowFunctionReturnTypeRector::class, ParamTypeByMethodCallTypeRector::class, TypedPropertyFromAssignsRector::class, AddReturnTypeDeclarationBasedOnParentClassMethodRector::class, ReturnTypeFromStrictTypedPropertyRector::class, TypedPropertyFromStrictConstructorRector::class, AddVoidReturnTypeWhereNoReturnRector::class, ReturnTypeFromStrictFluentReturnRector::class, ReturnTypeFromReturnNewRector::class, AddMethodCallBasedStrictParamTypeRector::class, ReturnTypeFromStrictBoolReturnExprRector::class, ReturnTypeFromStrictNativeCallRector::class, ReturnTypeFromStrictNewArrayRector::class, ReturnTypeFromStrictScalarReturnExprRector::class, ReturnTypeFromStrictParamRector::class, TypedPropertyFromStrictSetUpRector::class, ParamTypeByParentCallTypeRector::class, AddParamTypeSplFixedArrayRector::class, AddParamTypeBasedOnPHPUnitDataProviderRector::class, AddParamTypeFromPropertyTypeRector::class, AddReturnTypeDeclarationFromYieldsRector::class, ReturnTypeFromReturnDirectArrayRector::class, ReturnTypeFromStrictConstantReturnRector::class, ReturnTypeFromStrictTypedCallRector::class, ReturnNeverTypeRector::class, EmptyOnNullableObjectToInstanceOfRector::class, PropertyTypeFromStrictSetterGetterRector::class, ReturnTypeFromStrictTernaryRector::class, BoolReturnTypeFromStrictScalarReturnsRector::class, NumericReturnTypeFromStrictScalarReturnsRector::class, StrictArrayParamDimFetchRector::class, ReturnUnionTypeRector::class, StrictStringParamConcatRector::class, MergeDateTimePropertyTypeDeclarationRector::class]);
// the rule order matters, as its used in withTypeCoverageLevel() method
// place the safest rules first, follow by more complex ones
$rectorConfig->rules(TypeDeclarationLevel::RULES);
};

View File

@ -1,4 +1,4 @@
# 355 Rules Overview
# 374 Rules Overview
<br>
@ -6,11 +6,13 @@
- [Arguments](#arguments) (4)
- [CodeQuality](#codequality) (73)
- [Carbon](#carbon) (3)
- [CodeQuality](#codequality) (75)
- [CodingStyle](#codingstyle) (28)
- [DeadCode](#deadcode) (42)
- [DeadCode](#deadcode) (44)
- [EarlyReturn](#earlyreturn) (9)
@ -42,21 +44,23 @@
- [Php81](#php81) (9)
- [Php82](#php82) (4)
- [Php82](#php82) (5)
- [Php83](#php83) (3)
- [Php84](#php84) (1)
- [Privatization](#privatization) (5)
- [Removing](#removing) (5)
- [Renaming](#renaming) (9)
- [Renaming](#renaming) (10)
- [Strict](#strict) (5)
- [Transform](#transform) (22)
- [Transform](#transform) (25)
- [TypeDeclaration](#typedeclaration) (40)
- [TypeDeclaration](#typedeclaration) (46)
- [Visibility](#visibility) (3)
@ -140,6 +144,59 @@ Replaces defined map of arguments in defined methods and their calls.
<br>
## Carbon
### DateFuncCallToCarbonRector
Convert `date()` function call to Carbon::*()
- class: [`Rector\Carbon\Rector\FuncCall\DateFuncCallToCarbonRector`](../rules/Carbon/Rector/FuncCall/DateFuncCallToCarbonRector.php)
```diff
class SomeClass
{
public function run()
{
- $date = date('Y-m-d');
+ $date = \Carbon\Carbon::now()->format('Y-m-d')
}
}
```
<br>
### DateTimeInstanceToCarbonRector
Convert new `DateTime()` to Carbon::*()
- class: [`Rector\Carbon\Rector\New_\DateTimeInstanceToCarbonRector`](../rules/Carbon/Rector/New_/DateTimeInstanceToCarbonRector.php)
```diff
-$date = new \DateTime('today');
+$date = \Carbon\Carbon::today();
```
<br>
### DateTimeMethodCallToCarbonRector
Convert new `DateTime()` with a method call to Carbon::*()
- class: [`Rector\Carbon\Rector\MethodCall\DateTimeMethodCallToCarbonRector`](../rules/Carbon/Rector/MethodCall/DateTimeMethodCallToCarbonRector.php)
```diff
class SomeClass
{
public function run()
{
- $date = (new \DateTime('today +20 day'))->format('Y-m-d');
+ $date = \Carbon\Carbon::today()->addDays(20)->format('Y-m-d')
}
}
```
<br>
## CodeQuality
### AbsolutizeRequireAndIncludePathRector
@ -547,6 +604,32 @@ Make if conditions more explicit
<br>
### ExplicitReturnNullRector
Add explicit return null to method/function that returns a value, but missed main return
- class: [`Rector\CodeQuality\Rector\ClassMethod\ExplicitReturnNullRector`](../rules/CodeQuality/Rector/ClassMethod/ExplicitReturnNullRector.php)
```diff
class SomeClass
{
/**
- * @return string|void
+ * @return string|null
*/
public function run(int $number)
{
if ($number > 50) {
return 'yes';
}
+
+ return null;
}
}
```
<br>
### FlipTypeControlToUseExclusiveTypeRector
Flip type control from null compare to use exclusive instanceof object
@ -1352,6 +1435,30 @@ Change switch with only 1 check to if
<br>
### StaticToSelfStaticMethodCallOnFinalClassRector
Change `static::methodCall()` to `self::methodCall()` on final class
- class: [`Rector\CodeQuality\Rector\Class_\StaticToSelfStaticMethodCallOnFinalClassRector`](../rules/CodeQuality/Rector/Class_/StaticToSelfStaticMethodCallOnFinalClassRector.php)
```diff
final class SomeClass
{
public function d()
{
- echo static::run();
+ echo self::run();
}
private static function run()
{
echo 'test';
}
}
```
<br>
### StrlenZeroToIdenticalEmptyStringRector
Changes strlen comparison to 0 to direct empty string compare
@ -2131,6 +2238,29 @@ Removes recasting of the same type
<br>
### ReduceAlwaysFalseIfOrRector
Reduce always false in a if ( || ) condition
- class: [`Rector\DeadCode\Rector\If_\ReduceAlwaysFalseIfOrRector`](../rules/DeadCode/Rector/If_/ReduceAlwaysFalseIfOrRector.php)
```diff
class SomeClass
{
public function run(int $number)
{
- if (! is_int($number) || $number > 50) {
+ if ($number > 50) {
return 'yes';
}
return 'no';
}
}
```
<br>
### RemoveAlwaysTrueIfConditionRector
Remove if condition that is always true
@ -2811,6 +2941,29 @@ Remove `@param` docblock with same type as parameter type
<br>
### RemoveUselessReadOnlyTagRector
Remove useless `@readonly` annotation on native readonly type
- class: [`Rector\DeadCode\Rector\Property\RemoveUselessReadOnlyTagRector`](../rules/DeadCode/Rector/Property/RemoveUselessReadOnlyTagRector.php)
```diff
final class SomeClass
{
- /**
- * @readonly
- */
private readonly string $name;
public function __construct(string $name)
{
$this->name = $name;
}
}
```
<br>
### RemoveUselessReturnExprInConstructRector
Remove useless return Expr in `__construct()`
@ -4669,9 +4822,9 @@ Change annotation to attribute
class SymfonyRoute
{
- /**
- * @Route("/path", name="action")
- * @Route("/path", name="action") api route
- */
+ #[Route(path: '/path', name: 'action')]
+ #[Route(path: '/path', name: 'action')] // api route
public function action()
{
}
@ -5248,6 +5401,20 @@ Change deprecated utf8_decode and utf8_encode to mb_convert_encoding
<br>
### VariableInStringInterpolationFixerRector
Replace deprecated "${var}" to "{$var}"
- class: [`Rector\Php82\Rector\Encapsed\VariableInStringInterpolationFixerRector`](../rules/Php82/Rector/Encapsed/VariableInStringInterpolationFixerRector.php)
```diff
$c = "football";
-echo "I like playing ${c}";
+echo "I like playing {$c}";
```
<br>
## Php83
### AddOverrideAttributeToOverriddenMethodsRector
@ -5277,7 +5444,7 @@ Add override attribute to overridden methods
### AddTypeToConstRector
Add const to type
Add type to constants
- class: [`Rector\Php83\Rector\ClassConst\AddTypeToConstRector`](../rules/Php83/Rector/ClassConst/AddTypeToConstRector.php)
@ -5304,6 +5471,21 @@ Combine separated host and port on `ldap_connect()` args
<br>
## Php84
### ExplicitNullableParamTypeRector
Make implicit nullable param to explicit
- class: [`Rector\Php84\Rector\Param\ExplicitNullableParamTypeRector`](../rules/Php84/Rector/Param/ExplicitNullableParamTypeRector.php)
```diff
-function foo(string $param = null) {}
+function foo(?string $param = null) {}
```
<br>
## Privatization
### FinalizeClassesWithoutChildrenRector
@ -5332,10 +5514,10 @@ PHPUnit test case will be finalized
- class: [`Rector\Privatization\Rector\Class_\FinalizeTestCaseClassRector`](../rules/Privatization/Rector/Class_/FinalizeTestCaseClassRector.php)
```diff
-use PHPUnit\Framework\TestCase;
+final use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\TestCase;
class SomeClass extends TestCase
-class SomeClass extends TestCase
+final class SomeClass extends TestCase
{
}
```
@ -5577,6 +5759,21 @@ Replace constant by new ones
<br>
### RenameFunctionLikeParamWithinCallLikeArgRector
Rename param within closures and arrow functions based on use with specified method calls
:wrench: **configure it!**
- class: [`Rector\Renaming\Rector\FunctionLike\RenameFunctionLikeParamWithinCallLikeArgRector`](../rules/Renaming/Rector/FunctionLike/RenameFunctionLikeParamWithinCallLikeArgRector.php)
```diff
-(new SomeClass)->process(function ($param) {});
+(new SomeClass)->process(function ($parameter) {});
```
<br>
### RenameFunctionRector
Turns defined function call new one.
@ -5813,6 +6010,21 @@ Add interface by used trait
<br>
### ArrayDimFetchToMethodCallRector
Change array dim fetch to method call
:wrench: **configure it!**
- class: [`Rector\Transform\Rector\ArrayDimFetch\ArrayDimFetchToMethodCallRector`](../rules/Transform/Rector/ArrayDimFetch/ArrayDimFetchToMethodCallRector.php)
```diff
-$app['someService'];
+$app->make('someService');
```
<br>
### AttributeKeyToClassConstFetchRector
Replace key value on specific attribute to class constant
@ -5835,6 +6047,21 @@ Replace key value on specific attribute to class constant
<br>
### ConstFetchToClassConstFetchRector
Change const fetch to class const fetch
:wrench: **configure it!**
- class: [`Rector\Transform\Rector\ConstFetch\ConstFetchToClassConstFetchRector`](../rules/Transform/Rector/ConstFetch/ConstFetchToClassConstFetchRector.php)
```diff
-$x = CONTEXT_COURSE
+$x = course::LEVEL
```
<br>
### FuncCallToConstFetchRector
Changes use of function calls to use constants
@ -6085,6 +6312,21 @@ Replaces properties assign calls be defined methods.
<br>
### RectorConfigBuilderRector
Change RectorConfig to RectorConfigBuilder
- class: [`Rector\Transform\Rector\FileWithoutNamespace\RectorConfigBuilderRector`](../rules/Transform/Rector/FileWithoutNamespace/RectorConfigBuilderRector.php)
```diff
-return static function (RectorConfig $rectorConfig): void {
- $rectorConfig->rule(SomeRector::class);
-};
+return RectorConfig::configure()->rules([SomeRector::class]);
```
<br>
### ReplaceParentCallByPropertyCallRector
Changes method calls in child of specific types to defined property method call
@ -6253,6 +6495,34 @@ Add known return type to arrow function
<br>
### AddClosureVoidReturnTypeWhereNoReturnRector
Add closure return type void if there is no return
- class: [`Rector\TypeDeclaration\Rector\Closure\AddClosureVoidReturnTypeWhereNoReturnRector`](../rules/TypeDeclaration/Rector/Closure/AddClosureVoidReturnTypeWhereNoReturnRector.php)
```diff
-function () {
+function (): void {
}
```
<br>
### AddFunctionVoidReturnTypeWhereNoReturnRector
Add function return type void if there is no return
- class: [`Rector\TypeDeclaration\Rector\Function_\AddFunctionVoidReturnTypeWhereNoReturnRector`](../rules/TypeDeclaration/Rector/Function_/AddFunctionVoidReturnTypeWhereNoReturnRector.php)
```diff
-function restore() {
+function restore(): void {
}
```
<br>
### AddMethodCallBasedStrictParamTypeRector
Change private method param type to strict type, based on passed strict types
@ -6324,6 +6594,21 @@ Add param types where needed
<br>
### AddParamTypeForFunctionLikeWithinCallLikeArgDeclarationRector
Add param types where needed
:wrench: **configure it!**
- class: [`Rector\TypeDeclaration\Rector\FunctionLike\AddParamTypeForFunctionLikeWithinCallLikeArgDeclarationRector`](../rules/TypeDeclaration/Rector/FunctionLike/AddParamTypeForFunctionLikeWithinCallLikeArgDeclarationRector.php)
```diff
-(new SomeClass)->process(function ($parameter) {});
+(new SomeClass)->process(function (string $parameter) {});
```
<br>
### AddParamTypeFromPropertyTypeRector
Adds param type declaration based on property type the value is assigned to PHPUnit provider return type declaration
@ -6452,6 +6737,26 @@ Changes defined return typehint of method and class.
<br>
### AddTestsVoidReturnTypeWhereNoReturnRector
Add void to PHPUnit test methods
- class: [`Rector\TypeDeclaration\Rector\Class_\AddTestsVoidReturnTypeWhereNoReturnRector`](../rules/TypeDeclaration/Rector/Class_/AddTestsVoidReturnTypeWhereNoReturnRector.php)
```diff
use PHPUnit\Framework\TestCase;
class SomeClass extends TestCase
{
- public function testSomething()
+ public function testSomething(): void
{
}
}
```
<br>
### AddVoidReturnTypeWhereNoReturnRector
Add return type void to function like without any return
@ -6515,6 +6820,32 @@ Change return type based on strict returns type operations
<br>
### ChildDoctrineRepositoryClassTypeRector
Add return type to classes that extend `Doctrine\ORM\EntityRepository` based on return Doctrine method names
- class: [`Rector\TypeDeclaration\Rector\Class_\ChildDoctrineRepositoryClassTypeRector`](../rules/TypeDeclaration/Rector/Class_/ChildDoctrineRepositoryClassTypeRector.php)
```diff
use Doctrine\ORM\EntityRepository;
/**
* @extends EntityRepository<SomeType>
*/
final class SomeRepository extends EntityRepository
{
- public function getActiveItem()
+ public function getActiveItem(): ?SomeType
{
return $this->findOneBy([
'something'
]);
}
}
```
<br>
### DeclareStrictTypesRector
Add declare(strict_types=1) if missing
@ -6554,6 +6885,24 @@ Change `empty()` on nullable object to instanceof check
<br>
### IncreaseDeclareStrictTypesRector
Add declare strict types to a limited amount of classes at a time, to try out in the wild and increase level gradually
:wrench: **configure it!**
- class: [`Rector\TypeDeclaration\Rector\StmtsAwareInterface\IncreaseDeclareStrictTypesRector`](../rules/TypeDeclaration/Rector/StmtsAwareInterface/IncreaseDeclareStrictTypesRector.php)
```diff
+declare(strict_types=1);
+
function someFunction()
{
}
```
<br>
### MergeDateTimePropertyTypeDeclarationRector
Set DateTime to DateTimeInterface for DateTime property with DateTimeInterface docblock

View File

@ -291,6 +291,9 @@ require_once __DIR__ . '/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/InvalidTagV
require_once __DIR__ . '/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/MethodTagValueNode.php';
require_once __DIR__ . '/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/MethodTagValueParameterNode.php';
require_once __DIR__ . '/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/MixinTagValueNode.php';
require_once __DIR__ . '/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ParamClosureThisTagValueNode.php';
require_once __DIR__ . '/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ParamImmediatelyInvokedCallableTagValueNode.php';
require_once __DIR__ . '/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ParamLaterInvokedCallableTagValueNode.php';
require_once __DIR__ . '/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ParamOutTagValueNode.php';
require_once __DIR__ . '/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ParamTagValueNode.php';
require_once __DIR__ . '/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocChildNode.php';

View File

@ -29,7 +29,7 @@ use Rector\Rector\AbstractRector;
use Rector\StaticTypeMapper\StaticTypeMapper;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
use RectorPrefix202402\Webmozart\Assert\Assert;
use RectorPrefix202405\Webmozart\Assert\Assert;
/**
* @see \Rector\Tests\Arguments\Rector\ClassMethod\ArgumentAdderRector\ArgumentAdderRectorTest
*/

View File

@ -15,7 +15,7 @@ use Rector\Rector\AbstractRector;
use Rector\ValueObject\MethodName;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
use RectorPrefix202402\Webmozart\Assert\Assert;
use RectorPrefix202405\Webmozart\Assert\Assert;
/**
* @api used in rector-symfony
* @see \Rector\Tests\Arguments\Rector\ClassMethod\ReplaceArgumentDefaultValueRector\ReplaceArgumentDefaultValueRectorTest

View File

@ -11,7 +11,7 @@ use Rector\Contract\Rector\ConfigurableRectorInterface;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
use RectorPrefix202402\Webmozart\Assert\Assert;
use RectorPrefix202405\Webmozart\Assert\Assert;
/**
* @changelog https://php.watch/versions/8.1/version_compare-operator-restrictions
* @changelog https://github.com/rectorphp/rector/issues/6271

View File

@ -11,7 +11,7 @@ use Rector\Contract\Rector\ConfigurableRectorInterface;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
use RectorPrefix202402\Webmozart\Assert\Assert;
use RectorPrefix202405\Webmozart\Assert\Assert;
/**
* @see \Rector\Tests\Arguments\Rector\MethodCall\RemoveMethodCallParamRector\RemoveMethodCallParamRectorTest
*/

View File

@ -0,0 +1,58 @@
<?php
declare (strict_types=1);
namespace Rector\Carbon\NodeFactory;
use RectorPrefix202405\Nette\Utils\Strings;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Identifier;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Scalar\String_;
final class CarbonCallFactory
{
/**
* @var string
* @see https://regex101.com/r/9vGt8r/1
*/
private const DAY_COUNT_REGEX = '#\\+(\\s+)?(?<count>\\d+)(\\s+)?(day|days)#';
/**
* @var string
* @see https://regex101.com/r/6VUUQF/1
*/
private const MONTH_COUNT_REGEX = '#\\+(\\s+)?(?<count>\\d+)(\\s+)?(month|months)#';
/**
* @var array<self::*_REGEX, string>
*/
private const REGEX_TO_METHOD_NAME_MAP = [self::DAY_COUNT_REGEX => 'addDays', self::MONTH_COUNT_REGEX => 'addMonths'];
/**
* @return \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall
*/
public function createFromDateTimeString(FullyQualified $carbonFullyQualified, String_ $string)
{
$dateTimeValue = $string->value;
if ($dateTimeValue === 'now') {
return new StaticCall($carbonFullyQualified, new Identifier('now'));
}
if ($dateTimeValue === 'today') {
return new StaticCall($carbonFullyQualified, new Identifier('today'));
}
$hasToday = Strings::match($dateTimeValue, '#today#');
if ($hasToday !== null) {
$carbonCall = new StaticCall($carbonFullyQualified, new Identifier('today'));
} else {
$carbonCall = new StaticCall($carbonFullyQualified, new Identifier('now'));
}
foreach (self::REGEX_TO_METHOD_NAME_MAP as $regex => $methodName) {
$match = Strings::match($dateTimeValue, $regex);
if ($match === null) {
continue;
}
$countLNumber = new LNumber((int) $match['count']);
$carbonCall = new MethodCall($carbonCall, new Identifier($methodName), [new Arg($countLNumber)]);
}
return $carbonCall;
}
}

View File

@ -0,0 +1,72 @@
<?php
declare (strict_types=1);
namespace Rector\Carbon\Rector\FuncCall;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Scalar\String_;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Rector\Tests\Carbon\Rector\FuncCall\DateFuncCallToCarbonRector\DateFuncCallToCarbonRectorTest
*/
final class DateFuncCallToCarbonRector extends AbstractRector
{
public function getRuleDefinition() : RuleDefinition
{
return new RuleDefinition('Convert date() function call to Carbon::*()', [new CodeSample(<<<'CODE_SAMPLE'
class SomeClass
{
public function run()
{
$date = date('Y-m-d');
}
}
CODE_SAMPLE
, <<<'CODE_SAMPLE'
class SomeClass
{
public function run()
{
$date = \Carbon\Carbon::now()->format('Y-m-d')
}
}
CODE_SAMPLE
)]);
}
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes() : array
{
return [FuncCall::class];
}
/**
* @param FuncCall $node
*/
public function refactor(Node $node) : ?Node
{
if (!$this->isName($node->name, 'date')) {
return null;
}
if ($node->isFirstClassCallable()) {
return null;
}
if (\count($node->getArgs()) !== 1) {
return null;
}
$firstArg = $node->getArgs()[0];
if (!$firstArg->value instanceof String_) {
return null;
}
// create now and format()
$nowStaticCall = new StaticCall(new FullyQualified('Carbon\\Carbon'), 'now');
return new MethodCall($nowStaticCall, 'format', [new Arg($firstArg->value)]);
}
}

View File

@ -0,0 +1,90 @@
<?php
declare (strict_types=1);
namespace Rector\Carbon\Rector\MethodCall;
use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\New_;
use PhpParser\Node\Name;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Scalar\String_;
use Rector\Carbon\NodeFactory\CarbonCallFactory;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Rector\Tests\Carbon\Rector\MethodCall\DateTimeMethodCallToCarbonRector\DateTimeMethodCallToCarbonRectorTest
*/
final class DateTimeMethodCallToCarbonRector extends AbstractRector
{
/**
* @readonly
* @var \Rector\Carbon\NodeFactory\CarbonCallFactory
*/
private $carbonCallFactory;
public function __construct(CarbonCallFactory $carbonCallFactory)
{
$this->carbonCallFactory = $carbonCallFactory;
}
public function getRuleDefinition() : RuleDefinition
{
return new RuleDefinition('Convert new DateTime() with a method call to Carbon::*()', [new CodeSample(<<<'CODE_SAMPLE'
class SomeClass
{
public function run()
{
$date = (new \DateTime('today +20 day'))->format('Y-m-d');
}
}
CODE_SAMPLE
, <<<'CODE_SAMPLE'
class SomeClass
{
public function run()
{
$date = \Carbon\Carbon::today()->addDays(20)->format('Y-m-d')
}
}
CODE_SAMPLE
)]);
}
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes() : array
{
return [MethodCall::class];
}
/**
* @param MethodCall $node
*/
public function refactor(Node $node) : ?Node
{
if (!$node->var instanceof New_) {
return null;
}
$new = $node->var;
if (!$new->class instanceof Name) {
return null;
}
if (!$this->isName($new->class, 'DateTime')) {
return null;
}
if ($new->isFirstClassCallable()) {
return null;
}
if (\count($new->getArgs()) !== 1) {
// @todo handle in separate static call
return null;
}
$firstArg = $new->getArgs()[0];
if (!$firstArg->value instanceof String_) {
return null;
}
$carbonFullyQualified = new FullyQualified('Carbon\\Carbon');
$carbonCall = $this->carbonCallFactory->createFromDateTimeString($carbonFullyQualified, $firstArg->value);
$node->var = $carbonCall;
return $node;
}
}

View File

@ -0,0 +1,84 @@
<?php
declare (strict_types=1);
namespace Rector\Carbon\Rector\New_;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node;
use PhpParser\Node\Expr\New_;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Identifier;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Scalar\String_;
use Rector\Carbon\NodeFactory\CarbonCallFactory;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @changelog https://github.com/briannesbitt/Carbon/issues/231
*
* @see \Rector\Tests\Carbon\Rector\New_\DateTimeInstanceToCarbonRector\DateTimeInstanceToCarbonRectorTest
*/
final class DateTimeInstanceToCarbonRector extends AbstractRector
{
/**
* @readonly
* @var \Rector\Carbon\NodeFactory\CarbonCallFactory
*/
private $carbonCallFactory;
public function __construct(CarbonCallFactory $carbonCallFactory)
{
$this->carbonCallFactory = $carbonCallFactory;
}
public function getRuleDefinition() : RuleDefinition
{
return new RuleDefinition('Convert new DateTime() to Carbon::*()', [new CodeSample(<<<'CODE_SAMPLE'
$date = new \DateTime('today');
CODE_SAMPLE
, <<<'CODE_SAMPLE'
$date = \Carbon\Carbon::today();
CODE_SAMPLE
)]);
}
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes() : array
{
return [New_::class];
}
/**
* @param New_ $node
*/
public function refactor(Node $node) : ?Node
{
if ($this->isName($node->class, 'DateTime')) {
return $this->refactorWithClass($node, 'Carbon\\Carbon');
}
if ($this->isName($node->class, 'DateTimeImmutable')) {
return $this->refactorWithClass($node, 'Carbon\\CarbonImmutable');
}
return null;
}
/**
* @return \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|null
*/
public function refactorWithClass(New_ $new, string $className)
{
if ($new->isFirstClassCallable()) {
return null;
}
// no arg? ::now()
$carbonFullyQualified = new FullyQualified($className);
if ($new->args === []) {
return new StaticCall($carbonFullyQualified, new Identifier('now'));
}
if (\count($new->getArgs()) === 1) {
$firstArg = $new->getArgs()[0];
if ($firstArg->value instanceof String_) {
return $this->carbonCallFactory->createFromDateTimeString($carbonFullyQualified, $firstArg->value);
}
}
return null;
}
}

View File

@ -47,6 +47,9 @@ final class VariableDimFetchAssignResolver
}
$assign = $stmtExpr;
$keyExpr = $this->matchKeyOnArrayDimFetchOfVariable($assign, $variable);
if ($assign->var instanceof ArrayDimFetch && $assign->var->var instanceof ArrayDimFetch) {
return [];
}
$keysAndExprs[] = new KeyAndExpr($keyExpr, $assign->expr, $stmt->getComments());
}
// we can only work with same variable

View File

@ -5,6 +5,9 @@ namespace Rector\CodeQuality\Rector\Array_;
use PhpParser\Node;
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Stmt\ClassConst;
use PhpParser\Node\Stmt\Property;
use PhpParser\NodeTraverser;
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\Php\PhpMethodReflection;
use Rector\NodeCollector\NodeAnalyzer\ArrayCallableMethodMatcher;
@ -89,13 +92,17 @@ CODE_SAMPLE
*/
public function getNodeTypes() : array
{
return [Array_::class];
return [Property::class, ClassConst::class, Array_::class];
}
/**
* @param Array_ $node
* @param Property|ClassConst|Array_ $node
* @return null|int|\PhpParser\Node
*/
public function refactorWithScope(Node $node, Scope $scope) : ?Node
public function refactorWithScope(Node $node, Scope $scope)
{
if ($node instanceof Property || $node instanceof ClassConst) {
return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
}
if ($this->shouldSkipTwigExtension($scope)) {
return null;
}

View File

@ -0,0 +1,174 @@
<?php
declare (strict_types=1);
namespace Rector\CodeQuality\Rector\ClassMethod;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Expr\ConstFetch;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Function_;
use PhpParser\Node\Stmt\Return_;
use PhpParser\NodeTraverser;
use PHPStan\Type\NullType;
use PHPStan\Type\UnionType;
use PHPStan\Type\VoidType;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger;
use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory;
use Rector\Rector\AbstractRector;
use Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer;
use Rector\TypeDeclaration\TypeInferer\SilentVoidResolver;
use Rector\ValueObject\MethodName;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Rector\Tests\CodeQuality\Rector\ClassMethod\ExplicitReturnNullRector\ExplicitReturnNullRectorTest
*/
final class ExplicitReturnNullRector extends AbstractRector
{
/**
* @readonly
* @var \Rector\TypeDeclaration\TypeInferer\SilentVoidResolver
*/
private $silentVoidResolver;
/**
* @readonly
* @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory
*/
private $phpDocInfoFactory;
/**
* @readonly
* @var \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory
*/
private $typeFactory;
/**
* @readonly
* @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger
*/
private $phpDocTypeChanger;
/**
* @readonly
* @var \Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer
*/
private $returnTypeInferer;
public function __construct(SilentVoidResolver $silentVoidResolver, PhpDocInfoFactory $phpDocInfoFactory, TypeFactory $typeFactory, PhpDocTypeChanger $phpDocTypeChanger, ReturnTypeInferer $returnTypeInferer)
{
$this->silentVoidResolver = $silentVoidResolver;
$this->phpDocInfoFactory = $phpDocInfoFactory;
$this->typeFactory = $typeFactory;
$this->phpDocTypeChanger = $phpDocTypeChanger;
$this->returnTypeInferer = $returnTypeInferer;
}
public function getRuleDefinition() : RuleDefinition
{
return new RuleDefinition('Add explicit return null to method/function that returns a value, but missed main return', [new CodeSample(<<<'CODE_SAMPLE'
class SomeClass
{
/**
* @return string|void
*/
public function run(int $number)
{
if ($number > 50) {
return 'yes';
}
}
}
CODE_SAMPLE
, <<<'CODE_SAMPLE'
class SomeClass
{
/**
* @return string|null
*/
public function run(int $number)
{
if ($number > 50) {
return 'yes';
}
return null;
}
}
CODE_SAMPLE
)]);
}
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes() : array
{
return [ClassMethod::class, Function_::class];
}
/**
* @param ClassMethod|Function_ $node
*/
public function refactor(Node $node) : ?Node
{
// known return type, nothing to improve
if ($node->returnType instanceof Node) {
return null;
}
if ($node instanceof ClassMethod && $this->isName($node, MethodName::CONSTRUCT)) {
return null;
}
$returnType = $this->returnTypeInferer->inferFunctionLike($node);
if (!$returnType instanceof UnionType) {
return null;
}
$hasChanged = \false;
$this->traverseNodesWithCallable((array) $node->stmts, static function (Node $node) use(&$hasChanged) {
if ($node instanceof Class_ || $node instanceof Function_ || $node instanceof Closure) {
return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
}
if ($node instanceof Return_ && !$node->expr instanceof Expr) {
$hasChanged = \true;
$node->expr = new ConstFetch(new Name('null'));
return $node;
}
return null;
});
if (!$this->silentVoidResolver->hasSilentVoid($node)) {
if ($hasChanged) {
$this->transformDocUnionVoidToUnionNull($node);
return $node;
}
return null;
}
$node->stmts[] = new Return_(new ConstFetch(new Name('null')));
$this->transformDocUnionVoidToUnionNull($node);
return $node;
}
/**
* @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $node
*/
private function transformDocUnionVoidToUnionNull($node) : void
{
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
$returnType = $phpDocInfo->getReturnType();
if (!$returnType instanceof UnionType) {
return;
}
$newTypes = [];
$hasChanged = \false;
foreach ($returnType->getTypes() as $type) {
if ($type instanceof VoidType) {
$type = new NullType();
$hasChanged = \true;
}
$newTypes[] = $type;
}
if (!$hasChanged) {
return;
}
$type = $this->typeFactory->createMixedPassedOrUnionTypeAndKeepConstant($newTypes);
if (!$type instanceof UnionType) {
return;
}
$this->phpDocTypeChanger->changeReturnType($node, $phpDocInfo, $type);
}
}

View File

@ -152,6 +152,7 @@ CODE_SAMPLE
{
\end($stmts);
$lastKey = \key($stmts);
\reset($stmts);
foreach ($stmts as $key => $stmt) {
if ($key === $lastKey) {
// skip last item

View File

@ -121,7 +121,7 @@ CODE_SAMPLE
if (!$node instanceof StaticCall) {
return null;
}
if (!$this->isName($node->class, 'self')) {
if (!$this->isNames($node->class, ['self', 'static'])) {
return null;
}
if (!$this->isName($node->name, $classMethodName)) {
@ -151,7 +151,7 @@ CODE_SAMPLE
if (!$node instanceof StaticCall) {
return null;
}
if (!$this->isName($node->class, 'self')) {
if (!$this->isNames($node->class, ['self', 'static'])) {
return null;
}
if (!$this->isName($node->name, $currentClassMethodName)) {

View File

@ -4,12 +4,16 @@ declare (strict_types=1);
namespace Rector\CodeQuality\Rector\ClassMethod;
use PhpParser\Node;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\New_;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Function_;
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\FunctionReflection;
use PHPStan\Reflection\MethodReflection;
use PHPStan\Reflection\Native\NativeFunctionReflection;
use Rector\CodingStyle\Reflection\VendorLocationDetector;
use Rector\NodeTypeResolver\PHPStan\ParametersAcceptorSelectorVariantsWrapper;
use Rector\Php80\NodeResolver\ArgumentSorter;
@ -81,41 +85,49 @@ CODE_SAMPLE
*/
public function getNodeTypes() : array
{
return [ClassMethod::class, New_::class, MethodCall::class, StaticCall::class];
return [ClassMethod::class, Function_::class, New_::class, MethodCall::class, StaticCall::class, FuncCall::class];
}
/**
* @param ClassMethod|New_|MethodCall|StaticCall $node
* @return \PhpParser\Node\Stmt\ClassMethod|null|\PhpParser\Node\Expr\New_|\PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall
* @param ClassMethod|Function_|New_|MethodCall|StaticCall|FuncCall $node
* @return \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|null|\PhpParser\Node\Expr\New_|\PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\FuncCall
*/
public function refactorWithScope(Node $node, Scope $scope)
{
if ($node instanceof ClassMethod) {
return $this->refactorClassMethod($node, $scope);
if ($node instanceof ClassMethod || $node instanceof Function_) {
return $this->refactorClassMethodOrFunction($node, $scope);
}
if ($node instanceof New_) {
return $this->refactorNew($node, $scope);
}
return $this->refactorMethodCall($node, $scope);
return $this->refactorMethodCallOrFuncCall($node, $scope);
}
private function refactorClassMethod(ClassMethod $classMethod, Scope $scope) : ?ClassMethod
/**
* @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $node
* @return \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|null
*/
private function refactorClassMethodOrFunction($node, Scope $scope)
{
if ($classMethod->params === []) {
if ($node->params === []) {
return null;
}
if ($classMethod->getAttribute(self::HAS_SWAPPED_PARAMS, \false) === \true) {
if ($node->getAttribute(self::HAS_SWAPPED_PARAMS, \false) === \true) {
return null;
}
$classMethodReflection = $this->reflectionResolver->resolveMethodReflectionFromClassMethod($classMethod, $scope);
if (!$classMethodReflection instanceof MethodReflection) {
if ($node instanceof ClassMethod) {
$reflection = $this->reflectionResolver->resolveMethodReflectionFromClassMethod($node, $scope);
} else {
$reflection = $this->reflectionResolver->resolveFunctionReflectionFromFunction($node, $scope);
}
if (!$reflection instanceof MethodReflection && !$reflection instanceof FunctionReflection) {
return null;
}
$expectedArgOrParamOrder = $this->resolveExpectedArgParamOrderIfDifferent($classMethodReflection, $classMethod, $scope);
$expectedArgOrParamOrder = $this->resolveExpectedArgParamOrderIfDifferent($reflection, $node, $scope);
if ($expectedArgOrParamOrder === null) {
return null;
}
$classMethod->params = $this->argumentSorter->sortArgsByExpectedParamOrder($classMethod->params, $expectedArgOrParamOrder);
$classMethod->setAttribute(self::HAS_SWAPPED_PARAMS, \true);
return $classMethod;
$node->params = $this->argumentSorter->sortArgsByExpectedParamOrder($node->params, $expectedArgOrParamOrder);
$node->setAttribute(self::HAS_SWAPPED_PARAMS, \true);
return $node;
}
private function refactorNew(New_ $new, Scope $scope) : ?New_
{
@ -137,39 +149,46 @@ CODE_SAMPLE
return $new;
}
/**
* @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $methodCall
* @return \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|null
* @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\FuncCall $node
* @return \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\FuncCall|null
*/
private function refactorMethodCall($methodCall, Scope $scope)
private function refactorMethodCallOrFuncCall($node, Scope $scope)
{
if ($methodCall->isFirstClassCallable()) {
if ($node->isFirstClassCallable()) {
return null;
}
$methodReflection = $this->reflectionResolver->resolveFunctionLikeReflectionFromCall($methodCall);
if (!$methodReflection instanceof MethodReflection) {
$reflection = $this->reflectionResolver->resolveFunctionLikeReflectionFromCall($node);
if (!$reflection instanceof MethodReflection && !$reflection instanceof FunctionReflection) {
return null;
}
$expectedArgOrParamOrder = $this->resolveExpectedArgParamOrderIfDifferent($methodReflection, $methodCall, $scope);
$expectedArgOrParamOrder = $this->resolveExpectedArgParamOrderIfDifferent($reflection, $node, $scope);
if ($expectedArgOrParamOrder === null) {
return null;
}
$newArgs = $this->argumentSorter->sortArgsByExpectedParamOrder($methodCall->getArgs(), $expectedArgOrParamOrder);
if ($methodCall->args === $newArgs) {
$newArgs = $this->argumentSorter->sortArgsByExpectedParamOrder($node->getArgs(), $expectedArgOrParamOrder);
if ($node->args === $newArgs) {
return null;
}
$methodCall->args = $newArgs;
return $methodCall;
$node->args = $newArgs;
return $node;
}
/**
* @return int[]|null
* @param \PhpParser\Node\Expr\New_|\PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Expr\StaticCall $node
* @param \PHPStan\Reflection\MethodReflection|\PHPStan\Reflection\FunctionReflection $reflection
* @param \PhpParser\Node\Expr\New_|\PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\FuncCall $node
*/
private function resolveExpectedArgParamOrderIfDifferent(MethodReflection $methodReflection, $node, Scope $scope) : ?array
private function resolveExpectedArgParamOrderIfDifferent($reflection, $node, Scope $scope) : ?array
{
if ($this->vendorLocationDetector->detectMethodReflection($methodReflection)) {
if ($reflection instanceof NativeFunctionReflection) {
return null;
}
$parametersAcceptor = ParametersAcceptorSelectorVariantsWrapper::select($methodReflection, $node, $scope);
if ($reflection instanceof MethodReflection && $this->vendorLocationDetector->detectMethodReflection($reflection)) {
return null;
}
if ($reflection instanceof FunctionReflection && $this->vendorLocationDetector->detectFunctionReflection($reflection)) {
return null;
}
$parametersAcceptor = ParametersAcceptorSelectorVariantsWrapper::select($reflection, $node, $scope);
$expectedParameterReflections = $this->requireOptionalParamResolver->resolveFromParametersAcceptor($parametersAcceptor);
if ($expectedParameterReflections === $parametersAcceptor->getParameters()) {
return null;

View File

@ -4,6 +4,7 @@ declare (strict_types=1);
namespace Rector\CodeQuality\Rector\Class_;
use PhpParser\Node;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Stmt\Class_;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\ReflectionProvider;
@ -154,7 +155,10 @@ CODE_SAMPLE
if ($classReflection->hasMethod('__set')) {
return \true;
}
return $classReflection->hasMethod('__get');
if ($classReflection->hasMethod('__get')) {
return \true;
}
return $class->extends instanceof FullyQualified && !$this->reflectionProvider->hasClass($class->extends->toString());
}
/**
* @param array<string, Type> $fetchedLocalPropertyNameToTypes

View File

@ -0,0 +1,100 @@
<?php
declare (strict_types=1);
namespace Rector\CodeQuality\Rector\Class_;
use PhpParser\Node;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Identifier;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
use Rector\Enum\ObjectReference;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @changelog https://3v4l.org/JK1g2#v5.0.0
* @see \Rector\Tests\CodeQuality\Rector\Class_\StaticToSelfStaticMethodCallOnFinalClassRector\StaticToSelfStaticMethodCallOnFinalClassRectorTest
*/
final class StaticToSelfStaticMethodCallOnFinalClassRector extends AbstractRector
{
public function getRuleDefinition() : RuleDefinition
{
return new RuleDefinition('Change `static::methodCall()` to `self::methodCall()` on final class', [new CodeSample(<<<'CODE_SAMPLE'
final class SomeClass
{
public function d()
{
echo static::run();
}
private static function run()
{
echo 'test';
}
}
CODE_SAMPLE
, <<<'CODE_SAMPLE'
final class SomeClass
{
public function d()
{
echo self::run();
}
private static function run()
{
echo 'test';
}
}
CODE_SAMPLE
)]);
}
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes() : array
{
return [Class_::class];
}
/**
* @param Class_ $node
*/
public function refactor(Node $node) : ?Class_
{
if (!$node->isFinal()) {
return null;
}
$hasChanged = \false;
$this->traverseNodesWithCallable($node->stmts, function (Node $subNode) use(&$hasChanged, $node) : ?StaticCall {
if (!$subNode instanceof StaticCall) {
return null;
}
if (!$this->isName($subNode->class, ObjectReference::STATIC)) {
return null;
}
// skip dynamic method
if (!$subNode->name instanceof Identifier) {
return null;
}
$methodName = (string) $this->getName($subNode->name);
$targetClassMethod = $node->getMethod($methodName);
// skip call non-existing method from current class to ensure transformation is safe
if (!$targetClassMethod instanceof ClassMethod) {
return null;
}
// avoid overlapped change
if (!$targetClassMethod->isStatic()) {
return null;
}
$hasChanged = \true;
$subNode->class = new Name('self');
return $subNode;
});
if ($hasChanged) {
return $node;
}
return null;
}
}

View File

@ -3,7 +3,7 @@
declare (strict_types=1);
namespace Rector\CodeQuality\Rector\Concat;
use RectorPrefix202402\Nette\Utils\Strings;
use RectorPrefix202405\Nette\Utils\Strings;
use PhpParser\Node;
use PhpParser\Node\Expr\BinaryOp\Concat;
use PhpParser\Node\Scalar\String_;

View File

@ -55,21 +55,29 @@ CODE_SAMPLE
public function refactor(Node $node) : ?Node
{
$leftStaticType = $this->nodeTypeResolver->getNativeType($node->left);
// objects can be different by content
if ($leftStaticType instanceof ObjectType) {
return null;
}
if ($leftStaticType instanceof MixedType) {
return null;
}
$rightStaticType = $this->nodeTypeResolver->getNativeType($node->right);
if ($rightStaticType instanceof MixedType) {
// objects can be different by content
if ($leftStaticType instanceof ObjectType || $rightStaticType instanceof ObjectType) {
return null;
}
if ($leftStaticType instanceof MixedType || $rightStaticType instanceof MixedType) {
return null;
}
if ($leftStaticType->isString()->yes() && $rightStaticType->isString()->yes()) {
return $this->processIdenticalOrNotIdentical($node);
}
// different types
if (!$leftStaticType->equals($rightStaticType)) {
return null;
}
return $this->processIdenticalOrNotIdentical($node);
}
/**
* @param \PhpParser\Node\Expr\BinaryOp\Equal|\PhpParser\Node\Expr\BinaryOp\NotEqual $node
* @return \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\BinaryOp\NotIdentical
*/
private function processIdenticalOrNotIdentical($node)
{
if ($node instanceof Equal) {
return new Identical($node->left, $node->right);
}

View File

@ -6,10 +6,11 @@ namespace Rector\CodeQuality\Rector\Expression;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Ternary;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Stmt\Expression;
use PhpParser\Node\Stmt\If_;
use PHPStan\Analyser\Scope;
use Rector\DeadCode\SideEffect\SideEffectNodeDetector;
use Rector\NodeAnalyzer\ExprAnalyzer;
use Rector\Rector\AbstractScopeAwareRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@ -20,12 +21,12 @@ final class TernaryFalseExpressionToIfRector extends AbstractScopeAwareRector
{
/**
* @readonly
* @var \Rector\DeadCode\SideEffect\SideEffectNodeDetector
* @var \Rector\NodeAnalyzer\ExprAnalyzer
*/
private $sideEffectNodeDetector;
public function __construct(SideEffectNodeDetector $sideEffectNodeDetector)
private $exprAnalyzer;
public function __construct(ExprAnalyzer $exprAnalyzer)
{
$this->sideEffectNodeDetector = $sideEffectNodeDetector;
$this->exprAnalyzer = $exprAnalyzer;
}
public function getRuleDefinition() : RuleDefinition
{
@ -70,7 +71,7 @@ CODE_SAMPLE
if (!$ternary->if instanceof Expr) {
return null;
}
if ($this->sideEffectNodeDetector->detect($ternary->else, $scope) || $this->sideEffectNodeDetector->detectCallExpr($ternary->else, $scope)) {
if (!$ternary->else instanceof Variable && $this->exprAnalyzer->isDynamicExpr($ternary->else)) {
return null;
}
return new If_($ternary->cond, ['stmts' => [new Expression($ternary->if)]]);

View File

@ -13,13 +13,14 @@ use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\Expression;
use PhpParser\Node\Stmt\For_;
use Rector\Rector\AbstractRector;
use PHPStan\Analyser\Scope;
use Rector\Rector\AbstractScopeAwareRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Rector\Tests\CodeQuality\Rector\For_\ForRepeatedCountToOwnVariableRector\ForRepeatedCountToOwnVariableRectorTest
*/
final class ForRepeatedCountToOwnVariableRector extends AbstractRector
final class ForRepeatedCountToOwnVariableRector extends AbstractScopeAwareRector
{
/**
* @var string
@ -63,8 +64,11 @@ CODE_SAMPLE
* @param For_ $node
* @return Stmt[]|null
*/
public function refactor(Node $node) : ?array
public function refactorWithScope(Node $node, Scope $scope) : ?array
{
if ($scope->hasVariableType(self::COUNTER_NAME)->yes()) {
return null;
}
$countInCond = null;
$counterVariable = new Variable(self::COUNTER_NAME);
foreach ($node->cond as $condExpr) {

View File

@ -88,15 +88,16 @@ CODE_SAMPLE
return null;
}
$nextStmt = $node->stmts[$key + 1] ?? null;
if (!$nextStmt instanceof Return_) {
continue;
}
$return = $this->processForeachNodeWithReturnInside($foreach, $foreachReturnOrAssign, $nextStmt);
if (!$return instanceof Return_) {
continue;
}
$node->stmts[$key] = $return;
// cleanup next return
if ($nextStmt instanceof Return_) {
unset($node->stmts[$key + 1]);
}
unset($node->stmts[$key + 1]);
$hasChanged = \true;
}
}

View File

@ -78,7 +78,7 @@ CODE_SAMPLE
if (!$nestedArrayItemItem instanceof ArrayItem) {
continue;
}
$array->items[] = new ArrayItem($nestedArrayItemItem->value, $nestedArrayItemItem->key);
$array->items[] = $nestedArrayItemItem->unpack ? $nestedArrayItemItem : new ArrayItem($nestedArrayItemItem->value, $nestedArrayItemItem->key);
$isAssigned = \true;
}
}

View File

@ -3,7 +3,7 @@
declare (strict_types=1);
namespace Rector\CodeQuality\Rector\FuncCall;
use RectorPrefix202402\Nette\Utils\Strings;
use RectorPrefix202405\Nette\Utils\Strings;
use PhpParser\Node;
use PhpParser\Node\Scalar\String_;
use Rector\NodeNameResolver\Regex\RegexPatternDetector;

View File

@ -3,9 +3,11 @@
declare (strict_types=1);
namespace Rector\CodeQuality\Rector\FuncCall;
use RectorPrefix202405\Nette\Utils\Strings;
use PhpParser\Node;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Name;
use PhpParser\Node\Scalar\String_;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@ -14,6 +16,11 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
*/
final class SimplifyStrposLowerRector extends AbstractRector
{
/**
* @var string
* @see https://regex101.com/r/Jokjt8/1
*/
private const UPPERCASE_REGEX = '#[A-Z]#';
public function getRuleDefinition() : RuleDefinition
{
return new RuleDefinition('Simplify strpos(strtolower(), "...") calls', [new CodeSample('strpos(strtolower($var), "...")', 'stripos($var, "...")')]);
@ -36,10 +43,11 @@ final class SimplifyStrposLowerRector extends AbstractRector
if ($node->isFirstClassCallable()) {
return null;
}
if (!isset($node->getArgs()[0])) {
$args = $node->getArgs();
if (!isset($args[0], $args[1])) {
return null;
}
$firstArg = $node->getArgs()[0];
$firstArg = $args[0];
if (!$firstArg->value instanceof FuncCall) {
return null;
}
@ -48,6 +56,13 @@ final class SimplifyStrposLowerRector extends AbstractRector
if (!$this->isName($innerFuncCall, 'strtolower')) {
return null;
}
$secondArg = $args[1];
if (!$secondArg->value instanceof String_) {
return null;
}
if (Strings::match($secondArg->value->value, self::UPPERCASE_REGEX) !== null) {
return null;
}
// pop 1 level up
$node->args[0] = $innerFuncCall->getArgs()[0];
$node->name = new Name('stripos');

View File

@ -22,6 +22,7 @@ use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\ElseIf_;
use PhpParser\Node\Stmt\If_;
use PHPStan\Type\MixedType;
use PHPStan\Type\ObjectType;
use Rector\NodeTypeResolver\TypeAnalyzer\ArrayTypeAnalyzer;
use Rector\NodeTypeResolver\TypeAnalyzer\StringTypeAnalyzer;
@ -110,8 +111,8 @@ CODE_SAMPLE
if ($conditionNode instanceof Bool_) {
return null;
}
$conditionStaticType = $this->getType($conditionNode);
if ($conditionStaticType->isBoolean()->yes()) {
$conditionStaticType = $this->nodeTypeResolver->getNativeType($conditionNode);
if ($conditionStaticType instanceof MixedType || $conditionStaticType->isBoolean()->yes()) {
return null;
}
$binaryOp = $this->resolveNewConditionNode($conditionNode, $isNegated);

View File

@ -5,7 +5,9 @@ namespace Rector\CodeQuality\Rector\If_;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\BinaryOp\Equal;
use PhpParser\Node\Expr\BinaryOp\Identical;
use PhpParser\Node\Expr\BinaryOp\NotEqual;
use PhpParser\Node\Expr\BinaryOp\NotIdentical;
use PhpParser\Node\Expr\BooleanNot;
use PhpParser\Node\Stmt\Else_;
@ -140,7 +142,7 @@ CODE_SAMPLE
if (\strpos($condString, '!=') === \false) {
return !$this->valueResolver->isTrueOrFalse($return->expr);
}
return !$if->cond instanceof NotIdentical;
return !$if->cond instanceof NotIdentical && !$if->cond instanceof NotEqual;
}
private function processReturnTrue(If_ $if, Return_ $nextReturn) : Return_
{
@ -155,6 +157,10 @@ CODE_SAMPLE
$notIdentical = new NotIdentical($if->cond->left, $if->cond->right);
return new Return_($this->exprBoolCaster->boolCastOrNullCompareIfNeeded($notIdentical));
}
if ($if->cond instanceof Equal) {
$notIdentical = new NotEqual($if->cond->left, $if->cond->right);
return new Return_($this->exprBoolCaster->boolCastOrNullCompareIfNeeded($notIdentical));
}
if (!$nextReturn->expr instanceof Expr) {
return null;
}
@ -207,6 +213,10 @@ CODE_SAMPLE
$if->cond = new Identical($if->cond->left, $if->cond->right);
return $this->processReturnTrue($if, $return);
}
if ($if->cond instanceof NotEqual && $this->valueResolver->isTrue($expr)) {
$if->cond = new Equal($if->cond->left, $if->cond->right);
return $this->processReturnTrue($if, $return);
}
return $this->processReturnFalse($if, $return);
}
return null;

View File

@ -3,7 +3,7 @@
declare (strict_types=1);
namespace Rector\CodeQuality\Rector\Include_;
use RectorPrefix202402\Nette\Utils\Strings;
use RectorPrefix202405\Nette\Utils\Strings;
use PhpParser\Node;
use PhpParser\Node\Expr\BinaryOp\Concat;
use PhpParser\Node\Expr\Include_;

View File

@ -53,6 +53,6 @@ final class SimplifyTautologyTernaryRector extends AbstractRector
if (!$twoNodeMatch instanceof TwoNodeMatch) {
return null;
}
return $node->if;
return $node->cond instanceof NotIdentical ? $node->if : $node->else;
}
}

View File

@ -3,7 +3,7 @@
declare (strict_types=1);
namespace Rector\CodingStyle\Application;
use RectorPrefix202402\Nette\Utils\Strings;
use RectorPrefix202405\Nette\Utils\Strings;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\Declare_;

View File

@ -3,11 +3,10 @@
declare (strict_types=1);
namespace Rector\CodingStyle\ClassNameImport\ClassNameImportSkipVoter;
use RectorPrefix202402\Nette\Utils\Strings;
use RectorPrefix202405\Nette\Utils\Strings;
use PhpParser\Node;
use Rector\CodingStyle\ClassNameImport\ShortNameResolver;
use Rector\CodingStyle\Contract\ClassNameImport\ClassNameImportSkipVoterInterface;
use Rector\Configuration\RenamedClassesDataCollector;
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
use Rector\ValueObject\Application\File;
/**
@ -26,15 +25,9 @@ final class FullyQualifiedNameClassNameImportSkipVoter implements ClassNameImpor
* @var \Rector\CodingStyle\ClassNameImport\ShortNameResolver
*/
private $shortNameResolver;
/**
* @readonly
* @var \Rector\Configuration\RenamedClassesDataCollector
*/
private $renamedClassesDataCollector;
public function __construct(ShortNameResolver $shortNameResolver, RenamedClassesDataCollector $renamedClassesDataCollector)
public function __construct(ShortNameResolver $shortNameResolver)
{
$this->shortNameResolver = $shortNameResolver;
$this->renamedClassesDataCollector = $renamedClassesDataCollector;
}
public function shouldSkip(File $file, FullyQualifiedObjectType $fullyQualifiedObjectType, Node $node) : bool
{
@ -43,7 +36,6 @@ final class FullyQualifiedNameClassNameImportSkipVoter implements ClassNameImpor
$shortNamesToFullyQualifiedNames = $this->shortNameResolver->resolveFromFile($file);
$fullyQualifiedObjectTypeShortName = $fullyQualifiedObjectType->getShortName();
$className = $fullyQualifiedObjectType->getClassName();
$removedUses = $this->renamedClassesDataCollector->getOldClasses();
foreach ($shortNamesToFullyQualifiedNames as $shortName => $fullyQualifiedName) {
if ($fullyQualifiedObjectTypeShortName !== $shortName) {
$shortName = $this->cleanShortName($shortName);
@ -52,10 +44,7 @@ final class FullyQualifiedNameClassNameImportSkipVoter implements ClassNameImpor
continue;
}
$fullyQualifiedName = \ltrim($fullyQualifiedName, '\\');
if ($className === $fullyQualifiedName) {
return \false;
}
return !\in_array($fullyQualifiedName, $removedUses, \true);
return $className !== $fullyQualifiedName;
}
return \false;
}

View File

@ -3,7 +3,6 @@
declare (strict_types=1);
namespace Rector\CodingStyle\ClassNameImport;
use RectorPrefix202402\Nette\Utils\Reflection;
use PhpParser\Node;
use PhpParser\Node\Identifier;
use PhpParser\Node\Name;
@ -12,8 +11,6 @@ use PhpParser\Node\Stmt\ClassLike;
use PhpParser\Node\Stmt\Namespace_;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\ReflectionProvider;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
use Rector\CodingStyle\NodeAnalyzer\UseImportNameMatcher;
@ -24,7 +21,6 @@ use Rector\PhpDocParser\PhpDocParser\PhpDocNodeTraverser;
use Rector\PhpParser\Node\BetterNodeFinder;
use Rector\PhpParser\Node\CustomNode\FileWithoutNamespace;
use Rector\ValueObject\Application\File;
use ReflectionClass;
/**
* @see \Rector\Tests\CodingStyle\ClassNameImport\ShortNameResolver\ShortNameResolverTest
*/
@ -40,11 +36,6 @@ final class ShortNameResolver
* @var \Rector\NodeNameResolver\NodeNameResolver
*/
private $nodeNameResolver;
/**
* @readonly
* @var \PHPStan\Reflection\ReflectionProvider
*/
private $reflectionProvider;
/**
* @readonly
* @var \Rector\PhpParser\Node\BetterNodeFinder
@ -64,11 +55,10 @@ final class ShortNameResolver
* @var array<string, string[]>
*/
private $shortNamesByFilePath = [];
public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeNameResolver $nodeNameResolver, ReflectionProvider $reflectionProvider, BetterNodeFinder $betterNodeFinder, UseImportNameMatcher $useImportNameMatcher, PhpDocInfoFactory $phpDocInfoFactory)
public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder, UseImportNameMatcher $useImportNameMatcher, PhpDocInfoFactory $phpDocInfoFactory)
{
$this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser;
$this->nodeNameResolver = $nodeNameResolver;
$this->reflectionProvider = $reflectionProvider;
$this->betterNodeFinder = $betterNodeFinder;
$this->useImportNameMatcher = $useImportNameMatcher;
$this->phpDocInfoFactory = $phpDocInfoFactory;
@ -152,7 +142,6 @@ final class ShortNameResolver
*/
private function resolveFromStmtsDocBlocks(array $stmts) : array
{
$classReflection = $this->resolveClassReflection($stmts);
$shortNames = [];
$this->simpleCallableNodeTraverser->traverseNodesWithCallable($stmts, function (Node $node) use(&$shortNames) {
// speed up for nodes that are
@ -176,42 +165,22 @@ final class ShortNameResolver
});
return null;
});
return $this->fqnizeShortNames($shortNames, $classReflection, $stmts);
}
/**
* @param Node[] $stmts
*/
private function resolveClassReflection(array $stmts) : ?ClassReflection
{
$firstClassLike = $this->betterNodeFinder->findFirstInstanceOf($stmts, ClassLike::class);
if (!$firstClassLike instanceof ClassLike) {
return null;
}
$className = (string) $this->nodeNameResolver->getName($firstClassLike);
if (!$this->reflectionProvider->hasClass($className)) {
return null;
}
return $this->reflectionProvider->getClass($className);
return $this->fqnizeShortNames($shortNames, $stmts);
}
/**
* @param string[] $shortNames
* @param Stmt[] $stmts
* @return array<string, string>
*/
private function fqnizeShortNames(array $shortNames, ?ClassReflection $classReflection, array $stmts) : array
private function fqnizeShortNames(array $shortNames, array $stmts) : array
{
$shortNamesToFullyQualifiedNames = [];
$nativeReflectionClass = $classReflection instanceof ClassReflection && !$classReflection->isAnonymous() ? $classReflection->getNativeReflection() : null;
foreach ($shortNames as $shortName) {
$stmtsMatchedName = $this->useImportNameMatcher->matchNameWithStmts($shortName, $stmts);
if ($nativeReflectionClass instanceof ReflectionClass) {
$fullyQualifiedName = Reflection::expandClassName($shortName, $nativeReflectionClass);
} elseif (\is_string($stmtsMatchedName)) {
$fullyQualifiedName = $stmtsMatchedName;
} else {
$fullyQualifiedName = $shortName;
if ($stmtsMatchedName == null) {
continue;
}
$shortNamesToFullyQualifiedNames[$shortName] = $fullyQualifiedName;
$shortNamesToFullyQualifiedNames[$shortName] = $stmtsMatchedName;
}
return $shortNamesToFullyQualifiedNames;
}

View File

@ -3,7 +3,7 @@
declare (strict_types=1);
namespace Rector\CodingStyle\Naming;
use RectorPrefix202402\Nette\Utils\Strings;
use RectorPrefix202405\Nette\Utils\Strings;
use PhpParser\Node\Identifier;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt\ClassLike;

View File

@ -3,7 +3,7 @@
declare (strict_types=1);
namespace Rector\CodingStyle\NodeAnalyzer;
use RectorPrefix202402\Nette\Utils\Strings;
use RectorPrefix202405\Nette\Utils\Strings;
use PhpParser\Node\Identifier;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\GroupUse;

View File

@ -3,7 +3,7 @@
declare (strict_types=1);
namespace Rector\CodingStyle\Rector\Catch_;
use RectorPrefix202402\Nette\Utils\Strings;
use RectorPrefix202405\Nette\Utils\Strings;
use PhpParser\Node;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\Closure;

View File

@ -85,17 +85,28 @@ CODE_SAMPLE
if (!$classReflection instanceof ClassReflection) {
return null;
}
if ($classReflection->isAnonymous()) {
return null;
}
$parentClassReflections = $classReflection->getParents();
if ($parentClassReflections === []) {
return null;
}
$hasChanged = \false;
$interfaces = $classReflection->getInterfaces();
foreach ($node->getMethods() as $classMethod) {
if ($classMethod->isMagic()) {
continue;
}
/** @var string $methodName */
$methodName = $this->getName($classMethod->name);
if ($classMethod->isPublic()) {
foreach ($interfaces as $interface) {
if ($interface->hasNativeMethod($methodName)) {
continue 2;
}
}
}
foreach ($parentClassReflections as $parentClassReflection) {
$nativeClassReflection = $parentClassReflection->getNativeReflection();
// the class reflection above takes also @method annotations into an account

View File

@ -3,7 +3,7 @@
declare (strict_types=1);
namespace Rector\CodingStyle\Rector\Encapsed;
use RectorPrefix202402\Nette\Utils\Strings;
use RectorPrefix202405\Nette\Utils\Strings;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr;

View File

@ -89,6 +89,7 @@ CODE_SAMPLE
}
\end($node->stmts);
$totalKeys = \key($node->stmts);
\reset($node->stmts);
for ($key = $jumpToKey; $key < $totalKeys; ++$key) {
if (!isset($node->stmts[$key], $node->stmts[$key + 1])) {
break;
@ -122,7 +123,7 @@ CODE_SAMPLE
}
/**
* @param int|float $rangeLine
* @return int|float
* @return float|int
*/
private function resolveRangeLineFromComment($rangeLine, int $line, int $endLine, Stmt $nextStmt)
{

View File

@ -3,7 +3,7 @@
declare (strict_types=1);
namespace Rector\CodingStyle\Rector\Stmt;
use RectorPrefix202402\Nette\Utils\Strings;
use RectorPrefix202405\Nette\Utils\Strings;
use PhpParser\Node;
use PhpParser\Node\Identifier;
use PhpParser\Node\Stmt\Namespace_;

View File

@ -3,7 +3,7 @@
declare (strict_types=1);
namespace Rector\CodingStyle\Rector\String_;
use RectorPrefix202402\Nette\Utils\Strings;
use RectorPrefix202405\Nette\Utils\Strings;
use PhpParser\Node;
use PhpParser\Node\Expr\ClassConstFetch;
use PhpParser\Node\Name\FullyQualified;

View File

@ -3,6 +3,7 @@
declare (strict_types=1);
namespace Rector\CodingStyle\Reflection;
use PHPStan\Reflection\FunctionReflection;
use PHPStan\Reflection\MethodReflection;
use Rector\FileSystem\FilePathHelper;
final class VendorLocationDetector
@ -20,6 +21,15 @@ final class VendorLocationDetector
{
$declaringClassReflection = $methodReflection->getDeclaringClass();
$fileName = $declaringClassReflection->getFileName();
return $this->detect($fileName);
}
public function detectFunctionReflection(FunctionReflection $functionReflection) : bool
{
$fileName = $functionReflection->getFileName();
return $this->detect($fileName);
}
private function detect(?string $fileName = null) : bool
{
// probably internal
if ($fileName === null) {
return \false;

View File

@ -4,6 +4,7 @@ declare (strict_types=1);
namespace Rector\DeadCode\NodeAnalyzer;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\NullsafeMethodCall;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Identifier;
use PhpParser\Node\Name;
@ -29,7 +30,7 @@ final class CallCollectionAnalyzer
$this->nodeNameResolver = $nodeNameResolver;
}
/**
* @param StaticCall[]|MethodCall[] $calls
* @param StaticCall[]|MethodCall[]|NullsafeMethodCall[] $calls
*/
public function isExists(array $calls, string $classMethodName, string $className) : bool
{
@ -52,14 +53,14 @@ final class CallCollectionAnalyzer
return \false;
}
/**
* @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $call
* @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\NullsafeMethodCall $call
*/
private function isSelfStatic($call) : bool
{
return $call instanceof StaticCall && $call->class instanceof Name && \in_array($call->class->toString(), [ObjectReference::SELF, ObjectReference::STATIC], \true);
}
/**
* @param \PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall $call
* @param \PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\NullsafeMethodCall $call
*/
private function shouldSkip($call, string $classMethodName) : bool
{

View File

@ -9,6 +9,7 @@ use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\ArrayItem;
use PhpParser\Node\Expr\CallLike;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\NullsafeMethodCall;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt\Class_;
@ -88,11 +89,15 @@ final class IsClassMethodUsedAnalyzer
if ($this->isClassMethodCalledInLocalMethodCall($class, $classMethodName)) {
return \true;
}
// 2. direct static calls
// 2. direct null-safe calls
if ($this->isClassMethodCalledInLocalNullsafeMethodCall($class, $classMethodName)) {
return \true;
}
// 3. direct static calls
if ($this->isClassMethodUsedInLocalStaticCall($class, $classMethodName)) {
return \true;
}
// 3. magic array calls!
// 4. magic array calls!
if ($this->isClassMethodCalledInLocalArrayCall($class, $classMethod, $scope)) {
return \true;
}
@ -113,6 +118,13 @@ final class IsClassMethodUsedAnalyzer
$methodCalls = $this->betterNodeFinder->findInstanceOf($class, MethodCall::class);
return $this->callCollectionAnalyzer->isExists($methodCalls, $classMethodName, $className);
}
private function isClassMethodCalledInLocalNullsafeMethodCall(Class_ $class, string $classMethodName) : bool
{
$className = (string) $this->nodeNameResolver->getName($class);
/** @var Node\Expr\NullsafeMethodCall[] $methodCalls */
$methodCalls = $this->betterNodeFinder->findInstanceOf($class, NullsafeMethodCall::class);
return $this->callCollectionAnalyzer->isExists($methodCalls, $classMethodName, $className);
}
private function isInArrayMap(Class_ $class, Array_ $array) : bool
{
if (!$array->getAttribute(ArrayMapArgVisitor::ATTRIBUTE_NAME) instanceof Arg) {
@ -134,11 +146,12 @@ final class IsClassMethodUsedAnalyzer
{
/** @var Array_[] $arrays */
$arrays = $this->betterNodeFinder->findInstanceOf($class, Array_::class);
$classMethodName = $this->nodeNameResolver->getName($classMethod);
foreach ($arrays as $array) {
if ($this->isInArrayMap($class, $array)) {
return \true;
}
$arrayCallable = $this->arrayCallableMethodMatcher->match($array, $scope);
$arrayCallable = $this->arrayCallableMethodMatcher->match($array, $scope, $classMethodName);
if ($arrayCallable instanceof ArrayCallableDynamicMethod) {
return \true;
}

View File

@ -5,6 +5,7 @@ namespace Rector\DeadCode\NodeAnalyzer;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\NullsafePropertyFetch;
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Expr\StaticPropertyFetch;
use PhpParser\Node\Stmt\Class_;
@ -24,7 +25,7 @@ final class PropertyWriteonlyAnalyzer
public function hasClassDynamicPropertyNames(Class_ $class) : bool
{
return (bool) $this->betterNodeFinder->findFirst($class, static function (Node $node) : bool {
if (!$node instanceof PropertyFetch) {
if (!$node instanceof PropertyFetch && !$node instanceof NullsafePropertyFetch) {
return \false;
}
// has dynamic name - could be anything
@ -34,7 +35,7 @@ final class PropertyWriteonlyAnalyzer
/**
* The property fetches are always only assigned to, nothing else
*
* @param array<PropertyFetch|StaticPropertyFetch> $propertyFetches
* @param array<PropertyFetch|StaticPropertyFetch|NullsafePropertyFetch> $propertyFetches
*/
public function arePropertyFetchesExclusivelyBeingAssignedTo(array $propertyFetches) : bool
{

View File

@ -0,0 +1,66 @@
<?php
declare (strict_types=1);
namespace Rector\DeadCode\NodeAnalyzer;
use PhpParser\Node;
use PhpParser\Node\Expr\ArrayDimFetch;
use PhpParser\Node\Expr\BinaryOp\BooleanAnd;
use PhpParser\Node\Expr\BinaryOp\BooleanOr;
use PhpParser\Node\Expr\Instanceof_;
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Expr\StaticPropertyFetch;
use PhpParser\Node\Expr\Variable;
use PHPStan\Reflection\ClassReflection;
use Rector\NodeAnalyzer\ExprAnalyzer;
use Rector\PhpParser\Node\BetterNodeFinder;
use Rector\Reflection\ReflectionResolver;
final class SafeLeftTypeBooleanAndOrAnalyzer
{
/**
* @readonly
* @var \Rector\PhpParser\Node\BetterNodeFinder
*/
private $betterNodeFinder;
/**
* @readonly
* @var \Rector\NodeAnalyzer\ExprAnalyzer
*/
private $exprAnalyzer;
/**
* @readonly
* @var \Rector\Reflection\ReflectionResolver
*/
private $reflectionResolver;
public function __construct(BetterNodeFinder $betterNodeFinder, ExprAnalyzer $exprAnalyzer, ReflectionResolver $reflectionResolver)
{
$this->betterNodeFinder = $betterNodeFinder;
$this->exprAnalyzer = $exprAnalyzer;
$this->reflectionResolver = $reflectionResolver;
}
/**
* @param \PhpParser\Node\Expr\BinaryOp\BooleanAnd|\PhpParser\Node\Expr\BinaryOp\BooleanOr $booleanAnd
*/
public function isSafe($booleanAnd) : bool
{
$hasNonTypedFromParam = (bool) $this->betterNodeFinder->findFirst($booleanAnd->left, function (Node $node) : bool {
return $node instanceof Variable && $this->exprAnalyzer->isNonTypedFromParam($node);
});
if ($hasNonTypedFromParam) {
return \false;
}
$hasPropertyFetchOrArrayDimFetch = (bool) $this->betterNodeFinder->findFirst($booleanAnd->left, static function (Node $node) : bool {
return $node instanceof PropertyFetch || $node instanceof StaticPropertyFetch || $node instanceof ArrayDimFetch;
});
// get type from Property and ArrayDimFetch is unreliable
if ($hasPropertyFetchOrArrayDimFetch) {
return \false;
}
// skip trait this
$classReflection = $this->reflectionResolver->resolveClassReflection($booleanAnd);
if ($classReflection instanceof ClassReflection && $classReflection->isTrait()) {
return !$booleanAnd->left instanceof Instanceof_;
}
return \true;
}
}

View File

@ -10,6 +10,7 @@ use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger;
use Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode;
use Rector\DeadCode\PhpDoc\Guard\StandaloneTypeRemovalGuard;
use Rector\DeadCode\TypeNodeAnalyzer\GenericTypeNodeAnalyzer;
use Rector\DeadCode\TypeNodeAnalyzer\MixedArrayTypeNodeAnalyzer;
use Rector\NodeNameResolver\NodeNameResolver;
@ -47,7 +48,12 @@ final class DeadParamTagValueNodeAnalyzer
* @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger
*/
private $phpDocTypeChanger;
public function __construct(NodeNameResolver $nodeNameResolver, TypeComparator $typeComparator, GenericTypeNodeAnalyzer $genericTypeNodeAnalyzer, MixedArrayTypeNodeAnalyzer $mixedArrayTypeNodeAnalyzer, ParamAnalyzer $paramAnalyzer, PhpDocTypeChanger $phpDocTypeChanger)
/**
* @readonly
* @var \Rector\DeadCode\PhpDoc\Guard\StandaloneTypeRemovalGuard
*/
private $standaloneTypeRemovalGuard;
public function __construct(NodeNameResolver $nodeNameResolver, TypeComparator $typeComparator, GenericTypeNodeAnalyzer $genericTypeNodeAnalyzer, MixedArrayTypeNodeAnalyzer $mixedArrayTypeNodeAnalyzer, ParamAnalyzer $paramAnalyzer, PhpDocTypeChanger $phpDocTypeChanger, StandaloneTypeRemovalGuard $standaloneTypeRemovalGuard)
{
$this->nodeNameResolver = $nodeNameResolver;
$this->typeComparator = $typeComparator;
@ -55,6 +61,7 @@ final class DeadParamTagValueNodeAnalyzer
$this->mixedArrayTypeNodeAnalyzer = $mixedArrayTypeNodeAnalyzer;
$this->paramAnalyzer = $paramAnalyzer;
$this->phpDocTypeChanger = $phpDocTypeChanger;
$this->standaloneTypeRemovalGuard = $standaloneTypeRemovalGuard;
}
public function isDead(ParamTagValueNode $paramTagValueNode, FunctionLike $functionLike) : bool
{
@ -78,11 +85,15 @@ final class DeadParamTagValueNodeAnalyzer
return \false;
}
if (!$paramTagValueNode->type instanceof BracketsAwareUnionTypeNode) {
return \true;
return $this->standaloneTypeRemovalGuard->isLegal($paramTagValueNode->type, $param->type);
}
if ($this->mixedArrayTypeNodeAnalyzer->hasMixedArrayType($paramTagValueNode->type)) {
return $this->isAllowedBracketAwareUnion($paramTagValueNode->type);
}
private function isAllowedBracketAwareUnion(BracketsAwareUnionTypeNode $bracketsAwareUnionTypeNode) : bool
{
if ($this->mixedArrayTypeNodeAnalyzer->hasMixedArrayType($bracketsAwareUnionTypeNode)) {
return \false;
}
return !$this->genericTypeNodeAnalyzer->hasGenericType($paramTagValueNode->type);
return !$this->genericTypeNodeAnalyzer->hasGenericType($bracketsAwareUnionTypeNode);
}
}

View File

@ -7,7 +7,7 @@ use PhpParser\Node\FunctionLike;
use PHPStan\PhpDocParser\Ast\Node;
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode;
use PHPStan\Type\Type;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
use Rector\Comments\NodeDocBlock\DocBlockUpdater;
use Rector\DeadCode\PhpDoc\DeadParamTagValueNodeAnalyzer;
@ -29,11 +29,11 @@ final class ParamTagRemover
$this->deadParamTagValueNodeAnalyzer = $deadParamTagValueNodeAnalyzer;
$this->docBlockUpdater = $docBlockUpdater;
}
public function removeParamTagsIfUseless(PhpDocInfo $phpDocInfo, FunctionLike $functionLike) : bool
public function removeParamTagsIfUseless(PhpDocInfo $phpDocInfo, FunctionLike $functionLike, ?Type $type = null) : bool
{
$hasChanged = \false;
$phpDocNodeTraverser = new PhpDocNodeTraverser();
$phpDocNodeTraverser->traverseWithCallable($phpDocInfo->getPhpDocNode(), '', function (Node $docNode) use($functionLike, &$hasChanged) : ?int {
$phpDocNodeTraverser->traverseWithCallable($phpDocInfo->getPhpDocNode(), '', function (Node $docNode) use($functionLike, &$hasChanged, $type, $phpDocInfo) : ?int {
if (!$docNode instanceof PhpDocTagNode) {
return null;
}
@ -44,8 +44,12 @@ final class ParamTagRemover
if ($docNode->name !== '@param') {
return null;
}
// skip union types
if ($docNode->value->type instanceof UnionTypeNode) {
$paramType = $phpDocInfo->getParamType($docNode->value->parameterName);
if ($type instanceof Type) {
if ($type->equals($paramType)) {
$hasChanged = \true;
return PhpDocNodeTraverser::NODE_REMOVE;
}
return null;
}
if (!$this->deadParamTagValueNodeAnalyzer->isDead($docNode->value, $functionLike)) {

View File

@ -14,6 +14,7 @@ use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger;
use Rector\Comments\NodeDocBlock\DocBlockUpdater;
use Rector\DeadCode\PhpDoc\DeadVarTagValueNodeAnalyzer;
use Rector\NodeTypeResolver\TypeComparator\TypeComparator;
use Rector\PHPStanStaticTypeMapper\DoctrineTypeAnalyzer;
final class VarTagRemover
{
@ -42,13 +43,19 @@ final class VarTagRemover
* @var \Rector\Comments\NodeDocBlock\DocBlockUpdater
*/
private $docBlockUpdater;
public function __construct(DoctrineTypeAnalyzer $doctrineTypeAnalyzer, PhpDocInfoFactory $phpDocInfoFactory, DeadVarTagValueNodeAnalyzer $deadVarTagValueNodeAnalyzer, PhpDocTypeChanger $phpDocTypeChanger, DocBlockUpdater $docBlockUpdater)
/**
* @readonly
* @var \Rector\NodeTypeResolver\TypeComparator\TypeComparator
*/
private $typeComparator;
public function __construct(DoctrineTypeAnalyzer $doctrineTypeAnalyzer, PhpDocInfoFactory $phpDocInfoFactory, DeadVarTagValueNodeAnalyzer $deadVarTagValueNodeAnalyzer, PhpDocTypeChanger $phpDocTypeChanger, DocBlockUpdater $docBlockUpdater, TypeComparator $typeComparator)
{
$this->doctrineTypeAnalyzer = $doctrineTypeAnalyzer;
$this->phpDocInfoFactory = $phpDocInfoFactory;
$this->deadVarTagValueNodeAnalyzer = $deadVarTagValueNodeAnalyzer;
$this->phpDocTypeChanger = $phpDocTypeChanger;
$this->docBlockUpdater = $docBlockUpdater;
$this->typeComparator = $typeComparator;
}
public function removeVarTagIfUseless(PhpDocInfo $phpDocInfo, Property $property) : bool
{
@ -92,7 +99,15 @@ final class VarTagRemover
if ($this->phpDocTypeChanger->isAllowed($varTagValueNode->type)) {
return;
}
// keep subtypes like positive-int
if ($this->shouldKeepSubtypes($type, $phpDocInfo->getVarType())) {
return;
}
$phpDocInfo->removeByType(VarTagValueNode::class);
$this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($node);
}
private function shouldKeepSubtypes(Type $type, Type $varType) : bool
{
return !$this->typeComparator->areTypesEqual($type, $varType) && $this->typeComparator->isSubtype($varType, $type);
}
}

View File

@ -95,10 +95,7 @@ CODE_SAMPLE
return null;
}
// we cannot be sure here
if ($this->containsCompactFuncCall($node)) {
return null;
}
if ($this->containsFileIncludes($node)) {
if ($this->shouldSkip($stmts)) {
return null;
}
$assignedVariableNamesByStmtPosition = $this->resolvedAssignedVariablesByStmtPosition($stmts);
@ -165,24 +162,19 @@ CODE_SAMPLE
return \false;
}
/**
* @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike
* @param Stmt[] $stmts
*/
private function containsCompactFuncCall($functionLike) : bool
private function shouldSkip(array $stmts) : bool
{
$compactFuncCall = $this->betterNodeFinder->findFirst($functionLike, function (Node $node) : bool {
return (bool) $this->betterNodeFinder->findFirst($stmts, function (Node $node) : bool {
if ($node instanceof Include_) {
return \true;
}
if (!$node instanceof FuncCall) {
return \false;
}
return $this->isName($node, 'compact');
});
return $compactFuncCall instanceof FuncCall;
}
/**
* @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike
*/
private function containsFileIncludes($functionLike) : bool
{
return (bool) $this->betterNodeFinder->findInstancesOf($functionLike, [Include_::class]);
}
/**
* @param array<int, Stmt> $stmts

View File

@ -93,7 +93,7 @@ CODE_SAMPLE
if (!isset(self::CAST_CLASS_TO_NODE_TYPE[$nodeClass])) {
return null;
}
$nodeType = $this->getType($node->expr);
$nodeType = $this->nodeTypeResolver->getNativeType($node->expr);
if ($nodeType instanceof MixedType) {
return null;
}

View File

@ -17,7 +17,7 @@ use Rector\Contract\Rector\ConfigurableRectorInterface;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
use RectorPrefix202402\Webmozart\Assert\Assert;
use RectorPrefix202405\Webmozart\Assert\Assert;
/**
* @see \Rector\Tests\DeadCode\Rector\ClassLike\RemoveAnnotationRector\RemoveAnnotationRectorTest
*/

Some files were not shown because too many files have changed in this diff Show More