当前位置: 首页>>代码示例>>PHP>>正文


PHP ReflectionProperty::getName方法代码示例

本文整理汇总了PHP中ReflectionProperty::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionProperty::getName方法的具体用法?PHP ReflectionProperty::getName怎么用?PHP ReflectionProperty::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ReflectionProperty的用法示例。


在下文中一共展示了ReflectionProperty::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: match

 /**
  * {@inheritdoc}
  */
 public function match(\ReflectionProperty $property, $givenName)
 {
     if (array_key_exists($property->getName(), $this->map)) {
         return $this->map[$property->getName()] === $givenName;
     }
     return false;
 }
开发者ID:rafrsr,项目名称:lib-array2object,代码行数:10,代码来源:MapMatcher.php

示例2: __construct

 /**
  * @param \ReflectionProperty $accessedProperty
  * @param string              $nameSuffix
  */
 public function __construct(ReflectionProperty $accessedProperty, $nameSuffix)
 {
     $this->accessedProperty = $accessedProperty;
     $originalName = $this->accessedProperty->getName();
     $name = UniqueIdentifierGenerator::getIdentifier($originalName . $nameSuffix);
     parent::__construct(Class_::MODIFIER_PRIVATE, array(new PropertyProperty($name)));
 }
开发者ID:royopa,项目名称:GeneratedHydrator,代码行数:11,代码来源:PropertyAccessor.php

示例3: defaultValue

 public function defaultValue()
 {
     if ($this->property->isDefault()) {
         $defaultProperties = $this->property->getDeclaringClass()->getDefaultProperties();
         return $defaultProperties[$this->property->getName()];
     }
     return null;
 }
开发者ID:watoki,项目名称:reflect,代码行数:8,代码来源:InstanceVariableProperty.php

示例4: getDeclaringClass

 /**
  * Returns declaring class or trait.
  * @return \ReflectionClass
  */
 public static function getDeclaringClass(\ReflectionProperty $prop)
 {
     foreach ($prop->getDeclaringClass()->getTraits() as $trait) {
         if ($trait->hasProperty($prop->getName())) {
             return self::getDeclaringClass($trait->getProperty($prop->getName()));
         }
     }
     return $prop->getDeclaringClass();
 }
开发者ID:Northys,项目名称:di,代码行数:13,代码来源:PhpReflection.php

示例5: isKey

 /**
  * Has the class in annotation this property as key?
  *
  * @return boolean
  */
 public function isKey()
 {
     if ($this->isKey === null) {
         foreach ($this->getAnnotationClass()->getAll('key') as $key) {
             if ($key == $this->property->getName()) {
                 return true;
             }
         }
     }
     return $this->isKey;
 }
开发者ID:kathynka,项目名称:Foundation,代码行数:16,代码来源:Field.php

示例6: resolvePropertyMetadata

 /**
  * Generic class property resolver.
  *
  * @param \ReflectionProperty $property
  * @param ClassMetadata       $classMetadata
  *
  * @return PropertyMetadata Resolved property metadata
  */
 protected function resolvePropertyMetadata(\ReflectionProperty $property, ClassMetadata $classMetadata) : PropertyMetadata
 {
     // Create method metadata instance
     $propertyMetadata = $classMetadata->propertiesMetadata[$property->getName()] ?? new PropertyMetadata($classMetadata);
     $propertyMetadata->name = $property->getName();
     $propertyMetadata->modifiers = $property->getModifiers();
     $propertyMetadata->isPublic = $property->isPublic();
     $propertyMetadata->typeHint = $this->getCommentTypeHint(is_string($property->getDocComment()) ? $property->getDocComment() : '');
     // Store property metadata to class metadata
     return $classMetadata->propertiesMetadata[$propertyMetadata->name] = $propertyMetadata;
 }
开发者ID:samsonframework,项目名称:container,代码行数:19,代码来源:PropertyResolverTrait.php

示例7: exportCode

 /**
  * Exports the PHP code
  *
  * @return string
  */
 public function exportCode()
 {
     $default_properties = $this->_property->getDeclaringClass()->getDefaultProperties();
     $modifiers = \Reflection::getModifierNames($this->_property->getModifiers());
     $default_value = null;
     if (array_key_exists($this->_property->getName(), $default_properties)) {
         $default_value = $default_properties[$this->_property->getName()];
         if (!is_numeric($default_value)) {
             $default_value = "'{$default_value}'";
         }
     }
     return sprintf('%s $%s%s;', join(' ', $modifiers), $this->_property->getName(), !is_null($default_value) ? " = {$default_value}" : '');
 }
开发者ID:michalkoslab,项目名称:Helpers,代码行数:18,代码来源:ReflectionProperty.php

示例8: getPropertyIdentifier

 public static function getPropertyIdentifier(\ReflectionProperty $reflectionProperty, $className)
 {
     $key = null;
     if ($reflectionProperty->isPrivate()) {
         $key = '\\0' . $className . '\\0' . $reflectionProperty->getName();
     } elseif ($reflectionProperty->isProtected()) {
         $key = '' . "" . '*' . "" . $reflectionProperty->getName();
     } elseif ($reflectionProperty->isPublic()) {
         $key = $reflectionProperty->getName();
     }
     if (null === $key) {
         throw new \InvalidArgumentException('Unable to detect property visibility');
     }
     return $key;
 }
开发者ID:graphaware,项目名称:neo4j-php-ogm,代码行数:15,代码来源:ProxyUtils.php

示例9: getPropertyClass

 /**
  * Parse the docblock of the property to get the class of the var annotation.
  *
  * @param \ReflectionProperty $property
  *
  * @throws AnnotationException Non exists class.
  *
  * @return null|ObjectDefinition
  */
 public function getPropertyClass(\ReflectionProperty $property)
 {
     $propertyComment = $property->getDocComment();
     if (!preg_match('/@var\\s+([^\\s\\(\\*\\/]+)/', $propertyComment, $matches)) {
         return;
     }
     $className = end($matches);
     if (!is_string($className) || in_array($className, static::$ignoredTypes)) {
         return;
     }
     $classWithNamespace = $className;
     if ($this->namespaceExists($classWithNamespace) === false) {
         $classWithNamespace = $this->namespace . '\\' . $className;
     }
     if (!$this->classExists($classWithNamespace)) {
         $declaringClass = $property->getDeclaringClass();
         throw new AnnotationException(sprintf('The @var annotation on %s::%s contains a non existent class "%s"', $declaringClass->name, $property->getName(), $className));
     }
     $createNewObject = function ($propertyComment, $className, $classWithNamespace) {
         $classParameters = $this->propertyClassParameters($propertyComment, $className);
         if (is_array($classParameters)) {
             $values = [];
             foreach ($classParameters as $value) {
                 $values[] = static::parseValue($value);
             }
             $object = new ObjectDefinition($classWithNamespace, $className);
             $object->setConstructorInjection($values);
             return $object;
         }
         return new $classWithNamespace();
     };
     return $createNewObject($propertyComment, $className, $classWithNamespace);
 }
开发者ID:devstackphp,项目名称:di,代码行数:42,代码来源:PhpDocReader.php

示例10: resolveProperty

 /**
  * {@inheritdoc}
  * @throws PropertyDefinitionNotFoundException
  */
 public function resolveProperty(DefinitionAnalyzer $analyzer, ClassDefinition $classDefinition, \ReflectionProperty $reflectionProperty)
 {
     $propertyName = $reflectionProperty->getName();
     if ($classDefinition->hasProperty($propertyName)) {
         $classDefinition->getProperty($propertyName)->defineDependency(new ServiceReference($this->value['value']));
     }
 }
开发者ID:samsonframework,项目名称:container,代码行数:11,代码来源:InjectService.php

示例11: getNativePropertyType

 /**
  * @param  ReflectionProperty
  * @param  array (string => string)
  * @param  string
  * @return string
  */
 public function getNativePropertyType(ReflectionProperty $prop, &$defaults, &$type)
 {
     $name = $prop->getName();
     if ($doc = trim($prop->getDocComment(), " \t\r\n*/")) {
         if (preg_match('/@var[ \\t]+([a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*)\\s*(:?\\[[\\s0-9]*\\]|)/', $doc, $m)) {
             if ($m[2]) {
                 $type = 'arr';
             } else {
                 $type = substr(strtolower($m[1]), 0, 3);
                 if ($type == 'mix') {
                     $type = 'str';
                 } elseif (!in_array($type, self::$phpTypes)) {
                     $type = 'obj';
                 }
             }
         }
     }
     if (!$type) {
         $type = substr(gettype(self::referenceObj($prop->getDeclaringClass()->getName())->{$name}), 0, 3);
     }
     $nativeType = $this->nativeTypes[$type == 'str' ? strlen('' . $defaults[$name]) > 255 ? 'tex' : 'str' : $type];
     if (!$nativeType) {
         throw new IllegalTypeException('Unstorable type: ' . $type . ' for property: ' . $name);
     }
     return $nativeType;
 }
开发者ID:rsms,项目名称:phpab,代码行数:32,代码来源:PObjectStorage.php

示例12: getPropertyLine

 /**
  * @param \ReflectionProperty $property
  * @return int
  */
 public static function getPropertyLine(\ReflectionProperty $property)
 {
     $class = $property->getDeclaringClass();
     $context = 'file';
     $contextBrackets = 0;
     foreach (token_get_all(file_get_contents($class->getFileName())) as $token) {
         if ($token === '{') {
             $contextBrackets += 1;
         } elseif ($token === '}') {
             $contextBrackets -= 1;
         }
         if (!is_array($token)) {
             continue;
         }
         if ($token[0] === T_CLASS) {
             $context = 'class';
             $contextBrackets = 0;
         } elseif ($context === 'class' && $contextBrackets === 1 && $token[0] === T_VARIABLE) {
             if ($token[1] === '$' . $property->getName()) {
                 return $token[2];
             }
         }
     }
     return NULL;
 }
开发者ID:kdyby,项目名称:doctrine,代码行数:29,代码来源:Helpers.php

示例13: reflectProperty

function reflectProperty($class, $property)
{
    $propInfo = new ReflectionProperty($class, $property);
    echo "**********************************\n";
    echo "Reflecting on property {$class}::{$property}\n\n";
    echo "__toString():\n";
    var_dump($propInfo->__toString());
    echo "export():\n";
    var_dump(ReflectionProperty::export($class, $property, true));
    echo "export():\n";
    var_dump(ReflectionProperty::export($class, $property, false));
    echo "getName():\n";
    var_dump($propInfo->getName());
    echo "isPublic():\n";
    var_dump($propInfo->isPublic());
    echo "isPrivate():\n";
    var_dump($propInfo->isPrivate());
    echo "isProtected():\n";
    var_dump($propInfo->isProtected());
    echo "isStatic():\n";
    var_dump($propInfo->isStatic());
    $instance = new $class();
    if ($propInfo->isPublic()) {
        echo "getValue():\n";
        var_dump($propInfo->getValue($instance));
        $propInfo->setValue($instance, "NewValue");
        echo "getValue() after a setValue():\n";
        var_dump($propInfo->getValue($instance));
    }
    echo "\n**********************************\n";
}
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:ReflectionProperty_basic1.php

示例14: getName

 public function getName()
 {
     if (isset($this->_name)) {
         return $this->_name;
     }
     return parent::getName();
 }
开发者ID:ncud,项目名称:sagalaya,代码行数:7,代码来源:SchemaReflectionProperty.php

示例15: getPropertyParserBuilder

 private function getPropertyParserBuilder(\ReflectionProperty $property)
 {
     $propertyParserBuilder = new PropertyParserBuilder($property->getName());
     foreach ($this->annotationReader->getAnnotationsFromProperty($property) as $propertyAnnotation) {
         $this->annotationParserFactory->getAnnotationParserFor($propertyAnnotation)->execute($propertyAnnotation, $propertyParserBuilder);
     }
     return $propertyParserBuilder;
 }
开发者ID:mcustiel,项目名称:php-simple-request,代码行数:8,代码来源:ParserGenerator.php


注:本文中的ReflectionProperty::getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。