Skip to content

[5.8] Path of the view in compiled template causes regression with declare(strict_types=1) in templates #27704

@mfn

Description

@mfn
  • Laravel Version: 5.8.2
  • PHP Version: 7.2
  • Database Driver & Version: n/a

Description:

[5.8] Provide a path of the view in compiled view added a new feature so that the first line of a compiled template contains the path to the view.

Unfortunately this breaks templates using <?php declare(strict_types = 1); in the first line.

PHP requires strict_types to be the very first statement in the PHP file. The error:

In b4b770a497bc79e9d39868f8567850fb50c4f817.php line 2:
                                                                           
  strict_types declaration must be the very first statement in the script  

Steps To Reproduce:

Template:

<?php declare(strict_types = 1);
// anything you want

Generated template in 5.7:

<?php declare(strict_types = 1);
// anything you want

Generated template in 5.8:

<?php /* /vagrant/project/resources/views/emails/template.blade.php */ ?>
<?php declare(strict_types = 1);
// anything you want

Were I work there's a strict policy about this requirement with no exceptions, same for type declarations. I've been using them since Laravel 5.1 and never had issues so far.

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