Skip to content

gh-2913: avoid infinite loop when resolving constant type#2943

Merged
dantleech merged 1 commit intomasterfrom
gh-2913-infinite-loop
Oct 17, 2025
Merged

gh-2913: avoid infinite loop when resolving constant type#2943
dantleech merged 1 commit intomasterfrom
gh-2913-infinite-loop

Conversation

@dantleech
Copy link
Copy Markdown
Collaborator

When we have a cycle such as declare('Foo', Foo) PHP will bail at runtime because it will evaluate Foo before declare. Phpactor will evalute Foo lazily - but even if it located it eagerly (bad for performance) the indxer will find the constant, because the indexer doesn't know that the value causes a cycle.

for now we only evaluate literal values.

Fixes #2913

When we have a cycle such as `declare('Foo', Foo)` PHP will bail at
runtime because it will evaluate `Foo` before `declare`. Phpactor will
evalute `Foo` lazily - but even if it located it eagerly (bad for
performance) the indxer _will find_ the constant, because the indexer
doesn't know that the value causes a cycle.

for now we just avoid resolving values if they are QualifiedName's.
@dantleech dantleech force-pushed the gh-2913-infinite-loop branch from a25a09b to a22af93 Compare October 17, 2025 14:12
@dantleech dantleech merged commit 7f1a270 into master Oct 17, 2025
11 checks passed
@dantleech dantleech deleted the gh-2913-infinite-loop branch October 17, 2025 14:31
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.

Orphaned language-server:diagnostics Process When File Contains namespace Timer

1 participant