php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44642 Trouble with scope resolution operator being used twice
Submitted: 2008-04-04 22:18 UTC Modified: 2008-04-05 18:01 UTC
Votes:4
Avg. Score:4.5 ± 0.9
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: bsgreenb at gmail dot com Assigned:
Status: Wont fix Package: Class/Object related
PHP Version: 5.3CVS-2008-04-04 (CVS) OS: Windows XP
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2008-04-04 22:18 UTC] bsgreenb at gmail dot com
Description:
------------
The problem is that a::$b::d() causes error, where a is a class with static variable $b, which points to a seperate class c, which has the static function d. 

I know other people have encountered this problem.  One person told me the only way they knew to deal with this was call_user_func()  this seems like something that would be very important to fix.  it is for me, at least.

Reproduce code:
---------------
<?php

//Tested on PHP 5.3,

Class a {
	public static $b ='c';
}

Class c {
	public static function d()
	{
		return 'this works';
	}
}
a::$b; // 'c'
c::d(); // 'this works'
a::$b::d(); /* this crashes with the following error:
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\testobj.php on line 17
*/

?>

Expected result:
----------------
I expected that a::$b::d() would return 'this works', as opposed to throwing an error at me.

Actual result:
--------------
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\testobj.php on line 17

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-04-05 12:29 UTC] colder@php.net
No need to make the language accepts such unreadable code...

what about $name = A::$b;
$name::d(); ?
 [2008-04-05 17:59 UTC] bsgreenb at gmail dot com
I mean, yes, it can be done that way, but shouldn't we have the option of doing it this way?  There are plenty of "unreadable" ways of writing PHP code that follow from the internal logic of the language.  If 5.3 guarantees the ability to call static with variables, it would seem only reasonable to assume that this can be done with two variables.
 [2008-04-05 18:01 UTC] bsgreenb at gmail dot com
At the very least, if the developers of PHP are not willing to apply this change, could you at least update the documentation to indicate that code like this results in an error?
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Tue Aug 29 15:01:52 2017 UTC