Bug #63256 [Opn]: ReflectionProperty::getName() returns false

From: Date: Thu, 11 Oct 2012 03:20:32 +0000
Subject: Bug #63256 [Opn]: ReflectionProperty::getName() returns false
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-174009@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63256&edit=1

 ID:                 63256
 Updated by:         laruence@php.net
 Reported by:        asynchronio at gmail dot com
 Summary:            ReflectionProperty::getName() returns false
 Status:             Open
 Type:               Bug
 Package:            Reflection related
 Operating System:   Windows 7 (x64)
 PHP Version:        5.4.7
 Block user comment: N
 Private report:     N

 New Comment:

I can not reproduce this with 5.3/5.4, neither linux nor windows.


Previous Comments:
------------------------------------------------------------------------
[2012-10-11 02:51:11] 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 02:41:01] 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:19:24] laruence@php.net

I am not sure what's the problem is? 

did you mean getValue?

------------------------------------------------------------------------
[2012-10-10 21:48:33] 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" }


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63256&edit=1


Thread (11 messages)

« previous php.bugs (#174009) next »