ReflectionClass_getStaticPropertyValue_002.phpt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 (TypeError $e) {
  15. echo $e->getMessage() . "\n";
  16. }
  17. try {
  18. var_dump($rc->getStaticPropertyValue());
  19. } catch (TypeError $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 (TypeError $e) {
  35. echo $e->getMessage() . "\n";
  36. }
  37. ?>
  38. --EXPECTF--
  39. ReflectionClass::getStaticPropertyValue() expects at most 2 arguments, 3 given
  40. ReflectionClass::getStaticPropertyValue() expects at least 1 argument, 0 given
  41. Deprecated: ReflectionClass::getStaticPropertyValue(): Passing null to parameter #1 ($name) of type string is deprecated in %s on line %d
  42. Property C::$ does not exist
  43. string(3) "def"
  44. ReflectionClass::getStaticPropertyValue(): Argument #1 ($name) must be of type string, array given