/** * Add a child. When $type is set to 'parameter' the child is added to the Streamwide_Introspection_Method::_params array. Otherwise the child * is set to be the return value of the method. If a return value has already been set returns false * * @param Streamwide_Introspection_Leaf_Interface $child child to add * @return boolean */ public function addChild(Streamwide_Introspection_Leaf_Interface $child) { // do not allow other Streamwide_Introspection_Method objects or Streamwide_Introspection_Array objects // to be added as children because it doesn't make sense $unallowedTypes = array(__CLASS__, 'Streamwide_Introspection_Array'); foreach ($unallowedTypes as $unallowedType) { if ($child instanceof $unallowedType) { return false; } } // Check to see if the child is the error structure for the method if ($child->isMethodError()) { if (0 === count($this->_errors)) { $this->_errors[] = $child; return false; } } // if the child is a method return value check to see if we don't already have set a return value // for this method if ($child->isMethodReturnValue()) { if (0 === count($this->_returns)) { $this->_returns[] = $child; return false; } } // if we got here we are certain that the child is a method parameter $this->_params[] = $child; return true; }