Skip to content

Zend.Files.ClosingTag removes closing tag from end of file without inserting a semicolon #2146

@TysonAndre

Description

@TysonAndre

Version: I'm able to reproduce this in the latest commit.
Expected: If <?= is used and a semicolon is needed in the fixed file, a semicolon should be inserted at an appropriate place (e.g. not as part of a line comment). (Or skip warning about it and fixing it)
Observed: No semicolon is inserted

The input file

text
<?php include($this->add('arg'))?>

The observed result (results in a parse error):

text
<?php include($this->add('arg'))

An example ruleset.xml:

<?xml version="1.0"?>
<ruleset name="ifwe">
    <description>Example coding standard</description>

    <rule ref="Zend">
    </rule>

</ruleset>

Command: path/to/PHP_CodeSniffer/bin/phpcbf --standard=ruleset.xml src/bug.php


A workaround is to exclude Zend.Files.ClosingTag.NotAllowed and include PSR2.Files.ClosingTag.NotAllowed or PSR2.

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