zend_lookup_class()

php.internals

Andrei Zmievski

23 years ago
Any objections to modifying zend_lookup_class() to support fully qualified class names? Meaning, if it's passed 'A::B' it will lookup class B in namespace A? This change would take a care of several places in the code where class name can be passed. -Andrei http://www.gravitonic.com/ "Everything has its wonders, even darkness and silence, and I learn, whatever state I may be in, therein to be content." - Helen Keller

Moriyoshi Koizumi

23 years ago
+1, because your patch is likely to fix the issue #21094. http://bugs.php.net/21094 Moriyoshi Andrei Zmievski <andrei@gravitonic.com> wrote:

Andi Gutmans

23 years ago
I'm not sure if it's a good idea to change it or if we'd want a new function because zend_lookup_class() is used in the core executor and this would just slow it down. Can you give me an example of where you'd want this to work? Andi At 11:20 AM 4/4/2003 -0500, Andrei Zmievski wrote:

Andrei Zmievski

23 years ago
On Sat, 05 Apr 2003, Andi Gutmans wrote:
> I'm not sure if it's a good idea to change it or if we'd want a new > function because zend_lookup_class() is used in the core executor and this > would just slow it down. Can you give me an example of where you'd want > this to work?
zend_builtin_functions.c: 575: if (zend_lookup_class(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), &pce TSRMLS_CC) == SUCCESS) { 673: if (zend_lookup_class(lcname, Z_STRLEN_PP(class_name), &pce TSRMLS_CC) == FAILURE) { 740: if (zend_lookup_class(Z_STRVAL_PP(class), Z_STRLEN_PP(class), &pce TSRMLS_CC) == SUCCESS) { Basically, any functions that take the name of a class and need to obtain the corresponding class entry, should also be able to take the namespace::class syntax. zend_lookup_class() seems like the best place to accomplish it. Any other suggestions? -Andrei http://www.gravitonic.com/ * Gun manufacturers don't make bad products, bad parents do. *

(Marcus Börger)

23 years ago
At 17:14 07.04.2003, Andrei Zmievski wrote:
>Basically, any functions that take the name of a class and need to >obtain the corresponding class entry, should also be able to take the >namespace::class syntax. zend_lookup_class() seems like the best place >to accomplish it. Any other suggestions?
Agreed

Andi Gutmans

23 years ago
At 11:14 AM 4/7/2003 -0400, Andrei Zmievski wrote:
>On Sat, 05 Apr 2003, Andi Gutmans wrote: > > I'm not sure if it's a good idea to change it or if we'd want a new > > function because zend_lookup_class() is used in the core executor and this > > would just slow it down. Can you give me an example of where you'd want > > this to work? > >zend_builtin_functions.c: > > 575: if (zend_lookup_class(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), &pce > TSRMLS_CC) == SUCCESS) { > 673: if (zend_lookup_class(lcname, Z_STRLEN_PP(class_name), &pce > TSRMLS_CC) == FAILURE) { > 740: if (zend_lookup_class(Z_STRVAL_PP(class), > Z_STRLEN_PP(class), &pce TSRMLS_CC) == SUCCESS) { > >Basically, any functions that take the name of a class and need to >obtain the corresponding class entry, should also be able to take the >namespace::class syntax. zend_lookup_class() seems like the best place >to accomplish it. Any other suggestions?
As zend_lookup_class() is used in the main executer of the engine I'd want to keep it as slim as possible. If you want to create a zend_foo_bar() function which does what you want, feel free to add it but it shouldn't be used in core stuff. Andi

Andrei Zmievski

23 years ago
On Mon, 07 Apr 2003, Andi Gutmans wrote:
> As zend_lookup_class() is used in the main executer of the engine I'd want > to keep it as slim as possible. If you want to create a zend_foo_bar() > function which does what you want, feel free to add it but it shouldn't be > used in core stuff.
Okay, I made a separate function, zend_lookup_ns_class(). What I'm wondering, though, is whether this function should support __autoload() or not. Since it's going to be used by functions like class_exists(), get_class_methods(), etc, does it make sense to call __autoload()? I would think not. -Andrei http://www.gravitonic.com/ "The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly go wrong goes wrong, it usually turns out to be impossible to get at or repair." -- Douglas Adams

(Marcus Börger)

23 years ago
At 18:55 08.04.2003, Andrei Zmievski wrote:
>On Mon, 07 Apr 2003, Andi Gutmans wrote: > > As zend_lookup_class() is used in the main executer of the engine I'd want > > to keep it as slim as possible. If you want to create a zend_foo_bar() > > function which does what you want, feel free to add it but it shouldn't be > > used in core stuff. > >Okay, I made a separate function, zend_lookup_ns_class(). What I'm >wondering, though, is whether this function should support __autoload() >or not. Since it's going to be used by functions like class_exists(), >get_class_methods(), etc, does it make sense to call __autoload()? I >would think not.
I think you should add a boolean parameter to allow/disallow __autoload which defaults to true. marcus

Andrei Zmievski

23 years ago
On Tue, 08 Apr 2003, Marcus Börger wrote:
> I think you should add a boolean parameter to allow/disallow __autoload > which defaults to true.
Add boolean parameter to what? -Andrei http://www.gravitonic.com/ "The only true currency in this bankrupt world is what we share with each other when we're uncool." -- Lester Bangs, from the film 'Almost Famous'

Andi Gutmans

23 years ago
At 12:55 PM 4/8/2003 -0400, Andrei Zmievski wrote:
>On Mon, 07 Apr 2003, Andi Gutmans wrote: > > As zend_lookup_class() is used in the main executer of the engine I'd want > > to keep it as slim as possible. If you want to create a zend_foo_bar() > > function which does what you want, feel free to add it but it shouldn't be > > used in core stuff. > >Okay, I made a separate function, zend_lookup_ns_class(). What I'm >wondering, though, is whether this function should support __autoload() >or not. Since it's going to be used by functions like class_exists(), >get_class_methods(), etc, does it make sense to call __autoload()? I >would think not.
I don't think so, although we might hit some situation where we might want it. Andi

Stanislav Malyshev

23 years ago
AZ>> Any objections to modifying zend_lookup_class() to support fully AZ>> qualified class names? Meaning, if it's passed 'A::B' it will lookup AZ>> class B in namespace A? This change would take a care of several AZ>> places in the code where class name can be passed. Could you point out which places are these?
-- Stanislav Malyshev, Zend Products Engineer stas@zend.com http://www.zend.com/ +972-3-6139665 ext.109

Andrei Zmievski

23 years ago
On Sun, 06 Apr 2003, Stanislav Malyshev wrote:
> AZ>> Any objections to modifying zend_lookup_class() to support fully > AZ>> qualified class names? Meaning, if it's passed 'A::B' it will lookup > AZ>> class B in namespace A? This change would take a care of several > AZ>> places in the code where class name can be passed. > > Could you point out which places are these?
See my reply to Andi. -Andrei http://www.gravitonic.com/ * Change is the only constant. *