Re: Bug/Req:#61422&#39003 enble Type Hint autoloading

From: Date: Tue, 01 May 2012 13:18:34 +0000
Subject: Re: Bug/Req:#61422&#39003 enble Type Hint autoloading
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-60406@lists.php.net to get a copy of this message
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 danko@very.lv Skype: d.alexeyev

« previous php.internals (#60406) next »