Edit report at https://bugs.php.net/bug.php?id=54512&edit=1

 ID:                 54512
 Updated by:         ahar...@php.net
 Reported by:        gphilip at vipmail dot hu
 Summary:            Strict notice of different method signatures does
                     not appear for constructor
-Status:             Closed
+Status:             Not a bug
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Fedora 14
 PHP Version:        5.3.6
-Assigned To:        nikic
+Assigned To:        
 Block user comment: N
 Private report:     N



Previous Comments:
------------------------------------------------------------------------
[2012-04-13 20:45:12] ni...@php.net

Constructors are not affected by the Liskov substitution principle, thus they 
don't need to have a matching signature. See 
http://stackoverflow.com/questions/5490824/should-constructors-comply-with-the-liskov-substitution-principle
 for a bit of reasoning.

------------------------------------------------------------------------
[2011-04-12 10:42:38] gphilip at vipmail dot hu

Description:
------------
When a method signature is different in an inherited class and its parent, you 
get 
a strict notice (assuming they are turned on).

This does not happen with constructors.

Test script:
---------------
<?php

error_reporting( -1 );

class A
{
        public function __construct( $a )
        {       
        }
}

class B extends A
{
        public function __construct( array $a )
        {
        }
}

class C
{
        public function doSomething( $a )
        {
        }
}

class D extends C
{
        public function doSomething( array $a )
        {
        }
}


Expected result:
----------------
Strict Notice Declaration of B::__construct() should be compatible with that of 
A::__construct() in ...

Strict Notice Declaration of D::doSomething() should be compatible with that of 
C::doSomething() in ...

Actual result:
--------------
Strict Notice Declaration of D::doSomething() should be compatible with that of 
C::doSomething() in ...


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=54512&edit=1

Reply via email to