Skip to content

PSR12.Files.FileHeader.SpacingAfterBlock error on declare strict types in files containing markup outside PHP opening and closing tags #2911

@kravchenko-a

Description

@kravchenko-a

Hello!

From PSR-12:
https://www.php-fig.org/psr/psr-12/#3-declare-statements-namespace-and-import-statements

When wishing to declare strict types in files containing markup outside PHP opening and closing tags, the declaration MUST be on the first line of the file and include an opening PHP tag, the strict types declaration and closing tag.

For example:

<?php declare(strict_types=1) ?>
<html>
<body>
    <?php
        // ... additional PHP code ...
    ?>
</body>
</html>

But PHP_CodeSniffer show the error on the first line of this example code:

phpcs: PSR12.Files.FileHeader.SpacingAfterBlock: Header blocks must be separated by a single blank line

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions