-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CodeQuality] Skip call parent::__construct() indirect parent on ConstructClassMethodToSetUpTestCaseRector #251
Merged
Merged
Changes from 9 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
8ecfd95
[CodeQuality] Skip call parent::__construct() on ConstructClassMethod…
samsonasik 95018d8
init early
samsonasik 3d533e2
register rules-tests
samsonasik fe88653
rename fixture
samsonasik e700d52
use StringUtils::isMatch
samsonasik 1972906
patch RemoveDataProviderTestPrefixRector
samsonasik b9c5aca
patch ReplaceTestAnnotationWithPrefixedFunctionRector
samsonasik e3b0e1c
patch RemoveEmptyTestMethodRector
samsonasik 9ca5e41
use fnmatch
samsonasik 719d28f
remove unused imports
samsonasik 33e7329
skip fixture
samsonasik 5e4999d
fix empty is not FuncCall
samsonasik 8c182f2
Fix AssertCallAnalyzer
samsonasik 7e389a7
skip indirect extends
samsonasik b6321ff
cs fix
samsonasik 5044935
cs fix
samsonasik ed9184e
current parent
samsonasik 00a4489
Fixed :tada:
samsonasik e39796b
fix exclude source
samsonasik 48e1b75
fix
samsonasik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...nstructClassMethodToSetUpTestCaseRector/Fixture/skip_call_parent_construct_exists.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\Class_\ConstructClassMethodToSetUpTestCaseRector\Fixture; | ||
|
||
use Rector\PHPUnit\Tests\CodeQuality\Rector\Class_\ConstructClassMethodToSetUpTestCaseRector\Source\TestResponse; | ||
|
||
final class SkipCallParentConstructExists extends TestResponse | ||
{ | ||
private $someValue; | ||
|
||
public function __construct() | ||
{ | ||
$this->someValue = 1000; | ||
|
||
parent::__construct(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...ctor/Class_/ConstructClassMethodToSetUpTestCaseRector/Fixture/skip_parameter_used.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\Class_\ConstructClassMethodToSetUpTestCaseRector\Fixture; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
final class SkipParameterUsed extends TestCase | ||
{ | ||
public function __construct($param) | ||
{ | ||
$this->initEarly($param); | ||
} | ||
|
||
private function initEarly($param) | ||
{ | ||
echo 'init'; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...deQuality/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector/Source/TestResponse.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\Class_\ConstructClassMethodToSetUpTestCaseRector\Source; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
abstract class TestResponse extends TestCase | ||
{ | ||
public function __construct() | ||
{ | ||
echo "init"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
use PhpParser\Node\Stmt\ClassMethod; | ||
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover; | ||
use Rector\Core\Rector\AbstractRector; | ||
use Rector\Core\Util\StringUtils; | ||
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; | ||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; | ||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; | ||
|
@@ -71,7 +72,7 @@ public function refactor(Node $node): ?Node | |
return null; | ||
} | ||
|
||
if ($this->isName($node->name, 'test*')) { | ||
if (fnmatch('test*', $node->name->toString(), FNM_NOESCAPE)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @TomasVotruba @staabm using |
||
return null; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TomasVotruba here
rules-tests
need to be registered to show the PHPUnit error, it was never executed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Damn, that's a big miss from my side 🤦 😅