ReflectionClass_getStaticPropertyValue_002.phpt 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. --TEST--
  2. ReflectionClass::getStaticPropertyValue() - bad params
  3. --CREDITS--
  4. Robin Fernandes <robinf@php.net>
  5. Steve Seear <stevseea@php.net>
  6. --FILE--
  7. <?php
  8. class C {
  9. public static $x;
  10. }
  11. $rc = new ReflectionClass('C');
  12. try {
  13. var_dump($rc->getStaticPropertyValue("x", "default value", 'blah'));
  14. } catch (Exception $e) {
  15. echo $e->getMessage() . "\n";
  16. }
  17. try {
  18. var_dump($rc->getStaticPropertyValue());
  19. } catch (Exception $e) {
  20. echo $e->getMessage() . "\n";
  21. }
  22. try {
  23. var_dump($rc->getStaticPropertyValue(null));
  24. } catch (Exception $e) {
  25. echo $e->getMessage() . "\n";
  26. }
  27. try {
  28. var_dump($rc->getStaticPropertyValue(1.5, 'def'));
  29. } catch (Exception $e) {
  30. echo $e->getMessage() . "\n";
  31. }
  32. try {
  33. var_dump($rc->getStaticPropertyValue(array(1,2,3)));
  34. } catch (Exception $e) {
  35. echo $e->getMessage() . "\n";
  36. }
  37. ?>
  38. --EXPECTF--
  39. Warning: ReflectionClass::getStaticPropertyValue() expects at most 2 parameters, 3 given in %s on line 8
  40. NULL
  41. Warning: ReflectionClass::getStaticPropertyValue() expects at least 1 parameter, 0 given in %s on line 13
  42. NULL
  43. Class C does not have a property named
  44. string(3) "def"
  45. Warning: ReflectionClass::getStaticPropertyValue() expects parameter 1 to be string, array given in %s on line 28
  46. NULL