Nette\DI\PhpReflection::parseAnnotation PHP Метод

parseAnnotation() публичный статический Метод

Returns an annotation value.
public static parseAnnotation ( Reflector $ref, $name ) : string | null
$ref Reflector
Результат string | null
    public static function parseAnnotation(\Reflector $ref, $name)
    {
        static $ok;
        if (!$ok) {
            if (!(new \ReflectionMethod(__METHOD__))->getDocComment()) {
                throw new Nette\InvalidStateException('You have to enable phpDoc comments in opcode cache.');
            }
            $ok = TRUE;
        }
        $name = preg_quote($name, '#');
        if ($ref->getDocComment() && preg_match("#[\\s*]@{$name}(?:\\s++([^@]\\S*)?|\$)#", trim($ref->getDocComment(), '/*'), $m)) {
            return isset($m[1]) ? $m[1] : '';
        }
    }

Usage Example

Пример #1
0
 private static function mockInjectedProperties()
 {
     /** @var \ReflectionProperty $property */
     foreach (self::$reflectedClass->getProperties() as $property) {
         if (Nette\DI\PhpReflection::parseAnnotation($property, 'inject') !== NULL || Nette\DI\PhpReflection::parseAnnotation($property, 'autowire') !== NULL) {
             if ($mockedParameterClass = Nette\DI\PhpReflection::parseAnnotation($property, 'var')) {
                 $mockedParameterClass = Nette\DI\PhpReflection::expandClassName($mockedParameterClass, Nette\DI\PhpReflection::getDeclaringClass($property));
             }
             self::setProperty($mockedParameterClass, $property);
         }
     }
 }
All Usage Examples Of Nette\DI\PhpReflection::parseAnnotation