On 2/7/2017 11:39 AM, Niklas Keller wrote:
> I don't see this as a potential problem. Autoloadeds are (1) not triggered
> for already loaded symbols and (2) and more importantly, autoloaders
> usually use a list of prefixes to load, so a whitelist, not a blacklist.
>
> Regards, Niklas
>
This is related to previous discussions about the implementation of
auto-loaders for functions and constants where we it was always a
problem on how to deal with stuff that has no use statement and no
namespace prefix, e.g.:
<?php
namespace Fleshgrinder\Examples;
in_array('foo', ['foo']);
Is this now the `in_array()` from PHP? Is this function defined in
`Fleshgrinder\Examples`?
One way to resolve this is:
<?php
namespace Fleshgrinder\Examples;
\in_array('foo', ['foo']);
This is unambiguous and clear, we have that one loaded already and
everything is fine. However, it introduces a backslash oriented
programming and makes everything harder to read.
<?php
namespace Fleshgrinder\Examples;
use function PHP\in_array;
in_array('foo', ['foo']);
This solves the issue too. Of course this becomes annoying very fast but
that is why I said that nikic's scalar objects should be introduced as well.
<?php
namespace Fleshgrinder\Examples;
['foo']->contains('foo');
In all cases, we know that the auto-loader does not require triggering
because the references are not ambiguous and that is what this was about.
--
Richard "Fleshgrinder" Fussenegger
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php