1--TEST-- 2ReflectionClass::getProperty() - error cases 3--CREDITS-- 4Robin Fernandes <robinf@php.net> 5Steve Seear <stevseea@php.net> 6--FILE-- 7<?php 8class C { 9 public $a; 10} 11 12$rc = new ReflectionClass("C"); 13echo "Check invalid params:\n"; 14try { 15 var_dump($rc->getProperty()); 16} catch (TypeError $e) { 17 echo $e->getMessage() . "\n"; 18} 19try { 20 var_dump($rc->getProperty("a", "a")); 21} catch (TypeError $e) { 22 echo $e->getMessage() . "\n"; 23} 24try { 25 var_dump($rc->getProperty(null)); 26} catch (exception $e) { 27 echo $e->getMessage() . "\n"; 28} 29try { 30 var_dump($rc->getProperty(1)); 31} catch (exception $e) { 32 echo $e->getMessage() . "\n"; 33} 34try { 35 var_dump($rc->getProperty(1.5)); 36} catch (exception $e) { 37 echo $e->getMessage() . "\n"; 38} 39try { 40 var_dump($rc->getProperty(true)); 41} catch (exception $e) { 42 echo $e->getMessage() . "\n"; 43} 44try { 45 var_dump($rc->getProperty(array(1,2,3))); 46} catch (TypeError $e) { 47 echo $e->getMessage() . "\n"; 48} 49try { 50 var_dump($rc->getProperty(new C)); 51} catch (TypeError $e) { 52 echo $e->getMessage() . "\n"; 53} 54?> 55--EXPECT-- 56Check invalid params: 57ReflectionClass::getProperty() expects exactly 1 argument, 0 given 58ReflectionClass::getProperty() expects exactly 1 argument, 2 given 59Property C::$ does not exist 60Property C::$1 does not exist 61Property C::$1.5 does not exist 62Property C::$1 does not exist 63ReflectionClass::getProperty(): Argument #1 ($name) must be of type string, array given 64ReflectionClass::getProperty(): Argument #1 ($name) must be of type string, C given 65