ReflectionClass_setStaticPropertyValue_002.phpt 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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->setStaticPropertyValue("x", "default value", 'blah'));
  14. } catch (Exception $e) {
  15. echo $e->getMessage() . "\n";
  16. }
  17. try {
  18. var_dump($rc->setStaticPropertyValue());
  19. } catch (Exception $e) {
  20. echo $e->getMessage() . "\n";
  21. }
  22. try {
  23. var_dump($rc->setStaticPropertyValue(null));
  24. } catch (Exception $e) {
  25. echo $e->getMessage() . "\n";
  26. }
  27. try {
  28. var_dump($rc->setStaticPropertyValue(null,null));
  29. } catch (Exception $e) {
  30. echo $e->getMessage() . "\n";
  31. }
  32. try {
  33. var_dump($rc->setStaticPropertyValue(1.5, 'def'));
  34. } catch (Exception $e) {
  35. echo $e->getMessage() . "\n";
  36. }
  37. try {
  38. var_dump($rc->setStaticPropertyValue(array(1,2,3), 'blah'));
  39. } catch (Exception $e) {
  40. echo $e->getMessage() . "\n";
  41. }
  42. ?>
  43. --EXPECTF--
  44. Warning: ReflectionClass::setStaticPropertyValue() expects exactly 2 parameters, 3 given in %s on line 8
  45. NULL
  46. Warning: ReflectionClass::setStaticPropertyValue() expects exactly 2 parameters, 0 given in %s on line 13
  47. NULL
  48. Warning: ReflectionClass::setStaticPropertyValue() expects exactly 2 parameters, 1 given in %s on line 18
  49. NULL
  50. Class C does not have a property named
  51. Class C does not have a property named 1.5
  52. Warning: ReflectionClass::setStaticPropertyValue() expects parameter 1 to be string, array given in %s on line 33
  53. NULL