Bug #18125 Updated: Cannot use :: operator when defining child classes

From: Date: Thu, 04 Jul 2002 05:14:53 +0000
Subject: Bug #18125 Updated: Cannot use :: operator when defining child classes
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-13075@lists.php.net to get a copy of this message
ID: 18125 Updated by: bob@bravenet.com Reported By: optikSmoke@subdimension.com Status: Open Bug Type: Zend Engine 2 problem Operating System: Linux 2.4.18 (RedHat 7.3) PHP Version: 4.0CVS-2002-07-02 New Comment: The problem exists in the internal handling of :: within classnames. Here is another example of the same problem in a different context. In this case...when using the classname within a variable, PHP isnt able to find the class. <? class App { function CreateObject($classname) { return new $classname; } } class App::Client { function __construct() { echo 'In App::Client constructor'; } } class Client { function __construct() { echo 'In Client constructor'; } } App::CreateObject('Client'); App::CreateObject('App::Client'); ?> Previous Comments: ------------------------------------------------------------------------ [2002-07-02 23:41:11] optikSmoke@subdimension.com Essentially, I have run into this problem: I am unable to use the '::' operator to define a class within a namespace or inherit from a class within another namespace (I am using 4.3.0-alpha2). Example: <? class Boo { class Scream { } } class Boo::Ahh extends Boo::Scream { } ?> This will generate a "expecting ''{'' on line 7" parser error (the "class Boo::Ahh ....." line). Similarly, "class Biff extends Boo::Scream {}" and "class Biff::Ahh extends Boo {}" (or any other definitions in these forms) will generate the same error. It appears to me that any class definitions that use the :: operator and the extends clause will generate this error. I have found this to be a problem that is particularly annoying, as I am developing a set of library classes that reside within specific namespaces, in seperate files. For example, I would like to be able to create a namespace "Foo" containing class "Bar" and its child class "Biff", both in seperate files so scripts not utililizing "Biff" need not load it. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=18125&edit=1

« previous php.bugs (#13075) next »