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


PHP ReflectionClass::getShortname方法代码示例

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


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

示例1: arrayValuesCheck

 /**
  * Simple test to see if array values are of specified type.
  *
  * @param  array $array Array of values.
  * @param  string $type Type to check
  * @param  string $className Named class, if type == 'class'
  * @return boolean Returns true is all values match type, otherwise false.
  */
 public static function arrayValuesCheck($array, $type, $className = '')
 {
     $status = true;
     if (is_array($array) && is_string($type)) {
         if ($type === 'class' && is_string($className) && !empty($className)) {
             foreach ($array as $item) {
                 if (!is_null($item)) {
                     if (!is_object($item)) {
                         $status = false;
                     } else {
                         $class = new \ReflectionClass($item);
                         if (!preg_match("/{$className}/", $class->getShortname())) {
                             $status = false;
                         }
                     }
                 }
             }
         } else {
             foreach ($array as $item) {
                 $function = 'is_' . $type;
                 if (function_exists($function)) {
                     if ($function($item) === false) {
                         $status = false;
                     }
                 } else {
                     $status = false;
                 }
             }
         }
     } else {
         $status = false;
     }
     return $status;
 }
开发者ID:tahertechs,项目名称:lavacharts,代码行数:42,代码来源:Utils.php

示例2: normalize

 /**
  * {@inheritdoc}
  */
 public function normalize($violationList, $format = null, array $context = [])
 {
     if ($violationList instanceof \Exception) {
         if ($this->debug) {
             $trace = $violationList->getTrace();
         }
     }
     $data = ['@context' => '/api/contexts/ConstraintViolationList', '@type' => 'ConstraintViolationList', 'title' => 'An error occurred', 'violations' => []];
     foreach ($violationList as $violation) {
         $key = $violation->getPropertyPath();
         $invalidValue = $violation->getInvalidValue();
         if (method_exists($violation->getRoot(), '__toString')) {
             $invalidValue = $this->propertyAccessor->getValue($violation->getRoot(), $violation->getPropertyPath());
         }
         if ($violation->getConstraint() instanceof UniqueEntity) {
             $class = method_exists($violation->getRoot(), 'getConfig') ? $violation->getRoot()->getConfig() : $violation->getRoot();
             $reflexion = new \ReflectionClass($class);
             $key = strtolower($reflexion->getShortname());
         }
         $data['violations'][$key][] = ['property' => $violation->getPropertyPath(), 'invalidValue' => $invalidValue, 'message' => $violation->getMessage()];
     }
     if (isset($trace)) {
         $data['trace'] = $trace;
     }
     return $data;
 }
开发者ID:eliberty,项目名称:api-bundle,代码行数:29,代码来源:ErrorViolationListNormalizer.php

示例3: __construct

 /**
  * Builds the ConfigOptions object.
  *
  * Passing an array of key value pairs will set the configuration for each
  * child object created from this parent object.
  *
  * @param  mixed                 $child  Child ConfigOption object.
  * @param  array                 $config Array of options.
  * @throws InvalidConfigValue
  * @throws InvalidConfigProperty
  * @return mixed
  */
 public function __construct($child, $config)
 {
     $class = new \ReflectionClass($child);
     $this->type = $class->getShortname();
     $this->options = array_map(function ($prop) {
         return $prop->name;
     }, $class->getProperties(\ReflectionProperty::IS_PUBLIC));
     if (is_array($config)) {
         foreach ($config as $option => $value) {
             if (in_array($option, $this->options)) {
                 $this->{$option}($value);
             } else {
                 throw new InvalidConfigProperty($this->type, __FUNCTION__, $option, $this->options);
             }
         }
     } else {
         throw new InvalidConfigValue(__FUNCTION__, 'array', 'with valid keys as ' . Utils::arrayToPipedString($this->options));
     }
 }
开发者ID:alienwizard,项目名称:MediahelpCRM_local,代码行数:31,代码来源:Format.php


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