|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-09-06 18:01 UTC] cataphract@php.net
-Status: Open
+Status: Bogus
[2010-09-06 18:01 UTC] cataphract@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 08 21:00:02 2025 UTC |
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