Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 0 additions & 40 deletions src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
use PhpParser\Node\Stmt\Foreach_;
use PhpParser\Node\Stmt\If_;
use PhpParser\Node\Stmt\Interface_;
use PhpParser\Node\Stmt\Property;
use PhpParser\Node\Stmt\Return_;
use PhpParser\Node\Stmt\Switch_;
use PhpParser\Node\Stmt\Trait_;
Expand Down Expand Up @@ -165,9 +164,6 @@ private function fillScope(array $stmts, string $filePath, MutatingScope $scope)
$mutatingScope = $mutatingScope->toWalkScope();
}

// why not simply this everywhere? what would we lose?
// $node->setAttribute(AttributeKey::SCOPE, $mutatingScope);

// the class reflection is resolved AFTER entering to class node
// so we need to get it from the first after this one
if ($node instanceof Class_ || $node instanceof Interface_ || $node instanceof Enum_) {
Expand Down Expand Up @@ -294,16 +290,6 @@ private function fillScope(array $stmts, string $filePath, MutatingScope $scope)
return;
}

if ($node instanceof Array_) {
$this->processArray($node, $mutatingScope);
return;
}

if ($node instanceof Property) {
$this->processProperty($node, $mutatingScope, $nodeCallback);
return;
}

if ($node instanceof Switch_) {
$this->processSwitch($node, $mutatingScope);
return;
Expand Down Expand Up @@ -579,32 +565,6 @@ private function processUnreachableStatementNode(
);
}

/**
* @param callable(Node $node, MutatingScope $scope): void $nodeCallback
*/
private function processProperty(Property $property, MutatingScope $mutatingScope, callable $nodeCallback): void
{
foreach ($property->props as $propertyProperty) {
$propertyProperty->setAttribute(AttributeKey::SCOPE, $mutatingScope);

if ($propertyProperty->default instanceof Expr) {
$propertyProperty->default->setAttribute(AttributeKey::SCOPE, $mutatingScope);
}
}

foreach ($property->hooks as $hook) {
if ($hook->body === null) {
continue;
}

/** @var Stmt[] $stmts */
$stmts = $hook->body instanceof Expr
? [new Expression($hook->body)]
: $hook->body;
$this->nodeScopeResolverProcessNodes($stmts, $mutatingScope, $nodeCallback);
}
}

private function processBinaryOp(BinaryOp $binaryOp, MutatingScope $mutatingScope): void
{
if (! $binaryOp->left->getAttribute(AttributeKey::SCOPE) instanceof MutatingScope) {
Expand Down
Loading