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
 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Wed Dec 11 00:01:28 2024 UTC