note 61083 deleted from language.oop5.decon by levim

From: Date: Tue, 18 Mar 2014 02:08:47 +0000
Subject: note 61083 deleted from language.oop5.decon by levim
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-198916@lists.php.net to get a copy of this message
Note Submitter: developit at mail dot ru ---- as [kida at keymail dot it] said you can't weaken a visibility of constructor when extending some class. but suggested trick that uses both old and new constructor namimg syntaxes to weaken visibility from 'protected' to 'public' seems a little bit odd. allthough it works allright. declaring extended class as 'abstract' with 'public' constructor will do quite the same thing in a more elegant manner and without any syntax mess. <?php class A { public function __construct() { //do smth } } abstract class B extends A { public function __construct() { parent::__construct(); } } ?> thus, you avoid instanciating class B as if it had a protected contructor

« previous php.notes (#198916) next »