Skip to content

Commit 0618e33

Browse files
committed
Merge branch 'PHP-5.4' of git.php.net:/php-src into PHP-5.4
* 'PHP-5.4' of git.php.net:/php-src: Fixed bug #61761 ('Overriding' a private static method with a different signature causes crash)
2 parents d6394e6 + da6465a commit 0618e33

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

Zend/tests/bug61761.phpt

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Bug #61761 ('Overriding' a private static method with a different signature causes crash)
3+
--FILE--
4+
<?php
5+
6+
class A
7+
{
8+
private static function test($a) { }
9+
}
10+
11+
class B extends A
12+
{
13+
private static function test($a, $b) { }
14+
}
15+
16+
?>
17+
--EXPECTF--
18+
Strict Standards: Declaration of B::test() should be compatible with A::test($a) in %sbug61761.php on line %d

Zend/zend_compile.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -3260,11 +3260,11 @@ static void do_inheritance_check_on_method(zend_function *child, zend_function *
32603260

32613261
if (child->common.prototype && (child->common.prototype->common.fn_flags & ZEND_ACC_ABSTRACT)) {
32623262
if (!zend_do_perform_implementation_check(child, child->common.prototype TSRMLS_CC)) {
3263-
zend_error(E_COMPILE_ERROR, "Declaration of %s::%s() must be compatible with %s", ZEND_FN_SCOPE_NAME(child), child->common.function_name, zend_get_function_declaration(child->common.prototype TSRMLS_CC));
3263+
zend_error(E_COMPILE_ERROR, "Declaration of %s::%s() must be compatible with %s", ZEND_FN_SCOPE_NAME(child), child->common.function_name, zend_get_function_declaration(child->common.prototype? child->common.prototype : parent TSRMLS_CC));
32643264
}
32653265
} else if (EG(error_reporting) & E_STRICT || EG(user_error_handler)) { /* Check E_STRICT (or custom error handler) before the check so that we save some time */
32663266
if (!zend_do_perform_implementation_check(child, parent TSRMLS_CC)) {
3267-
char *method_prototype = zend_get_function_declaration(child->common.prototype TSRMLS_CC);
3267+
char *method_prototype = zend_get_function_declaration(child->common.prototype? child->common.prototype : parent TSRMLS_CC);
32683268
zend_error(E_STRICT, "Declaration of %s::%s() should be compatible with %s", ZEND_FN_SCOPE_NAME(child), child->common.function_name, method_prototype);
32693269
efree(method_prototype);
32703270
}

0 commit comments

Comments
 (0)