|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-01-21 18:52 UTC] dpa-bugs at aegee dot org
Description:
------------
<?php
class A { }
class B { public function m(A $a = NULL, $n) { echo "B.m";} };
class C extends B { public function m(A $a , $n) { echo "C.m";} };
$b = new B();
$b->m(new A(), $b);
$c = new C();
$c->m(new A(), $b);
?>
reports nothing, but shall report:
PHP Warning: Declaration of C::m(A $a, $n) should be compatible with B::m(A $a = NULL, $n) on line 4
Removing on both places $n reports correctly:
PHP Warning: Declaration of C::m(A $a) should be compatible with B::m(A $a = NULL) on line 4
Same with php 5.6.17.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 21:00:01 2025 UTC |
Another example that does not rely on optional-before-required arguments: class A { public function m(array $a = null) {} } class B extends A { public function m(array $a = []) {} }There are bugs in * zend_do_perform_type_hint_check (never verifies compatibility of zend_arg_info.allow_null) * zend_get_function_declaration The bugs in zend_get_function_declaration are because we make this assumption: if (i >= required && !arg_info->is_variadic) So do not generate the correct error message when you fix the type hint check. It's 8am on Monday morning ... someone else should have a go ...