php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63256 ReflectionProperty::getName() returns false
Submitted: 2012-10-10 21:48 UTC Modified: 2012-10-11 22:06 UTC
From: asynchronio at gmail dot com Assigned:
Status: Closed Package: Reflection related
PHP Version: 5.4.7 OS: Windows 7 (x64)
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: asynchronio at gmail dot com
New email:
PHP Version: OS:

 

 [2012-10-10 21:48 UTC] asynchronio at gmail dot com
Description:
------------
ReflectionProperty name getter returns false, but getting name directly works 
fine.

Test script:
---------------
<?php
class Test {
	public $foo = 1;
	public $bar = 2;
	
	public function test()
	{
		$class = new ReflectionClass(get_class($this));
		$names = array();
		foreach($class->getProperties() as $property)
		{
			$names[] = $property->getName();
                        // This code works:
                        // $names[] = $property->name;

		}
		return $names;
	}

}

$test = new Test();
var_dump($test->test());

Expected result:
----------------
array(2) { [0]=> 1 [1]=> 2 }

Actual result:
--------------
array(2) { [0]=> string(3) "foo" [1]=> string(3) "bar" }

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-10-11 02:19 UTC] laruence@php.net
I am not sure what's the problem is? 

did you mean getValue?
 [2012-10-11 02:41 UTC] asynchronio at gmail dot com
Sorry, invalid data posted in Expected / Actual results

I've meant:

Expected result:
----------------
array(2) { [0]=> string(3) "foo" [1]=> string(3) "bar" }

Actual result:
--------------
array(2) { [0]=> bool(false) [1]=> bool(false) }
 [2012-10-11 02:51 UTC] asynchronio at gmail dot com
Test script outputs expected result in older versions, tested on 5.2.5 and 5.3.17
 [2012-10-11 03:20 UTC] laruence@php.net
I can not reproduce this with 5.3/5.4, neither linux nor windows.
 [2012-10-11 04:50 UTC] asynchronio at gmail dot com
Hm, interesting thing - i've found this example working fine via "php -e 
<test.php>", but it's not working via builtin web-server ("php -S localhost:8000" 
and then requesting script via browser)
 [2012-10-11 05:29 UTC] asynchronio at gmail dot com
Note: this looks fixed in 5.4.7 version (bug report is related to 5.4.6)
 [2012-10-11 10:02 UTC] reeze@php.net
Are the test script the same as yours ?
any more information?

see http://3v4l.org/Z9T8Q
no version of PHP returns false.
 [2012-10-11 10:29 UTC] laruence@php.net
reeze, reporter already indicated that this a windows issue in the bug info. your 
test box obviously is not a windows server.
 [2012-10-11 10:32 UTC] laruence@php.net
asynchronio, so you mean 5.4.7 works well now in your box?
if yes, then you can close this bug. thanks
 [2012-10-11 10:32 UTC] laruence@php.net
-Status: Open +Status: Feedback
 [2012-10-11 22:06 UTC] asynchronio at gmail dot com
-Status: Feedback +Status: Closed
 [2012-10-11 22:06 UTC] asynchronio at gmail dot com
closing due inability to reproduce
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 05:01:42 2025 UTC