75 Commits

Author SHA1 Message Date
Abdul Malik Ikhsan
6c813e5e4d
[Solid] Skip MoveVariableDeclarationNearReferenceRector when next statement has static call (#4914)
Co-authored-by: rector-bot <tomas@getrector.org>
2020-12-18 18:18:40 +01:00
Tomas Votruba
eddb2b29c9
[EarlyReturn] Decouple new rules (#4868) 2020-12-12 16:59:09 +00:00
Grzegorz Korba
21e5a6696c
Do not enforce interface-typing for classes with wider public API than defined by interface (#4845) 2020-12-10 18:55:34 +01:00
Abdul Malik Ikhsan
0e421247e8
[Solid] Skip ChangeAndIfToEarlyReturnRector on nested if in loop (#4757)
* ChangeAndIfToEarlyReturnRector: added failing test

* fix test warning

* rename test

* rename test

* try to fix the issue

* Update skip_nested_if_in_loop.inc

* rename fixture

* rename fixture

* extracted loop-types into constant

* fix

* refactor

* take Else_/ElseIf_ into account

* Update ChangeAndIfToEarlyReturnRector.php

* [Solid] Skip ChangeAndIfToEarlyReturnRector on nested if in loop, Closes #4728

* [ci-review] Rector Rectify

Co-authored-by: Tomas Votruba <tomas.vot@gmail.com>
Co-authored-by: Markus Staab <markus.staab@redaxo.de>
Co-authored-by: Markus Staab <maggus.staab@googlemail.com>
Co-authored-by: rector-bot <tomas@getrector.org>
2020-12-03 09:20:59 +01:00
TomasVotruba
275ef81062 fix missing deafault replace empty string 2020-12-01 15:00:00 +01:00
Markus Staab
ae0d38e1f0
added failing ChangeIfElseValueAssignToEarlyReturnRector test, regarding lost comments (#4698) 2020-11-27 17:38:07 +01:00
Markus Staab
04abc7af5c
create LostCommentBeforeElseIf failing test (#4697) 2020-11-27 17:33:16 +01:00
Markus Staab
972e0457cb
ChangeAndIfToEarlyReturnRector: added a failing testcase for continue-in-foreach (#4696)
* added a failing testcase

* initial try to fix 4693

* fix existing if_in_foreach test with wrong expected result

* Restore if_in_foreach.php.inc

* adusted wrong test expectation of if_in_foreach.php

* use betterNodeFinder->findFirstParentInstanceOf

* fix test expectation in if_in_foreach fixture

* fixed method name which was misleading

* fix variable name

* adjust impl

* Restore if_in_foreach.php.inc

* rm unused use

* fix impl
2020-11-27 16:10:48 +00:00
Markus Staab
fe47bc2cc7
ChangeAndIfToEarlyReturnRector: fix test expectation in if_in_foreach fixture (#4711)
* fix test expectation in if_in_foreach fixture

* fixed method name which was misleading

* fix variable name

* adjust impl
2020-11-27 13:59:56 +00:00
Abdul Malik Ikhsan
1c9cfafdda
[Solid] Fixes #4677 Skip MoveVariableDeclarationNearReferenceRector on multiple usage in Switch -> cases (#4678) 2020-11-23 22:23:44 +01:00
Abdul Malik Ikhsan
715b616ada
[Solid] use Variable node type for for MoveVariableDeclarationNearReferenceRector (#4670)
Co-authored-by: rector-bot <tomas@getrector.org>
2020-11-23 11:40:29 +01:00
Abdul Malik Ikhsan
f004f290c7
[Solid] Improve MoveVariableDeclarationNearReferenceRector : skip variable with usage in multiple level (#4643)
* [Solid] Improve MoveVariableDeclarationNearReferenceRector : skip variabel with usage in multiple level

* function name and var name

* stop calling parent attribute when previous of parent is an Expression with Assign with same variable

* phpstan

* deep up usage

* deeeeep level

* stop while when previous is Expression with Assign same var

* final touch

* [ci-review] Rector Rectify

* keep comment

* cast isFoundNext

* fixed

* separate method

* [ci-review] Rector Rectify

* clean up fixtures

Co-authored-by: rector-bot <tomas@getrector.org>
2020-11-18 21:26:54 +00:00
Tomas Votruba
0513315056
Change file system approach of MultipleClassFileToPsr4ClassesRector to file without namespace node (#4522)
* Change file system approach of MultipleClassFileToPsr4ClassesRector to file without namespace node

* update DecoupleClassMethodToOwnClassRector

* [ci] add rebase jobp

* disable fail fast for unit tests

* misc
2020-10-31 12:59:40 +00:00
Tomas Votruba
2c120e283e
Inform about useless second part in tests fixture, after -----, if it is identical (#4514)
* embed skip fixture of same before/after

* [Testing] Add exception on identical second half of the fixture, that should not change

* [ci] use composer 2 for code_analysis

* [ci-review] Rector Rectify

Co-authored-by: rector-bot <tomas@getrector.org>
2020-10-30 13:56:55 +00:00
Tomas Votruba
b302e493dd
[SOLID] Add MoveVariableDeclarationNearReferenceRector (#4410)
* Create test cases

* Create rector

* Add closure to possible parent scopes

* Register in SOLID set

* Document the feature

* fix adding variable in closure

* move MoveVariableDeclarationNearReferenceRector to Assign category, based on getNodeTypes()

* ci: drop phpunit matcher, not much helpful

* ignore for now, many cases to cover

* prepare release

Co-authored-by: Anna Filina <afilina@gmail.com>
2020-10-30 13:25:24 +00:00
Tomas Votruba
a1e50263d2
[cs] improve configured rules types (#4491)
* [cs] improve configured rules types

* [ci] update env variable
2020-10-27 14:00:39 +00:00
Igor
d017e5417e
[SOLID] Change if && to early return (process nested ifs) (#4395)
* [SOLID] Change if && to early return (process nested ifs)

* Skip if with void return

* Skip if parent if has void return

* [rector] Skip if parent if has void return

* [cs] Skip if parent if has void return

Co-authored-by: rector-bot <tomas@getrector.org>
2020-10-13 20:30:14 +02:00
Igor
874baec836
[SOLID] Change if && to early return (more than two conditions) (#4390)
Co-authored-by: rector-bot <tomas@getrector.org>
2020-10-11 11:43:51 +02:00
Tomas Votruba
4a76cdaa82
[SymfonyPHPConfig] Add monorepo split for value objects function (#4153)
* add monorepo split for symfony-php-config

* [SOLID] Prevent replacing referenced parametes with inlined constnat value

* make Symfon 5.0- compatible

* add support for reference skip in constructor

* [rector] add support for reference skip in constructor

* [cs] add support for reference skip in constructor

* improve misisng rule feedback

* underscore

* Fix ChangeReadOnlyVariableWithDefaultValueToConstantRector for new

* add clear-cache to all commands

* colors

* [rector] colors

* [cs] colors

Co-authored-by: rector-bot <tomas@getrector.org>
2020-10-10 17:42:43 +00:00
Igor
35537dba84
[SOLID] Change if && to early return (#4344)
Co-authored-by: rector-bot <tomas@getrector.org>
2020-10-10 18:27:13 +02:00
Tomas Votruba
d7f90774ee
allow php-parser 4.10 + fixes of args merge change (#4277)
* allow php-parser 4.10 + fixes of args merge change

* use fixed php-parser 4.10.1
2020-09-23 20:22:35 +00:00
Tomas Votruba
7ac228c638
[CI] Add type-declaration set (#4089)
* [CI] Add type-declaration set

* [rector] [CI] Add type-declaration set

* [cs] [CI] Add type-declaration set

* skip nullable void

* add anonymous parent/interface support

* refactor MultiExceptionCatchRector to use Catch_ over integers

* type fixes

* fix unoin array type override

* remove unused test cases

* drop overcomplicated InlineValidationRulesToArrayDefinitionRector

* skip assign on var

* [rector] skip assign on var

* [cs] skip assign on var

* [rector] [cs] skip assign on var

* skip assign on var

* fixes

* [rector] fixes

* [cs] fixes

Co-authored-by: rector-bot <tomas@getrector.org>
2020-09-01 17:56:30 +00:00
Tomas Votruba
042f08f71b
Drop YAML config support (#4081)
Co-authored-by: rector-bot <tomas@getrector.org>
2020-08-30 23:29:39 +02:00
Tomas Votruba
351e59fa3b
Fix array type (#4058)
Co-authored-by: rector-bot <tomas@getrector.org>
2020-08-29 16:20:27 +02:00
Tom Pavelec
dffcae0c82
Fixed some edge cases of creating constant name from value (#4041) 2020-08-27 17:08:49 +02:00
Tomas Votruba
1f61fe34f0
import repo entity (#3988)
* various fixes

* add import for generic types

* bump to newer phpstan with php-parser 4.9
2020-08-19 13:20:16 +00:00
dobryy
2e7bdca4e2
[DX] Rename namespaces respect node type (#3973) 2020-08-18 17:57:30 +02:00
Tomas Votruba
1c4b510513
PHPStan: require iterable types (#3936)
* phpstan: require iterable types

* add link on relative path and line

* fix missing class type

* typed array in Rector code + add data provide support resolver

* remove duplicated set

* drop unused yaml ecs config

* add out-of-the-box directory for 3rd party packages

* static fixes

* [rector] static fixes

* [cs] static fixes

* [rector] [cs] static fixes

* generic types

Co-authored-by: rector-bot <tomas@getrector.org>
2020-08-11 10:59:04 +00:00
Tomas Votruba
734d11f6c9
[SOLID] Skip func calls that change variable in ChangeReadOnlyVariableWithDefaultValueToConstantRector (#3916) 2020-08-07 00:25:25 +00:00
Tomas Votruba
484185aa8d
[SOLID] Skip property that is being changed by func call (#3898)
* add skip end function test case

* skip conversion of end() property
2020-08-04 13:02:12 +00:00
Tomas Votruba
55acb3578a
[MagicDisclosure] Add SetterOnSetterMethodCallToStandaloneAssignRector (#3860)
* [MagicDisclosure] Add MethodCallOnSetterMethodCallToStandaloneAssignRector

* merge ChainMethodCallManipulator to ChainMethodCallNodeAnalyzer for better DX

* [MagicDisclosure] Add in arg defluent

* rebase
2020-08-01 11:41:16 +00:00
TomasVotruba
fe72e003ed use constants in configs 2020-07-30 13:53:53 +02:00
TomasVotruba
7a5e0a446e fix foreach variable override in const decoupling 2020-07-12 10:36:33 +02:00
TomasVotruba
f00eb1c7b7 skip inversion of weak comparison 2020-07-05 01:58:13 +02:00
Derrick Schoen
09fd6fee8a Found a bug where if there is a nested if with an "OR" and all conditions evaluate to true, the rector changes the output.
When calling invertCondition() with a BooleanOr, it returns a BooleanAnd that needs a BooleanNot added.

Attempting to rebase and squanch to one commit.
2020-07-05 01:28:05 +02:00
TomasVotruba
9327cffa0e [SOLID] Prevent adding constant, that is reserved keyword in RepeatedLiteralToClassConstantRector 2020-07-02 00:45:01 +02:00
TomasVotruba
a8a6e7bcad rename file to fileInfo 2020-06-30 01:45:05 +02:00
TomasVotruba
7f49658112 change test(string ) to test(SmartFileInfo ) in tests 2020-06-25 20:02:36 +02:00
TomasVotruba
05d01aa455 fix missing continue 2020-06-24 23:38:52 +02:00
TomasVotruba
ab2f83c4f7 cs 2020-06-24 23:26:31 +02:00
TomasVotruba
2064e3cc4b cs 2020-06-24 23:26:27 +02:00
derrickschoen
e72ed987e6
reduce size of array 2020-06-24 17:06:39 -04:00
derrickschoen
740dd752ac
reduce size of array 2020-06-24 17:03:50 -04:00
Derrick Schoen
e12336e3c5 Reduce number of variables 2020-06-24 08:33:51 -04:00
Derrick Schoen
87e0c838cd Boolean Operands cause ChangeNestedForeachIfsToEarlyContinueRector to produce code that gives a different output from the original code. 2020-06-23 17:49:19 -04:00
TomasVotruba
5b8bf939a6 skip encapsed string from constant extraction 2020-06-15 15:23:23 +02:00
TomasVotruba
d1e5990531 fix nested comment in nested foreach to if 2020-06-15 11:58:12 +02:00
Tomas Votruba
363483fe1f
Merge pull request #3503 from derrickschoen/EarlyContinueBugWhenThereIsACommentInsideIfStatement
I found a bug with the ChangeNestedForeachIfsToEarlyContinueRector
2020-06-15 11:56:02 +02:00
TomasVotruba
43da75f2e1 skip multi assign ChangeReadOnlyVariableWithDefaultValueToConstantRector 2020-06-15 11:18:24 +02:00
Derrick Schoen
91cec91778 I found a bug with the ChangeNestedForeachIfsToEarlyContinueRector
When there is a comment inside the if statement before the brace, it misses a brace creating the early continue statement.

https://getrector.org/demo/9757fa4a-ed15-4130-8bdc-ae150305360e
2020-06-09 17:31:39 -04:00