php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43343 Variable class name
Submitted: 2007-11-20 11:01 UTC Modified: 2007-12-07 17:19 UTC
From: felipensp at gmail dot com Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.3CVS-2007-11-20 (snap) OS:
Private report: No CVE-ID: None
 [2007-11-20 11:01 UTC] felipensp at gmail dot com
Description:
------------
See the code below.

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

namespace foobar;

class foo { }

//var_dump(namespace::);
// Parse error: syntax error, unexpected ')', expecting T_STRING or T_VARIABLE or '$'

// Ok!

$foo = 'foo';

var_dump(new namespace::$foo);
// Fatal error: Class 'foobar' not found 

// var_dump(new namespace::foo); # Ok!

Expected result:
----------------
var_dump(namespace::);
Parse error: syntax error, unexpected ')', expecting T_STRING

or

Support the variable referencing class name.

Actual result:
--------------
Fatal error: Class 'foobar' not found 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-24 12:31 UTC] jani@php.net
Another namespace issue.
 [2007-12-07 17:19 UTC] dmitry@php.net
The syntax A::$foo assumes static property of class A.
The syntax namespace::$foo makes no sense as namespaces cannot contain variables.

The current version emits error message:

Fatal error: Cannot use 'namespace' as a class name
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Jul 30 11:01:23 2021 UTC