|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #53019 to obtain the name of instance in the ReflectionObject class
Submitted: 2010-10-08 00:42 UTC Modified: 2010-10-08 02:19 UTC
From: ngualano at yahoo dot it Assigned:
Status: Not a bug Package: Reflection related
PHP Version: 5.2.14 OS: windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
44 - 4 = ?
Subscribe to this entry?

 [2010-10-08 00:42 UTC] ngualano at yahoo dot it
why, the property 'name' in the ReflectionObject, returns the name of the class 
instead of name of instance of class?
we have, already the method 'getName' for obtain the class name;

Please implements this change, i need to obtain the name of instance inside of 
constructor and other methods.

Test script:
   class storage {
      function __construct(){
         $p= new ReflectionObject($this);
         echo $p->name;

   $mystore = new storage('pub');
   //when the object is constructed echo() display 'storage' instead 'mystore'


Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-08 02:19 UTC]
-Status: Open +Status: Bogus
 [2010-10-08 02:19 UTC]
Not possible/wouldn't make sense. As to the second part, there is no sensible solution for this case:

$mystore = new storage('pub');
$mystore2 = $mystore;


$this->prop = new storage('pub');
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Jun 25 05:01:24 2021 UTC