From:             olivier at m2mobi dot com
Operating system: Windows/Linux
PHP version:      5.4.7
Package:          Class/Object related
Bug Type:         Bug
Bug description:Implemented abstract function with additional parameter having 
default value

Description:
------------
Implemented abstract function with additional parameter having default
value
doesn't cause any error.


Will output:

I am the first arg. I am the additional arg.
I am the first arg. I am the additional arg default value.


If no default value the script crash.


Test script:
---------------
<?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.") ;

Expected result:
----------------
FATAL ERROR thrown

Actual result:
--------------
Just works, addition of a third argument is ignored:

<?php

class ConcreteChild2 extends AbstractMother
{
    public function methodWithOneArg($arg, $arg2="I am the additional arg
default value.", $arg3="I am another arg default value.")
    {
        echo $arg." ".$arg2." ".$arg3 ;
    }
}
echo "<br>" ;echo "<br>" ;

$child2 = new ConcreteChild2() ;

$child->methodWithOneArg( "I am the first arg.", "I am the additional
arg.", "I am the other additional arg") ;
echo "<br>" ;
$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.
I am the first arg. I am the additional arg default value.

-- 
Edit bug report at https://bugs.php.net/bug.php?id=63247&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=63247&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=63247&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=63247&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=63247&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=63247&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=63247&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=63247&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=63247&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=63247&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=63247&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=63247&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=63247&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=63247&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63247&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=63247&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=63247&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=63247&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63247&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=63247&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=63247&r=mysqlcfg

Reply via email to