|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-02-17 15:12 UTC] felipe@php.net
[2008-02-21 13:57 UTC] dmitry@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 03:00:01 2025 UTC |
Description: ------------ A class that is derived from a class with a private constructor and which does not provide its own constructor, can call the private parent constructor through a static function. Reproduce code: --------------- <?php class X { public $x; private function __construct($x) { $this->x = $x; } } class Y extends X { static public function cheat($x) { return new Y($x); } } $y = Y::cheat(5); echo $y->x, PHP_EOL; Expected result: ---------------- Fatal error: Call to private X::__construct() from invalid context ... Actual result: -------------- 5