Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing constant indexer #2249

Merged
merged 5 commits into from
May 1, 2023
Merged

Conversation

mamazu
Copy link
Contributor

@mamazu mamazu commented May 1, 2023

Closes #2168

What was the problem?

The problem was that in the old code phpactor created a constant for every (string literal) argument in a define call. This isn't correct since the first argument in the call is the name and the second argument is the value of the constant. The multilineness of the value was what tricked the cache. But this isn't a problem since the second argument shouldn't be a constant in the first place.

$record->setFilePath($document->uri()->path());
$index->write($record);
$firstArgument = $expression;
break;
Copy link
Collaborator

Choose a reason for hiding this comment

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

i think we just needed to add the break and the original code was ok? doing it like this means dealing with NULL and adding a temporary var on line 85. if we want to make the code "cleaner" we can extract a method, but I think just adding break is enough 🙂

@dantleech
Copy link
Collaborator

nice find! if you agree can you update the code as per the suggestion and update the CHANGELOG? 🙇

@mamazu
Copy link
Contributor Author

mamazu commented May 1, 2023

Yeah that implementation would be much easier. Fixed it now.

@dantleech dantleech merged commit 98ca767 into phpactor:master May 1, 2023
9 checks passed
@dantleech
Copy link
Collaborator

Merci 🙇

@mamazu mamazu deleted the fixing_constant_indexer branch May 1, 2023 19:46
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.

Complete not working due to error in cache file
2 participants