Skip to content

Commit f82dd2c

Browse files
committed
Bug #62956: fixing private method signature validation
In inheritance, if both methods are private, don not enforce the same signature.
1 parent c111067 commit f82dd2c

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

Zend/tests/bug61761.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ class B extends A
1414
}
1515

1616
?>
17+
==DONE==
1718
--EXPECTF--
18-
Strict Standards: Declaration of B::test() should be compatible with A::test($a) in %sbug61761.php on line %d
19+
==DONE==

Zend/tests/bug62956.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Bug #62956: "incompatible" signatures for private methods should not cause E_STRICT
3+
--FILE--
4+
<?php
5+
class Base
6+
{
7+
private function test()
8+
{}
9+
}
10+
11+
class Extension extends Base
12+
{
13+
private function test($arg)
14+
{}
15+
}
16+
17+
?>
18+
==DONE==
19+
--EXPECT--
20+
==DONE==

Zend/zend_compile.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2935,6 +2935,11 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c
29352935
return 1;
29362936
}
29372937

2938+
/* If both methods are private do not enforce a signature */
2939+
if ((fe->common.fn_flags & ZEND_ACC_PRIVATE) && (proto->common.fn_flags & ZEND_ACC_PRIVATE)) {
2940+
return 1;
2941+
}
2942+
29382943
/* check number of arguments */
29392944
if (proto->common.required_num_args < fe->common.required_num_args
29402945
|| proto->common.num_args > fe->common.num_args) {

0 commit comments

Comments
 (0)