summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlly Betts <olly@survex.com>2023-04-20 13:40:00 +1200
committerOlly Betts <olly@survex.com>2023-04-20 13:45:30 +1200
commit9873ff107af2f9dea05ddb9a48b9c2d7abbfd5dc (patch)
tree1c58c8e505270638ab329004f50b729305a2b474
parenta5e025e22afa8c808349a759fdaba3f23ac6bee4 (diff)
downloadswig-9873ff107af2f9dea05ddb9a48b9c2d7abbfd5dc.tar.gz
Remove remaining traces of PHP7 support
The bulk of this was already removed in e3b112c69ceed5c39cb07fa45a3ba62b27712679.
-rw-r--r--Examples/test-suite/php/default_args_runme.php26
-rw-r--r--Examples/test-suite/php/director_classes_runme.php75
-rw-r--r--Lib/exception.i7
-rw-r--r--Lib/php/phpinterfaces.i6
-rw-r--r--Source/Modules/php.cxx14
5 files changed, 38 insertions, 90 deletions
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;
}
}
diff --git a/Lib/exception.i b/Lib/exception.i
index 5cdea58e8..665e24b7e 100644
--- a/Lib/exception.i
+++ b/Lib/exception.i
@@ -14,14 +14,9 @@
#ifdef SWIGPHP
%{
-#if PHP_MAJOR_VERSION >= 8
-# define SWIG_HANDLE_VALUE_ERROR_FOR_PHP8(code) code == SWIG_ValueError ? zend_ce_value_error :
-#else
-# define SWIG_HANDLE_VALUE_ERROR_FOR_PHP8(code)
-#endif
#define SWIG_exception(code, msg) do { zend_throw_exception( \
code == SWIG_TypeError ? zend_ce_type_error : \
- SWIG_HANDLE_VALUE_ERROR_FOR_PHP8(code) \
+ code == SWIG_ValueError ? zend_ce_value_error : \
code == SWIG_DivisionByZero ? zend_ce_division_by_zero_error : \
code == SWIG_SyntaxError ? zend_ce_parse_error : \
code == SWIG_OverflowError ? zend_ce_arithmetic_error : \
diff --git a/Lib/php/phpinterfaces.i b/Lib/php/phpinterfaces.i
index 5b1da8b79..e1029b645 100644
--- a/Lib/php/phpinterfaces.i
+++ b/Lib/php/phpinterfaces.i
@@ -54,9 +54,7 @@
#define SWIG_PHP_INTERFACE_JsonSerializable_HEADER "ext/json/php_json.h"
// New in PHP 8.0.
-#if PHP_MAJOR_VERSION >= 8
-# define SWIG_PHP_INTERFACE_Stringable_CE zend_ce_stringable
-# define SWIG_PHP_INTERFACE_Stringable_HEADER "zend_interfaces.h"
-#endif
+#define SWIG_PHP_INTERFACE_Stringable_CE zend_ce_stringable
+#define SWIG_PHP_INTERFACE_Stringable_HEADER "zend_interfaces.h"
%}
diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx
index 6f326c15b..b272aab81 100644
--- a/Source/Modules/php.cxx
+++ b/Source/Modules/php.cxx
@@ -147,19 +147,13 @@ static void SwigPHP_emit_pointer_type_registrations() {
Printf(s_wrappers, "}\n\n");
Printf(s_wrappers, "/* Implement __toString equivalent, since that worked for the old-style resource wrapped pointers. */\n");
- Append(s_wrappers, "#if PHP_MAJOR_VERSION < 8\n");
- Printf(s_wrappers, "static int swig_ptr_cast_object(zval *z, zval *retval, int type) {\n");
- Append(s_wrappers, "#elif PHP_MAJOR_VERSION > 8 || PHP_MINOR_VERSION >= 2\n");
+ Append(s_wrappers, "#if PHP_MAJOR_VERSION > 8 || PHP_MINOR_VERSION >= 2\n");
Printf(s_wrappers, "static ZEND_RESULT_CODE swig_ptr_cast_object(zend_object *zobj, zval *retval, int type) {\n");
Append(s_wrappers, "#else\n");
Printf(s_wrappers, "static int swig_ptr_cast_object(zend_object *zobj, zval *retval, int type) {\n");
Append(s_wrappers, "#endif\n");
Printf(s_wrappers, " if (type == IS_STRING) {\n");
- Append(s_wrappers, "#if PHP_MAJOR_VERSION < 8\n");
- Printf(s_wrappers, " swig_object_wrapper *obj = SWIG_Z_FETCH_OBJ_P(z);\n");
- Append(s_wrappers, "#else\n");
Printf(s_wrappers, " swig_object_wrapper *obj = swig_php_fetch_object(zobj);\n");
- Append(s_wrappers, "#endif\n");
Printv(s_wrappers, " ZVAL_NEW_STR(retval, zend_strpprintf(0, \"SWIGPointer(%p,owned=%d)\", obj->ptr, obj->newobject));\n", NIL);
Printf(s_wrappers, " return SUCCESS;\n");
Printf(s_wrappers, " }\n");
@@ -2394,16 +2388,10 @@ public:
const char *funcname = GetChar(n, "sym:name");
Append(w->code, "{\n");
- Append(w->code, "#if PHP_MAJOR_VERSION < 8\n");
- Printf(w->code, "zval swig_funcname;\n");
- Printf(w->code, "ZVAL_STRINGL(&swig_funcname, \"%s\", %d);\n", funcname, strlen(funcname));
- Printf(w->code, "call_user_function(EG(function_table), &swig_self, &swig_funcname, &swig_zval_result, %d, args);\n", idx);
- Append(w->code, "#else\n");
Printf(w->code, "zend_string *swig_funcname = zend_string_init(\"%s\", %d, 0);\n", funcname, strlen(funcname));
Append(w->code, "zend_function *swig_zend_func = zend_std_get_method(&Z_OBJ(swig_self), swig_funcname, NULL);\n");
Append(w->code, "zend_string_release(swig_funcname);\n");
Printf(w->code, "if (swig_zend_func) zend_call_known_instance_method(swig_zend_func, Z_OBJ(swig_self), &swig_zval_result, %d, args);\n", idx);
- Append(w->code, "#endif\n");
/* exception handling */
tm = Swig_typemap_lookup("director:except", n, Swig_cresult_name(), 0);