flaupretre / pecl-pcs

PHP Code Service
Other
25 stars 4 forks source link

PHP 8 compatibility on Windows #20

Open Jan-E opened 3 years ago

Jan-E commented 3 years ago

Is PHP8 compatibility in the planning? pecl-compat/compat.h should at least have this change:

diff --git a/pecl-compat/compat.h b/pecl-compat/compat.h
index eccc0b7..185cef8 100644
--- a/pecl-compat/compat.h
+++ b/pecl-compat/compat.h
@@ -83,7 +83,7 @@
 #  include <sys/stat.h>
 #endif

-#ifdef PHP_WIN32
+#if defined(_MSC_VER) && _MSC_VER < 1920
 #include <win32/php_stdint.h>
 #else
 #include <inttypes.h>

Ratio: win32/php_stdint.h does not exist anymore in PHP8, but the VS16 compiler does provide a inttypes.h. So we check if we are using a MSVC compiler and if it is a lower version than Visual Studio 2019 (or VS16).

Jan-E commented 3 years ago

There is also the issue that the TSRMLS macros have been removed in PHP8. They already did not do anything at all in PHP7, but they are gone completely now. A crude way to deal with this is just to define them:

diff --git a/pecl-compat/compat.h b/pecl-compat/compat.h
index eccc0b7..c37263b 100644
--- a/pecl-compat/compat.h
+++ b/pecl-compat/compat.h
@@ -83,12 +83,22 @@
 #  include <sys/stat.h>
 #endif

-#ifdef PHP_WIN32
+#if defined(_MSC_VER) && _MSC_VER < 1920
 #include <win32/php_stdint.h>
 #else
 #include <inttypes.h>
 #endif

+#ifndef TSRMLS_DC
+#define TSRMLS_DC
+#endif
+#ifndef TSRMLS_CC
+#define TSRMLS_CC
+#endif
+#ifndef TSRMLS_C
+#define TSRMLS_C
+#endif
+
 #if ZEND_EXTENSION_API_NO >= PHP_5_6_X_API_NO
 #include "zend_virtual_cwd.h"
 #else