Bug #46851 [Com]: Strict standards: Declaration of ... should be compatible with that of ...
| From: | luoziluojun at 126 dot com | Date: | Fri, 26 Aug 2016 02:29:08 +0000 |
| Subject: | Bug #46851 [Com]: Strict standards: Declaration of ... should be compatible with that of ... | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-203553@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=46851&edit=1
ID: 46851
Comment by: luoziluojun at 126 dot com
Reported by: oliver at teqneers dot de
Summary: Strict standards: Declaration of ... should be
compatible with that of ...
Status: Not a bug
Type: Bug
Package: Scripting Engine problem
Operating System: OpenSuSE 11.0
PHP Version: 5.2.8
Block user comment: N
Private report: N
New Comment:
it's not resolve at 2016/8/26
Previous Comments:
------------------------------------------------------------------------
[2015-01-21 16:01:59] t dot kmieliauskas at gmail dot com
Hey, 2008 called, they said they wanted their errors back!
Still valid in 5.5.12...
------------------------------------------------------------------------
[2015-01-21 16:01:52] t dot kmieliauskas at gmail dot com
Hey, 2008 called, they said they wanted their errors back!
Still valid in 5.5.12...
------------------------------------------------------------------------
[2012-02-11 19:10:18] ldr at ldrutledge dot com
I understand the discussion above. The warning is because some possible method calls may fail due to
incomplete knowledge at compile-time.
However this causes the warning:
class A { public function foo(StdClass $a) {;}}
class B extends A { public function foo($a) {;}}
as does this:
class A { public function foo($a) {;}}
class B extends A { public function foo(StdClass $a) {;}}
In the case of
function bar(A $a, A $b){$a->foo($b);}
The second form can fail at run-time, but the first can not and should not trigger the error.
------------------------------------------------------------------------
[2012-02-09 06:10:45] eyal dot t at zend dot com
was wondering why the order of the class declarations affects whether a notice
is given, that is while
abstract class B extends A {
public static function foo($str){ echo $str; }
}
abstract class A {
public static function foo(){ echo 'bar'; }
}
causes the strict standard notice to show, the reversed order does not:
abstract class A {
public static function foo(){ echo 'bar'; }
}
abstract class B extends A {
public static function foo($str){ echo $str; }
}
------------------------------------------------------------------------
[2011-08-03 21:32:13] josh dot x dot guthrie at gmail dot com
This is not a bug in PHP, this is a flaw in your understanding of PHP and how it
handles method overloading. If your child class inherits from the parent class
and you override one of the parent class's methods, you must still pass it the
same number of parameters. Ex:
abstract class B extends A {
public static function foo($str){ echo $str; }
}
abstract class A {
public static function foo(){ echo 'bar'; }
}
What you will notice is that class A has a method "foo" which takes no
parameters. We then extend A with class B which overrides the method "foo" and
gives it a parameter "$str". This method overload is causing the strict error.
If you want a fix, make the parameter optional and it should remove the strict
warning. This fix has been tested with the __autoload function for class
loading.
------------------------------------------------------------------------
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
https://bugs.php.net/bug.php?id=46851
--
Edit this bug report at https://bugs.php.net/bug.php?id=46851&edit=1