ns_092.phpt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. --TEST--
  2. Typed group use statements
  3. --FILE--
  4. <?php
  5. namespace Foo\Bar {
  6. class A { function __construct() {echo __METHOD__,"\n";} }
  7. class B { function __construct() {echo __METHOD__,"\n";} }
  8. function fiz(){ echo __FUNCTION__,"\n"; }
  9. function biz(){ echo __FUNCTION__,"\n"; }
  10. function buz(){ echo __FUNCTION__,"\n"; }
  11. const FOO = 1;
  12. const BAR = 2;
  13. }
  14. namespace Fiz\Biz\Buz {
  15. use function Foo\Bar\{
  16. fiz,
  17. biz,
  18. buz as boz,
  19. A // <- this one must fail
  20. };
  21. use const Foo\Bar\{
  22. FOO as FOZ,
  23. BAR,
  24. B // <- this one must fail
  25. };
  26. use Foo\Bar\{ A, B, const BAR as BOZ };
  27. function buz(){ echo __FUNCTION__,"\n"; }
  28. const FOO = 100;
  29. echo "==== MIXED ====\n";
  30. new A();
  31. new B();
  32. var_dump(BOZ);
  33. echo "===== CONSTANTS ====\n";
  34. var_dump(FOO);
  35. var_dump(FOZ);
  36. var_dump(BAR);
  37. var_dump(defined('B'));
  38. echo "===== FUNCTIONS ====\n";
  39. buz();
  40. fiz();
  41. biz();
  42. boz();
  43. A();
  44. }
  45. --EXPECTF--
  46. ==== MIXED ====
  47. Foo\Bar\A::__construct
  48. Foo\Bar\B::__construct
  49. int(2)
  50. ===== CONSTANTS ====
  51. int(100)
  52. int(1)
  53. int(2)
  54. bool(false)
  55. ===== FUNCTIONS ====
  56. Fiz\Biz\Buz\buz
  57. Foo\Bar\fiz
  58. Foo\Bar\biz
  59. Foo\Bar\buz
  60. Fatal error: Uncaught Error: Call to undefined function Foo\Bar\A() in %sns_092.php:45
  61. Stack trace:
  62. #0 {main}
  63. thrown in %sns_092.php on line 45