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

 ID:               41461
 Updated by:       m...@php.net
 Reported by:      ralph at smashlabs dot com
 Summary:          E_STRICT notice when overriding methods not defined by
                   an Interface in hierarchy
-Status:           Verified
+Status:           Bogus
 Type:             Bug
 Package:          Class/Object related
 Operating System: *
 PHP Version:      5.*, 6CVS (2009-04-25)

 New Comment:

as stas said, E_STRICT needs to be set prior parsing the file


Previous Comments:
------------------------------------------------------------------------
[2009-11-03 18:17:55] markskilbeck at gmail dot com

PHP does not allow for method overloading.

------------------------------------------------------------------------
[2009-07-27 08:02:01] php at whoah dot net

Should this not be possible without errors or notices? I am 

overloading an overridden method. If memory serves me, I am able to do 

this in other OO languages (Java, .NET/C#).



class BaseClass {



        public function TestFunction ($parameter) {

                var_dump($parameter);

        }

}



class FooClass extends BaseClass {



        public function TestFunction () {

                parent::TestFunction('This is Foo');

        }

}



class BarClass extends BaseClass {



        public function TestFunction () {

                parent::TestFunction('This is Bar');

        }

}



$test = new FooClass();

$test->TestFunction();



$test = new BarClass();

$test->TestFunction();





Instead:



Strict Standards: Declaration of FooClass::TestFunction() should be 

compatible with that of BaseClass::TestFunction()



Strict Standards: Declaration of BarClass::TestFunction() should be 

compatible with that of BaseClass::TestFunction()

------------------------------------------------------------------------
[2008-08-08 19:57:45] s...@php.net

I took a look into it, here's some findings:



1. There's no difference between how arguments are matched with and
without interface. The difference is that with no interface binding
would happen in this case in compile time, so if your error reporting
did not have E_STRICT by default, error_reporting(E_ALL | E_STRICT) is
not executed and so the error is not seen.



2. someFunc($uno, $dos, $tres) is not a good replacement for
someFunc($uno, $dos) even ignoring the by-ref return, since it has extra
required argument. Making it not required should pass the strict check.



3. I think it can be allowed to override function that returns by-val
with function that returns by-ref, but not vice versa. 





------------------------------------------------------------------------
[2007-06-19 21:52:26] ralph at smashlabs dot com

Marcus,



After re-reading, I didn't think that I was clear in my original bug
report, so I attempted to clarify the matter (2 posts up).  I still
think this is a problem and that it hinders the usage of interfaces as
it restricts concrete classes from overriding methods introduced at the
abstract layer, not the interface layer.



If this is still by design, go ahead and close, but I wanted to make
absolutely sure as most people either do not care about E_STRICT, or
haven't run into the problem yet ;)



Thanks again,

Ralph

------------------------------------------------------------------------
[2007-05-28 17:53:41] ralph at smashlabs dot com

PS. I did check this with the internals list before I posted.. And I
think you actually confirmed it for me on the list



http://news.php.net/php.internals/29646



Thank you for your time,

-ralph

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


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    http://bugs.php.net/bug.php?id=41461


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

Reply via email to