Skip to content

PSR12.Files.FileHeader misidentifies file header in mixed content file #2732

@jrfnl

Description

@jrfnl

For the following code sample I would expect an error on line 1 about the missing blank line between the PHP open tag and the file docblock.

<?php
/**
 * Template file docblock.
 *
 * @package Vendor\Package
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

?>

<p><?php echo 'Some text string'; ?></p>

<?php

/**
 * Docblock.
 */
include 'foo.php';

The above mentioned expected error is not being thrown.

Instead I receive the following errors:

-------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-------------------------------------------------------------------------
 16 | ERROR | [ ] The file header must be the first content in the file
 20 | ERROR | [x] Header blocks must be separated by a single blank line
-------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------

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