/** * Will return a list of function definition objects extracted from a given token array * * @param array $tokens The token array * @param boolean $getRecursive Do we have to get the ancestral contents as well? * * @return boolean|\TechDivision\PBC\Entities\Lists\FunctionDefinitionList */ public function getDefinitionListFromTokens(array $tokens, $getRecursive = true) { // First of all we need to get the function tokens $tokens = $this->getFunctionTokens($tokens); // Did we get something valuable? $functionDefinitionList = new FunctionDefinitionList(); if ($tokens === false) { return false; } elseif (count($tokens) === 1) { // We got what we came for, or did we? if (isset($tokens[0])) { $functionDefinitionList->add($this->getDefinitionFromTokens($tokens[0], $getRecursive)); } return $functionDefinitionList; } elseif (count($tokens) > 1) { // We are still here, but got a function name to look for foreach ($tokens as $token) { try { $functionDefinitionList->add($this->getDefinitionFromTokens($token, $getRecursive)); } catch (\UnexpectedValueException $e) { // Just try the next one continue; } } } return $functionDefinitionList; }
/** * Will flatten all conditions available at the time of the call. * That means this method will check which conditions make sense in an inheritance context and will drop the * others. * This method MUST be protected/private so it will run through \TechDivision\PBC\Entities\AbstractLockableEntity's * __call() method which will check the lock status before doing anything. * * @return bool */ protected function flattenConditions() { // As our lists only supports unique entries anyway, the only thing left is to check if the condition's // assertions can be fulfilled (would be possible as direct assertions), and flatten the contained // function definitions as well $ancestralConditionIterator = $this->ancestralInvariants->getIterator(); foreach ($ancestralConditionIterator as $conditionList) { $conditionListIterator = $conditionList->getIterator(); foreach ($conditionListIterator as $assertion) { } } // No flatten all the function definitions we got $functionDefinitionIterator = $this->functionDefinitions->getIterator(); foreach ($functionDefinitionIterator as $functionDefinition) { $functionDefinition->flattenConditions(); } return false; }