Skip to content

Generic.ControlStructures.InlineControlStructure fix creates syntax error fixing if-try/catch #1253

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

Closed
gseric opened this issue Dec 28, 2016 · 2 comments

Comments

@gseric
Copy link

gseric commented Dec 28, 2016

This fixer generates invalid PHP code in some cases. E.g.:

// Original code:
if (true)
    try {
    }
    catch(Exception $e) {
    }

// After fix (syntax error!!!):
if (true) {
    try {
    }
}
    catch(Exception $e) {
    }

// Should be:
if (true) {
    try {
    }
    catch(Exception $e) {
    }
}

try/catch is not treated as a whole...

PHP_CodeSniffer 2.7.1

@gsherwood gsherwood changed the title Generic.ControlStructures.InlineControlStructure fix results with invalid PHP code in combination if-try/catch - Fixed bug #1253 : Generic.ControlStructures.InlineControlStructure fix creates syntax error fixing if-try/catch Jan 3, 2017
@gsherwood gsherwood changed the title - Fixed bug #1253 : Generic.ControlStructures.InlineControlStructure fix creates syntax error fixing if-try/catch Generic.ControlStructures.InlineControlStructure fix creates syntax error fixing if-try/catch Jan 3, 2017
gsherwood added a commit that referenced this issue Jan 3, 2017
…x creates syntax error fixing if-try/catch
@gsherwood
Copy link
Member

Thanks for the report. I've fixed this now.

@gseric
Copy link
Author

gseric commented Jan 4, 2017

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants