/**
  * This method will adjust a field list based on annotation instructions like "willAccept" or
  * "wontAccept".
  *
  * @param ReflectionMethod $reflectionMethod
  * @param array $fields
  * @return array
  */
 protected function adjustFieldListByAnnotation($reflectionMethod, $fields)
 {
     $docBlockUtility = new DocBlockUtility();
     $docComment = $reflectionMethod->getDocComment();
     $fieldsToAdd = $docBlockUtility->getAllAnnotationValues($docComment, '@willAccept');
     $fields = array_merge($fields, $fieldsToAdd);
     $fieldsToRemove = $docBlockUtility->getAllAnnotationValues($docComment, '@wontAccept');
     $fields = array_diff($fields, $fieldsToRemove);
     return $fields;
 }
Exemplo n.º 2
0
 public function testGetAllAnnotationValuesReturnsAllMatchingElements()
 {
     $docBlock = " * @param nothing\n" . " * @param something else\n" . " * @method myMethod\n";
     $docBlockUtility = new DocBlockUtility();
     $this->assertEquals(['nothing', 'something else'], $docBlockUtility->getAllAnnotationValues($docBlock, '@param'));
 }