1--TEST-- 2ReflectionMethod class getName(), isInternal() and isUserDefined() methods 3--FILE-- 4<?php 5 6function reflectMethod($class, $method) { 7 $methodInfo = new ReflectionMethod($class, $method); 8 echo "**********************************\n"; 9 echo "Reflecting on method $class::$method()\n\n"; 10 echo "\ngetName():\n"; 11 var_dump($methodInfo->getName()); 12 echo "\nisInternal():\n"; 13 var_dump($methodInfo->isInternal()); 14 echo "\nisUserDefined():\n"; 15 var_dump($methodInfo->isUserDefined()); 16 echo "\n**********************************\n"; 17} 18 19class TestClass 20{ 21 public function foo() { 22 echo "Called foo()\n"; 23 } 24 25 static function stat() { 26 echo "Called stat()\n"; 27 } 28 29 private function priv() { 30 echo "Called priv()\n"; 31 } 32 33 protected function prot() {} 34 35 public function __destruct() {} 36} 37 38class DerivedClass extends TestClass {} 39 40interface TestInterface { 41 public function int(); 42} 43 44reflectMethod("DerivedClass", "foo"); 45reflectMethod("TestClass", "stat"); 46reflectMethod("TestClass", "priv"); 47reflectMethod("TestClass", "prot"); 48reflectMethod("DerivedClass", "prot"); 49reflectMethod("TestInterface", "int"); 50reflectMethod("ReflectionProperty", "__construct"); 51reflectMethod("TestClass", "__destruct"); 52 53 54?> 55--EXPECT-- 56********************************** 57Reflecting on method DerivedClass::foo() 58 59 60getName(): 61string(3) "foo" 62 63isInternal(): 64bool(false) 65 66isUserDefined(): 67bool(true) 68 69********************************** 70********************************** 71Reflecting on method TestClass::stat() 72 73 74getName(): 75string(4) "stat" 76 77isInternal(): 78bool(false) 79 80isUserDefined(): 81bool(true) 82 83********************************** 84********************************** 85Reflecting on method TestClass::priv() 86 87 88getName(): 89string(4) "priv" 90 91isInternal(): 92bool(false) 93 94isUserDefined(): 95bool(true) 96 97********************************** 98********************************** 99Reflecting on method TestClass::prot() 100 101 102getName(): 103string(4) "prot" 104 105isInternal(): 106bool(false) 107 108isUserDefined(): 109bool(true) 110 111********************************** 112********************************** 113Reflecting on method DerivedClass::prot() 114 115 116getName(): 117string(4) "prot" 118 119isInternal(): 120bool(false) 121 122isUserDefined(): 123bool(true) 124 125********************************** 126********************************** 127Reflecting on method TestInterface::int() 128 129 130getName(): 131string(3) "int" 132 133isInternal(): 134bool(false) 135 136isUserDefined(): 137bool(true) 138 139********************************** 140********************************** 141Reflecting on method ReflectionProperty::__construct() 142 143 144getName(): 145string(11) "__construct" 146 147isInternal(): 148bool(true) 149 150isUserDefined(): 151bool(false) 152 153********************************** 154********************************** 155Reflecting on method TestClass::__destruct() 156 157 158getName(): 159string(10) "__destruct" 160 161isInternal(): 162bool(false) 163 164isUserDefined(): 165bool(true) 166 167********************************** 168