|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38064 ignored constructor visibility
Submitted: 2006-07-11 11:56 UTC Modified: 2006-08-07 23:25 UTC
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: instance at o2 dot pl Assigned: helly
Status: Closed Package: Class/Object related
PHP Version: 5.1.* OS: *
Private report: No CVE-ID:
 [2006-07-11 11:56 UTC] instance at o2 dot pl
Private __construct() can be called form inherited class constructor via parent::__construct();

I'm not sure, this was not reported, but I didn't found any this kind.

Also in PHP version 5.2 this was occured (not by me).


Reproduce code:

class A{

private function __construct(){}

class B extends A{

public function __construct(){

$instance=new B();


Expected result:
Fatal error: Call to private method A::__construct() from context 'B'

Actual result:
no error - everything is fine


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-07-17 19:43 UTC]
It shouldn't even be possible to override a private/protected ctor with a public one.

Can you please take a look at it Marcus?

 [2006-08-07 23:25 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Fri Nov 27 02:01:29 2015 UTC