php.net |  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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ngualano at yahoo dot it
New email:
PHP Version: OS:

 

 [2010-10-08 00:42 UTC] ngualano at yahoo dot it
Description:
------------
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:
---------------
<?php
   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:
----------------
mystore

Actual result:
--------------
storage

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-08 02:19 UTC] cataphract@php.net
-Status: Open +Status: Bogus
 [2010-10-08 02:19 UTC] cataphract@php.net
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;

or

$this->prop = new storage('pub');
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Jul 23 22:01:28 2019 UTC