php.net |  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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: p dot reisinger at gmail dot com
New email:
PHP Version: OS:

 

 [2009-11-25 22:24 UTC] p dot reisinger at gmail dot com
Description:
------------
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() {}
}


Patches

Pull Requests

History

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


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 22:01:28 2024 UTC