Recipe 7.7 Calling Methods on an Object Returned by Another Method
7.7.1 Problem
You need to call a
method on an object returned by another method.
7.7.2 Solution
Assign the object to a
temporary variable, and
then call the method of that temporary variable:
$orange = $fruit->get('citrus');
$orange->peel( );
7.7.3 Discussion
This is necessary because a parse error results from:
$fruit->get('citrus')->peel( );
Zend Engine 2 supports direct dereferencing of objects returned from
a method so this workaround is no longer necessary.
|