php-src/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt
Dmitry Stogov f2df6a4a3e - Improved memory usage
. zend_function.pass_rest_by_reference is replaced by
    ZEND_ACC_PASS_REST_BY_REFERENCE in zend_function.fn_flags
  . zend_function.return_reference is replaced by ZEND_ACC_RETURN_REFERENCE
    in zend_function.fn_flags
  . zend_arg_info.required_num_args removed. it was needed only for internal
    functions. Now the first arg_info for internal function (which has special
    meaning) is represented by zend_internal_function_info structure.
  . zend_op_array.size, size_var, size_literal, current_brk_cont,
    backpatch_count moved into CG(context), because they are used only during
    compilation.
  . zend_op_array.start_op is moved into EG(start_op), because it's used
    only for 'interactive' execution of single top-level op-array.
  . zend_op_array.done_pass_two is replaced by ZEND_ACC_DONE_PASS_TWO in
    zend_op_array.fn_flags.
  . op_array.vars array is trimmed (reallocated) during pass_two.
  . zend_class_entry.constants_updated is replaced by
     ZEND_ACC_CONSTANTS_UPDATED in zend_class_entry.ce_flags
  . the size of zend_class_entry is reduced by sharing the same memory space
    by different information for internal and user classes.
    See zend_class_inttry.info union.
2010-09-15 07:38:52 +00:00

243 lines
3.9 KiB
PHP

--TEST--
ReflectionMethod::getModifiers()
--FILE--
<?php
function reflectMethodModifiers($class) {
$classInfo = new reflectionClass($class);
$methodArray = $classInfo->getMethods();
foreach ($methodArray as $method) {
echo "Modifiers for method $method->class::$method->name():\n";
printf("0x%08x\n", $method->getModifiers());
echo "\n\n";
}
}
class TestClass
{
public function foo() {
echo "Called foo()\n";
}
static function stat() {
echo "Called stat()\n";
}
private function priv() {
echo "Called priv()\n";
}
protected function prot() {}
public final function fin() {}
public function __destruct() {}
public function __call($a, $b) {}
public function __clone() {}
public function __get($a) {}
public function __set($a, $b) {}
public function __unset($a) {}
public function __isset($a) {}
public function __tostring() {}
public function __sleep() {}
public function __wakeup() {}
public function __set_state() {}
public function __autoload() {}
}
class DerivedClass extends TestClass {}
interface TestInterface {
public function int();
public function __clone();
}
abstract class AbstractClass {
public abstract function foo();
}
reflectMethodModifiers("TestClass");
reflectMethodModifiers("DerivedClass");
reflectMethodModifiers("TestInterface");
reflectMethodModifiers("AbstractClass");
echo "Wrong number of params:\n";
$a = new ReflectionMethod('TestClass::foo');
$a->getModifiers(1);
$a = new ReflectionMethod('ReflectionMethod::getModifiers');
echo "\nReflectionMethod::getModifiers() modifiers:\n";
printf("0x%08x\n", $a->getModifiers());
?>
--EXPECTF--
Modifiers for method TestClass::foo():
0x08010100
Modifiers for method TestClass::stat():
0x08000101
Modifiers for method TestClass::priv():
0x08010400
Modifiers for method TestClass::prot():
0x08010200
Modifiers for method TestClass::fin():
0x08010104
Modifiers for method TestClass::__destruct():
0x08004100
Modifiers for method TestClass::__call():
0x08000100
Modifiers for method TestClass::__clone():
0x08008100
Modifiers for method TestClass::__get():
0x08000100
Modifiers for method TestClass::__set():
0x08000100
Modifiers for method TestClass::__unset():
0x08000100
Modifiers for method TestClass::__isset():
0x08000100
Modifiers for method TestClass::__tostring():
0x08000100
Modifiers for method TestClass::__sleep():
0x08010100
Modifiers for method TestClass::__wakeup():
0x08010100
Modifiers for method TestClass::__set_state():
0x08010100
Modifiers for method TestClass::__autoload():
0x08010100
Modifiers for method TestClass::foo():
0x08010100
Modifiers for method TestClass::stat():
0x08000101
Modifiers for method TestClass::priv():
0x08010400
Modifiers for method TestClass::prot():
0x08010200
Modifiers for method TestClass::fin():
0x08010104
Modifiers for method TestClass::__destruct():
0x08004100
Modifiers for method TestClass::__call():
0x08000100
Modifiers for method TestClass::__clone():
0x08008100
Modifiers for method TestClass::__get():
0x08000100
Modifiers for method TestClass::__set():
0x08000100
Modifiers for method TestClass::__unset():
0x08000100
Modifiers for method TestClass::__isset():
0x08000100
Modifiers for method TestClass::__tostring():
0x08000100
Modifiers for method TestClass::__sleep():
0x08010100
Modifiers for method TestClass::__wakeup():
0x08010100
Modifiers for method TestClass::__set_state():
0x08010100
Modifiers for method TestClass::__autoload():
0x08010100
Modifiers for method TestInterface::int():
0x08000102
Modifiers for method TestInterface::__clone():
0x08000102
Modifiers for method AbstractClass::foo():
0x08010102
Wrong number of params:
Warning: ReflectionMethod::getModifiers() expects exactly 0 parameters, 1 given in %sReflectionMethod_getModifiers_basic.php on line %d
ReflectionMethod::getModifiers() modifiers:
0x00000100