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

fix: Process variable before the end of scope #324

Merged
merged 2 commits into from
Jun 26, 2024

Conversation

biinari
Copy link
Contributor

@biinari biinari commented Jun 14, 2024

fixes #323

When the last php code is a short php open echo tag using a variable,
process the variable before processing the end of scope.

<?php
$a = 'foo';
?>
<html>
<?= $a ?> the last non-empty token is a variable.
</html>

biinari added 2 commits June 14, 2024 06:39
When a variable is used in a short php open echo tag, it should be
marked as used.
fixes sirbrillig#323

When the last php code is a short php open echo tag using a variable,
process the variable before processing the end of scope.
@sirbrillig
Copy link
Owner

Thank you! Sorry it took so long to review. I've been AFK for a month.

This is a very elegant fix although I'm not 100% sure I understand how it solves this bug since a token that's a variable shouldn't also be a token that closes a scope, but the tests pass so I'm content.

@sirbrillig sirbrillig merged commit bc8d7e3 into sirbrillig:2.x Jun 26, 2024
28 checks passed
@biinari
Copy link
Contributor Author

biinari commented Jun 26, 2024

Thanks for the review @sirbrillig, that was pretty quick to be honest. Hope you had a good break from the keyboard :)

To elaborate on how this fixes the issue, the variable isn't a token that would close a scope. It has just ended up as the last non-empty token in the file, making it the end of the top-level scope.

@biinari biinari deleted the fix_short_tag_variable_use branch June 26, 2024 20:55
@sirbrillig
Copy link
Owner

Ahh, that makes sense. Thanks for clarifying!

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.

Variable not marked as used in short open echo tag
2 participants