Hi everyone,

On 05/01/2012 03:25 PM, Laruence wrote:
     if you pass a right instance of class to a function , how can that
class not be loaded already?

     for example:
     function foo(Foo_Bar $a) {
     }

     how can you pass a Foo_Bar instance to function foo without
Foo_Bar class already defined?


Because Foo_Bar could be *defined* under a different name, say, Foo_Blah. Then, as soon as someone needed Foo_Bar, we would use class_alias to add an alias. That is, as soon as someone tried using Foo_Bar it would turn out that Foo_Bar and Foo_Blah are the same class and all Foo_Blah objects are *also* Foo_Bar objects and everything is cool. Therefore foo(new Foo_Blah()) would work (if there was autoload).

Please see the demo I provided at https://bugs.php.net/bug.php?id=61422

Then again, at least it's consistent with instanceof. Where calling autoload by default is probably indeed unacceptable.

This is complicated.

--
Best regards,

Danko Alexeyev,
VeryPositive

+371 2648 3953
da...@very.lv
Skype: d.alexeyev

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

Reply via email to