/** * @inheritdoc */ public function readProperties($class, $filter = \ReflectionProperty::IS_PUBLIC) { $properties = []; $classReflector = $this->container->getClassReflector($class); foreach ($classReflector->getProperties($filter) as $property) { try { $properties[$property->getName()] = $this->process($property, 'property'); } catch (\Exception $e) { if (is_object($class)) { $class = get_class($class); } throw new AnnotationException("An exception has occurred while reading property {$class}::{$property}", 0, $e); } } return $properties; }
/** * @param string $closing The closing character * * @return array */ private function parseList($closing) { $array = []; $currentKey = null; $currentValue = null; while (isset($this->parts[++$this->position])) { switch ($this->parts[$this->position]) { case '{': if (isset($currentValue)) { throw new SyntaxException('Unexpected { found.'); } $currentValue = $this->parseList('}'); break; case ',': if (!isset($currentValue)) { throw new SyntaxException('Unexpected , found.'); } $currentValue = $this->getValue($currentValue); if (isset($currentKey)) { $array[$currentKey] = $currentValue; } else { $array[] = $currentValue; } unset($currentKey, $currentValue); break; case ':': if (!isset($currentValue)) { throw new SyntaxException('Unexpected : found.'); } if (!ctype_alnum($currentValue)) { throw new SyntaxException('Keys must be alphanumeric.'); } $currentKey = $currentValue; unset($currentValue); break; case $closing: if (isset($currentValue)) { $currentValue = $this->getValue($currentValue); if (isset($currentKey)) { $array[$currentKey] = $currentValue; } else { $array[] = $currentValue; } } return $array; case '@': list($className, $parameters, $isClass) = $this->parseTag(); if (!$isClass) { throw new \UnexpectedValueException('Inner annotations must be class type annotations'); } $this->saveState(); $currentValue = $this->container->readClass($this->getFullyQualifiedName($className), $parameters, 'annotation'); $this->restoreState(); break; default: if (ctype_space($this->parts[$this->position])) { continue; } if (isset($currentValue)) { throw new SyntaxException('Unexpected data found'); } $currentValue = $this->parts[$this->position]; break; } } throw new SyntaxException('Unexpected end of comment'); }