mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-13 03:52:15 +02:00
add /packages directory to static analysis check
This commit is contained in:
parent
60f4a98b51
commit
fec9201cc2
@ -34,9 +34,9 @@
|
||||
},
|
||||
"scripts": {
|
||||
"all": ["phpunit", "@check-cs", "@phpstan"],
|
||||
"check-cs": "ecs check bin src tests",
|
||||
"fix-cs": "ecs check bin src tests --fix",
|
||||
"phpstan": "phpstan analyse bin src tests --level max --configuration phpstan.neon"
|
||||
"check-cs": "ecs check bin packages src tests",
|
||||
"fix-cs": "ecs check bin packages src tests --fix",
|
||||
"phpstan": "phpstan analyse bin packages src tests --level max --configuration phpstan.neon"
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
|
@ -17,6 +17,11 @@ use Rector\NodeTypeResolver\TypeContext;
|
||||
*/
|
||||
final class ClassLikeTypeResolver extends NodeVisitorAbstract
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const TYPE_ATTRIBUTE = 'type';
|
||||
|
||||
/**
|
||||
* @var TypeContext
|
||||
*/
|
||||
@ -62,11 +67,16 @@ final class ClassLikeTypeResolver extends NodeVisitorAbstract
|
||||
}
|
||||
|
||||
if ($variableType) {
|
||||
$node->setAttribute('type', $variableType);
|
||||
$node->setAttribute(self::TYPE_ATTRIBUTE, $variableType);
|
||||
}
|
||||
|
||||
if ($node instanceof Assign && $node->var instanceof Variable && $node->expr instanceof Variable) {
|
||||
$this->typeContext->addAssign($node->var->name, $node->expr->name);
|
||||
|
||||
$variableType = $this->typeContext->getTypeForVariable($node->var->name);
|
||||
if ($variableType) {
|
||||
$node->var->setAttribute(self::TYPE_ATTRIBUTE, $variableType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ final class TypeContext
|
||||
/**
|
||||
* @var mixed[]
|
||||
*/
|
||||
private $localTypes;
|
||||
private $localTypes = [];
|
||||
|
||||
/**
|
||||
* @var ClassLike|null
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Rector\NodeTypeResolver\Tests;
|
||||
|
||||
use Nette\Utils\Html;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use Rector\Contract\Parser\ParserInterface;
|
||||
use Rector\NodeTraverser\StandaloneTraverseNodeTraverser;
|
||||
@ -34,9 +35,11 @@ final class NodeTypeResolverTest extends AbstractContainerAwareTestCase
|
||||
/** @var Variable $htmlVariableNode */
|
||||
$htmlVariableNode = $nodes[1]->stmts[1]->stmts[0]->stmts[0]->expr->var;
|
||||
|
||||
$this->assertSame(
|
||||
'Nette\Utils\Html',
|
||||
$htmlVariableNode->getAttribute('type')
|
||||
);
|
||||
$this->assertSame(Html::class, $htmlVariableNode->getAttribute('type'));
|
||||
|
||||
/** @var Variable $assignedVariableNode */
|
||||
$assignedVariableNode = $nodes[1]->stmts[1]->stmts[0]->stmts[1]->expr->var;
|
||||
|
||||
$this->assertSame(Html::class, $assignedVariableNode->getAttribute('type'));
|
||||
}
|
||||
}
|
||||
|
@ -5,12 +5,14 @@
|
||||
>
|
||||
<!-- tests directories to run -->
|
||||
<testsuite>
|
||||
<directory>packages/*/tests</directory>
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
<!-- source to check coverage for -->
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">src</directory>
|
||||
<whitelist>
|
||||
<directory>packages/*/src</directory>
|
||||
<directory>src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
|
Loading…
x
Reference in New Issue
Block a user