diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 693530b9ba..8cc776642e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,18 +20,14 @@ jobs: fail-fast: false matrix: swoole: - - version: 5.0-php8.2 + - version: 5.1-php8.2 postgresql_version: "" - - version: 5.0-php8.1 + - version: 5.1-php8.1 postgresql_version: "" - - version: 5.0-php8.0 + - version: 5.0-php8.2 postgresql_version: "" - - version: 4.8-php8.1 + - version: 5.0-php8.1 postgresql_version: "" - - version: 4.8-php8.0 - postgresql_version: "v4.8.0" - - version: 4.8-php7.4 - postgresql_version: "v4.8.0" roadrunner: [2.7.*] env: ENV_SERVICE: swoole @@ -112,8 +108,8 @@ jobs: fail-fast: false matrix: swoole: - - version: 4.8-php8.0 - postgresql_version: f5eda17f89d160d0a89ac7c5db4636bdaefd48e6 + - version: 5.1-php8.2 + postgresql_version: "" roadrunner: [2.7.*] env: ENV_SERVICE: swoole @@ -190,7 +186,7 @@ jobs: strategy: fail-fast: false matrix: - swoole-cli: [v5.0.3, v4.8.11] + swoole-cli: [v5.0.3] env: MYSQL_DOCKER_VERSION: "8.0" GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -281,14 +277,9 @@ jobs: strategy: fail-fast: false matrix: - php: ["7.4", "8.0", "8.1", "8.2"] - swoole: [v5.0.3, v4.8.13] + php: ["8.1", "8.2"] + swoole: [v5.1.0, v5.0.3] roadrunner: [2.7.*] - exclude: - - php: 7.4 - swoole: v5.0.3 - - php: 8.2 - swoole: v4.8.13 env: MYSQL_SERVER_PASSWORD: "root" PHP_VERSION: ${{ matrix.php }} @@ -407,7 +398,7 @@ jobs: strategy: fail-fast: false matrix: - php: ["7.4", "8.0", "8.1"] # 部分扩展还未在 pecl 发布 PHP 8.2 Windows 版扩展,所以无法测试 + php: ["8.1"] # 部分扩展还未在 pecl 发布 PHP 8.2 Windows 版扩展,所以无法测试 roadrunner: [2.7.*] extensions: [ @@ -483,92 +474,3 @@ jobs: - name: Print logs if: failure() run: php .github\print-logs.php - - # ci-php82: - # name: Linux PHP-${{ matrix.php }} Swoole-${{ matrix.swoole.version }} RoadRunner-${{ matrix.roadrunner }} - # runs-on: ubuntu-20.04 - # strategy: - # fail-fast: false - # matrix: - # php: [8.2.0RC3] - # swoole: - # # - version: v5.0.3 - # # postgresql_version: "" - # # - version: v4.8.13 - # # postgresql_version: "" - # - version: fix-curl-hook-php8.2 - # postgresql_version: "" - # roadrunner: [2.7.*] - # env: - # ENV_SERVICE: php - # POSTGRESQL_VERSION: ${{ matrix.swoole.postgresql_version }} - # PHP_VERSION: ${{ matrix.php }} - # SWOOLE_VERSION: ${{ matrix.swoole.version }} - # MYSQL_DOCKER_VERSION: "8.0" - # REDIS_SERVER_HOST: redis - # ROADRUNNER_DOCKER_VERSION: ${{ matrix.roadrunner }} - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # COMPOSER_ENV: --ignore-platform-reqs - # steps: - # - name: Checkout - # uses: actions/checkout@v2 - # - name: Cache dependencies - # uses: actions/cache@v2 - # with: - # path: /tmp/composer - # key: ${{ runner.os }}-composer-${{ matrix.swoole.version }}-${{ hashFiles('/composer.json') }} - # - name: Prepare - # uses: ./.github/actions/ci-prepare - # with: - # env: ${{ env.ENV_SERVICE }} - # - name: Test - # if: ${{ env.test_prepared && always() }} - # run: docker exec ${ENV_SERVICE} composer test - # - name: Test swoole - # if: ${{ env.test_prepared && always() }} - # run: docker exec ${ENV_SERVICE} composer test-swoole - # - name: Test workerman - # if: ${{ env.test_prepared && always() }} - # run: docker exec ${ENV_SERVICE} composer test-workerman - # - name: Test workerman-gateway - # if: ${{ env.test_prepared && always() }} - # run: docker exec ${ENV_SERVICE} composer test-workerman-gateway - # - name: Test roadrunner - # if: ${{ env.test_prepared && always() }} - # run: docker exec ${ENV_SERVICE} composer test-roadrunner - # - name: Test fpm - # if: ${{ env.test_prepared && always() }} - # run: docker exec ${ENV_SERVICE} composer test-fpm - # - name: Test jwt - # if: ${{ env.test_prepared && always() }} - # run: docker exec ${ENV_SERVICE} composer test-jwt - # - name: Test queue - # if: ${{ env.test_prepared && always() }} - # run: docker exec ${ENV_SERVICE} composer test-queue - # - name: Test amqp - # if: ${{ env.test_prepared && always() }} - # run: docker exec ${ENV_SERVICE} composer test-amqp - # - name: Test kafka - # if: ${{ env.test_prepared && always() }} - # run: docker exec ${ENV_SERVICE} composer test-kafka - # - name: Test grpc - # if: ${{ env.test_prepared && always() }} - # run: docker exec ${ENV_SERVICE} composer test-grpc - # - name: Test snowflake - # if: ${{ env.test_prepared && always() }} - # run: docker exec ${ENV_SERVICE} composer test-snowflake - # - name: Test mqtt - # if: ${{ env.test_prepared && always() }} - # run: docker exec ${ENV_SERVICE} composer test-mqtt - # - name: Test smarty - # if: ${{ env.test_prepared && always() }} - # run: docker exec ${ENV_SERVICE} composer test-smarty - # - name: Test pgsql - # if: ${{ env.test_prepared && always() }} - # run: docker exec ${ENV_SERVICE} composer test-pgsql - # - name: Test phar - # if: ${{ env.test_prepared && always() }} - # run: docker exec ${ENV_SERVICE} composer test-phar - # - name: Print logs - # if: failure() - # run: docker exec ${ENV_SERVICE} php .github/print-logs.php diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml index 3c8c85236c..4616bea86c 100644 --- a/.github/workflows/phpcs.yml +++ b/.github/workflows/phpcs.yml @@ -15,8 +15,8 @@ jobs: tests: runs-on: ubuntu-20.04 env: - SWOOLE_DOCKER_VERSION: 4.8-php7.4 - POSTGRESQL_VERSION: v4.8.0 + SWOOLE_DOCKER_VERSION: 5.0-php8.1 + POSTGRESQL_VERSION: "" ENV_SERVICE: swoole-only steps: - name: Checkout diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 4d0676facb..614bb5e116 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -17,10 +17,10 @@ jobs: strategy: fail-fast: false matrix: - swoole-docker: [4.8-php7.4] + swoole-docker: [5.0-php8.1] env: SWOOLE_DOCKER_VERSION: ${{ matrix.swoole-docker }} - POSTGRESQL_VERSION: v4.8.0 + POSTGRESQL_VERSION: "" ENV_SERVICE: swoole-only steps: - name: Checkout diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml index 916f7dd071..1a397f2415 100644 --- a/.github/workflows/rector.yml +++ b/.github/workflows/rector.yml @@ -17,10 +17,10 @@ jobs: strategy: fail-fast: false matrix: - swoole-docker: [4.8-php7.4] + swoole-docker: [5.0-php8.1] env: SWOOLE_DOCKER_VERSION: ${{ matrix.swoole-docker }} - POSTGRESQL_VERSION: v4.8.0 + POSTGRESQL_VERSION: "" ENV_SERVICE: swoole-only steps: - name: Checkout diff --git a/README.md b/README.md index 4ff7898924..fef3140188 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ [![Latest Version](https://img.shields.io/packagist/v/imiphp/imi.svg)](https://packagist.org/packages/imiphp/imi) ![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/imiphp/imi/ci.yml?branch=3.0) -[![Php Version](https://img.shields.io/badge/php-%3E=7.4-brightgreen.svg)](https://secure.php.net/) -[![Swoole Version](https://img.shields.io/badge/swoole-%3E=4.8.0-brightgreen.svg)](https://github.com/swoole/swoole-src) +[![Php Version](https://img.shields.io/badge/php-%3E=8.1-brightgreen.svg)](https://secure.php.net/) +[![Swoole Version](https://img.shields.io/badge/swoole-%3E=5.0-brightgreen.svg)](https://github.com/swoole/swoole-src) [![imi Doc](https://img.shields.io/badge/docs-passing-green.svg)](https://doc.imiphp.com/v3.0/) [![imi License](https://img.shields.io/badge/license-MulanPSL%202.0-brightgreen.svg)](https://github.com/imiphp/imi/blob/master/LICENSE) [![star](https://gitee.com/yurunsoft/IMI/badge/star.svg?theme=gvp)](https://gitee.com/yurunsoft/IMI/stargazers) @@ -92,9 +92,9 @@ imi 框架进阶教程——五子棋游戏开发(免费7集全)= 7.4 +* [PHP](https://php.net/) >= 8.1 * [Composer](https://getcomposer.org/) >= 2.0 -* [Swoole](https://www.swoole.com/) >= 4.8.0 +* [Swoole](https://www.swoole.com/) >= 5.0 * Redis、PDO 扩展 ## Docker diff --git a/composer.json b/composer.json index a073a56a06..ba40c4210e 100644 --- a/composer.json +++ b/composer.json @@ -4,31 +4,25 @@ "license": "MulanPSL-2.0", "description": "imi 是一款支持长连接微服务分布式的 PHP 开发框架,可在 PHP-FPM、Swoole、Workerman 和 RoadRunner 等多种容器环境下运行。它支持 HttpApi、WebSocket、TCP、UDP、MQTT 服务的开发。", "require": { - "php": ">=7.4", + "php": ">=8.1", "ext-json": "*", "composer-runtime-api": "^2.0", - "monolog/monolog": "^2.2", - "phpdocumentor/reflection-docblock": "^5.2", - "psr/container": "~1.1|~2.0", - "psr/http-message": "~1.0", + "monolog/monolog": "~3.0", + "phpdocumentor/reflection-docblock": "~5.3", + "psr/container": "~2.0", + "psr/http-message": "~1.1|~2.0", "psr/http-server-middleware": "~1.0", - "psr/log": "~1.0|~2.0|~3.0", - "psr/simple-cache": "~1.0|~2.0", + "psr/log": "~2.0|~3.0", + "psr/simple-cache": "~2.0|~3.0", "symfony/console": "^5.1|^6.0", "symfony/event-dispatcher": "^5.1|^6.0", - "symfony/polyfill-php80": "^1.23", "symfony/polyfill-php81": "^1.23", "symfony/polyfill-php82": "^1.26", "symfony/process": "^5.1|^6.0", - "vlucas/phpdotenv": "~5.3", + "vlucas/phpdotenv": "~5.5", "yurunsoft/doctrine-annotations": "^1.73.0" }, "require-dev": { - "psr/container": "~1.1.0", - "psr/http-message": "~1.0.0", - "psr/http-server-middleware": "~1.0.0", - "psr/log": "~1.0.0", - "psr/simple-cache": "~1.0.0", "composer/semver": "^3.3.2", "php-cs-fixer/shim": "~3.17.0", "phpstan/phpstan": "~1.8.0", @@ -36,14 +30,9 @@ "rector/rector": "~0.13", "symfony/polyfill-uuid": "^1.27", "yurunsoft/ide-helper": "~1.0", - "yurunsoft/yurun-http": "^4.0.0" - }, - "replace": { - "symfony/polyfill-php71": "*", - "symfony/polyfill-php72": "*", - "symfony/polyfill-php73": "*", - "symfony/polyfill-php74": "*" + "yurunsoft/yurun-http": "^5.0.0" }, + "replace": {}, "autoload": { "psr-4": { "Imi\\": "src/" @@ -98,16 +87,16 @@ ], "install-test": "@php --ri swoole && composer install && cd ../ && composer test", "test-swoole": "@php src/Components/swoole/bin/swoole-phpunit -c src/Components/swoole/tests/phpunit.xml", - "test-workerman": "@php src/Components/workerman/vendor/bin/phpunit -c src/Components/workerman/tests/phpunit.xml", - "test-workerman-gateway-w": "@php src/Components/workerman-gateway/vendor/bin/phpunit -c src/Components/workerman-gateway/tests/phpunit.xml --testsuite workerman", - "test-workerman-gateway-s": "@php src/Components/workerman-gateway/vendor/bin/phpunit -c src/Components/workerman-gateway/tests/phpunit.xml --testsuite swoole", + "test-workerman": "@php vendor/bin/phpunit -c src/Components/workerman/tests/phpunit.xml", + "test-workerman-gateway-w": "@php vendor/bin/phpunit -c src/Components/workerman-gateway/tests/phpunit.xml --testsuite workerman", + "test-workerman-gateway-s": "@php vendor/bin/phpunit -c src/Components/workerman-gateway/tests/phpunit.xml --testsuite swoole", "test-workerman-gateway": [ "@composer test-workerman-gateway-w", "@composer test-workerman-gateway-s" ], - "test-roadrunner": "@php src/Components/roadrunner/vendor/bin/phpunit -c src/Components/roadrunner/tests/phpunit.xml", - "test-fpm": "@php src/Components/fpm/vendor/bin/phpunit -c src/Components/fpm/tests/phpunit.xml", - "test-jwt": "@php src/Components/jwt/vendor/bin/phpunit -c src/Components/jwt/tests/phpunit.xml", + "test-roadrunner": "@php vendor/bin/phpunit -c src/Components/roadrunner/tests/phpunit.xml", + "test-fpm": "@php vendor/bin/phpunit -c src/Components/fpm/tests/phpunit.xml", + "test-jwt": "@php vendor/bin/phpunit -c src/Components/jwt/tests/phpunit.xml", "test-queue": "@php src/Components/swoole/bin/swoole-phpunit -c src/Components/queue/tests/phpunit.xml", "test-amqp": [ "AMQP_TEST_MODE=swoole php src/Components/swoole/bin/swoole-phpunit -c src/Components/amqp/tests/phpunit.xml", @@ -118,9 +107,9 @@ "KAFKA_TEST_MODE=workerman php src/Components/swoole/bin/swoole-phpunit -c src/Components/kafka/tests/phpunit.xml" ], "test-grpc": "@php src/Components/swoole/bin/swoole-phpunit -c src/Components/grpc/tests/phpunit.xml", - "test-snowflake": "@php src/Components/snowflake/vendor/bin/phpunit -c src/Components/snowflake/tests/phpunit.xml", + "test-snowflake": "@php vendor/bin/phpunit -c src/Components/snowflake/tests/phpunit.xml", "test-mqtt": "@php src/Components/swoole/bin/swoole-phpunit -c src/Components/mqtt/tests/phpunit.xml", - "test-smarty": "@php src/Components/smarty/vendor/bin/phpunit -c src/Components/smarty/tests/phpunit.xml", + "test-smarty": "@php vendor/bin/phpunit -c src/Components/smarty/tests/phpunit.xml", "test-pgsql": "@php src/Components/swoole/bin/swoole-phpunit -c src/Components/pgsql/tests/phpunit.xml", "test-phar": "@php src/Components/phar/tests/run-tests.php", "test-components": [ diff --git a/dev/test-coverage-actions.sh b/dev/test-coverage-actions.sh index b92ca22e11..e370a3ef41 100755 --- a/dev/test-coverage-actions.sh +++ b/dev/test-coverage-actions.sh @@ -53,9 +53,9 @@ elif [[ $testType = "components" ]]; then "snowflake" ) - test "workerman-gateway-workerman" "php $paramsXdebug -dxdebug.mode=coverage src/Components/workerman-gateway/vendor/bin/phpunit -c ./src/Components/workerman-gateway/tests/phpunit.xml --testsuite workerman --coverage-php=./dev/cover/workerman-gateway-coverage.php -v" + test "workerman-gateway-workerman" "php $paramsXdebug -dxdebug.mode=coverage vendor/bin/phpunit -c ./src/Components/workerman-gateway/tests/phpunit.xml --testsuite workerman --coverage-php=./dev/cover/workerman-gateway-coverage.php -v" - test "workerman-gateway-swoole" "php $paramsXdebug -dxdebug.mode=coverage src/Components/workerman-gateway/vendor/bin/phpunit -c ./src/Components/workerman-gateway/tests/phpunit.xml --testsuite swoole --coverage-php=./dev/cover/workerman-gateway-swoole-coverage.php -v" + test "workerman-gateway-swoole" "php $paramsXdebug -dxdebug.mode=coverage vendor/bin/phpunit -c ./src/Components/workerman-gateway/tests/phpunit.xml --testsuite swoole --coverage-php=./dev/cover/workerman-gateway-swoole-coverage.php -v" export AMQP_TEST_MODE=swoole test "amqp-swoole" "php $paramsXdebug -dxdebug.mode=coverage src/Components/swoole/bin/swoole-phpunit -c ./src/Components/amqp/tests/phpunit.xml --coverage-php=./dev/cover/amqp-swoole-coverage.php -v" @@ -75,7 +75,7 @@ fi for name in "${phpUnitCommands[@]}" do - cmd="php $paramsXdebug -dxdebug.mode=coverage src/Components/$name/vendor/bin/phpunit -c ./src/Components/$name/tests/phpunit.xml --coverage-php=./dev/cover/$name-coverage.php -v" + cmd="php $paramsXdebug -dxdebug.mode=coverage vendor/bin/phpunit -c ./src/Components/$name/tests/phpunit.xml --coverage-php=./dev/cover/$name-coverage.php -v" test "$name" "$cmd" done diff --git a/dev/test-coverage.sh b/dev/test-coverage.sh index ed638a8573..363492e432 100755 --- a/dev/test-coverage.sh +++ b/dev/test-coverage.sh @@ -47,7 +47,7 @@ swoolePhpUnitCommands=( for name in "${phpUnitCommands[@]}" do - cmd="php $paramsXdebug -dxdebug.mode=coverage src/Components/$name/vendor/bin/phpunit -c ./src/Components/$name/tests/phpunit.xml --coverage-php=./dev/cover/$name-coverage.php -v" + cmd="php $paramsXdebug -dxdebug.mode=coverage vendor/bin/phpunit -c ./src/Components/$name/tests/phpunit.xml --coverage-php=./dev/cover/$name-coverage.php -v" test "$name" "$cmd" done @@ -69,8 +69,8 @@ test "kafka-swoole" "php $paramsXdebug -dxdebug.mode=coverage src/Components/swo export KAFKA_TEST_MODE=workerman test "kafka-workerman" "php $paramsXdebug -dxdebug.mode=coverage src/Components/swoole/bin/swoole-phpunit -c ./src/Components/kafka/tests/phpunit.xml --coverage-php=./dev/cover/kafka-workerman-coverage.php -v" -test "workerman-gateway-workerman" "php $paramsXdebug -dxdebug.mode=coverage src/Components/workerman-gateway/vendor/bin/phpunit -c ./src/Components/workerman-gateway/tests/phpunit.xml --testsuite workerman --coverage-php=./dev/cover/workerman-gateway-coverage.php -v" +test "workerman-gateway-workerman" "php $paramsXdebug -dxdebug.mode=coverage vendor/bin/phpunit -c ./src/Components/workerman-gateway/tests/phpunit.xml --testsuite workerman --coverage-php=./dev/cover/workerman-gateway-coverage.php -v" -test "workerman-gateway-swoole" "php $paramsXdebug -dxdebug.mode=coverage src/Components/workerman-gateway/vendor/bin/phpunit -c ./src/Components/workerman-gateway/tests/phpunit.xml --testsuite swoole --coverage-php=./dev/cover/workerman-gateway-swoole-coverage.php -v" +test "workerman-gateway-swoole" "php $paramsXdebug -dxdebug.mode=coverage vendor/bin/phpunit -c ./src/Components/workerman-gateway/tests/phpunit.xml --testsuite swoole --coverage-php=./dev/cover/workerman-gateway-swoole-coverage.php -v" php dev/merge-coverage.php $1 diff --git a/doc/README.md b/doc/README.md index cd81f211e9..9abb57d6fe 100644 --- a/doc/README.md +++ b/doc/README.md @@ -2,7 +2,7 @@ ![imi logo](https://cdn.jsdelivr.net/gh/imiphp/imi@3.0/res/logo.png) -[![Latest Version](https://img.shields.io/packagist/v/imiphp/imi.svg)](https://packagist.org/packages/imiphp/imi) ![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/imiphp/imi/ci.yml?branch=3.0) [![Php Version](https://img.shields.io/badge/php-%3E=7.4-brightgreen.svg)](https://secure.php.net/) [![Swoole Version](https://img.shields.io/badge/swoole-%3E=4.8.0-brightgreen.svg)](https://github.com/swoole/swoole-src) [![imi Doc](https://img.shields.io/badge/docs-passing-green.svg)](/v3.0/) [![imi License](https://img.shields.io/badge/license-MulanPSL%202.0-brightgreen.svg)](https://github.com/imiphp/imi/blob/master/LICENSE) [![star](https://gitee.com/yurunsoft/IMI/badge/star.svg?theme=gvp)](https://gitee.com/yurunsoft/IMI/stargazers) +[![Latest Version](https://img.shields.io/packagist/v/imiphp/imi.svg)](https://packagist.org/packages/imiphp/imi) ![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/imiphp/imi/ci.yml?branch=3.0) [![Php Version](https://img.shields.io/badge/php-%3E=8.1-brightgreen.svg)](https://secure.php.net/) [![Swoole Version](https://img.shields.io/badge/swoole-%3E=5.0.0-brightgreen.svg)](https://github.com/swoole/swoole-src) [![imi Doc](https://img.shields.io/badge/docs-passing-green.svg)](/v3.0/) [![imi License](https://img.shields.io/badge/license-MulanPSL%202.0-brightgreen.svg)](https://github.com/imiphp/imi/blob/master/LICENSE) [![star](https://gitee.com/yurunsoft/IMI/badge/star.svg?theme=gvp)](https://gitee.com/yurunsoft/IMI/stargazers) ## 介绍 @@ -81,9 +81,9 @@ imi 框架进阶教程——五子棋游戏开发(免费7集全)= 7.4 +* [PHP](https://php.net/) >= 8.1 * [Composer](https://getcomposer.org/) >= 2.0 -* [Swoole](https://www.swoole.com/) >= 4.8.0 +* [Swoole](https://www.swoole.com/) >= 5.0.0 * Redis、PDO 扩展 ## Docker diff --git a/doc/base/env.md b/doc/base/env.md index 3d27adb7a5..8648fab5d0 100644 --- a/doc/base/env.md +++ b/doc/base/env.md @@ -5,9 +5,9 @@ ## 运行环境 - Linux 系统 (Swoole 不支持在 Windows 上运行) -- [PHP](https://php.net/) >= 7.4 +- [PHP](https://php.net/) >= 8.1 - [Composer](https://getcomposer.org/) >= 2.0 -- [Swoole](https://www.swoole.com/) >= 4.8.0 +- [Swoole](https://www.swoole.com/) >= 5.0.0 - Redis、PDO 扩展 ## Windows 开发者 diff --git a/doc/base/qa.md b/doc/base/qa.md index 716fc1c57c..ad0835cffa 100644 --- a/doc/base/qa.md +++ b/doc/base/qa.md @@ -4,7 +4,7 @@ ## 通过 `composer create-project` 创建项目报错问题 -**解决方案:** 请确保你的环境依赖版本符合要求:PHP >= 7.4 && Composer >= 2.0 +**解决方案:** 请确保你的环境依赖版本符合要求:PHP >= 8.1 && Composer >= 2.0 查看命令:`php -v && composer -V` @@ -14,7 +14,7 @@ ## Composer 引入 `imi-swoole` 组件报错 -**解决方案:** 请确保你的 Swoole >= 4.8.0 +**解决方案:** 请确保你的 Swoole >= 5.0.0 查看命令:`php --ri swoole` diff --git a/doc/components/aop/index.md b/doc/components/aop/index.md index d09c757bfb..106bf3aebe 100644 --- a/doc/components/aop/index.md +++ b/doc/components/aop/index.md @@ -409,7 +409,7 @@ class TestClass protected $model2; /** - * 某Model对象,通过 PHP 7.4 以上类型声明注入 + * 某Model对象,类型声明注入 * @Inject */ protected XXX\Model\User $model3; diff --git a/doc/components/mqtt/client.md b/doc/components/mqtt/client.md index a5129588de..92637f7843 100644 --- a/doc/components/mqtt/client.md +++ b/doc/components/mqtt/client.md @@ -16,8 +16,6 @@ ] ``` -> MQTT 功能要求 PHP >= 7.4 - ## 使用 **事件监听类:** diff --git a/doc/production/docker.md b/doc/production/docker.md index 3a393a6627..c4494dbc3c 100644 --- a/doc/production/docker.md +++ b/doc/production/docker.md @@ -14,7 +14,7 @@ ```yml # 版本也可以自行修改 -FROM phpswoole/swoole:4.8-php7.4 +FROM phpswoole/swoole:5.0-php8.2 RUN apt update && apt install unzip @@ -33,7 +33,7 @@ RUN pecl install redis && docker-php-ext-enable redis ```yml # 版本也可以自行修改 -FROM php:7.4-cli +FROM php:8.2-cli RUN apt update && apt install unzip libevent-dev libssl-dev @@ -58,7 +58,7 @@ RUN curl -o /usr/bin/composer https://getcomposer.org/composer.phar && chmod +x ```yml # 版本也可以自行修改 -FROM php:7.4 +FROM php:8.2 RUN apt update && apt install unzip diff --git a/phpstan-components.neon b/phpstan-components.neon index 8b812be6d2..094c06c0a6 100644 --- a/phpstan-components.neon +++ b/phpstan-components.neon @@ -1,7 +1,7 @@ parameters: level: 6 - phpVersion: 80000 + phpVersion: 80100 paths: - src/Components @@ -11,7 +11,7 @@ parameters: - src/Components/grpc/example/grpc - src/Components/smarty/src/smarty-plugins - src/Components/swoole/src/Process/Process.php - - src/Components/pgsql/src/Db/Drivers/SwooleNew + - src/Components/pgsql/src/Db/Drivers/Swoole - src/Components/phar/src/Ignore bootstrapFiles: diff --git a/phpstan.neon b/phpstan.neon index c90a791360..d1d94bed6e 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,7 +1,7 @@ parameters: level: 6 - phpVersion: 80000 + phpVersion: 80100 paths: - src diff --git a/split-repository/composer.json b/split-repository/composer.json index c0a567eda8..ca0f91db54 100644 --- a/split-repository/composer.json +++ b/split-repository/composer.json @@ -2,8 +2,7 @@ "require": { "knplabs/github-api": "^3.0", "guzzlehttp/guzzle": "^7.0.1", - "http-interop/http-factory-guzzle": "^1.0", - "psr/http-message": "~1.0" + "http-interop/http-factory-guzzle": "^1.0" }, "autoload": { "psr-4": { diff --git a/src/Bean/ReflectionUtil.php b/src/Bean/ReflectionUtil.php index 01c16c7bf7..57712d2339 100644 --- a/src/Bean/ReflectionUtil.php +++ b/src/Bean/ReflectionUtil.php @@ -26,7 +26,7 @@ public static function getTypeComments(?\ReflectionType $type, ?string $classNam $typeStr = '\\' . $className; } } - else + elseif ('static' !== $typeStr) { $typeStr = '\\' . $typeStr; } @@ -96,7 +96,7 @@ public static function getTypeCode(?\ReflectionType $type, ?string $className = $typeStr = '\\' . $className; } } - else + elseif ('static' !== $typeStr) { $typeStr = '\\' . $typeStr; } diff --git a/src/Cache/Handler/Apcu.php b/src/Cache/Handler/Apcu.php index 2a7030e936..0df40499d3 100644 --- a/src/Cache/Handler/Apcu.php +++ b/src/Cache/Handler/Apcu.php @@ -19,7 +19,7 @@ class Apcu extends Base /** * {@inheritDoc} */ - public function get($key, $default = null) + public function get(string $key, mixed $default = null): mixed { $result = apcu_fetch($this->parseKey($key), $success); if ($success) @@ -35,7 +35,7 @@ public function get($key, $default = null) /** * {@inheritDoc} */ - public function set($key, $value, $ttl = null) + public function set(string $key, mixed $value, null|int|\DateInterval $ttl = null): bool { return apcu_store($this->parseKey($key), $value, (int) $ttl); } @@ -43,7 +43,7 @@ public function set($key, $value, $ttl = null) /** * {@inheritDoc} */ - public function delete($key) + public function delete(string $key): bool { return apcu_delete($this->parseKey($key)); } @@ -51,7 +51,7 @@ public function delete($key) /** * {@inheritDoc} */ - public function clear() + public function clear(): bool { return apcu_clear_cache(); } @@ -59,7 +59,7 @@ public function clear() /** * {@inheritDoc} */ - public function getMultiple($keys, $default = null) + public function getMultiple(iterable $keys, mixed $default = null): iterable { $result = []; foreach ($keys as $key) @@ -73,7 +73,7 @@ public function getMultiple($keys, $default = null) /** * {@inheritDoc} */ - public function setMultiple($values, $ttl = null) + public function setMultiple(iterable $values, null|int|\DateInterval $ttl = null): bool { $newValues = []; foreach ($values as $k => $v) @@ -87,7 +87,7 @@ public function setMultiple($values, $ttl = null) /** * {@inheritDoc} */ - public function deleteMultiple($keys) + public function deleteMultiple(iterable $keys): bool { $newKeys = []; foreach ($keys as $key) @@ -101,7 +101,7 @@ public function deleteMultiple($keys) /** * {@inheritDoc} */ - public function has($key) + public function has(string $key): bool { return apcu_exists($this->parseKey($key)); } diff --git a/src/Cache/Handler/File.php b/src/Cache/Handler/File.php index 41c84ae6ab..4624802c47 100644 --- a/src/Cache/Handler/File.php +++ b/src/Cache/Handler/File.php @@ -36,7 +36,7 @@ class File extends Base /** * {@inheritDoc} */ - public function get($key, $default = null) + public function get(string $key, mixed $default = null): mixed { $this->checkKey($key); $fileName = $this->getFileName($key); @@ -86,7 +86,7 @@ public function get($key, $default = null) /** * {@inheritDoc} */ - public function set($key, $value, $ttl = null) + public function set(string $key, mixed $value, null|int|\DateInterval $ttl = null): bool { $this->checkKey($key); $fileName = $this->getFileName($key); @@ -135,7 +135,7 @@ public function set($key, $value, $ttl = null) /** * {@inheritDoc} */ - public function delete($key) + public function delete(string $key): bool { $this->checkKey($key); $fileName = $this->getFileName($key); @@ -159,7 +159,7 @@ public function delete($key) /** * {@inheritDoc} */ - public function clear() + public function clear(): bool { foreach (FileUtil::enumAll($this->savePath) as $fileIterator) { @@ -180,7 +180,7 @@ public function clear() /** * {@inheritDoc} */ - public function getMultiple($keys, $default = null) + public function getMultiple(iterable $keys, mixed $default = null): iterable { $this->checkArrayOrTraversable($keys); $result = []; @@ -195,7 +195,7 @@ public function getMultiple($keys, $default = null) /** * {@inheritDoc} */ - public function setMultiple($values, $ttl = null) + public function setMultiple(iterable $values, null|int|\DateInterval $ttl = null): bool { $this->checkArrayOrTraversable($values); $result = true; @@ -215,7 +215,7 @@ public function setMultiple($values, $ttl = null) /** * {@inheritDoc} */ - public function deleteMultiple($keys) + public function deleteMultiple(iterable $keys): bool { $this->checkArrayOrTraversable($keys); $result = true; @@ -230,7 +230,7 @@ public function deleteMultiple($keys) /** * {@inheritDoc} */ - public function has($key) + public function has(string $key): bool { $this->checkKey($key); $fileName = $this->getFileName($key); diff --git a/src/Cache/Handler/Memory.php b/src/Cache/Handler/Memory.php index aa7b3c85e8..a6f4103fa8 100644 --- a/src/Cache/Handler/Memory.php +++ b/src/Cache/Handler/Memory.php @@ -27,7 +27,7 @@ public function __construct(array $option = []) /** * {@inheritDoc} */ - public function get($key, $default = null) + public function get(string $key, mixed $default = null): mixed { return self::$storage->get($key, $default); } @@ -35,7 +35,7 @@ public function get($key, $default = null) /** * {@inheritDoc} */ - public function set($key, $value, $ttl = null) + public function set(string $key, mixed $value, null|int|\DateInterval $ttl = null): bool { // ttl 支持 \DateInterval 格式 if ($ttl instanceof \DateInterval) @@ -50,7 +50,7 @@ public function set($key, $value, $ttl = null) /** * {@inheritDoc} */ - public function delete($key) + public function delete(string $key): bool { self::$storage->unset($key); @@ -60,7 +60,7 @@ public function delete($key) /** * {@inheritDoc} */ - public function clear() + public function clear(): bool { self::$storage->clear(); @@ -70,7 +70,7 @@ public function clear() /** * {@inheritDoc} */ - public function getMultiple($keys, $default = null) + public function getMultiple(iterable $keys, mixed $default = null): iterable { $this->checkArrayOrTraversable($keys); $object = self::$storage; @@ -86,7 +86,7 @@ public function getMultiple($keys, $default = null) /** * {@inheritDoc} */ - public function setMultiple($values, $ttl = null) + public function setMultiple(iterable $values, null|int|\DateInterval $ttl = null): bool { $this->checkArrayOrTraversable($values); // ttl 支持 \DateInterval 格式 @@ -106,7 +106,7 @@ public function setMultiple($values, $ttl = null) /** * {@inheritDoc} */ - public function deleteMultiple($keys) + public function deleteMultiple(iterable $keys): bool { $this->checkArrayOrTraversable($keys); $object = self::$storage; @@ -121,7 +121,7 @@ public function deleteMultiple($keys) /** * {@inheritDoc} */ - public function has($key) + public function has(string $key): bool { return self::$storage->isset($key); } diff --git a/src/Cache/Handler/Redis.php b/src/Cache/Handler/Redis.php index 2da4528356..ab81e49a0e 100644 --- a/src/Cache/Handler/Redis.php +++ b/src/Cache/Handler/Redis.php @@ -31,7 +31,7 @@ class Redis extends Base /** * {@inheritDoc} */ - public function get($key, $default = null) + public function get(string $key, mixed $default = null): mixed { $this->checkKey($key); $result = ImiRedis::use(fn (\Imi\Redis\RedisHandler $redis) => $redis->get($this->parseKey($key)), $this->poolName, true); @@ -48,7 +48,7 @@ public function get($key, $default = null) /** * {@inheritDoc} */ - public function set($key, $value, $ttl = null) + public function set(string $key, mixed $value, null|int|\DateInterval $ttl = null): bool { $this->checkKey($key); // ttl 支持 \DateInterval 格式 @@ -63,7 +63,7 @@ public function set($key, $value, $ttl = null) /** * {@inheritDoc} */ - public function delete($key) + public function delete(string $key): bool { $this->checkKey($key); @@ -73,7 +73,7 @@ public function delete($key) /** * {@inheritDoc} */ - public function clear() + public function clear(): bool { return (bool) ImiRedis::use(static fn (\Imi\Redis\RedisHandler $redis) => $redis->flushDB(), $this->poolName, true); } @@ -81,7 +81,7 @@ public function clear() /** * {@inheritDoc} */ - public function getMultiple($keys, $default = null) + public function getMultiple(iterable $keys, mixed $default = null): iterable { $this->checkArrayOrTraversable($keys); foreach ($keys as &$key) @@ -111,7 +111,7 @@ public function getMultiple($keys, $default = null) /** * {@inheritDoc} */ - public function setMultiple($values, $ttl = null) + public function setMultiple(iterable $values, null|int|\DateInterval $ttl = null): bool { $this->checkArrayOrTraversable($values); if ($values instanceof \Traversable) @@ -158,7 +158,7 @@ public function setMultiple($values, $ttl = null) /** * {@inheritDoc} */ - public function deleteMultiple($keys) + public function deleteMultiple(iterable $keys): bool { $this->checkArrayOrTraversable($keys); @@ -173,7 +173,7 @@ public function deleteMultiple($keys) /** * {@inheritDoc} */ - public function has($key) + public function has(string $key): bool { $this->checkKey($key); diff --git a/src/Cache/Handler/RedisHash.php b/src/Cache/Handler/RedisHash.php index 4bfcbb9e10..15f80fce64 100644 --- a/src/Cache/Handler/RedisHash.php +++ b/src/Cache/Handler/RedisHash.php @@ -57,7 +57,7 @@ class RedisHash extends Base /** * {@inheritDoc} */ - public function get($key, $default = null) + public function get(string $key, mixed $default = null): mixed { $this->parseKey($key, $member); $result = Redis::use(static fn (\Imi\Redis\RedisHandler $redis) => $redis->hGet($key, $member), $this->poolName, true); @@ -74,7 +74,7 @@ public function get($key, $default = null) /** * {@inheritDoc} */ - public function set($key, $value, $ttl = null) + public function set(string $key, mixed $value, null|int|\DateInterval $ttl = null): bool { $this->parseKey($key, $member); @@ -84,7 +84,7 @@ public function set($key, $value, $ttl = null) /** * {@inheritDoc} */ - public function delete($key) + public function delete(string $key): bool { $this->parseKey($key, $member); @@ -103,7 +103,7 @@ public function delete($key) /** * {@inheritDoc} */ - public function clear() + public function clear(): bool { return (bool) Redis::use(static fn (\Imi\Redis\RedisHandler $redis) => $redis->flushDB(), $this->poolName, true); } @@ -111,7 +111,7 @@ public function clear() /** * {@inheritDoc} */ - public function getMultiple($keys, $default = null) + public function getMultiple(iterable $keys, mixed $default = null): iterable { $this->checkArrayOrTraversable($keys); @@ -152,7 +152,7 @@ public function getMultiple($keys, $default = null) /** * {@inheritDoc} */ - public function setMultiple($values, $ttl = null) + public function setMultiple(iterable $values, null|int|\DateInterval $ttl = null): bool { $this->checkArrayOrTraversable($values); @@ -193,7 +193,7 @@ public function setMultiple($values, $ttl = null) /** * {@inheritDoc} */ - public function deleteMultiple($keys) + public function deleteMultiple(iterable $keys): bool { $this->checkArrayOrTraversable($keys); @@ -224,7 +224,7 @@ public function deleteMultiple($keys) /** * {@inheritDoc} */ - public function has($key) + public function has(string $key): bool { $this->parseKey($key, $member); diff --git a/src/Cache/Handler/RequestContext.php b/src/Cache/Handler/RequestContext.php index 4151dd9582..36a8a0a88a 100644 --- a/src/Cache/Handler/RequestContext.php +++ b/src/Cache/Handler/RequestContext.php @@ -22,7 +22,7 @@ class RequestContext extends Base /** * {@inheritDoc} */ - public function get($key, $default = null) + public function get(string $key, mixed $default = null): mixed { return $this->getObject()->get($key, $default); } @@ -30,7 +30,7 @@ public function get($key, $default = null) /** * {@inheritDoc} */ - public function set($key, $value, $ttl = null) + public function set(string $key, mixed $value, null|int|\DateInterval $ttl = null): bool { // ttl 支持 \DateInterval 格式 if ($ttl instanceof \DateInterval) @@ -45,7 +45,7 @@ public function set($key, $value, $ttl = null) /** * {@inheritDoc} */ - public function delete($key) + public function delete(string $key): bool { $this->getObject()->unset($key); @@ -55,7 +55,7 @@ public function delete($key) /** * {@inheritDoc} */ - public function clear() + public function clear(): bool { $this->getObject()->clear(); @@ -65,7 +65,7 @@ public function clear() /** * {@inheritDoc} */ - public function getMultiple($keys, $default = null) + public function getMultiple(iterable $keys, mixed $default = null): iterable { $this->checkArrayOrTraversable($keys); $object = $this->getObject(); @@ -81,7 +81,7 @@ public function getMultiple($keys, $default = null) /** * {@inheritDoc} */ - public function setMultiple($values, $ttl = null) + public function setMultiple(iterable $values, null|int|\DateInterval $ttl = null): bool { $this->checkArrayOrTraversable($values); // ttl 支持 \DateInterval 格式 @@ -101,7 +101,7 @@ public function setMultiple($values, $ttl = null) /** * {@inheritDoc} */ - public function deleteMultiple($keys) + public function deleteMultiple(iterable $keys): bool { $this->checkArrayOrTraversable($keys); $object = $this->getObject(); @@ -116,7 +116,7 @@ public function deleteMultiple($keys) /** * {@inheritDoc} */ - public function has($key) + public function has(string $key): bool { return $this->getObject()->isset($key); } diff --git a/src/Components/access-control/README.md b/src/Components/access-control/README.md index 7f248803b1..de8d238ed7 100644 --- a/src/Components/access-control/README.md +++ b/src/Components/access-control/README.md @@ -1,7 +1,7 @@ # imi-access-control [![Latest Version](https://img.shields.io/packagist/v/imiphp/imi-access-control.svg)](https://packagist.org/packages/imiphp/imi-access-control) -[![Php Version](https://img.shields.io/badge/php-%3E=7.4-brightgreen.svg)](https://secure.php.net/) +[![Php Version](https://img.shields.io/badge/php-%3E=8.1-brightgreen.svg)](https://secure.php.net/) [![Swoole Version](https://img.shields.io/badge/swoole-%3E=4.1.0-brightgreen.svg)](https://github.com/swoole/swoole-src) [![IMI License](https://img.shields.io/github/license/imiphp/imi-access-control.svg)](https://github.com/imiphp/imi-access-control/blob/master/LICENSE) @@ -177,7 +177,7 @@ QQ群:17916227 [![点击加群](https://pub.idqqimg.com/wpa/images/group.png " ## 运行环境 -- [PHP](https://php.net/) >= 7.4 +- [PHP](https://php.net/) >= 8.1 - [Composer](https://getcomposer.org/) >= 2.0 - [Swoole](https://www.swoole.com/) >= 4.1.0 diff --git a/src/Components/amqp/README.md b/src/Components/amqp/README.md index b6ef0f51f7..36d90cf5e9 100644 --- a/src/Components/amqp/README.md +++ b/src/Components/amqp/README.md @@ -1,8 +1,8 @@ # imi-amqp [![Latest Version](https://img.shields.io/packagist/v/imiphp/imi-amqp.svg)](https://packagist.org/packages/imiphp/imi-amqp) -[![Php Version](https://img.shields.io/badge/php-%3E=7.4-brightgreen.svg)](https://secure.php.net/) -[![Swoole Version](https://img.shields.io/badge/swoole-%3E=4.8.0-brightgreen.svg)](https://github.com/swoole/swoole-src) +[![Php Version](https://img.shields.io/badge/php-%3E=8.1-brightgreen.svg)](https://secure.php.net/) +[![Swoole Version](https://img.shields.io/badge/swoole-%3E=5.0.0-brightgreen.svg)](https://github.com/swoole/swoole-src) [![IMI License](https://img.shields.io/github/license/imiphp/imi-amqp.svg)](https://github.com/imiphp/imi-amqp/blob/master/LICENSE) ## 介绍 @@ -480,9 +480,9 @@ QQ群:17916227 [![点击加群](https://pub.idqqimg.com/wpa/images/group.png " ## 运行环境 -- [PHP](https://php.net/) >= 7.4 +- [PHP](https://php.net/) >= 8.1 - [Composer](https://getcomposer.org/) >= 2.0 -- [Swoole](https://www.swoole.com/) >= 4.8.0 +- [Swoole](https://www.swoole.com/) >= 5.0.0 ## 版权信息 diff --git a/src/Components/amqp/composer.json b/src/Components/amqp/composer.json index 8c2fb62971..3cab49ed37 100644 --- a/src/Components/amqp/composer.json +++ b/src/Components/amqp/composer.json @@ -5,12 +5,11 @@ "description": "支持在 imi 框架中使用 支持 AMQP 协议的消息队列,如:RabbitMQ", "require": { "imiphp/imi-queue": "~3.0.0", - "php-amqplib/php-amqplib": "^2.12.0|^3.0.0" + "php-amqplib/php-amqplib": "^3.5" }, "require-dev": { "yurunsoft/ide-helper": "~1.0", - "swoole/ide-helper": "~4.8", - "phpunit/phpunit": "~9.6" + "swoole/ide-helper": "~5.0" }, "autoload": { "psr-4": { diff --git a/src/Components/apidoc/README.md b/src/Components/apidoc/README.md index cddbfe33c0..1c01b9378d 100644 --- a/src/Components/apidoc/README.md +++ b/src/Components/apidoc/README.md @@ -1,8 +1,8 @@ # imi-apidoc [![Latest Version](https://img.shields.io/packagist/v/imiphp/imi-apidoc.svg)](https://packagist.org/packages/imiphp/imi-apidoc) -[![Php Version](https://img.shields.io/badge/php-%3E=7.4-brightgreen.svg)](https://secure.php.net/) -[![Swoole Version](https://img.shields.io/badge/swoole-%3E=4.8.0-brightgreen.svg)](https://github.com/swoole/swoole-src) +[![Php Version](https://img.shields.io/badge/php-%3E=8.1-brightgreen.svg)](https://secure.php.net/) +[![Swoole Version](https://img.shields.io/badge/swoole-%3E=5.0.0-brightgreen.svg)](https://github.com/swoole/swoole-src) [![IMI License](https://img.shields.io/github/license/imiphp/imi-apidoc.svg)](https://github.com/imiphp/imi-apidoc/blob/master/LICENSE) ## 介绍 @@ -150,9 +150,9 @@ QQ群:17916227 [![点击加群](https://pub.idqqimg.com/wpa/images/group.png " ## 运行环境 -- [PHP](https://php.net/) >= 7.4 +- [PHP](https://php.net/) >= 8.1 - [Composer](https://getcomposer.org/) >= 2.0 -- [Swoole](https://www.swoole.com/) >= 4.8.0 +- [Swoole](https://www.swoole.com/) >= 5.0.0 ## 版权信息 diff --git a/src/Components/apidoc/composer.json b/src/Components/apidoc/composer.json index b7d4ed56c2..ed614e4d85 100644 --- a/src/Components/apidoc/composer.json +++ b/src/Components/apidoc/composer.json @@ -9,7 +9,7 @@ }, "require-dev": { "yurunsoft/ide-helper": "~1.0", - "swoole/ide-helper": "~4.8" + "swoole/ide-helper": "~5.0" }, "autoload": { "psr-4": { diff --git a/src/Components/fpm/composer.json b/src/Components/fpm/composer.json index 6eed794ea8..f1366080d1 100644 --- a/src/Components/fpm/composer.json +++ b/src/Components/fpm/composer.json @@ -4,9 +4,7 @@ "license": "MulanPSL-2.0", "description": "imi php-fpm component", "require": {}, - "require-dev": { - "phpunit/phpunit": "~9.6" - }, + "require-dev": {}, "autoload": { "psr-4": { "Imi\\Fpm\\": "src/" diff --git a/src/Components/fpm/src/Http/Message/FpmResponse.php b/src/Components/fpm/src/Http/Message/FpmResponse.php index 40bace3e2c..10d50659dc 100644 --- a/src/Components/fpm/src/Http/Message/FpmResponse.php +++ b/src/Components/fpm/src/Http/Message/FpmResponse.php @@ -66,7 +66,7 @@ private function sendHeaders(): void /** * {@inheritDoc} */ - public function send(): self + public function send(): static { if ($this->responseBodyEmitter) { @@ -94,7 +94,7 @@ public function send(): self /** * {@inheritDoc} */ - public function sendFile(string $filename, ?string $contentType = null, ?string $outputFileName = null, int $offset = 0, int $length = 0): self + public function sendFile(string $filename, ?string $contentType = null, ?string $outputFileName = null, int $offset = 0, int $length = 0): static { if (null === $outputFileName) { diff --git a/src/Components/grpc/README.md b/src/Components/grpc/README.md index d17d184fe0..87bc967701 100644 --- a/src/Components/grpc/README.md +++ b/src/Components/grpc/README.md @@ -1,7 +1,7 @@ # imi-grpc [![Latest Version](https://img.shields.io/packagist/v/imiphp/imi-grpc.svg)](https://packagist.org/packages/imiphp/imi-grpc) -[![Php Version](https://img.shields.io/badge/php-%3E=7.4-brightgreen.svg)](https://secure.php.net/) +[![Php Version](https://img.shields.io/badge/php-%3E=8.1-brightgreen.svg)](https://secure.php.net/) [![Swoole Version](https://img.shields.io/badge/swoole-%3E=4.1.0-brightgreen.svg)](https://github.com/swoole/swoole-src) [![IMI License](https://img.shields.io/github/license/imiphp/imi-grpc.svg)](https://github.com/imiphp/imi-grpc/blob/master/LICENSE) @@ -236,9 +236,9 @@ QQ群:17916227 [![点击加群](https://pub.idqqimg.com/wpa/images/group.png " ## 运行环境 -- [PHP](https://php.net/) >= 7.4 +- [PHP](https://php.net/) >= 8.1 - [Composer](https://getcomposer.org/) >= 2.0 -- [Swoole](https://www.swoole.com/) >= 4.8.0 +- [Swoole](https://www.swoole.com/) >= 5.0.0 ## 版权信息 diff --git a/src/Components/grpc/composer.json b/src/Components/grpc/composer.json index d842a836dd..206320f5ba 100644 --- a/src/Components/grpc/composer.json +++ b/src/Components/grpc/composer.json @@ -5,7 +5,7 @@ "description": "在 imi 框架中集成 gRPC 服务开发、客户端调用及连接池", "require": { "imiphp/imi-rpc": "~3.0.0", - "yurunsoft/yurun-http": "^4.0.0", + "yurunsoft/yurun-http": "^5.0.0", "google/protobuf": "^3.10.0" }, "require-dev": {}, diff --git a/src/Components/hprose/README.md b/src/Components/hprose/README.md index a33a4c3000..84ea6315b4 100644 --- a/src/Components/hprose/README.md +++ b/src/Components/hprose/README.md @@ -1,7 +1,7 @@ # imi-hprose [![Latest Version](https://img.shields.io/packagist/v/imiphp/imi-hprose.svg)](https://packagist.org/packages/imiphp/imi-hprose) -[![Php Version](https://img.shields.io/badge/php-%3E=7.4-brightgreen.svg)](https://secure.php.net/) +[![Php Version](https://img.shields.io/badge/php-%3E=8.1-brightgreen.svg)](https://secure.php.net/) [![Swoole Version](https://img.shields.io/badge/swoole-%3E=4.1.0-brightgreen.svg)](https://github.com/swoole/swoole-src) [![IMI License](https://img.shields.io/github/license/imiphp/imi-hprose.svg)](https://github.com/imiphp/imi-hprose/blob/master/LICENSE) @@ -191,7 +191,7 @@ QQ群:17916227 [![点击加群](https://pub.idqqimg.com/wpa/images/group.png " ## 运行环境 -- [PHP](https://php.net/) >= 7.4 +- [PHP](https://php.net/) >= 8.1 - [Composer](https://getcomposer.org/) >= 2.0 - [Swoole](https://www.swoole.com/) >= 4.1.0 diff --git a/src/Components/jwt/README.md b/src/Components/jwt/README.md index 0bff76d940..66b68b36bc 100644 --- a/src/Components/jwt/README.md +++ b/src/Components/jwt/README.md @@ -1,7 +1,7 @@ # imi-jwt [![Latest Version](https://img.shields.io/packagist/v/imiphp/imi-jwt.svg)](https://packagist.org/packages/imiphp/imi-jwt) -[![Php Version](https://img.shields.io/badge/php-%3E=7.4-brightgreen.svg)](https://secure.php.net/) +[![Php Version](https://img.shields.io/badge/php-%3E=8.1-brightgreen.svg)](https://secure.php.net/) [![Swoole Version](https://img.shields.io/badge/swoole-%3E=4.1.0-brightgreen.svg)](https://github.com/swoole/swoole-src) [![IMI License](https://img.shields.io/github/license/imiphp/imi-jwt.svg)](https://github.com/imiphp/imi-jwt/blob/master/LICENSE) @@ -186,7 +186,7 @@ QQ群:17916227 [![点击加群](https://pub.idqqimg.com/wpa/images/group.png " ## 运行环境 -- [PHP](https://php.net/) >= 7.4 +- [PHP](https://php.net/) >= 8.1 - [Composer](https://getcomposer.org/) >= 2.0 - [Swoole](https://www.swoole.com/) >= 4.1.0 diff --git a/src/Components/jwt/composer.json b/src/Components/jwt/composer.json index 981cd72659..f854d470d2 100644 --- a/src/Components/jwt/composer.json +++ b/src/Components/jwt/composer.json @@ -6,9 +6,7 @@ "require": { "lcobucci/jwt": "^3.4.6|^4.0.4|^4.1.5" }, - "require-dev": { - "phpunit/phpunit": "~9.6" - }, + "require-dev": {}, "autoload": { "psr-4": { "Imi\\JWT\\": "src/" diff --git a/src/Components/jwt/tests/bootstrap.php b/src/Components/jwt/tests/bootstrap.php new file mode 100644 index 0000000000..b49daece6d --- /dev/null +++ b/src/Components/jwt/tests/bootstrap.php @@ -0,0 +1,5 @@ + = 7.4 +- [PHP](https://php.net/) >= 8.1 - [Composer](https://getcomposer.org/) >= 2.0 -- [Swoole](https://www.swoole.com/) >= 4.8.0 +- [Swoole](https://www.swoole.com/) >= 5.0.0 ## 版权信息 diff --git a/src/Components/kafka/composer.json b/src/Components/kafka/composer.json index 7e6582c52a..14cd970760 100644 --- a/src/Components/kafka/composer.json +++ b/src/Components/kafka/composer.json @@ -9,7 +9,7 @@ }, "require-dev": { "yurunsoft/ide-helper": "~1.0", - "swoole/ide-helper": "~4.8" + "swoole/ide-helper": "~5.0" }, "autoload": { "psr-4": { diff --git a/src/Components/macro/README.md b/src/Components/macro/README.md index e65af74509..d90583239b 100644 --- a/src/Components/macro/README.md +++ b/src/Components/macro/README.md @@ -1,8 +1,8 @@ # imi-macro [![Latest Version](https://img.shields.io/packagist/v/imiphp/imi-macro.svg)](https://packagist.org/packages/imiphp/imi-macro) -[![Php Version](https://img.shields.io/badge/php-%3E=7.4-brightgreen.svg)](https://secure.php.net/) -[![Swoole Version](https://img.shields.io/badge/swoole-%3E=4.8.0-brightgreen.svg)](https://github.com/swoole/swoole-src) +[![Php Version](https://img.shields.io/badge/php-%3E=8.1-brightgreen.svg)](https://secure.php.net/) +[![Swoole Version](https://img.shields.io/badge/swoole-%3E=5.0.0-brightgreen.svg)](https://github.com/swoole/swoole-src) [![IMI License](https://img.shields.io/github/license/imiphp/imi-macro.svg)](https://github.com/imiphp/imi-macro/blob/master/LICENSE) ## 介绍 @@ -37,9 +37,9 @@ QQ群:17916227 [![点击加群](https://pub.idqqimg.com/wpa/images/group.png " ## 运行环境 -- [PHP](https://php.net/) >= 7.4 +- [PHP](https://php.net/) >= 8.1 - [Composer](https://getcomposer.org/) >= 2.0 -- [Swoole](https://www.swoole.com/) >= 4.8.0 +- [Swoole](https://www.swoole.com/) >= 5.0.0 ## 版权信息 diff --git a/src/Components/mqtt/README.md b/src/Components/mqtt/README.md index 9390449191..a011da6cf5 100644 --- a/src/Components/mqtt/README.md +++ b/src/Components/mqtt/README.md @@ -1,8 +1,8 @@ # imi-mqtt [![Latest Version](https://img.shields.io/packagist/v/imiphp/imi-mqtt.svg)](https://packagist.org/packages/imiphp/imi-mqtt) -[![Php Version](https://img.shields.io/badge/php-%3E=7.4-brightgreen.svg)](https://secure.php.net/) -[![Swoole Version](https://img.shields.io/badge/swoole-%3E=4.8.0-brightgreen.svg)](https://github.com/swoole/swoole-src) +[![Php Version](https://img.shields.io/badge/php-%3E=8.1-brightgreen.svg)](https://secure.php.net/) +[![Swoole Version](https://img.shields.io/badge/swoole-%3E=5.0.0-brightgreen.svg)](https://github.com/swoole/swoole-src) [![IMI License](https://img.shields.io/github/license/imiphp/imi-mqtt.svg)](https://github.com/imiphp/imi-mqtt/blob/master/LICENSE) ## 介绍 @@ -260,9 +260,9 @@ QQ群:17916227 [![点击加群](https://pub.idqqimg.com/wpa/images/group.png " ## 运行环境 -- [PHP](https://php.net/) >= 7.4 +- [PHP](https://php.net/) >= 8.1 - [Composer](https://getcomposer.org/) >= 2.0 -- [Swoole](https://www.swoole.com/) >= 4.8.0 +- [Swoole](https://www.swoole.com/) >= 5.0.0 ## 版权信息 diff --git a/src/Components/mqtt/composer.json b/src/Components/mqtt/composer.json index 038d060ae1..78d421f95b 100644 --- a/src/Components/mqtt/composer.json +++ b/src/Components/mqtt/composer.json @@ -8,7 +8,7 @@ }, "require-dev": { "yurunsoft/ide-helper": "~1.0", - "swoole/ide-helper": "~4.8" + "swoole/ide-helper": "~5.0" }, "autoload": { "psr-4": { diff --git a/src/Components/pgsql/README.md b/src/Components/pgsql/README.md index ebcd0e930a..fba613d579 100644 --- a/src/Components/pgsql/README.md +++ b/src/Components/pgsql/README.md @@ -1,8 +1,8 @@ # imi-pgsql [![Latest Version](https://img.shields.io/packagist/v/imiphp/imi-pgsql.svg)](https://packagist.org/packages/imiphp/imi-pgsql) -[![Php Version](https://img.shields.io/badge/php-%3E=7.4-brightgreen.svg)](https://secure.php.net/) -[![Swoole Version](https://img.shields.io/badge/swoole-%3E=4.8.0-brightgreen.svg)](https://github.com/swoole/swoole-src) +[![Php Version](https://img.shields.io/badge/php-%3E=8.1-brightgreen.svg)](https://secure.php.net/) +[![Swoole Version](https://img.shields.io/badge/swoole-%3E=5.0.0-brightgreen.svg)](https://github.com/swoole/swoole-src) [![IMI License](https://img.shields.io/github/license/imiphp/imi-pgsql.svg)](https://github.com/imiphp/imi-pgsql/blob/master/LICENSE) ## 介绍 @@ -33,9 +33,9 @@ QQ群:17916227 [![点击加群](https://pub.idqqimg.com/wpa/images/group.png " ## 运行环境 -- [PHP](https://php.net/) >= 7.4 +- [PHP](https://php.net/) >= 8.1 - [Composer](https://getcomposer.org/) -- [Swoole](https://www.swoole.com/) >= 4.8.0 +- [Swoole](https://www.swoole.com/) >= 5.0.0 ## 版权信息 diff --git a/src/Components/pgsql/composer.json b/src/Components/pgsql/composer.json index 3cb69412b8..29bab24e73 100644 --- a/src/Components/pgsql/composer.json +++ b/src/Components/pgsql/composer.json @@ -5,7 +5,7 @@ "description": "imi 框架配套的 pgsql 组件", "require": {}, "require-dev": { - "swoole/ide-helper": "~4.8" + "swoole/ide-helper": "~5.0" }, "autoload": { "psr-4": { diff --git a/src/Components/phar/composer.json b/src/Components/phar/composer.json index e24bcef3e2..2abfeb31f0 100644 --- a/src/Components/phar/composer.json +++ b/src/Components/phar/composer.json @@ -4,7 +4,7 @@ "license": "MulanPSL-2.0", "description": "imi phar component", "require": { - "php": ">=7.4", + "php": ">=8.1", "composer-runtime-api": "^2.0", "composer/xdebug-handler": "^2.0|^3.0", "symfony/console": "^5.4|^6.0", diff --git a/src/Components/phar/src/PharBuildCommand.php b/src/Components/phar/src/PharBuildCommand.php index cbaa2e7836..ebb858113f 100644 --- a/src/Components/phar/src/PharBuildCommand.php +++ b/src/Components/phar/src/PharBuildCommand.php @@ -43,6 +43,7 @@ protected function execute(InputInterface $input, OutputInterface $output) { if (file_exists($configFile)) { + /** @var \Symfony\Component\Console\Helper\QuestionHelper $helper */ $helper = $this->getHelper('question'); $question = new ConfirmationQuestion('The configuration file already exists, whether to overwrite it? (y or n)', false); diff --git a/src/Components/phar/tests/project/composer.json b/src/Components/phar/tests/project/composer.json index 0fda44ee6e..529182d265 100644 --- a/src/Components/phar/tests/project/composer.json +++ b/src/Components/phar/tests/project/composer.json @@ -3,7 +3,7 @@ "type": "project", "description": "imi 框架的 Http Server 项目。https://imiphp.com", "require": { - "php": ">=7.4", + "php": ">=8.1", "imiphp/imi": "3.0.9999", "imiphp/imi-macro": "3.0.9999", "imiphp/imi-workerman": "3.0.9999", @@ -11,7 +11,7 @@ "imiphp/imi-roadrunner": "3.0.9999" }, "require-dev": { - "swoole/ide-helper": "^4.7", + "swoole/ide-helper": "~5.0", "imiphp/imi-phar": "3.0.9999", "friendsofphp/php-cs-fixer": "~3.13.0" }, diff --git a/src/Components/queue/README.md b/src/Components/queue/README.md index 183ec6fc92..b311debfb5 100644 --- a/src/Components/queue/README.md +++ b/src/Components/queue/README.md @@ -1,8 +1,8 @@ # imi-queue [![Latest Version](https://img.shields.io/packagist/v/imiphp/imi-queue.svg)](https://packagist.org/packages/imiphp/imi-queue) -[![Php Version](https://img.shields.io/badge/php-%3E=7.4-brightgreen.svg)](https://secure.php.net/) -[![Swoole Version](https://img.shields.io/badge/swoole-%3E=4.8.0-brightgreen.svg)](https://github.com/swoole/swoole-src) +[![Php Version](https://img.shields.io/badge/php-%3E=8.1-brightgreen.svg)](https://secure.php.net/) +[![Swoole Version](https://img.shields.io/badge/swoole-%3E=5.0.0-brightgreen.svg)](https://github.com/swoole/swoole-src) [![IMI License](https://img.shields.io/github/license/imiphp/imi-queue.svg)](https://github.com/imiphp/imi-queue/blob/master/LICENSE) ## 介绍 @@ -258,9 +258,9 @@ QQ群:17916227 [![点击加群](https://pub.idqqimg.com/wpa/images/group.png " ## 运行环境 -- [PHP](https://php.net/) >= 7.4 +- [PHP](https://php.net/) >= 8.1 - [Composer](https://getcomposer.org/) >= 2.0 -- [Swoole](https://www.swoole.com/) >= 4.8.0 +- [Swoole](https://www.swoole.com/) >= 5.0.0 ## 版权信息 diff --git a/src/Components/queue/composer.json b/src/Components/queue/composer.json index 133f1f2ed6..1912216dfe 100644 --- a/src/Components/queue/composer.json +++ b/src/Components/queue/composer.json @@ -6,8 +6,7 @@ "require": {}, "require-dev": { "yurunsoft/ide-helper": "~1.0", - "swoole/ide-helper": "~4.8", - "phpunit/phpunit": "~9.6" + "swoole/ide-helper": "~5.0" }, "autoload": { "psr-4": { diff --git a/src/Components/rate-limit/README.md b/src/Components/rate-limit/README.md index 5767c0e72b..11db5c726a 100644 --- a/src/Components/rate-limit/README.md +++ b/src/Components/rate-limit/README.md @@ -1,7 +1,7 @@ # imi-rate-limit [![Latest Version](https://img.shields.io/packagist/v/imiphp/imi-rate-limit.svg)](https://packagist.org/packages/imiphp/imi-rate-limit) -[![Php Version](https://img.shields.io/badge/php-%3E=7.4-brightgreen.svg)](https://secure.php.net/) +[![Php Version](https://img.shields.io/badge/php-%3E=8.1-brightgreen.svg)](https://secure.php.net/) [![Swoole Version](https://img.shields.io/badge/swoole-%3E=4.1.0-brightgreen.svg)](https://github.com/swoole/swoole-src) [![IMI License](https://img.shields.io/github/license/imiphp/imi-rate-limit.svg)](https://github.com/imiphp/imi-rate-limit/blob/master/LICENSE) @@ -157,7 +157,7 @@ QQ群:17916227 [![点击加群](https://pub.idqqimg.com/wpa/images/group.png " ## 运行环境 -- [PHP](https://php.net/) >= 7.4 +- [PHP](https://php.net/) >= 8.1 - [Composer](https://getcomposer.org/) >= 2.0 - [Swoole](https://www.swoole.com/) >= 4.1.0 diff --git a/src/Components/roadrunner/composer.json b/src/Components/roadrunner/composer.json index 04ca51aecf..13b475c91c 100644 --- a/src/Components/roadrunner/composer.json +++ b/src/Components/roadrunner/composer.json @@ -7,9 +7,7 @@ "spiral/roadrunner": "~2.0", "symfony/yaml": "^5.3|^6.0" }, - "require-dev": { - "phpunit/phpunit": "~9.6" - }, + "require-dev": {}, "autoload": { "psr-4": { "Imi\\RoadRunner\\": "src/" diff --git a/src/Components/roadrunner/src/Http/Message/RoadRunnerRequest.php b/src/Components/roadrunner/src/Http/Message/RoadRunnerRequest.php index d57313dd1b..cf0a0d3ae4 100644 --- a/src/Components/roadrunner/src/Http/Message/RoadRunnerRequest.php +++ b/src/Components/roadrunner/src/Http/Message/RoadRunnerRequest.php @@ -45,7 +45,7 @@ protected function initUri(): void /** * {@inheritDoc} */ - public function withParsedBody($data) + public function withParsedBody($data): static { $result = parent::withParsedBody($data); $contentType = $_SERVER['CONTENT_TYPE'] ?? ''; diff --git a/src/Components/roadrunner/src/Http/Message/RoadRunnerResponse.php b/src/Components/roadrunner/src/Http/Message/RoadRunnerResponse.php index a6efc7423b..6495c86a03 100644 --- a/src/Components/roadrunner/src/Http/Message/RoadRunnerResponse.php +++ b/src/Components/roadrunner/src/Http/Message/RoadRunnerResponse.php @@ -44,7 +44,7 @@ public function isBodyWritable(): bool /** * {@inheritDoc} */ - public function send(): self + public function send(): static { if ($this->isWritable) { @@ -93,7 +93,7 @@ protected function cookieArrayToHeader(array $cookie): string /** * {@inheritDoc} */ - public function sendFile(string $filename, ?string $contentType = null, ?string $outputFileName = null, int $offset = 0, int $length = 0): self + public function sendFile(string $filename, ?string $contentType = null, ?string $outputFileName = null, int $offset = 0, int $length = 0): static { if ($this->isWritable) { diff --git a/src/Components/rpc/README.md b/src/Components/rpc/README.md index 7d5ec6d6bc..9cad168c7b 100644 --- a/src/Components/rpc/README.md +++ b/src/Components/rpc/README.md @@ -1,7 +1,7 @@ # imi-rpc [![Latest Version](https://img.shields.io/packagist/v/imiphp/imi-rpc.svg)](https://packagist.org/packages/imiphp/imi-rpc) -[![Php Version](https://img.shields.io/badge/php-%3E=7.4-brightgreen.svg)](https://secure.php.net/) +[![Php Version](https://img.shields.io/badge/php-%3E=8.1-brightgreen.svg)](https://secure.php.net/) [![Swoole Version](https://img.shields.io/badge/swoole-%3E=4.1.0-brightgreen.svg)](https://github.com/swoole/swoole-src) [![IMI License](https://img.shields.io/github/license/imiphp/imi-rpc.svg)](https://github.com/imiphp/imi-rpc/blob/master/LICENSE) @@ -46,7 +46,7 @@ QQ群:17916227 [![点击加群](https://pub.idqqimg.com/wpa/images/group.png " ## 运行环境 -- [PHP](https://php.net/) >= 7.4 +- [PHP](https://php.net/) >= 8.1 - [Composer](https://getcomposer.org/) >= 2.0 - [Swoole](https://www.swoole.com/) >= 4.1.0 diff --git a/src/Components/shared-memory/README.md b/src/Components/shared-memory/README.md index 82370b0a62..338e836cbe 100644 --- a/src/Components/shared-memory/README.md +++ b/src/Components/shared-memory/README.md @@ -1,7 +1,7 @@ # imi-shared-memory [![Latest Version](https://img.shields.io/packagist/v/imiphp/imi-shared-memory.svg)](https://packagist.org/packages/imiphp/imi-shared-memory) -[![Php Version](https://img.shields.io/badge/php-%3E=7.4-brightgreen.svg)](https://secure.php.net/) +[![Php Version](https://img.shields.io/badge/php-%3E=8.1-brightgreen.svg)](https://secure.php.net/) [![Swoole Version](https://img.shields.io/badge/swoole-%3E=4.1.0-brightgreen.svg)](https://github.com/swoole/swoole-src) [![IMI License](https://img.shields.io/github/license/imiphp/imi-shared-memory.svg)](https://github.com/imiphp/imi-shared-memory/blob/master/LICENSE) @@ -103,7 +103,7 @@ QQ群:17916227 [![点击加群](https://pub.idqqimg.com/wpa/images/group.png " ## 运行环境 -- [PHP](https://php.net/) >= 7.4 +- [PHP](https://php.net/) >= 8.1 - [Composer](https://getcomposer.org/) >= 2.0 - [Swoole](https://www.swoole.com/) >= 4.1.0 diff --git a/src/Components/smarty/README.md b/src/Components/smarty/README.md index 3ea5e8bd53..4a9dba1727 100644 --- a/src/Components/smarty/README.md +++ b/src/Components/smarty/README.md @@ -1,8 +1,8 @@ # imi-smarty [![Latest Version](https://img.shields.io/packagist/v/imiphp/imi-smarty.svg)](https://packagist.org/packages/imiphp/imi-smarty) -[![Php Version](https://img.shields.io/badge/php-%3E=7.4-brightgreen.svg)](https://secure.php.net/) -[![Swoole Version](https://img.shields.io/badge/swoole-%3E=4.8.0-brightgreen.svg)](https://github.com/swoole/swoole-src) +[![Php Version](https://img.shields.io/badge/php-%3E=8.1-brightgreen.svg)](https://secure.php.net/) +[![Swoole Version](https://img.shields.io/badge/swoole-%3E=5.0.0-brightgreen.svg)](https://github.com/swoole/swoole-src) [![IMI License](https://img.shields.io/github/license/imiphp/imi-smarty.svg)](https://github.com/imiphp/imi-smarty/blob/master/LICENSE) ## 介绍 @@ -87,9 +87,9 @@ QQ群:17916227 [![点击加群](https://pub.idqqimg.com/wpa/images/group.png " ## 运行环境 -- [PHP](https://php.net/) >= 7.4 +- [PHP](https://php.net/) >= 8.1 - [Composer](https://getcomposer.org/) >= 2.0 -- [Swoole](https://www.swoole.com/) >= 4.8.0 +- [Swoole](https://www.swoole.com/) >= 5.0.0 ## 版权信息 diff --git a/src/Components/smarty/composer.json b/src/Components/smarty/composer.json index 24da0991ac..771419dc21 100644 --- a/src/Components/smarty/composer.json +++ b/src/Components/smarty/composer.json @@ -6,9 +6,7 @@ "require": { "smarty/smarty": "~3.1" }, - "require-dev": { - "phpunit/phpunit": "~9.6" - }, + "require-dev": {}, "autoload": { "psr-4": { "Imi\\Smarty\\": "src/" diff --git a/src/Components/smarty/tests/composer.json b/src/Components/smarty/tests/composer.json index 9c9d54a572..ce04b9ebb5 100644 --- a/src/Components/smarty/tests/composer.json +++ b/src/Components/smarty/tests/composer.json @@ -1,6 +1,6 @@ { "require": { - "php": ">=7.4.0", + "php": ">=8.1", "yurunsoft/yurun-http": "~3.2" } } \ No newline at end of file diff --git a/src/Components/snowflake/README.md b/src/Components/snowflake/README.md index c428f9feae..3f16ba27ea 100644 --- a/src/Components/snowflake/README.md +++ b/src/Components/snowflake/README.md @@ -1,8 +1,8 @@ # imi-snowflake [![Latest Version](https://img.shields.io/packagist/v/imiphp/imi-snowflake.svg)](https://packagist.org/packages/imiphp/imi-snowflake) -[![Php Version](https://img.shields.io/badge/php-%3E=7.4-brightgreen.svg)](https://secure.php.net/) -[![Swoole Version](https://img.shields.io/badge/swoole-%3E=4.8.0-brightgreen.svg)](https://github.com/swoole/swoole-src) +[![Php Version](https://img.shields.io/badge/php-%3E=8.1-brightgreen.svg)](https://secure.php.net/) +[![Swoole Version](https://img.shields.io/badge/swoole-%3E=5.0.0-brightgreen.svg)](https://github.com/swoole/swoole-src) [![IMI License](https://img.shields.io/github/license/imiphp/imi-snowflake.svg)](https://github.com/imiphp/imi-snowflake/blob/master/LICENSE) ## 介绍 @@ -92,7 +92,7 @@ QQ群:17916227 [![点击加群](https://pub.idqqimg.com/wpa/images/group.png " ## 运行环境 -- [PHP](https://php.net/) >= 7.4 +- [PHP](https://php.net/) >= 8.1 - [Composer](https://getcomposer.org/) >= 2.0 - [Swoole](https://www.swoole.com/) >= 4.1.0 diff --git a/src/Components/snowflake/composer.json b/src/Components/snowflake/composer.json index 5d9eca2711..3fb050766a 100644 --- a/src/Components/snowflake/composer.json +++ b/src/Components/snowflake/composer.json @@ -6,9 +6,7 @@ "require": { "godruoyi/php-snowflake": "^1.0" }, - "require-dev": { - "phpunit/phpunit": "~9.6" - }, + "require-dev": {}, "autoload": { "psr-4": { "Imi\\Snowflake\\": "src/" diff --git a/src/Components/snowflake/tests/bootstrap.php b/src/Components/snowflake/tests/bootstrap.php new file mode 100644 index 0000000000..b49daece6d --- /dev/null +++ b/src/Components/snowflake/tests/bootstrap.php @@ -0,0 +1,5 @@ + = 7.4 +* [PHP](https://php.net/) >= 8.1 * [Composer](https://getcomposer.org/) >= 2.0 -* [Swoole](https://www.swoole.com/) >= 4.8.0 +* [Swoole](https://www.swoole.com/) >= 5.0.0 ## 版权信息 diff --git a/src/Components/swoole/composer.json b/src/Components/swoole/composer.json index 8c9093f5b7..368152be07 100644 --- a/src/Components/swoole/composer.json +++ b/src/Components/swoole/composer.json @@ -4,12 +4,11 @@ "license": "MulanPSL-2.0", "description": "imi swoole component", "require": { - "ext-swoole": ">=4.8", + "ext-swoole": ">=5.0", "yurunsoft/swoole-co-pool": "~1.0|~2.0" }, "require-dev": { - "phpunit/phpunit": "~9.6", - "swoole/ide-helper": "~4.8" + "swoole/ide-helper": "~5.0" }, "autoload": { "psr-4": { diff --git a/src/Components/swoole/src/Http/Message/SwooleResponse.php b/src/Components/swoole/src/Http/Message/SwooleResponse.php index 2a063d4244..49a08e6d69 100644 --- a/src/Components/swoole/src/Http/Message/SwooleResponse.php +++ b/src/Components/swoole/src/Http/Message/SwooleResponse.php @@ -91,7 +91,7 @@ private function sendHeaders(): void /** * {@inheritDoc} */ - public function send(): self + public function send(): static { if ($this->responseBodyEmitter) { @@ -120,7 +120,7 @@ public function send(): self /** * {@inheritDoc} */ - public function sendFile(string $filename, ?string $contentType = null, ?string $outputFileName = null, int $offset = 0, int $length = 0): self + public function sendFile(string $filename, ?string $contentType = null, ?string $outputFileName = null, int $offset = 0, int $length = 0): static { if (null === $outputFileName) { diff --git a/src/Components/swoole/src/Log/SwooleLogger.php b/src/Components/swoole/src/Log/SwooleLogger.php index 643b29a91f..c7307be7f3 100644 --- a/src/Components/swoole/src/Log/SwooleLogger.php +++ b/src/Components/swoole/src/Log/SwooleLogger.php @@ -10,6 +10,8 @@ use Imi\Log\MonoLogger; use Imi\Swoole\Util\Coroutine; use Monolog\DateTimeImmutable; +use Monolog\Level; +use Monolog\LogRecord; use Swoole\Coroutine\Channel; class SwooleLogger extends MonoLogger @@ -30,11 +32,12 @@ public function __construct(...$args) parent::__construct(...$args); if ($this->async = Config::get('@app.logger.async', false) && Coroutine::isIn()) { - $this->pushProcessor(static function (array $record): array { - if (isset($record['context'][self::KEY_IMI_ASYNC_DATETIME])) + $this->pushProcessor(static function (LogRecord $record): LogRecord { + if (isset($record->context[self::KEY_IMI_ASYNC_DATETIME])) { - $record['datetime'] = $record['context'][self::KEY_IMI_ASYNC_DATETIME]; - unset($record['context'][self::KEY_IMI_ASYNC_DATETIME]); + $context = $record->context; + unset($context[self::KEY_IMI_ASYNC_DATETIME]); + $record = $record->with(datetime: $record->context[self::KEY_IMI_ASYNC_DATETIME], context: $context); } return $record; @@ -53,7 +56,7 @@ public function __construct(...$args) /** * {@inheritDoc} */ - public function addRecord(int $level, string $message, array $context = [], ?DateTimeImmutable $datetime = null): bool + public function addRecord(int|Level $level, string $message, array $context = [], DateTimeImmutable $datetime = null): bool { if ($this->asyncLogging) { diff --git a/src/Components/workerman-gateway/composer.json b/src/Components/workerman-gateway/composer.json index b29c25631c..389447f4b7 100644 --- a/src/Components/workerman-gateway/composer.json +++ b/src/Components/workerman-gateway/composer.json @@ -8,7 +8,6 @@ "yurunsoft/workerman-gateway-sdk": "^1.0" }, "require-dev": { - "phpunit/phpunit": "~9.6", "wrench/wrench": "~2.0" }, "autoload": { diff --git a/src/Components/workerman/composer.json b/src/Components/workerman/composer.json index 1254354d65..b80fa962dd 100644 --- a/src/Components/workerman/composer.json +++ b/src/Components/workerman/composer.json @@ -8,7 +8,6 @@ "workerman/channel": "^1.1" }, "require-dev": { - "phpunit/phpunit": "~9.6", "wrench/wrench": "~2.0" }, "autoload": { diff --git a/src/Components/workerman/src/Http/Message/WorkermanResponse.php b/src/Components/workerman/src/Http/Message/WorkermanResponse.php index f2a47afe24..e4e733dbaf 100644 --- a/src/Components/workerman/src/Http/Message/WorkermanResponse.php +++ b/src/Components/workerman/src/Http/Message/WorkermanResponse.php @@ -111,7 +111,7 @@ private function sendHeaders(): void /** * {@inheritDoc} */ - public function send(): self + public function send(): static { if ($this->responseBodyEmitter) { @@ -153,7 +153,7 @@ public function send(): self /** * {@inheritDoc} */ - public function sendFile(string $filename, ?string $contentType = null, ?string $outputFileName = null, int $offset = 0, int $length = 0): self + public function sendFile(string $filename, ?string $contentType = null, ?string $outputFileName = null, int $offset = 0, int $length = 0): static { if (null === $outputFileName) { diff --git a/src/Log/Formatter/ConsoleLineFormatter.php b/src/Log/Formatter/ConsoleLineFormatter.php index 9dec5f6f0f..63531dcdf9 100644 --- a/src/Log/Formatter/ConsoleLineFormatter.php +++ b/src/Log/Formatter/ConsoleLineFormatter.php @@ -6,6 +6,7 @@ use Imi\Log\LogLevel; use Monolog\Formatter\LineFormatter; +use Monolog\LogRecord; class ConsoleLineFormatter extends LineFormatter { @@ -47,9 +48,10 @@ public function __construct(?string $format = null, ?string $dateFormat = 'Y-m-d /** * {@inheritdoc} */ - public function format(array $record): string + public function format(LogRecord $record): string { - $vars = $this->normalize($record); + /** @var array $vars */ + $vars = $this->normalize($record->toArray()); $output = $this->format; diff --git a/src/Log/Handler/ConsoleHandler.php b/src/Log/Handler/ConsoleHandler.php index aadb35313f..f880b4989b 100644 --- a/src/Log/Handler/ConsoleHandler.php +++ b/src/Log/Handler/ConsoleHandler.php @@ -7,6 +7,7 @@ use Imi\Cli\ImiCommand; use Imi\Log\MonoLogger; use Monolog\Handler\AbstractProcessingHandler; +use Monolog\LogRecord; use Symfony\Component\Console\Output\OutputInterface; /** @@ -28,9 +29,9 @@ public function __construct(?OutputInterface $output = null, $level = MonoLogger /** * {@inheritdoc} */ - protected function write(array $record): void + protected function write(LogRecord $record): void { - $this->output->write((string) $record['formatted']); + $this->output->write((string) $record->formatted); } public function getOutput(): OutputInterface diff --git a/src/Log/MonoLogger.php b/src/Log/MonoLogger.php index 1c65b5cc71..11005ccacd 100644 --- a/src/Log/MonoLogger.php +++ b/src/Log/MonoLogger.php @@ -4,9 +4,11 @@ namespace Imi\Log; -use Composer\InstalledVersions; use Monolog\Logger; +/** + * @phpstan-ignore-next-line + */ class MonoLogger extends Logger { /** @@ -18,17 +20,6 @@ public function __construct(...$args) { parent::__construct(...$args); - // 禁用不兼容协程并发的深度检测功能 - if (method_exists($this, 'useLoggingLoopDetection')) - { - $this->useLoggingLoopDetection(false); - } - elseif (version_compare(InstalledVersions::getVersion('monolog/monolog'), '2.6.0', '>=')) - { - $ref = new \ReflectionClass(parent::class); - $property = $ref->getProperty('logDepth'); - $property->setAccessible(true); - $property->setValue($this, \PHP_INT_MIN); - } + $this->useLoggingLoopDetection(false); } } diff --git a/src/Server/Http/Message/Proxy/RequestProxy.php b/src/Server/Http/Message/Proxy/RequestProxy.php index 63c3f6c90a..3e9ad34e4a 100644 --- a/src/Server/Http/Message/Proxy/RequestProxy.php +++ b/src/Server/Http/Message/Proxy/RequestProxy.php @@ -12,42 +12,42 @@ * * @method \Imi\Util\Socket\IPEndPoint getClientAddress() * @method static \Imi\Util\Socket\IPEndPoint getClientAddress() - * @method mixed getServerParam(string $name, $default = NULL) - * @method static mixed getServerParam(string $name, $default = NULL) - * @method mixed getCookie(string $name, $default = NULL) - * @method static mixed getCookie(string $name, $default = NULL) + * @method mixed getServerParam(string $name, mixed $default = NULL) + * @method static mixed getServerParam(string $name, mixed $default = NULL) + * @method string|null getCookie(string $name, ?string $default = NULL) + * @method static string|null getCookie(string $name, ?string $default = NULL) * @method \Imi\Util\Http\Contract\IServerRequest setCookieParams(array $cookies) * @method static \Imi\Util\Http\Contract\IServerRequest setCookieParams(array $cookies) * @method \Imi\Util\Http\Contract\IServerRequest setQueryParams(array $query) * @method static \Imi\Util\Http\Contract\IServerRequest setQueryParams(array $query) * @method \Imi\Util\Http\Contract\IServerRequest setUploadedFiles(array $uploadedFiles) * @method static \Imi\Util\Http\Contract\IServerRequest setUploadedFiles(array $uploadedFiles) - * @method \Imi\Util\Http\Contract\IServerRequest setParsedBody($data) - * @method static \Imi\Util\Http\Contract\IServerRequest setParsedBody($data) - * @method \Imi\Util\Http\Contract\IServerRequest setAttribute(string $name, $value) - * @method static \Imi\Util\Http\Contract\IServerRequest setAttribute(string $name, $value) + * @method \Imi\Util\Http\Contract\IServerRequest setParsedBody(object|array|null $data) + * @method static \Imi\Util\Http\Contract\IServerRequest setParsedBody(object|array|null $data) + * @method \Imi\Util\Http\Contract\IServerRequest setAttribute(string $name, mixed $value) + * @method static \Imi\Util\Http\Contract\IServerRequest setAttribute(string $name, mixed $value) * @method \Imi\Util\Http\Contract\IServerRequest removeAttribute(string $name) * @method static \Imi\Util\Http\Contract\IServerRequest removeAttribute(string $name) - * @method mixed get(?string $name = NULL, $default = NULL) - * @method static mixed get(?string $name = NULL, $default = NULL) - * @method mixed post(?string $name = NULL, $default = NULL) - * @method static mixed post(?string $name = NULL, $default = NULL) + * @method mixed get(?string $name = NULL, mixed $default = NULL) + * @method static mixed get(?string $name = NULL, mixed $default = NULL) + * @method mixed post(?string $name = NULL, mixed $default = NULL) + * @method static mixed post(?string $name = NULL, mixed $default = NULL) * @method bool hasGet(string $name) * @method static bool hasGet(string $name) * @method bool hasPost(string $name) * @method static bool hasPost(string $name) - * @method mixed request(?string $name = NULL, $default = NULL) - * @method static mixed request(?string $name = NULL, $default = NULL) + * @method mixed request(?string $name = NULL, mixed $default = NULL) + * @method static mixed request(?string $name = NULL, mixed $default = NULL) * @method bool hasRequest(string $name) * @method static bool hasRequest(string $name) * @method \Imi\Util\Http\Contract\IServerRequest withGet(array $get) * @method static \Imi\Util\Http\Contract\IServerRequest withGet(array $get) * @method \Imi\Util\Http\Contract\IServerRequest setGet(array $get) * @method static \Imi\Util\Http\Contract\IServerRequest setGet(array $get) - * @method \Imi\Util\Http\Contract\IServerRequest withPost($post) - * @method static \Imi\Util\Http\Contract\IServerRequest withPost($post) - * @method \Imi\Util\Http\Contract\IServerRequest setPost($post) - * @method static \Imi\Util\Http\Contract\IServerRequest setPost($post) + * @method \Imi\Util\Http\Contract\IServerRequest withPost(mixed $post) + * @method static \Imi\Util\Http\Contract\IServerRequest withPost(mixed $post) + * @method \Imi\Util\Http\Contract\IServerRequest setPost(mixed $post) + * @method static \Imi\Util\Http\Contract\IServerRequest setPost(mixed $post) * @method \Imi\Util\Http\Contract\IServerRequest withRequest(array $request) * @method static \Imi\Util\Http\Contract\IServerRequest withRequest(array $request) * @method \Imi\Util\Http\Contract\IServerRequest setRequest(array $request) @@ -72,48 +72,48 @@ * @method static \Psr\Http\Message\ServerRequestInterface withParsedBody($data) * @method array getAttributes() * @method static array getAttributes() - * @method mixed getAttribute($name, $default = NULL) - * @method static mixed getAttribute($name, $default = NULL) - * @method \Psr\Http\Message\ServerRequestInterface withAttribute($name, $value) - * @method static \Psr\Http\Message\ServerRequestInterface withAttribute($name, $value) - * @method \Psr\Http\Message\ServerRequestInterface withoutAttribute($name) - * @method static \Psr\Http\Message\ServerRequestInterface withoutAttribute($name) + * @method mixed getAttribute(string $name, $default = NULL) + * @method static mixed getAttribute(string $name, $default = NULL) + * @method \Psr\Http\Message\ServerRequestInterface withAttribute(string $name, $value) + * @method static \Psr\Http\Message\ServerRequestInterface withAttribute(string $name, $value) + * @method \Psr\Http\Message\ServerRequestInterface withoutAttribute(string $name) + * @method static \Psr\Http\Message\ServerRequestInterface withoutAttribute(string $name) * @method string getRequestTarget() * @method static string getRequestTarget() - * @method \Psr\Http\Message\RequestInterface withRequestTarget($requestTarget) - * @method static \Psr\Http\Message\RequestInterface withRequestTarget($requestTarget) + * @method \Psr\Http\Message\RequestInterface withRequestTarget(string $requestTarget) + * @method static \Psr\Http\Message\RequestInterface withRequestTarget(string $requestTarget) * @method string getMethod() * @method static string getMethod() - * @method \Psr\Http\Message\RequestInterface withMethod($method) - * @method static \Psr\Http\Message\RequestInterface withMethod($method) + * @method \Psr\Http\Message\RequestInterface withMethod(string $method) + * @method static \Psr\Http\Message\RequestInterface withMethod(string $method) * @method \Psr\Http\Message\UriInterface getUri() * @method static \Psr\Http\Message\UriInterface getUri() - * @method \Psr\Http\Message\RequestInterface withUri(\Psr\Http\Message\UriInterface $uri, $preserveHost = false) - * @method static \Psr\Http\Message\RequestInterface withUri(\Psr\Http\Message\UriInterface $uri, $preserveHost = false) + * @method \Psr\Http\Message\RequestInterface withUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) + * @method static \Psr\Http\Message\RequestInterface withUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) * @method string getProtocolVersion() * @method static string getProtocolVersion() - * @method \Psr\Http\Message\MessageInterface withProtocolVersion($version) - * @method static \Psr\Http\Message\MessageInterface withProtocolVersion($version) + * @method \Psr\Http\Message\MessageInterface withProtocolVersion(string $version) + * @method static \Psr\Http\Message\MessageInterface withProtocolVersion(string $version) * @method string[][] getHeaders() * @method static string[][] getHeaders() - * @method bool hasHeader($name) - * @method static bool hasHeader($name) - * @method string[] getHeader($name) - * @method static string[] getHeader($name) - * @method string getHeaderLine($name) - * @method static string getHeaderLine($name) - * @method \Psr\Http\Message\MessageInterface withHeader($name, $value) - * @method static \Psr\Http\Message\MessageInterface withHeader($name, $value) - * @method \Psr\Http\Message\MessageInterface withAddedHeader($name, $value) - * @method static \Psr\Http\Message\MessageInterface withAddedHeader($name, $value) - * @method \Psr\Http\Message\MessageInterface withoutHeader($name) - * @method static \Psr\Http\Message\MessageInterface withoutHeader($name) + * @method bool hasHeader(string $name) + * @method static bool hasHeader(string $name) + * @method string[] getHeader(string $name) + * @method static string[] getHeader(string $name) + * @method string getHeaderLine(string $name) + * @method static string getHeaderLine(string $name) + * @method \Psr\Http\Message\MessageInterface withHeader(string $name, $value) + * @method static \Psr\Http\Message\MessageInterface withHeader(string $name, $value) + * @method \Psr\Http\Message\MessageInterface withAddedHeader(string $name, $value) + * @method static \Psr\Http\Message\MessageInterface withAddedHeader(string $name, $value) + * @method \Psr\Http\Message\MessageInterface withoutHeader(string $name) + * @method static \Psr\Http\Message\MessageInterface withoutHeader(string $name) * @method \Psr\Http\Message\StreamInterface getBody() * @method static \Psr\Http\Message\StreamInterface getBody() * @method \Psr\Http\Message\MessageInterface withBody(\Psr\Http\Message\StreamInterface $body) * @method static \Psr\Http\Message\MessageInterface withBody(\Psr\Http\Message\StreamInterface $body) - * @method \Imi\Util\Http\Contract\IRequest setRequestTarget($requestTarget) - * @method static \Imi\Util\Http\Contract\IRequest setRequestTarget($requestTarget) + * @method \Imi\Util\Http\Contract\IRequest setRequestTarget(string $requestTarget) + * @method static \Imi\Util\Http\Contract\IRequest setRequestTarget(string $requestTarget) * @method \Imi\Util\Http\Contract\IRequest setMethod(string $method) * @method static \Imi\Util\Http\Contract\IRequest setMethod(string $method) * @method \Imi\Util\Http\Contract\IRequest setUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) diff --git a/src/Server/Http/Message/Proxy/RequestProxyObject.php b/src/Server/Http/Message/Proxy/RequestProxyObject.php index d636e6e428..44cb7bc6c8 100644 --- a/src/Server/Http/Message/Proxy/RequestProxyObject.php +++ b/src/Server/Http/Message/Proxy/RequestProxyObject.php @@ -15,42 +15,42 @@ * * @method \Imi\Util\Socket\IPEndPoint getClientAddress() * @method static \Imi\Util\Socket\IPEndPoint getClientAddress() - * @method mixed getServerParam(string $name, $default = NULL) - * @method static mixed getServerParam(string $name, $default = NULL) - * @method mixed getCookie(string $name, $default = NULL) - * @method static mixed getCookie(string $name, $default = NULL) + * @method mixed getServerParam(string $name, mixed $default = NULL) + * @method static mixed getServerParam(string $name, mixed $default = NULL) + * @method string|null getCookie(string $name, ?string $default = NULL) + * @method static string|null getCookie(string $name, ?string $default = NULL) * @method \Imi\Util\Http\Contract\IServerRequest setCookieParams(array $cookies) * @method static \Imi\Util\Http\Contract\IServerRequest setCookieParams(array $cookies) * @method \Imi\Util\Http\Contract\IServerRequest setQueryParams(array $query) * @method static \Imi\Util\Http\Contract\IServerRequest setQueryParams(array $query) * @method \Imi\Util\Http\Contract\IServerRequest setUploadedFiles(array $uploadedFiles) * @method static \Imi\Util\Http\Contract\IServerRequest setUploadedFiles(array $uploadedFiles) - * @method \Imi\Util\Http\Contract\IServerRequest setParsedBody($data) - * @method static \Imi\Util\Http\Contract\IServerRequest setParsedBody($data) - * @method \Imi\Util\Http\Contract\IServerRequest setAttribute(string $name, $value) - * @method static \Imi\Util\Http\Contract\IServerRequest setAttribute(string $name, $value) + * @method \Imi\Util\Http\Contract\IServerRequest setParsedBody(object|array|null $data) + * @method static \Imi\Util\Http\Contract\IServerRequest setParsedBody(object|array|null $data) + * @method \Imi\Util\Http\Contract\IServerRequest setAttribute(string $name, mixed $value) + * @method static \Imi\Util\Http\Contract\IServerRequest setAttribute(string $name, mixed $value) * @method \Imi\Util\Http\Contract\IServerRequest removeAttribute(string $name) * @method static \Imi\Util\Http\Contract\IServerRequest removeAttribute(string $name) - * @method mixed get(?string $name = NULL, $default = NULL) - * @method static mixed get(?string $name = NULL, $default = NULL) - * @method mixed post(?string $name = NULL, $default = NULL) - * @method static mixed post(?string $name = NULL, $default = NULL) + * @method mixed get(?string $name = NULL, mixed $default = NULL) + * @method static mixed get(?string $name = NULL, mixed $default = NULL) + * @method mixed post(?string $name = NULL, mixed $default = NULL) + * @method static mixed post(?string $name = NULL, mixed $default = NULL) * @method bool hasGet(string $name) * @method static bool hasGet(string $name) * @method bool hasPost(string $name) * @method static bool hasPost(string $name) - * @method mixed request(?string $name = NULL, $default = NULL) - * @method static mixed request(?string $name = NULL, $default = NULL) + * @method mixed request(?string $name = NULL, mixed $default = NULL) + * @method static mixed request(?string $name = NULL, mixed $default = NULL) * @method bool hasRequest(string $name) * @method static bool hasRequest(string $name) * @method \Imi\Util\Http\Contract\IServerRequest withGet(array $get) * @method static \Imi\Util\Http\Contract\IServerRequest withGet(array $get) * @method \Imi\Util\Http\Contract\IServerRequest setGet(array $get) * @method static \Imi\Util\Http\Contract\IServerRequest setGet(array $get) - * @method \Imi\Util\Http\Contract\IServerRequest withPost($post) - * @method static \Imi\Util\Http\Contract\IServerRequest withPost($post) - * @method \Imi\Util\Http\Contract\IServerRequest setPost($post) - * @method static \Imi\Util\Http\Contract\IServerRequest setPost($post) + * @method \Imi\Util\Http\Contract\IServerRequest withPost(mixed $post) + * @method static \Imi\Util\Http\Contract\IServerRequest withPost(mixed $post) + * @method \Imi\Util\Http\Contract\IServerRequest setPost(mixed $post) + * @method static \Imi\Util\Http\Contract\IServerRequest setPost(mixed $post) * @method \Imi\Util\Http\Contract\IServerRequest withRequest(array $request) * @method static \Imi\Util\Http\Contract\IServerRequest withRequest(array $request) * @method \Imi\Util\Http\Contract\IServerRequest setRequest(array $request) @@ -75,48 +75,48 @@ * @method static \Psr\Http\Message\ServerRequestInterface withParsedBody($data) * @method array getAttributes() * @method static array getAttributes() - * @method mixed getAttribute($name, $default = NULL) - * @method static mixed getAttribute($name, $default = NULL) - * @method \Psr\Http\Message\ServerRequestInterface withAttribute($name, $value) - * @method static \Psr\Http\Message\ServerRequestInterface withAttribute($name, $value) - * @method \Psr\Http\Message\ServerRequestInterface withoutAttribute($name) - * @method static \Psr\Http\Message\ServerRequestInterface withoutAttribute($name) + * @method mixed getAttribute(string $name, $default = NULL) + * @method static mixed getAttribute(string $name, $default = NULL) + * @method \Psr\Http\Message\ServerRequestInterface withAttribute(string $name, $value) + * @method static \Psr\Http\Message\ServerRequestInterface withAttribute(string $name, $value) + * @method \Psr\Http\Message\ServerRequestInterface withoutAttribute(string $name) + * @method static \Psr\Http\Message\ServerRequestInterface withoutAttribute(string $name) * @method string getRequestTarget() * @method static string getRequestTarget() - * @method \Psr\Http\Message\RequestInterface withRequestTarget($requestTarget) - * @method static \Psr\Http\Message\RequestInterface withRequestTarget($requestTarget) + * @method \Psr\Http\Message\RequestInterface withRequestTarget(string $requestTarget) + * @method static \Psr\Http\Message\RequestInterface withRequestTarget(string $requestTarget) * @method string getMethod() * @method static string getMethod() - * @method \Psr\Http\Message\RequestInterface withMethod($method) - * @method static \Psr\Http\Message\RequestInterface withMethod($method) + * @method \Psr\Http\Message\RequestInterface withMethod(string $method) + * @method static \Psr\Http\Message\RequestInterface withMethod(string $method) * @method \Psr\Http\Message\UriInterface getUri() * @method static \Psr\Http\Message\UriInterface getUri() - * @method \Psr\Http\Message\RequestInterface withUri(\Psr\Http\Message\UriInterface $uri, $preserveHost = false) - * @method static \Psr\Http\Message\RequestInterface withUri(\Psr\Http\Message\UriInterface $uri, $preserveHost = false) + * @method \Psr\Http\Message\RequestInterface withUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) + * @method static \Psr\Http\Message\RequestInterface withUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) * @method string getProtocolVersion() * @method static string getProtocolVersion() - * @method \Psr\Http\Message\MessageInterface withProtocolVersion($version) - * @method static \Psr\Http\Message\MessageInterface withProtocolVersion($version) + * @method \Psr\Http\Message\MessageInterface withProtocolVersion(string $version) + * @method static \Psr\Http\Message\MessageInterface withProtocolVersion(string $version) * @method string[][] getHeaders() * @method static string[][] getHeaders() - * @method bool hasHeader($name) - * @method static bool hasHeader($name) - * @method string[] getHeader($name) - * @method static string[] getHeader($name) - * @method string getHeaderLine($name) - * @method static string getHeaderLine($name) - * @method \Psr\Http\Message\MessageInterface withHeader($name, $value) - * @method static \Psr\Http\Message\MessageInterface withHeader($name, $value) - * @method \Psr\Http\Message\MessageInterface withAddedHeader($name, $value) - * @method static \Psr\Http\Message\MessageInterface withAddedHeader($name, $value) - * @method \Psr\Http\Message\MessageInterface withoutHeader($name) - * @method static \Psr\Http\Message\MessageInterface withoutHeader($name) + * @method bool hasHeader(string $name) + * @method static bool hasHeader(string $name) + * @method string[] getHeader(string $name) + * @method static string[] getHeader(string $name) + * @method string getHeaderLine(string $name) + * @method static string getHeaderLine(string $name) + * @method \Psr\Http\Message\MessageInterface withHeader(string $name, $value) + * @method static \Psr\Http\Message\MessageInterface withHeader(string $name, $value) + * @method \Psr\Http\Message\MessageInterface withAddedHeader(string $name, $value) + * @method static \Psr\Http\Message\MessageInterface withAddedHeader(string $name, $value) + * @method \Psr\Http\Message\MessageInterface withoutHeader(string $name) + * @method static \Psr\Http\Message\MessageInterface withoutHeader(string $name) * @method \Psr\Http\Message\StreamInterface getBody() * @method static \Psr\Http\Message\StreamInterface getBody() * @method \Psr\Http\Message\MessageInterface withBody(\Psr\Http\Message\StreamInterface $body) * @method static \Psr\Http\Message\MessageInterface withBody(\Psr\Http\Message\StreamInterface $body) - * @method \Imi\Util\Http\Contract\IRequest setRequestTarget($requestTarget) - * @method static \Imi\Util\Http\Contract\IRequest setRequestTarget($requestTarget) + * @method \Imi\Util\Http\Contract\IRequest setRequestTarget(string $requestTarget) + * @method static \Imi\Util\Http\Contract\IRequest setRequestTarget(string $requestTarget) * @method \Imi\Util\Http\Contract\IRequest setMethod(string $method) * @method static \Imi\Util\Http\Contract\IRequest setMethod(string $method) * @method \Imi\Util\Http\Contract\IRequest setUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) @@ -137,7 +137,7 @@ public function getClientAddress(): \Imi\Util\Socket\IPEndPoint /** * {@inheritDoc} */ - public function getServerParam(string $name, $default = null) + public function getServerParam(string $name, mixed $default = null): mixed { return self::__getProxyInstance()->getServerParam($name, $default); } @@ -145,7 +145,7 @@ public function getServerParam(string $name, $default = null) /** * {@inheritDoc} */ - public function getCookie(string $name, $default = null) + public function getCookie(string $name, ?string $default = null): ?string { return self::__getProxyInstance()->getCookie($name, $default); } @@ -177,7 +177,7 @@ public function setUploadedFiles(array $uploadedFiles): \Imi\Util\Http\Contract\ /** * {@inheritDoc} */ - public function setParsedBody($data): \Imi\Util\Http\Contract\IServerRequest + public function setParsedBody(object|array|null $data): \Imi\Util\Http\Contract\IServerRequest { return self::__getProxyInstance()->setParsedBody($data); } @@ -185,7 +185,7 @@ public function setParsedBody($data): \Imi\Util\Http\Contract\IServerRequest /** * {@inheritDoc} */ - public function setAttribute(string $name, $value): \Imi\Util\Http\Contract\IServerRequest + public function setAttribute(string $name, mixed $value): \Imi\Util\Http\Contract\IServerRequest { return self::__getProxyInstance()->setAttribute($name, $value); } @@ -201,7 +201,7 @@ public function removeAttribute(string $name): \Imi\Util\Http\Contract\IServerRe /** * {@inheritDoc} */ - public function get(?string $name = null, $default = null) + public function get(?string $name = null, mixed $default = null): mixed { return self::__getProxyInstance()->get($name, $default); } @@ -209,7 +209,7 @@ public function get(?string $name = null, $default = null) /** * {@inheritDoc} */ - public function post(?string $name = null, $default = null) + public function post(?string $name = null, mixed $default = null): mixed { return self::__getProxyInstance()->post($name, $default); } @@ -233,7 +233,7 @@ public function hasPost(string $name): bool /** * {@inheritDoc} */ - public function request(?string $name = null, $default = null) + public function request(?string $name = null, mixed $default = null): mixed { return self::__getProxyInstance()->request($name, $default); } @@ -265,7 +265,7 @@ public function setGet(array $get): \Imi\Util\Http\Contract\IServerRequest /** * {@inheritDoc} */ - public function withPost($post): \Imi\Util\Http\Contract\IServerRequest + public function withPost(mixed $post): \Imi\Util\Http\Contract\IServerRequest { return self::__getProxyInstance()->withPost($post); } @@ -273,7 +273,7 @@ public function withPost($post): \Imi\Util\Http\Contract\IServerRequest /** * {@inheritDoc} */ - public function setPost($post): \Imi\Util\Http\Contract\IServerRequest + public function setPost(mixed $post): \Imi\Util\Http\Contract\IServerRequest { return self::__getProxyInstance()->setPost($post); } @@ -297,7 +297,7 @@ public function setRequest(array $request): \Imi\Util\Http\Contract\IServerReque /** * {@inheritDoc} */ - public function getServerParams() + public function getServerParams(): array { return self::__getProxyInstance()->getServerParams(...\func_get_args()); } @@ -305,7 +305,7 @@ public function getServerParams() /** * {@inheritDoc} */ - public function getCookieParams() + public function getCookieParams(): array { return self::__getProxyInstance()->getCookieParams(...\func_get_args()); } @@ -313,7 +313,7 @@ public function getCookieParams() /** * {@inheritDoc} */ - public function withCookieParams(array $cookies) + public function withCookieParams(array $cookies): \Psr\Http\Message\ServerRequestInterface { return self::__getProxyInstance()->withCookieParams($cookies); } @@ -321,7 +321,7 @@ public function withCookieParams(array $cookies) /** * {@inheritDoc} */ - public function getQueryParams() + public function getQueryParams(): array { return self::__getProxyInstance()->getQueryParams(...\func_get_args()); } @@ -329,7 +329,7 @@ public function getQueryParams() /** * {@inheritDoc} */ - public function withQueryParams(array $query) + public function withQueryParams(array $query): \Psr\Http\Message\ServerRequestInterface { return self::__getProxyInstance()->withQueryParams($query); } @@ -337,7 +337,7 @@ public function withQueryParams(array $query) /** * {@inheritDoc} */ - public function getUploadedFiles() + public function getUploadedFiles(): array { return self::__getProxyInstance()->getUploadedFiles(...\func_get_args()); } @@ -345,7 +345,7 @@ public function getUploadedFiles() /** * {@inheritDoc} */ - public function withUploadedFiles(array $uploadedFiles) + public function withUploadedFiles(array $uploadedFiles): \Psr\Http\Message\ServerRequestInterface { return self::__getProxyInstance()->withUploadedFiles($uploadedFiles); } @@ -361,7 +361,7 @@ public function getParsedBody() /** * {@inheritDoc} */ - public function withParsedBody($data) + public function withParsedBody($data): \Psr\Http\Message\ServerRequestInterface { return self::__getProxyInstance()->withParsedBody($data); } @@ -369,7 +369,7 @@ public function withParsedBody($data) /** * {@inheritDoc} */ - public function getAttributes() + public function getAttributes(): array { return self::__getProxyInstance()->getAttributes(...\func_get_args()); } @@ -377,7 +377,7 @@ public function getAttributes() /** * {@inheritDoc} */ - public function getAttribute($name, $default = null) + public function getAttribute(string $name, $default = null) { return self::__getProxyInstance()->getAttribute($name, $default); } @@ -385,7 +385,7 @@ public function getAttribute($name, $default = null) /** * {@inheritDoc} */ - public function withAttribute($name, $value) + public function withAttribute(string $name, $value): \Psr\Http\Message\ServerRequestInterface { return self::__getProxyInstance()->withAttribute($name, $value); } @@ -393,7 +393,7 @@ public function withAttribute($name, $value) /** * {@inheritDoc} */ - public function withoutAttribute($name) + public function withoutAttribute(string $name): \Psr\Http\Message\ServerRequestInterface { return self::__getProxyInstance()->withoutAttribute($name); } @@ -401,7 +401,7 @@ public function withoutAttribute($name) /** * {@inheritDoc} */ - public function getRequestTarget() + public function getRequestTarget(): string { return self::__getProxyInstance()->getRequestTarget(...\func_get_args()); } @@ -409,7 +409,7 @@ public function getRequestTarget() /** * {@inheritDoc} */ - public function withRequestTarget($requestTarget) + public function withRequestTarget(string $requestTarget): \Psr\Http\Message\RequestInterface { return self::__getProxyInstance()->withRequestTarget($requestTarget); } @@ -417,7 +417,7 @@ public function withRequestTarget($requestTarget) /** * {@inheritDoc} */ - public function getMethod() + public function getMethod(): string { return self::__getProxyInstance()->getMethod(...\func_get_args()); } @@ -425,7 +425,7 @@ public function getMethod() /** * {@inheritDoc} */ - public function withMethod($method) + public function withMethod(string $method): \Psr\Http\Message\RequestInterface { return self::__getProxyInstance()->withMethod($method); } @@ -433,7 +433,7 @@ public function withMethod($method) /** * {@inheritDoc} */ - public function getUri() + public function getUri(): \Psr\Http\Message\UriInterface { return self::__getProxyInstance()->getUri(...\func_get_args()); } @@ -441,7 +441,7 @@ public function getUri() /** * {@inheritDoc} */ - public function withUri(\Psr\Http\Message\UriInterface $uri, $preserveHost = false) + public function withUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false): \Psr\Http\Message\RequestInterface { return self::__getProxyInstance()->withUri($uri, $preserveHost); } @@ -449,7 +449,7 @@ public function withUri(\Psr\Http\Message\UriInterface $uri, $preserveHost = fal /** * {@inheritDoc} */ - public function getProtocolVersion() + public function getProtocolVersion(): string { return self::__getProxyInstance()->getProtocolVersion(...\func_get_args()); } @@ -457,7 +457,7 @@ public function getProtocolVersion() /** * {@inheritDoc} */ - public function withProtocolVersion($version) + public function withProtocolVersion(string $version): \Psr\Http\Message\MessageInterface { return self::__getProxyInstance()->withProtocolVersion($version); } @@ -465,7 +465,7 @@ public function withProtocolVersion($version) /** * {@inheritDoc} */ - public function getHeaders() + public function getHeaders(): array { return self::__getProxyInstance()->getHeaders(...\func_get_args()); } @@ -473,7 +473,7 @@ public function getHeaders() /** * {@inheritDoc} */ - public function hasHeader($name) + public function hasHeader(string $name): bool { return self::__getProxyInstance()->hasHeader($name); } @@ -481,7 +481,7 @@ public function hasHeader($name) /** * {@inheritDoc} */ - public function getHeader($name) + public function getHeader(string $name): array { return self::__getProxyInstance()->getHeader($name); } @@ -489,7 +489,7 @@ public function getHeader($name) /** * {@inheritDoc} */ - public function getHeaderLine($name) + public function getHeaderLine(string $name): string { return self::__getProxyInstance()->getHeaderLine($name); } @@ -497,7 +497,7 @@ public function getHeaderLine($name) /** * {@inheritDoc} */ - public function withHeader($name, $value) + public function withHeader(string $name, $value): \Psr\Http\Message\MessageInterface { return self::__getProxyInstance()->withHeader($name, $value); } @@ -505,7 +505,7 @@ public function withHeader($name, $value) /** * {@inheritDoc} */ - public function withAddedHeader($name, $value) + public function withAddedHeader(string $name, $value): \Psr\Http\Message\MessageInterface { return self::__getProxyInstance()->withAddedHeader($name, $value); } @@ -513,7 +513,7 @@ public function withAddedHeader($name, $value) /** * {@inheritDoc} */ - public function withoutHeader($name) + public function withoutHeader(string $name): \Psr\Http\Message\MessageInterface { return self::__getProxyInstance()->withoutHeader($name); } @@ -521,7 +521,7 @@ public function withoutHeader($name) /** * {@inheritDoc} */ - public function getBody() + public function getBody(): \Psr\Http\Message\StreamInterface { return self::__getProxyInstance()->getBody(...\func_get_args()); } @@ -529,7 +529,7 @@ public function getBody() /** * {@inheritDoc} */ - public function withBody(\Psr\Http\Message\StreamInterface $body) + public function withBody(\Psr\Http\Message\StreamInterface $body): \Psr\Http\Message\MessageInterface { return self::__getProxyInstance()->withBody($body); } @@ -537,7 +537,7 @@ public function withBody(\Psr\Http\Message\StreamInterface $body) /** * {@inheritDoc} */ - public function setRequestTarget($requestTarget): \Imi\Util\Http\Contract\IRequest + public function setRequestTarget(string $requestTarget): \Imi\Util\Http\Contract\IRequest { return self::__getProxyInstance()->setRequestTarget($requestTarget); } diff --git a/src/Server/Http/Message/Proxy/ResponseProxy.php b/src/Server/Http/Message/Proxy/ResponseProxy.php index 9a8754db99..b707e4f964 100644 --- a/src/Server/Http/Message/Proxy/ResponseProxy.php +++ b/src/Server/Http/Message/Proxy/ResponseProxy.php @@ -34,8 +34,8 @@ * @method static \Imi\Util\Http\Contract\IResponse setCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) * @method array getCookieParams() * @method static array getCookieParams() - * @method mixed getCookie(string $name, $default = NULL) - * @method static mixed getCookie(string $name, $default = NULL) + * @method array|null getCookie(string $name, ?array $default = NULL) + * @method static array|null getCookie(string $name, ?array $default = NULL) * @method array getTrailers() * @method static array getTrailers() * @method bool hasTrailer(string $name) @@ -48,38 +48,38 @@ * @method static \Imi\Util\Http\Contract\IResponse setTrailer(string $name, string $value) * @method int getStatusCode() * @method static int getStatusCode() - * @method \Psr\Http\Message\ResponseInterface withStatus($code, $reasonPhrase = '') - * @method static \Psr\Http\Message\ResponseInterface withStatus($code, $reasonPhrase = '') + * @method \Psr\Http\Message\ResponseInterface withStatus(int $code, string $reasonPhrase = '') + * @method static \Psr\Http\Message\ResponseInterface withStatus(int $code, string $reasonPhrase = '') * @method string getReasonPhrase() * @method static string getReasonPhrase() * @method string getProtocolVersion() * @method static string getProtocolVersion() - * @method \Psr\Http\Message\MessageInterface withProtocolVersion($version) - * @method static \Psr\Http\Message\MessageInterface withProtocolVersion($version) + * @method \Psr\Http\Message\MessageInterface withProtocolVersion(string $version) + * @method static \Psr\Http\Message\MessageInterface withProtocolVersion(string $version) * @method string[][] getHeaders() * @method static string[][] getHeaders() - * @method bool hasHeader($name) - * @method static bool hasHeader($name) - * @method string[] getHeader($name) - * @method static string[] getHeader($name) - * @method string getHeaderLine($name) - * @method static string getHeaderLine($name) - * @method \Psr\Http\Message\MessageInterface withHeader($name, $value) - * @method static \Psr\Http\Message\MessageInterface withHeader($name, $value) - * @method \Psr\Http\Message\MessageInterface withAddedHeader($name, $value) - * @method static \Psr\Http\Message\MessageInterface withAddedHeader($name, $value) - * @method \Psr\Http\Message\MessageInterface withoutHeader($name) - * @method static \Psr\Http\Message\MessageInterface withoutHeader($name) + * @method bool hasHeader(string $name) + * @method static bool hasHeader(string $name) + * @method string[] getHeader(string $name) + * @method static string[] getHeader(string $name) + * @method string getHeaderLine(string $name) + * @method static string getHeaderLine(string $name) + * @method \Psr\Http\Message\MessageInterface withHeader(string $name, $value) + * @method static \Psr\Http\Message\MessageInterface withHeader(string $name, $value) + * @method \Psr\Http\Message\MessageInterface withAddedHeader(string $name, $value) + * @method static \Psr\Http\Message\MessageInterface withAddedHeader(string $name, $value) + * @method \Psr\Http\Message\MessageInterface withoutHeader(string $name) + * @method static \Psr\Http\Message\MessageInterface withoutHeader(string $name) * @method \Psr\Http\Message\StreamInterface getBody() * @method static \Psr\Http\Message\StreamInterface getBody() * @method \Psr\Http\Message\MessageInterface withBody(\Psr\Http\Message\StreamInterface $body) * @method static \Psr\Http\Message\MessageInterface withBody(\Psr\Http\Message\StreamInterface $body) * @method \Imi\Util\Http\Contract\IMessage setProtocolVersion(string $version) * @method static \Imi\Util\Http\Contract\IMessage setProtocolVersion(string $version) - * @method \Imi\Util\Http\Contract\IMessage setHeader(string $name, $value) - * @method static \Imi\Util\Http\Contract\IMessage setHeader(string $name, $value) - * @method \Imi\Util\Http\Contract\IMessage addHeader(string $name, $value) - * @method static \Imi\Util\Http\Contract\IMessage addHeader(string $name, $value) + * @method \Imi\Util\Http\Contract\IMessage setHeader(string $name, array|string $value) + * @method static \Imi\Util\Http\Contract\IMessage setHeader(string $name, array|string $value) + * @method \Imi\Util\Http\Contract\IMessage addHeader(string $name, array|string $value) + * @method static \Imi\Util\Http\Contract\IMessage addHeader(string $name, array|string $value) * @method \Imi\Util\Http\Contract\IMessage removeHeader(string $name) * @method static \Imi\Util\Http\Contract\IMessage removeHeader(string $name) * @method \Imi\Util\Http\Contract\IMessage setBody(\Psr\Http\Message\StreamInterface $body) diff --git a/src/Server/Http/Message/Proxy/ResponseProxyObject.php b/src/Server/Http/Message/Proxy/ResponseProxyObject.php index dbc423591c..335287b0af 100644 --- a/src/Server/Http/Message/Proxy/ResponseProxyObject.php +++ b/src/Server/Http/Message/Proxy/ResponseProxyObject.php @@ -37,8 +37,8 @@ * @method static \Imi\Util\Http\Contract\IResponse setCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) * @method array getCookieParams() * @method static array getCookieParams() - * @method mixed getCookie(string $name, $default = NULL) - * @method static mixed getCookie(string $name, $default = NULL) + * @method array|null getCookie(string $name, ?array $default = NULL) + * @method static array|null getCookie(string $name, ?array $default = NULL) * @method array getTrailers() * @method static array getTrailers() * @method bool hasTrailer(string $name) @@ -51,38 +51,38 @@ * @method static \Imi\Util\Http\Contract\IResponse setTrailer(string $name, string $value) * @method int getStatusCode() * @method static int getStatusCode() - * @method \Psr\Http\Message\ResponseInterface withStatus($code, $reasonPhrase = '') - * @method static \Psr\Http\Message\ResponseInterface withStatus($code, $reasonPhrase = '') + * @method \Psr\Http\Message\ResponseInterface withStatus(int $code, string $reasonPhrase = '') + * @method static \Psr\Http\Message\ResponseInterface withStatus(int $code, string $reasonPhrase = '') * @method string getReasonPhrase() * @method static string getReasonPhrase() * @method string getProtocolVersion() * @method static string getProtocolVersion() - * @method \Psr\Http\Message\MessageInterface withProtocolVersion($version) - * @method static \Psr\Http\Message\MessageInterface withProtocolVersion($version) + * @method \Psr\Http\Message\MessageInterface withProtocolVersion(string $version) + * @method static \Psr\Http\Message\MessageInterface withProtocolVersion(string $version) * @method string[][] getHeaders() * @method static string[][] getHeaders() - * @method bool hasHeader($name) - * @method static bool hasHeader($name) - * @method string[] getHeader($name) - * @method static string[] getHeader($name) - * @method string getHeaderLine($name) - * @method static string getHeaderLine($name) - * @method \Psr\Http\Message\MessageInterface withHeader($name, $value) - * @method static \Psr\Http\Message\MessageInterface withHeader($name, $value) - * @method \Psr\Http\Message\MessageInterface withAddedHeader($name, $value) - * @method static \Psr\Http\Message\MessageInterface withAddedHeader($name, $value) - * @method \Psr\Http\Message\MessageInterface withoutHeader($name) - * @method static \Psr\Http\Message\MessageInterface withoutHeader($name) + * @method bool hasHeader(string $name) + * @method static bool hasHeader(string $name) + * @method string[] getHeader(string $name) + * @method static string[] getHeader(string $name) + * @method string getHeaderLine(string $name) + * @method static string getHeaderLine(string $name) + * @method \Psr\Http\Message\MessageInterface withHeader(string $name, $value) + * @method static \Psr\Http\Message\MessageInterface withHeader(string $name, $value) + * @method \Psr\Http\Message\MessageInterface withAddedHeader(string $name, $value) + * @method static \Psr\Http\Message\MessageInterface withAddedHeader(string $name, $value) + * @method \Psr\Http\Message\MessageInterface withoutHeader(string $name) + * @method static \Psr\Http\Message\MessageInterface withoutHeader(string $name) * @method \Psr\Http\Message\StreamInterface getBody() * @method static \Psr\Http\Message\StreamInterface getBody() * @method \Psr\Http\Message\MessageInterface withBody(\Psr\Http\Message\StreamInterface $body) * @method static \Psr\Http\Message\MessageInterface withBody(\Psr\Http\Message\StreamInterface $body) * @method \Imi\Util\Http\Contract\IMessage setProtocolVersion(string $version) * @method static \Imi\Util\Http\Contract\IMessage setProtocolVersion(string $version) - * @method \Imi\Util\Http\Contract\IMessage setHeader(string $name, $value) - * @method static \Imi\Util\Http\Contract\IMessage setHeader(string $name, $value) - * @method \Imi\Util\Http\Contract\IMessage addHeader(string $name, $value) - * @method static \Imi\Util\Http\Contract\IMessage addHeader(string $name, $value) + * @method \Imi\Util\Http\Contract\IMessage setHeader(string $name, array|string $value) + * @method static \Imi\Util\Http\Contract\IMessage setHeader(string $name, array|string $value) + * @method \Imi\Util\Http\Contract\IMessage addHeader(string $name, array|string $value) + * @method static \Imi\Util\Http\Contract\IMessage addHeader(string $name, array|string $value) * @method \Imi\Util\Http\Contract\IMessage removeHeader(string $name) * @method static \Imi\Util\Http\Contract\IMessage removeHeader(string $name) * @method \Imi\Util\Http\Contract\IMessage setBody(\Psr\Http\Message\StreamInterface $body) @@ -189,7 +189,7 @@ public function getCookieParams(): array /** * {@inheritDoc} */ - public function getCookie(string $name, $default = null) + public function getCookie(string $name, ?array $default = null): ?array { return self::__getProxyInstance()->getCookie($name, $default); } @@ -237,7 +237,7 @@ public function setTrailer(string $name, string $value): \Imi\Util\Http\Contract /** * {@inheritDoc} */ - public function getStatusCode() + public function getStatusCode(): int { return self::__getProxyInstance()->getStatusCode(...\func_get_args()); } @@ -245,7 +245,7 @@ public function getStatusCode() /** * {@inheritDoc} */ - public function withStatus($code, $reasonPhrase = '') + public function withStatus(int $code, string $reasonPhrase = ''): \Psr\Http\Message\ResponseInterface { return self::__getProxyInstance()->withStatus($code, $reasonPhrase); } @@ -253,7 +253,7 @@ public function withStatus($code, $reasonPhrase = '') /** * {@inheritDoc} */ - public function getReasonPhrase() + public function getReasonPhrase(): string { return self::__getProxyInstance()->getReasonPhrase(...\func_get_args()); } @@ -261,7 +261,7 @@ public function getReasonPhrase() /** * {@inheritDoc} */ - public function getProtocolVersion() + public function getProtocolVersion(): string { return self::__getProxyInstance()->getProtocolVersion(...\func_get_args()); } @@ -269,7 +269,7 @@ public function getProtocolVersion() /** * {@inheritDoc} */ - public function withProtocolVersion($version) + public function withProtocolVersion(string $version): \Psr\Http\Message\MessageInterface { return self::__getProxyInstance()->withProtocolVersion($version); } @@ -277,7 +277,7 @@ public function withProtocolVersion($version) /** * {@inheritDoc} */ - public function getHeaders() + public function getHeaders(): array { return self::__getProxyInstance()->getHeaders(...\func_get_args()); } @@ -285,7 +285,7 @@ public function getHeaders() /** * {@inheritDoc} */ - public function hasHeader($name) + public function hasHeader(string $name): bool { return self::__getProxyInstance()->hasHeader($name); } @@ -293,7 +293,7 @@ public function hasHeader($name) /** * {@inheritDoc} */ - public function getHeader($name) + public function getHeader(string $name): array { return self::__getProxyInstance()->getHeader($name); } @@ -301,7 +301,7 @@ public function getHeader($name) /** * {@inheritDoc} */ - public function getHeaderLine($name) + public function getHeaderLine(string $name): string { return self::__getProxyInstance()->getHeaderLine($name); } @@ -309,7 +309,7 @@ public function getHeaderLine($name) /** * {@inheritDoc} */ - public function withHeader($name, $value) + public function withHeader(string $name, $value): \Psr\Http\Message\MessageInterface { return self::__getProxyInstance()->withHeader($name, $value); } @@ -317,7 +317,7 @@ public function withHeader($name, $value) /** * {@inheritDoc} */ - public function withAddedHeader($name, $value) + public function withAddedHeader(string $name, $value): \Psr\Http\Message\MessageInterface { return self::__getProxyInstance()->withAddedHeader($name, $value); } @@ -325,7 +325,7 @@ public function withAddedHeader($name, $value) /** * {@inheritDoc} */ - public function withoutHeader($name) + public function withoutHeader(string $name): \Psr\Http\Message\MessageInterface { return self::__getProxyInstance()->withoutHeader($name); } @@ -333,7 +333,7 @@ public function withoutHeader($name) /** * {@inheritDoc} */ - public function getBody() + public function getBody(): \Psr\Http\Message\StreamInterface { return self::__getProxyInstance()->getBody(...\func_get_args()); } @@ -341,7 +341,7 @@ public function getBody() /** * {@inheritDoc} */ - public function withBody(\Psr\Http\Message\StreamInterface $body) + public function withBody(\Psr\Http\Message\StreamInterface $body): \Psr\Http\Message\MessageInterface { return self::__getProxyInstance()->withBody($body); } @@ -357,7 +357,7 @@ public function setProtocolVersion(string $version): \Imi\Util\Http\Contract\IMe /** * {@inheritDoc} */ - public function setHeader(string $name, $value): \Imi\Util\Http\Contract\IMessage + public function setHeader(string $name, array|string $value): \Imi\Util\Http\Contract\IMessage { return self::__getProxyInstance()->setHeader($name, $value); } @@ -365,7 +365,7 @@ public function setHeader(string $name, $value): \Imi\Util\Http\Contract\IMessag /** * {@inheritDoc} */ - public function addHeader(string $name, $value): \Imi\Util\Http\Contract\IMessage + public function addHeader(string $name, array|string $value): \Imi\Util\Http\Contract\IMessage { return self::__getProxyInstance()->addHeader($name, $value); } diff --git a/src/Server/Http/Message/UploadedFile.php b/src/Server/Http/Message/UploadedFile.php index 8f661bb13e..1ba98936b1 100644 --- a/src/Server/Http/Message/UploadedFile.php +++ b/src/Server/Http/Message/UploadedFile.php @@ -67,17 +67,15 @@ public function __construct(string $fileName, string $mediaType, $tmpFileName, i /** * {@inheritDoc} */ - public function getStream() + public function getStream(): StreamInterface { return $this->stream ??= new FileStream($this->tmpFileName); } /** * {@inheritDoc} - * - * @return void */ - public function moveTo($targetPath) + public function moveTo(string $targetPath): void { if (!\is_string($targetPath)) { @@ -120,7 +118,7 @@ public function moveTo($targetPath) /** * {@inheritDoc} */ - public function getSize() + public function getSize(): ?int { return $this->size; } @@ -128,7 +126,7 @@ public function getSize() /** * {@inheritDoc} */ - public function getError() + public function getError(): int { return $this->error; } @@ -136,7 +134,7 @@ public function getError() /** * {@inheritDoc} */ - public function getClientFilename() + public function getClientFilename(): ?string { return $this->fileName; } @@ -144,7 +142,7 @@ public function getClientFilename() /** * {@inheritDoc} */ - public function getClientMediaType() + public function getClientMediaType(): ?string { return $this->mediaType; } diff --git a/src/Util/Http/AbstractMessage.php b/src/Util/Http/AbstractMessage.php index c814b7f060..1b7500717c 100644 --- a/src/Util/Http/AbstractMessage.php +++ b/src/Util/Http/AbstractMessage.php @@ -55,7 +55,7 @@ protected function initProtocolVersion(): void /** * {@inheritDoc} */ - public function getProtocolVersion() + public function getProtocolVersion(): string { if (!$this->protocolVersionInited) { @@ -68,8 +68,10 @@ public function getProtocolVersion() /** * {@inheritDoc} + * + * @return static */ - public function withProtocolVersion($version) + public function withProtocolVersion($version): self { $self = clone $this; $self->protocolVersion = $version; @@ -80,6 +82,8 @@ public function withProtocolVersion($version) /** * {@inheritDoc} + * + * @return static */ public function setProtocolVersion(string $version): self { @@ -99,7 +103,7 @@ protected function initHeaders(): void /** * {@inheritDoc} */ - public function getHeaders() + public function getHeaders(): array { if (!$this->headersInited) { @@ -113,7 +117,7 @@ public function getHeaders() /** * {@inheritDoc} */ - public function hasHeader($name) + public function hasHeader(string $name): bool { if (!$this->headersInited) { @@ -133,7 +137,7 @@ public function hasHeader($name) /** * {@inheritDoc} */ - public function getHeader($name) + public function getHeader(string $name): array { if (!$this->headersInited) { @@ -160,7 +164,7 @@ public function getHeader($name) /** * {@inheritDoc} */ - public function getHeaderLine($name) + public function getHeaderLine(string $name): string { if (!$this->headersInited) { @@ -184,8 +188,10 @@ public function getHeaderLine($name) /** * {@inheritDoc} + * + * @return static */ - public function withHeader($name, $value) + public function withHeader(string $name, $value): self { $self = clone $this; if (!$self->headersInited) @@ -199,6 +205,8 @@ public function withHeader($name, $value) /** * {@inheritDoc} + * + * @return static */ public function setHeader(string $name, $value): self { @@ -213,8 +221,10 @@ public function setHeader(string $name, $value): self /** * {@inheritDoc} + * + * @return static */ - public function withAddedHeader($name, $value) + public function withAddedHeader(string $name, $value): self { $self = clone $this; if (!$self->headersInited) @@ -229,6 +239,8 @@ public function withAddedHeader($name, $value) /** * {@inheritDoc} + * + * @return static */ public function addHeader(string $name, $value): self { @@ -272,8 +284,10 @@ public function addHeader(string $name, $value): self /** * {@inheritDoc} + * + * @return static */ - public function withoutHeader($name) + public function withoutHeader(string $name): self { $self = clone $this; if (!$self->headersInited) @@ -288,6 +302,8 @@ public function withoutHeader($name) /** * {@inheritDoc} + * + * @return static */ public function removeHeader(string $name): self { @@ -319,7 +335,7 @@ protected function initBody(): void /** * {@inheritDoc} */ - public function getBody() + public function getBody(): StreamInterface { if (!$this->bodyInited) { @@ -332,8 +348,10 @@ public function getBody() /** * {@inheritDoc} + * + * @return static */ - public function withBody(StreamInterface $body) + public function withBody(StreamInterface $body): self { $self = clone $this; $self->body = $body; @@ -344,6 +362,8 @@ public function withBody(StreamInterface $body) /** * {@inheritDoc} + * + * @return static */ public function setBody(StreamInterface $body): self { @@ -360,7 +380,7 @@ public function setBody(StreamInterface $body): self * * @return static */ - protected function mergeHeaders(array $headers, self $object = null): self + protected function mergeHeaders(array $headers, ?self $object = null): self { if (null === $object) { diff --git a/src/Util/Http/Contract/IMessage.php b/src/Util/Http/Contract/IMessage.php index 41e50dd232..660d50b655 100644 --- a/src/Util/Http/Contract/IMessage.php +++ b/src/Util/Http/Contract/IMessage.php @@ -34,7 +34,7 @@ public function setProtocolVersion(string $version): self; * * @throws \InvalidArgumentException for invalid header names or values */ - public function setHeader(string $name, $value): self; + public function setHeader(string $name, string|array $value): self; /** * Return an instance with the specified header appended with the given value. @@ -50,7 +50,7 @@ public function setHeader(string $name, $value): self; * * @throws \InvalidArgumentException for invalid header names or values */ - public function addHeader(string $name, $value): self; + public function addHeader(string $name, string|array $value): self; /** * Return an instance without the specified header. diff --git a/src/Util/Http/Contract/IRequest.php b/src/Util/Http/Contract/IRequest.php index 4790b2599b..f29f63b34b 100644 --- a/src/Util/Http/Contract/IRequest.php +++ b/src/Util/Http/Contract/IRequest.php @@ -20,11 +20,9 @@ interface IRequest extends RequestInterface * @see http://tools.ietf.org/html/rfc7230#section-5.3 (for the various * request-target forms allowed in request messages) * - * @param mixed $requestTarget - * * @return static */ - public function setRequestTarget($requestTarget): self; + public function setRequestTarget(string $requestTarget): self; /** * Return an instance with the provided HTTP method. diff --git a/src/Util/Http/Contract/IResponse.php b/src/Util/Http/Contract/IResponse.php index a02bb99f76..1ba47046bd 100644 --- a/src/Util/Http/Contract/IResponse.php +++ b/src/Util/Http/Contract/IResponse.php @@ -55,12 +55,8 @@ public function getCookieParams(): array; /** * 获取cookie值 - * - * @param mixed $default - * - * @return mixed */ - public function getCookie(string $name, $default = null); + public function getCookie(string $name, ?array $default = null): ?array; /** * 获取 Trailer 列表. diff --git a/src/Util/Http/Contract/IServerRequest.php b/src/Util/Http/Contract/IServerRequest.php index fea3283bcb..4f4b33bfe9 100644 --- a/src/Util/Http/Contract/IServerRequest.php +++ b/src/Util/Http/Contract/IServerRequest.php @@ -10,21 +10,13 @@ interface IServerRequest extends ServerRequestInterface, IRequest { /** * 获取服务器参数. - * - * @param mixed $default - * - * @return mixed */ - public function getServerParam(string $name, $default = null); + public function getServerParam(string $name, mixed $default = null): mixed; /** * 获取cookie值 - * - * @param mixed $default - * - * @return mixed */ - public function getCookie(string $name, $default = null); + public function getCookie(string $name, ?string $default = null): ?string; /** * Return an instance with the specified cookies. @@ -100,7 +92,7 @@ public function setUploadedFiles(array $uploadedFiles): self; * @throws \InvalidArgumentException if an unsupported argument type is * provided */ - public function setParsedBody($data): self; + public function setParsedBody(array|object|null $data): self; /** * Return an instance with the specified derived request attribute. @@ -115,7 +107,7 @@ public function setParsedBody($data): self; * * @return static */ - public function setAttribute(string $name, $value): self; + public function setAttribute(string $name, mixed $value): self; /** * Return an instance that removes the specified derived request attribute. @@ -134,22 +126,14 @@ public function removeAttribute(string $name): self; /** * 获取 GET 参数 * 当 $name 为 null 时,返回所有. - * - * @param mixed $default - * - * @return mixed */ - public function get(?string $name = null, $default = null); + public function get(?string $name = null, mixed $default = null): mixed; /** * 获取 POST 参数 * 当 $name 为 null 时,返回所有. - * - * @param mixed $default - * - * @return mixed */ - public function post(?string $name = null, $default = null); + public function post(?string $name = null, mixed $default = null): mixed; /** * 判断是否存在 GET 参数. @@ -165,13 +149,8 @@ public function hasPost(string $name): bool; * 获取 REQUEST 参数 * 当 $name 为 null 时,返回所有 * REQUEST 中包括:GET/POST/COOKIE. - * - * @param string $name - * @param mixed $default - * - * @return mixed */ - public function request(?string $name = null, $default = null); + public function request(?string $name = null, mixed $default = null): mixed; /** * 判断是否存在 REQUEST 参数 @@ -196,20 +175,16 @@ public function setGet(array $get): self; /** * 设置 POST 数据. * - * @param mixed $post - * * @return static */ - public function withPost($post): self; + public function withPost(mixed $post): self; /** * 设置 POST 数据. * - * @param mixed $post - * * @return static */ - public function setPost($post): self; + public function setPost(mixed $post): self; /** * 设置 Request 数据. diff --git a/src/Util/Http/Request.php b/src/Util/Http/Request.php index 9eaf230c21..34416e32e2 100644 --- a/src/Util/Http/Request.php +++ b/src/Util/Http/Request.php @@ -45,7 +45,7 @@ class Request extends AbstractMessage implements IRequest /** * {@inheritDoc} */ - public function getRequestTarget() + public function getRequestTarget(): string { if (null === $this->requestTarget) { @@ -64,8 +64,10 @@ public function getRequestTarget() /** * {@inheritDoc} + * + * @return static */ - public function withRequestTarget($requestTarget) + public function withRequestTarget(string $requestTarget): self { $self = clone $this; $self->requestTarget = $requestTarget; @@ -75,8 +77,10 @@ public function withRequestTarget($requestTarget) /** * {@inheritDoc} + * + * @return static */ - public function setRequestTarget($requestTarget): self + public function setRequestTarget(string $requestTarget): self { $this->requestTarget = $requestTarget; @@ -93,7 +97,7 @@ protected function initMethod(): void /** * {@inheritDoc} */ - public function getMethod() + public function getMethod(): string { if (!$this->methodInited) { @@ -106,8 +110,10 @@ public function getMethod() /** * {@inheritDoc} + * + * @return static */ - public function withMethod($method) + public function withMethod(string $method): self { $self = clone $this; $self->method = $method; @@ -118,6 +124,8 @@ public function withMethod($method) /** * {@inheritDoc} + * + * @return static */ public function setMethod(string $method): self { @@ -137,7 +145,7 @@ protected function initUri(): void /** * {@inheritDoc} */ - public function getUri() + public function getUri(): UriInterface { if (!$this->uriInited) { @@ -150,8 +158,10 @@ public function getUri() /** * {@inheritDoc} + * + * @return static */ - public function withUri(UriInterface $uri, $preserveHost = false) + public function withUri(UriInterface $uri, bool $preserveHost = false): self { $self = clone $this; @@ -161,6 +171,8 @@ public function withUri(UriInterface $uri, $preserveHost = false) /** * {@inheritDoc} + * + * @return static */ public function setUri(UriInterface $uri, bool $preserveHost = false): self { diff --git a/src/Util/Http/Response.php b/src/Util/Http/Response.php index bab2e7e79e..9684a14ec8 100644 --- a/src/Util/Http/Response.php +++ b/src/Util/Http/Response.php @@ -43,15 +43,17 @@ public function __construct() /** * {@inheritDoc} */ - public function getStatusCode() + public function getStatusCode(): int { return $this->statusCode; } /** * {@inheritDoc} + * + * @return static */ - public function withStatus($code, $reasonPhrase = '') + public function withStatus(int $code, string $reasonPhrase = ''): self { $self = clone $this; $self->statusCode = $code; @@ -69,6 +71,8 @@ public function withStatus($code, $reasonPhrase = '') /** * {@inheritDoc} + * + * @return static */ public function setStatus(int $code, string $reasonPhrase = ''): self { @@ -88,7 +92,7 @@ public function setStatus(int $code, string $reasonPhrase = ''): self /** * {@inheritDoc} */ - public function getReasonPhrase() + public function getReasonPhrase(): string { if ('' === $this->reasonPhrase) { @@ -100,6 +104,8 @@ public function getReasonPhrase() /** * {@inheritDoc} + * + * @return static */ public function withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false): self { @@ -119,6 +125,8 @@ public function withCookie(string $key, string $value, int $expire = 0, string $ /** * {@inheritDoc} + * + * @return static */ public function setCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false): self { @@ -146,7 +154,7 @@ public function getCookieParams(): array /** * {@inheritDoc} */ - public function getCookie(string $name, $default = null) + public function getCookie(string $name, ?array $default = null): ?array { return $this->cookies[$name] ?? $default; } @@ -177,6 +185,8 @@ public function getTrailer(string $name): ?string /** * {@inheritDoc} + * + * @return static */ public function withTrailer(string $name, string $value): self { @@ -188,6 +198,8 @@ public function withTrailer(string $name, string $value): self /** * {@inheritDoc} + * + * @return static */ public function setTrailer(string $name, string $value): self { diff --git a/src/Util/Http/ServerRequest.php b/src/Util/Http/ServerRequest.php index 331aac8791..9d1fda3b14 100644 --- a/src/Util/Http/ServerRequest.php +++ b/src/Util/Http/ServerRequest.php @@ -98,7 +98,7 @@ public function getServerParams(): array /** * {@inheritDoc} */ - public function getServerParam(string $name, $default = null) + public function getServerParam(string $name, mixed $default = null): mixed { if (!$this->serverInited) { @@ -118,6 +118,8 @@ protected function initRequestParams(): void /** * {@inheritDoc} + * + * @return static */ public function setCookieParams(array $cookies): self { @@ -134,7 +136,7 @@ public function setCookieParams(array $cookies): self /** * {@inheritDoc} */ - public function getCookieParams() + public function getCookieParams(): array { if (!$this->requestParamsInited) { @@ -147,8 +149,10 @@ public function getCookieParams() /** * {@inheritDoc} + * + * @return static */ - public function withCookieParams(array $cookies) + public function withCookieParams(array $cookies): self { $self = clone $this; if (!$self->requestParamsInited) @@ -164,7 +168,7 @@ public function withCookieParams(array $cookies) /** * {@inheritDoc} */ - public function getCookie(string $name, $default = null) + public function getCookie(string $name, ?string $default = null): ?string { if (!$this->requestParamsInited) { @@ -177,6 +181,8 @@ public function getCookie(string $name, $default = null) /** * {@inheritDoc} + * + * @return static */ public function setQueryParams(array $query): self { @@ -193,7 +199,7 @@ public function setQueryParams(array $query): self /** * {@inheritDoc} */ - public function getQueryParams() + public function getQueryParams(): array { if (!$this->requestParamsInited) { @@ -206,8 +212,10 @@ public function getQueryParams() /** * {@inheritDoc} + * + * @return static */ - public function withQueryParams(array $query) + public function withQueryParams(array $query): self { $self = clone $this; if (!$self->requestParamsInited) @@ -230,7 +238,7 @@ protected function initUploadedFiles(): void /** * {@inheritDoc} */ - public function getUploadedFiles() + public function getUploadedFiles(): array { if (!$this->uploadedFilesInited) { @@ -243,8 +251,10 @@ public function getUploadedFiles() /** * {@inheritDoc} + * + * @return static */ - public function withUploadedFiles(array $uploadedFiles) + public function withUploadedFiles(array $uploadedFiles): self { $self = clone $this; @@ -254,6 +264,8 @@ public function withUploadedFiles(array $uploadedFiles) /** * {@inheritDoc} + * + * @return static */ public function setUploadedFiles(array $uploadedFiles): self { @@ -347,8 +359,10 @@ public function getParsedBody() /** * {@inheritDoc} + * + * @return static */ - public function withParsedBody($data) + public function withParsedBody($data): self { $self = clone $this; $self->parsedBody = $data; @@ -358,6 +372,8 @@ public function withParsedBody($data) /** * {@inheritDoc} + * + * @return static */ public function setParsedBody($data): self { @@ -369,7 +385,7 @@ public function setParsedBody($data): self /** * {@inheritDoc} */ - public function getAttributes() + public function getAttributes(): array { return $this->attributes; } @@ -377,7 +393,7 @@ public function getAttributes() /** * {@inheritDoc} */ - public function getAttribute($name, $default = null) + public function getAttribute(string $name, $default = null) { $attributes = $this->attributes; if (\array_key_exists($name, $attributes)) @@ -392,8 +408,10 @@ public function getAttribute($name, $default = null) /** * {@inheritDoc} + * + * @return static */ - public function withAttribute($name, $value) + public function withAttribute(string $name, $value): self { $self = clone $this; $self->attributes[$name] = $value; @@ -403,6 +421,8 @@ public function withAttribute($name, $value) /** * {@inheritDoc} + * + * @return static */ public function setAttribute(string $name, $value): self { @@ -413,8 +433,10 @@ public function setAttribute(string $name, $value): self /** * {@inheritDoc} + * + * @return static */ - public function withoutAttribute($name) + public function withoutAttribute(string $name): self { $self = clone $this; if (\array_key_exists($name, $self->attributes)) @@ -427,6 +449,8 @@ public function withoutAttribute($name) /** * {@inheritDoc} + * + * @return static */ public function removeAttribute(string $name): self { @@ -441,7 +465,7 @@ public function removeAttribute(string $name): self /** * {@inheritDoc} */ - public function get(?string $name = null, $default = null) + public function get(?string $name = null, mixed $default = null): mixed { if (!$this->requestParamsInited) { @@ -461,7 +485,7 @@ public function get(?string $name = null, $default = null) /** * {@inheritDoc} */ - public function post(?string $name = null, $default = null) + public function post(?string $name = null, mixed $default = null): mixed { if (!$this->requestParamsInited) { @@ -509,7 +533,7 @@ public function hasPost(string $name): bool /** * {@inheritDoc} */ - public function request(?string $name = null, $default = null) + public function request(?string $name = null, mixed $default = null): mixed { if (!$this->requestParamsInited) { @@ -547,6 +571,8 @@ public function hasRequest(string $name): bool /** * {@inheritDoc} + * + * @return static */ public function withGet(array $get): self { @@ -563,6 +589,8 @@ public function withGet(array $get): self /** * {@inheritDoc} + * + * @return static */ public function setGet(array $get): self { @@ -578,8 +606,10 @@ public function setGet(array $get): self /** * {@inheritDoc} + * + * @return static */ - public function withPost($post): self + public function withPost(mixed $post): self { $self = clone $this; if (!$self->requestParamsInited) @@ -594,8 +624,10 @@ public function withPost($post): self /** * {@inheritDoc} + * + * @return static */ - public function setPost($post): self + public function setPost(mixed $post): self { if (!$this->requestParamsInited) { @@ -609,6 +641,8 @@ public function setPost($post): self /** * {@inheritDoc} + * + * @return static */ public function withRequest(array $request): self { @@ -625,6 +659,8 @@ public function withRequest(array $request): self /** * {@inheritDoc} + * + * @return static */ public function setRequest(array $request): self { diff --git a/src/Util/Stream/FileStream.php b/src/Util/Stream/FileStream.php index 26a20cae41..0e03c07076 100644 --- a/src/Util/Stream/FileStream.php +++ b/src/Util/Stream/FileStream.php @@ -70,7 +70,7 @@ public function __destruct() /** * {@inheritDoc} */ - public function __toString() + public function __toString(): string { try { @@ -109,7 +109,7 @@ public function detach() /** * {@inheritDoc} */ - public function getSize() + public function getSize(): ?int { $stat = fstat($this->stream); if (false === $stat) @@ -123,7 +123,7 @@ public function getSize() /** * {@inheritDoc} */ - public function tell() + public function tell(): int { $result = ftell($this->stream); if (false === $result) @@ -137,7 +137,7 @@ public function tell() /** * {@inheritDoc} */ - public function eof() + public function eof(): bool { return feof($this->stream); } @@ -145,17 +145,15 @@ public function eof() /** * {@inheritDoc} */ - public function isSeekable() + public function isSeekable(): bool { return (bool) $this->getMetadata('seekable'); } /** * {@inheritDoc} - * - * @return void */ - public function seek($offset, $whence = \SEEK_SET) + public function seek(int $offset, int $whence = \SEEK_SET): void { if (-1 === fseek($this->stream, $offset, $whence)) { @@ -177,7 +175,7 @@ public function rewind(): void /** * {@inheritDoc} */ - public function isWritable() + public function isWritable(): bool { return \in_array($this->mode, [ StreamMode::WRITE_CLEAN, @@ -193,7 +191,7 @@ public function isWritable() /** * {@inheritDoc} */ - public function write($string) + public function write(string $string): int { $result = fwrite($this->stream, $string); if (false === $result) @@ -207,7 +205,7 @@ public function write($string) /** * {@inheritDoc} */ - public function isReadable() + public function isReadable(): bool { return \in_array($this->mode, [ StreamMode::READ_WRITE, @@ -221,7 +219,7 @@ public function isReadable() /** * {@inheritDoc} */ - public function read($length) + public function read(int $length): string { $result = fread($this->stream, $length); if (false === $result) @@ -235,7 +233,7 @@ public function read($length) /** * {@inheritDoc} */ - public function getContents() + public function getContents(): string { $result = stream_get_contents($this->stream); if (false === $result) @@ -249,7 +247,7 @@ public function getContents() /** * {@inheritDoc} */ - public function getMetadata($key = null) + public function getMetadata(?string $key = null) { $result = stream_get_meta_data($this->stream); // @phpstan-ignore-next-line diff --git a/src/Util/Stream/MemoryStream.php b/src/Util/Stream/MemoryStream.php index b4f3fac0fd..b55d15f47d 100644 --- a/src/Util/Stream/MemoryStream.php +++ b/src/Util/Stream/MemoryStream.php @@ -33,7 +33,7 @@ public function __construct(string $content = '') /** * {@inheritDoc} */ - public function __toString() + public function __toString(): string { return $this->content; } @@ -58,7 +58,7 @@ public function detach() /** * {@inheritDoc} */ - public function getSize() + public function getSize(): ?int { return $this->size; } @@ -66,7 +66,7 @@ public function getSize() /** * {@inheritDoc} */ - public function tell() + public function tell(): int { return $this->position; } @@ -74,7 +74,7 @@ public function tell() /** * {@inheritDoc} */ - public function eof() + public function eof(): bool { return $this->position >= $this->size - 1; } @@ -82,17 +82,15 @@ public function eof() /** * {@inheritDoc} */ - public function isSeekable() + public function isSeekable(): bool { return true; } /** * {@inheritDoc} - * - * @return void */ - public function seek($offset, $whence = \SEEK_SET) + public function seek(int $offset, int $whence = \SEEK_SET): void { switch ($whence) { @@ -123,7 +121,7 @@ public function rewind(): void /** * {@inheritDoc} */ - public function isWritable() + public function isWritable(): bool { return true; } @@ -131,7 +129,7 @@ public function isWritable() /** * {@inheritDoc} */ - public function write($string) + public function write(string $string): int { $content = &$this->content; $position = &$this->position; @@ -158,7 +156,7 @@ public function write($string) /** * {@inheritDoc} */ - public function isReadable() + public function isReadable(): bool { return true; } @@ -166,7 +164,7 @@ public function isReadable() /** * {@inheritDoc} */ - public function read($length) + public function read(int $length): string { $position = &$this->position; $result = substr($this->content, $position, $length); @@ -178,7 +176,7 @@ public function read($length) /** * {@inheritDoc} */ - public function getContents() + public function getContents(): string { $position = &$this->position; if (0 === $position) @@ -196,7 +194,7 @@ public function getContents() /** * {@inheritDoc} */ - public function getMetadata($key = null) + public function getMetadata(?string $key = null) { return null; } diff --git a/src/Util/Uri.php b/src/Util/Uri.php index 513bd302fa..a7609659e6 100644 --- a/src/Util/Uri.php +++ b/src/Util/Uri.php @@ -159,7 +159,7 @@ public static function getDomain(UriInterface $uri): string /** * {@inheritDoc} */ - public function getScheme() + public function getScheme(): string { return $this->scheme; } @@ -167,7 +167,7 @@ public function getScheme() /** * {@inheritDoc} */ - public function getAuthority() + public function getAuthority(): string { $result = $this->host; if ('' !== $this->userInfo) @@ -185,7 +185,7 @@ public function getAuthority() /** * {@inheritDoc} */ - public function getUserInfo() + public function getUserInfo(): string { return $this->userInfo; } @@ -193,7 +193,7 @@ public function getUserInfo() /** * {@inheritDoc} */ - public function getHost() + public function getHost(): string { return $this->host; } @@ -201,7 +201,7 @@ public function getHost() /** * {@inheritDoc} */ - public function getPort() + public function getPort(): ?int { return $this->port; } @@ -209,7 +209,7 @@ public function getPort() /** * {@inheritDoc} */ - public function getPath() + public function getPath(): string { return $this->path; } @@ -217,7 +217,7 @@ public function getPath() /** * {@inheritDoc} */ - public function getQuery() + public function getQuery(): string { return $this->query; } @@ -225,7 +225,7 @@ public function getQuery() /** * {@inheritDoc} */ - public function getFragment() + public function getFragment(): string { return $this->fragment; } @@ -233,7 +233,7 @@ public function getFragment() /** * {@inheritDoc} */ - public function withScheme($scheme) + public function withScheme(string $scheme): self { if (!\is_string($scheme)) { @@ -249,10 +249,10 @@ public function withScheme($scheme) * {@inheritDoc} */ public function withUserInfo( - $user, + string $user, #[\SensitiveParameter] - $password = null - ) { + ?string $password = null + ): self { $self = clone $this; $self->userInfo = $user; if (null !== $password) @@ -266,7 +266,7 @@ public function withUserInfo( /** * {@inheritDoc} */ - public function withHost($host) + public function withHost(string $host): self { $self = clone $this; $self->host = $host; @@ -277,7 +277,7 @@ public function withHost($host) /** * {@inheritDoc} */ - public function withPort($port) + public function withPort(?int $port): self { $self = clone $this; $self->port = $port; @@ -288,7 +288,7 @@ public function withPort($port) /** * {@inheritDoc} */ - public function withPath($path) + public function withPath(string $path): self { $self = clone $this; $self->path = $path; @@ -299,7 +299,7 @@ public function withPath($path) /** * {@inheritDoc} */ - public function withQuery($query) + public function withQuery(string $query): self { $self = clone $this; $self->query = $query; @@ -310,7 +310,7 @@ public function withQuery($query) /** * {@inheritDoc} */ - public function withFragment($fragment) + public function withFragment(string $fragment): self { $self = clone $this; $self->fragment = $fragment; diff --git a/tests/unit/Component/Tests/Util/Http/ResponseTest.php b/tests/unit/Component/Tests/Util/Http/ResponseTest.php index 8cab80a8c8..26f28fcfb1 100644 --- a/tests/unit/Component/Tests/Util/Http/ResponseTest.php +++ b/tests/unit/Component/Tests/Util/Http/ResponseTest.php @@ -55,7 +55,7 @@ private function __testX(string $type): void 'secure' => false, 'httponly' => false, ], $response->getCookie('a')); - $this->assertEquals('aaa', $response->getCookie('b', 'aaa')); + $this->assertEquals([], $response->getCookie('b', [])); // trailer $response = new Response(); diff --git a/tests/unit/Component/Tests/Util/Http/ServerRequestTest.php b/tests/unit/Component/Tests/Util/Http/ServerRequestTest.php index a8c3df78ea..0385961895 100644 --- a/tests/unit/Component/Tests/Util/Http/ServerRequestTest.php +++ b/tests/unit/Component/Tests/Util/Http/ServerRequestTest.php @@ -16,6 +16,7 @@ use Imi\Util\Http\ServerRequest; use Imi\Util\Stream\MemoryStream; use Imi\Util\Uri; +use TypeError; class ServerRequestTest extends BaseTest { @@ -65,7 +66,15 @@ private function __testX(string $type): void } $request = new ServerRequest(); - $this->assertNull($request->getUri()); + try + { + $this->assertNull($request->getUri()); + $this->assertTrue(false); + } + catch (TypeError) + { + $this->assertTrue(true); + } $this->__testHeader($type); $this->__testParsedBody($type); diff --git a/website/src/page/index.html b/website/src/page/index.html index 6cc52a0529..0292fd96a3 100644 --- a/website/src/page/index.html +++ b/website/src/page/index.html @@ -97,10 +97,10 @@

PHP长连接微服务分布式开发框架

src="https://gitee.com/yurunsoft/IMI/badge/star.svg?theme=gvp" alt="star" loading="lazy" /> Php Version Swoole Version