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


PHP ReflectionObject::getStaticProperties方法代码示例

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


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

示例1: getNestedItem

 /**
  * Gets a nested value from an object
  *
  * @param string $pattern
  * @param mixed  $object
  * @param mixed  $default
  * @return mixed|null
  */
 public function getNestedItem($pattern, $object, $default = null)
 {
     $parts = explode("/", $pattern);
     $lastObject = $object;
     $nr = 0;
     $totalParts = count($parts);
     $item = null;
     foreach ($parts as $part) {
         $item = null;
         $nr++;
         $found = false;
         if ($part == '') {
             return $default;
         }
         try {
             if (is_object($lastObject)) {
                 $mthd = 'get' . ucfirst($part);
                 $mthdIs = 'is' . ucfirst($part);
                 if (substr($part, 0, 2) == '::') {
                     $reflect = new \ReflectionObject($lastObject);
                     $props = $reflect->getStaticProperties();
                     $nm = substr($part, 2);
                     if (isset($props[$nm])) {
                         $prop = $reflect->getProperty($nm);
                         if ($prop->isPublic()) {
                             $item = $lastObject::${$nm};
                         }
                     }
                 } elseif (is_callable([$lastObject, $mthd])) {
                     $item = $lastObject->{$mthd}();
                 } elseif (is_callable([$lastObject, $mthdIs])) {
                     $item = $lastObject->{$mthdIs}();
                 } elseif (is_callable([$lastObject, $part])) {
                     $item = $lastObject->{$part}();
                 } else {
                     $reflect = new \ReflectionObject($lastObject);
                     $prop = $reflect->getProperty($part);
                     if ($prop->isPublic()) {
                         $item = $lastObject->{$part};
                     }
                 }
                 $found = true;
             } elseif (is_array($lastObject)) {
                 if (array_key_exists($part, $lastObject)) {
                     $item = $lastObject[$part];
                     $found = true;
                 }
             }
         } catch (\Exception $e) {
             return $default;
         }
         if (!is_null($item) && !is_object($item) && !is_array($item) && $nr < $totalParts || !$found) {
             //its a string,boolean or integer , but we're not at the end of the list so we can't find the end
             return $default;
         }
         $lastObject = $item;
     }
     return $item;
 }
开发者ID:webdevvie,项目名称:nestis,代码行数:67,代码来源:Nestis.php

示例2: toArray

 /**
  * @return array assoc
  */
 public function toArray()
 {
     $ref = new \ReflectionObject($this);
     $props = $ref->getProperties(\ReflectionProperty::IS_PUBLIC);
     $static_props = $ref->getStaticProperties();
     if (empty($static_props) === false) {
         $static_props = array_keys($static_props);
     }
     $arr = [];
     foreach ($props as $prop) {
         $key = $prop->getName();
         if (in_array($key, $static_props)) {
             continue;
         }
         $arr[$key] = $prop->getValue($this);
     }
     return $arr;
 }
开发者ID:reioto,项目名称:form-object,代码行数:21,代码来源:Data.php

示例3: ReflectionObject

<?php

/*
This is a page that displays all stores that the user has defined. It also provides the ability to add new stores or refresh the database tagging of transactions after a new store has been added.
*/
require_once "include_files.php";
$t = new db_cache_tag();
$rt = new ReflectionObject($t);
$tagList = $rt->getStaticProperties();
unset($t);
unset($rt);
$s = new db_cache_store();
$st = new ReflectionObject($s);
$storeList = $st->getStaticProperties();
unset($s);
unset($st);
?>
<!DOCTYPE html>
<html>
	<head>
		<script type="text/javascript" src="fusioncharts-suite/assets/scripts/jquery.min.js"></script>
		<script type="text/javascript" src="jquery-ui-1.11.0.custom/jquery-ui.min.js"></script>
		<link rel="stylesheet" type="text/css" href="jquery-ui-1.11.0.custom/jquery-ui.min.css">
		<script>
			$(function(){
				$( "#dialog-form" ).hide();
				
				//initialize form
				resetForm();
			});
			
开发者ID:emadmessiha,项目名称:expenseTracker,代码行数:30,代码来源:stores.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


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