On 1/20/2017 7:58 PM, Nikita Popov wrote:
> On Fri, Jan 20, 2017 at 7:55 PM, Stanislav Malyshev <smalys...@gmail.com>
> wrote:
> 
>> Hi!
>>
>>> Since the autoloading functions proposal is stalled, how about allowing
>> for
>>> import of static functions instead?
>>>
>>>     use function Foo::bar;
>>>
>>>     bar(); // calls Foo::bar()
>>
>> I'm not sure why it is good. This would certainly be confusing, if you
>> call strlen and turns out it's completely different function from what
>> you thought. One thing when it's the same namespace, at least you can be
>> aware what this package does, but if it's just an arbitrary function
>> from anywhere, it's really bad for understanding the code.
>>
> 
> How is that different from the already existing "use function foo\bar\baz
> as strlen"?
> 

Or any other function that has no namespace separator in front.

```
<?php

namespace Fleshgrinder\Examples;

function strlen($string) {
    return 42; // Troll! =)
}

final class SomeClass {

    public function __construct() {
        echo strlen('f');
    }

}

new SomeClass;

```

This is actually used by some in tests to provoke error conditions in
built-in PHP functions to verify their error handling.

-- 
Richard "Fleshgrinder" Fussenegger

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

Reply via email to