Re: [PHP-DEV] [RFC] Namespace-scoped declares, again

  106574
August 13, 2019 20:35 rowan.collins@gmail.com (Rowan Collins)
On 13/08/2019 18:40, Liam Hammett wrote:
> > declare(strict_types=1) { > class Example { > // ... > } > }
This already works (except for the "encoding" declare, which would make little sense halfway down a file).
> spl_autoload_register(function ($className) { > declare(strict_types=1) { > include $className . '.php'; > } > });
This, however, doesn't, because each file has to declare its own options, so we'd need some new syntax for "include with current parser options". It would also lead to the possibility for the same file to be included twice with different options, which would be confusing; or for it to be in OpCache twice with different options, which would be complex to implement. Regards, -- Rowan Collins [IMSoP]