private parent constructor callable through static function
| Bug #44141 | private parent constructor callable through static function | ||||
|---|---|---|---|---|---|
| Submitted: | 2008-02-17 06:09 UTC | Modified: | 2008-02-21 13:57 UTC | ||
| From: | B dot Steinbrink at gmx dot de | Assigned: | dmitry (profile) | ||
| Status: | Closed | Package: | Class/Object related | ||
| PHP Version: | 5.2.5 | OS: | Debian Linux | ||
| Private report: | No | CVE-ID: | None | ||
[2008-02-17 06:09 UTC] B dot Steinbrink at gmx dot de
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
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2008-02-21 13:57 UTC] dmitry@php.net