StandaloneLinePromotedPropertyFixer: properly deal with attributes.#78
Merged
TomasVotruba merged 2 commits intosymplify:mainfrom Oct 2, 2025
Merged
StandaloneLinePromotedPropertyFixer: properly deal with attributes.#78TomasVotruba merged 2 commits intosymplify:mainfrom
TomasVotruba merged 2 commits intosymplify:mainfrom
Conversation
Member
|
Tldr; Can you fix failing CI? |
Contributor
Author
|
Failing CI seems completely unrelated to my changes. It doesn't concern the same files at all. 🤔 |
Member
|
Could be the case, but we use boy scout rule here :) failing CI is a blocker. |
Co-Authored-By: Claude Code 🤖 <noreply@anthropic.com>
- Sort named parameters in rector.php - Update PHPStan ignored errors to match new PHP version range - Add new PHPStan ignores for offset access and array filter issues - Remove obsolete PHPStan ignored error patterns Co-Authored-By: Claude Code 🤖 <noreply@anthropic.com>
Contributor
Author
|
Fixed. I added PHPStan inspections to the baseline, given there were already quite a few in there. I suppose they were caused by the absence of a |
Member
|
Looks good 👌 there are always issue with that token iterator. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claude Code (AI) : explanation of the two changes
What it does: When iterating backward through constructor parameters, the code needs to check each token.
The bug: The token was captured in a variable BEFORE skipping over nested blocks, but checked AFTER skipping. So it was checking the wrong token.
The fix: Simply moved 2 lines - now the token variable is assigned AFTER skipping, so it always examines the correct token.
What it does: When going backward through tokens, it skips over "blocks" (parentheses, arrays, etc.) so commas inside those blocks aren't treated as parameter separators.
The bug: It wasn't skipping attribute blocks like #[JMS\Expose, JMS\Type('integer')], so the comma inside was incorrectly treated as a parameter separator.
The fix:
The findAttributeStart() is just a 10-line loop that searches backward until it finds T_ATTRIBUTE (the #[ token). I could have used more complex existing infrastructure, but a simple backward search is the most straightforward solution.
What I did (simple approach):
Alternative using existing infrastructure:
The codebase already has BlockFinder (injected in the constructor) that knows how to find attribute blocks:
Why I didn't use it:
Looking at BlockFinder::findInTokensByEdge() (lines 40-90 in BlockFinder.php), it's designed to be called on opening tokens like (, [, {, or specific kinds like T_ATTRIBUTE, T_FUNCTION, etc. When
called on a closing ], it would treat it as an array bracket, not an attribute bracket.
So I'd need to add special logic or modify BlockFinder, which would be more invasive. The simple backward loop is more minimalist and self-contained.