#50302 [Opn->Bgs]: final private function __construct
| From: | jani@php.net | Date: | Thu, 26 Nov 2009 10:10:55 +0000 |
| Subject: | #50302 [Opn->Bgs]: final private function __construct | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-145096@lists.php.net to get a copy of this message | ||
ID: 50302
Updated by: jani@php.net
Reported By: p dot reisinger at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
PHP Version: 5.3.1
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[2009-11-25 22:24:55] 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() {}
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50302&edit=1