File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / reflection / tests / ReflectionMethod_getStaticVariables_basic.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:48:00 2012 UTC (13 years, 1 month ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, v5_3_10, HEAD
php

--TEST--
ReflectionMethod::getStaticVariables()
--FILE--
<?php

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());

?>
--EXPECT--
Public method:
array(3) {
  ["c"]=>
  NULL
  ["a"]=>
  int(1)
  ["b"]=>
  string(5) "hello"
}

Private method:
array(1) {
  ["a"]=>
  int(1)
}

Method with no static variables:
array(0) {
}

Internal Method:
array(0) {
}

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>