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


PHP ReflectionClass::hasProperty方法代码示例

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


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

示例1: testClassDeviceResult

 public function testClassDeviceResult()
 {
     $class = new \ReflectionClass('UAParser\\Result\\Device');
     $this->assertTrue($class->hasProperty('model'), 'property family does not exist anymore');
     $this->assertTrue($class->hasProperty('brand'), 'property major does not exist anymore');
     $this->assertTrue($class->hasProperty('family'), 'property family does not exist anymore');
 }
开发者ID:ThaDafinser,项目名称:UserAgentParser,代码行数:7,代码来源:UAParserTest.php

示例2: process

 /**
  * {@inheritdoc}
  */
 public function process(ContainerBuilder $container)
 {
     foreach ($container->findTaggedServiceIds('mautic.event_subscriber') as $id => $tags) {
         $definition = $container->findDefinition($id);
         $classParents = class_parents($definition->getClass());
         if (!in_array(CommonSubscriber::class, $classParents)) {
             continue;
         }
         $definition->addMethodCall('setTemplating', [new Reference('mautic.helper.templating')]);
         $definition->addMethodCall('setRequest', [new Reference('request_stack')]);
         $definition->addMethodCall('setSecurity', [new Reference('mautic.security')]);
         $definition->addMethodCall('setSerializer', [new Reference('jms_serializer')]);
         $definition->addMethodCall('setSystemParameters', [new Parameter('mautic.parameters')]);
         $definition->addMethodCall('setDispatcher', [new Reference('event_dispatcher')]);
         $definition->addMethodCall('setTranslator', [new Reference('translator')]);
         $definition->addMethodCall('setEntityManager', [new Reference('doctrine.orm.entity_manager')]);
         $definition->addMethodCall('setRouter', [new Reference('router')]);
         $class = $definition->getClass();
         $reflected = new \ReflectionClass($class);
         if ($reflected->hasProperty('logger')) {
             $definition->addMethodCall('setLogger', [new Reference('monolog.logger.mautic')]);
         }
         // Temporary, for development purposes
         if ($reflected->hasProperty('factory')) {
             $definition->addMethodCall('setFactory', [new Reference('mautic.factory')]);
         }
         if (in_array(WebhookSubscriberBase::class, $classParents)) {
             $definition->addMethodCall('setWebhookModel', [new Reference('mautic.webhook.model.webhook')]);
         }
         $definition->addMethodCall('init');
     }
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:35,代码来源:EventPass.php

示例3: __get

 /**
  * Magic function which handles the properties accessibility.
  * @param string $propertyName The property name.
  */
 public function __get($propertyName)
 {
     switch ($propertyName) {
         case '_baseExtendableObject':
             return $this->_baseExtendableObject;
         default:
             $class = new \ReflectionClass($this);
             if ($class->hasProperty($propertyName)) {
                 $property = $class->getProperty($propertyName);
                 $property->setAccessible(true);
                 return $property->getValue($this);
             } else {
                 if ($class->hasProperty('_' . $propertyName)) {
                     $property = $class->getProperty('_' . $propertyName);
                     $property->setAccessible(true);
                     return $property->getValue($this);
                 } else {
                     $baseClass = new \ReflectionClass($_baseExtendableObject);
                     $method = $baseClass->getMethod('__get');
                     return $method->invoke($this, $propertyName);
                 }
             }
             return null;
     }
 }
开发者ID:Gnucki,项目名称:DaFramework,代码行数:29,代码来源:ExtendableObjectDecorator.php

示例4: testAddProperty

 /**
  */
 public function testAddProperty()
 {
     $prop = new ReflectionProperty('test');
     $this->assertFalse($this->object->hasProperty('test'));
     $this->object->addProperty($prop);
     $this->assertTrue($this->object->hasProperty('test'));
 }
开发者ID:neiluJ,项目名称:Documentor,代码行数:9,代码来源:ReflectionClassTest.php

示例5: testContracts

 public function testContracts()
 {
     $this->assertTrue($this->reflectedObject->isAbstract());
     $this->assertTrue($this->reflectedObject->hasMethod('getDefaultConfig'));
     $this->assertTrue($this->reflectedObject->hasProperty('ts'));
     $this->assertTrue($this->reflectedObject->hasProperty('shortcodes'));
     $this->assertTrue($this->reflectedObject->hasProperty('config'));
 }
开发者ID:ming-hai,项目名称:XoopsCore,代码行数:8,代码来源:SanitizerComponentTest.php

示例6: getProperty

 protected function getProperty($name)
 {
     if (!$this->target->hasProperty($name)) {
         $message = sprintf('Property not found on object %s.', get_class($this->origin));
         throw new OutOfBoundsException($message);
     }
     /** @var ReflectionProperty $property */
     $property = $this->target->getProperty($name);
     $property->setAccessible(true);
     return $property;
 }
开发者ID:bogdananton,项目名称:php-class-helper,代码行数:11,代码来源:ClassHelper.php

示例7: add_hook_reflect

 /**
  * Adds the name of the specified hook to $hooks using reflection.
  * @param $class_name
  */
 private function add_hook_reflect($class_name)
 {
     $reflector = new ReflectionClass($class_name);
     if (!$reflector->isAbstract() && $reflector->isSubclassOf("Hook") && $class_name !== "GenericHook" && $reflector->hasProperty("friendly_name")) {
         $instance = $reflector->newInstance();
         $name = $reflector->getProperty("friendly_name")->getValue($instance);
         $this->hooks[$name] = "";
         if ($this->get_config("Main", "web_hooks") && $reflector->hasProperty("web") && $reflector->getProperty("web")->getValue($instance)) {
             $this->web_hooks[$name] = "";
         }
     }
 }
开发者ID:creatorfromhell,项目名称:WebCorePlus,代码行数:16,代码来源:PluginModule.php

示例8: getPropertyValue

 /**
  * @param $property_name
  * @param $name
  * @return \Symforce\CoreBundle\Annotation\SymforceAbstractAnnotation|array
  * @throws \Exception
  */
 public function getPropertyValue($property_name, $name, $fetch_values = false)
 {
     if (!$this->reflection->hasProperty($property_name)) {
         throw new \Exception(sprintf("class property(%s->%s) not exists in file: %s ", $this->name, $property_name, $this->reflection->getFileName()));
     }
     if (!isset($this->properties_annotations[$property_name][$name])) {
         throw new \Exception();
     }
     if ($fetch_values) {
         $this->properties_annotations[$property_name][$name]->values;
     }
     return $this->properties_annotations[$property_name][$name]->value;
 }
开发者ID:symforce,项目名称:symforce-core,代码行数:19,代码来源:SymforceAnnotationCache.php

示例9: __construct

 public function __construct($data = NULL)
 {
     if (!is_null($data) && !is_numeric($data) && !is_array($data) && !$data instanceof stdClass) {
         throw new ShopException('Invalid $data type');
     }
     if (is_array($data) || $data instanceof stdClass) {
         $this->loadFromArray((array) $data);
     }
     /**
      * Look for Item repository.
      * For IDE purposes like code completion $this->repo's type should be hinted in each Item the way I did in Cart.
      */
     $repoClass = $this->getRepo();
     $reflection = new ReflectionClass($repoClass);
     $repoClass = (string) $reflection->getName();
     $this->repo = $reflection->isInstantiable() ? new $repoClass() : null;
     /**
      * Look for srl field if it's not already set in class $meta
      */
     $reflection = new ReflectionClass($this);
     if ($srlField = $this->getMeta('srl')) {
         //if srl is given
         if (!$reflection->hasProperty($srlField)) {
             throw new ShopException("Srl field '{$srlField}' doesn't exist");
         }
     } elseif ($reflection->hasProperty('srl')) {
         $this->setMeta('srl', 'srl');
     } else {
         //else return the first _srl field
         foreach ($this as $field => $value) {
             if (substr($field, strlen($field) - 4, strlen($field)) === '_srl') {
                 $this->setMeta('srl', $field);
                 break;
             }
         }
         if (!$this->getMeta('srl')) {
             throw new ShopException('Couldn\'t identify the _srl column');
         }
     }
     //data can also be a serial
     if (is_numeric($data)) {
         if ($obj = $this->repo->get($data, "get%E", get_called_class())) {
             $this->copy($obj);
         } else {
             throw new ShopException("No such {$this->repo->entity} srl {$data}");
         }
     }
     if (is_null(self::$cache)) {
         self::$cache = new ShopCache();
     }
 }
开发者ID:haegyung,项目名称:xe-module-shop,代码行数:51,代码来源:BaseItem.php

示例10: __toString

 public function __toString()
 {
     $object = new \ReflectionClass($this);
     // Get the name of the constant type
     $type = array_search($this->getType(), $object->getConstants());
     // SimpleToken
     if ($object->hasProperty('value')) {
         return sprintf('Token: %s Value: %s', $type, $this->getValue());
     } elseif ($object->hasProperty('name')) {
         return sprintf('Token: %s Namespace: %s Name: %s', $type, $this->getNamespace(), $this->getName());
     } else {
         return sprintf('Token: %s', $type);
     }
 }
开发者ID:phpml,项目名称:phpml,代码行数:14,代码来源:Token.php

示例11: castObject

 /**
  * Casts objects to arrays and adds the dynamic property prefix.
  *
  * @param object           $obj       The object to cast
  * @param \ReflectionClass $reflector The class reflector to use for inspecting the object definition
  *
  * @return array The array-cast of the object, with prefixed dynamic properties
  */
 public static function castObject($obj, \ReflectionClass $reflector)
 {
     if ($reflector->hasMethod('__debugInfo')) {
         $a = $obj->__debugInfo();
     } elseif ($obj instanceof \Closure) {
         $a = array();
     } else {
         $a = (array) $obj;
     }
     if ($obj instanceof \__PHP_Incomplete_Class) {
         return $a;
     }
     if ($a) {
         $combine = false;
         $p = array_keys($a);
         foreach ($p as $i => $k) {
             if (isset($k[0]) && "" !== $k[0] && !$reflector->hasProperty($k)) {
                 $combine = true;
                 $p[$i] = self::PREFIX_DYNAMIC . $k;
             } elseif (isset($k[16]) && "" === $k[16] && 0 === strpos($k, "class@anonymous")) {
                 $combine = true;
                 $p[$i] = "" . $reflector->getParentClass() . '@anonymous' . strrchr($k, "");
             }
         }
         if ($combine) {
             $a = array_combine($p, $a);
         }
     }
     return $a;
 }
开发者ID:symfony,项目名称:var-dumper,代码行数:38,代码来源:Caster.php

示例12: postPersist

 /**
  * Este escucha permite esteblecer el consecutivo de las entidades 
  * al momento de ser almacenadas en base de datos
  * @author Cesar Giraldo <cesargiraldo1108@gmail.com> 23/12/2015
  * @param LifecycleEventArgs $args
  */
 public function postPersist(LifecycleEventArgs $args)
 {
     $entity = $args->getEntity();
     $className = get_class($entity);
     $entityManager = $args->getEntityManager();
     $reflectedClass = new \ReflectionClass($className);
     if ($reflectedClass->hasProperty('consecutive')) {
         $consecutive = null;
         $enabledEntity = false;
         if ($entity instanceof Entity\Item) {
             $enabledEntity = true;
             //buscamos la cantidad de items que tiene creado un proyecto para asignar el consecutivo
             $project = $entity->getProject();
             $consecutive = $project->getLastItemConsecutive() + 1;
             $project->setLastItemConsecutive($consecutive);
             $entityManager->persist($project);
         } elseif ($entity instanceof Entity\Sprint) {
             $enabledEntity = true;
             //buscamos la cantidad de items que tiene creado un proyecto para asignar el consecutivo
             $project = $entity->getProject();
             $consecutive = $project->getLastSprintConsecutive() + 1;
             $project->setLastSprintConsecutive($consecutive);
             $entityManager->persist($project);
         }
         if ($enabledEntity) {
             if ($consecutive != null) {
                 $entity->setConsecutive($consecutive);
             } else {
                 $entity->setConsecutive(1);
             }
             $entityManager->flush();
         }
     }
 }
开发者ID:cesar-giraldo,项目名称:agile-scrum,代码行数:40,代码来源:Indexer.php

示例13: setBriefProperty

 public function setBriefProperty($object, $name, $value, $expectedClass = null)
 {
     $reflection = new \ReflectionClass($object);
     if (!$reflection->hasProperty($name)) {
         return false;
     }
     $property = $reflection->getProperty($name);
     $property->setAccessible(true);
     if ($value instanceof Resource) {
         $value = $value->getUri();
         $annotation = $this->annotationReader->getPropertyAnnotation($property, 'Soil\\CommentsDigestBundle\\Annotation\\Entity');
         if ($annotation) {
             $expectedClass = $annotation->value ?: true;
             var_dump($expectedClass);
             try {
                 $entity = $this->resolver->getEntityForURI($value, $expectedClass);
             } catch (\Exception $e) {
                 $entity = null;
                 echo "Problem with discovering" . PHP_EOL;
                 echo $e->getMessage() . PHP_EOL;
                 var_dump($value, $expectedClass);
                 echo PHP_EOL;
                 //FIXME: Add logging
             }
             if ($entity) {
                 $value = $entity;
             }
         }
     } elseif ($value instanceof Literal) {
         $value = $value->getValue();
     }
     $property->setValue($object, $value);
 }
开发者ID:soilby,项目名称:comments-digest-bundle,代码行数:33,代码来源:BriefPropertySetter.php

示例14: setPropertyValue

 /**
  * @param $tableField TableField
  * @param $value object
  * @param $propertyName string
  * @param $destination object
  * @return mixed|EntityProxy
  */
 private function setPropertyValue($tableField, $value, $propertyName, $destination)
 {
     if (!is_null($value)) {
         if ($tableField->isNumericType()) {
             settype($value, "float");
         } elseif ($tableField->isBoolType()) {
             settype($value, "boolean");
         } elseif ($tableField->isStringType()) {
             settype($value, "string");
         }
     }
     if ($fkConstraint = $tableField->getForeignKeyConstraint()) {
         if ($fkConstraint->isOneToMany()) {
             $referencedTableData = $fkConstraint->getForeignKeyField()->getTable();
             $entity = $referencedTableData->getEntityInstance();
             $value = new CollectionProxy($destination, $this->daoFactory->getDaoFromEntity($entity), $tableField);
         } else {
             $referencedTableData = $fkConstraint->getForeignKeyField()->getTable();
             $entity = $referencedTableData->getEntityInstance();
             $value = new EntityProxy($destination, $entity, $this->daoFactory->getDaoFromEntity($entity), $tableField);
         }
     }
     if ($this->reflectionEntityClass->hasProperty($propertyName)) {
         $property = $this->reflectionEntityClass->getProperty($propertyName);
         if (!$property->isPublic()) {
             $property->setAccessible(true);
             $property->setValue($destination, $value);
             $property->setAccessible(false);
         } else {
             $property->setValue($destination, $value);
         }
     } else {
         $destination->{$propertyName} = $value;
     }
 }
开发者ID:netbrain,项目名称:simphple-orm,代码行数:42,代码来源:Dao.php

示例15: process

 /**
  * {@inheritdoc}
  */
 public function process(ContainerBuilder $container)
 {
     foreach ($container->findTaggedServiceIds('mautic.model') as $id => $tags) {
         $definition = $container->findDefinition($id);
         $definition->addMethodCall('setEntityManager', [new Reference('doctrine.orm.entity_manager')]);
         $definition->addMethodCall('setSecurity', [new Reference('mautic.security')]);
         $definition->addMethodCall('setDispatcher', [new Reference('event_dispatcher')]);
         $definition->addMethodCall('setTranslator', [new Reference('translator')]);
         $definition->addMethodCall('setUserHelper', [new Reference('mautic.helper.user')]);
         $modelClass = $definition->getClass();
         $reflected = new \ReflectionClass($modelClass);
         if ($reflected->hasMethod('setRouter')) {
             $definition->addMethodCall('setRouter', [new Reference('router')]);
         }
         if ($reflected->hasMethod('setLogger')) {
             $definition->addMethodCall('setLogger', [new Reference('monolog.logger.mautic')]);
         }
         if ($reflected->hasMethod('setSession')) {
             $definition->addMethodCall('setSession', [new Reference('session')]);
         }
         // Temporary, for development purposes
         if ($reflected->hasProperty('factory')) {
             $definition->addMethodCall('setFactory', [new Reference('mautic.factory')]);
         }
     }
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:29,代码来源:ModelPass.php


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