php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28699 Reflection api bugs
Submitted: 2004-06-08 17:59 UTC Modified: 2004-06-10 13:52 UTC
From: D dot Kingma at jool dot nl Assigned: helly (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.0.0RC3 OS: *
Private report: No CVE-ID: None
 [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).


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-06-08 22:23 UTC] D dot Kingma at jool dot nl
There is also another small bug: When the comment above a method starts with '/** ' (notice the space at the end) the getDocComments() function will return an empty string. When you remove the trailing space, all works fine.

And finally a small functionality request: please add the getDocComments() function to the reflectionProperty class, since the description of the var with the @var tag is also a well known functionality of packages like javadoc/phpdoc and it would come in handy if you cannot only get te description of methods, classes and functions but also the defined properties of the class.

Thnx
David
 [2004-06-09 11:05 UTC] D dot Kingma at jool dot nl
changed category to 'Zend engine 2 problem'
 [2004-06-10 13:09 UTC] D dot Kingma at jool dot nl
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	}
 [2004-06-10 13:10 UTC] D dot Kingma at jool dot nl
Also in RC3
 [2004-06-10 13:37 UTC] helly@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.
 [2004-06-10 13:48 UTC] helly@php.net
BTW: The '/**' is another issue (which i also fixed). Please fill in separate bug reports for separate things in the future.
 [2004-06-10 13:52 UTC] D dot Kingma at jool dot nl
Thnx, I will post the small feature request in a sepperate 'bug report'.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 07:01:29 2024 UTC