Skip to content

Commit 08777e9

Browse files
pmmaganikic
authored andcommitted
Don't enforce LSP if prototype method is private
Fixes bug #72496.
1 parent 717a043 commit 08777e9

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ PHP NEWS
55
- Core:
66
. Fix bug #71936 (Segmentation fault destroying HTTP_RAW_POST_DATA).
77
(mike dot laspina at gmail dot com, Remi)
8+
. Fix bug #72496 (Cannot declare public method with signature incompatible
9+
with parent private method). (Pedro Magalhães)
810

911
- bz2:
1012
. Fix bug #72447 (Type Confusion in php_bz2_filter_create()). (gogil at

Zend/tests/bug72496.phpt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
--TEST--
2+
Bug #72496 (declare public method with signature incompatible with parent private method should not throw a warning)
3+
--FILE--
4+
<?php
5+
class Foo
6+
{
7+
private function getFoo()
8+
{
9+
return 'Foo';
10+
}
11+
12+
private function getBar()
13+
{
14+
return 'Bar';
15+
}
16+
17+
private function getBaz()
18+
{
19+
return 'Baz';
20+
}
21+
}
22+
23+
class Bar extends Foo
24+
{
25+
public function getFoo($extraArgument)
26+
{
27+
return $extraArgument;
28+
}
29+
30+
protected function getBar($extraArgument)
31+
{
32+
return $extraArgument;
33+
}
34+
35+
private function getBaz($extraArgument)
36+
{
37+
return $extraArgument;
38+
}
39+
}
40+
41+
echo "OK\n";
42+
--EXPECT--
43+
OK

Zend/zend_compile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3252,8 +3252,8 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c
32523252
return 1;
32533253
}
32543254

3255-
/* If both methods are private do not enforce a signature */
3256-
if ((fe->common.fn_flags & ZEND_ACC_PRIVATE) && (proto->common.fn_flags & ZEND_ACC_PRIVATE)) {
3255+
/* If the prototype method is private do not enforce a signature */
3256+
if (proto->common.fn_flags & ZEND_ACC_PRIVATE) {
32573257
return 1;
32583258
}
32593259

0 commit comments

Comments
 (0)