So to clarify the question...

<?php
class A {
        function foo() {
                return get_called_class();
        }
}
class B extends A {
        function bar() {
                return A::foo();
        }
}
class C extensa A {
        function bar() {
                return B::bar();
        }
}
echo B::foo(); // this must return "B". This is not a question, the question
is in the following two lines...
echo B::bar(); // this must return "B", because B::bar() calls to A::foo()
and A is parent of B, so "late static binding" still the same

I don't understand this. How comes you called A::foo() and you get B? Doesn't make sense to me. If you call A::foo, you are supposed to get A. It looks like your intent is that A::foo() returns different things depending on where it is called, which is not good.

echo C::bar(); // this must return "B" too, because C:bar() calls to
B::bar(), but B is not the parent of C, so the call to B::bar() is handled
in the same way as in the previous line.

This should give the same as previous, of course, since in both cases B::bar() is called.

Is this the expected behavior? (I would prefer it. My previous patches
worked in this way).

I don't think it's good.

Or may be both lines must return "A"? (like Etienne's patches do, and like
my latest path does)

Yes.
--
Stanislav Malyshev, Zend Software Architect
[EMAIL PROTECTED]   http://www.zend.com/
(408)253-8829   MSN: [EMAIL PROTECTED]

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

Reply via email to