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

 ID:                 63256
 Comment by:         asynchronio at gmail dot com
 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:

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)


Previous Comments:
------------------------------------------------------------------------
[2012-10-11 03:20:32] larue...@php.net

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

------------------------------------------------------------------------
[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] larue...@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

Reply via email to