예제 #1
0
 /**
  * @see \Phpdoc2rst\Element\Element::__toString()
  */
 public function __toString()
 {
     $methodName = $this->reflection->getName();
     list($methodName, $httpMethod) = $this->processMethodName($methodName);
     $string = sprintf(".. _%s:\n%s\n----\n", $methodName, $methodName);
     $string .= "Method: {$httpMethod} \n\n";
     $parser = $this->getParser();
     if ($description = $parser->getDescription()) {
         $string .= $description . "\n\n";
     }
     return trim($string);
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function getName()
 {
     return $this->reflection->getName();
 }
예제 #3
0
 /**
  * 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));
             }
         }
     }
 }