/**
  * @param AbstractAnnotation[] $annotations
  * @param $comment
  * @param null $filePath
  * @param bool $avoidIfNoAnnotations
  * @return array|null
  * @throws \Exception
  */
 private static function getAnnotationsArrayInComment($annotations, $comment, $filePath = null, $avoidIfNoAnnotations = false)
 {
     $annotationsArray = array();
     $errorsArray = array();
     $hadAnnotationRegistered = false;
     foreach ($annotations as $annot) {
         $stalked = self::stalkAnnot($annot->getName(), $comment);
         if ($stalked === null and $annot->getType() === REQUIRED) {
             $errorsArray[] = ['err' => 'Missing', 'annot' => $annot->getName()];
             continue;
         }
         if ($stalked !== null and !$annot->isValidValue($stalked)) {
             $errorsArray[] = ['err' => 'Wrong value (' . $stalked . ')', 'annot' => $annot->getName()];
             continue;
         }
         if ($stalked !== null) {
             $hadAnnotationRegistered = true;
         }
         $annotationsArray[$annot->getName()] = $stalked ?: $annot->getDefaultValue();
     }
     if (count($errorsArray)) {
         if ($avoidIfNoAnnotations and !$hadAnnotationRegistered) {
             return null;
         } else {
             Rules::throwInvalidAnnotationsException($errorsArray, $filePath);
         }
     }
     return $annotationsArray;
 }