ReflectionClass_constructor_002.phpt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. --TEST--
  2. ReflectionClass::__constructor() - bad arguments
  3. --FILE--
  4. <?php
  5. try {
  6. var_dump(new ReflectionClass());
  7. } catch (Exception $e) {
  8. echo $e->getMessage() . "\n";
  9. }
  10. try {
  11. var_dump(new ReflectionClass(null));
  12. } catch (Exception $e) {
  13. echo $e->getMessage() . "\n";
  14. }
  15. try {
  16. var_dump(new ReflectionClass(true));
  17. } catch (Exception $e) {
  18. echo $e->getMessage() . "\n";
  19. }
  20. try {
  21. var_dump(new ReflectionClass(1));
  22. } catch (Exception $e) {
  23. echo $e->getMessage() . "\n";
  24. }
  25. try {
  26. var_dump(new ReflectionClass(array(1,2,3)));
  27. } catch (Exception $e) {
  28. echo $e->getMessage() . "\n";
  29. }
  30. try {
  31. var_dump(new ReflectionClass("stdClass", 1));
  32. } catch (Exception $e) {
  33. echo $e->getMessage() . "\n";
  34. }
  35. try {
  36. var_dump(new ReflectionClass("X"));
  37. } catch (Exception $e) {
  38. echo $e->getMessage() . "\n";
  39. }
  40. ?>
  41. --EXPECTF--
  42. Warning: ReflectionClass::__construct() expects exactly 1 parameter, 0 given in %s on line 3
  43. object(ReflectionClass)#%d (1) {
  44. ["name"]=>
  45. string(0) ""
  46. }
  47. Class does not exist
  48. Class 1 does not exist
  49. Class 1 does not exist
  50. Notice: Array to string conversion in %s on line 27
  51. Class Array does not exist
  52. Warning: ReflectionClass::__construct() expects exactly 1 parameter, 2 given in %s on line 33
  53. object(ReflectionClass)#%d (1) {
  54. ["name"]=>
  55. string(0) ""
  56. }
  57. Class X does not exist