Php_codesniffer: Generic.ControlStructures.InlineControlStructure fixing fails when inline control structure contains closure

Created on 19 Jun 2018  路  1Comment  路  Source: squizlabs/PHP_CodeSniffer

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)
Bug

Most helpful comment

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

>All comments

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

Was this page helpful?
0 / 5 - 0 ratings