Skip to content

PSR2 standard does not allow closing tag for mixed PHP/HTML files #453

@clamburger

Description

@clamburger

PSR-2 states the following (emphasis mine):

The closing ?> tag MUST be omitted from files containing only PHP.

Zend.Files.ClosingTag only checks for a closing tag at the end of the file, ignoring the bolded part.

Here's an example Gist which is valid according to PSR-2, but running phpcs --standard=PSR2 on the file gives the following output:

-------------------------------------------------------------------------------- FOUND 1 ERROR AFFECTING 1 LINE -------------------------------------------------------------------------------- 7 | ERROR | [x] A closing tag is not permitted at the end of a PHP file -------------------------------------------------------------------------------- PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY -------------------------------------------------------------------------------- 

Running phpcbf will remove the final closing tag.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions