> On Sun, 2024-07-28 at 00:48 +0200, Claude Pache wrote:
> > 
> > For the case of functions (and constants) in the global namespace,
> > there was an RFC on the subject about 4 years ago, which has been
> > declined; see: https://wiki.php.net/rfc/use_global_elements and the
> > discussion threads referenced at the bottom of that page.
> 


What about:

    namespace foo;
    use global functions;
    
    class MyClass{
       // do stuff
    }
    
The `use global functions` directive goes after the namespace
declaration, but before any other code. It applies to the entire file,
but only to the current file.

It tells the parser that, if a function call is found in the file, use
the global function. Do not make an NS lookup op code, and if the
function is a recognized built-in with a dedicated op code, use the
dedicated op code.

Methods and classes are unaffected.

Reply via email to