1--TEST-- 2ReflectionClass::getMethod() - error cases 3--CREDITS-- 4Robin Fernandes <robinf@php.net> 5Steve Seear <stevseea@php.net> 6--FILE-- 7<?php 8class C { 9 function f() {} 10} 11 12$rc = new ReflectionClass("C"); 13echo "Check invalid params:\n"; 14try { 15 var_dump($rc->getMethod()); 16} catch (Exception $e) { 17 echo $e->getMessage() . "\n"; 18} 19try { 20 var_dump($rc->getMethod("f", "f")); 21} catch (Exception $e) { 22 echo $e->getMessage() . "\n"; 23} 24try { 25 var_dump($rc->getMethod(null)); 26} catch (Exception $e) { 27 echo $e->getMessage() . "\n"; 28} 29try { 30 var_dump($rc->getMethod(1)); 31} catch (Exception $e) { 32 echo $e->getMessage() . "\n"; 33} 34try { 35 var_dump($rc->getMethod(1.5)); 36} catch (Exception $e) { 37 echo $e->getMessage() . "\n"; 38} 39try { 40 var_dump($rc->getMethod(true)); 41} catch (Exception $e) { 42 echo $e->getMessage() . "\n"; 43} 44try { 45 var_dump($rc->getMethod(array(1,2,3))); 46} catch (Exception $e) { 47 echo $e->getMessage() . "\n"; 48} 49try { 50 var_dump($rc->getMethod(new C)); 51} catch (Exception $e) { 52 echo $e->getMessage() . "\n"; 53} 54 55 56?> 57--EXPECTF-- 58Check invalid params: 59 60Warning: ReflectionClass::getMethod() expects exactly 1 parameter, 0 given in %s on line 9 61NULL 62 63Warning: ReflectionClass::getMethod() expects exactly 1 parameter, 2 given in %s on line 14 64NULL 65Method does not exist 66Method 1 does not exist 67Method 1.5 does not exist 68Method 1 does not exist 69 70Warning: ReflectionClass::getMethod() expects parameter 1 to be string, array given in %s on line 39 71NULL 72 73Warning: ReflectionClass::getMethod() expects parameter 1 to be string, object given in %s on line 44 74NULL