bug44141.phpt 561 B

123456789101112131415161718192021222324252627282930
  1. --TEST--
  2. Bug #44141 (private parent constructor callable through static function)
  3. --FILE--
  4. <?php
  5. class X
  6. {
  7. public $x;
  8. private function __construct($x)
  9. {
  10. $this->x = $x;
  11. }
  12. }
  13. class Y extends X
  14. {
  15. static public function cheat($x)
  16. {
  17. return new Y($x);
  18. }
  19. }
  20. $y = Y::cheat(5);
  21. echo $y->x, PHP_EOL;
  22. ?>
  23. --EXPECTF--
  24. Fatal error: Uncaught Error: Call to private X::__construct() from scope Y in %s:%d
  25. Stack trace:
  26. #0 %s(%d): Y::cheat(5)
  27. #1 {main}
  28. thrown in %sbug44141.php on line 15