Bug #55839 [NEW]: Static accessors through variables only work on simple variables
| From: | chris at mcfadyen dot ca | Date: | Mon, 03 Oct 2011 18:47:15 +0000 |
| Subject: | Bug #55839 [NEW]: Static accessors through variables only work on simple variables | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-164062@lists.php.net to get a copy of this message | ||
From:
Operating system: Windows
PHP version: 5.3SVN-2011-10-03 (SVN)
Package: Class/Object related
Bug Type: Bug
Bug description:Static accessors through variables only work on simple variables
Description:
------------
Using a static operator ( :: ) works for simple variables (
$foo::function() ),
but results in an undefined variable warning for the class name at run-time
when
using a class property ( ${$bar->foo}::function() ). Obviously, a direct
access
attempt ( $bar->foo::function() ) fails with a parse error.
---
From manual page: http://www.php.net/language.oop5.static
---
Test script:
---------------
class A {
public $referrer = 'B';
}
class B {
public static function foo() {
echo "Foo";
}
}
$b = 'B';
$a = new A();
$b::foo();
${$a->referrer}::foo();
$c = $a->referrer;
$c::foo();
Expected result:
----------------
I would expect to see
Foo
Foo
Foo
Actual result:
--------------
This is the result:
Foo
Notice (8): Undefined variable: B
Foo
--
Edit bug report at https://bugs.php.net/bug.php?id=55839&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=55839&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=55839&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=55839&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=55839&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=55839&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=55839&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=55839&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=55839&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=55839&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=55839&r=support
Expected behavior: https://bugs.php.net/fix.php?id=55839&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=55839&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=55839&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=55839&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=55839&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=55839&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=55839&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=55839&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=55839&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=55839&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=55839&r=mysqlcfg