note 61083 added to language.oop5.decon
| From: | developitatmaildotru at osu1 dot php dot net | Date: | Wed, 25 Jan 2006 10:32:02 +0000 |
| Subject: | note 61083 added to language.oop5.decon | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-102409@lists.php.net to get a copy of this message | ||
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
----
Server IP: 195.54.192.44
Probable Submitter: 213.147.37.165 (proxied: unknown)
----
Manual Page -- http://www.php.net/manual/en/language.oop5.decon.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+61083
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61083&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61083&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61083&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61083&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61083&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61083&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61083&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+61083&report=yes
Search -- http://master.php.net/manage/user-notes.php