note 110300 added to language.oop5.abstract
| From: | olivier at m2mobi dot com | Date: | Tue, 09 Oct 2012 11:26:24 +0000 |
| Subject: | note 110300 added to language.oop5.abstract | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-191204@lists.php.net to get a copy of this message | ||
Extending abstract class with override of abstract method having additional parameters with default
value works while its not documented: is it borderline?
Example
<?php
<?php
abstract class AbstractMother
{
public abstract function methodWithOneArg( $arg );
}
class ConcreteChild extends AbstractMother
{
public function methodWithOneArg($arg, $arg2="I am the additional arg default value.")
{
echo $arg." ".$arg2 ;
}
}
$child = new ConcreteChild() ;
$child->methodWithOneArg( "I am the first arg.", "I am the additional arg.")
;
echo "<br>" ;
$child->methodWithOneArg("I am the first arg.") ;
?>
Will output:
I am the first arg. I am the additional arg.
I am the first arg. I am the additional arg default value.
no error is thrown
----
Server IP: 69.147.83.199
Probable Submitter: 188.65.166.78
----
Manual Page -- http://www.php.net/manual/en/language.oop5.abstract.php
Edit -- https://master.php.net/note/edit/110300
Del: integrated -- https://master.php.net/note/delete/110300/integrated
Del: useless -- https://master.php.net/note/delete/110300/useless
Del: bad code -- https://master.php.net/note/delete/110300/bad+code
Del: spam -- https://master.php.net/note/delete/110300/spam
Del: non-english -- https://master.php.net/note/delete/110300/non-english
Del: in docs -- https://master.php.net/note/delete/110300/in+docs
Del: other reasons-- https://master.php.net/note/delete/110300
Reject -- https://master.php.net/note/reject/110300
Search -- https://master.php.net/manage/user-notes.php