Skip to content

Commit 87202b7

Browse files
committed
Limit API check to only public methods
1 parent 688a046 commit 87202b7

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
Protocol Test That Protected And Private Methods Are Ignored
3+
--FILE--
4+
<?php
5+
6+
class Foo {
7+
public function bar($abc) {}
8+
}
9+
class Bar {
10+
public function bar($abc) {}
11+
protected function bar2() {}
12+
private function bar3() {}
13+
}
14+
15+
function foo(<Bar> $bar) {
16+
var_dump($bar);
17+
}
18+
19+
foo(new Foo);
20+
?>
21+
--EXPECT--
22+
object(Foo)#1 (0) {
23+
}

Zend/zend_operators.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1822,6 +1822,11 @@ static int protocol_check_function_implementation(void *function_entry TSRMLS_DC
18221822
zend_uint child_flags;
18231823
zend_uint protocol_flags = ((zend_function*) function_entry)->common.fn_flags;
18241824

1825+
if (protocol_flags & (ZEND_ACC_PRIVATE | ZEND_ACC_PROTECTED)) {
1826+
/* Skip the non-public API */
1827+
return ZEND_HASH_APPLY_KEEP;
1828+
}
1829+
18251830
TSRMLS_FETCH();
18261831
ce = va_arg(args, zend_class_entry*);
18271832
result = va_arg(args, zend_bool*);
@@ -1835,6 +1840,7 @@ static int protocol_check_function_implementation(void *function_entry TSRMLS_DC
18351840
return ZEND_HASH_APPLY_STOP;
18361841
}
18371842
child_flags = child->common.fn_flags;
1843+
18381844
if ((child_flags & ZEND_ACC_STATIC) != (protocol_flags & ZEND_ACC_STATIC)) {
18391845
*result = 0;
18401846
return ZEND_HASH_APPLY_STOP;

0 commit comments

Comments
 (0)