|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50302 final private function __construct
Submitted: 2009-11-25 22:24 UTC Modified: 2009-11-26 10:10 UTC
From: p dot reisinger at gmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.3.1 OS:
Private report: No CVE-ID: None
 [2009-11-25 22:24 UTC] p dot reisinger at gmail dot com
When somebody creates final private constructor then the class that extends this class cannot have constructor at all, even though private methods shouldn't be visible outside of the class. So final private constructor shouldn't allow calling parent::__construct(), but creating constructor should be allowed.
The same happens if class has final private method, then no subclass can use method with the same name (I know that there is no point creating private final, but it seems a problem when there'll be final instance variables in the future, plus it is a problem with constructors).

As I understand, parent's constructor is not called automatically, 
(parent::__construct() needs to be called) because if parent's constructor is private but not final then the code works.

Reproduce code:
class Test {
    final private function __construct() {}

class SubTest extends Test {
    // private methods shouldn't be visible
    // and I am not calling parent::__construct();
    public function __construct() {}


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-11-26 10:10 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Sep 28 13:01:23 2020 UTC