From 9873ff107af2f9dea05ddb9a48b9c2d7abbfd5dc Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 20 Apr 2023 13:40:00 +1200 Subject: Remove remaining traces of PHP7 support The bulk of this was already removed in e3b112c69ceed5c39cb07fa45a3ba62b27712679. --- Examples/test-suite/php/default_args_runme.php | 26 ++++---- Examples/test-suite/php/director_classes_runme.php | 75 +++++++--------------- 2 files changed, 34 insertions(+), 67 deletions(-) (limited to 'Examples') diff --git a/Examples/test-suite/php/default_args_runme.php b/Examples/test-suite/php/default_args_runme.php index 31cbe0ff4..cf4932209 100644 --- a/Examples/test-suite/php/default_args_runme.php +++ b/Examples/test-suite/php/default_args_runme.php @@ -126,19 +126,17 @@ check::equal(chartest5(), "B", "chartest5()"); check::equal(chartest6(), "C", "chartest6()"); -if (PHP_MAJOR_VERSION >= 8) { - // Regression test for bug in initial implementation of PHP type declarations. - $p = (new ReflectionMethod('TrickyInPython', 'value_m1'))->getParameters(); - // empty array in buggy version - check::equal(count($p), 2, "Expected 2 parameters"); - check::equal((string)$p[0]->getType(), 'int', "Expected int parameter"); - check::equal((string)$p[1]->getType(), 'int', "Expected int parameter"); - - $p = (new ReflectionMethod('EnumClass', 'blah'))->getParameters(); - // empty array in buggy version - check::equal(count($p), 2, "Expected 2 parameters"); - check::equal((string)$p[0]->getType(), 'int', "Expected int parameter"); - check::equal((string)$p[1]->getType(), 'int', "Expected int parameter"); -} +// Regression test for bug in initial implementation of PHP type declarations. +$p = (new ReflectionMethod('TrickyInPython', 'value_m1'))->getParameters(); +// empty array in buggy version +check::equal(count($p), 2, "Expected 2 parameters"); +check::equal((string)$p[0]->getType(), 'int', "Expected int parameter"); +check::equal((string)$p[1]->getType(), 'int', "Expected int parameter"); + +$p = (new ReflectionMethod('EnumClass', 'blah'))->getParameters(); +// empty array in buggy version +check::equal(count($p), 2, "Expected 2 parameters"); +check::equal((string)$p[0]->getType(), 'int', "Expected int parameter"); +check::equal((string)$p[1]->getType(), 'int', "Expected int parameter"); check::done(); diff --git a/Examples/test-suite/php/director_classes_runme.php b/Examples/test-suite/php/director_classes_runme.php index 937d0db3f..170e10f26 100644 --- a/Examples/test-suite/php/director_classes_runme.php +++ b/Examples/test-suite/php/director_classes_runme.php @@ -8,61 +8,30 @@ check::classes(array('director_classes', 'Base', 'BaseClass', 'Caller', 'Derived // New vars check::globals(array('PrintDebug')); -if (PHP_MAJOR_VERSION < 8) { - // Without type declarations since we don't generate them for PHP < 8 - // and we need to be compatible with method declarations in Base. - class PHPDerived extends Base { - function Val($x) { return $x; } - function Ref($x) { return $x; } - function Ptr($x) { return $x; } - function ConstPtrRef($x) { return $x; } - function FullyOverloaded($x) { - $rv = parent::FullyOverloaded($x); - $rv = preg_replace('/Base/', 'PHPDerived', $rv); - return $rv; - } - function SemiOverloaded($x) { - # this is going to be awkward because we can't really - # semi-overload in PHP, but we can sort of fake it. - if (!is_int($x)) { - return parent::SemiOverloaded($x); - } - $rv = parent::SemiOverloaded($x); - $rv = preg_replace('/Base/', 'PHPDerived', $rv); - return $rv; - } - function DefaultParms($x, $y = 1.1) { - $rv = parent::DefaultParms($x, $y); - $rv = preg_replace('/Base/', 'PHPDerived', $rv); - return $rv; - } +class PHPDerived extends Base { + function Val(DoubleHolder $x) { return $x; } + function Ref(DoubleHolder $x) { return $x; } + function Ptr(?DoubleHolder $x) { return $x; } + function ConstPtrRef(?DoubleHolder $x) { return $x; } + function FullyOverloaded($x) { + $rv = parent::FullyOverloaded($x); + $rv = preg_replace('/Base/', 'PHPDerived', $rv); + return $rv; } -} else { - class PHPDerived extends Base { - function Val(DoubleHolder $x) { return $x; } - function Ref(DoubleHolder $x) { return $x; } - function Ptr(?DoubleHolder $x) { return $x; } - function ConstPtrRef(?DoubleHolder $x) { return $x; } - function FullyOverloaded($x) { - $rv = parent::FullyOverloaded($x); - $rv = preg_replace('/Base/', 'PHPDerived', $rv); - return $rv; - } - function SemiOverloaded($x) { - # this is going to be awkward because we can't really - # semi-overload in PHP, but we can sort of fake it. - if (!is_int($x)) { - return parent::SemiOverloaded($x); - } - $rv = parent::SemiOverloaded($x); - $rv = preg_replace('/Base/', 'PHPDerived', $rv); - return $rv; - } - function DefaultParms(int $x, float $y = 1.1) { - $rv = parent::DefaultParms($x, $y); - $rv = preg_replace('/Base/', 'PHPDerived', $rv); - return $rv; + function SemiOverloaded($x) { + # this is going to be awkward because we can't really + # semi-overload in PHP, but we can sort of fake it. + if (!is_int($x)) { + return parent::SemiOverloaded($x); } + $rv = parent::SemiOverloaded($x); + $rv = preg_replace('/Base/', 'PHPDerived', $rv); + return $rv; + } + function DefaultParms(int $x, float $y = 1.1) { + $rv = parent::DefaultParms($x, $y); + $rv = preg_replace('/Base/', 'PHPDerived', $rv); + return $rv; } } -- cgit v1.2.1