mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-16 13:33:13 +02:00
coding standard fixes, use PHPStan as dependency
This commit is contained in:
parent
7fe31cde23
commit
ca3aa06941
@ -15,10 +15,10 @@ script:
|
||||
# run tests
|
||||
- vendor/bin/phpunit $PHPUNIT_FLAGS
|
||||
# check coding standard (defined in composer.json "scripts" section)
|
||||
# if this fails, run "composer fs" to fix all fixable issues
|
||||
# if this fails, run "composer fix-cs" to fix all fixable issues
|
||||
- composer check-cs
|
||||
# check with phpstan (defined in composer.json "scripts" section)
|
||||
# - composer phpstan
|
||||
- composer phpstan
|
||||
|
||||
after_script:
|
||||
# upload coverage.xml file to Coveralls to analyze it
|
||||
|
@ -11,13 +11,13 @@
|
||||
"symfony/console": "^3.3",
|
||||
"symfony/dependency-injection": "^3.3",
|
||||
"nikic/php-parser": "4.0.x-dev as 3.0.2",
|
||||
"nette/utils": "^2.4"
|
||||
"nette/utils": "^2.4",
|
||||
"phpstan/phpstan": "^0.8"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^6.2",
|
||||
"tracy/tracy": "^2.4",
|
||||
"symplify/easy-coding-standard": "^2.2",
|
||||
"phpstan/phpstan": "^0.8"
|
||||
"symplify/easy-coding-standard": "^2.2"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
@ -1,5 +1,6 @@
|
||||
includes:
|
||||
- vendor/symplify/easy-coding-standard/config/symfony-checkers.neon
|
||||
- vendor/symplify/easy-coding-standard/config/symfony-risky-checkers.neon
|
||||
- vendor/symplify/easy-coding-standard/config/php70-checkers.neon
|
||||
- vendor/symplify/easy-coding-standard/config/php71-checkers.neon
|
||||
- vendor/symplify/easy-coding-standard/config/symplify-checkers.neon
|
||||
|
@ -36,7 +36,7 @@ final class NodeTraverserFactory
|
||||
}
|
||||
|
||||
foreach ($this->nodeVisitors as $nodeVisitor) {
|
||||
if (in_array(get_class($nodeVisitor), $this->priorityNodeVisitorClasses, true)) {
|
||||
if ($this->isPriorityNodeVisitor($nodeVisitor)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -45,4 +45,11 @@ final class NodeTraverserFactory
|
||||
|
||||
return $nodeTraverser;
|
||||
}
|
||||
|
||||
private function isPriorityNodeVisitor(NodeVisitor $nodeVisitor): bool
|
||||
{
|
||||
$nodeVisitorClass = get_class($nodeVisitor);
|
||||
|
||||
return in_array($nodeVisitorClass, $this->priorityNodeVisitorClasses, true);
|
||||
}
|
||||
}
|
||||
|
@ -6,14 +6,20 @@ use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\Node\Identifier;
|
||||
use Rector\Deprecation\SetNames;
|
||||
use Rector\NodeTraverser\TokenSwitcher;
|
||||
use Rector\Rector\AbstractRector;
|
||||
|
||||
final class HtmlAddMethodRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @var Node
|
||||
* @var TokenSwitcher
|
||||
*/
|
||||
private $previousNode;
|
||||
private $tokenSwitcher;
|
||||
|
||||
public function __construct(TokenSwitcher $tokenSwitcher)
|
||||
{
|
||||
$this->tokenSwitcher = $tokenSwitcher;
|
||||
}
|
||||
|
||||
public function getSetName(): string
|
||||
{
|
||||
@ -55,4 +61,12 @@ final class HtmlAddMethodRector extends AbstractRector
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Node[] $nodes
|
||||
*/
|
||||
public function afterTraverse(array $nodes): void
|
||||
{
|
||||
$this->tokenSwitcher->enable();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user