/** * Returns visible properties magicly declared by inspected class. * * @return array */ public function getOwnMagicProperties() { if (null === $this->ownMagicProperties) { $this->ownMagicProperties = array(); if (!(self::$propertyAccessLevels & InternalReflectionProperty::IS_PUBLIC) || false === $this->getDocComment()) { return $this->ownMagicProperties; } foreach (array('property', 'property-read', 'property-write') as $annotationName) { $annotations = $this->getAnnotation($annotationName); if (null === $annotations) { continue; } foreach ($annotations as $annotation) { if (!preg_match('~^(?:([\\w\\\\]+(?:\\|[\\w\\\\]+)*)\\s+)?\\$(\\w+)(?:\\s+(.*))?($)~s', $annotation, $matches)) { // Wrong annotation format continue; } list(, $typeHint, $name, $shortDescription) = $matches; if (empty($typeHint)) { $typeHint = 'mixed'; } $doc = $this->getDocComment(); $tmp = $annotation; if ($delimiter = strpos($annotation, "\n")) { $tmp = substr($annotation, 0, $delimiter); } $startLine = $this->getStartLine() + substr_count(substr($doc, 0, strpos($doc, $tmp)), "\n"); $endLine = $startLine + substr_count($annotation, "\n"); $magicProperty = new ReflectionPropertyMagic(null, self::$generator); $magicProperty->setName($name)->setTypeHint($typeHint)->setShortDescription(str_replace("\n", ' ', $shortDescription))->setStartLine($startLine)->setEndLine($endLine)->setReadOnly('property-read' === $annotationName)->setWriteOnly('property-write' === $annotationName)->setDeclaringClass($this)->addAnnotation('var', $typeHint); $this->ownMagicProperties[$name] = $magicProperty; } } } return $this->ownMagicProperties; }