Hi,

I object to the following proposed behaviour, which is confusing:

<?php
declare(function_and_const_lookup='global');
 
namespace MyNS;
 
function sprintf($msg, ...$args) {
    // this and remaining statements still refer to \sprintf, not MyNS\sprintf
    return sprintf("Prefix $msg", ...$args);
}
?>

I think we can do better, following the example of what we have today, namely: 
Currently, the following triggers a fatal error:

<?php
namespace MyNS;
use function OtherNS\foo;

function foo() { }
// Fatal Error: Cannot declare function MyNS\foo because the name is already in 
use
?>

Therefore I suggest that the following be an error:

<?php
declare(function_and_const_lookup='global');
namespace MyNS;

function foo() { }
// Fatal Error: Cannot declare function foo because the name refers is in the 
global namespace

?>

and that you have to explicitly say that you use the current namespace for that 
name:

<?php
declare(function_and_const_lookup='global');
namespace MyNS;
use function MyNS\foo;
// or, equivalently: use function namespace\foo:

function foo() { }

foo(); // <-- this is the function defined just above

?>

—Claude
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to