php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #31318 Static method invocation with classname in a variable
Submitted: 2004-12-28 10:35 UTC Modified: 2007-09-27 08:25 UTC
Votes:17
Avg. Score:4.6 ± 0.7
Reproduced:14 of 14 (100.0%)
Same Version:3 (21.4%)
Same OS:9 (64.3%)
From: sebastian@php.net Assigned: colder (profile)
Status: Closed Package: Feature/Change Request
PHP Version: 5CVS-2004-12-28 (dev) OS: Irrelevant
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sebastian@php.net
New email:
PHP Version: OS:

 

 [2004-12-28 10:35 UTC] sebastian@php.net
Description:
------------
Static members of a class should be accessible even if the classname is stored in a variable.

Reproduce code:
---------------
<?php
class Foo {
    public static function bar() {
        print 'Foo::bar()';
    }
}

$class = 'Foo';
$class::bar();
?>


Expected result:
----------------
Foo::bar()

Actual result:
--------------
Parse error: parse error in D:\foo.php on line 9

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-02 11:59 UTC] andrey@php.net
ReflectionAPI?
 [2005-05-10 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2006-01-31 15:49 UTC] markus at cultcom dot de
This still does'nt work and I would realy like to see this working because it is very ugly to use
eval("return $className::method();") as a workaround...
 [2006-01-31 17:51 UTC] phoeniks at nm dot ru
try
$result = call_user_func(array($class, 'bar'));
 [2007-08-13 15:51 UTC] l dot lucioni at communicationvalley dot it
but still exists. why is it not classified as a bug?
 [2007-08-13 16:05 UTC] bjori@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at 
http://www.php.net/downloads.php

Fixed in PHP5.2.4RC1
 [2007-09-27 08:25 UTC] bjori@php.net
(Was reverted prior to 5.2.4 but committed to 5.3.0)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC