[php] Adjust #required params for subclass methods

If the same method name is implemented in a parent class then the
subclass can't have more required parameters than that or else we
get a compatibility error when the module is loaded.

The testsuite wasn't catching this problem because it was no longer
trying to load the modules for testcases without _runme.php, because
the mechanism to do that relied on there being a generated .php
wrapper, which we no longer have by default.  Fix that to provide a
regression test for this fix.

See #2151
This commit is contained in:
Olly Betts 2022-06-12 10:12:02 +12:00
commit 9cdf46e8c8
5 changed files with 29 additions and 15 deletions

View file

@ -68,18 +68,18 @@ missingtests: missingcpptests missingctests
@echo ' $(MULTI_CPP_TEST_CASES) '|grep -F -v ' $* ' >/dev/null ||\
$(MAKE) $*.multicpptest
# Runs the testcase. Tries to run testcase_runme.php, and if that's not
# found, runs testcase.php, except for multicpptests.
# Runs the testcase. Tries to run testcase_runme.php, and if that's not found,
# at least test that the module loads without errors, except for multicpptests.
run_testcase = \
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_EXTENSION=$(TARGETPREFIX)$*@PHP_SO@ PHP_SCRIPT=$(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL='$(RUNTOOL)' php_run; \
elif [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*.php -a ! -f $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list ]; then \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_EXTENSION=$(TARGETPREFIX)$*@PHP_SO@ PHP_SCRIPT=$(SCRIPTDIR)/$(SCRIPTPREFIX)$*.php RUNTOOL='$(RUNTOOL)' php_run; \
elif [ ! -f $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list ]; then \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_EXTENSION=$(TARGETPREFIX)$*@PHP_SO@ PHP_SCRIPT= RUNTOOL='$(RUNTOOL)' php_run; \
fi
# Clean: remove the generated .php file
# Clean: remove the generated PHP-specific files
%.clean:
@rm -f $*.php php_$*.h
@rm -f php_$*.h
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' php_clean

View file

@ -22,19 +22,19 @@ check::equal($a->ping(), "MyFoo::ping()", "MyFoo::ping failed");
check::equal($a->pong(), "Foo::pong();MyFoo::ping()", "MyFoo::pong failed");
class MyExample1 extends Example1 {
function Color($r, $g, $b) {
function Color($r, $g = NULL, $b = NULL) {
return $r;
}
}
class MyExample2 extends Example1 {
function Color($r, $g, $b) {
function Color($r, $g = NULL, $b = NULL) {
return $g;
}
}
class MyExample3 extends Example1 {
function Color($r, $g, $b) {
function Color($r, $g = NULL, $b = NULL) {
return $b;
}
}

View file

@ -26,7 +26,7 @@ class MyFoo extends Foo {
return $v;
}
function vsecond($v1, $v2) {
function vsecond($v1, $v2 = NULL) {
return $v2;
}
}