From:             sveta at microbecal dot com
Operating system: FreeBSD, WindowsXP
PHP version:      5.0.4
PHP Bug Type:     Scripting Engine problem
Bug description:  Type hinting incorrect behavior

Description:
------------
In my example type hinting in method foo() in child class is incompatible
with same method in parent class. But it still working with E_STRICT.

Reproduce code:
---------------
error_reporting(E_ALL | E_STRICT);

class A {}

abstract class B {
        protected $bar;
        
        public function foo($bar) {
                $this->bar = $bar;
                echo "some\n";
                return $this;
        }
}

class C extends B
{
        public function foo(A $bar)
        {
                $this->bar = $bar;
                
                echo "not expected\n";
                return $this;
        }
}

$c = new C;
$c->foo(new A);


Expected result:
----------------
Fatal error: Declaration of C::foo() must be compatible with that of
B::foo() 

Actual result:
--------------
not expected

-- 
Edit bug report at http://bugs.php.net/?id=33902&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=33902&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=33902&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=33902&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=33902&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=33902&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=33902&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=33902&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=33902&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=33902&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=33902&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=33902&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=33902&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=33902&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=33902&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=33902&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=33902&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=33902&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=33902&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=33902&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=33902&r=mysqlcfg

Reply via email to