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


PHP ReflectionObject::hasProperty方法代码示例

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


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

示例1: setMyPropertie

 public function setMyPropertie($object = null)
 {
     if (null === $this->_meta_self_reflection) {
         $this->_meta_self_reflection = new \ReflectionObject($this);
     }
     $this->freeze = false;
     if (is_array($object) || is_object($object)) {
         // $access = \\Symfony\Component\PropertyAccess\PropertyAccess::getPropertyAccessor() ;
         foreach ($object as $property => $value) {
             if (null === $value) {
                 continue;
             }
             $set = 'set_' . $property;
             try {
                 if (method_exists($this, $set)) {
                     if ($this->{$set}($value)) {
                         $this->throwError("%s already seted", $property);
                     }
                 } else {
                     if (!$this->_meta_self_reflection->hasProperty($property)) {
                         $this->throwError("%s not exists", $property);
                     }
                     $_set = 'set' . $this->camelize($property);
                     if (method_exists($this, $_set)) {
                         throw new \Exception(sprintf("%s->%s method %s should change to %s", $this->getMeteTypeName(), $property, $_set, $set));
                     }
                     if (0 === strpos($property, '_')) {
                         $this->throwError("%s is private property", $property);
                     }
                     $_property = $this->_meta_self_reflection->getProperty($property);
                     if ($_property->isStatic()) {
                         $this->throwError("%s is static property", $property);
                     }
                     if ($_property->isPrivate()) {
                         $this->throwError("%s is private property", $property);
                     }
                     /*
                                             $_property->setAccessible( true ) ;
                                             $_property->setValue( $this, $value ) ;
                     */
                     $this->{$property} = $value;
                 }
                 $this->_annot_properties[$property] = true;
             } catch (\Symforce\AdminBundle\Compiler\MetaType\Exception $e) {
                 if ($this instanceof \Symforce\AdminBundle\Compiler\MetaType\DoctrineType || $this instanceof \Symforce\AdminBundle\Compiler\MetaType\DoctrineProperty) {
                     $this->throwPropertyError($property, $e->getMessage());
                 } else {
                     throw $e;
                 }
             }
         }
     } else {
         if (!empty($object)) {
             throw new \Exception(sprintf("%s can not setValue(%s)", $this->getClassName(), $value));
         }
     }
     $this->freeze = true;
 }
开发者ID:symforce,项目名称:symforce-admin,代码行数:58,代码来源:Type.php

示例2: findProperty

 /**
  * @param \ReflectionObject $reflectionObject
  * @param string $key
  * @return null|\ReflectionProperty
  */
 private static function findProperty(\ReflectionObject $reflectionObject, $key)
 {
     if ($reflectionObject->hasProperty($key)) {
         return $reflectionObject->getProperty($key);
     }
     $camelized = lcfirst(join(array_map('ucfirst', explode('_', $key))));
     if ($reflectionObject->hasProperty($camelized)) {
         return $reflectionObject->getProperty($camelized);
     }
     return null;
 }
开发者ID:kix,项目名称:apiranha,代码行数:16,代码来源:ReflectionHydratorListener.php

示例3: setProperty

 /**
  * @param string $property
  * @param mixed $value
  */
 private function setProperty($property, $value)
 {
     $reflection = new \ReflectionObject($this);
     if (!$reflection->hasProperty($property) || !$reflection->getProperty($property)->isPrivate()) {
         $this->{$property} = $value;
     }
 }
开发者ID:stoutlogic,项目名称:understory,代码行数:11,代码来源:CustomTaxonomy.php

示例4: __construct

 protected function __construct()
 {
     $config = Hayate_Config::getInstance();
     if ((!$config->get('view', false) || !isset($config->core->view['smarty_dir'])) && !class_exists('Smarty', false)) {
         throw new Hayate_View_Exception(_('smarty_dir configuration parameter missing.'));
     }
     if (!class_exists('Smarty', false)) {
         require_once rtrim($config->core->view['smarty_dir'], '\\/') . '/Smarty.class.php';
     }
     // finally we can instantiate
     $this->smarty = new Smarty();
     // and set the properties values
     $ro = new ReflectionObject($this->smarty);
     foreach ($config->core->view as $prop => $val) {
         if ($ro->hasProperty($prop)) {
             $this->smarty->{$prop} = $val;
         }
     }
     /*
             if (version_compare($this->smarty->_version, '3.0') < 0)
             {
                 $this->is_smarty_2 = true;
             }
     */
 }
开发者ID:heromaeda,项目名称:hayate,代码行数:25,代码来源:Smarty.php

示例5: getPropertyValue

 public static function getPropertyValue($object, $propertyName)
 {
     $refClass = new \ReflectionObject($object);
     if ($refClass->hasProperty($propertyName)) {
         $property = $refClass->getProperty($propertyName);
         $property->setAccessible(true);
         return $property->getValue($object);
     }
 }
开发者ID:joeldavuk,项目名称:framework,代码行数:9,代码来源:Object.php

示例6: matches

 /**
  * (non-PHPdoc)
  * @see CIUnit_Framework_ConstraintAbstract::matches()
  */
 protected function matches($value)
 {
     $object = new ReflectionObject($value);
     if ($object->hasProperty($this->attribute)) {
         $attribute = $object->getProperty($this->attribute);
         return $attribute->isStatic();
     }
     return FALSE;
 }
开发者ID:ykbryan,项目名称:ciunit-framework,代码行数:13,代码来源:ObjectHasStaticAttribute.php

示例7: propertiesSetAndMatch

 /**
  * iteratest through properties to set values on the stub that exists on the stub class. If $force is true,
  * will set the value regardless of whether or not the property exists on the element.
  *
  * @param $stub
  * @param array $properties
  * @param bool  $force
  */
 public static function propertiesSetAndMatch($stub, array $properties = array(), $force = false)
 {
     $rf_obj = new ReflectionObject($stub);
     foreach ($properties as $name => $value) {
         if ($force || $rf_obj->hasProperty($name)) {
             $stub->{$name} = $value;
         }
     }
     $stub->__phpunit_getInvocationMocker()->addMatcher(new ComponentStubMatcher($properties));
 }
开发者ID:openeyes,项目名称:openeyes,代码行数:18,代码来源:ComponentStubGenerator.php

示例8: run

 public function run()
 {
     global $request;
     $em = \Shared\DoctrineHelper::getEntityManager();
     $idPlayer = $this->objPlayer->getId();
     $codeVerif = $request->request->get("numeroVerif");
     $objSuppressionPersonnage = \Site\SiteHelper::getSuppressionPersonnageRepository()->findByIdPlayerAndNumeroVerif($this->objPlayer->getId(), $codeVerif);
     if ($objSuppressionPersonnage !== null) {
         if (\Player\PlayerHelper::haveGuild($idPlayer) == false) {
             $objPlayerIndex = \Player\PlayerHelper::getPlayerIndexRepository()->find($this->objAccount->getId());
             if ($objPlayerIndex->getPid1() == $idPlayer) {
                 $func = "setPid1";
             } else {
                 if ($objPlayerIndex->getPid2() == $idPlayer) {
                     $func = "setPid2";
                 } else {
                     if ($objPlayerIndex->getPid3() == $idPlayer) {
                         $func = "setPid3";
                     } else {
                         if ($objPlayerIndex->getPid4() == $idPlayer) {
                             $func = "setPid4";
                         }
                     }
                 }
             }
             $objPlayerIndex->{$func}(0);
             $em->persist($objPlayerIndex);
             \Player\PlayerHelper::getMarriageRepository()->deleteByIdPlayer($idPlayer);
             \Player\PlayerHelper::getItemRepository()->deleteByOwnerId($idPlayer, ["EQUIPMENT", "INVENTORY"]);
             $objPlayerDelete = new \Player\Entity\PlayerDeleted();
             $oldReflection = new \ReflectionObject($this->objPlayer);
             $newReflection = new \ReflectionObject($objPlayerDelete);
             foreach ($oldReflection->getProperties() as $property) {
                 if ($newReflection->hasProperty($property->getName())) {
                     $newProperty = $newReflection->getProperty($property->getName());
                     $newProperty->setAccessible(true);
                     $newProperty->setValue($objPlayerDelete, $property->getValue($this->objPlayer));
                 }
             }
             $em->persist($objPlayerDelete);
             \Player\PlayerHelper::getMessengerListRepository()->deleteByNamePlayer($this->objPlayer->getName());
             $em->remove($this->objPlayer);
             $em->remove($objSuppressionPersonnage);
             $em->flush();
             $Tableau_Retour_Json = array('result' => true);
         } else {
             $em->remove($objSuppressionPersonnage);
             $em->flush();
             $Tableau_Retour_Json = array('result' => false, 'reasons' => "Le joueur est membre ou chef d'une guilde.");
         }
     } else {
         $Tableau_Retour_Json = array('result' => false, 'reasons' => "Le code de vérification n'est pas le bon.");
     }
     echo json_encode($Tableau_Retour_Json);
 }
开发者ID:SylvainSimon,项目名称:Metinify,代码行数:55,代码来源:ajaxPersonnageDeleteExecute.php

示例9: set

 /**
  * Sets the property of an object: It does not matter whether the property
  * is public, private or protected
  *
  * @param string $property
  * @param mixed $value
  * @param $object
  * @return void
  */
 public static function set($property, $value, $object)
 {
     $reflection = new \ReflectionObject($object);
     if ($reflection->hasProperty($property)) {
         $property = $reflection->getProperty($property);
         $property->setAccessible(true);
         $property->setValue($object, $value);
     } else {
         $object->{$property} = $value;
     }
 }
开发者ID:scandio,项目名称:troba,代码行数:20,代码来源:ObjectProperty.php

示例10: lcfirst

 /**
  * Implementation of __call
  * Adds getter and setter methods for all non-private properties.
  * If a set-Operation for a non-private property is called, the change
  * will be tracked.
  *
  * @param $name
  * @param $arguments
  * @return mixed
  */
 function __call($name, $arguments)
 {
     if (strpos($name, 'get') === 0) {
         $propertyName = lcfirst(substr($name, 3));
         if (property_exists($this, $propertyName)) {
             return $this->{$propertyName};
         }
         return null;
     }
     if (strpos($name, 'set') === 0 && sizeof($arguments) == 1) {
         $propertyName = lcfirst(substr($name, 3));
         // never allow setting of private or protected properties
         if (!$this->initialReflectionObject->hasProperty($propertyName) || $this->initialReflectionObject->getProperty($propertyName)->isPublic()) {
             // do nothing if nothing changed
             if (!property_exists($this, $propertyName) || $this->{$propertyName} != $arguments[0]) {
                 $this->{$propertyName} = $arguments[0];
                 $this->propertyChanges[] = $propertyName;
             }
         }
     }
 }
开发者ID:seifertT,项目名称:jira-php-api,代码行数:31,代码来源:DiffableObject.php

示例11: fillEntity

 /**
  * Заполнить сущность данными
  *
  * @param mixed $entity Сущность, которую нужно заполнить
  * @param array $data данные, которыми нужно заполнить сущность. Ключи - имена свойств, значения - значения
  */
 public function fillEntity($entity, array $data)
 {
     $object = new \ReflectionObject($entity);
     foreach ($data as $key => $value) {
         $propertyName = $this->createPropertyName($key);
         if (!$object->hasProperty($propertyName)) {
             continue;
         }
         $property = $object->getProperty($propertyName);
         $property->setAccessible(true);
         $property->setValue($entity, $value);
     }
 }
开发者ID:antonmarin,项目名称:amocrm,代码行数:19,代码来源:ArrayMapper.php

示例12: getPostProcessInstance

 /**
  * @inheritdoc
  */
 public function getPostProcessInstance($postProcessName, array $parameters = [])
 {
     $postProcessClass = 'A7\\PostProcessors\\' . $postProcessName;
     $postProcessObject = new $postProcessClass();
     $postProcessReflectionObject = new \ReflectionObject($postProcessObject);
     if ($postProcessReflectionObject->hasProperty('a7')) {
         $a7Property = $postProcessReflectionObject->getProperty('a7');
         $a7Property->setAccessible(true);
         $a7Property->setValue($postProcessObject, $this->a7);
     }
     if ($postProcessReflectionObject->hasProperty('annotationManager')) {
         $annotationManagerProperty = $postProcessReflectionObject->getProperty('annotationManager');
         $annotationManagerProperty->setAccessible(true);
         $annotationManagerProperty->setValue($postProcessObject, $this->annotationManager);
     }
     if ($postProcessReflectionObject->hasProperty('parameters')) {
         $annotationManagerProperty = $postProcessReflectionObject->getProperty('parameters');
         $annotationManagerProperty->setAccessible(true);
         $annotationManagerProperty->setValue($postProcessObject, $parameters);
     }
     return $postProcessObject;
 }
开发者ID:ArmineKhachatryan,项目名称:A7,代码行数:25,代码来源:PostProcessManager.php

示例13: tryReadOption

 /**
  * {@inheritdoc}
  */
 protected function tryReadOption($name, &$out, $default = null)
 {
     $success = false;
     $name = $this->prefix . $name;
     $out = $default;
     if (!$this->classOrObj) {
         return false;
     }
     if (isset($this->cache[$name]) || array_key_exists($name, $this->cache)) {
         $out = $this->cache[$name];
         $success = true;
     } elseif ($this->reflector->hasProperty($name)) {
         $out = $this->readFromProperty($name);
         $success = true;
         $this->cache[$name] = $out;
     } elseif ($this->reflector->hasMethod($name)) {
         $out = $this->readFromMethod($name);
         $success = true;
         $this->cache[$name] = $out;
     }
     return $success;
 }
开发者ID:bcen,项目名称:silex-dispatcher,代码行数:25,代码来源:DeclarativeResourceOption.php

示例14: assign

 public function assign($document, $object)
 {
     $reflector = new ReflectionObject($object);
     foreach ($document as $name => $value) {
         if ($reflector->hasProperty($name)) {
             $attribute = $reflector->getProperty($name);
             $attribute->setAccessible(TRUE);
             $attribute->setValue($object, $value);
         } else {
             $object->{$name} = $value;
         }
     }
     return $object;
 }
开发者ID:bigjoevtrj,项目名称:codeigniter-bootstrap,代码行数:14,代码来源:documentrepository.php

示例15: hydrate

 /**
  * @param array $data
  * @param $object
  * @return mixed
  */
 public function hydrate(array $data, $object)
 {
     $reflection = new \ReflectionObject($object);
     foreach ($data as $name => $value) {
         $propertyName = $this->namingStrategy ? $this->namingStrategy->convert($name) : $name;
         if ($reflection->hasProperty($propertyName)) {
             $property = $reflection->getProperty($propertyName);
             if ($property->isPublic()) {
                 $property->setValue($object, $value);
             }
         }
     }
     return $object;
 }
开发者ID:vegas-cmf,项目名称:common,代码行数:19,代码来源:Property.php


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