Edit report at http://bugs.php.net/bug.php?id=52783&edit=1
ID: 52783 Updated by: cataphr...@php.net Reported by: augustowebd at gmail dot com Summary: error on construct's Access level -Status: Open +Status: Bogus Type: Bug Package: *General Issues Operating System: Linux nvirus 2.6.28-19-generic PHP Version: 5.3.3 Block user comment: N 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 In PHP, constructors have the same checks as other methods on inheritance, with the exception mentioned in the manual (no arguments check, except if the constructor is specified in an interface). Previous Comments: ------------------------------------------------------------------------ [2010-09-06 16:45:20] augustowebd at gmail dot com Description: ------------ given an abstract class Foo which has a constructor public: abstract class Foo{ public function __construct (){ echo "Foor ::"; } } and a concrete class(Bar) that extends Foo, but the latter has its constructor protected: final class Bar extends { protected function __construct () { parent:: __construct (); echo "bar"; } } It generates a fatal error. This is expected behavior of normal methods, but not for constructors Test script: --------------- abstract class Foo{ public function __construct(){ echo "Foo::"; } } final class Bar extends Foo{ protecte function __construct(){ parent::__construct(); echo "bar"; } public static function bar(){ new self(); } } Bar::bar(); Expected result: ---------------- Foo::bar Actual result: -------------- Fatal error: Access level to Bar::__construct() must be public (as in class Foo) in /var/www/index.php on line 17 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52783&edit=1