Skip to content

Signature is valid if there are less args #424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Zend/tests/argument_restriction_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Class Base {
}

class Sub extends Base {
public function &test() {
public function &test(array $bar) {
}
}
?>
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/argument_restriction_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Abstract Class Base {
}

class Sub extends Base {
public function test($foo, array &$bar) {
public function test($foo, array $bar) {
}
}
?>
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/argument_restriction_003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Abstract Class Base {
}

class Sub extends Base {
public function test() {
public function test(Bar $foo) {
}
}
?>
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/argument_restriction_005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Bug #55719 (Argument restriction should come with a more specific error message)
--FILE--
<?php
class Sub implements ArrayAccess {
public function offsetSet() {
public function offsetSet(array $foo) {
}
}
?>
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/bug47981.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set_error_handler("errh");

interface a{}
class b implements a { function f($a=1) {}}
class c extends b {function f() {}}
class c extends b {function f($a) {}}
?>
--EXPECTF--
string(60) "Declaration of c::f() should be compatible with b::f($a = 1)"
2 changes: 1 addition & 1 deletion Zend/tests/bug51421.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ abstract class TestInterface {
}

class Test extends TestInterface {
public function __construct() {}
public function __construct(OtherClass $var) {}
}

?>
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/bug64988.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Noisy1 extends Base1 {
}
}
class Smooth1 extends Noisy1 {
public function insert(array $data) {
public function insert(array $data, $option1) {
return parent::insert($data, count($data));
}
}
Expand Down
4 changes: 2 additions & 2 deletions Zend/tests/traits/bug60153.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ interface IFoo {
}

trait TFoo {
public function oneArgument() {}
public function oneArgument($a, $b) {}
}

class C implements IFoo {
use TFoo;
}

--EXPECTF--
Fatal error: Declaration of TFoo::oneArgument() must be compatible with IFoo::oneArgument($a) in %s on line %d
Fatal error: Declaration of TFoo::oneArgument($a, $b) must be compatible with IFoo::oneArgument($a) in %s on line %d
4 changes: 2 additions & 2 deletions Zend/tests/traits/bug60217b.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ trait TBroken1 {
}

trait TBroken2 {
public abstract function foo($a, $b = 0);
public abstract function foo($a, $b);
}

class CBroken {
Expand All @@ -23,4 +23,4 @@ $o = new CBroken;
$o->foo(1);

--EXPECTF--
Fatal error: Declaration of TBroken2::foo($a, $b = 0) must be compatible with TBroken1::foo($a) in %s on line %d
Fatal error: Declaration of TBroken2::foo($a, $b) must be compatible with TBroken1::foo($a) in %s on line %d
4 changes: 2 additions & 2 deletions Zend/tests/traits/bug60217c.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Bug #60217 (Requiring the same method from different traits and abstract methods
<?php

trait TBroken1 {
public abstract function foo($a, $b = 0);
public abstract function foo($a, $b);
}

trait TBroken2 {
Expand All @@ -23,4 +23,4 @@ $o = new CBroken;
$o->foo(1);

--EXPECTF--
Fatal error: Declaration of TBroken2::foo($a) must be compatible with TBroken1::foo($a, $b = 0) in %s on line %d
Fatal error: Declaration of TBroken2::foo($a) must be compatible with TBroken1::foo($a, $b) in %s on line %d
9 changes: 5 additions & 4 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -3115,7 +3115,7 @@ static void do_inherit_method(zend_function *function) /* {{{ */

static zend_bool zend_do_perform_implementation_check(const zend_function *fe, const zend_function *proto TSRMLS_DC) /* {{{ */
{
zend_uint i;
zend_uint i, num_args;

/* If it's a user function then arg_info == NULL means we don't have any parameters but
* we still need to do the arg number checks. We are only willing to ignore this for internal
Expand All @@ -3140,8 +3140,7 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c
}

/* check number of arguments */
if (proto->common.required_num_args < fe->common.required_num_args
|| proto->common.num_args > fe->common.num_args) {
if (proto->common.required_num_args < fe->common.required_num_args) {
return 0;
}

Expand All @@ -3157,7 +3156,9 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c
return 0;
}

for (i=0; i < proto->common.num_args; i++) {
num_args = MIN(proto->common.num_args, fe->common.num_args);

for (i = 0; i < num_args; i++) {
if (ZEND_LOG_XOR(fe->common.arg_info[i].class_name, proto->common.arg_info[i].class_name)) {
/* Only one has a type hint and the other one doesn't */
return 0;
Expand Down
3 changes: 2 additions & 1 deletion ext/standard/tests/filters/php_user_filter_01.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ class bar extends php_user_filter {
function onClose() {}
}
?>
===DONE===
--EXPECTF--
Strict Standards: Declaration of bar::filter() should be compatible with php_user_filter::filter($in, $out, &$consumed, $closing) in %s on line %d
===DONE===
6 changes: 3 additions & 3 deletions tests/classes/ctor_in_interface_02.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ZE2 A class constructor must keep the signature of all interfaces
<?php
interface constr1
{
function __construct();
function __construct($a, $b);
}

interface constr2 extends constr1
Expand All @@ -13,7 +13,7 @@ interface constr2 extends constr1

class implem12 implements constr2
{
function __construct()
function __construct($a, $b)
{
}
}
Expand All @@ -25,7 +25,7 @@ interface constr3

class implem13 implements constr1, constr3
{
function __construct()
function __construct($a, $b)
{
}
}
Expand Down
2 changes: 0 additions & 2 deletions tests/classes/inheritance_003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,4 @@ class B extends A
?>
===DONE===
--EXPECTF--

Strict Standards: Declaration of B::f() should be compatible with A::f($x) in %sinheritance_003.php on line %d
===DONE===
1 change: 0 additions & 1 deletion tests/classes/method_override_optional_arg_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,5 @@ $b->foo(1);

?>
--EXPECTF--
Strict Standards: Declaration of C::foo() should be compatible with A::foo($arg1 = 1) in %s on line %d
int(1)
int(3)
1 change: 0 additions & 1 deletion tests/classes/method_override_optional_arg_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ $b->foo();

?>
--EXPECTF--
Strict Standards: Declaration of B::foo() should be compatible with A::foo($arg = 1) in %s on line %d
foo