/** * This method will add all assertions any ancestral structures (parent classes, implemented interfaces) might have * to the passed class definition. * * @param \AppserverIo\Doppelgaenger\Entities\Definitions\FunctionDefinition $functionDefinition The function definition * we are working on * * @return void */ protected function addAncestralAssertions(FunctionDefinition $functionDefinition) { $dependencies = $this->currentDefinition->getDependencies(); foreach ($dependencies as $dependency) { // freshly set the dependency definition to avoid side effects $dependencyDefinition = null; $fileEntry = $this->structureMap->getEntry($dependency); if (!$fileEntry instanceof Structure) { // Continue, don't fail as we might have dependencies which are not under Doppelgaenger surveillance continue; } // Get the needed parser $structureParserFactory = new StructureParserFactory(); $parser = $structureParserFactory->getInstance($fileEntry->getType(), $fileEntry->getPath(), $this->config, $this->structureMap, $this->structureDefinitionHierarchy); // Get the definition $dependencyDefinition = $parser->getDefinition($dependency, true); // Get the function definitions of the dependency structure $dependencyFunctionDefinitions = $dependencyDefinition->getFunctionDefinitions(); // If we have a method with the name of the current one we have to get the conditions as ancestrals if ($dependencyFunctionDefinitions->entryExists($functionDefinition->getName())) { // Get the definition $dependencyFunctionDefinition = $dependencyFunctionDefinitions->get($functionDefinition->getName()); // If the ancestral function uses the old keyword we have to do too if ($dependencyFunctionDefinition->usesOld() !== false) { $functionDefinition->setUsesOld(true); } // Get the conditions $functionDefinition->setAncestralPreconditions($dependencyFunctionDefinition->getAllPreconditions(true)); $functionDefinition->setAncestralPostconditions($dependencyFunctionDefinition->getAllPostconditions(true)); } } }