bug44141.phpt 574 B

1234567891011121314151617181920212223242526272829
  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. --EXPECTF--
  23. Fatal error: Uncaught Error: Call to private X::__construct() from context 'Y' in %sbug44141.php:15
  24. Stack trace:
  25. #0 %s(%d): Y::cheat(5)
  26. #1 {main}
  27. thrown in %sbug44141.php on line 15