From 4c37294275e05fa4a0c20d65df82e49673f63f99 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 10 Mar 2025 11:17:27 +0800 Subject: [PATCH 1/6] Fix built-in php and composer install plugin error --- src/ZM/ConsoleApplication.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ZM/ConsoleApplication.php b/src/ZM/ConsoleApplication.php index 9c0a6308..8e632127 100644 --- a/src/ZM/ConsoleApplication.php +++ b/src/ZM/ConsoleApplication.php @@ -32,7 +32,11 @@ final class ConsoleApplication extends Application // 初始化 Composer 变量 if (file_exists(WORKING_DIR . '/runtime/composer.phar')) { echo '* Using native composer' . PHP_EOL; - putenv('COMPOSER_EXECUTABLE=' . WORKING_DIR . '/runtime/composer.phar'); + if (WORKING_DIR . '/runtime/php' === PHP_BINARY) { + putenv('COMPOSER_EXECUTABLE="' . WORKING_DIR . '/runtime/php ' . WORKING_DIR . '/runtime/composer.phar"'); + } else { + putenv('COMPOSER_EXECUTABLE="' . WORKING_DIR . '/runtime/composer.phar"'); + } } $this->registerCommandLoader(); From 2da5ef3db192115bafcd2d659d8e089853b5b5dd Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 10 Mar 2025 11:05:30 +0800 Subject: [PATCH 2/6] Update to PHP 8.4 compatible --- .php-cs-fixer.php | 2 ++ composer.json | 4 ++-- src/ZM/Bootstrap/HandleExceptions.php | 3 +-- tests/ZM/Event/EventProviderTest.php | 3 +++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 6dda3026..2f6ab9e3 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -68,6 +68,8 @@ return (new PhpCsFixer\Config()) 'php_unit_test_class_requires_covers' => false, 'fully_qualified_strict_types' => false, 'new_with_parentheses' => false, + 'operator_linebreak' => false, + 'php_unit_data_provider_method_order' => false, ]) ->setFinder( PhpCsFixer\Finder::create() diff --git a/composer.json b/composer.json index 021b2da5..bca05730 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,7 @@ "jangregor/phpstan-prophecy": "^1.0", "jetbrains/phpstorm-attributes": "^1.0", "mikey179/vfsstream": "^1.6", - "phpspec/prophecy-phpunit": "^2.0", + "phpspec/prophecy-phpunit": "^2.3", "phpstan/extension-installer": "^1.1", "phpstan/phpstan": "^1.1", "phpstan/phpstan-deprecation-rules": "^1.0", @@ -99,7 +99,7 @@ }, "scripts": { "analyse": "phpstan analyse --memory-limit 300M", - "cs-fix": "PHP_CS_FIXER_FUTURE_MODE=1 php-cs-fixer fix", + "cs-fix": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix", "test": "bin/phpunit-zm --no-coverage" } } diff --git a/src/ZM/Bootstrap/HandleExceptions.php b/src/ZM/Bootstrap/HandleExceptions.php index 2e4fcec1..425f87ad 100644 --- a/src/ZM/Bootstrap/HandleExceptions.php +++ b/src/ZM/Bootstrap/HandleExceptions.php @@ -20,7 +20,6 @@ class HandleExceptions implements Bootstrapper E_USER_ERROR => ['PHP Error: ', 'error'], E_USER_WARNING => ['PHP Warning: ', 'warning'], E_USER_NOTICE => ['PHP Notice: ', 'notice'], - E_STRICT => ['PHP Strict: ', 'notice'], E_RECOVERABLE_ERROR => ['PHP Recoverable Error: ', 'error'], E_DEPRECATED => ['PHP Deprecated: ', 'notice'], E_USER_DEPRECATED => ['PHP User Deprecated: ', 'notice'], @@ -30,7 +29,7 @@ class HandleExceptions implements Bootstrapper logger()->{$level_tip[1]}($error); // 如果 return false 则错误会继续递交给 PHP 标准错误处理 return true; - }, E_ALL | E_STRICT); + }); // 重载异常处理器 ExceptionHandler::getInstance()->overrideWith(new Handler()); diff --git a/tests/ZM/Event/EventProviderTest.php b/tests/ZM/Event/EventProviderTest.php index 28157a3b..ff3bd089 100644 --- a/tests/ZM/Event/EventProviderTest.php +++ b/tests/ZM/Event/EventProviderTest.php @@ -49,6 +49,9 @@ class EventProviderTest extends TestCase public function testAddEventListenerWithCallableArray(): void { + if (PHP_VERSION_ID >= 80400) { + $this->markTestSkipped('PHP 8.4.0 has a bug that cannot pass this test'); + } // no meaning for using ZMUtil, just for testing $event = new ZMUtil(); $callback = [$this, 'testAddEventListenerWithCallableArray']; From 3a05a0e6baabb149b313df3cb04b32f1d5ef2341 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 10 Mar 2025 11:07:21 +0800 Subject: [PATCH 3/6] Update to PHP 8.4 compatible --- src/ZM/Command/ProxyServerCommand.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ZM/Command/ProxyServerCommand.php b/src/ZM/Command/ProxyServerCommand.php index 164cd878..f42cee45 100644 --- a/src/ZM/Command/ProxyServerCommand.php +++ b/src/ZM/Command/ProxyServerCommand.php @@ -262,7 +262,6 @@ class ProxyServerCommand extends Command break; case CMD_UDP_ASSOCIATE: $connection->stage = STAGE_UDP_ASSOC; - var_dump('CMD_UDP_ASSOCIATE ' . ($this->config['udp_port'] ?? 2222)); if ($this->config['udp_port'] == 0) { $connection->udpWorker = new Worker('udp://0.0.0.0:0'); /* @phpstan-ignore-next-line */ @@ -274,7 +273,7 @@ class ProxyServerCommand extends Command $listenInfo = stream_socket_get_name($connection->udpWorker->getMainSocket(), false); [$bind_addr, $bind_port] = explode(':', $listenInfo); } else { - $bind_port = $this->config['udp_port'] ?? 2222; + $bind_port = $this->config['udp_port']; } $bind_addr = $this->config['wanIP'] ?? '192.168.1.1'; From 228762ce7b700f7ec1d1ea8791d475119d4f329f Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 10 Mar 2025 11:10:25 +0800 Subject: [PATCH 4/6] Update workflow lowest php version --- .github/workflows/build-release-artifacts.yml | 2 +- .github/workflows/coding-style.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- .github/workflows/test.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-release-artifacts.yml b/.github/workflows/build-release-artifacts.yml index d95e7d04..7f746675 100644 --- a/.github/workflows/build-release-artifacts.yml +++ b/.github/workflows/build-release-artifacts.yml @@ -19,7 +19,7 @@ jobs: - name: Setup PHP uses: sunxyw/workflows/setup-environment@main with: - php-version: 8.0 + php-version: 8.1 php-extensions: swoole, posix, json operating-system: ubuntu-latest use-cache: true diff --git a/.github/workflows/coding-style.yml b/.github/workflows/coding-style.yml index 9847a787..4add0e61 100644 --- a/.github/workflows/coding-style.yml +++ b/.github/workflows/coding-style.yml @@ -34,7 +34,7 @@ jobs: - name: Setup PHP uses: sunxyw/workflows/setup-environment@main with: - php-version: 8.0 + php-version: 8.1 php-extensions: swoole, posix, json operating-system: ubuntu-latest use-cache: true diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 0b813362..617c691d 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -34,7 +34,7 @@ jobs: - name: Setup PHP uses: sunxyw/workflows/setup-environment@main with: - php-version: 8.0 + php-version: 8.1 php-extensions: swoole, posix, json operating-system: ubuntu-latest use-cache: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ed09c156..d251b00f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,7 +33,7 @@ jobs: strategy: matrix: operating-system: [ ubuntu-latest, windows-latest, macos-latest ] - php-version: [ 8.0, 8.1, 8.2 ] + php-version: [ 8.1, 8.2, 8.3, 8.4 ] name: PHP ${{ matrix.php-version }} Test (${{ matrix.operating-system }}) runs-on: ${{ matrix.operating-system }} timeout-minutes: 10 From d5e18a72296df0cd7c1b1d02c4a4260dd6fdfc3f Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 10 Mar 2025 07:46:03 +0000 Subject: [PATCH 5/6] update api docs --- docs/.vuepress/public/doxy/class_z_m_1_1_framework.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/.vuepress/public/doxy/class_z_m_1_1_framework.html b/docs/.vuepress/public/doxy/class_z_m_1_1_framework.html index 980b65e3..60e9a3a2 100755 --- a/docs/.vuepress/public/doxy/class_z_m_1_1_framework.html +++ b/docs/.vuepress/public/doxy/class_z_m_1_1_framework.html @@ -131,7 +131,7 @@ Public 成员函数 - + @@ -522,7 +522,7 @@ Protected 属性

成员变量

const VERSION_ID = 724
const VERSION_ID = 725
 
const VERSION = '3.2.4'
 
- +
const VERSION_ID = 724const VERSION_ID = 725
From 5e3397e7ae0c97023cefecad9aae4f265aa4063e Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 10 Mar 2025 07:46:04 +0000 Subject: [PATCH 6/6] increment build number (build 726) --- src/ZM/Framework.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ZM/Framework.php b/src/ZM/Framework.php index 3cfa09a3..f3903cf7 100644 --- a/src/ZM/Framework.php +++ b/src/ZM/Framework.php @@ -47,7 +47,7 @@ class Framework use Singleton; /** @var int 版本ID */ - public const VERSION_ID = 725; + public const VERSION_ID = 726; /** @var string 版本名称 */ public const VERSION = '3.2.4';