Commit Graph

1275 Commits

Author SHA1 Message Date
Tomas Votruba
f5a06553ce
[CodeQuality] Add InlineIsAInstanceOfRector (#2364) 2022-05-27 00:01:06 +02:00
Abdul Malik Ikhsan
3da22b0231
[Php81] Skip ArrayDimFetch from ArrayObject in Assign var on ReadOnlyPropertyRector (#2363)
* [Php81] Skip ArrayDimFetch from ArrayObject in Assign var on ReadOnlyPropertyRector

* Fixed 🎉

* eol
2022-05-26 09:13:59 +02:00
Tomas Votruba
66dbb1e307
Allow to rename method if in interface (#2362)
* add test fixture

* allow rename method in interface
2022-05-25 21:35:18 +00:00
Abdul Malik Ikhsan
5d0138dcef
Fixture class name fix (#2360) 2022-05-25 07:35:48 +00:00
Abdul Malik Ikhsan
9c6b3d708c
[TypeDeclaration] Skip curly {@inheritdoc} on AddArrayReturnDocTypeRector (#2359) 2022-05-25 09:26:56 +02:00
Abdul Malik Ikhsan
4c53b206a4
[Php80] Do not remove array<mixed> inside Union type on UnionTypesRector (#2358)
* [Php80] Do not remove array<mixed> inside Union type on UnionTypesRector

* Fixed 🎉

* also allow mixed[]

* clean up

* clean up
2022-05-25 08:52:50 +02:00
Abdul Malik Ikhsan
dc9189280f
[PHPStan] Update to PHPStan ^1.7.0 (#2354)
* [PHPStan] Update to PHPStan ^1.7.0

* [ci-review] Rector Rectify

* [ci-review] Rector Rectify

* already 1.7.1

* skip pull from PHPStan PhpPropertyReflection

* rename fixture

* debug

* Fixed 🎉

* keep mysqli object use case

Co-authored-by: GitHub Action <action@github.com>
2022-05-24 19:55:12 +07:00
Abdul Malik Ikhsan
f25715b7b3
[Php73] Skip Encapsed on StringifyStrNeedlesRector + Temporary Pin PHPStan 1.6.9 (#2352)
* [Php73] Skip Encapsed on StringifyStrNeedlesRector

* phpstan

* [ci-review] Rector Rectify

* [ci-review] Rector Rectify

* Fixed 🎉

* eol

* update requirement to PHPStan 1.7.0

* temporary pin to 1.6.9

* [ci-review] Rector Rectify

* [ci-review] Rector Rectify

Co-authored-by: GitHub Action <action@github.com>
2022-05-24 15:29:10 +07:00
Abdul Malik Ikhsan
1691157a64
[Core] Use PropertyFetchAnalyzer::isFilledViaMethodCallInConstructStmts() in ConstructorAssignDetector::isPropertyAssigned() (#2351)
* [Core] Use PropertyFetchAnalyzer::isFilledViaMethodCallInConstructStmts() in ConstructorAssignDetector::isPropertyAssigned()

* more

* [ci-review] Rector Rectify

* [ci-review] Rector Rectify

* [ci-review] Rector Rectify

* [ci-review] Rector Rectify

* add test for self static

* more tests

* phpstan

* [ci-review] Rector Rectify

* StaticPropertyFetch detection fix

* final touch: clean up: donot create object when not needed

* final touch: clean up

* final touch: clean up

* [ci-review] Rector Rectify

* [ci-review] Rector Rectify

* [ci-review] Rector Rectify

Co-authored-by: GitHub Action <action@github.com>
2022-05-23 21:06:50 +07:00
Abdul Malik Ikhsan
3fe07aa6a1
[Experiment][Naming] Keep GroupUse Stmt on UseImportsResolver::resolveForNode() (#2349)
Co-authored-by: GitHub Action <action@github.com>
2022-05-22 22:57:59 +02:00
Abdul Malik Ikhsan
f8c204adba
[Naming] Handle Grouped use import on UseImportsResolver (#2348)
Co-authored-by: Dominik Ritter <dritter03@googlemail.com>
Co-authored-by: GitHub Action <action@github.com>
2022-05-22 19:34:31 +02:00
Abdul Malik Ikhsan
68906c7e17
[DeadCode] Skip used in compact() on RemoveUnusedConstructorParamRector (#2345)
* [DeadCode] Skip used in compact() on RemoveUnusedConstructorParamRector

* Fixed 🎉

* phpstan

* phpstan

* [ci-review] Rector Rectify

Co-authored-by: GitHub Action <action@github.com>
2022-05-22 13:42:14 +02:00
Abdul Malik Ikhsan
fef1a03955
[DeadCode] Skip used in Closure use on RemoveUnusedConstructorParamRector (#2341) 2022-05-21 18:24:10 +02:00
Abdul Malik Ikhsan
1a56ec1736
[Php80] Handle default in previous not used in next switch (#2335)
* [Php80] Handle default in previous not used in next switch

* debug

* Fixed 🎉

* Fixed 🎉
2022-05-20 01:07:00 +07:00
Abdul Malik Ikhsan
3f0a0b7259
[Php80] Skip no default return fluent on ChangeSwitchToMatchRector (#2334) 2022-05-19 18:23:22 +02:00
Abdul Malik Ikhsan
f90acd4c3a
[DowngradePhp80] Handle inside Closure on DowngradeMatchToSwitchRector (#2333)
* [DowngradePhp80] Handle inside Closure on DowngradeMatchToSwitchRector

* Fixed 🎉

* CI tweak

* updated tests

* check parent structure

* verify original node

* clean up

* rollback

* run all tests with paratest
2022-05-19 21:25:28 +07:00
Abdul Malik Ikhsan
30a53bfd93
[DowngradePhp80] Add in arrow function in return support on DowngradeMatchToSwitchRector (#2331)
* [DowngradePhp80] Add in arrow function in return support on DowngradeMatchToSwitchRector

* Fixed 🎉

* [ci-review] Rector Rectify

* final touch: variable naming

* final touch: variable naming

* final touch: variable naming

* final touch: comment for future

* final touch: comment for future

* Fixed 🎉

* Fixed 🎉

* phpstan

* [ci-review] Rector Rectify

* fix test

Co-authored-by: GitHub Action <action@github.com>
2022-05-19 08:52:59 +02:00
Abdul Malik Ikhsan
36af81f0dd
[DowngradePhp80] Handle match inside ArrowFunction on DowngradeMatchToSwitchRector (#2330)
Co-authored-by: GitHub Action <action@github.com>
2022-05-18 17:19:35 +02:00
Abdul Malik Ikhsan
e33bcf19be
[Core] Override pModifiers() method to set final and abstract modifiers early on BetterStandardPrinter (#2328)
Co-authored-by: GitHub Action <action@github.com>
2022-05-18 12:41:43 +02:00
Abdul Malik Ikhsan
2c0f802aaf
[DeadCode] Allow return Nop Stmts (comments) on RemoveAlwaysTrueIfConditionRector (#2327) 2022-05-18 10:07:35 +02:00
Abdul Malik Ikhsan
50943ea4f2
[CodeQuality] Skip re use variable in assign Expr on InlineArrayReturnAssignRector (#2325)
* [CodeQuality] Skip re use variable in assign Expr on InlineArrayReturnAssignRector

* Fixed 🎉

* [ci-review] Rector Rectify

* final touch: move check for reuse

* matchKeyOnArrayDimFetchOfVariable never reuse

Co-authored-by: GitHub Action <action@github.com>
2022-05-18 08:29:33 +07:00
Abdul Malik Ikhsan
3ed69d7ecf
[CodeQuality] Apply StmtsAwareInterface node on SimplifyUselessVariableRector (#2310)
* [CodeQuality] Apply StmtsAwareInterface node on SimplifyUselessVariableRector

* implemented

* final touch: no need to continue when stmt is found, removal after return is handled on RemoveUnreachableStatementRector
2022-05-14 11:27:29 +02:00
USAMI Kenta
f92d5deca3
Fix Scalar_Encapsed node as dynamic in ExprAnalyzer::isDynamicExpr() (#2309)
* Add test to skip interpolated string conversion

* Fix Scalar_Encapsed node as dynamic in ExprAnalyzer::isDynamicExpr()
2022-05-14 09:36:09 +07:00
Abdul Malik Ikhsan
f0d68c75a1
[Php82] Fixtures for skip combination writable + readonly on ReadOnlyClassRector (#2304)
* [Php82] Fixtures for skip combination writable + readonly on ReadOnlyClassRector

* more
2022-05-12 16:03:54 +00:00
Abdul Malik Ikhsan
78aaf7ee0b
[Php82] Add ReadOnlyClassRector (#2296)
* [Php82] Add ReadOnlyClassRector

* skip has non-readonly property

* note

* note

* note

* [ci-review] Rector Rectify

* skip has AllowDynamicProperties attribute

* skip already readonly

* [ci-review] Rector Rectify

* skip property promotion not readonly

* no params means no property promotion, skip if no property defined

* note

* note

* skip final class, possibly extendable

* add fixture

* add @see

* visibility union ndoe rules/Privatization/NodeManipulator/VisibilityManipulator.php

* visibility union ndoe rules/Privatization/NodeManipulator/VisibilityManipulator.php

* remove already readonly fixture

* comment

* skip anonymous class fixture

* skip non-final class fixture

* skip allow dynamic fixture

* class check

* skip has writable property fixture

* skip no properties

* skip property promotion writable

* debug

* [ci-review] Rector Rectify

* fix

* eol

* fix

* [ci-review] Rector Rectify

* final touch: add up-to-php82 level setlist

Co-authored-by: GitHub Action <action@github.com>
2022-05-12 22:44:59 +07:00
Tomas Votruba
3bae3b9e75
[Downgrade] Separate multi level dependency in DowngradeArraySpreadRector (#2298) 2022-05-12 08:50:48 +00:00
Tomas Votruba
3d499125b8
Add Scope refresh for changed or new nodes (#2292) 2022-05-12 08:33:27 +02:00
Tomas Votruba
39e552c4c9
Various little improvement (#2297) 2022-05-12 08:07:50 +02:00
Tomas Votruba
1026ede751
Remove requires from tests, as all tests run on PHP 8.1 (#2293)
* remove requires from tests, as all tests run on PHP 8.1

* fix zero value
2022-05-12 00:15:54 +02:00
Tomas Votruba
17d200dfa6
[DX] Skip extra comment, add RectorConfig->rules() (#2290) 2022-05-11 16:45:25 +00:00
Tomas Votruba
9163864800
Remove DowngradeGeneratedScalarTypesRector as way hacky to particular string solution, better use patching (#2289) 2022-05-11 16:21:59 +00:00
Abdul Malik Ikhsan
12fa9407f7
[DeadCode] Skip @return static on return self when class is not final or in trait on RemoveUselessReturnTagRector (#2282)
* [DeadCode] Skip @return static on return self when class is not final

* Fixed 🎉

* eol

* reduce complexity

* fix

* reduce complexity

* [ci-review] Rector Rectify

* [ci-review] Rector Rectify

Co-authored-by: GitHub Action <action@github.com>
2022-05-11 08:06:19 +03:00
Abdul Malik Ikhsan
8b4c7c5fd8
[CodeQuality] Handle empty stmts on RemoveAlwaysTrueConditionSetInConstructorRector (#2281)
* [CodeQuality] Handle empty stmts on RemoveAlwaysTrueConditionSetInConstructorRector

* Fixed 🎉
2022-05-11 01:16:01 +00:00
Abdul Malik Ikhsan
ebd4c3fee6
[Renaming] Skip renaming method call on RenameMethodRector when both old and new exists, which implements interface as config (#2276)
* [Renaming] Skip renaming method call on RenameMethodRector when both old and new exists

* rollback fixture

* verify if caller is a class that implements interface, which both old and new method exists

* [ci-review] Rector Rectify

* clean up

* allow directly get ClassReflection from StaticCall/MethodCall from ReflectionResolver

* clean up

* [ci-review] Rector Rectify

* [ci-review] Rector Rectify

* [ci-review] Rector Rectify

* verify that classlike is different, it means it is a child

* final touch: comment

Co-authored-by: GitHub Action <action@github.com>
2022-05-11 07:32:41 +07:00
Tomas Votruba
27476c0909
add few fixtures (#2279) 2022-05-10 16:25:25 +00:00
Tomas Votruba
fa073d4408
[CodeQuality] Add SimplifyIfExactValueReturnValueRector (#2278) 2022-05-10 18:08:30 +02:00
Lenny4
4468743419
[FEAT] refacto OrderAttributesRector (#2243)
* [FEAT] refacto OrderAttributesRector to allow strategy instead of specific array

* [DOC] update doc OrderAttributesRector

* [FIX] add option default value

* [REFACTO] create SpecificOrder folder

* [TU] add tu AlphabeticallOrder

* [FIX] use isAlphabetically instead of duplicate function logic

* [FIX] fix phpstan errors

* [FIX] fix NoNestedFuncCallRule ignore rule for OrderAttributesRector
2022-05-09 12:44:14 +02:00
Tomas Votruba
975fdf113f
[DX] Add StmtsAwareInterface to catch node by type (#2269)
* add StmtsAwareInterface to catch node by type

* update build-preload

* use StmtsAwareInterface in InlineArrayReturnAssignRector
2022-05-08 20:50:37 +00:00
Abdul Malik Ikhsan
ae2e38ed98
[CodeQuality] Skip empty array push args and no 2nd arg on ChangeArrayPushToArrayAssignRector (#2266)
* [CodeQuality] Skip empty array push args and no 2nd arg on ChangeArrayPushToArrayAssignRector

* Fixed 🎉
2022-05-08 11:15:42 +00:00
Abdul Malik Ikhsan
fb8260c3a1
[DeadCode] Ensure no stmts check on RemovePhpVersionIdCheckRector (#2260)
* [DeadCode] Ensure no stmts check on RemovePhpVersionIdCheckRector

* [DeadCode] Ensure no stmts check on RemovePhpVersionIdCheckRector

* Fixed 🎉

* more fixture
2022-05-07 18:45:53 +00:00
Abdul Malik Ikhsan
3135f29362
[DeadCode] Ensure has stmts on RemoveDeadInstanceOfRector (#2252)
* [DeadCode] Ensure has stmts on RemoveDeadInstanceOfRector

* Fixed 🎉

* fix
2022-05-07 10:18:33 +00:00
Tomas Votruba
6d814fb385
Refactor DowngradePipeToMultiCatchExceptionRector to work directly with stmts (#2245) 2022-05-07 00:48:43 +02:00
Tomas Votruba
712237ec22
Error message improvements (#2242) 2022-05-06 07:36:43 +00:00
Tomas Votruba
ede1106a69
[DX] Improve DowngradeCatchThrowableRector to return nodes directly (#2241)
Co-authored-by: GitHub Action <action@github.com>
2022-05-06 09:09:50 +02:00
Tomas Votruba
561e3963e1
Use refactorWithScope() in MakeInheritedMethodVisibilitySameAsParentRector (#2236)
* make MakeInheritedMethodVisibilitySameAsParentRector work with scope and Class_ node

* use scope aware rule in ForeachItemsAssignToEmptyArrayToAssignRector

* use Scope aware method in ParamTypeDeclarationRector

* make DowngradeNonCapturingCatchesRector use of scope aware

* make RemoveDeadInstanceOfRector use of scope awre

* misc

* make ChangeMethodVisibilityRector use the scope aware

* make ParamTypeByParentCallTypeRector use of abstract scope aware

* make Php4ConstructorRector scope aware

* use Scope aware in AddClosureReturnTypeRector

* make DowngradeParentTypeDeclarationRector use of scope aware

* move up the loop

* cleanup static method check, not used
2022-05-05 19:36:21 +02:00
Abdul Malik Ikhsan
a19b983ce9
[DeadCode] Add StaticPropertyFetch removal support on RemoveUnusedPrivatePropertyRector (#2233)
* [DeadCode] Add StaticPropertyFetch removal support on RemoveUnusedPrivatePropertyRector

* implemented

* ensure local property fetch : this or self

* [ci-review] Rector Rectify

* [ci-review] Rector Rectify

* final touch: phpstan

Co-authored-by: GitHub Action <action@github.com>
2022-05-05 08:50:36 +00:00
Tomas Votruba
3184d55477
[DX] Use direct return of multi nodes instead of 2 addNode before/after node (#2232)
Co-authored-by: GitHub Action <action@github.com>
2022-05-05 10:25:46 +02:00
Abdul Malik Ikhsan
dd178deaa6
[DeadCode] Do not remove unused param in middle on RemoveUnusedConstructorParamRector (#2231)
* [DeadCode] Do not remove unused param in middle on RemoveUnusedConstructorParamRector

* more fixture

* Fixed 🎉

* Fixed 🎉
2022-05-05 14:39:19 +07:00
Tomas Votruba
0175838a0c
[DX] Cleanup ComplexNodeRemover (#2230)
* misc

* final

* cleanup

* [ci-review] Rector Rectify

Co-authored-by: GitHub Action <action@github.com>
2022-05-05 08:04:15 +02:00
Tomas Votruba
2d16736414
[DX] Remove poorly designed NodeToReplacePostRector, return changed nodes directly in the current rule (#2229) 2022-05-05 00:16:25 +02:00