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


PHP Reflection::getModifierNames方法代码示例

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


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

示例1: __construct

 /**
  * Loads a class and uses [reflection](http://php.net/reflection) to parse
  * the class. Reads the class modifiers, constants and comment. Parses the
  * comment to find the description and tags.
  *
  * @param   string   class name
  * @return  void
  */
 public function __construct($class)
 {
     $this->class = new ReflectionClass($class);
     if ($modifiers = $this->class->getModifiers()) {
         $this->modifiers = '<small>' . implode(' ', Reflection::getModifierNames($modifiers)) . '</small> ';
     }
     if ($constants = $this->class->getConstants()) {
         foreach ($constants as $name => $value) {
             $this->constants[$name] = Kohana::debug($value);
         }
     }
     $parent = $this->class;
     do {
         if ($comment = $parent->getDocComment()) {
             // Found a description for this class
             break;
         }
     } while ($parent = $parent->getParentClass());
     list($this->description, $this->tags) = Kodoc::parse($comment);
     // If this class extends Kodoc_Missing, add a warning about possible
     // incomplete documentation
     $parent = $this->class;
     while ($parent = $parent->getParentClass()) {
         if ($parent->name == 'Kodoc_Missing') {
             $warning = "[!!] **This class, or a class parent, could not be\n\t\t\t\t           found or loaded. This could be caused by a missing\n\t\t\t\t\t\t   module or other dependancy. The documentation for\n\t\t\t\t\t\t   class may not be complete!**";
             $this->description = Markdown($warning) . $this->description;
         }
     }
 }
开发者ID:azuya,项目名称:Wi3,代码行数:37,代码来源:class.php

示例2: writeMethod

 public function writeMethod(\ReflectionMethod $method)
 {
     $args = [];
     foreach ($method->getParameters() as $parameter) {
         $arg = '';
         if ($parameter->isArray()) {
             $arg .= 'array ';
         } else {
             if ($parameter->getClass()) {
                 $arg .= '\\' . $parameter->getClass()->getName() . ' ';
             }
         }
         if ($parameter->isPassedByReference()) {
             $arg .= '&';
         }
         $arg .= '$' . $parameter->getName();
         try {
             $defaultValue = $parameter->getDefaultValue();
             $arg .= ' = ' . var_export($defaultValue, true);
         } catch (ReflectionException $e) {
             if ($parameter->isOptional()) {
                 $arg .= ' = null';
             }
         }
         $args[] = $arg;
     }
     $modifiers = array_diff(\Reflection::getModifierNames($method->getModifiers()), ['abstract']);
     $methodName = ($method->returnsReference() ? '&' : '') . $method->getName();
     $this->code[] = '  ' . implode(' ', $modifiers) . ' function ' . $methodName . '(' . implode(', ', $args) . ') {';
     $this->code[] = '    $result = $this->' . $this->propertyName . '->invoke($this, \'' . $method->getName() . '\', func_get_args());';
     $this->code[] = '    return $result;';
     $this->code[] = '  }';
 }
开发者ID:crashuxx,项目名称:phproxy,代码行数:33,代码来源:DefaultBuilder.php

示例3: __construct

 /**
  * undocumented function
  *
  * @return  void
  * @author  Neil Brayfield
  **/
 public function __construct($class)
 {
     $this->class = new \ReflectionClass($class);
     $this->name = str_replace($this->class->getNamespaceName() . '\\', '', $this->class->name);
     if ($modifiers = $this->class->getModifiers()) {
         $this->modifiers = implode(' ', \Reflection::getModifierNames($modifiers)) . ' ';
     }
     $this->constants = $this->class->getConstants();
     // If ReflectionClass::getParentClass() won't work if the class in
     // question is an interface
     if ($this->class->isInterface()) {
         $this->parents = $this->class->getInterfaces();
     } else {
         $parent = $this->class;
         while ($parent = $parent->getParentClass()) {
             $this->parents[] = $parent;
         }
     }
     if (!($comment = $this->class->getDocComment())) {
         foreach ($this->parents as $parent) {
             if ($comment = $parent->getDocComment()) {
                 // Found a description for this class
                 break;
             }
         }
     }
     list($this->description, $this->tags) = $this->userguide->parse($comment);
 }
开发者ID:braf,项目名称:phalcana-userguide,代码行数:34,代码来源:DocClass.php

示例4: __construct

 public function __construct($class, $property, $default = null)
 {
     $property = new \ReflectionProperty($class, $property);
     list($description, $tags) = $this->userguide->parse($property->getDocComment());
     $this->description = $description;
     if ($modifiers = $property->getModifiers()) {
         $this->modifiers = '<small>' . implode(' ', \Reflection::getModifierNames($modifiers)) . '</small> ';
     }
     if (isset($tags['var'])) {
         if (preg_match('/^(\\S*)(?:\\s*(.+?))?$/s', $tags['var'][0], $matches)) {
             $this->type = $matches[1];
             if (isset($matches[2])) {
                 $this->description = $this->markdown->transform($matches[2]);
             }
         }
     }
     $this->property = $property;
     // Show the value of static properties, but only if they are public or we are php 5.3 or
     // higher and can force them to be accessible
     if ($property->isStatic()) {
         $property->setAccessible(true);
         // Don't debug the entire object, just say what kind of object it is
         if (is_object($property->getValue($class))) {
             $this->value = '<pre>object ' . get_class($property->getValue($class)) . '()</pre>';
         } else {
             $this->value = Debug::vars($property->getValue($class));
         }
     }
     // Store the defult property
     $this->default = Debug::vars($default);
 }
开发者ID:braf,项目名称:phalcana-userguide,代码行数:31,代码来源:DocProperty.php

示例5: __construct

 /**
  * Loads a class and uses [reflection](http://php.net/reflection) to parse
  * the class. Reads the class modifiers, constants and comment. Parses the
  * comment to find the description and tags.
  *
  * @param   string  Class name
  * @return  void
  */
 public function __construct($class)
 {
     $this->class = new ReflectionClass($class);
     if ($modifiers = $this->class->getModifiers()) {
         $this->modifiers = '<small>' . implode(' ', Reflection::getModifierNames($modifiers)) . '</small> ';
     }
     $this->constants = $this->class->getConstants();
     // If ReflectionClass::getParentClass() won't work if the class in
     // question is an interface
     if ($this->class->isInterface()) {
         $this->parents = $this->class->getInterfaces();
     } else {
         $parent = $this->class;
         while ($parent = $parent->getParentClass()) {
             $this->parents[] = $parent;
         }
     }
     if (!($comment = $this->class->getDocComment())) {
         foreach ($this->parents as $parent) {
             if ($comment = $parent->getDocComment()) {
                 // Found a description for this class
                 break;
             }
         }
     }
     list($this->description, $this->tags) = Kodoc::parse($comment, FALSE);
 }
开发者ID:robert-kampas,项目名称:games-collection-manager,代码行数:35,代码来源:Class.php

示例6: dump_methodModifierNames

function dump_methodModifierNames($class)
{
    $obj = new ReflectionClass($class);
    foreach ($obj->getMethods() as $method) {
        var_dump($obj->getName() . "::" . $method->getName(), Reflection::getModifierNames($method->getModifiers()));
    }
}
开发者ID:badlamer,项目名称:hhvm,代码行数:7,代码来源:ReflectionClass_getModifierNames_basic.php

示例7: inspect

 /**
  * {@inheritdoc}
  *
  * @see \Contrib\Component\Inspector\ObjectInspectorInterface::inspect()
  */
 public function inspect()
 {
     $methodList = static::sortByModifier($this->methods);
     foreach ($methodList as $modifiers) {
         foreach ($modifiers as $method) {
             $methodName = $method->getName();
             if ($method->returnsReference()) {
                 $this->inspection[$methodName]['name'] = $this->referenceIndicator . $methodName;
             } else {
                 $this->inspection[$methodName]['name'] = $methodName;
             }
             $this->inspection[$methodName]['modifier'] = implode(' ', \Reflection::getModifierNames($method->getModifiers()));
             $params = $method->getParameters();
             if (!empty($params)) {
                 $this->inspection[$methodName] = array_merge($this->inspection[$methodName], $this->getParametersInspection($params));
             }
             if ($this->isInheritMethod($method, $declaringClass)) {
                 $this->inspection[$methodName]['inherit'] = $this->getInheritanceInspection($declaringClass);
             } elseif ($this->isImplementMethod($method, $declaringClass)) {
                 $this->inspection[$methodName]['implement'] = $this->getInheritanceInspection($declaringClass);
             } elseif ($this->isOverrideMethod($method, $declaringClass)) {
                 $this->inspection[$methodName]['override'] = $this->getInheritanceInspection($declaringClass);
             }
         }
     }
     $this->inspection = static::sortByInheritance($this->inspection);
 }
开发者ID:satooshi,项目名称:object-inspector,代码行数:32,代码来源:ObjectMethodInspector.php

示例8: __construct

 public function __construct($class, $property)
 {
     $property = new ReflectionProperty($class, $property);
     list($description, $tags) = Kodoc::parse($property->getDocComment());
     $this->description = $description;
     if ($modifiers = $property->getModifiers()) {
         $this->modifiers = '<small>' . implode(' ', Reflection::getModifierNames($modifiers)) . '</small> ';
     }
     if (isset($tags['var'])) {
         if (preg_match('/^(\\S*)(?:\\s*(.+?))?$/', $tags['var'][0], $matches)) {
             $this->type = $matches[1];
             if (isset($matches[2])) {
                 $this->description = Markdown($matches[2]);
             }
         }
     }
     $this->property = $property;
     // Show the value of static properties, but only if they are public or we are php 5.3 or higher and can force them to be accessible
     if ($property->isStatic() and ($property->isPublic() or version_compare(PHP_VERSION, '5.3', '>='))) {
         // Force the property to be accessible
         if (version_compare(PHP_VERSION, '5.3', '>=')) {
             $property->setAccessible(TRUE);
         }
         // Don't debug the entire object, just say what kind of object it is
         if (is_object($property->getValue($class))) {
             $this->value = '<pre>object ' . get_class($property->getValue($class)) . '()</pre>';
         } else {
             $this->value = Kohana::debug($property->getValue($class));
         }
     }
 }
开发者ID:azuya,项目名称:Wi3,代码行数:31,代码来源:property.php

示例9: m

function m($m)
{
    $n = "";
    foreach (Reflection::getModifierNames($m) as $mn) {
        $n .= $mn . " ";
    }
    return $n;
}
开发者ID:gzysuzhou,项目名称:ext-http,代码行数:8,代码来源:gen_stubs.php

示例10: exportCode

 /**
  * Exports the PHP code
  *
  * @return string
  */
 public function exportCode()
 {
     $modifiers = \Reflection::getModifierNames($this->_method->getModifiers());
     $params = array();
     // Export method's parameters
     foreach ($this->_method->getParameters() as $param) {
         $reflection_parameter = new ReflectionParameter($param);
         $params[] = $reflection_parameter->exportCode();
     }
     return sprintf('%s function %s(%s) {}', join(' ', $modifiers), $this->_method->getName(), join(', ', $params));
 }
开发者ID:michalkoslab,项目名称:Helpers,代码行数:16,代码来源:ReflectionMethod.php

示例11: exportCode

 /**
  * Exports the PHP code
  *
  * @return string
  */
 public function exportCode()
 {
     $default_properties = $this->_property->getDeclaringClass()->getDefaultProperties();
     $modifiers = \Reflection::getModifierNames($this->_property->getModifiers());
     $default_value = null;
     if (array_key_exists($this->_property->getName(), $default_properties)) {
         $default_value = $default_properties[$this->_property->getName()];
         if (!is_numeric($default_value)) {
             $default_value = "'{$default_value}'";
         }
     }
     return sprintf('%s $%s%s;', join(' ', $modifiers), $this->_property->getName(), !is_null($default_value) ? " = {$default_value}" : '');
 }
开发者ID:michalkoslab,项目名称:Helpers,代码行数:18,代码来源:ReflectionProperty.php

示例12: __construct

 public function __construct($class, $method)
 {
     $this->method = new ReflectionMethod($class, $method);
     $this->class = $parent = $this->method->getDeclaringClass();
     if ($modifiers = $this->method->getModifiers()) {
         $this->modifiers = '<small>' . implode(' ', Reflection::getModifierNames($modifiers)) . '</small> ';
     }
     do {
         if ($parent->hasMethod($method) and $comment = $parent->getMethod($method)->getDocComment()) {
             // Found a description for this method
             break;
         }
     } while ($parent = $parent->getParentClass());
     list($this->description, $tags) = Kodoc::parse($comment);
     if ($file = $this->class->getFileName()) {
         $this->source = Kodoc::source($file, $this->method->getStartLine(), $this->method->getEndLine());
     }
     if (isset($tags['param'])) {
         $params = array();
         foreach ($this->method->getParameters() as $i => $param) {
             if (isset($tags['param'][$i])) {
                 if ($param->isDefaultValueAvailable()) {
                     $name = $param->name . ' = ' . var_export($param->getDefaultValue(), TRUE);
                 } else {
                     $name = $param->name;
                 }
                 preg_match('/^(\\S+)(?:\\s*(.+))?$/', $tags['param'][$i], $matches);
                 $verbose = '<small>' . $matches[1] . '</small> ';
                 if (isset($matches[2])) {
                     $verbose .= '<span class="param" title="' . $matches[2] . '">$' . $name . '</span>';
                 } else {
                     $verbose .= '<span class="param">$' . $name . '</span>';
                 }
                 $params[] = $verbose;
             }
         }
         $this->params = implode(', ', $params);
         unset($tags['param']);
     }
     if (isset($tags['return'])) {
         foreach ($tags['return'] as $return) {
             if (preg_match('/^(\\S*)(?:\\s*(.+?))?$/', $return, $matches)) {
                 $this->return[] = array($matches[1], isset($matches[2]) ? $matches[2] : '');
             }
         }
         unset($tags['return']);
     }
     $this->tags = $tags;
 }
开发者ID:sentry360,项目名称:userguide,代码行数:49,代码来源:method.php

示例13: __construct

 public function __construct($class, $property)
 {
     $property = new ReflectionProperty($class, $property);
     list($description, $tags) = self::parse($property->getDocComment());
     $this->data['title'] = $description[0];
     $this->data['description'] = trim(implode("\n", $description));
     if ($modifiers = $property->getModifiers()) {
         $this->data['modifiers'] = implode(' ', Reflection::getModifierNames($modifiers));
     } else {
         $this->data['modifiers'] = 'public';
     }
     if (isset($tags['var'])) {
         if (preg_match('/^(\\S*)(?:\\s*(.+?))?$/', $tags['var'][0], $matches)) {
             $this->data['type'] = $matches[1];
             if (isset($matches[2])) {
                 $this->data['description'] = array($matches[2]);
             }
         }
     }
     $this->data['name'] = $property->name;
     $this->data['class_name'] = $property->class;
     $this->data['is_static'] = $property->isStatic();
     $this->data['is_public'] = $property->isPublic();
     $class_rf = $property->getDeclaringClass();
     if ($property->class != $class) {
         $this->data['is_php_class'] = $class_rf->getStartLine() ? 0 : 1;
     } else {
         $this->data['is_php_class'] = false;
     }
     $have_value = false;
     if ($property->isStatic()) {
         $v = $class_rf->getStaticProperties();
         if (isset($v[$property->name])) {
             $value = $v[$property->name];
             $have_value = true;
         }
     } else {
         if (!$property->isPrivate()) {
             if (!$class_rf->isFinal() && !$class_rf->isAbstract()) {
                 $value = self::getValue($class, $property->name);
                 $have_value = true;
             }
         }
     }
     if ($have_value) {
         $this->data['value'] = self::dump($value);
         $this->data['value_serialized'] = serialize($value);
     }
 }
开发者ID:xiaodin1,项目名称:myqee,代码行数:49,代码来源:docs_roperty.php

示例14: __toString

 /**
  * Returns the string representation of the Reflection method object.
  *
  * @link http://php.net/manual/en/reflectionmethod.tostring.php
  *
  * @return string
  */
 public function __toString()
 {
     $paramFormat = $this->getNumberOfParameters() > 0 ? "\n\n  - Parameters [%d] {%s\n  }" : '';
     $methodParameters = $this->getParameters();
     try {
         $prototype = $this->getPrototype();
     } catch (\ReflectionException $e) {
         $prototype = null;
     }
     $prototypeClass = $prototype ? $prototype->getDeclaringClass()->name : '';
     $paramString = '';
     $identation = str_repeat(' ', 4);
     foreach ($methodParameters as $methodParameter) {
         $paramString .= "\n{$identation}" . $methodParameter;
     }
     return sprintf("%sMethod [ <user%s%s%s>%s%s%s %s method %s ] {\n  @@ %s %d - %d{$paramFormat}\n}\n", $this->getDocComment() ? $this->getDocComment() . "\n" : '', $prototype ? ", overwrites {$prototypeClass}, prototype {$prototypeClass}" : '', $this->isConstructor() ? ', ctor' : '', $this->isDestructor() ? ', dtor' : '', $this->isFinal() ? ' final' : '', $this->isStatic() ? ' static' : '', $this->isAbstract() ? ' abstract' : '', join(' ', \Reflection::getModifierNames($this->getModifiers() & 1792)), $this->getName(), $this->getFileName(), $this->getStartLine(), $this->getEndLine(), count($methodParameters), $paramString);
 }
开发者ID:console-helpers,项目名称:parser-reflection,代码行数:24,代码来源:ReflectionMethod.php

示例15: __construct

 public function __construct($class, $method)
 {
     $method = new ReflectionMethod($class, $method);
     $this->name = $method->name;
     $class = $parent = $method->getDeclaringClass();
     if ($modifiers = $method->getModifiers()) {
         $this->modifiers = '<small>' . implode(' ', Reflection::getModifierNames($modifiers)) . '</small> ';
     }
     $comment = '';
     do {
         if ($parent->hasMethod($this->name)) {
             $comment = $parent->getMethod($this->name)->getDocComment();
             // Found a description for this method
             break;
         }
     } while ($parent = $parent->getParentClass());
     list($this->description, $tags) = Kodoc::parse($comment);
     if ($file = $class->getFileName()) {
         $this->source = Kodoc::source($file, $method->getStartLine(), $method->getEndLine());
     }
     if (isset($tags['param'])) {
         $params = array();
         foreach ($method->getParameters() as $i => $param) {
             $param = new Kodoc_Method_Param(array($method->class, $method->name), $i);
             if (isset($tags['param'][$i])) {
                 if (preg_match('/^(\\S*)\\s*(\\$\\w+)?(?:\\s*(.+?))?$/', $tags['param'][$i], $matches)) {
                     $param->type = $matches[1];
                     $param->description = arr::get($matches, 3);
                 }
             }
             $params[] = $param;
         }
         $this->params = $params;
         unset($tags['param']);
     }
     if (isset($tags['return'])) {
         foreach ($tags['return'] as $return) {
             if (preg_match('/^(\\S*)(?:\\s*(.+?))?$/', $return, $matches)) {
                 $this->return[] = array($matches[1], isset($matches[2]) ? $matches[2] : '');
             }
         }
         unset($tags['return']);
     }
     $this->tags = $tags;
 }
开发者ID:JamesKnott,项目名称:kohana24-userguide,代码行数:45,代码来源:Kodoc_Method.php


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