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


PHP ReflectionMethod::getStaticVariables方法代码示例

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


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

示例1: getStaticVariables

 /**
  * Returns an associative array containing this method's static variables
  * and their values
  *
  * @return array<sting,mixed> This method's static variables
  */
 public function getStaticVariables()
 {
     if ($this->reflectionSource instanceof ReflectionMethod) {
         return $this->reflectionSource->getStaticVariables();
     } else {
         return parent::getStaticVariables();
     }
 }
开发者ID:naderman,项目名称:ezc-reflection,代码行数:14,代码来源:method.php

示例2: ReflectionFunction

};
echo "---- ReflectionFunction ----\n";
$rf = new ReflectionFunction('foo');
echo "ReflectionFunction(1):";
var_dump($rf->getStaticVariables());
foo();
echo "ReflectionFunction(2):";
var_dump($rf->getStaticVariables());
foo();
$rf = new ReflectionFunction('foo');
echo "ReflectionFunction(3):";
var_dump($rf->getStaticVariables());
echo "---- ReflectionMethod ----\n";
$rf = new ReflectionMethod('Bar', 'foo');
echo "ReflectionMethod(1):";
var_dump($rf->getStaticVariables());
Bar::foo();
echo "ReflectionMethod(2):";
var_dump($rf->getStaticVariables());
Bar::foo();
$rf = new ReflectionFunction('foo');
echo "ReflectionMethod(3):";
var_dump($rf->getStaticVariables());
echo "---- ReflectionClosure ----\n";
$rf = new ReflectionFunction($foo);
echo "ReflectionFunction(1-closure):";
var_dump($rf->getStaticVariables());
$foo();
echo "ReflectionFunction(2-closure):";
var_dump($rf->getStaticVariables());
$foo();
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:reflection_static_vars.php

示例3: increment

<pre>
<?php 
class Counter
{
    private static $c = 0;
    public static final function increment()
    {
        return ++self::$c;
    }
}
// Создание экземпляра класса ReflectionMethod
$method = new ReflectionMethod('Counter', 'increment');
// exit;
// Вывод основной информации
printf("===> %s%s%s%s%s%s%s метод '%s' (который является %s)\n" . "     объявлен в %s\n" . "     строки с %d по %d\n" . "     имеет модификаторы %d[%s]\n", $method->isInternal() ? 'Встроенный' : 'Пользовательский', $method->isAbstract() ? ' абстрактный' : '', $method->isFinal() ? ' финальный' : '', $method->isPublic() ? ' public' : '', $method->isPrivate() ? ' private' : '', $method->isProtected() ? ' protected' : '', $method->isStatic() ? ' статический' : '', $method->getName(), $method->isConstructor() ? 'конструктором' : 'обычным методом', $method->getFileName(), $method->getStartLine(), $method->getEndline(), $method->getModifiers(), implode(' ', Reflection::getModifierNames($method->getModifiers())));
// Вывод статических переменных, если они есть
if ($statics = $method->getStaticVariables()) {
    printf("---> Статическая переменная: %s\n", var_export($statics, 1));
}
// Вызов метода
printf("---> Результат вызова: ");
$result = $method->invoke(3);
echo $result;
?>
</pre>
开发者ID:sydorenkovd,项目名称:features_for_phpoopsecond.local,代码行数:25,代码来源:03-method.php

示例4: f

} catch (TypeError $re) {
    echo "Ok - " . $re->getMessage() . PHP_EOL;
}
try {
    new ReflectionMethod('a', 'b', 'c');
} catch (TypeError $re) {
    echo "Ok - " . $re->getMessage() . PHP_EOL;
}
class C
{
    public function f()
    {
    }
}
$rm = new ReflectionMethod('C', 'f');
var_dump($rm->isFinal(1));
var_dump($rm->isAbstract(1));
var_dump($rm->isPrivate(1));
var_dump($rm->isProtected(1));
var_dump($rm->isPublic(1));
var_dump($rm->isStatic(1));
var_dump($rm->isConstructor(1));
var_dump($rm->isDestructor(1));
var_dump($rm->getModifiers(1));
var_dump($rm->isInternal(1));
var_dump($rm->isUserDefined(1));
var_dump($rm->getFileName(1));
var_dump($rm->getStartLine(1));
var_dump($rm->getEndLine(1));
var_dump($rm->getStaticVariables(1));
var_dump($rm->getName(1));
开发者ID:zaky-92,项目名称:php-1,代码行数:31,代码来源:ext_reflection_tests_ReflectionMethod_006.php

示例5: fn

<?php

$a = 4;
$b = 'i am a string';
function fn($c)
{
    return $c + 5;
}
$lam = function ($c) use($a, $b) {
    return $a + $c;
};
class C
{
    public static $i;
    public $j;
    public function meth($c)
    {
        return $c + 3;
    }
}
$refl = new ReflectionFunction('fn');
var_dump($refl->getStaticVariables());
$refl = new ReflectionFunction($lam);
var_dump($refl->getStaticVariables());
$refl = new ReflectionMethod('C', 'meth');
var_dump($refl->getStaticVariables());
开发者ID:badlamer,项目名称:hhvm,代码行数:26,代码来源:closure_get_static_vars.php

示例6: foo

class TestClass
{
    public function foo()
    {
        static $c;
        static $a = 1;
        static $b = "hello";
        $d = 5;
    }
    private function bar()
    {
        static $a = 1;
    }
    public function noStatics()
    {
        $a = 54;
    }
}
echo "Public method:\n";
$methodInfo = new ReflectionMethod('TestClass::foo');
var_dump($methodInfo->getStaticVariables());
echo "\nPrivate method:\n";
$methodInfo = new ReflectionMethod('TestClass::bar');
var_dump($methodInfo->getStaticVariables());
echo "\nMethod with no static variables:\n";
$methodInfo = new ReflectionMethod('TestClass::noStatics');
var_dump($methodInfo->getStaticVariables());
echo "\nInternal Method:\n";
$methodInfo = new ReflectionMethod('ReflectionClass::getName');
var_dump($methodInfo->getStaticVariables());
开发者ID:badlamer,项目名称:hhvm,代码行数:30,代码来源:ReflectionMethod_getStaticVariables_basic.php

示例7: dummy

<?php

function dummy()
{
    static $a = array();
}
class Test
{
    const A = 0;
    public function func()
    {
        static $a = array(self::A => 'a');
    }
}
$reflect = new ReflectionFunction("dummy");
print_r($reflect->getStaticVariables());
$reflect = new ReflectionMethod('Test', 'func');
print_r($reflect->getStaticVariables());
开发者ID:badlamer,项目名称:hhvm,代码行数:18,代码来源:bug63614.php


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