|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62218 Namespace conflict with Reflection
Submitted: 2012-06-03 20:10 UTC Modified: 2012-06-03 22:07 UTC
From: titch at tut dot by Assigned:
Status: Closed Package: Class/Object related
PHP Version: 5.4.3 OS: Ubuntu 12.04
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: titch at tut dot by
New email:
PHP Version: OS:


 [2012-06-03 20:10 UTC] titch at tut dot by
if namespace defined, ReflectionObject can't find class by name with namespace prefix

[Sun Jun 03 22:56:50 2012] [error] [client] PHP Fatal error:  Class 'MyProject\\ReflectionObject' not found in /var/www/myproject/MyClass.php on line 6

also namespaces doesn't works with ReflectionClass etc.

but all those scripts work without namespace

Test script:
//500 Internal Server Error
namespace MyProject;
class MyClass {
  function ff(){
    a = new ReflectionObject($this);
    echo 'it works';
$a = new MyClass();


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-06-03 20:15 UTC] titch at tut dot by
sorry, comment "//500 Internal Server Error" was added while posting
remove it, cause namespace must be first directive at script
but it's doesn't fix problem with Reflection, it just misspast
 [2012-06-03 22:03 UTC] mail+php at requinix dot net
So not resolved then? Okay. But not a bug.

As the error message states, PHP can't find MyProject\ReflectionObject. Because 
it's not there. It's at \ReflectionObject.

a = new \ReflectionObject($this);

Read up:
 [2012-06-03 22:07 UTC] titch at tut dot by
Thank you! Resolved.
 [2012-06-03 22:07 UTC] titch at tut dot by
-Status: Open +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jun 20 07:01:29 2024 UTC