Skip to content

Conversation

@TomasVotruba
Copy link
Member

@TomasVotruba TomasVotruba commented Nov 24, 2021

@TomasVotruba TomasVotruba force-pushed the tv-refresh-scope-on-rename branch from 498126a to 99f266f Compare November 24, 2021 10:47
@TomasVotruba TomasVotruba changed the title add prototype for scope refresh issues [WIP] [DX] Add prototype for scope refresh issues Nov 24, 2021
Comment on lines 266 to 273
// refresh PHPStan scope, parent connections and other attributes
$scope = $node->getAttribute(AttributeKey::SCOPE);
$parent = $node->getAttribute(AttributeKey::PARENT_NODE);
$this->phpStanNodeScopeResolver->refreshStmtNodes($parent, [$node], $scope);

// update parents relations - must run before connectParentNodes()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the important change. On changed node, all the children of this node and this node get retraverse of scope.

Comment on lines +39 to +43
foreach ($itemsByName as $items) {
if (count($items)) {
continue;
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before this change, the type was lost on $values renamed to $items.
Now the $items have the ArrayType as original $values have 👍

@TomasVotruba TomasVotruba force-pushed the tv-refresh-scope-on-rename branch 6 times, most recently from 0ef1a51 to 061f54b Compare November 24, 2021 20:48
Copy link
Member

@samsonasik samsonasik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To show that the refresh scope working, the part that can be removed is second parameter bool $isCheckNameScope = false at:

public function isUsed(Expr $expr, bool $isCheckNameScope = false): bool

After removed, run tests against tests/Issues:

vendor/bin/phpunit tests/Issues

and verify if it cause error or not.

@TomasVotruba TomasVotruba force-pushed the tv-refresh-scope-on-rename branch 12 times, most recently from 50f1565 to f204f29 Compare November 25, 2021 21:27
@TomasVotruba TomasVotruba force-pushed the tv-refresh-scope-on-rename branch from f204f29 to 312de27 Compare November 25, 2021 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants