|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-06-08 17:59 UTC] D dot Kingma at jool dot nl
Description: ------------ I came across a bug in the reflection api. When a class has a property in capitals and you use the getProperties function from the reflectionClass class all works fine, you get an array with reflectionProperty object. But when you try to get the property manually it fails, throwing an ReflectionException saying it is not a property of that class (also when as a parameter tot the reflectionproperty class i give the name attribute of the reflectionproperty object given from the getProperties method). PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 22:00:01 2025 UTC |
reproduction code: <?php class testReflection{ var $CAPS; var $lower; } //throws an exception, while it should not $x=new reflectionProperty('testReflection','CAPS'); //works as expected $y=new reflectionProperty('testReflection','lower'); /* Same for when you reference an object, instead of giving the name of the class */ $test=new testReflection(); //throws an exception, while it should not $x2=new reflectionProperty($test,'CAPS'); //works as expected $y2=new reflectionProperty($test,'lower'); ?> Possible solution for the CAPS problem: The properties hash table ce->properties_info probably keeps the property names in the origanal string format (didn't change it with tolower()). So the fix will probably be to remove the zend_str_tolower_copy (line 2729) [zend_reflection_api.c] 2728 lcname = do_alloca(name_len + 1); 2729 zend_str_tolower_copy(lcname, name_str, name_len); 2730 if (zend_hash_find(&ce->properties_info, lcname, name_len + 1, (void **) &property_info) == FAILURE) { 2731 free_alloca(lcname); 2732 zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, 2733 "Property %s::$%s does not exist", ce->name, name_str); 2734 return; 2735 }