/** * @param \TokenReflection\IReflectionMethod $method * @return string */ private function writeReturnType(IReflectionMethod $method) { $returnType = ''; preg_match('/\\*\\h+@return\\h+([^\\h]+)/', (string) $method->getDocComment(), $matches); if (isset($matches[1])) { $returnType = $matches[1]; if ($method->getDeclaringClass()) { $returnType = $this->expandNamespaceAlias($method->getDeclaringClass(), $returnType); } $returnType = ' : ' . $this->formatClassName($returnType); } return $returnType; }
/** * @return int */ public function getEndLine() { return $this->reflection->getEndLine(); }
protected function getParser() { return new CommentParser($this->reflection->getDocComment()); }
/** * Will test if the typehint of a parameter has been changed in a restrictive way and if a parameter has been added * * @param \TokenReflection\IReflection $structureReflection The current structure reflection to inspect * @param \TokenReflection\IReflectionMethod $currentMethod The current method reflection to inspect * @param \TokenReflection\IReflectionMethod $formerMethod The former method reflection to compare to * * @return boolean */ protected function didParametersChangeType(IReflection $structureReflection, IReflectionMethod $currentMethod, IReflectionMethod $formerMethod) { $formerParameters = $formerMethod->getParameters(); $currentParameters = $currentMethod->getParameters(); $parameterCount = count($currentParameters); for ($i = 0; $i < $parameterCount; $i++) { // if both methods have the parameter we compare types, otherwise we check for optionality if (isset($formerParameters[$i])) { // the parameter has been here before, but are the types consisten? if ($formerParameters[$i]->getOriginalTypeHint() !== $currentParameters[$i]->getOriginalTypeHint()) { $this->result->addReason(new Reason($structureReflection->getName(), $currentMethod->getName(), Reason::TYPEHINT_RESTRICTED, $this->mapper)); } } else { // the parameter has not been here before, is it optional? if (!$currentParameters[$i]->isDefaultValueAvailable()) { $this->result->addReason(new Reason($structureReflection->getName(), $currentMethod->getName(), Reason::PARAMETER_ADDED, $this->mapper)); } } } }