News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Hasin Hayder's Blog:
An interesting bug in ReflectionParameter object in PHP 5.2.1
May 14, 2007 @ 10:11:00

In a new blog post today, Hasin Hayder points out an interesting bug he found in the Reflection functionality that's offered in one of the latest PHP5 series release, version 5.2.1 (also found in 5.2.2). It deals with an issue in the ReflectionParameter object.

[Despite the closing of this bug] there is still the following bug alive in ReflectionParameter object, I tested it against the PHP version 5.2.1 . So what is this bug? The reflection parameter cannot retrieve the default value of a parameter if the next parameter has no default value. PHP simply omits all the variables before that variable and return only values after that variable.

He illustrates with a test class that uses reflection to get the parameters for the constructor. Unfortunately, the object only comes back with the last attribute. This is solved later in the comments, however, when it's discovered that the parameters, some of which are optional, are not in the "correct order" - optional parameters should always follow the required.

0 comments voice your opinion now!
bug reflection parameter order constructor bug reflection parameter order constructor


blog comments powered by Disqus

Similar Posts

Zend Developer Zone: Zend_Controller_Action, Now With Parameters!

MaltBlue.com: Zend\Db\Sql\Select - The Basics (Columns, Limit & Order)

7PHP.com: Auto Generate Properties Dynamically For Your Classes Using Magic Methods & Reflection

PHP-GTK Community Site: Enabling code completion for PHP-GTK in your PHP IDE

Pierre-Alain Joye's Blog: Prominent PHP Users (developers), do your homework or be humble/keep quiet


Community Events





Don't see your event here?
Let us know!


wordpress list testing podcast library api release install developer laravel configure interview application code unittest community threedevsandamaybe language series introduction

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework