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


PHP ReflectionObject::getDefaultProperties方法代码示例

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


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

示例1: mergeObject

 /**
  * Deep-merge the source object over the destination object and return the results.
  *
  * @param object $destinationObject
  * @param object $sourceObject
  *
  * @return object
  */
 private function mergeObject($destinationObject, $sourceObject)
 {
     $reflectedDestination = new \ReflectionObject($destinationObject);
     $reflectedSource = new \ReflectionObject($sourceObject);
     $defaultPropertyValues = $reflectedDestination->getDefaultProperties();
     foreach ($reflectedSource->getProperties() as $sourceProperty) {
         $destinationObject = $this->mergeProperty($destinationObject, $reflectedDestination->getProperty($sourceProperty->getName()), $sourceObject, $sourceProperty, $defaultPropertyValues);
     }
     return $destinationObject;
 }
开发者ID:crazycodr,项目名称:phpDocumentor2,代码行数:18,代码来源:Merger.php

示例2: cleanupContainer

 /**
  * Remove all container references from all loaded services
  *
  * @param ContainerInterface $container
  */
 protected function cleanupContainer(ContainerInterface $container)
 {
     $containerReflection = new \ReflectionObject($container);
     $containerServicesPropertyReflection = $containerReflection->getProperty('services');
     $containerServicesPropertyReflection->setAccessible(true);
     $services = $containerServicesPropertyReflection->getValue($container) ?: [];
     foreach ($services as $serviceId => $service) {
         if ('kernel' === $serviceId) {
             continue;
         }
         $serviceReflection = new \ReflectionObject($service);
         $servicePropertiesReflections = $serviceReflection->getProperties();
         $servicePropertiesDefaultValues = $serviceReflection->getDefaultProperties();
         foreach ($servicePropertiesReflections as $servicePropertyReflection) {
             $defaultPropertyValue = null;
             if (isset($servicePropertiesDefaultValues[$servicePropertyReflection->getName()])) {
                 $defaultPropertyValue = $servicePropertiesDefaultValues[$servicePropertyReflection->getName()];
             }
             $servicePropertyReflection->setAccessible(true);
             $servicePropertyReflection->setValue($service, $defaultPropertyValue);
         }
     }
     $containerServicesPropertyReflection->setValue($container, null);
 }
开发者ID:lingoda,项目名称:Sylius,代码行数:29,代码来源:TestKernel.php

示例3: _reflectionProperties

 private function _reflectionProperties(\ReflectionObject $reflection, $data)
 {
     $cache = [];
     $properties = $reflection->getProperties();
     $default_properties = $reflection->getDefaultProperties();
     foreach ($properties as $property) {
         $visibility = null;
         if ($property->isPrivate()) {
             $visibility = 'private';
         } elseif ($property->isProtected()) {
             $visibility = 'protected';
         } elseif ($property->isPublic()) {
             $visibility = 'public';
         }
         if ($property->isStatic()) {
             $visibility .= ' static';
         }
         $name = $property->getName();
         if ($property->isPrivate() || $property->isProtected()) {
             $property->setAccessible(true);
         }
         $value = $property->getValue($data);
         // additional information about this property
         // gets appended after the name
         $info_flgs = [];
         $is_default_property = $property->isDefault();
         if ($is_default_property && $value == $default_properties[$name]) {
             $info_flgs[] = '<span class="d-obj-icon d-obj-prop-default-val" title="This is the Property\'s Default Value"></span>';
         }
         if (!$is_default_property) {
             $info_flgs[] = '<span class="d-obj-icon d-obj-prop-added" title="This Property Was Added Dynamically"></span>';
         }
         $display_name = '<span class="d-visibility">' . $visibility . '</span>&nbsp;' . $name . (count($info_flgs) ? implode('', $info_flgs) : '');
         $cache[$display_name] = $value;
         if ($property->isPrivate() || $property->isProtected()) {
             $property->setAccessible(false);
         }
     }
     $name = '<span class="d-information" title="Properties in this object (includes inherited and dynamically added)"></span>&nbsp;';
     $name .= '<span class="d-obj-info">Properties</span>';
     $this->render($cache, $name);
 }
开发者ID:aronduby,项目名称:dump,代码行数:42,代码来源:ump.php

示例4: buildFromObject

 /**
  * @param $param
  * @param \ReflectionObject $reflection
  */
 private function buildFromObject($param, $reflection = null)
 {
     foreach ($param as $key => $value) {
         $this->object['Object default'][$key] = $value;
     }
     // Get info on the object
     $this->object['Reflection']['In namespace'] = $reflection->inNamespace() ? 'Yes' : 'No';
     if ($reflection->inNamespace()) {
         $this->object['Class namespace'] = $reflection->getNamespaceName();
     }
     $this->object['Reflection']['Class name'] = $reflection->getName();
     $this->object['Reflection']['Is internal'] = $reflection->isInternal() ? 'Yes' : 'No';
     $this->object['Reflection']['Is iterable'] = $reflection->isIterateable() ? 'Yes' : 'No';
     $this->object['Reflection']['Is abstract'] = $reflection->isAbstract() ? 'Yes' : 'No';
     $this->object['Reflection']['Is final'] = $reflection->isFinal() ? 'Yes' : 'No';
     $this->object['Reflection']['Is user defined'] = $reflection->isUserDefined() ? 'Yes' : 'No';
     $this->object['Reflection']['Is instantiable'] = $reflection->isInstantiable() ? 'Yes' : 'No';
     $this->object['Reflection']['Is clonable'] = $reflection->isCloneable() ? 'Yes' : 'No';
     $this->object['Reflection']['Is interface'] = $reflection->isInterface() ? 'Yes' : 'No';
     $this->object['Reflection']['Class constants'] = !empty($reflection->getConstants()) ? $reflection->getConstants() : 'Class has no constants';
     $this->object['Reflection']['Class static properties'] = !empty($reflection->getStaticProperties()) ? $reflection->getStaticProperties() : 'Class has no static properties';
     $this->object['Reflection']['Class default properties'] = !empty($reflection->getDefaultProperties()) ? $reflection->getDefaultProperties() : 'Class has no default properties';
     if (null === $reflection->getConstructor()) {
         $this->object['Reflection']['Class construct'] = 'Class has no construct.';
     } else {
         $this->object['Reflection']['Class construct'] = $reflection->getConstructor();
     }
     $this->object['Reflection']['Class interfaces'] = !empty($reflection->getInterfaces()) ? $reflection->getInterfaces() : 'Class implements no interfaces';
     $this->object['Reflection']['Class traits'] = !empty($reflection->getTraits()) ? $reflection->getTraits() : 'Class has no traits';
     $this->object['Reflection']['Class parent'] = $reflection->getParentClass() !== false ? $reflection->getParentClass() : 'Class has no parent';
     if (false === $reflection->getFileName()) {
         $this->object['Reflection']['Defined in'] = 'Class is internal, no definition to provide.';
     } else {
         $this->object['Reflection']['Defined in'] = $reflection->getFileName();
     }
     if (false === $reflection->getFileName()) {
         $this->object['Reflection']['Start line'] = 'Class is internal, no start line to provide.';
     } else {
         $this->object['Reflection']['Start line'] = $reflection->getFileName();
     }
     if (false === $reflection->getEndLine()) {
         $this->object['Reflection']['End line'] = 'Class is internal, no end line to provide.';
     } else {
         $this->object['Reflection']['End line'] = $reflection->getEndLine();
     }
     if (false === $reflection->getDocComment()) {
         $this->object['Reflection']['Doc comments'] = 'No documents to provide.';
     } else {
         $this->object['Reflection']['Doc comments'] = $reflection->getDocComment();
     }
     // End get info
     $this->html .= "<span class=\"js-parent-object\">";
     if (!empty($this->object['Object default'])) {
         $this->html .= "<div class=\"js-object-default-tab \"><button class=\"button-reflection button\">Show reflection</button></div>";
         $this->html .= "<div class=\"js-object-default \">";
         $this->buildFromObjectIterationInformationRecursive($this->object['Object default']);
         $this->html .= "</div>";
     }
     if ($param instanceof \Closure) {
         $this->html .= "<div class=\"js-object-default-tab \"><button class=\"button-reflection button\">Show reflection</button></div>";
         $this->html .= "<div class=\"js-object-default \">";
         $this->html .= "<span class=\"css-type-string\">Nothing here...</span>";
         $this->html .= "</div>";
     }
     $this->html .= "<div class=\"js-object-reflection-tab hide\"><button class=\"button-class-default button\">Show default</button></div>";
     $this->html .= "<div class=\"js-object-reflection hide\">";
     $this->buildFromObjectReflectionInformationRecursive($this->object['Reflection']);
     $this->html .= "</div>";
     $this->html .= "</span>";
     $this->object = [];
 }
开发者ID:junky-pic,项目名称:php-pretty-print,代码行数:75,代码来源:HtmlBuilder.php

示例5: setData

 public function setData($data)
 {
     $reflection = new ReflectionObject($this);
     $default_properties = $reflection->getDefaultProperties();
     if (!$this->hasData($this->form_id)) {
         $_SESSION['appointment_booking'][$this->form_id] = array();
     }
     foreach ($reflection->getProperties() as $reflectionProperty) {
         $field_name = $reflectionProperty->getName();
         if (isset($data[$field_name])) {
             $_SESSION['appointment_booking'][$this->form_id][$field_name] = $data[$field_name];
             // overwrite to default property only if there are no property or it's empty
         } elseif (!isset($_SESSION['appointment_booking'][$this->form_id][$field_name]) || empty($_SESSION['appointment_booking'][$this->form_id][$field_name])) {
             $_SESSION['appointment_booking'][$this->form_id][$field_name] = $default_properties[$field_name];
         }
     }
 }
开发者ID:VLabsInc,项目名称:WordPressPlatforms,代码行数:17,代码来源:AB_UserBookingData.php

示例6: getAdminPhpGenerator

 /**
  * @param string $domain
  * @return ActionGenerator 
  */
 public function getAdminPhpGenerator(\Symforce\AdminBundle\Compiler\MetaType\Admin\Entity $admin)
 {
     $_key = 'admin.' . $admin->name;
     if (isset($this->cached_generators[$_key])) {
         return $this->cached_generators[$_key];
     }
     $class = new \Symforce\AdminBundle\Compiler\Generator\PhpClass();
     $rc = new \ReflectionObject($admin);
     $default_properties = $rc->getDefaultProperties();
     if ($default_properties['parent_class_name'] === $admin->parent_class_name) {
         $parent_name = preg_replace('/\\\\Entity\\\\(\\w+)$/', '\\\\Admin\\\\\\1Admin', $admin->class_name);
         if (class_exists($parent_name)) {
             if (!is_subclass_of($parent_name, "\\Symforce\\AdminBundle\\Compiler\\Cache\\AdminCache")) {
                 throw new \Exception(sprintf("%s admin class %s exists, but not extends from Symforce\\AdminBundle\\Compiler\\Cache\\AdminCache", $admin->class_name, $parent_name));
             }
             $admin->parent_class_name = $parent_name;
         }
     }
     $this->admin_unmaps[$admin->_compile_class_name] = $admin->class_name;
     if ('Symforce\\AdminBundle\\Compiler\\Cache\\AdminCache' !== $admin->parent_class_name) {
         if (isset($this->admin_unmaps[$admin->parent_class_name])) {
             throw new \Exception(sprintf("%s,%s,%s", $admin->parent_class_name, $this->admin_unmaps[$admin->parent_class_name], $admin->class_name));
         }
         $this->admin_unmaps[$admin->parent_class_name] = $admin->class_name;
     }
     $class->setName($admin->_compile_class_name)->setParentClassName('\\' . $admin->parent_class_name)->setFinal(true);
     // $class->addUseStatement('Symfony\Component\Validator\Constraints', 'Assert') ;
     // $class->addUseStatement('Symfony\Bridge\Doctrine\Validator\Constraints', 'DoctrineAssert') ;
     $this->cached_generators[$_key] = $class;
     return $class;
 }
开发者ID:symforce,项目名称:symforce-admin,代码行数:35,代码来源:Generator.php


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