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
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: felipensp at gmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 14:01:27 2025 UTC