Example #1
0
File: Array.php Project: cwcw/cms
 /**
  * Add a child. Note that only one child is allowed. This is because the introspection will check every element
  * of an array method parameter to correspond with the definition of this child
  *
  * @param Streamwide_Introspection_Composite_Interface $child child parameter
  * @return void
  */
 public function addChild(Streamwide_Introspection_Leaf_Interface $child)
 {
     if (count($this->_children) == 0) {
         $this->_children[] = $child;
         $child->setParent($this);
     }
 }
Example #2
0
File: Method.php Project: cwcw/cms
 /**
  * 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;
 }