[php] Try again to fix default_args_runme.php for PHP7

This commit is contained in:
Olly Betts 2022-06-12 15:02:26 +12:00
commit cdcb8cc9ee

View file

@ -46,48 +46,50 @@ check::equal($f->double_if_void_ptr_is_null(7), 14, "\$f->double_if_void_ptr_is_
# an exception. We handle the older versions by suppressing the error with `@`, # an exception. We handle the older versions by suppressing the error with `@`,
# then checking for the created object being Null if the PHP version is < 7.3. # then checking for the created object being Null if the PHP version is < 7.3.
if (PHP_MAJOR_VERSION == 7) {
$old_error_handler = set_error_handler(function($n,$s,$f,$l){throw preg_match('/^Wrong parameter count/', $s) ? new ArgumentCountError($s) : new Error($s);});
}
try { try {
@$f = new Foo(1); $f = new Foo(1);
if (!(PHP_MAJOR_VERSION == 7 && PHP_MINOR_VERSION < 3 && $f === null)) check::fail("Foo::Foo ignore is not working");
check::fail("Foo::Foo ignore is not working");
} catch (ArgumentCountError $e) { } catch (ArgumentCountError $e) {
} }
try { try {
@$f = new Foo(1, 2); $f = new Foo(1, 2);
if (!(PHP_MAJOR_VERSION == 7 && PHP_MINOR_VERSION < 3 && $f === null)) check::fail("Foo::Foo ignore is not working");
check::fail("Foo::Foo ignore is not working");
} catch (ArgumentCountError $e) { } catch (ArgumentCountError $e) {
} }
try { try {
@$f = new Foo(1, 2, 3); $f = new Foo(1, 2, 3);
if (!(PHP_MAJOR_VERSION == 7 && PHP_MINOR_VERSION < 3 && $f === null)) check::fail("Foo::Foo ignore is not working");
check::fail("Foo::Foo ignore is not working");
} catch (ArgumentCountError $e) { } catch (ArgumentCountError $e) {
} }
try { try {
@$m = $f->meth(1); $m = $f->meth(1);
if (!(PHP_MAJOR_VERSION == 7 && PHP_MINOR_VERSION < 3 && $f === null)) check::fail("Foo::meth ignore is not working");
check::fail("Foo::meth ignore is not working");
} catch (Error $e) { } catch (Error $e) {
} }
try { try {
@$m = $f->meth(1, 2); $m = $f->meth(1, 2);
if (!(PHP_MAJOR_VERSION == 7 && PHP_MINOR_VERSION < 3 && $f === null)) check::fail("Foo::meth ignore is not working");
check::fail("Foo::meth ignore is not working");
} catch (Error $e) { } catch (Error $e) {
} }
try { try {
@$m = $f->meth(1, 2, 3); $m = $f->meth(1, 2, 3);
if (!(PHP_MAJOR_VERSION == 7 && PHP_MINOR_VERSION < 3 && $f === null)) check::fail("Foo::meth ignore is not working");
check::fail("Foo::meth ignore is not working");
} catch (Error $e) { } catch (Error $e) {
} }
if (PHP_MAJOR_VERSION == 7) {
set_error_handler($old_error_handler);
}
check::equal(Klass::inc(100, new Klass(22))->val, 122, "Klass::inc failed"); check::equal(Klass::inc(100, new Klass(22))->val, 122, "Klass::inc failed");
check::equal(klass::inc(100)->val, 99, "klass::inc failed"); check::equal(klass::inc(100)->val, 99, "klass::inc failed");