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 (exception $e) { 17 echo $e->getMessage() . "\n"; 18} 19try { 20 var_dump($rc->getProperty("a", "a")); 21} catch (exception $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 (exception $e) { 47 echo $e->getMessage() . "\n"; 48} 49try { 50 var_dump($rc->getProperty(new C)); 51} catch (exception $e) { 52 echo $e->getMessage() . "\n"; 53} 54?> 55--EXPECTF-- 56Check invalid params: 57 58Warning: ReflectionClass::getProperty() expects exactly 1 parameter, 0 given in %s on line 9 59NULL 60 61Warning: ReflectionClass::getProperty() expects exactly 1 parameter, 2 given in %s on line 14 62NULL 63Property does not exist 64Property 1 does not exist 65Property 1.5 does not exist 66Property 1 does not exist 67 68Warning: ReflectionClass::getProperty() expects parameter 1 to be string, array given in %s on line 39 69NULL 70 71Warning: ReflectionClass::getProperty() expects parameter 1 to be string, object given in %s on line 44 72NULL 73