ns_056.phpt 505 B

123456789101112131415161718192021222324252627282930
  1. --TEST--
  2. 056: type-hint compatibility in namespaces
  3. --FILE--
  4. <?php
  5. namespace test\ns1;
  6. use \SplObserver;
  7. class Foo implements SplObserver {
  8. function update(\SplSubject $x): void {
  9. echo "ok\n";
  10. }
  11. }
  12. class Bar implements \SplSubject {
  13. function attach(SplObserver $x): void {
  14. echo "ok\n";
  15. }
  16. function notify(): void {
  17. }
  18. function detach(SplObserver $x): void {
  19. }
  20. }
  21. $foo = new Foo();
  22. $bar = new Bar();
  23. $bar->attach($foo);
  24. $foo->update($bar);
  25. ?>
  26. --EXPECT--
  27. ok
  28. ok