1--TEST-- 2ReflectionMethod constructor errors 3--CREDITS-- 4Robin Fernandes <robinf@php.net> 5Steve Seear <stevseea@php.net> 6--FILE-- 7<?php 8 9class TestClass 10{ 11 public function foo() { 12 } 13} 14 15 16try { 17 echo "\nWrong type of argument (bool):\n"; 18 $methodInfo = new ReflectionMethod(true); 19} catch (Exception $e) { 20 print $e->__toString(); 21} 22try { 23 echo "\nWrong type of argument (int):\n"; 24 $methodInfo = new ReflectionMethod(3); 25} catch (Exception $e) { 26 print $e->__toString(); 27} 28try { 29 echo "\nWrong type of argument (bool, string):\n"; 30 $methodInfo = new ReflectionMethod(true, "foo"); 31} catch (Exception $e) { 32 print $e->__toString(); 33} 34try { 35 echo "\nWrong type of argument (string, bool):\n"; 36 $methodInfo = new ReflectionMethod('TestClass', true); 37} catch (Exception $e) { 38 print $e->__toString(); 39} 40try { 41 echo "\nNo method given:\n"; 42 $methodInfo = new ReflectionMethod("TestClass"); 43} catch (Exception $e) { 44 print $e->__toString(); 45} 46try { 47 echo "\nClass and Method in same string, bad method name:\n"; 48 $methodInfo = new ReflectionMethod("TestClass::foop::dedoop"); 49} catch (Exception $e) { 50 print $e->__toString(); 51} 52try { 53 echo "\nClass and Method in same string, bad class name:\n"; 54 $methodInfo = new ReflectionMethod("TestCla::foo"); 55} catch (Exception $e) { 56 print $e->__toString(); 57} 58try { 59 echo "\nClass and Method in same string (ok):\n"; 60 $methodInfo = new ReflectionMethod("TestClass::foo"); 61} catch (Exception $e) { 62 print $e->__toString(); 63} 64 65?> 66--EXPECTF-- 67Wrong type of argument (bool): 68ReflectionException: ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be a valid method name in %s:%d 69Stack trace: 70#0 %s ReflectionMethod->__construct('1') 71#1 {main} 72Wrong type of argument (int): 73ReflectionException: ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be a valid method name in %s:%d 74Stack trace: 75#0 %s ReflectionMethod->__construct('3') 76#1 {main} 77Wrong type of argument (bool, string): 78ReflectionException: Class "1" does not exist in %s:%d 79Stack trace: 80#0 %s ReflectionMethod->__construct('1', 'foo') 81#1 {main} 82Wrong type of argument (string, bool): 83ReflectionException: Method TestClass::1() does not exist in %s:%d 84Stack trace: 85#0 %s ReflectionMethod->__construct('TestClass', '1') 86#1 {main} 87No method given: 88ReflectionException: ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be a valid method name in %s:%d 89Stack trace: 90#0 %s ReflectionMethod->__construct('TestClass') 91#1 {main} 92Class and Method in same string, bad method name: 93ReflectionException: Method TestClass::foop::dedoop() does not exist in %s:%d 94Stack trace: 95#0 %s ReflectionMethod->__construct('TestClass::foop...') 96#1 {main} 97Class and Method in same string, bad class name: 98ReflectionException: Class "TestCla" does not exist in %s:%d 99Stack trace: 100#0 %s ReflectionMethod->__construct('TestCla::foo') 101#1 {main} 102Class and Method in same string (ok): 103