note 101664 added to language.oop5.visibility

From: Date: Mon, 03 Jan 2011 16:15:47 +0000
Subject: note 101664 added to language.oop5.visibility
Groups: php.notes 
Request: Send a blank email to php-notes+get-175409@lists.php.net to get a copy of this message
<?php abstract class Foo { abstract protected function __construct(); } class Bar extends Foo { public function __construct() { } } $obj_bar = new Bar(); ?> Works... <?php abstract class Foo { abstract protected function __construct(); } class Bar extends Foo { protected function __construct() { } } $obj_bar = new Bar(); ?> Outputs: "Fatal error: Call to protected Bar::__construct() from invalid context" - as expected, because __construct() has to be public in this case.. But: <?php abstract class Foo { abstract protected function __construct(); } class Bar extends Foo { private function __construct() { } } $obj_bar = new Bar(); ?> Ouputs:"Fatal error: Access level to Bar::__construct() must be protected (as in class Foo) or weaker" I think "private" is weaker than "protected", isn't it? And: Should the concrete Class "Bar", wich extends "Foo" not have exactly the same visibility of __construct() as in "Foo"? ---- Server IP: 69.147.83.197 Probable Submitter: 93.212.203.79 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.visibility.php Edit -- https://master.php.net/note/edit/101664 Del: integrated -- https://master.php.net/note/delete/101664/integrated Del: useless -- https://master.php.net/note/delete/101664/useless Del: bad code -- https://master.php.net/note/delete/101664/bad+code Del: spam -- https://master.php.net/note/delete/101664/spam Del: non-english -- https://master.php.net/note/delete/101664/non-english Del: in docs -- https://master.php.net/note/delete/101664/in+docs Del: other reasons-- https://master.php.net/note/delete/101664 Reject -- https://master.php.net/note/reject/101664 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#175409) next »