|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-02-09 11:19 UTC] helly@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 19:00:02 2025 UTC |
Description: ------------ While it's no problem to change the visibility of a constructor (limit the visibility) when using the old way of declaring a constructor (function with the same name as the class), it's not possible to lower the visibility in a hierarchy where the constructors are named after the new standard : __construct() . The engine have to check whether the name is __construct() (what about __destruct()? ), and not to complain in this case that the visibility is lowered. The first example emits a fatal error. The second is perfectly valid. Reproduce code: --------------- php -r 'class a{public function __construct() {}} class b extends a {private function __construct(){}}' php -r 'class a{public function a() {}} class b extends a {private function b(){}}' Actual result: -------------- PHP Fatal error: Access level to b::__construct() must be public (as in class a) in Command line code on line 1