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

Generic/DisallowShortOpenTag: prevent fixer conflict #835

Merged

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Feb 19, 2025

Description

The original fixer conflict which inspired this fix can be reproduced via:

phpcbf -ps ./src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.19.inc --report=full,source --suffix=.fixed --standard=Squiz

What it basically comes down to is that this sniff would replace the <?= with <?php echo, even in case of a parse error, which would then cause problems for other sniffs.

Fixed now by ignoring this particular parse error.

Includes test.

Note: this PR will be most straight-forward to review while ignoring whitespace changes.

Suggested changelog entry

Generic.PHP.DisallowShortOpenTag: don't act on parse errors

Related issues/external references

Related to #152

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

The original fixer conflict which inspired this fix can be reproduced via:
```bash
phpcbf -ps ./src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.19.inc --report=full,source --suffix=.fixed --standard=Squiz
```

What it basically comes down to is that this sniff would replace the `<?=` with `<?php echo`, even in case of a parse error, which would then cause problems for other sniffs.

Fixed now by ignoring this particular parse error.

Includes test.

Note: this PR will be most straight-forward to review while ignoring whitespace changes.
@jrfnl jrfnl merged commit f4af289 into master Mar 3, 2025
57 checks passed
@jrfnl jrfnl deleted the feature/generic-disallowshortopentag-dont-act-on-parse-error branch March 3, 2025 18:41
jrfnl added a commit that referenced this pull request Mar 3, 2025
The original fixer conflict which inspired this fix can be reproduced via:
```bash
phpcbf -ps ./src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.19.inc --report=full,source --suffix=.fixed --standard=Squiz
```

What it basically comes down to is that this sniff would replace the `<?=` with `<?php echo`, even in case of a parse error, which would then cause problems for other sniffs.

Fixed now by ignoring this particular parse error.

Includes test.

Note: this PR will be most straight-forward to review while ignoring whitespace changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant