Hello,
i've written the following code using Etiennes LSB. But I'm facing some
problems.
<?php
class A {
function foo() {
echo get_called_class()
;
}
}
class B extends A {
}
class C {
function moo() {
B::foo();
}
}
B::foo(); // echos "B" - good
$c = new C;
$c->moo(); // echos "C" - wtf?? should be B
?>
Is it a bug, or did I miss anything?
Sebastian Deutsch
Hello, Sebastian
This seems to be a known bug http://bugs.php.net/bug.php?id=43408 and in
fact already assigned.
Fallbacks occur in static/self calls, as static/self resolve to "foo"
and it returns foo as expected.
However, when you do a parent::demo() you actually call bar::demo(),
which is currently understood as a "fully qualified call": the caller is
not passed.There are plans to allow explicit parent call to pass the caller, but
this is still under discussion.
Hello,
care... my case is slightly different. I was aware of that problem, but
in my case I call B::foo() from the main scope - it behaves right -
when I call it within the scope of C (same call) it behaves different.
This is different as described in the bug. The same call should
have the same output, not depending of the scope where I call it.
Sebastian
Lokrain schrieb:
Hello, Sebastian
This seems to be a known bug http://bugs.php.net/bug.php?id=43408 and in
fact already assigned.Fallbacks occur in static/self calls, as static/self resolve to "foo"
and it returns foo as expected.
However, when you do a parent::demo() you actually call bar::demo(),
which is currently understood as a "fully qualified call": the caller is
not passed.There are plans to allow explicit parent call to pass the caller, but
this is still under discussion.
Hello,
that's it. Even
$b = new B;
$b->foo(); // echos "B" - good
works.
Thank you!
*.sebastian
Sebastian Deutsch schrieb:
Hello,
care... my case is slightly different. I was aware of that problem, but
in my case I call B::foo() from the main scope - it behaves right -
when I call it within the scope of C (same call) it behaves different.This is different as described in the bug. The same call should
have the same output, not depending of the scope where I call it.Sebastian
Lokrain schrieb:
Hello, Sebastian
This seems to be a known bug http://bugs.php.net/bug.php?id=43408 and in
fact already assigned.Fallbacks occur in static/self calls, as static/self resolve to "foo"
and it returns foo as expected.
However, when you do a parent::demo() you actually call bar::demo(),
which is currently understood as a "fully qualified call": the caller is
not passed.There are plans to allow explicit parent call to pass the caller, but
this is still under discussion.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
My original reply missed the list :|
Hi,
i've written the following code using Etiennes LSB. But I'm facing some
problems.<?php
class A {
function foo() {
echoget_called_class()
;
}
}class B extends A { } class C { function moo() { B::foo(); } } B::foo(); // echos "B" - good $c = new C; $c->moo(); // echos "C" - wtf?? should be B
?>
Is it a bug, or did I miss anything?
If you mark your function "foo" static - as you should - its "BB" for me.
Moritz Bechler
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHsEeydLVsKnwBr9YRAu8LAJ4+/pnKZ1YzM0wN9k7Vg9eyWaZnUQCeKTrO
hgv4dRz1YtLqHRgagUOKwQA=
=cxLj
-----END PGP SIGNATURE