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.ControlStructures.InlineControlStructure fixing fails when inline control structure contains closure #2065

Closed
cronfy opened this issue Jun 19, 2018 · 1 comment
Milestone

Comments

@cronfy
Copy link

cronfy commented Jun 19, 2018

phpcbf corrupts code by Generic.ControlStructures.InlineControlStructure.NotAllowed sniff.

Consider this code:

<?php

if (true) $callable = function () {
    return true;
};

phpcbf transforms it to:

<?php

if (true) {
    $callable = function () {
        return true;
    }
};

Which is incorrect - semicolon is placed wrongly.

phpcs.xml is very simple:

<?xml version="1.0"?>
<ruleset name="This project standard">
    <description>Standard for this project</description>
    <rule ref="PSR2"/>
</ruleset>

Version:

$ phpcbf --version
PHP_CodeSniffer version 3.3.0 (stable) by Squiz (http://www.squiz.net)
@gsherwood gsherwood added this to the 3.3.1 milestone Jun 19, 2018
@gsherwood gsherwood changed the title phpcbf corrupts code by Generic.ControlStructures.InlineControlStructure.NotAllowed Auto-fixing fails for inline control structures containing a closure Jun 20, 2018
@gsherwood gsherwood changed the title Auto-fixing fails for inline control structures containing a closure Generic.ControlStructures.InlineControlStructure fixing fails when inline control structure contains closure Jun 20, 2018
gsherwood added a commit that referenced this issue Jun 20, 2018
…xing fails when inline control structure contains closure
@gsherwood
Copy link
Member

Thanks for reporting this bug. The fix will be in 3.3.1.

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