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


PHP ReflectionClass::getModifiers方法代码示例

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


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

示例1: inspectModifier

 /**
  * Inspect modifier.
  *
  * @return void
  */
 protected function inspectModifier()
 {
     $modifiers = \Reflection::getModifierNames($this->class->getModifiers());
     if (!empty($modifiers)) {
         $this->inspection['modifier'] = implode(' ', $modifiers);
     }
 }
开发者ID:satooshi,项目名称:object-inspector,代码行数:12,代码来源:ObjectTypeInspector.php

示例2: castClass

    public static function castClass(\ReflectionClass $c, array $a, Stub $stub, $isNested, $filter = 0)
    {
        $prefix = Caster::PREFIX_VIRTUAL;

        if ($n = \Reflection::getModifierNames($c->getModifiers())) {
            $a[$prefix.'modifiers'] = implode(' ', $n);
        }

        self::addMap($a, $c, array(
            'extends' => 'getParentClass',
            'implements' => 'getInterfaceNames',
            'constants' => 'getConstants',
        ));

        foreach ($c->getProperties() as $n) {
            $a[$prefix.'properties'][$n->name] = $n;
        }

        foreach ($c->getMethods() as $n) {
            $a[$prefix.'methods'][$n->name] = $n;
        }

        if (!($filter & Caster::EXCLUDE_VERBOSE) && !$isNested) {
            self::addExtra($a, $c);
        }

        return $a;
    }
开发者ID:ninvfeng,项目名称:symfony,代码行数:28,代码来源:ReflectionCaster.php

示例3: testGetModifiers

 /**
  * Tests getModifier() method
  * NB: value is masked because there are many internal constants that aren't exported in the userland
  *
  * @dataProvider listOfClasses55
  *
  * @param string $className Class name to test
  */
 public function testGetModifiers($className)
 {
     $mask = \ReflectionClass::IS_EXPLICIT_ABSTRACT + \ReflectionClass::IS_FINAL + \ReflectionClass::IS_IMPLICIT_ABSTRACT;
     $parsedRefClass = $this->parsedRefFileNamespace->getClass($className);
     $originalRefClass = new \ReflectionClass($className);
     $parsedModifiers = $parsedRefClass->getModifiers() & $mask;
     $originalModifiers = $originalRefClass->getModifiers() & $mask;
     $this->assertEquals($originalModifiers, $parsedModifiers);
 }
开发者ID:goaop,项目名称:parser-reflection,代码行数:17,代码来源:ReflectionClassTest.php

示例4: ReflectionClass

<?php

trait T
{
}
$r = new ReflectionClass('T');
var_dump(Reflection::getModifierNames($r->getModifiers()));
var_dump($r->isAbstract());
var_dump($r->isInstantiable());
var_dump($r->isCloneable());
开发者ID:gleamingthecube,项目名称:php,代码行数:10,代码来源:ext_reflection_reflectionclass_for_traits.php

示例5: count

{
    const START = 0;
    private static $c = Counter::START;
    /**
     * Invoke counter
     *
     * @access public
     * @return int
     */
    public function count()
    {
        return self::$c++;
    }
}
$class = new ReflectionClass('Counter');
printf("===> The %s%s%s %s '%s' [extends %s]" . " declared in %s" . " lines %d to %d" . " having the modifiers %d [%s]<br/>", $class->isInternal() ? 'internal' : 'user-defined', $class->isAbstract() ? ' abstract' : '', $class->isFinal() ? ' final' : '', $class->isInterface() ? 'interface' : 'class', $class->getName(), var_export($class->getParentClass(), 1), $class->getFileName(), $class->getStartLine(), $class->getEndline(), $class->getModifiers(), implode(' ', Reflection::getModifierNames($class->getModifiers())));
// output: ===> The user-defined class 'Counter' [extends ReflectionClass::__set_state(array( 'name' => 'Object', ))] declared in /home/cg/root/main.php lines 15 to 31 having the modifiers 524288 []
printf("===> Documentation:%s<br/>", var_export($class->getDocComment(), 1));
// output: ===> Documentation:'/** * A counter class */'
printf("===> Implements:%s<br/>", var_export($class->getInterfaces(), 1));
// output: ===> Implements:array ( 'NSerializable' => ReflectionClass::__set_state(array( 'name' => 'NSerializable', )), )
printf("===> Constants: %s<br/>", var_export($class->getConstants(), 1));
// output: ===> Constants: array ( 'START' => 0, )
printf("===> Properties: %s<br/>", var_export($class->getProperties(), 1));
// output: ===> Properties: array ( 0 => ReflectionProperty::__set_state(array( 'name' => 'c', 'class' => 'Counter', )), )
printf("===> Methods: %s<br/>", var_export($class->getMethods(), 1));
// output: ===> Methods: array ( 0 => ReflectionMethod::__set_state(array( 'name' => 'count', 'class' => 'Counter', )), )
if ($class->isInstantiable()) {
    $counter = $class->newInstance();
    echo '===> $counter is instance? ';
    echo $class->isInstance($counter) ? 'yes' : 'no';
开发者ID:KB-WEB-DEVELOPMENT,项目名称:Kami_Barut_PHP_projects,代码行数:31,代码来源:ReflectionClass+methods+example.php

示例6: getInterfaces

var_dump($rb->getInterfaceNames());
print "\n";
print "--- getInterfaces() ---\n";
# Very verbose.
#var_dump(
$rb->getInterfaces();
print "\n";
print "--- getMethod() ---\n";
print "\n";
print "--- getMethods() ---\n";
# Very verbose.
#var_dump(
$rb->getMethods();
print "\n";
print "--- getModifiers() ---\n";
var_dump($rb->getModifiers());
print "\n";
print "--- getName() ---\n";
var_dump($rb->getName());
print "\n";
print "--- getParentClass() ---\n";
var_dump($rb->getParentClass());
var_dump($rb->getParentClass()->getName());
print "\n";
print "--- getProperties() ---\n";
# Very verbose.
#var_dump(
$rb->getProperties();
print "\n";
print "--- getProperty() ---\n";
# Very verbose.
开发者ID:alphaxxl,项目名称:hhvm,代码行数:31,代码来源:reflection.php

示例7: reflect

 /**
  * Show reflection
  *
  * Show reflection
  *
  * <code>
  * Panda_Debug::reflect('BEAR_Form');  // Class
  * Panda_Debug::reflect($obj);        // Objecy
  * Panda_Debug::reflect('p');         // Function
  * </code>
  *
  * @param string $target      target
  * @param boll   $cehckParent check parent class
  *
  * @return void
  */
 public static function reflect($target, $cehckParent = false)
 {
     if (is_object($target)) {
         $target = get_class($target);
     }
     switch (true) {
         case function_exists($target):
             $ref = new ReflectionFunction($target);
             $info['name'] = $ref->isInternal() ? 'The internal ' : 'The user-defined ';
             $info['name'] .= $targetName = $ref->getName();
             $info['declare in'] = $ref->getFileName() . ' lines ' . $ref->getStartLine() . ' to ' . $ref->getEndline();
             $info['Documentation'] = $ref->getDocComment();
             $statics = $ref->getStaticVariables();
             if ($statics) {
                 $info['Static variables'] = $statics;
             }
             $type = 'function';
             break;
         case class_exists($target, false):
             $ref = new ReflectionClass($target);
             $type = 'class';
             $info['name'] = $ref->isInternal() ? 'The internal ' : 'The user-defined ';
             $info['name'] .= $ref->isAbstract() ? ' abstract ' : '';
             $info['name'] .= $ref->isFinal() ? ' final ' : '';
             $info['name'] .= $ref->isInterface() ? 'interface ' : 'class ';
             $info['name'] .= $targetName = $ref->getName();
             $info['declare in'] = $ref->getFileName() . ' lines ' . $ref->getStartLine() . ' to ' . $ref->getEndline();
             $info['modifiers'] = Reflection::getModifierNames($ref->getModifiers());
             $info['Documentation'] = $ref->getDocComment();
             $info['Implements'] = $ref->getInterfaces();
             $info['Constants'] = $ref->getConstants();
             foreach ($ref->getProperties() as $prop) {
                 // ReflectionProperty クラスのインスタンスを生成する
                 $propRef = new ReflectionProperty($targetName, $prop->name);
                 if ($propRef->isPublic()) {
                     $porps[] = $prop->name;
                 }
             }
             //            $info['Public Properties'] = $porps;
             foreach ($ref->getMethods() as $method) {
                 $methodRef = new ReflectionMethod($targetName, $method->name);
                 if ($methodRef->isPublic() || $method->isStatic()) {
                     $final = $method->isFinal() ? 'final ' : '';
                     $pubic = $method->isPublic() ? 'public ' : '';
                     $static = $method->isStatic() ? ' static ' : '';
                     $methods[] = sprintf("%s%s%s %s", $final, $pubic, $static, $method->name);
                 }
             }
             $info['Public Methods'] = $methods;
             if ($ref->isInstantiable() && is_object($target)) {
                 $info['isInstance ?'] = $ref->isInstance($target) ? 'yes' : 'no';
             }
             if ($parent) {
                 $info['parent'] .= $ref->getParentClass();
             }
             break;
         default:
             $type = 'Invalid Object/Class';
             $targetName = $target;
             $info = null;
             break;
     }
     print_a($info, "show_objects:1;label: Reflection of {$type} '{$targetName}'");
 }
开发者ID:sssAlchemy,项目名称:Panda,代码行数:80,代码来源:Debug.php

示例8: classes

 /**
  * Create a syntax highlighted diagram of a class, including parent dependencies,  memebers and functions.
  *
  * @param   object  $obj  The object to explore.
  * @return  string        The formatted diagram of the object.
  */
 public static function classes($obj)
 {
     echo self::$is_themed ? '' : self::$theme;
     $current_class = new \ReflectionObject($obj);
     $class = new \ReflectionClass($current_class->getName());
     $parents = array();
     while ($parent = $class->getParentClass()) {
         $mod = "<h3><b class='rtn'>{$parstr}</b>" . implode(' ', \Reflection::getModifierNames($class->getModifiers()));
         $nam = "Class <b class='nam'>" . $class->getName() . "</b></h3>";
         $lin = self::get_func_url($class->getStartLine(), $class->getEndLine(), $class->getFileName());
         $doc = self::clean_docblok($class->getdocComment(), false, "Undocumented {$parstr}" . "Class");
         $parents[] = "<div class='method'>";
         $parents[] = $lin;
         $parents[] = Syntax::php(trim($mod . $nam), 'all');
         $parents[] = "<b class='com'>{$doc}</b>";
         $properties = implode($class->getProperties());
         $properties = str_replace('<default>', '', $properties);
         $properties = str_replace('Property [ ', '', $properties);
         $properties = str_replace(' ]', '', $properties);
         $properties = explode(' ', $properties);
         $len = 0;
         foreach ($properties as $k => $v) {
             if ($k % 2 !== 0) {
                 $test = strlen($v);
                 $len = $test > $len ? $test + 1 : $len;
             }
         }
         foreach ($properties as $k => $v) {
             $properties[$k] = ltrim(sprintf("%-{$len}s", $v));
         }
         $properties = implode('', $properties);
         $properties = explode("\n", $properties);
         asort($properties);
         $properties = "<h4>Properties:</h4>" . implode("\n", $properties);
         $parents[] = Syntax::php($properties, 'all');
         if ($parstr !== 'Parent ') {
             $parents[] = self::build_func_list($obj);
         }
         $parents[] = "</div>";
         $parstr = "Parent ";
         $class = $parent;
     }
     $class_info = "Parents: " . implode(", ", $parents);
     $class_info = Syntax::php($class_info, 'all');
     $classinfo = implode($parents);
     echo $classinfo;
     /*
     	$class = new \ReflectionObject($obj);
     	ReflectionObject::export($obj);
     	$test  = new \ReflectionClass($obj);
     	print_r($test->getProperties());
     
     
     	echo 'getConstants()        '; print_r(         $class->getConstants()                ) .PHP_EOL;
     	echo 'getDefaultProperties()'; print_r(         $class->getDefaultProperties()        ) .PHP_EOL;
     	echo 'getInterfaceNames()   '; print_r(         $class->getInterfaceNames()           ) .PHP_EOL;
     	echo 'getInterfaces()       '; print_r(         $class->getInterfaces()               ) .PHP_EOL;
     	echo 'getMethods()          '; print_r(         $class->getMethods()                  ) .PHP_EOL;
     	echo 'getProperties()       '; print_r(         $class->getProperties()               ) .PHP_EOL;
     	echo 'getStaticProperties() '; print_r(         $class->getStaticProperties()         ) .PHP_EOL;
     	echo 'getTraitAliases()     '; print_r(         $class->getTraitAliases()             ) .PHP_EOL;
     	echo 'getTraitNames()       '; print_r(         $class->getTraitNames()               ) .PHP_EOL;
     	echo 'getTraits()           '; print_r(         $class->getTraits()                   ) .PHP_EOL;
     	echo 'hasConstant()         '. AT::boolstr( $class->hasConstant($class->getName())) .PHP_EOL;
     	echo 'inNamespace()         '. AT::boolstr( $class->inNamespace()                 ) .PHP_EOL;
     	echo 'isAbstract()          '. AT::boolstr( $class->isAbstract()                  ) .PHP_EOL;
     	echo 'isCloneable()         '. AT::boolstr( $class->isCloneable()                 ) .PHP_EOL;
     	echo 'isFinal()             '. AT::boolstr( $class->isFinal()                     ) .PHP_EOL;
     	echo 'isInstantiable()      '. AT::boolstr( $class->isInstantiable()              ) .PHP_EOL;
     	echo 'isInterface()         '. AT::boolstr( $class->isInterface()                 ) .PHP_EOL;
     	echo 'isInternal()          '. AT::boolstr( $class->isInternal()                  ) .PHP_EOL;
     	echo 'isIterateable()       '. AT::boolstr( $class->isIterateable()               ) .PHP_EOL;
     	echo 'isTrait()             '. AT::boolstr( $class->isTrait()                     ) .PHP_EOL;
     	echo 'isUserDefined()       '. AT::boolstr( $class->isUserDefined()               ) .PHP_EOL;
     	echo 'getEndLine()          '.                  $class->getEndLine()                    .PHP_EOL;
     	echo 'getModifiers()        '.                  $class->getModifiers()                  .PHP_EOL;
     	echo 'getStartLine()        '.                  $class->getStartLine()                  .PHP_EOL;
     	echo 'getDocComment()       '.                  $class->getDocComment()                 .PHP_EOL;
     	echo 'getExtensionName()    '.                  $class->getExtensionName()              .PHP_EOL;
     	echo 'getFileName()         '.                  $class->getFileName()                   .PHP_EOL;
     	echo 'getName()             '.                  $class->getName()                       .PHP_EOL;
     	echo 'getNamespaceName()    '.                  $class->getNamespaceName()              .PHP_EOL;
     	echo 'getShortName()        '.                  $class->getShortName()                  .PHP_EOL;
     */
 }
开发者ID:tundratech,项目名称:alpine,代码行数:91,代码来源:Explore.php

示例9: getModifiers

 /**
  * Returns the Java language modifiers for this class or interface, encoded
  * in an int. The modifiers consist of the Java Virtual Machine's
  * constants for <code>public</code>, <code>protected</code>,
  * <code>private</code>, <code>final</code>, <code>static</code>,
  * <code>abstract</code> and <code>interface</code>; they should be decoded
  * using the methods of class <code>Modifier</code>.
  *
  * <p> If the underlying class is an array class, then its
  * <code>public</code>, <code>private</code> and <code>protected</code>
  * modifiers are the same as those of its component type.  If this
  * <code>Class</code> represents a primitive type or void, its
  * <code>public</code> modifier is always <code>true</code>, and its
  * <code>protected</code> and <code>private</code> modifiers are always
  * <code>false</code>. If this object represents an array class, a
  * primitive type or void, then its <code>final</code> modifier is always
  * <code>true</code> and its interface modifier is always
  * <code>false</code>. The values of its other modifiers are not determined
  * by this specification.
  *
  * <p> The modifier encodings are defined in <em>The Java Virtual Machine
  * Specification</em>, table 4.1.
  *
  * @return the <code>int</code> representing the modifiers for this class
  * @see     java.lang.reflect.Modifier
  * @since JDK1.1
  */
 public function getModifiers()
 {
     return $this->reflectionClass->getModifiers();
 }
开发者ID:robo47,项目名称:BlazeFramework,代码行数:31,代码来源:ClassWrapper.php

示例10: ReflectionClass

<?php

class C
{
}
$rc = new ReflectionClass("C");
var_dump($rc->isFinal('X'));
var_dump($rc->isInterface(null));
var_dump($rc->isAbstract(true));
var_dump($rc->getModifiers(array(1, 2, 3)));
开发者ID:badlamer,项目名称:hhvm,代码行数:10,代码来源:ReflectionClass_modifiers_002.php

示例11: transformClass

 function transformClass(ReflectionClass $class)
 {
     $is_internal = $class->isInternal() ? 'internal' : 'user-defined';
     $is_abstract = $class->isAbstract() ? ' abstract' : '';
     $is_final = $class->isFinal() ? ' final' : '';
     $is_interface = $class->isInterface() ? 'interface' : '';
     $type = $class->isInterface() ? 'interface' : 'class';
     $name = $class->getName();
     $extends = @$class->getParentClass()->name;
     if ($class->isInternal() || $class->isInterface()) {
         $this->important[] = $name;
     }
     $implements = array();
     foreach ($class->getInterfaces() as $i) {
         $implements[] = $i->name;
     }
     $implements_inherited = array();
     if ($class->getParentClass()) {
         foreach ($class->getParentClass()->getInterfaces() as $i) {
             $implements_inherited[] = $i->name;
         }
     }
     $implements_directly = array_diff($implements, $implements_inherited);
     $modifiers = Reflection::getModifierNames($class->getModifiers());
     extract($this->transformDocBlock($class->getDocComment()));
     $this->__global_hack = array();
     $properties = array();
     $properties_inherited = array();
     foreach ($class->getProperties() as $property) {
         if ($property->getDeclaringClass()->name == $class->name) {
             $properties[] = $this->transformProperty($property, FALSE);
         } else {
             $properties_inherited[] = $this->transformProperty($property, TRUE);
         }
     }
     $methods = array();
     $methods_inherited = array();
     foreach ($class->getMethods() as $method) {
         if ($method->getDeclaringClass()->name == $class->name) {
             $methods[] = $this->transformMethod($method);
         } else {
             $methods_inherited[] = $this->transformMethod($method);
         }
     }
     ob_start();
     include "templates/" . $this->template . "/class.tmpl.php";
     return ob_get_clean();
 }
开发者ID:harrysame,项目名称:PHP-MySQL,代码行数:48,代码来源:pepper.php

示例12: getModifiers

 /**
  * @return array
  */
 public function getModifiers()
 {
     return Reflection::getModifierNames($this->class->getModifiers());
 }
开发者ID:sysvyz,项目名称:brunt,代码行数:7,代码来源:ReflectiveCRClass.php

示例13: testModifiers

 /**
  * Tests class modifiers.
  */
 public function testModifiers()
 {
     static $classes = array('TokenReflection_Test_ClassModifiersIface1', 'TokenReflection_Test_ClassModifiersIface2', 'TokenReflection_Test_ClassModifiersIface3', 'TokenReflection_Test_ClassModifiersIface4', 'TokenReflection_Test_ClassModifiersClass1', 'TokenReflection_Test_ClassModifiersClass2', 'TokenReflection_Test_ClassModifiersClass3', 'TokenReflection_Test_ClassModifiersClass4', 'TokenReflection_Test_ClassModifiersClass5', 'TokenReflection_Test_ClassModifiersClass6', 'TokenReflection_Test_ClassModifiersClass7', 'TokenReflection_Test_ClassModifiersClass8');
     require_once $this->getFilePath('modifiers');
     $this->getBroker()->process($this->getFilePath('modifiers'));
     foreach ($classes as $className) {
         $token = $this->getBroker()->getClass($className);
         $internal = new \ReflectionClass($className);
         $this->assertSame($internal->getModifiers(), $token->getModifiers(), $className);
     }
 }
开发者ID:eduardobenito10,项目名称:jenkins-php-quickstart,代码行数:14,代码来源:ReflectionClassTest.php

示例14: dump_modifierNames

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

示例15: count

class Object
{
}
class Counter extends Object implements MyInterface
{
    const START = 0;
    private static $c = Counter::START;
    public function count()
    {
        return self::$c++;
    }
}
// Создание экземпляра класса ReflectionClass
$class = new ReflectionClass('Counter');
// Вывод основной информации
printf("===> %s%s%s %s '%s' [экземпляр класса %s]\n" . "     объявлен в %s\n" . "     строки с %d по %d\n" . "     имеет модификаторы %d [%s]\n", $class->isInternal() ? 'Встроенный' : 'Пользовательский', $class->isAbstract() ? ' абстрактный' : '', $class->isFinal() ? ' финальный' : '', $class->isInterface() ? 'интерфейс' : 'класс', $class->getName(), var_export($class->getParentClass(), 1), $class->getFileName(), $class->getStartLine(), $class->getEndline(), $class->getModifiers(), implode(' ', Reflection::getModifierNames($class->getModifiers())));
// Вывод тех интерфейсов, которые реализует этот класс
printf("---> Интерфейсы:\n %s\n", var_export($class->getInterfaces(), 1));
// Вывод констант класса
printf("---> Константы: %s\n", var_export($class->getConstants(), 1));
// Вывод свойств класса
printf("---> Свойства: %s\n", var_export($class->getProperties(), 1));
// Вывод методов класса
printf("---> Методы: %s\n", var_export($class->getMethods(), 1));
// Если есть возможность создать экземпляр класса, то создаем его
if ($class->isInstantiable()) {
    $counter = $class->newInstance();
    echo '---> Создан ли экземпляр класса ' . $class->getName() . '? ';
    echo $class->isInstance($counter) ? 'Да' : 'Нет';
    echo "\n---> Создан ли экземпляр класса Object()? ";
    echo $class->isInstance(new Object()) ? 'Да' : 'Нет';
开发者ID:ralf000,项目名称:PHP4,代码行数:31,代码来源:05-class-2.php


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