Re: [RFC] Namespace-scoped declares, again

From: Date: Tue, 13 Aug 2019 20:35:12 +0000
Subject: Re: [RFC] Namespace-scoped declares, again
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-106574@lists.php.net to get a copy of this message
On 13/08/2019 18:40, Liam Hammett wrote:
<?php 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]

« previous php.internals (#106574) next »