Re: [RFC] Namespace-scoped declares, again

From: Date: Tue, 13 Aug 2019 20:26:27 +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-106572@lists.php.net to get a copy of this message
On 13/08/2019 18:45, Mark Randall wrote:
I thought about this as my first consideration, however it effectively requires that the PHP code within the package class is fully parsed and executed in order for it to retrieve the data. Consider pre-loading where the code is compiled, but not run, it would not be possible to use namespace level defines to add compile-level optimizations or checks (at least without some AST hackery).
Ah, that makes sense. Does that necessarily mean we need a dummy class, though? The autoloading logic in the engine knows that it called the autoload callback expecting a package definition, so can count as success that the package is now defined. In other words, the file the autoloader included would look like this (again, sticking to the notion that "package" is separate from "namespace"): # # File: /lib/company/project1.php # <?php packagedef company/project1 {
    strict_types=1;
    strict_operators=1;
    upgrade_errors_to_exceptions=E_ALL;
} Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#106572) next »