Skip to content

Generic.ControlStructures.InlineControlStructure fixing fails when inline control structure contains closure #2065

Closed
@cronfy

Description

@cronfy

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions