Zend Framework

Zend_Server_Reflection - func_get_args() and incorrect phpdoc handling

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.0.0 RC1
  • Fix Version/s: 1.6.0
  • Component/s: Zend_Server_Reflection
  • Labels:
    None
  • Fix Version Priority:
    Should Have

Description

Overview

There seems to be a problem that I've found when brought up by someone on #zftalk . It seems that Zend_Server_Reflection has problems with the use of func_get_args() when there is an @param phpdoc statement with extra params.

Example

/**
* Internally redirects one action to another
*
* @param string $action The new action to be redirected to
* @param mixed Any other parameters passed to this method will be passed as
* parameters to the new action.
* @access public
*/
function setAction($action)  {
    $this->action = $action;
    $args = func_get_args();
    unset($args[0]);
    call_user_func_array(array(&$this, $action), $args);
}

Result

Error msg: ( ! ) Fatal error: Call to a member function isOptional() on a non-object in Zend/Server/Reflection/Function/Abstract.php on line 346

Discussion links

http://www.nabble.com/Zend_Server_Reflection-t3822461.html#a10827860


http://www.spotsec.com

Issue Links

Activity

Hide
Darby Felton added a comment -

Updated affected component.

Show
Darby Felton added a comment - Updated affected component.
Hide
Bill Karwin added a comment -

Assigning to Matthew.

Show
Bill Karwin added a comment - Assigning to Matthew.
Hide
Matthew Weier O'Phinney added a comment -

It's typically not a good plan when creating web services to allow dynamic numbers of arguments, and I'd argue that instead of allowing an undetermined number of arguments, you should have a second array argument (defaulting to an empty array).

I'll look into this, but it represents a potential BC break. Currently, each parameter is a ReflectionParameter, whereas the fix for this would require either a different object type or array as a possibility.

Show
Matthew Weier O'Phinney added a comment - It's typically not a good plan when creating web services to allow dynamic numbers of arguments, and I'd argue that instead of allowing an undetermined number of arguments, you should have a second array argument (defaulting to an empty array). I'll look into this, but it represents a potential BC break. Currently, each parameter is a ReflectionParameter, whereas the fix for this would require either a different object type or array as a possibility.
Hide
Matthew Weier O'Phinney added a comment -

Another report in ZF-1866. I will attempt to fix this for 1.1.0

Show
Matthew Weier O'Phinney added a comment - Another report in ZF-1866. I will attempt to fix this for 1.1.0
Hide
Alexander Veremyev added a comment -

Fixed.

Exception is thrown now if number of arguments doesn't correspond number of actual function arguments.

That should be the best solution for services.

Show
Alexander Veremyev added a comment - Fixed. Exception is thrown now if number of arguments doesn't correspond number of actual function arguments. That should be the best solution for services.
Hide
Wil Sinclair added a comment -

Updating for the 1.6.0 release.

Show
Wil Sinclair added a comment - Updating for the 1.6.0 release.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
2h
Original Estimate - 2 hours
Remaining:
2h
Remaining Estimate - 2 hours
Logged:
Not Specified
Time Spent - Not Specified