From a04ef2983f52742db343bace5ccc34004933e2f7 Mon Sep 17 00:00:00 2001 From: Yurun Date: Fri, 13 Oct 2023 14:57:18 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E8=BF=90=E8=A1=8C=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8D=87=E7=BA=A7=EF=BC=8CPHP=20>=3D=208.1?= =?UTF-8?q?=EF=BC=8CSwoole=20>=3D=205.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 112 +----------------- .github/workflows/phpcs.yml | 4 +- .github/workflows/phpstan.yml | 4 +- .github/workflows/rector.yml | 4 +- README.md | 8 +- composer.json | 5 +- doc/README.md | 6 +- doc/base/env.md | 4 +- doc/base/qa.md | 4 +- doc/components/aop/index.md | 2 +- doc/components/mqtt/client.md | 2 - doc/production/docker.md | 6 +- src/Components/access-control/README.md | 4 +- src/Components/amqp/README.md | 8 +- src/Components/amqp/composer.json | 2 +- src/Components/apidoc/README.md | 8 +- src/Components/apidoc/composer.json | 2 +- src/Components/grpc/README.md | 6 +- src/Components/hprose/README.md | 4 +- src/Components/jwt/README.md | 4 +- src/Components/kafka/README.md | 8 +- src/Components/kafka/composer.json | 2 +- src/Components/macro/README.md | 8 +- src/Components/mqtt/README.md | 8 +- src/Components/mqtt/composer.json | 2 +- src/Components/pgsql/README.md | 8 +- src/Components/pgsql/composer.json | 2 +- src/Components/phar/composer.json | 2 +- .../phar/tests/project/composer.json | 2 +- src/Components/queue/README.md | 8 +- src/Components/queue/composer.json | 2 +- src/Components/rate-limit/README.md | 4 +- src/Components/rpc/README.md | 4 +- src/Components/shared-memory/README.md | 4 +- src/Components/smarty/README.md | 8 +- src/Components/smarty/tests/composer.json | 2 +- src/Components/snowflake/README.md | 6 +- src/Components/swoole-tracker/README.md | 8 +- src/Components/swoole/composer.json | 4 +- website/src/page/index.html | 4 +- 40 files changed, 97 insertions(+), 198 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 693530b9ba..4f9a57d757 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,12 +26,6 @@ jobs: postgresql_version: "" - version: 5.0-php8.0 postgresql_version: "" - - version: 4.8-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 +106,8 @@ jobs: fail-fast: false matrix: swoole: - - version: 4.8-php8.0 - postgresql_version: f5eda17f89d160d0a89ac7c5db4636bdaefd48e6 + - version: 5.0-php8.2 + postgresql_version: "" roadrunner: [2.7.*] env: ENV_SERVICE: swoole @@ -190,7 +184,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 +275,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.0", "8.1", "8.2"] + swoole: [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 +396,7 @@ jobs: strategy: fail-fast: false matrix: - php: ["7.4", "8.0", "8.1"] # 部分扩展还未在 pecl 发布 PHP 8.2 Windows 版扩展,所以无法测试 + php: ["8.0", "8.1"] # 部分扩展还未在 pecl 发布 PHP 8.2 Windows 版扩展,所以无法测试 roadrunner: [2.7.*] extensions: [ @@ -483,92 +472,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..955b314f81 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "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", @@ -42,7 +42,8 @@ "symfony/polyfill-php71": "*", "symfony/polyfill-php72": "*", "symfony/polyfill-php73": "*", - "symfony/polyfill-php74": "*" + "symfony/polyfill-php74": "*", + "symfony/polyfill-php80": "*" }, "autoload": { "psr-4": { 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/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..f769b09bb5 100644 --- a/src/Components/amqp/composer.json +++ b/src/Components/amqp/composer.json @@ -9,7 +9,7 @@ }, "require-dev": { "yurunsoft/ide-helper": "~1.0", - "swoole/ide-helper": "~4.8", + "swoole/ide-helper": "~5.0", "phpunit/phpunit": "~9.6" }, "autoload": { 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/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/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/kafka/README.md b/src/Components/kafka/README.md index 6cd5a668b0..a28976adfd 100644 --- a/src/Components/kafka/README.md +++ b/src/Components/kafka/README.md @@ -1,8 +1,8 @@ # imi-kafka [![Latest Version](https://img.shields.io/packagist/v/imiphp/imi-kafka.svg)](https://packagist.org/packages/imiphp/imi-kafka) -[![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-kafka.svg)](https://github.com/imiphp/imi-kafka/blob/master/LICENSE) ## 介绍 @@ -272,9 +272,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/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/tests/project/composer.json b/src/Components/phar/tests/project/composer.json index 0fda44ee6e..c1ab112857 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", 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..9f0dd8e436 100644 --- a/src/Components/queue/composer.json +++ b/src/Components/queue/composer.json @@ -6,7 +6,7 @@ "require": {}, "require-dev": { "yurunsoft/ide-helper": "~1.0", - "swoole/ide-helper": "~4.8", + "swoole/ide-helper": "~5.0", "phpunit/phpunit": "~9.6" }, "autoload": { 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/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/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/swoole-tracker/README.md b/src/Components/swoole-tracker/README.md index a50dc9040a..01bc241097 100644 --- a/src/Components/swoole-tracker/README.md +++ b/src/Components/swoole-tracker/README.md @@ -1,8 +1,8 @@ # imi-swoole-tracker [![Latest Version](https://img.shields.io/packagist/v/imiphp/imi-swoole-tracker.svg)](https://packagist.org/packages/imiphp/imi-swoole-tracker) -[![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-swoole-tracker.svg)](https://github.com/imiphp/imi-swoole-tracker/blob/master/LICENSE) ## 介绍 @@ -185,9 +185,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/swoole/composer.json b/src/Components/swoole/composer.json index 8c9093f5b7..db6dad21ad 100644 --- a/src/Components/swoole/composer.json +++ b/src/Components/swoole/composer.json @@ -4,12 +4,12 @@ "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/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 Date: Mon, 16 Oct 2023 15:40:10 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E7=9A=84=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 30 +- phpstan.neon | 2 +- split-repository/composer.json | 3 +- src/Bean/ReflectionUtil.php | 10 +- src/Cache/Handler/Apcu.php | 16 +- src/Cache/Handler/File.php | 16 +- src/Cache/Handler/Memory.php | 16 +- src/Cache/Handler/Redis.php | 16 +- src/Cache/Handler/RedisHash.php | 16 +- src/Cache/Handler/RequestContext.php | 16 +- src/Components/grpc/composer.json | 2 +- .../swoole/src/Log/SwooleLogger.php | 13 +- src/Facade/Cli/FacadeGenerate.php | 6 +- src/Log/Formatter/ConsoleLineFormatter.php | 6 +- src/Log/Handler/ConsoleHandler.php | 5 +- src/Log/MonoLogger.php | 17 +- .../Cli/RequestContextProxyGenerate.php | 6 +- .../Http/Message/Contract/IHttpResponse.php | 10 +- .../Http/Message/Proxy/RequestProxy.php | 220 ++++++------ .../Http/Message/Proxy/RequestProxyObject.php | 318 +++++++++--------- .../Http/Message/Proxy/ResponseProxy.php | 100 +++--- .../Message/Proxy/ResponseProxyObject.php | 160 ++++----- src/Server/Http/Message/Response.php | 6 +- src/Server/Http/Message/UploadedFile.php | 14 +- src/Util/Http/AbstractMessage.php | 36 +- src/Util/Http/Contract/IMessage.php | 20 +- src/Util/Http/Contract/IRequest.php | 14 +- src/Util/Http/Contract/IResponse.php | 26 +- src/Util/Http/Contract/IServerRequest.php | 83 +---- src/Util/Http/Request.php | 18 +- src/Util/Http/Response.php | 18 +- src/Util/Http/ServerRequest.php | 56 +-- src/Util/Stream/FileStream.php | 24 +- src/Util/Stream/MemoryStream.php | 24 +- src/Util/Uri.php | 34 +- .../Tests/Util/Http/ResponseTest.php | 2 +- .../Tests/Util/Http/ServerRequestTest.php | 11 +- 37 files changed, 653 insertions(+), 737 deletions(-) diff --git a/composer.json b/composer.json index 955b314f81..e96bd90388 100644 --- a/composer.json +++ b/composer.json @@ -7,28 +7,22 @@ "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,15 +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": "*", - "symfony/polyfill-php80": "*" + "yurunsoft/yurun-http": "^5.0.0" }, + "replace": {}, "autoload": { "psr-4": { "Imi\\": "src/" 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..1fd6c20104 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; } @@ -172,9 +172,13 @@ public static function allowsType(\ReflectionType $type, string $checkType, ?str { if (null !== $className) { - $typeStr = $className; + $typeStr = '\\' . $className; } } + elseif ('static' !== $typeStr) + { + $typeStr = '\\' . $typeStr; + } } return $typeStr === $checkType || \in_array($typeStr, $checkTypes) || is_subclass_of($checkType, $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/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/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/Facade/Cli/FacadeGenerate.php b/src/Facade/Cli/FacadeGenerate.php index 6d29da8d7a..93f09b7d7a 100644 --- a/src/Facade/Cli/FacadeGenerate.php +++ b/src/Facade/Cli/FacadeGenerate.php @@ -76,10 +76,14 @@ public function generate(string $facadeClass, string $class, bool $request): voi if (false !== $docComment && preg_match('/@return\s+([^\s]+)/', $docComment, $matches) > 0) { $class = $matches[1]; - if ('self' === $class || 'static' === $class) + if ('self' === $class) { $returnType = '\\' . $method->getDeclaringClass()->getName(); } + elseif ('static' === $class) + { + $returnType = 'static'; + } elseif ('\\' === $class[0]) { $returnType = $class; 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/RequestContextProxy/Cli/RequestContextProxyGenerate.php b/src/RequestContextProxy/Cli/RequestContextProxyGenerate.php index f12ebd49e4..44bb6bed84 100644 --- a/src/RequestContextProxy/Cli/RequestContextProxyGenerate.php +++ b/src/RequestContextProxy/Cli/RequestContextProxyGenerate.php @@ -93,10 +93,14 @@ public function generate(string $target, string $class, string $name, ?string $b if (false !== $docComment && preg_match('/@return\s+([^\s]+)/', $docComment, $matches) > 0) { $class = $matches[1]; - if ('self' === $class || 'static' === $class) + if ('self' === $class) { $returnType = '\\' . $method->getDeclaringClass()->getName(); } + elseif ('static' === $class) + { + $returnType = 'static'; + } elseif ('\\' === $class[0]) { $returnType = $class; diff --git a/src/Server/Http/Message/Contract/IHttpResponse.php b/src/Server/Http/Message/Contract/IHttpResponse.php index 7d0ed5c916..6f9aafc903 100644 --- a/src/Server/Http/Message/Contract/IHttpResponse.php +++ b/src/Server/Http/Message/Contract/IHttpResponse.php @@ -17,12 +17,12 @@ interface IHttpResponse extends IResponse * 设置服务器端重定向 * 默认状态码为302. */ - public function redirect(string $url, int $status = StatusCode::FOUND): self; + public function redirect(string $url, int $status = StatusCode::FOUND): static; /** * 发送所有响应数据. */ - public function send(): self; + public function send(): static; /** * 发送文件,一般用于文件下载. @@ -31,7 +31,7 @@ public function send(): self; * @param int $offset 上传文件的偏移量,可以指定从文件的中间部分开始传输数据。此特性可用于支持断点续传。 * @param int $length 发送数据的尺寸,默认为整个文件的尺寸 */ - 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; /** * 响应头是否可写. @@ -43,9 +43,9 @@ public function isHeaderWritable(): bool; */ public function isBodyWritable(): bool; - public function withResponseBodyEmitter(?IResponseBodyEmitter $responseBodyEmitter): self; + public function withResponseBodyEmitter(?IResponseBodyEmitter $responseBodyEmitter): static; - public function setResponseBodyEmitter(?IResponseBodyEmitter $responseBodyEmitter): self; + public function setResponseBodyEmitter(?IResponseBodyEmitter $responseBodyEmitter): static; public function getResponseBodyEmitter(): ?IResponseBodyEmitter; } diff --git a/src/Server/Http/Message/Proxy/RequestProxy.php b/src/Server/Http/Message/Proxy/RequestProxy.php index 63c3f6c90a..96a1dad785 100644 --- a/src/Server/Http/Message/Proxy/RequestProxy.php +++ b/src/Server/Http/Message/Proxy/RequestProxy.php @@ -10,116 +10,116 @@ /** * @RequestContextProxy(class="Imi\Server\Http\Message\Contract\IHttpRequest", name="request") * - * @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 \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 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 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 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 withRequest(array $request) - * @method static \Imi\Util\Http\Contract\IServerRequest withRequest(array $request) - * @method \Imi\Util\Http\Contract\IServerRequest setRequest(array $request) - * @method static \Imi\Util\Http\Contract\IServerRequest setRequest(array $request) - * @method array getServerParams() - * @method static array getServerParams() - * @method array getCookieParams() - * @method static array getCookieParams() - * @method \Psr\Http\Message\ServerRequestInterface withCookieParams(array $cookies) - * @method static \Psr\Http\Message\ServerRequestInterface withCookieParams(array $cookies) - * @method array getQueryParams() - * @method static array getQueryParams() - * @method \Psr\Http\Message\ServerRequestInterface withQueryParams(array $query) - * @method static \Psr\Http\Message\ServerRequestInterface withQueryParams(array $query) - * @method array getUploadedFiles() - * @method static array getUploadedFiles() - * @method \Psr\Http\Message\ServerRequestInterface withUploadedFiles(array $uploadedFiles) - * @method static \Psr\Http\Message\ServerRequestInterface withUploadedFiles(array $uploadedFiles) - * @method array|object|null getParsedBody() - * @method static null|array|object getParsedBody() - * @method \Psr\Http\Message\ServerRequestInterface withParsedBody($data) - * @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 string getRequestTarget() - * @method static string getRequestTarget() - * @method \Psr\Http\Message\RequestInterface withRequestTarget($requestTarget) - * @method static \Psr\Http\Message\RequestInterface withRequestTarget($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\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 string getProtocolVersion() - * @method static string getProtocolVersion() - * @method \Psr\Http\Message\MessageInterface withProtocolVersion($version) - * @method static \Psr\Http\Message\MessageInterface withProtocolVersion($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 \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 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) - * @method static \Imi\Util\Http\Contract\IRequest setUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) - * @method \Psr\Http\Message\UriInterface getAppUri(?string $serverName = NULL) - * @method static \Psr\Http\Message\UriInterface getAppUri(?string $serverName = NULL) + * @method \Imi\Util\Socket\IPEndPoint getClientAddress() + * @method static \Imi\Util\Socket\IPEndPoint getClientAddress() + * @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 static setCookieParams(array $cookies) + * @method static static setCookieParams(array $cookies) + * @method static setQueryParams(array $query) + * @method static static setQueryParams(array $query) + * @method static setUploadedFiles(array $uploadedFiles) + * @method static static setUploadedFiles(array $uploadedFiles) + * @method static setParsedBody(object|array|null $data) + * @method static static setParsedBody(object|array|null $data) + * @method static setAttribute(string $name, mixed $value) + * @method static static setAttribute(string $name, mixed $value) + * @method static removeAttribute(string $name) + * @method static static removeAttribute(string $name) + * @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, 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 static withGet(array $get) + * @method static static withGet(array $get) + * @method static setGet(array $get) + * @method static static setGet(array $get) + * @method static withPost(mixed $post) + * @method static static withPost(mixed $post) + * @method static setPost(mixed $post) + * @method static static setPost(mixed $post) + * @method static withRequest(array $request) + * @method static static withRequest(array $request) + * @method static setRequest(array $request) + * @method static static setRequest(array $request) + * @method array getServerParams() + * @method static array getServerParams() + * @method array getCookieParams() + * @method static array getCookieParams() + * @method static withCookieParams(array $cookies) + * @method static static withCookieParams(array $cookies) + * @method array getQueryParams() + * @method static array getQueryParams() + * @method static withQueryParams(array $query) + * @method static static withQueryParams(array $query) + * @method array getUploadedFiles() + * @method static array getUploadedFiles() + * @method static withUploadedFiles(array $uploadedFiles) + * @method static static withUploadedFiles(array $uploadedFiles) + * @method array|object|null getParsedBody() + * @method static null|array|object getParsedBody() + * @method static withParsedBody($data) + * @method static static withParsedBody($data) + * @method array getAttributes() + * @method static array getAttributes() + * @method mixed getAttribute(string $name, $default = NULL) + * @method static mixed getAttribute(string $name, $default = NULL) + * @method static withAttribute(string $name, $value) + * @method static static withAttribute(string $name, $value) + * @method static withoutAttribute(string $name) + * @method static static withoutAttribute(string $name) + * @method string getRequestTarget() + * @method static string getRequestTarget() + * @method static withRequestTarget(string $requestTarget) + * @method static static withRequestTarget(string $requestTarget) + * @method string getMethod() + * @method static string getMethod() + * @method static withMethod(string $method) + * @method static static withMethod(string $method) + * @method \Psr\Http\Message\UriInterface getUri() + * @method static \Psr\Http\Message\UriInterface getUri() + * @method static withUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) + * @method static static withUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) + * @method string getProtocolVersion() + * @method static string getProtocolVersion() + * @method static withProtocolVersion(string $version) + * @method static static withProtocolVersion(string $version) + * @method string[][] getHeaders() + * @method static string[][] getHeaders() + * @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 static withHeader(string $name, $value) + * @method static static withHeader(string $name, $value) + * @method static withAddedHeader(string $name, $value) + * @method static static withAddedHeader(string $name, $value) + * @method static withoutHeader(string $name) + * @method static static withoutHeader(string $name) + * @method \Psr\Http\Message\StreamInterface getBody() + * @method static \Psr\Http\Message\StreamInterface getBody() + * @method static withBody(\Psr\Http\Message\StreamInterface $body) + * @method static static withBody(\Psr\Http\Message\StreamInterface $body) + * @method static setRequestTarget(string $requestTarget) + * @method static static setRequestTarget(string $requestTarget) + * @method static setMethod(string $method) + * @method static static setMethod(string $method) + * @method static setUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) + * @method static static setUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) + * @method \Psr\Http\Message\UriInterface getAppUri(?string $serverName = NULL) + * @method static \Psr\Http\Message\UriInterface getAppUri(?string $serverName = NULL) */ class RequestProxy extends BaseRequestContextProxy { diff --git a/src/Server/Http/Message/Proxy/RequestProxyObject.php b/src/Server/Http/Message/Proxy/RequestProxyObject.php index d636e6e428..ab2b355963 100644 --- a/src/Server/Http/Message/Proxy/RequestProxyObject.php +++ b/src/Server/Http/Message/Proxy/RequestProxyObject.php @@ -13,116 +13,116 @@ * * @RequestContextProxy(class="Imi\Server\Http\Message\Contract\IHttpRequest", name="request") * - * @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 \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 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 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 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 withRequest(array $request) - * @method static \Imi\Util\Http\Contract\IServerRequest withRequest(array $request) - * @method \Imi\Util\Http\Contract\IServerRequest setRequest(array $request) - * @method static \Imi\Util\Http\Contract\IServerRequest setRequest(array $request) - * @method array getServerParams() - * @method static array getServerParams() - * @method array getCookieParams() - * @method static array getCookieParams() - * @method \Psr\Http\Message\ServerRequestInterface withCookieParams(array $cookies) - * @method static \Psr\Http\Message\ServerRequestInterface withCookieParams(array $cookies) - * @method array getQueryParams() - * @method static array getQueryParams() - * @method \Psr\Http\Message\ServerRequestInterface withQueryParams(array $query) - * @method static \Psr\Http\Message\ServerRequestInterface withQueryParams(array $query) - * @method array getUploadedFiles() - * @method static array getUploadedFiles() - * @method \Psr\Http\Message\ServerRequestInterface withUploadedFiles(array $uploadedFiles) - * @method static \Psr\Http\Message\ServerRequestInterface withUploadedFiles(array $uploadedFiles) - * @method array|object|null getParsedBody() - * @method static null|array|object getParsedBody() - * @method \Psr\Http\Message\ServerRequestInterface withParsedBody($data) - * @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 string getRequestTarget() - * @method static string getRequestTarget() - * @method \Psr\Http\Message\RequestInterface withRequestTarget($requestTarget) - * @method static \Psr\Http\Message\RequestInterface withRequestTarget($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\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 string getProtocolVersion() - * @method static string getProtocolVersion() - * @method \Psr\Http\Message\MessageInterface withProtocolVersion($version) - * @method static \Psr\Http\Message\MessageInterface withProtocolVersion($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 \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 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) - * @method static \Imi\Util\Http\Contract\IRequest setUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) - * @method \Psr\Http\Message\UriInterface getAppUri(?string $serverName = NULL) - * @method static \Psr\Http\Message\UriInterface getAppUri(?string $serverName = NULL) + * @method \Imi\Util\Socket\IPEndPoint getClientAddress() + * @method static \Imi\Util\Socket\IPEndPoint getClientAddress() + * @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 static setCookieParams(array $cookies) + * @method static static setCookieParams(array $cookies) + * @method static setQueryParams(array $query) + * @method static static setQueryParams(array $query) + * @method static setUploadedFiles(array $uploadedFiles) + * @method static static setUploadedFiles(array $uploadedFiles) + * @method static setParsedBody(object|array|null $data) + * @method static static setParsedBody(object|array|null $data) + * @method static setAttribute(string $name, mixed $value) + * @method static static setAttribute(string $name, mixed $value) + * @method static removeAttribute(string $name) + * @method static static removeAttribute(string $name) + * @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, 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 static withGet(array $get) + * @method static static withGet(array $get) + * @method static setGet(array $get) + * @method static static setGet(array $get) + * @method static withPost(mixed $post) + * @method static static withPost(mixed $post) + * @method static setPost(mixed $post) + * @method static static setPost(mixed $post) + * @method static withRequest(array $request) + * @method static static withRequest(array $request) + * @method static setRequest(array $request) + * @method static static setRequest(array $request) + * @method array getServerParams() + * @method static array getServerParams() + * @method array getCookieParams() + * @method static array getCookieParams() + * @method static withCookieParams(array $cookies) + * @method static static withCookieParams(array $cookies) + * @method array getQueryParams() + * @method static array getQueryParams() + * @method static withQueryParams(array $query) + * @method static static withQueryParams(array $query) + * @method array getUploadedFiles() + * @method static array getUploadedFiles() + * @method static withUploadedFiles(array $uploadedFiles) + * @method static static withUploadedFiles(array $uploadedFiles) + * @method array|object|null getParsedBody() + * @method static null|array|object getParsedBody() + * @method static withParsedBody($data) + * @method static static withParsedBody($data) + * @method array getAttributes() + * @method static array getAttributes() + * @method mixed getAttribute(string $name, $default = NULL) + * @method static mixed getAttribute(string $name, $default = NULL) + * @method static withAttribute(string $name, $value) + * @method static static withAttribute(string $name, $value) + * @method static withoutAttribute(string $name) + * @method static static withoutAttribute(string $name) + * @method string getRequestTarget() + * @method static string getRequestTarget() + * @method static withRequestTarget(string $requestTarget) + * @method static static withRequestTarget(string $requestTarget) + * @method string getMethod() + * @method static string getMethod() + * @method static withMethod(string $method) + * @method static static withMethod(string $method) + * @method \Psr\Http\Message\UriInterface getUri() + * @method static \Psr\Http\Message\UriInterface getUri() + * @method static withUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) + * @method static static withUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) + * @method string getProtocolVersion() + * @method static string getProtocolVersion() + * @method static withProtocolVersion(string $version) + * @method static static withProtocolVersion(string $version) + * @method string[][] getHeaders() + * @method static string[][] getHeaders() + * @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 static withHeader(string $name, $value) + * @method static static withHeader(string $name, $value) + * @method static withAddedHeader(string $name, $value) + * @method static static withAddedHeader(string $name, $value) + * @method static withoutHeader(string $name) + * @method static static withoutHeader(string $name) + * @method \Psr\Http\Message\StreamInterface getBody() + * @method static \Psr\Http\Message\StreamInterface getBody() + * @method static withBody(\Psr\Http\Message\StreamInterface $body) + * @method static static withBody(\Psr\Http\Message\StreamInterface $body) + * @method static setRequestTarget(string $requestTarget) + * @method static static setRequestTarget(string $requestTarget) + * @method static setMethod(string $method) + * @method static static setMethod(string $method) + * @method static setUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) + * @method static static setUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) + * @method \Psr\Http\Message\UriInterface getAppUri(?string $serverName = NULL) + * @method static \Psr\Http\Message\UriInterface getAppUri(?string $serverName = NULL) */ class RequestProxyObject extends BaseRequestContextProxy implements \Imi\Server\Http\Message\Contract\IHttpRequest { @@ -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); } @@ -153,7 +153,7 @@ public function getCookie(string $name, $default = null) /** * {@inheritDoc} */ - public function setCookieParams(array $cookies): \Imi\Util\Http\Contract\IServerRequest + public function setCookieParams(array $cookies): static { return self::__getProxyInstance()->setCookieParams($cookies); } @@ -161,7 +161,7 @@ public function setCookieParams(array $cookies): \Imi\Util\Http\Contract\IServer /** * {@inheritDoc} */ - public function setQueryParams(array $query): \Imi\Util\Http\Contract\IServerRequest + public function setQueryParams(array $query): static { return self::__getProxyInstance()->setQueryParams($query); } @@ -169,7 +169,7 @@ public function setQueryParams(array $query): \Imi\Util\Http\Contract\IServerReq /** * {@inheritDoc} */ - public function setUploadedFiles(array $uploadedFiles): \Imi\Util\Http\Contract\IServerRequest + public function setUploadedFiles(array $uploadedFiles): static { return self::__getProxyInstance()->setUploadedFiles($uploadedFiles); } @@ -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): static { 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): static { return self::__getProxyInstance()->setAttribute($name, $value); } @@ -193,7 +193,7 @@ public function setAttribute(string $name, $value): \Imi\Util\Http\Contract\ISer /** * {@inheritDoc} */ - public function removeAttribute(string $name): \Imi\Util\Http\Contract\IServerRequest + public function removeAttribute(string $name): static { return self::__getProxyInstance()->removeAttribute($name); } @@ -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); } @@ -249,7 +249,7 @@ public function hasRequest(string $name): bool /** * {@inheritDoc} */ - public function withGet(array $get): \Imi\Util\Http\Contract\IServerRequest + public function withGet(array $get): static { return self::__getProxyInstance()->withGet($get); } @@ -257,7 +257,7 @@ public function withGet(array $get): \Imi\Util\Http\Contract\IServerRequest /** * {@inheritDoc} */ - public function setGet(array $get): \Imi\Util\Http\Contract\IServerRequest + public function setGet(array $get): static { return self::__getProxyInstance()->setGet($get); } @@ -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): static { 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): static { return self::__getProxyInstance()->setPost($post); } @@ -281,7 +281,7 @@ public function setPost($post): \Imi\Util\Http\Contract\IServerRequest /** * {@inheritDoc} */ - public function withRequest(array $request): \Imi\Util\Http\Contract\IServerRequest + public function withRequest(array $request): static { return self::__getProxyInstance()->withRequest($request); } @@ -289,7 +289,7 @@ public function withRequest(array $request): \Imi\Util\Http\Contract\IServerRequ /** * {@inheritDoc} */ - public function setRequest(array $request): \Imi\Util\Http\Contract\IServerRequest + public function setRequest(array $request): static { return self::__getProxyInstance()->setRequest($request); } @@ -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): static { return self::__getProxyInstance()->setRequestTarget($requestTarget); } @@ -545,7 +545,7 @@ public function setRequestTarget($requestTarget): \Imi\Util\Http\Contract\IReque /** * {@inheritDoc} */ - public function setMethod(string $method): \Imi\Util\Http\Contract\IRequest + public function setMethod(string $method): static { return self::__getProxyInstance()->setMethod($method); } @@ -553,7 +553,7 @@ public function setMethod(string $method): \Imi\Util\Http\Contract\IRequest /** * {@inheritDoc} */ - public function setUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false): \Imi\Util\Http\Contract\IRequest + public function setUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false): static { return self::__getProxyInstance()->setUri($uri, $preserveHost); } diff --git a/src/Server/Http/Message/Proxy/ResponseProxy.php b/src/Server/Http/Message/Proxy/ResponseProxy.php index 9a8754db99..c41695f75e 100644 --- a/src/Server/Http/Message/Proxy/ResponseProxy.php +++ b/src/Server/Http/Message/Proxy/ResponseProxy.php @@ -10,80 +10,80 @@ /** * @RequestContextProxy(class="Imi\Server\Http\Message\Contract\IHttpResponse", name="response") * - * @method \Imi\Server\Http\Message\Contract\IHttpResponse redirect(string $url, int $status = 302) - * @method static \Imi\Server\Http\Message\Contract\IHttpResponse redirect(string $url, int $status = 302) - * @method \Imi\Server\Http\Message\Contract\IHttpResponse send() - * @method static \Imi\Server\Http\Message\Contract\IHttpResponse send() - * @method \Imi\Server\Http\Message\Contract\IHttpResponse sendFile(string $filename, ?string $contentType = NULL, ?string $outputFileName = NULL, int $offset = 0, int $length = 0) - * @method static \Imi\Server\Http\Message\Contract\IHttpResponse sendFile(string $filename, ?string $contentType = NULL, ?string $outputFileName = NULL, int $offset = 0, int $length = 0) + * @method static redirect(string $url, int $status = 302) + * @method static static redirect(string $url, int $status = 302) + * @method static send() + * @method static static send() + * @method static sendFile(string $filename, ?string $contentType = NULL, ?string $outputFileName = NULL, int $offset = 0, int $length = 0) + * @method static static sendFile(string $filename, ?string $contentType = NULL, ?string $outputFileName = NULL, int $offset = 0, int $length = 0) * @method bool isHeaderWritable() * @method static bool isHeaderWritable() * @method bool isBodyWritable() * @method static bool isBodyWritable() - * @method \Imi\Server\Http\Message\Contract\IHttpResponse withResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) - * @method static \Imi\Server\Http\Message\Contract\IHttpResponse withResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) - * @method \Imi\Server\Http\Message\Contract\IHttpResponse setResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) - * @method static \Imi\Server\Http\Message\Contract\IHttpResponse setResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) + * @method static withResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) + * @method static static withResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) + * @method static setResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) + * @method static static setResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) * @method \Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter|null getResponseBodyEmitter() * @method static \Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter|null getResponseBodyEmitter() - * @method \Imi\Util\Http\Contract\IResponse setStatus(int $code, string $reasonPhrase = '') - * @method static \Imi\Util\Http\Contract\IResponse setStatus(int $code, string $reasonPhrase = '') - * @method \Imi\Util\Http\Contract\IResponse withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) - * @method static \Imi\Util\Http\Contract\IResponse withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) - * @method \Imi\Util\Http\Contract\IResponse setCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) - * @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 static setStatus(int $code, string $reasonPhrase = '') + * @method static static setStatus(int $code, string $reasonPhrase = '') + * @method static withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) + * @method static static withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) + * @method static setCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) + * @method static static 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) * @method static bool hasTrailer(string $name) * @method string|null getTrailer(string $name) * @method static string|null getTrailer(string $name) - * @method \Imi\Util\Http\Contract\IResponse withTrailer(string $name, string $value) - * @method static \Imi\Util\Http\Contract\IResponse withTrailer(string $name, string $value) - * @method \Imi\Util\Http\Contract\IResponse setTrailer(string $name, string $value) - * @method static \Imi\Util\Http\Contract\IResponse setTrailer(string $name, string $value) + * @method static withTrailer(string $name, string $value) + * @method static static withTrailer(string $name, string $value) + * @method static setTrailer(string $name, string $value) + * @method static static 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 static withStatus(int $code, string $reasonPhrase = '') + * @method static static 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 static withProtocolVersion(string $version) + * @method static static 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 static withHeader(string $name, $value) + * @method static static withHeader(string $name, $value) + * @method static withAddedHeader(string $name, $value) + * @method static static withAddedHeader(string $name, $value) + * @method static withoutHeader(string $name) + * @method static static 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 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) - * @method static \Imi\Util\Http\Contract\IMessage setBody(\Psr\Http\Message\StreamInterface $body) + * @method static withBody(\Psr\Http\Message\StreamInterface $body) + * @method static static withBody(\Psr\Http\Message\StreamInterface $body) + * @method static setProtocolVersion(string $version) + * @method static static setProtocolVersion(string $version) + * @method static setHeader(string $name, array|string $value) + * @method static static setHeader(string $name, array|string $value) + * @method static addHeader(string $name, array|string $value) + * @method static static addHeader(string $name, array|string $value) + * @method static removeHeader(string $name) + * @method static static removeHeader(string $name) + * @method static setBody(\Psr\Http\Message\StreamInterface $body) + * @method static static setBody(\Psr\Http\Message\StreamInterface $body) */ class ResponseProxy extends BaseRequestContextProxy { diff --git a/src/Server/Http/Message/Proxy/ResponseProxyObject.php b/src/Server/Http/Message/Proxy/ResponseProxyObject.php index dbc423591c..4cc8b0e52e 100644 --- a/src/Server/Http/Message/Proxy/ResponseProxyObject.php +++ b/src/Server/Http/Message/Proxy/ResponseProxyObject.php @@ -13,87 +13,87 @@ * * @RequestContextProxy(class="Imi\Server\Http\Message\Contract\IHttpResponse", name="response") * - * @method \Imi\Server\Http\Message\Contract\IHttpResponse redirect(string $url, int $status = 302) - * @method static \Imi\Server\Http\Message\Contract\IHttpResponse redirect(string $url, int $status = 302) - * @method \Imi\Server\Http\Message\Contract\IHttpResponse send() - * @method static \Imi\Server\Http\Message\Contract\IHttpResponse send() - * @method \Imi\Server\Http\Message\Contract\IHttpResponse sendFile(string $filename, ?string $contentType = NULL, ?string $outputFileName = NULL, int $offset = 0, int $length = 0) - * @method static \Imi\Server\Http\Message\Contract\IHttpResponse sendFile(string $filename, ?string $contentType = NULL, ?string $outputFileName = NULL, int $offset = 0, int $length = 0) + * @method static redirect(string $url, int $status = 302) + * @method static static redirect(string $url, int $status = 302) + * @method static send() + * @method static static send() + * @method static sendFile(string $filename, ?string $contentType = NULL, ?string $outputFileName = NULL, int $offset = 0, int $length = 0) + * @method static static sendFile(string $filename, ?string $contentType = NULL, ?string $outputFileName = NULL, int $offset = 0, int $length = 0) * @method bool isHeaderWritable() * @method static bool isHeaderWritable() * @method bool isBodyWritable() * @method static bool isBodyWritable() - * @method \Imi\Server\Http\Message\Contract\IHttpResponse withResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) - * @method static \Imi\Server\Http\Message\Contract\IHttpResponse withResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) - * @method \Imi\Server\Http\Message\Contract\IHttpResponse setResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) - * @method static \Imi\Server\Http\Message\Contract\IHttpResponse setResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) + * @method static withResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) + * @method static static withResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) + * @method static setResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) + * @method static static setResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) * @method \Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter|null getResponseBodyEmitter() * @method static \Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter|null getResponseBodyEmitter() - * @method \Imi\Util\Http\Contract\IResponse setStatus(int $code, string $reasonPhrase = '') - * @method static \Imi\Util\Http\Contract\IResponse setStatus(int $code, string $reasonPhrase = '') - * @method \Imi\Util\Http\Contract\IResponse withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) - * @method static \Imi\Util\Http\Contract\IResponse withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) - * @method \Imi\Util\Http\Contract\IResponse setCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) - * @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 static setStatus(int $code, string $reasonPhrase = '') + * @method static static setStatus(int $code, string $reasonPhrase = '') + * @method static withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) + * @method static static withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) + * @method static setCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) + * @method static static 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) * @method static bool hasTrailer(string $name) * @method string|null getTrailer(string $name) * @method static string|null getTrailer(string $name) - * @method \Imi\Util\Http\Contract\IResponse withTrailer(string $name, string $value) - * @method static \Imi\Util\Http\Contract\IResponse withTrailer(string $name, string $value) - * @method \Imi\Util\Http\Contract\IResponse setTrailer(string $name, string $value) - * @method static \Imi\Util\Http\Contract\IResponse setTrailer(string $name, string $value) + * @method static withTrailer(string $name, string $value) + * @method static static withTrailer(string $name, string $value) + * @method static setTrailer(string $name, string $value) + * @method static static 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 static withStatus(int $code, string $reasonPhrase = '') + * @method static static 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 static withProtocolVersion(string $version) + * @method static static 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 static withHeader(string $name, $value) + * @method static static withHeader(string $name, $value) + * @method static withAddedHeader(string $name, $value) + * @method static static withAddedHeader(string $name, $value) + * @method static withoutHeader(string $name) + * @method static static 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 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) - * @method static \Imi\Util\Http\Contract\IMessage setBody(\Psr\Http\Message\StreamInterface $body) + * @method static withBody(\Psr\Http\Message\StreamInterface $body) + * @method static static withBody(\Psr\Http\Message\StreamInterface $body) + * @method static setProtocolVersion(string $version) + * @method static static setProtocolVersion(string $version) + * @method static setHeader(string $name, array|string $value) + * @method static static setHeader(string $name, array|string $value) + * @method static addHeader(string $name, array|string $value) + * @method static static addHeader(string $name, array|string $value) + * @method static removeHeader(string $name) + * @method static static removeHeader(string $name) + * @method static setBody(\Psr\Http\Message\StreamInterface $body) + * @method static static setBody(\Psr\Http\Message\StreamInterface $body) */ class ResponseProxyObject extends BaseRequestContextProxy implements \Imi\Server\Http\Message\Contract\IHttpResponse { /** * {@inheritDoc} */ - public function redirect(string $url, int $status = 302): \Imi\Server\Http\Message\Contract\IHttpResponse + public function redirect(string $url, int $status = 302): static { return self::__getProxyInstance()->redirect($url, $status); } @@ -101,7 +101,7 @@ public function redirect(string $url, int $status = 302): \Imi\Server\Http\Messa /** * {@inheritDoc} */ - public function send(): \Imi\Server\Http\Message\Contract\IHttpResponse + public function send(): static { return self::__getProxyInstance()->send(...\func_get_args()); } @@ -109,7 +109,7 @@ public function send(): \Imi\Server\Http\Message\Contract\IHttpResponse /** * {@inheritDoc} */ - public function sendFile(string $filename, ?string $contentType = null, ?string $outputFileName = null, int $offset = 0, int $length = 0): \Imi\Server\Http\Message\Contract\IHttpResponse + public function sendFile(string $filename, ?string $contentType = null, ?string $outputFileName = null, int $offset = 0, int $length = 0): static { return self::__getProxyInstance()->sendFile($filename, $contentType, $outputFileName, $offset, $length); } @@ -133,7 +133,7 @@ public function isBodyWritable(): bool /** * {@inheritDoc} */ - public function withResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter): \Imi\Server\Http\Message\Contract\IHttpResponse + public function withResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter): static { return self::__getProxyInstance()->withResponseBodyEmitter($responseBodyEmitter); } @@ -141,7 +141,7 @@ public function withResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contra /** * {@inheritDoc} */ - public function setResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter): \Imi\Server\Http\Message\Contract\IHttpResponse + public function setResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter): static { return self::__getProxyInstance()->setResponseBodyEmitter($responseBodyEmitter); } @@ -157,7 +157,7 @@ public function getResponseBodyEmitter(): ?\Imi\Server\Http\Message\Emitter\Cont /** * {@inheritDoc} */ - public function setStatus(int $code, string $reasonPhrase = ''): \Imi\Util\Http\Contract\IResponse + public function setStatus(int $code, string $reasonPhrase = ''): static { return self::__getProxyInstance()->setStatus($code, $reasonPhrase); } @@ -165,7 +165,7 @@ public function setStatus(int $code, string $reasonPhrase = ''): \Imi\Util\Http\ /** * {@inheritDoc} */ - public function withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false): \Imi\Util\Http\Contract\IResponse + public function withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false): static { return self::__getProxyInstance()->withCookie($key, $value, $expire, $path, $domain, $secure, $httponly); } @@ -173,7 +173,7 @@ public function withCookie(string $key, string $value, int $expire = 0, string $ /** * {@inheritDoc} */ - public function setCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false): \Imi\Util\Http\Contract\IResponse + public function setCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false): static { return self::__getProxyInstance()->setCookie($key, $value, $expire, $path, $domain, $secure, $httponly); } @@ -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); } @@ -221,7 +221,7 @@ public function getTrailer(string $name): ?string /** * {@inheritDoc} */ - public function withTrailer(string $name, string $value): \Imi\Util\Http\Contract\IResponse + public function withTrailer(string $name, string $value): static { return self::__getProxyInstance()->withTrailer($name, $value); } @@ -229,7 +229,7 @@ public function withTrailer(string $name, string $value): \Imi\Util\Http\Contrac /** * {@inheritDoc} */ - public function setTrailer(string $name, string $value): \Imi\Util\Http\Contract\IResponse + public function setTrailer(string $name, string $value): static { return self::__getProxyInstance()->setTrailer($name, $value); } @@ -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); } @@ -349,7 +349,7 @@ public function withBody(\Psr\Http\Message\StreamInterface $body) /** * {@inheritDoc} */ - public function setProtocolVersion(string $version): \Imi\Util\Http\Contract\IMessage + public function setProtocolVersion(string $version): static { return self::__getProxyInstance()->setProtocolVersion($version); } @@ -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): static { 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): static { return self::__getProxyInstance()->addHeader($name, $value); } @@ -373,7 +373,7 @@ public function addHeader(string $name, $value): \Imi\Util\Http\Contract\IMessag /** * {@inheritDoc} */ - public function removeHeader(string $name): \Imi\Util\Http\Contract\IMessage + public function removeHeader(string $name): static { return self::__getProxyInstance()->removeHeader($name); } @@ -381,7 +381,7 @@ public function removeHeader(string $name): \Imi\Util\Http\Contract\IMessage /** * {@inheritDoc} */ - public function setBody(\Psr\Http\Message\StreamInterface $body): \Imi\Util\Http\Contract\IMessage + public function setBody(\Psr\Http\Message\StreamInterface $body): static { return self::__getProxyInstance()->setBody($body); } diff --git a/src/Server/Http/Message/Response.php b/src/Server/Http/Message/Response.php index 511dbac696..3c22803abe 100644 --- a/src/Server/Http/Message/Response.php +++ b/src/Server/Http/Message/Response.php @@ -15,13 +15,13 @@ abstract class Response extends \Imi\Util\Http\Response implements IHttpResponse /** * {@inheritDoc} */ - public function redirect(string $url, int $status = StatusCode::FOUND): self + public function redirect(string $url, int $status = StatusCode::FOUND): static { // @phpstan-ignore-next-line return $this->setStatus($status)->setHeader('location', $url); } - public function withResponseBodyEmitter(?IResponseBodyEmitter $responseBodyEmitter): self + public function withResponseBodyEmitter(?IResponseBodyEmitter $responseBodyEmitter): static { $clone = clone $this; $clone->responseBodyEmitter = $responseBodyEmitter; @@ -29,7 +29,7 @@ public function withResponseBodyEmitter(?IResponseBodyEmitter $responseBodyEmitt return $clone; } - public function setResponseBodyEmitter(?IResponseBodyEmitter $responseBodyEmitter): self + public function setResponseBodyEmitter(?IResponseBodyEmitter $responseBodyEmitter): static { $this->responseBodyEmitter = $responseBodyEmitter; 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..790ecfe3c3 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) { @@ -69,7 +69,7 @@ public function getProtocolVersion() /** * {@inheritDoc} */ - public function withProtocolVersion($version) + public function withProtocolVersion($version): static { $self = clone $this; $self->protocolVersion = $version; @@ -81,7 +81,7 @@ public function withProtocolVersion($version) /** * {@inheritDoc} */ - public function setProtocolVersion(string $version): self + public function setProtocolVersion(string $version): static { $this->protocolVersion = $version; $this->protocolVersionInited = true; @@ -99,7 +99,7 @@ protected function initHeaders(): void /** * {@inheritDoc} */ - public function getHeaders() + public function getHeaders(): array { if (!$this->headersInited) { @@ -113,7 +113,7 @@ public function getHeaders() /** * {@inheritDoc} */ - public function hasHeader($name) + public function hasHeader(string $name): bool { if (!$this->headersInited) { @@ -133,7 +133,7 @@ public function hasHeader($name) /** * {@inheritDoc} */ - public function getHeader($name) + public function getHeader(string $name): array { if (!$this->headersInited) { @@ -160,7 +160,7 @@ public function getHeader($name) /** * {@inheritDoc} */ - public function getHeaderLine($name) + public function getHeaderLine(string $name): string { if (!$this->headersInited) { @@ -185,7 +185,7 @@ public function getHeaderLine($name) /** * {@inheritDoc} */ - public function withHeader($name, $value) + public function withHeader(string $name, $value): static { $self = clone $this; if (!$self->headersInited) @@ -200,7 +200,7 @@ public function withHeader($name, $value) /** * {@inheritDoc} */ - public function setHeader(string $name, $value): self + public function setHeader(string $name, $value): static { if (!$this->headersInited) { @@ -214,7 +214,7 @@ public function setHeader(string $name, $value): self /** * {@inheritDoc} */ - public function withAddedHeader($name, $value) + public function withAddedHeader(string $name, $value): static { $self = clone $this; if (!$self->headersInited) @@ -230,7 +230,7 @@ public function withAddedHeader($name, $value) /** * {@inheritDoc} */ - public function addHeader(string $name, $value): self + public function addHeader(string $name, $value): static { if (!$this->headersInited) { @@ -273,7 +273,7 @@ public function addHeader(string $name, $value): self /** * {@inheritDoc} */ - public function withoutHeader($name) + public function withoutHeader(string $name): static { $self = clone $this; if (!$self->headersInited) @@ -289,7 +289,7 @@ public function withoutHeader($name) /** * {@inheritDoc} */ - public function removeHeader(string $name): self + public function removeHeader(string $name): static { if (!$this->headersInited) { @@ -319,7 +319,7 @@ protected function initBody(): void /** * {@inheritDoc} */ - public function getBody() + public function getBody(): StreamInterface { if (!$this->bodyInited) { @@ -333,7 +333,7 @@ public function getBody() /** * {@inheritDoc} */ - public function withBody(StreamInterface $body) + public function withBody(StreamInterface $body): static { $self = clone $this; $self->body = $body; @@ -345,7 +345,7 @@ public function withBody(StreamInterface $body) /** * {@inheritDoc} */ - public function setBody(StreamInterface $body): self + public function setBody(StreamInterface $body): static { $this->body = $body; $this->bodyInited = true; @@ -357,10 +357,8 @@ public function setBody(StreamInterface $body): self * 在当前实例下设置头. * * @param static|null $object - * - * @return static */ - protected function mergeHeaders(array $headers, self $object = null): self + protected function mergeHeaders(array $headers, self $object = null): static { if (null === $object) { diff --git a/src/Util/Http/Contract/IMessage.php b/src/Util/Http/Contract/IMessage.php index 41e50dd232..4b58e997c9 100644 --- a/src/Util/Http/Contract/IMessage.php +++ b/src/Util/Http/Contract/IMessage.php @@ -16,10 +16,8 @@ interface IMessage extends MessageInterface * "1.1", "1.0"). * * @param string $version HTTP protocol version - * - * @return static */ - public function setProtocolVersion(string $version): self; + public function setProtocolVersion(string $version): static; /** * Return an instance with the provided value replacing the specified header. @@ -30,11 +28,9 @@ public function setProtocolVersion(string $version): self; * @param string $name case-insensitive header field name * @param string|string[] $value header value(s) * - * @return static - * * @throws \InvalidArgumentException for invalid header names or values */ - public function setHeader(string $name, $value): self; + public function setHeader(string $name, string|array $value): static; /** * Return an instance with the specified header appended with the given value. @@ -46,11 +42,9 @@ public function setHeader(string $name, $value): self; * @param string $name case-insensitive header field name to add * @param string|string[] $value header value(s) * - * @return static - * * @throws \InvalidArgumentException for invalid header names or values */ - public function addHeader(string $name, $value): self; + public function addHeader(string $name, string|array $value): static; /** * Return an instance without the specified header. @@ -58,10 +52,8 @@ public function addHeader(string $name, $value): self; * Header resolution MUST be done without case-sensitivity. * * @param string $name case-insensitive header field name to remove - * - * @return static */ - public function removeHeader(string $name): self; + public function removeHeader(string $name): static; /** * Return an instance with the specified message body. @@ -70,9 +62,7 @@ public function removeHeader(string $name): self; * * @param StreamInterface $body body * - * @return static - * * @throws \InvalidArgumentException when the body is not valid */ - public function setBody(StreamInterface $body): self; + public function setBody(StreamInterface $body): static; } diff --git a/src/Util/Http/Contract/IRequest.php b/src/Util/Http/Contract/IRequest.php index 4790b2599b..7aba69b5e5 100644 --- a/src/Util/Http/Contract/IRequest.php +++ b/src/Util/Http/Contract/IRequest.php @@ -19,12 +19,8 @@ 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): static; /** * Return an instance with the provided HTTP method. @@ -35,11 +31,9 @@ public function setRequestTarget($requestTarget): self; * * @param string $method case-sensitive method * - * @return static - * * @throws \InvalidArgumentException for invalid HTTP methods */ - public function setMethod(string $method): self; + public function setMethod(string $method): static; /** * Returns an instance with the provided URI. @@ -66,10 +60,8 @@ public function setMethod(string $method): self; * * @param UriInterface $uri new request URI to use * @param bool $preserveHost preserve the original state of the Host header - * - * @return static */ - public function setUri(UriInterface $uri, bool $preserveHost = false): self; + public function setUri(UriInterface $uri, bool $preserveHost = false): static; public function getAppUri(?string $serverName = null): UriInterface; } diff --git a/src/Util/Http/Contract/IResponse.php b/src/Util/Http/Contract/IResponse.php index a02bb99f76..d57779411c 100644 --- a/src/Util/Http/Contract/IResponse.php +++ b/src/Util/Http/Contract/IResponse.php @@ -23,25 +23,19 @@ interface IResponse extends ResponseInterface, IMessage * provided status code; if none is provided, implementations MAY * use the defaults as suggested in the HTTP specification * - * @return static - * * @throws \InvalidArgumentException for invalid status code arguments */ - public function setStatus(int $code, string $reasonPhrase = ''): self; + public function setStatus(int $code, string $reasonPhrase = ''): static; /** * 设置cookie. - * - * @return static */ - public function withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false): self; + public function withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false): static; /** * 设置cookie. - * - * @return static */ - public function setCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false): self; + public function setCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false): static; /** * Retrieve cookies. @@ -55,12 +49,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 列表. @@ -79,15 +69,11 @@ public function getTrailer(string $name): ?string; /** * 设置 Trailer. - * - * @return static */ - public function withTrailer(string $name, string $value): self; + public function withTrailer(string $name, string $value): static; /** * 设置 Trailer. - * - * @return static */ - public function setTrailer(string $name, string $value): self; + public function setTrailer(string $name, string $value): static; } diff --git a/src/Util/Http/Contract/IServerRequest.php b/src/Util/Http/Contract/IServerRequest.php index fea3283bcb..5f8c3eec75 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. @@ -37,10 +29,8 @@ public function getCookie(string $name, $default = null); * instance, nor related values in the server params. * * @param array $cookies array of key/value pairs representing cookies - * - * @return static */ - public function setCookieParams(array $cookies): self; + public function setCookieParams(array $cookies): static; /** * Return an instance with the specified query string arguments. @@ -58,21 +48,17 @@ public function setCookieParams(array $cookies): self; * * @param array $query array of query string arguments, typically from * $_GET - * - * @return static */ - public function setQueryParams(array $query): self; + public function setQueryParams(array $query): static; /** * Create a new instance with the specified uploaded files. * * @param array $uploadedFiles an array tree of UploadedFileInterface instances * - * @return static - * * @throws \InvalidArgumentException if an invalid structure is provided */ - public function setUploadedFiles(array $uploadedFiles): self; + public function setUploadedFiles(array $uploadedFiles): static; /** * Return an instance with the specified body parameters. @@ -95,12 +81,10 @@ public function setUploadedFiles(array $uploadedFiles): self; * @param array|object|null $data The deserialized body data. This will * typically be in an array or object. * - * @return static - * * @throws \InvalidArgumentException if an unsupported argument type is * provided */ - public function setParsedBody($data): self; + public function setParsedBody(array|object|null $data): static; /** * Return an instance with the specified derived request attribute. @@ -112,10 +96,8 @@ public function setParsedBody($data): self; * * @param string $name the attribute name * @param mixed $value the value of the attribute - * - * @return static */ - public function setAttribute(string $name, $value): self; + public function setAttribute(string $name, mixed $value): static; /** * Return an instance that removes the specified derived request attribute. @@ -126,30 +108,20 @@ public function setAttribute(string $name, $value): self; * @see getAttributes() * * @param string $name the attribute name - * - * @return static */ - public function removeAttribute(string $name): self; + public function removeAttribute(string $name): static; /** * 获取 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 +137,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 参数 @@ -181,47 +148,31 @@ public function hasRequest(string $name): bool; /** * 设置 GET 数据. - * - * @return static */ - public function withGet(array $get): self; + public function withGet(array $get): static; /** * 设置 GET 数据. - * - * @return static */ - public function setGet(array $get): self; + public function setGet(array $get): static; /** * 设置 POST 数据. - * - * @param mixed $post - * - * @return static */ - public function withPost($post): self; + public function withPost(mixed $post): static; /** * 设置 POST 数据. - * - * @param mixed $post - * - * @return static */ - public function setPost($post): self; + public function setPost(mixed $post): static; /** * 设置 Request 数据. - * - * @return static */ - public function withRequest(array $request): self; + public function withRequest(array $request): static; /** * 设置 Request 数据. - * - * @return static */ - public function setRequest(array $request): self; + public function setRequest(array $request): static; } diff --git a/src/Util/Http/Request.php b/src/Util/Http/Request.php index 9eaf230c21..fa112841c1 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) { @@ -65,7 +65,7 @@ public function getRequestTarget() /** * {@inheritDoc} */ - public function withRequestTarget($requestTarget) + public function withRequestTarget(string $requestTarget): static { $self = clone $this; $self->requestTarget = $requestTarget; @@ -76,7 +76,7 @@ public function withRequestTarget($requestTarget) /** * {@inheritDoc} */ - public function setRequestTarget($requestTarget): self + public function setRequestTarget(string $requestTarget): static { $this->requestTarget = $requestTarget; @@ -93,7 +93,7 @@ protected function initMethod(): void /** * {@inheritDoc} */ - public function getMethod() + public function getMethod(): string { if (!$this->methodInited) { @@ -107,7 +107,7 @@ public function getMethod() /** * {@inheritDoc} */ - public function withMethod($method) + public function withMethod(string $method): static { $self = clone $this; $self->method = $method; @@ -119,7 +119,7 @@ public function withMethod($method) /** * {@inheritDoc} */ - public function setMethod(string $method): self + public function setMethod(string $method): static { $this->method = $method; $this->methodInited = true; @@ -137,7 +137,7 @@ protected function initUri(): void /** * {@inheritDoc} */ - public function getUri() + public function getUri(): UriInterface { if (!$this->uriInited) { @@ -151,7 +151,7 @@ public function getUri() /** * {@inheritDoc} */ - public function withUri(UriInterface $uri, $preserveHost = false) + public function withUri(UriInterface $uri, bool $preserveHost = false): static { $self = clone $this; @@ -162,7 +162,7 @@ public function withUri(UriInterface $uri, $preserveHost = false) /** * {@inheritDoc} */ - public function setUri(UriInterface $uri, bool $preserveHost = false): self + public function setUri(UriInterface $uri, bool $preserveHost = false): static { $this->uri = $uri; $this->appUri = null; diff --git a/src/Util/Http/Response.php b/src/Util/Http/Response.php index bab2e7e79e..09134ca7ae 100644 --- a/src/Util/Http/Response.php +++ b/src/Util/Http/Response.php @@ -43,7 +43,7 @@ public function __construct() /** * {@inheritDoc} */ - public function getStatusCode() + public function getStatusCode(): int { return $this->statusCode; } @@ -51,7 +51,7 @@ public function getStatusCode() /** * {@inheritDoc} */ - public function withStatus($code, $reasonPhrase = '') + public function withStatus(int $code, string $reasonPhrase = ''): static { $self = clone $this; $self->statusCode = $code; @@ -70,7 +70,7 @@ public function withStatus($code, $reasonPhrase = '') /** * {@inheritDoc} */ - public function setStatus(int $code, string $reasonPhrase = ''): self + public function setStatus(int $code, string $reasonPhrase = ''): static { $this->statusCode = $code; if ('' === $reasonPhrase) @@ -88,7 +88,7 @@ public function setStatus(int $code, string $reasonPhrase = ''): self /** * {@inheritDoc} */ - public function getReasonPhrase() + public function getReasonPhrase(): string { if ('' === $this->reasonPhrase) { @@ -101,7 +101,7 @@ public function getReasonPhrase() /** * {@inheritDoc} */ - public function withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false): self + public function withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false): static { $self = clone $this; $self->cookies[$key] = [ @@ -120,7 +120,7 @@ public function withCookie(string $key, string $value, int $expire = 0, string $ /** * {@inheritDoc} */ - public function setCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false): self + public function setCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false): static { $this->cookies[$key] = [ 'key' => $key, @@ -146,7 +146,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; } @@ -178,7 +178,7 @@ public function getTrailer(string $name): ?string /** * {@inheritDoc} */ - public function withTrailer(string $name, string $value): self + public function withTrailer(string $name, string $value): static { $self = clone $this; $self->trailers[$name] = $value; @@ -189,7 +189,7 @@ public function withTrailer(string $name, string $value): self /** * {@inheritDoc} */ - public function setTrailer(string $name, string $value): self + public function setTrailer(string $name, string $value): static { $this->trailers[$name] = $value; diff --git a/src/Util/Http/ServerRequest.php b/src/Util/Http/ServerRequest.php index 331aac8791..66d309f731 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) { @@ -119,7 +119,7 @@ protected function initRequestParams(): void /** * {@inheritDoc} */ - public function setCookieParams(array $cookies): self + public function setCookieParams(array $cookies): static { if (!$this->requestParamsInited) { @@ -134,7 +134,7 @@ public function setCookieParams(array $cookies): self /** * {@inheritDoc} */ - public function getCookieParams() + public function getCookieParams(): array { if (!$this->requestParamsInited) { @@ -148,7 +148,7 @@ public function getCookieParams() /** * {@inheritDoc} */ - public function withCookieParams(array $cookies) + public function withCookieParams(array $cookies): static { $self = clone $this; if (!$self->requestParamsInited) @@ -164,7 +164,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) { @@ -178,7 +178,7 @@ public function getCookie(string $name, $default = null) /** * {@inheritDoc} */ - public function setQueryParams(array $query): self + public function setQueryParams(array $query): static { if (!$this->requestParamsInited) { @@ -193,7 +193,7 @@ public function setQueryParams(array $query): self /** * {@inheritDoc} */ - public function getQueryParams() + public function getQueryParams(): array { if (!$this->requestParamsInited) { @@ -207,7 +207,7 @@ public function getQueryParams() /** * {@inheritDoc} */ - public function withQueryParams(array $query) + public function withQueryParams(array $query): static { $self = clone $this; if (!$self->requestParamsInited) @@ -230,7 +230,7 @@ protected function initUploadedFiles(): void /** * {@inheritDoc} */ - public function getUploadedFiles() + public function getUploadedFiles(): array { if (!$this->uploadedFilesInited) { @@ -244,7 +244,7 @@ public function getUploadedFiles() /** * {@inheritDoc} */ - public function withUploadedFiles(array $uploadedFiles) + public function withUploadedFiles(array $uploadedFiles): static { $self = clone $this; @@ -255,7 +255,7 @@ public function withUploadedFiles(array $uploadedFiles) /** * {@inheritDoc} */ - public function setUploadedFiles(array $uploadedFiles): self + public function setUploadedFiles(array $uploadedFiles): static { $objectFiles = &$this->files; $objectFiles = []; @@ -348,7 +348,7 @@ public function getParsedBody() /** * {@inheritDoc} */ - public function withParsedBody($data) + public function withParsedBody($data): static { $self = clone $this; $self->parsedBody = $data; @@ -359,7 +359,7 @@ public function withParsedBody($data) /** * {@inheritDoc} */ - public function setParsedBody($data): self + public function setParsedBody($data): static { $this->parsedBody = $data; @@ -369,7 +369,7 @@ public function setParsedBody($data): self /** * {@inheritDoc} */ - public function getAttributes() + public function getAttributes(): array { return $this->attributes; } @@ -377,7 +377,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)) @@ -393,7 +393,7 @@ public function getAttribute($name, $default = null) /** * {@inheritDoc} */ - public function withAttribute($name, $value) + public function withAttribute(string $name, $value): static { $self = clone $this; $self->attributes[$name] = $value; @@ -404,7 +404,7 @@ public function withAttribute($name, $value) /** * {@inheritDoc} */ - public function setAttribute(string $name, $value): self + public function setAttribute(string $name, $value): static { $this->attributes[$name] = $value; @@ -414,7 +414,7 @@ public function setAttribute(string $name, $value): self /** * {@inheritDoc} */ - public function withoutAttribute($name) + public function withoutAttribute(string $name): static { $self = clone $this; if (\array_key_exists($name, $self->attributes)) @@ -428,7 +428,7 @@ public function withoutAttribute($name) /** * {@inheritDoc} */ - public function removeAttribute(string $name): self + public function removeAttribute(string $name): static { if (\array_key_exists($name, $this->attributes)) { @@ -441,7 +441,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 +461,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 +509,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) { @@ -548,7 +548,7 @@ public function hasRequest(string $name): bool /** * {@inheritDoc} */ - public function withGet(array $get): self + public function withGet(array $get): static { $self = clone $this; if (!$self->requestParamsInited) @@ -564,7 +564,7 @@ public function withGet(array $get): self /** * {@inheritDoc} */ - public function setGet(array $get): self + public function setGet(array $get): static { if (!$this->requestParamsInited) { @@ -579,7 +579,7 @@ public function setGet(array $get): self /** * {@inheritDoc} */ - public function withPost($post): self + public function withPost(mixed $post): static { $self = clone $this; if (!$self->requestParamsInited) @@ -595,7 +595,7 @@ public function withPost($post): self /** * {@inheritDoc} */ - public function setPost($post): self + public function setPost(mixed $post): static { if (!$this->requestParamsInited) { @@ -610,7 +610,7 @@ public function setPost($post): self /** * {@inheritDoc} */ - public function withRequest(array $request): self + public function withRequest(array $request): static { $self = clone $this; if (!$self->requestParamsInited) @@ -626,7 +626,7 @@ public function withRequest(array $request): self /** * {@inheritDoc} */ - public function setRequest(array $request): self + public function setRequest(array $request): static { if (!$this->requestParamsInited) { diff --git a/src/Util/Stream/FileStream.php b/src/Util/Stream/FileStream.php index 26a20cae41..4035561369 100644 --- a/src/Util/Stream/FileStream.php +++ b/src/Util/Stream/FileStream.php @@ -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..dedafc5832 100644 --- a/src/Util/Stream/MemoryStream.php +++ b/src/Util/Stream/MemoryStream.php @@ -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..f36fae1251 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): static { 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 + ): static { $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): static { $self = clone $this; $self->host = $host; @@ -277,7 +277,7 @@ public function withHost($host) /** * {@inheritDoc} */ - public function withPort($port) + public function withPort(?int $port): static { $self = clone $this; $self->port = $port; @@ -288,7 +288,7 @@ public function withPort($port) /** * {@inheritDoc} */ - public function withPath($path) + public function withPath(string $path): static { $self = clone $this; $self->path = $path; @@ -299,7 +299,7 @@ public function withPath($path) /** * {@inheritDoc} */ - public function withQuery($query) + public function withQuery(string $query): static { $self = clone $this; $self->query = $query; @@ -310,7 +310,7 @@ public function withQuery($query) /** * {@inheritDoc} */ - public function withFragment($fragment) + public function withFragment(string $fragment): static { $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); From b026342f86fae233e3f4699df9edfd7addec9e6d Mon Sep 17 00:00:00 2001 From: Yurun Date: Mon, 16 Oct 2023 16:06:10 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 6 ++---- phpstan-components.neon | 2 +- src/Components/fpm/src/Http/Message/FpmResponse.php | 2 +- src/Components/phar/src/PharBuildCommand.php | 1 + .../roadrunner/src/Http/Message/RoadRunnerRequest.php | 2 +- .../roadrunner/src/Http/Message/RoadRunnerResponse.php | 2 +- src/Components/swoole/src/Http/Message/SwooleResponse.php | 2 +- .../workerman/src/Http/Message/WorkermanResponse.php | 2 +- 8 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4f9a57d757..05567140d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,8 +24,6 @@ jobs: postgresql_version: "" - version: 5.0-php8.1 postgresql_version: "" - - version: 5.0-php8.0 - postgresql_version: "" roadrunner: [2.7.*] env: ENV_SERVICE: swoole @@ -275,7 +273,7 @@ jobs: strategy: fail-fast: false matrix: - php: ["8.0", "8.1", "8.2"] + php: ["8.1", "8.2"] swoole: [v5.0.3] roadrunner: [2.7.*] env: @@ -396,7 +394,7 @@ jobs: strategy: fail-fast: false matrix: - php: ["8.0", "8.1"] # 部分扩展还未在 pecl 发布 PHP 8.2 Windows 版扩展,所以无法测试 + php: ["8.1"] # 部分扩展还未在 pecl 发布 PHP 8.2 Windows 版扩展,所以无法测试 roadrunner: [2.7.*] extensions: [ diff --git a/phpstan-components.neon b/phpstan-components.neon index 8b812be6d2..7b21c70404 100644 --- a/phpstan-components.neon +++ b/phpstan-components.neon @@ -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/src/Components/fpm/src/Http/Message/FpmResponse.php b/src/Components/fpm/src/Http/Message/FpmResponse.php index 40bace3e2c..2733698edd 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) { 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/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..3e6f55875c 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) { diff --git a/src/Components/swoole/src/Http/Message/SwooleResponse.php b/src/Components/swoole/src/Http/Message/SwooleResponse.php index 2a063d4244..74ae6fa82f 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) { diff --git a/src/Components/workerman/src/Http/Message/WorkermanResponse.php b/src/Components/workerman/src/Http/Message/WorkermanResponse.php index f2a47afe24..a4afe0b610 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) { From 588fce535a5d73dee252d1b7626a1f071d9f9917 Mon Sep 17 00:00:00 2001 From: Yurun Date: Tue, 17 Oct 2023 14:25:07 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Bean/ReflectionUtil.php | 6 +----- src/Components/fpm/src/Http/Message/FpmResponse.php | 2 +- .../roadrunner/src/Http/Message/RoadRunnerResponse.php | 2 +- src/Components/swoole/src/Http/Message/SwooleResponse.php | 2 +- .../workerman/src/Http/Message/WorkermanResponse.php | 2 +- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/Bean/ReflectionUtil.php b/src/Bean/ReflectionUtil.php index 1fd6c20104..57712d2339 100644 --- a/src/Bean/ReflectionUtil.php +++ b/src/Bean/ReflectionUtil.php @@ -172,13 +172,9 @@ public static function allowsType(\ReflectionType $type, string $checkType, ?str { if (null !== $className) { - $typeStr = '\\' . $className; + $typeStr = $className; } } - elseif ('static' !== $typeStr) - { - $typeStr = '\\' . $typeStr; - } } return $typeStr === $checkType || \in_array($typeStr, $checkTypes) || is_subclass_of($checkType, $typeStr); diff --git a/src/Components/fpm/src/Http/Message/FpmResponse.php b/src/Components/fpm/src/Http/Message/FpmResponse.php index 2733698edd..10d50659dc 100644 --- a/src/Components/fpm/src/Http/Message/FpmResponse.php +++ b/src/Components/fpm/src/Http/Message/FpmResponse.php @@ -94,7 +94,7 @@ public function send(): static /** * {@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/roadrunner/src/Http/Message/RoadRunnerResponse.php b/src/Components/roadrunner/src/Http/Message/RoadRunnerResponse.php index 3e6f55875c..6495c86a03 100644 --- a/src/Components/roadrunner/src/Http/Message/RoadRunnerResponse.php +++ b/src/Components/roadrunner/src/Http/Message/RoadRunnerResponse.php @@ -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/swoole/src/Http/Message/SwooleResponse.php b/src/Components/swoole/src/Http/Message/SwooleResponse.php index 74ae6fa82f..49a08e6d69 100644 --- a/src/Components/swoole/src/Http/Message/SwooleResponse.php +++ b/src/Components/swoole/src/Http/Message/SwooleResponse.php @@ -120,7 +120,7 @@ public function send(): static /** * {@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/workerman/src/Http/Message/WorkermanResponse.php b/src/Components/workerman/src/Http/Message/WorkermanResponse.php index a4afe0b610..e4e733dbaf 100644 --- a/src/Components/workerman/src/Http/Message/WorkermanResponse.php +++ b/src/Components/workerman/src/Http/Message/WorkermanResponse.php @@ -153,7 +153,7 @@ public function send(): static /** * {@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) { From ce00e670b64072a202ee66bc86c164c907e21c7b Mon Sep 17 00:00:00 2001 From: Yurun Date: Tue, 17 Oct 2023 15:46:08 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- phpstan-components.neon | 2 +- src/Facade/Cli/FacadeGenerate.php | 6 +- .../Cli/RequestContextProxyGenerate.php | 6 +- .../Http/Message/Proxy/RequestProxy.php | 220 +++++++++--------- .../Http/Message/Proxy/RequestProxyObject.php | 220 +++++++++--------- .../Http/Message/Proxy/ResponseProxy.php | 24 +- .../Message/Proxy/ResponseProxyObject.php | 24 +- 7 files changed, 247 insertions(+), 255 deletions(-) diff --git a/phpstan-components.neon b/phpstan-components.neon index 7b21c70404..094c06c0a6 100644 --- a/phpstan-components.neon +++ b/phpstan-components.neon @@ -1,7 +1,7 @@ parameters: level: 6 - phpVersion: 80000 + phpVersion: 80100 paths: - src/Components diff --git a/src/Facade/Cli/FacadeGenerate.php b/src/Facade/Cli/FacadeGenerate.php index 93f09b7d7a..6d29da8d7a 100644 --- a/src/Facade/Cli/FacadeGenerate.php +++ b/src/Facade/Cli/FacadeGenerate.php @@ -76,14 +76,10 @@ public function generate(string $facadeClass, string $class, bool $request): voi if (false !== $docComment && preg_match('/@return\s+([^\s]+)/', $docComment, $matches) > 0) { $class = $matches[1]; - if ('self' === $class) + if ('self' === $class || 'static' === $class) { $returnType = '\\' . $method->getDeclaringClass()->getName(); } - elseif ('static' === $class) - { - $returnType = 'static'; - } elseif ('\\' === $class[0]) { $returnType = $class; diff --git a/src/RequestContextProxy/Cli/RequestContextProxyGenerate.php b/src/RequestContextProxy/Cli/RequestContextProxyGenerate.php index 44bb6bed84..f12ebd49e4 100644 --- a/src/RequestContextProxy/Cli/RequestContextProxyGenerate.php +++ b/src/RequestContextProxy/Cli/RequestContextProxyGenerate.php @@ -93,14 +93,10 @@ public function generate(string $target, string $class, string $name, ?string $b if (false !== $docComment && preg_match('/@return\s+([^\s]+)/', $docComment, $matches) > 0) { $class = $matches[1]; - if ('self' === $class) + if ('self' === $class || 'static' === $class) { $returnType = '\\' . $method->getDeclaringClass()->getName(); } - elseif ('static' === $class) - { - $returnType = 'static'; - } elseif ('\\' === $class[0]) { $returnType = $class; diff --git a/src/Server/Http/Message/Proxy/RequestProxy.php b/src/Server/Http/Message/Proxy/RequestProxy.php index 96a1dad785..44c1f86078 100644 --- a/src/Server/Http/Message/Proxy/RequestProxy.php +++ b/src/Server/Http/Message/Proxy/RequestProxy.php @@ -10,116 +10,116 @@ /** * @RequestContextProxy(class="Imi\Server\Http\Message\Contract\IHttpRequest", name="request") * - * @method \Imi\Util\Socket\IPEndPoint getClientAddress() - * @method static \Imi\Util\Socket\IPEndPoint getClientAddress() - * @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 static setCookieParams(array $cookies) - * @method static static setCookieParams(array $cookies) - * @method static setQueryParams(array $query) - * @method static static setQueryParams(array $query) - * @method static setUploadedFiles(array $uploadedFiles) - * @method static static setUploadedFiles(array $uploadedFiles) - * @method static setParsedBody(object|array|null $data) - * @method static static setParsedBody(object|array|null $data) - * @method static setAttribute(string $name, mixed $value) - * @method static static setAttribute(string $name, mixed $value) - * @method static removeAttribute(string $name) - * @method static static removeAttribute(string $name) - * @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, 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 static withGet(array $get) - * @method static static withGet(array $get) - * @method static setGet(array $get) - * @method static static setGet(array $get) - * @method static withPost(mixed $post) - * @method static static withPost(mixed $post) - * @method static setPost(mixed $post) - * @method static static setPost(mixed $post) - * @method static withRequest(array $request) - * @method static static withRequest(array $request) - * @method static setRequest(array $request) - * @method static static setRequest(array $request) - * @method array getServerParams() - * @method static array getServerParams() - * @method array getCookieParams() - * @method static array getCookieParams() - * @method static withCookieParams(array $cookies) - * @method static static withCookieParams(array $cookies) - * @method array getQueryParams() - * @method static array getQueryParams() - * @method static withQueryParams(array $query) - * @method static static withQueryParams(array $query) - * @method array getUploadedFiles() - * @method static array getUploadedFiles() - * @method static withUploadedFiles(array $uploadedFiles) - * @method static static withUploadedFiles(array $uploadedFiles) - * @method array|object|null getParsedBody() - * @method static null|array|object getParsedBody() - * @method static withParsedBody($data) - * @method static static withParsedBody($data) - * @method array getAttributes() - * @method static array getAttributes() - * @method mixed getAttribute(string $name, $default = NULL) - * @method static mixed getAttribute(string $name, $default = NULL) - * @method static withAttribute(string $name, $value) - * @method static static withAttribute(string $name, $value) - * @method static withoutAttribute(string $name) - * @method static static withoutAttribute(string $name) - * @method string getRequestTarget() - * @method static string getRequestTarget() - * @method static withRequestTarget(string $requestTarget) - * @method static static withRequestTarget(string $requestTarget) - * @method string getMethod() - * @method static string getMethod() - * @method static withMethod(string $method) - * @method static static withMethod(string $method) - * @method \Psr\Http\Message\UriInterface getUri() - * @method static \Psr\Http\Message\UriInterface getUri() - * @method static withUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) - * @method static static withUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) - * @method string getProtocolVersion() - * @method static string getProtocolVersion() - * @method static withProtocolVersion(string $version) - * @method static static withProtocolVersion(string $version) - * @method string[][] getHeaders() - * @method static string[][] getHeaders() - * @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 static withHeader(string $name, $value) - * @method static static withHeader(string $name, $value) - * @method static withAddedHeader(string $name, $value) - * @method static static withAddedHeader(string $name, $value) - * @method static withoutHeader(string $name) - * @method static static withoutHeader(string $name) - * @method \Psr\Http\Message\StreamInterface getBody() - * @method static \Psr\Http\Message\StreamInterface getBody() - * @method static withBody(\Psr\Http\Message\StreamInterface $body) - * @method static static withBody(\Psr\Http\Message\StreamInterface $body) - * @method static setRequestTarget(string $requestTarget) - * @method static static setRequestTarget(string $requestTarget) - * @method static setMethod(string $method) - * @method static static setMethod(string $method) - * @method static setUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) - * @method static static setUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) - * @method \Psr\Http\Message\UriInterface getAppUri(?string $serverName = NULL) - * @method static \Psr\Http\Message\UriInterface getAppUri(?string $serverName = NULL) + * @method \Imi\Util\Socket\IPEndPoint getClientAddress() + * @method static \Imi\Util\Socket\IPEndPoint getClientAddress() + * @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 static setCookieParams(array $cookies) + * @method static static setCookieParams(array $cookies) + * @method static setQueryParams(array $query) + * @method static static setQueryParams(array $query) + * @method static setUploadedFiles(array $uploadedFiles) + * @method static static setUploadedFiles(array $uploadedFiles) + * @method static setParsedBody(object|array|null $data) + * @method static static setParsedBody(object|array|null $data) + * @method static setAttribute(string $name, mixed $value) + * @method static static setAttribute(string $name, mixed $value) + * @method static removeAttribute(string $name) + * @method static static removeAttribute(string $name) + * @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, 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 static withGet(array $get) + * @method static static withGet(array $get) + * @method static setGet(array $get) + * @method static static setGet(array $get) + * @method static withPost(mixed $post) + * @method static static withPost(mixed $post) + * @method static setPost(mixed $post) + * @method static static setPost(mixed $post) + * @method static withRequest(array $request) + * @method static static withRequest(array $request) + * @method static setRequest(array $request) + * @method static static setRequest(array $request) + * @method array getServerParams() + * @method static array getServerParams() + * @method array getCookieParams() + * @method static array getCookieParams() + * @method \Psr\Http\Message\ServerRequestInterface withCookieParams(array $cookies) + * @method static \Psr\Http\Message\ServerRequestInterface withCookieParams(array $cookies) + * @method array getQueryParams() + * @method static array getQueryParams() + * @method \Psr\Http\Message\ServerRequestInterface withQueryParams(array $query) + * @method static \Psr\Http\Message\ServerRequestInterface withQueryParams(array $query) + * @method array getUploadedFiles() + * @method static array getUploadedFiles() + * @method \Psr\Http\Message\ServerRequestInterface withUploadedFiles(array $uploadedFiles) + * @method static \Psr\Http\Message\ServerRequestInterface withUploadedFiles(array $uploadedFiles) + * @method array|object|null getParsedBody() + * @method static null|array|object getParsedBody() + * @method \Psr\Http\Message\ServerRequestInterface withParsedBody($data) + * @method static \Psr\Http\Message\ServerRequestInterface withParsedBody($data) + * @method array getAttributes() + * @method static array getAttributes() + * @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(string $requestTarget) + * @method static \Psr\Http\Message\RequestInterface withRequestTarget(string $requestTarget) + * @method string getMethod() + * @method static string getMethod() + * @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, 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(string $version) + * @method static \Psr\Http\Message\MessageInterface withProtocolVersion(string $version) + * @method string[][] getHeaders() + * @method static string[][] getHeaders() + * @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 static setRequestTarget(string $requestTarget) + * @method static static setRequestTarget(string $requestTarget) + * @method static setMethod(string $method) + * @method static static setMethod(string $method) + * @method static setUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) + * @method static static setUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) + * @method \Psr\Http\Message\UriInterface getAppUri(?string $serverName = NULL) + * @method static \Psr\Http\Message\UriInterface getAppUri(?string $serverName = NULL) */ class RequestProxy extends BaseRequestContextProxy { diff --git a/src/Server/Http/Message/Proxy/RequestProxyObject.php b/src/Server/Http/Message/Proxy/RequestProxyObject.php index ab2b355963..d14d95dafb 100644 --- a/src/Server/Http/Message/Proxy/RequestProxyObject.php +++ b/src/Server/Http/Message/Proxy/RequestProxyObject.php @@ -13,116 +13,116 @@ * * @RequestContextProxy(class="Imi\Server\Http\Message\Contract\IHttpRequest", name="request") * - * @method \Imi\Util\Socket\IPEndPoint getClientAddress() - * @method static \Imi\Util\Socket\IPEndPoint getClientAddress() - * @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 static setCookieParams(array $cookies) - * @method static static setCookieParams(array $cookies) - * @method static setQueryParams(array $query) - * @method static static setQueryParams(array $query) - * @method static setUploadedFiles(array $uploadedFiles) - * @method static static setUploadedFiles(array $uploadedFiles) - * @method static setParsedBody(object|array|null $data) - * @method static static setParsedBody(object|array|null $data) - * @method static setAttribute(string $name, mixed $value) - * @method static static setAttribute(string $name, mixed $value) - * @method static removeAttribute(string $name) - * @method static static removeAttribute(string $name) - * @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, 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 static withGet(array $get) - * @method static static withGet(array $get) - * @method static setGet(array $get) - * @method static static setGet(array $get) - * @method static withPost(mixed $post) - * @method static static withPost(mixed $post) - * @method static setPost(mixed $post) - * @method static static setPost(mixed $post) - * @method static withRequest(array $request) - * @method static static withRequest(array $request) - * @method static setRequest(array $request) - * @method static static setRequest(array $request) - * @method array getServerParams() - * @method static array getServerParams() - * @method array getCookieParams() - * @method static array getCookieParams() - * @method static withCookieParams(array $cookies) - * @method static static withCookieParams(array $cookies) - * @method array getQueryParams() - * @method static array getQueryParams() - * @method static withQueryParams(array $query) - * @method static static withQueryParams(array $query) - * @method array getUploadedFiles() - * @method static array getUploadedFiles() - * @method static withUploadedFiles(array $uploadedFiles) - * @method static static withUploadedFiles(array $uploadedFiles) - * @method array|object|null getParsedBody() - * @method static null|array|object getParsedBody() - * @method static withParsedBody($data) - * @method static static withParsedBody($data) - * @method array getAttributes() - * @method static array getAttributes() - * @method mixed getAttribute(string $name, $default = NULL) - * @method static mixed getAttribute(string $name, $default = NULL) - * @method static withAttribute(string $name, $value) - * @method static static withAttribute(string $name, $value) - * @method static withoutAttribute(string $name) - * @method static static withoutAttribute(string $name) - * @method string getRequestTarget() - * @method static string getRequestTarget() - * @method static withRequestTarget(string $requestTarget) - * @method static static withRequestTarget(string $requestTarget) - * @method string getMethod() - * @method static string getMethod() - * @method static withMethod(string $method) - * @method static static withMethod(string $method) - * @method \Psr\Http\Message\UriInterface getUri() - * @method static \Psr\Http\Message\UriInterface getUri() - * @method static withUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) - * @method static static withUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) - * @method string getProtocolVersion() - * @method static string getProtocolVersion() - * @method static withProtocolVersion(string $version) - * @method static static withProtocolVersion(string $version) - * @method string[][] getHeaders() - * @method static string[][] getHeaders() - * @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 static withHeader(string $name, $value) - * @method static static withHeader(string $name, $value) - * @method static withAddedHeader(string $name, $value) - * @method static static withAddedHeader(string $name, $value) - * @method static withoutHeader(string $name) - * @method static static withoutHeader(string $name) - * @method \Psr\Http\Message\StreamInterface getBody() - * @method static \Psr\Http\Message\StreamInterface getBody() - * @method static withBody(\Psr\Http\Message\StreamInterface $body) - * @method static static withBody(\Psr\Http\Message\StreamInterface $body) - * @method static setRequestTarget(string $requestTarget) - * @method static static setRequestTarget(string $requestTarget) - * @method static setMethod(string $method) - * @method static static setMethod(string $method) - * @method static setUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) - * @method static static setUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) - * @method \Psr\Http\Message\UriInterface getAppUri(?string $serverName = NULL) - * @method static \Psr\Http\Message\UriInterface getAppUri(?string $serverName = NULL) + * @method \Imi\Util\Socket\IPEndPoint getClientAddress() + * @method static \Imi\Util\Socket\IPEndPoint getClientAddress() + * @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 static setCookieParams(array $cookies) + * @method static static setCookieParams(array $cookies) + * @method static setQueryParams(array $query) + * @method static static setQueryParams(array $query) + * @method static setUploadedFiles(array $uploadedFiles) + * @method static static setUploadedFiles(array $uploadedFiles) + * @method static setParsedBody(object|array|null $data) + * @method static static setParsedBody(object|array|null $data) + * @method static setAttribute(string $name, mixed $value) + * @method static static setAttribute(string $name, mixed $value) + * @method static removeAttribute(string $name) + * @method static static removeAttribute(string $name) + * @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, 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 static withGet(array $get) + * @method static static withGet(array $get) + * @method static setGet(array $get) + * @method static static setGet(array $get) + * @method static withPost(mixed $post) + * @method static static withPost(mixed $post) + * @method static setPost(mixed $post) + * @method static static setPost(mixed $post) + * @method static withRequest(array $request) + * @method static static withRequest(array $request) + * @method static setRequest(array $request) + * @method static static setRequest(array $request) + * @method array getServerParams() + * @method static array getServerParams() + * @method array getCookieParams() + * @method static array getCookieParams() + * @method \Psr\Http\Message\ServerRequestInterface withCookieParams(array $cookies) + * @method static \Psr\Http\Message\ServerRequestInterface withCookieParams(array $cookies) + * @method array getQueryParams() + * @method static array getQueryParams() + * @method \Psr\Http\Message\ServerRequestInterface withQueryParams(array $query) + * @method static \Psr\Http\Message\ServerRequestInterface withQueryParams(array $query) + * @method array getUploadedFiles() + * @method static array getUploadedFiles() + * @method \Psr\Http\Message\ServerRequestInterface withUploadedFiles(array $uploadedFiles) + * @method static \Psr\Http\Message\ServerRequestInterface withUploadedFiles(array $uploadedFiles) + * @method array|object|null getParsedBody() + * @method static null|array|object getParsedBody() + * @method \Psr\Http\Message\ServerRequestInterface withParsedBody($data) + * @method static \Psr\Http\Message\ServerRequestInterface withParsedBody($data) + * @method array getAttributes() + * @method static array getAttributes() + * @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(string $requestTarget) + * @method static \Psr\Http\Message\RequestInterface withRequestTarget(string $requestTarget) + * @method string getMethod() + * @method static string getMethod() + * @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, 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(string $version) + * @method static \Psr\Http\Message\MessageInterface withProtocolVersion(string $version) + * @method string[][] getHeaders() + * @method static string[][] getHeaders() + * @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 static setRequestTarget(string $requestTarget) + * @method static static setRequestTarget(string $requestTarget) + * @method static setMethod(string $method) + * @method static static setMethod(string $method) + * @method static setUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) + * @method static static setUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) + * @method \Psr\Http\Message\UriInterface getAppUri(?string $serverName = NULL) + * @method static \Psr\Http\Message\UriInterface getAppUri(?string $serverName = NULL) */ class RequestProxyObject extends BaseRequestContextProxy implements \Imi\Server\Http\Message\Contract\IHttpRequest { diff --git a/src/Server/Http/Message/Proxy/ResponseProxy.php b/src/Server/Http/Message/Proxy/ResponseProxy.php index c41695f75e..6c02635834 100644 --- a/src/Server/Http/Message/Proxy/ResponseProxy.php +++ b/src/Server/Http/Message/Proxy/ResponseProxy.php @@ -48,14 +48,14 @@ * @method static static setTrailer(string $name, string $value) * @method int getStatusCode() * @method static int getStatusCode() - * @method static withStatus(int $code, string $reasonPhrase = '') - * @method static static withStatus(int $code, string $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 static withProtocolVersion(string $version) - * @method static static withProtocolVersion(string $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(string $name) @@ -64,16 +64,16 @@ * @method static string[] getHeader(string $name) * @method string getHeaderLine(string $name) * @method static string getHeaderLine(string $name) - * @method static withHeader(string $name, $value) - * @method static static withHeader(string $name, $value) - * @method static withAddedHeader(string $name, $value) - * @method static static withAddedHeader(string $name, $value) - * @method static withoutHeader(string $name) - * @method static static withoutHeader(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 static withBody(\Psr\Http\Message\StreamInterface $body) - * @method static static withBody(\Psr\Http\Message\StreamInterface $body) + * @method \Psr\Http\Message\MessageInterface withBody(\Psr\Http\Message\StreamInterface $body) + * @method static \Psr\Http\Message\MessageInterface withBody(\Psr\Http\Message\StreamInterface $body) * @method static setProtocolVersion(string $version) * @method static static setProtocolVersion(string $version) * @method static setHeader(string $name, array|string $value) diff --git a/src/Server/Http/Message/Proxy/ResponseProxyObject.php b/src/Server/Http/Message/Proxy/ResponseProxyObject.php index 4cc8b0e52e..ec79dfd90f 100644 --- a/src/Server/Http/Message/Proxy/ResponseProxyObject.php +++ b/src/Server/Http/Message/Proxy/ResponseProxyObject.php @@ -51,14 +51,14 @@ * @method static static setTrailer(string $name, string $value) * @method int getStatusCode() * @method static int getStatusCode() - * @method static withStatus(int $code, string $reasonPhrase = '') - * @method static static withStatus(int $code, string $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 static withProtocolVersion(string $version) - * @method static static withProtocolVersion(string $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(string $name) @@ -67,16 +67,16 @@ * @method static string[] getHeader(string $name) * @method string getHeaderLine(string $name) * @method static string getHeaderLine(string $name) - * @method static withHeader(string $name, $value) - * @method static static withHeader(string $name, $value) - * @method static withAddedHeader(string $name, $value) - * @method static static withAddedHeader(string $name, $value) - * @method static withoutHeader(string $name) - * @method static static withoutHeader(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 static withBody(\Psr\Http\Message\StreamInterface $body) - * @method static static withBody(\Psr\Http\Message\StreamInterface $body) + * @method \Psr\Http\Message\MessageInterface withBody(\Psr\Http\Message\StreamInterface $body) + * @method static \Psr\Http\Message\MessageInterface withBody(\Psr\Http\Message\StreamInterface $body) * @method static setProtocolVersion(string $version) * @method static static setProtocolVersion(string $version) * @method static setHeader(string $name, array|string $value) From 20b7736c4d190cee20ee8e3543c6b6c3c188ab3b Mon Sep 17 00:00:00 2001 From: Yurun Date: Tue, 17 Oct 2023 19:25:44 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Http/Message/Contract/IHttpResponse.php | 10 +-- .../Http/Message/Proxy/RequestProxy.php | 60 ++++++------- .../Http/Message/Proxy/RequestProxyObject.php | 90 +++++++++---------- .../Http/Message/Proxy/ResponseProxy.php | 60 ++++++------- .../Message/Proxy/ResponseProxyObject.php | 90 +++++++++---------- src/Server/Http/Message/Response.php | 6 +- src/Util/Http/AbstractMessage.php | 44 ++++++--- src/Util/Http/Contract/IMessage.php | 20 +++-- src/Util/Http/Contract/IRequest.php | 12 ++- src/Util/Http/Contract/IResponse.php | 20 +++-- src/Util/Http/Contract/IServerRequest.php | 48 +++++++--- src/Util/Http/Request.php | 24 +++-- src/Util/Http/Response.php | 24 +++-- src/Util/Http/ServerRequest.php | 72 +++++++++++---- src/Util/Stream/FileStream.php | 2 +- src/Util/Stream/MemoryStream.php | 2 +- src/Util/Uri.php | 14 +-- 17 files changed, 365 insertions(+), 233 deletions(-) diff --git a/src/Server/Http/Message/Contract/IHttpResponse.php b/src/Server/Http/Message/Contract/IHttpResponse.php index 6f9aafc903..7d0ed5c916 100644 --- a/src/Server/Http/Message/Contract/IHttpResponse.php +++ b/src/Server/Http/Message/Contract/IHttpResponse.php @@ -17,12 +17,12 @@ interface IHttpResponse extends IResponse * 设置服务器端重定向 * 默认状态码为302. */ - public function redirect(string $url, int $status = StatusCode::FOUND): static; + public function redirect(string $url, int $status = StatusCode::FOUND): self; /** * 发送所有响应数据. */ - public function send(): static; + public function send(): self; /** * 发送文件,一般用于文件下载. @@ -31,7 +31,7 @@ public function send(): static; * @param int $offset 上传文件的偏移量,可以指定从文件的中间部分开始传输数据。此特性可用于支持断点续传。 * @param int $length 发送数据的尺寸,默认为整个文件的尺寸 */ - public function sendFile(string $filename, ?string $contentType = null, ?string $outputFileName = null, int $offset = 0, int $length = 0): static; + public function sendFile(string $filename, ?string $contentType = null, ?string $outputFileName = null, int $offset = 0, int $length = 0): self; /** * 响应头是否可写. @@ -43,9 +43,9 @@ public function isHeaderWritable(): bool; */ public function isBodyWritable(): bool; - public function withResponseBodyEmitter(?IResponseBodyEmitter $responseBodyEmitter): static; + public function withResponseBodyEmitter(?IResponseBodyEmitter $responseBodyEmitter): self; - public function setResponseBodyEmitter(?IResponseBodyEmitter $responseBodyEmitter): static; + public function setResponseBodyEmitter(?IResponseBodyEmitter $responseBodyEmitter): self; public function getResponseBodyEmitter(): ?IResponseBodyEmitter; } diff --git a/src/Server/Http/Message/Proxy/RequestProxy.php b/src/Server/Http/Message/Proxy/RequestProxy.php index 44c1f86078..3e9ad34e4a 100644 --- a/src/Server/Http/Message/Proxy/RequestProxy.php +++ b/src/Server/Http/Message/Proxy/RequestProxy.php @@ -16,18 +16,18 @@ * @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 static setCookieParams(array $cookies) - * @method static static setCookieParams(array $cookies) - * @method static setQueryParams(array $query) - * @method static static setQueryParams(array $query) - * @method static setUploadedFiles(array $uploadedFiles) - * @method static static setUploadedFiles(array $uploadedFiles) - * @method static setParsedBody(object|array|null $data) - * @method static static setParsedBody(object|array|null $data) - * @method static setAttribute(string $name, mixed $value) - * @method static static setAttribute(string $name, mixed $value) - * @method static removeAttribute(string $name) - * @method static static removeAttribute(string $name) + * @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(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, mixed $default = NULL) * @method static mixed get(?string $name = NULL, mixed $default = NULL) * @method mixed post(?string $name = NULL, mixed $default = NULL) @@ -40,18 +40,18 @@ * @method static mixed request(?string $name = NULL, mixed $default = NULL) * @method bool hasRequest(string $name) * @method static bool hasRequest(string $name) - * @method static withGet(array $get) - * @method static static withGet(array $get) - * @method static setGet(array $get) - * @method static static setGet(array $get) - * @method static withPost(mixed $post) - * @method static static withPost(mixed $post) - * @method static setPost(mixed $post) - * @method static static setPost(mixed $post) - * @method static withRequest(array $request) - * @method static static withRequest(array $request) - * @method static setRequest(array $request) - * @method static static setRequest(array $request) + * @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(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) + * @method static \Imi\Util\Http\Contract\IServerRequest setRequest(array $request) * @method array getServerParams() * @method static array getServerParams() * @method array getCookieParams() @@ -112,12 +112,12 @@ * @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 static setRequestTarget(string $requestTarget) - * @method static static setRequestTarget(string $requestTarget) - * @method static setMethod(string $method) - * @method static static setMethod(string $method) - * @method static setUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) - * @method static static setUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) + * @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) + * @method static \Imi\Util\Http\Contract\IRequest setUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) * @method \Psr\Http\Message\UriInterface getAppUri(?string $serverName = NULL) * @method static \Psr\Http\Message\UriInterface getAppUri(?string $serverName = NULL) */ diff --git a/src/Server/Http/Message/Proxy/RequestProxyObject.php b/src/Server/Http/Message/Proxy/RequestProxyObject.php index d14d95dafb..44cb7bc6c8 100644 --- a/src/Server/Http/Message/Proxy/RequestProxyObject.php +++ b/src/Server/Http/Message/Proxy/RequestProxyObject.php @@ -19,18 +19,18 @@ * @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 static setCookieParams(array $cookies) - * @method static static setCookieParams(array $cookies) - * @method static setQueryParams(array $query) - * @method static static setQueryParams(array $query) - * @method static setUploadedFiles(array $uploadedFiles) - * @method static static setUploadedFiles(array $uploadedFiles) - * @method static setParsedBody(object|array|null $data) - * @method static static setParsedBody(object|array|null $data) - * @method static setAttribute(string $name, mixed $value) - * @method static static setAttribute(string $name, mixed $value) - * @method static removeAttribute(string $name) - * @method static static removeAttribute(string $name) + * @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(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, mixed $default = NULL) * @method static mixed get(?string $name = NULL, mixed $default = NULL) * @method mixed post(?string $name = NULL, mixed $default = NULL) @@ -43,18 +43,18 @@ * @method static mixed request(?string $name = NULL, mixed $default = NULL) * @method bool hasRequest(string $name) * @method static bool hasRequest(string $name) - * @method static withGet(array $get) - * @method static static withGet(array $get) - * @method static setGet(array $get) - * @method static static setGet(array $get) - * @method static withPost(mixed $post) - * @method static static withPost(mixed $post) - * @method static setPost(mixed $post) - * @method static static setPost(mixed $post) - * @method static withRequest(array $request) - * @method static static withRequest(array $request) - * @method static setRequest(array $request) - * @method static static setRequest(array $request) + * @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(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) + * @method static \Imi\Util\Http\Contract\IServerRequest setRequest(array $request) * @method array getServerParams() * @method static array getServerParams() * @method array getCookieParams() @@ -115,12 +115,12 @@ * @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 static setRequestTarget(string $requestTarget) - * @method static static setRequestTarget(string $requestTarget) - * @method static setMethod(string $method) - * @method static static setMethod(string $method) - * @method static setUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) - * @method static static setUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) + * @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) + * @method static \Imi\Util\Http\Contract\IRequest setUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false) * @method \Psr\Http\Message\UriInterface getAppUri(?string $serverName = NULL) * @method static \Psr\Http\Message\UriInterface getAppUri(?string $serverName = NULL) */ @@ -153,7 +153,7 @@ public function getCookie(string $name, ?string $default = null): ?string /** * {@inheritDoc} */ - public function setCookieParams(array $cookies): static + public function setCookieParams(array $cookies): \Imi\Util\Http\Contract\IServerRequest { return self::__getProxyInstance()->setCookieParams($cookies); } @@ -161,7 +161,7 @@ public function setCookieParams(array $cookies): static /** * {@inheritDoc} */ - public function setQueryParams(array $query): static + public function setQueryParams(array $query): \Imi\Util\Http\Contract\IServerRequest { return self::__getProxyInstance()->setQueryParams($query); } @@ -169,7 +169,7 @@ public function setQueryParams(array $query): static /** * {@inheritDoc} */ - public function setUploadedFiles(array $uploadedFiles): static + public function setUploadedFiles(array $uploadedFiles): \Imi\Util\Http\Contract\IServerRequest { return self::__getProxyInstance()->setUploadedFiles($uploadedFiles); } @@ -177,7 +177,7 @@ public function setUploadedFiles(array $uploadedFiles): static /** * {@inheritDoc} */ - public function setParsedBody(object|array|null $data): static + public function setParsedBody(object|array|null $data): \Imi\Util\Http\Contract\IServerRequest { return self::__getProxyInstance()->setParsedBody($data); } @@ -185,7 +185,7 @@ public function setParsedBody(object|array|null $data): static /** * {@inheritDoc} */ - public function setAttribute(string $name, mixed $value): static + public function setAttribute(string $name, mixed $value): \Imi\Util\Http\Contract\IServerRequest { return self::__getProxyInstance()->setAttribute($name, $value); } @@ -193,7 +193,7 @@ public function setAttribute(string $name, mixed $value): static /** * {@inheritDoc} */ - public function removeAttribute(string $name): static + public function removeAttribute(string $name): \Imi\Util\Http\Contract\IServerRequest { return self::__getProxyInstance()->removeAttribute($name); } @@ -249,7 +249,7 @@ public function hasRequest(string $name): bool /** * {@inheritDoc} */ - public function withGet(array $get): static + public function withGet(array $get): \Imi\Util\Http\Contract\IServerRequest { return self::__getProxyInstance()->withGet($get); } @@ -257,7 +257,7 @@ public function withGet(array $get): static /** * {@inheritDoc} */ - public function setGet(array $get): static + public function setGet(array $get): \Imi\Util\Http\Contract\IServerRequest { return self::__getProxyInstance()->setGet($get); } @@ -265,7 +265,7 @@ public function setGet(array $get): static /** * {@inheritDoc} */ - public function withPost(mixed $post): static + public function withPost(mixed $post): \Imi\Util\Http\Contract\IServerRequest { return self::__getProxyInstance()->withPost($post); } @@ -273,7 +273,7 @@ public function withPost(mixed $post): static /** * {@inheritDoc} */ - public function setPost(mixed $post): static + public function setPost(mixed $post): \Imi\Util\Http\Contract\IServerRequest { return self::__getProxyInstance()->setPost($post); } @@ -281,7 +281,7 @@ public function setPost(mixed $post): static /** * {@inheritDoc} */ - public function withRequest(array $request): static + public function withRequest(array $request): \Imi\Util\Http\Contract\IServerRequest { return self::__getProxyInstance()->withRequest($request); } @@ -289,7 +289,7 @@ public function withRequest(array $request): static /** * {@inheritDoc} */ - public function setRequest(array $request): static + public function setRequest(array $request): \Imi\Util\Http\Contract\IServerRequest { return self::__getProxyInstance()->setRequest($request); } @@ -537,7 +537,7 @@ public function withBody(\Psr\Http\Message\StreamInterface $body): \Psr\Http\Mes /** * {@inheritDoc} */ - public function setRequestTarget(string $requestTarget): static + public function setRequestTarget(string $requestTarget): \Imi\Util\Http\Contract\IRequest { return self::__getProxyInstance()->setRequestTarget($requestTarget); } @@ -545,7 +545,7 @@ public function setRequestTarget(string $requestTarget): static /** * {@inheritDoc} */ - public function setMethod(string $method): static + public function setMethod(string $method): \Imi\Util\Http\Contract\IRequest { return self::__getProxyInstance()->setMethod($method); } @@ -553,7 +553,7 @@ public function setMethod(string $method): static /** * {@inheritDoc} */ - public function setUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false): static + public function setUri(\Psr\Http\Message\UriInterface $uri, bool $preserveHost = false): \Imi\Util\Http\Contract\IRequest { return self::__getProxyInstance()->setUri($uri, $preserveHost); } diff --git a/src/Server/Http/Message/Proxy/ResponseProxy.php b/src/Server/Http/Message/Proxy/ResponseProxy.php index 6c02635834..b707e4f964 100644 --- a/src/Server/Http/Message/Proxy/ResponseProxy.php +++ b/src/Server/Http/Message/Proxy/ResponseProxy.php @@ -10,28 +10,28 @@ /** * @RequestContextProxy(class="Imi\Server\Http\Message\Contract\IHttpResponse", name="response") * - * @method static redirect(string $url, int $status = 302) - * @method static static redirect(string $url, int $status = 302) - * @method static send() - * @method static static send() - * @method static sendFile(string $filename, ?string $contentType = NULL, ?string $outputFileName = NULL, int $offset = 0, int $length = 0) - * @method static static sendFile(string $filename, ?string $contentType = NULL, ?string $outputFileName = NULL, int $offset = 0, int $length = 0) + * @method \Imi\Server\Http\Message\Contract\IHttpResponse redirect(string $url, int $status = 302) + * @method static \Imi\Server\Http\Message\Contract\IHttpResponse redirect(string $url, int $status = 302) + * @method \Imi\Server\Http\Message\Contract\IHttpResponse send() + * @method static \Imi\Server\Http\Message\Contract\IHttpResponse send() + * @method \Imi\Server\Http\Message\Contract\IHttpResponse sendFile(string $filename, ?string $contentType = NULL, ?string $outputFileName = NULL, int $offset = 0, int $length = 0) + * @method static \Imi\Server\Http\Message\Contract\IHttpResponse sendFile(string $filename, ?string $contentType = NULL, ?string $outputFileName = NULL, int $offset = 0, int $length = 0) * @method bool isHeaderWritable() * @method static bool isHeaderWritable() * @method bool isBodyWritable() * @method static bool isBodyWritable() - * @method static withResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) - * @method static static withResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) - * @method static setResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) - * @method static static setResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) + * @method \Imi\Server\Http\Message\Contract\IHttpResponse withResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) + * @method static \Imi\Server\Http\Message\Contract\IHttpResponse withResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) + * @method \Imi\Server\Http\Message\Contract\IHttpResponse setResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) + * @method static \Imi\Server\Http\Message\Contract\IHttpResponse setResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) * @method \Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter|null getResponseBodyEmitter() * @method static \Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter|null getResponseBodyEmitter() - * @method static setStatus(int $code, string $reasonPhrase = '') - * @method static static setStatus(int $code, string $reasonPhrase = '') - * @method static withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) - * @method static static withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) - * @method static setCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) - * @method static static setCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) + * @method \Imi\Util\Http\Contract\IResponse setStatus(int $code, string $reasonPhrase = '') + * @method static \Imi\Util\Http\Contract\IResponse setStatus(int $code, string $reasonPhrase = '') + * @method \Imi\Util\Http\Contract\IResponse withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) + * @method static \Imi\Util\Http\Contract\IResponse withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) + * @method \Imi\Util\Http\Contract\IResponse setCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) + * @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 array|null getCookie(string $name, ?array $default = NULL) @@ -42,10 +42,10 @@ * @method static bool hasTrailer(string $name) * @method string|null getTrailer(string $name) * @method static string|null getTrailer(string $name) - * @method static withTrailer(string $name, string $value) - * @method static static withTrailer(string $name, string $value) - * @method static setTrailer(string $name, string $value) - * @method static static setTrailer(string $name, string $value) + * @method \Imi\Util\Http\Contract\IResponse withTrailer(string $name, string $value) + * @method static \Imi\Util\Http\Contract\IResponse withTrailer(string $name, string $value) + * @method \Imi\Util\Http\Contract\IResponse setTrailer(string $name, string $value) + * @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(int $code, string $reasonPhrase = '') @@ -74,16 +74,16 @@ * @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 static setProtocolVersion(string $version) - * @method static static setProtocolVersion(string $version) - * @method static setHeader(string $name, array|string $value) - * @method static static setHeader(string $name, array|string $value) - * @method static addHeader(string $name, array|string $value) - * @method static static addHeader(string $name, array|string $value) - * @method static removeHeader(string $name) - * @method static static removeHeader(string $name) - * @method static setBody(\Psr\Http\Message\StreamInterface $body) - * @method static static setBody(\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, 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) + * @method static \Imi\Util\Http\Contract\IMessage setBody(\Psr\Http\Message\StreamInterface $body) */ class ResponseProxy extends BaseRequestContextProxy { diff --git a/src/Server/Http/Message/Proxy/ResponseProxyObject.php b/src/Server/Http/Message/Proxy/ResponseProxyObject.php index ec79dfd90f..335287b0af 100644 --- a/src/Server/Http/Message/Proxy/ResponseProxyObject.php +++ b/src/Server/Http/Message/Proxy/ResponseProxyObject.php @@ -13,28 +13,28 @@ * * @RequestContextProxy(class="Imi\Server\Http\Message\Contract\IHttpResponse", name="response") * - * @method static redirect(string $url, int $status = 302) - * @method static static redirect(string $url, int $status = 302) - * @method static send() - * @method static static send() - * @method static sendFile(string $filename, ?string $contentType = NULL, ?string $outputFileName = NULL, int $offset = 0, int $length = 0) - * @method static static sendFile(string $filename, ?string $contentType = NULL, ?string $outputFileName = NULL, int $offset = 0, int $length = 0) + * @method \Imi\Server\Http\Message\Contract\IHttpResponse redirect(string $url, int $status = 302) + * @method static \Imi\Server\Http\Message\Contract\IHttpResponse redirect(string $url, int $status = 302) + * @method \Imi\Server\Http\Message\Contract\IHttpResponse send() + * @method static \Imi\Server\Http\Message\Contract\IHttpResponse send() + * @method \Imi\Server\Http\Message\Contract\IHttpResponse sendFile(string $filename, ?string $contentType = NULL, ?string $outputFileName = NULL, int $offset = 0, int $length = 0) + * @method static \Imi\Server\Http\Message\Contract\IHttpResponse sendFile(string $filename, ?string $contentType = NULL, ?string $outputFileName = NULL, int $offset = 0, int $length = 0) * @method bool isHeaderWritable() * @method static bool isHeaderWritable() * @method bool isBodyWritable() * @method static bool isBodyWritable() - * @method static withResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) - * @method static static withResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) - * @method static setResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) - * @method static static setResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) + * @method \Imi\Server\Http\Message\Contract\IHttpResponse withResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) + * @method static \Imi\Server\Http\Message\Contract\IHttpResponse withResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) + * @method \Imi\Server\Http\Message\Contract\IHttpResponse setResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) + * @method static \Imi\Server\Http\Message\Contract\IHttpResponse setResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter) * @method \Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter|null getResponseBodyEmitter() * @method static \Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter|null getResponseBodyEmitter() - * @method static setStatus(int $code, string $reasonPhrase = '') - * @method static static setStatus(int $code, string $reasonPhrase = '') - * @method static withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) - * @method static static withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) - * @method static setCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) - * @method static static setCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) + * @method \Imi\Util\Http\Contract\IResponse setStatus(int $code, string $reasonPhrase = '') + * @method static \Imi\Util\Http\Contract\IResponse setStatus(int $code, string $reasonPhrase = '') + * @method \Imi\Util\Http\Contract\IResponse withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) + * @method static \Imi\Util\Http\Contract\IResponse withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) + * @method \Imi\Util\Http\Contract\IResponse setCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) + * @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 array|null getCookie(string $name, ?array $default = NULL) @@ -45,10 +45,10 @@ * @method static bool hasTrailer(string $name) * @method string|null getTrailer(string $name) * @method static string|null getTrailer(string $name) - * @method static withTrailer(string $name, string $value) - * @method static static withTrailer(string $name, string $value) - * @method static setTrailer(string $name, string $value) - * @method static static setTrailer(string $name, string $value) + * @method \Imi\Util\Http\Contract\IResponse withTrailer(string $name, string $value) + * @method static \Imi\Util\Http\Contract\IResponse withTrailer(string $name, string $value) + * @method \Imi\Util\Http\Contract\IResponse setTrailer(string $name, string $value) + * @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(int $code, string $reasonPhrase = '') @@ -77,23 +77,23 @@ * @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 static setProtocolVersion(string $version) - * @method static static setProtocolVersion(string $version) - * @method static setHeader(string $name, array|string $value) - * @method static static setHeader(string $name, array|string $value) - * @method static addHeader(string $name, array|string $value) - * @method static static addHeader(string $name, array|string $value) - * @method static removeHeader(string $name) - * @method static static removeHeader(string $name) - * @method static setBody(\Psr\Http\Message\StreamInterface $body) - * @method static static setBody(\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, 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) + * @method static \Imi\Util\Http\Contract\IMessage setBody(\Psr\Http\Message\StreamInterface $body) */ class ResponseProxyObject extends BaseRequestContextProxy implements \Imi\Server\Http\Message\Contract\IHttpResponse { /** * {@inheritDoc} */ - public function redirect(string $url, int $status = 302): static + public function redirect(string $url, int $status = 302): \Imi\Server\Http\Message\Contract\IHttpResponse { return self::__getProxyInstance()->redirect($url, $status); } @@ -101,7 +101,7 @@ public function redirect(string $url, int $status = 302): static /** * {@inheritDoc} */ - public function send(): static + public function send(): \Imi\Server\Http\Message\Contract\IHttpResponse { return self::__getProxyInstance()->send(...\func_get_args()); } @@ -109,7 +109,7 @@ public function send(): static /** * {@inheritDoc} */ - public function sendFile(string $filename, ?string $contentType = null, ?string $outputFileName = null, int $offset = 0, int $length = 0): static + public function sendFile(string $filename, ?string $contentType = null, ?string $outputFileName = null, int $offset = 0, int $length = 0): \Imi\Server\Http\Message\Contract\IHttpResponse { return self::__getProxyInstance()->sendFile($filename, $contentType, $outputFileName, $offset, $length); } @@ -133,7 +133,7 @@ public function isBodyWritable(): bool /** * {@inheritDoc} */ - public function withResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter): static + public function withResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter): \Imi\Server\Http\Message\Contract\IHttpResponse { return self::__getProxyInstance()->withResponseBodyEmitter($responseBodyEmitter); } @@ -141,7 +141,7 @@ public function withResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contra /** * {@inheritDoc} */ - public function setResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter): static + public function setResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter): \Imi\Server\Http\Message\Contract\IHttpResponse { return self::__getProxyInstance()->setResponseBodyEmitter($responseBodyEmitter); } @@ -157,7 +157,7 @@ public function getResponseBodyEmitter(): ?\Imi\Server\Http\Message\Emitter\Cont /** * {@inheritDoc} */ - public function setStatus(int $code, string $reasonPhrase = ''): static + public function setStatus(int $code, string $reasonPhrase = ''): \Imi\Util\Http\Contract\IResponse { return self::__getProxyInstance()->setStatus($code, $reasonPhrase); } @@ -165,7 +165,7 @@ public function setStatus(int $code, string $reasonPhrase = ''): static /** * {@inheritDoc} */ - public function withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false): static + public function withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false): \Imi\Util\Http\Contract\IResponse { return self::__getProxyInstance()->withCookie($key, $value, $expire, $path, $domain, $secure, $httponly); } @@ -173,7 +173,7 @@ public function withCookie(string $key, string $value, int $expire = 0, string $ /** * {@inheritDoc} */ - public function setCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false): static + public function setCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false): \Imi\Util\Http\Contract\IResponse { return self::__getProxyInstance()->setCookie($key, $value, $expire, $path, $domain, $secure, $httponly); } @@ -221,7 +221,7 @@ public function getTrailer(string $name): ?string /** * {@inheritDoc} */ - public function withTrailer(string $name, string $value): static + public function withTrailer(string $name, string $value): \Imi\Util\Http\Contract\IResponse { return self::__getProxyInstance()->withTrailer($name, $value); } @@ -229,7 +229,7 @@ public function withTrailer(string $name, string $value): static /** * {@inheritDoc} */ - public function setTrailer(string $name, string $value): static + public function setTrailer(string $name, string $value): \Imi\Util\Http\Contract\IResponse { return self::__getProxyInstance()->setTrailer($name, $value); } @@ -349,7 +349,7 @@ public function withBody(\Psr\Http\Message\StreamInterface $body): \Psr\Http\Mes /** * {@inheritDoc} */ - public function setProtocolVersion(string $version): static + public function setProtocolVersion(string $version): \Imi\Util\Http\Contract\IMessage { return self::__getProxyInstance()->setProtocolVersion($version); } @@ -357,7 +357,7 @@ public function setProtocolVersion(string $version): static /** * {@inheritDoc} */ - public function setHeader(string $name, array|string $value): static + 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, array|string $value): static /** * {@inheritDoc} */ - public function addHeader(string $name, array|string $value): static + public function addHeader(string $name, array|string $value): \Imi\Util\Http\Contract\IMessage { return self::__getProxyInstance()->addHeader($name, $value); } @@ -373,7 +373,7 @@ public function addHeader(string $name, array|string $value): static /** * {@inheritDoc} */ - public function removeHeader(string $name): static + public function removeHeader(string $name): \Imi\Util\Http\Contract\IMessage { return self::__getProxyInstance()->removeHeader($name); } @@ -381,7 +381,7 @@ public function removeHeader(string $name): static /** * {@inheritDoc} */ - public function setBody(\Psr\Http\Message\StreamInterface $body): static + public function setBody(\Psr\Http\Message\StreamInterface $body): \Imi\Util\Http\Contract\IMessage { return self::__getProxyInstance()->setBody($body); } diff --git a/src/Server/Http/Message/Response.php b/src/Server/Http/Message/Response.php index 3c22803abe..511dbac696 100644 --- a/src/Server/Http/Message/Response.php +++ b/src/Server/Http/Message/Response.php @@ -15,13 +15,13 @@ abstract class Response extends \Imi\Util\Http\Response implements IHttpResponse /** * {@inheritDoc} */ - public function redirect(string $url, int $status = StatusCode::FOUND): static + public function redirect(string $url, int $status = StatusCode::FOUND): self { // @phpstan-ignore-next-line return $this->setStatus($status)->setHeader('location', $url); } - public function withResponseBodyEmitter(?IResponseBodyEmitter $responseBodyEmitter): static + public function withResponseBodyEmitter(?IResponseBodyEmitter $responseBodyEmitter): self { $clone = clone $this; $clone->responseBodyEmitter = $responseBodyEmitter; @@ -29,7 +29,7 @@ public function withResponseBodyEmitter(?IResponseBodyEmitter $responseBodyEmitt return $clone; } - public function setResponseBodyEmitter(?IResponseBodyEmitter $responseBodyEmitter): static + public function setResponseBodyEmitter(?IResponseBodyEmitter $responseBodyEmitter): self { $this->responseBodyEmitter = $responseBodyEmitter; diff --git a/src/Util/Http/AbstractMessage.php b/src/Util/Http/AbstractMessage.php index 790ecfe3c3..1b7500717c 100644 --- a/src/Util/Http/AbstractMessage.php +++ b/src/Util/Http/AbstractMessage.php @@ -68,8 +68,10 @@ public function getProtocolVersion(): string /** * {@inheritDoc} + * + * @return static */ - public function withProtocolVersion($version): static + public function withProtocolVersion($version): self { $self = clone $this; $self->protocolVersion = $version; @@ -80,8 +82,10 @@ public function withProtocolVersion($version): static /** * {@inheritDoc} + * + * @return static */ - public function setProtocolVersion(string $version): static + public function setProtocolVersion(string $version): self { $this->protocolVersion = $version; $this->protocolVersionInited = true; @@ -184,8 +188,10 @@ public function getHeaderLine(string $name): string /** * {@inheritDoc} + * + * @return static */ - public function withHeader(string $name, $value): static + public function withHeader(string $name, $value): self { $self = clone $this; if (!$self->headersInited) @@ -199,8 +205,10 @@ public function withHeader(string $name, $value): static /** * {@inheritDoc} + * + * @return static */ - public function setHeader(string $name, $value): static + public function setHeader(string $name, $value): self { if (!$this->headersInited) { @@ -213,8 +221,10 @@ public function setHeader(string $name, $value): static /** * {@inheritDoc} + * + * @return static */ - public function withAddedHeader(string $name, $value): static + public function withAddedHeader(string $name, $value): self { $self = clone $this; if (!$self->headersInited) @@ -229,8 +239,10 @@ public function withAddedHeader(string $name, $value): static /** * {@inheritDoc} + * + * @return static */ - public function addHeader(string $name, $value): static + public function addHeader(string $name, $value): self { if (!$this->headersInited) { @@ -272,8 +284,10 @@ public function addHeader(string $name, $value): static /** * {@inheritDoc} + * + * @return static */ - public function withoutHeader(string $name): static + public function withoutHeader(string $name): self { $self = clone $this; if (!$self->headersInited) @@ -288,8 +302,10 @@ public function withoutHeader(string $name): static /** * {@inheritDoc} + * + * @return static */ - public function removeHeader(string $name): static + public function removeHeader(string $name): self { if (!$this->headersInited) { @@ -332,8 +348,10 @@ public function getBody(): StreamInterface /** * {@inheritDoc} + * + * @return static */ - public function withBody(StreamInterface $body): static + public function withBody(StreamInterface $body): self { $self = clone $this; $self->body = $body; @@ -344,8 +362,10 @@ public function withBody(StreamInterface $body): static /** * {@inheritDoc} + * + * @return static */ - public function setBody(StreamInterface $body): static + public function setBody(StreamInterface $body): self { $this->body = $body; $this->bodyInited = true; @@ -357,8 +377,10 @@ public function setBody(StreamInterface $body): static * 在当前实例下设置头. * * @param static|null $object + * + * @return static */ - protected function mergeHeaders(array $headers, self $object = null): static + 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 4b58e997c9..660d50b655 100644 --- a/src/Util/Http/Contract/IMessage.php +++ b/src/Util/Http/Contract/IMessage.php @@ -16,8 +16,10 @@ interface IMessage extends MessageInterface * "1.1", "1.0"). * * @param string $version HTTP protocol version + * + * @return static */ - public function setProtocolVersion(string $version): static; + public function setProtocolVersion(string $version): self; /** * Return an instance with the provided value replacing the specified header. @@ -28,9 +30,11 @@ public function setProtocolVersion(string $version): static; * @param string $name case-insensitive header field name * @param string|string[] $value header value(s) * + * @return static + * * @throws \InvalidArgumentException for invalid header names or values */ - public function setHeader(string $name, string|array $value): static; + public function setHeader(string $name, string|array $value): self; /** * Return an instance with the specified header appended with the given value. @@ -42,9 +46,11 @@ public function setHeader(string $name, string|array $value): static; * @param string $name case-insensitive header field name to add * @param string|string[] $value header value(s) * + * @return static + * * @throws \InvalidArgumentException for invalid header names or values */ - public function addHeader(string $name, string|array $value): static; + public function addHeader(string $name, string|array $value): self; /** * Return an instance without the specified header. @@ -52,8 +58,10 @@ public function addHeader(string $name, string|array $value): static; * Header resolution MUST be done without case-sensitivity. * * @param string $name case-insensitive header field name to remove + * + * @return static */ - public function removeHeader(string $name): static; + public function removeHeader(string $name): self; /** * Return an instance with the specified message body. @@ -62,7 +70,9 @@ public function removeHeader(string $name): static; * * @param StreamInterface $body body * + * @return static + * * @throws \InvalidArgumentException when the body is not valid */ - public function setBody(StreamInterface $body): static; + public function setBody(StreamInterface $body): self; } diff --git a/src/Util/Http/Contract/IRequest.php b/src/Util/Http/Contract/IRequest.php index 7aba69b5e5..f29f63b34b 100644 --- a/src/Util/Http/Contract/IRequest.php +++ b/src/Util/Http/Contract/IRequest.php @@ -19,8 +19,10 @@ interface IRequest extends RequestInterface * * @see http://tools.ietf.org/html/rfc7230#section-5.3 (for the various * request-target forms allowed in request messages) + * + * @return static */ - public function setRequestTarget(string $requestTarget): static; + public function setRequestTarget(string $requestTarget): self; /** * Return an instance with the provided HTTP method. @@ -31,9 +33,11 @@ public function setRequestTarget(string $requestTarget): static; * * @param string $method case-sensitive method * + * @return static + * * @throws \InvalidArgumentException for invalid HTTP methods */ - public function setMethod(string $method): static; + public function setMethod(string $method): self; /** * Returns an instance with the provided URI. @@ -60,8 +64,10 @@ public function setMethod(string $method): static; * * @param UriInterface $uri new request URI to use * @param bool $preserveHost preserve the original state of the Host header + * + * @return static */ - public function setUri(UriInterface $uri, bool $preserveHost = false): static; + public function setUri(UriInterface $uri, bool $preserveHost = false): self; public function getAppUri(?string $serverName = null): UriInterface; } diff --git a/src/Util/Http/Contract/IResponse.php b/src/Util/Http/Contract/IResponse.php index d57779411c..1ba47046bd 100644 --- a/src/Util/Http/Contract/IResponse.php +++ b/src/Util/Http/Contract/IResponse.php @@ -23,19 +23,25 @@ interface IResponse extends ResponseInterface, IMessage * provided status code; if none is provided, implementations MAY * use the defaults as suggested in the HTTP specification * + * @return static + * * @throws \InvalidArgumentException for invalid status code arguments */ - public function setStatus(int $code, string $reasonPhrase = ''): static; + public function setStatus(int $code, string $reasonPhrase = ''): self; /** * 设置cookie. + * + * @return static */ - public function withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false): static; + public function withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false): self; /** * 设置cookie. + * + * @return static */ - public function setCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false): static; + public function setCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false): self; /** * Retrieve cookies. @@ -69,11 +75,15 @@ public function getTrailer(string $name): ?string; /** * 设置 Trailer. + * + * @return static */ - public function withTrailer(string $name, string $value): static; + public function withTrailer(string $name, string $value): self; /** * 设置 Trailer. + * + * @return static */ - public function setTrailer(string $name, string $value): static; + public function setTrailer(string $name, string $value): self; } diff --git a/src/Util/Http/Contract/IServerRequest.php b/src/Util/Http/Contract/IServerRequest.php index 5f8c3eec75..4f4b33bfe9 100644 --- a/src/Util/Http/Contract/IServerRequest.php +++ b/src/Util/Http/Contract/IServerRequest.php @@ -29,8 +29,10 @@ public function getCookie(string $name, ?string $default = null): ?string; * instance, nor related values in the server params. * * @param array $cookies array of key/value pairs representing cookies + * + * @return static */ - public function setCookieParams(array $cookies): static; + public function setCookieParams(array $cookies): self; /** * Return an instance with the specified query string arguments. @@ -48,17 +50,21 @@ public function setCookieParams(array $cookies): static; * * @param array $query array of query string arguments, typically from * $_GET + * + * @return static */ - public function setQueryParams(array $query): static; + public function setQueryParams(array $query): self; /** * Create a new instance with the specified uploaded files. * * @param array $uploadedFiles an array tree of UploadedFileInterface instances * + * @return static + * * @throws \InvalidArgumentException if an invalid structure is provided */ - public function setUploadedFiles(array $uploadedFiles): static; + public function setUploadedFiles(array $uploadedFiles): self; /** * Return an instance with the specified body parameters. @@ -81,10 +87,12 @@ public function setUploadedFiles(array $uploadedFiles): static; * @param array|object|null $data The deserialized body data. This will * typically be in an array or object. * + * @return static + * * @throws \InvalidArgumentException if an unsupported argument type is * provided */ - public function setParsedBody(array|object|null $data): static; + public function setParsedBody(array|object|null $data): self; /** * Return an instance with the specified derived request attribute. @@ -96,8 +104,10 @@ public function setParsedBody(array|object|null $data): static; * * @param string $name the attribute name * @param mixed $value the value of the attribute + * + * @return static */ - public function setAttribute(string $name, mixed $value): static; + public function setAttribute(string $name, mixed $value): self; /** * Return an instance that removes the specified derived request attribute. @@ -108,8 +118,10 @@ public function setAttribute(string $name, mixed $value): static; * @see getAttributes() * * @param string $name the attribute name + * + * @return static */ - public function removeAttribute(string $name): static; + public function removeAttribute(string $name): self; /** * 获取 GET 参数 @@ -148,31 +160,43 @@ public function hasRequest(string $name): bool; /** * 设置 GET 数据. + * + * @return static */ - public function withGet(array $get): static; + public function withGet(array $get): self; /** * 设置 GET 数据. + * + * @return static */ - public function setGet(array $get): static; + public function setGet(array $get): self; /** * 设置 POST 数据. + * + * @return static */ - public function withPost(mixed $post): static; + public function withPost(mixed $post): self; /** * 设置 POST 数据. + * + * @return static */ - public function setPost(mixed $post): static; + public function setPost(mixed $post): self; /** * 设置 Request 数据. + * + * @return static */ - public function withRequest(array $request): static; + public function withRequest(array $request): self; /** * 设置 Request 数据. + * + * @return static */ - public function setRequest(array $request): static; + public function setRequest(array $request): self; } diff --git a/src/Util/Http/Request.php b/src/Util/Http/Request.php index fa112841c1..34416e32e2 100644 --- a/src/Util/Http/Request.php +++ b/src/Util/Http/Request.php @@ -64,8 +64,10 @@ public function getRequestTarget(): string /** * {@inheritDoc} + * + * @return static */ - public function withRequestTarget(string $requestTarget): static + public function withRequestTarget(string $requestTarget): self { $self = clone $this; $self->requestTarget = $requestTarget; @@ -75,8 +77,10 @@ public function withRequestTarget(string $requestTarget): static /** * {@inheritDoc} + * + * @return static */ - public function setRequestTarget(string $requestTarget): static + public function setRequestTarget(string $requestTarget): self { $this->requestTarget = $requestTarget; @@ -106,8 +110,10 @@ public function getMethod(): string /** * {@inheritDoc} + * + * @return static */ - public function withMethod(string $method): static + public function withMethod(string $method): self { $self = clone $this; $self->method = $method; @@ -118,8 +124,10 @@ public function withMethod(string $method): static /** * {@inheritDoc} + * + * @return static */ - public function setMethod(string $method): static + public function setMethod(string $method): self { $this->method = $method; $this->methodInited = true; @@ -150,8 +158,10 @@ public function getUri(): UriInterface /** * {@inheritDoc} + * + * @return static */ - public function withUri(UriInterface $uri, bool $preserveHost = false): static + public function withUri(UriInterface $uri, bool $preserveHost = false): self { $self = clone $this; @@ -161,8 +171,10 @@ public function withUri(UriInterface $uri, bool $preserveHost = false): static /** * {@inheritDoc} + * + * @return static */ - public function setUri(UriInterface $uri, bool $preserveHost = false): static + public function setUri(UriInterface $uri, bool $preserveHost = false): self { $this->uri = $uri; $this->appUri = null; diff --git a/src/Util/Http/Response.php b/src/Util/Http/Response.php index 09134ca7ae..9684a14ec8 100644 --- a/src/Util/Http/Response.php +++ b/src/Util/Http/Response.php @@ -50,8 +50,10 @@ public function getStatusCode(): int /** * {@inheritDoc} + * + * @return static */ - public function withStatus(int $code, string $reasonPhrase = ''): static + public function withStatus(int $code, string $reasonPhrase = ''): self { $self = clone $this; $self->statusCode = $code; @@ -69,8 +71,10 @@ public function withStatus(int $code, string $reasonPhrase = ''): static /** * {@inheritDoc} + * + * @return static */ - public function setStatus(int $code, string $reasonPhrase = ''): static + public function setStatus(int $code, string $reasonPhrase = ''): self { $this->statusCode = $code; if ('' === $reasonPhrase) @@ -100,8 +104,10 @@ public function getReasonPhrase(): string /** * {@inheritDoc} + * + * @return static */ - public function withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false): static + public function withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false): self { $self = clone $this; $self->cookies[$key] = [ @@ -119,8 +125,10 @@ 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): static + public function setCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false): self { $this->cookies[$key] = [ 'key' => $key, @@ -177,8 +185,10 @@ public function getTrailer(string $name): ?string /** * {@inheritDoc} + * + * @return static */ - public function withTrailer(string $name, string $value): static + public function withTrailer(string $name, string $value): self { $self = clone $this; $self->trailers[$name] = $value; @@ -188,8 +198,10 @@ public function withTrailer(string $name, string $value): static /** * {@inheritDoc} + * + * @return static */ - public function setTrailer(string $name, string $value): static + public function setTrailer(string $name, string $value): self { $this->trailers[$name] = $value; diff --git a/src/Util/Http/ServerRequest.php b/src/Util/Http/ServerRequest.php index 66d309f731..9d1fda3b14 100644 --- a/src/Util/Http/ServerRequest.php +++ b/src/Util/Http/ServerRequest.php @@ -118,8 +118,10 @@ protected function initRequestParams(): void /** * {@inheritDoc} + * + * @return static */ - public function setCookieParams(array $cookies): static + public function setCookieParams(array $cookies): self { if (!$this->requestParamsInited) { @@ -147,8 +149,10 @@ public function getCookieParams(): array /** * {@inheritDoc} + * + * @return static */ - public function withCookieParams(array $cookies): static + public function withCookieParams(array $cookies): self { $self = clone $this; if (!$self->requestParamsInited) @@ -177,8 +181,10 @@ public function getCookie(string $name, ?string $default = null): ?string /** * {@inheritDoc} + * + * @return static */ - public function setQueryParams(array $query): static + public function setQueryParams(array $query): self { if (!$this->requestParamsInited) { @@ -206,8 +212,10 @@ public function getQueryParams(): array /** * {@inheritDoc} + * + * @return static */ - public function withQueryParams(array $query): static + public function withQueryParams(array $query): self { $self = clone $this; if (!$self->requestParamsInited) @@ -243,8 +251,10 @@ public function getUploadedFiles(): array /** * {@inheritDoc} + * + * @return static */ - public function withUploadedFiles(array $uploadedFiles): static + public function withUploadedFiles(array $uploadedFiles): self { $self = clone $this; @@ -254,8 +264,10 @@ public function withUploadedFiles(array $uploadedFiles): static /** * {@inheritDoc} + * + * @return static */ - public function setUploadedFiles(array $uploadedFiles): static + public function setUploadedFiles(array $uploadedFiles): self { $objectFiles = &$this->files; $objectFiles = []; @@ -347,8 +359,10 @@ public function getParsedBody() /** * {@inheritDoc} + * + * @return static */ - public function withParsedBody($data): static + public function withParsedBody($data): self { $self = clone $this; $self->parsedBody = $data; @@ -358,8 +372,10 @@ public function withParsedBody($data): static /** * {@inheritDoc} + * + * @return static */ - public function setParsedBody($data): static + public function setParsedBody($data): self { $this->parsedBody = $data; @@ -392,8 +408,10 @@ public function getAttribute(string $name, $default = null) /** * {@inheritDoc} + * + * @return static */ - public function withAttribute(string $name, $value): static + public function withAttribute(string $name, $value): self { $self = clone $this; $self->attributes[$name] = $value; @@ -403,8 +421,10 @@ public function withAttribute(string $name, $value): static /** * {@inheritDoc} + * + * @return static */ - public function setAttribute(string $name, $value): static + public function setAttribute(string $name, $value): self { $this->attributes[$name] = $value; @@ -413,8 +433,10 @@ public function setAttribute(string $name, $value): static /** * {@inheritDoc} + * + * @return static */ - public function withoutAttribute(string $name): static + public function withoutAttribute(string $name): self { $self = clone $this; if (\array_key_exists($name, $self->attributes)) @@ -427,8 +449,10 @@ public function withoutAttribute(string $name): static /** * {@inheritDoc} + * + * @return static */ - public function removeAttribute(string $name): static + public function removeAttribute(string $name): self { if (\array_key_exists($name, $this->attributes)) { @@ -547,8 +571,10 @@ public function hasRequest(string $name): bool /** * {@inheritDoc} + * + * @return static */ - public function withGet(array $get): static + public function withGet(array $get): self { $self = clone $this; if (!$self->requestParamsInited) @@ -563,8 +589,10 @@ public function withGet(array $get): static /** * {@inheritDoc} + * + * @return static */ - public function setGet(array $get): static + public function setGet(array $get): self { if (!$this->requestParamsInited) { @@ -578,8 +606,10 @@ public function setGet(array $get): static /** * {@inheritDoc} + * + * @return static */ - public function withPost(mixed $post): static + public function withPost(mixed $post): self { $self = clone $this; if (!$self->requestParamsInited) @@ -594,8 +624,10 @@ public function withPost(mixed $post): static /** * {@inheritDoc} + * + * @return static */ - public function setPost(mixed $post): static + public function setPost(mixed $post): self { if (!$this->requestParamsInited) { @@ -609,8 +641,10 @@ public function setPost(mixed $post): static /** * {@inheritDoc} + * + * @return static */ - public function withRequest(array $request): static + public function withRequest(array $request): self { $self = clone $this; if (!$self->requestParamsInited) @@ -625,8 +659,10 @@ public function withRequest(array $request): static /** * {@inheritDoc} + * + * @return static */ - public function setRequest(array $request): static + public function setRequest(array $request): self { if (!$this->requestParamsInited) { diff --git a/src/Util/Stream/FileStream.php b/src/Util/Stream/FileStream.php index 4035561369..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 { diff --git a/src/Util/Stream/MemoryStream.php b/src/Util/Stream/MemoryStream.php index dedafc5832..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; } diff --git a/src/Util/Uri.php b/src/Util/Uri.php index f36fae1251..a7609659e6 100644 --- a/src/Util/Uri.php +++ b/src/Util/Uri.php @@ -233,7 +233,7 @@ public function getFragment(): string /** * {@inheritDoc} */ - public function withScheme(string $scheme): static + public function withScheme(string $scheme): self { if (!\is_string($scheme)) { @@ -252,7 +252,7 @@ public function withUserInfo( string $user, #[\SensitiveParameter] ?string $password = null - ): static { + ): self { $self = clone $this; $self->userInfo = $user; if (null !== $password) @@ -266,7 +266,7 @@ public function withUserInfo( /** * {@inheritDoc} */ - public function withHost(string $host): static + public function withHost(string $host): self { $self = clone $this; $self->host = $host; @@ -277,7 +277,7 @@ public function withHost(string $host): static /** * {@inheritDoc} */ - public function withPort(?int $port): static + public function withPort(?int $port): self { $self = clone $this; $self->port = $port; @@ -288,7 +288,7 @@ public function withPort(?int $port): static /** * {@inheritDoc} */ - public function withPath(string $path): static + public function withPath(string $path): self { $self = clone $this; $self->path = $path; @@ -299,7 +299,7 @@ public function withPath(string $path): static /** * {@inheritDoc} */ - public function withQuery(string $query): static + public function withQuery(string $query): self { $self = clone $this; $self->query = $query; @@ -310,7 +310,7 @@ public function withQuery(string $query): static /** * {@inheritDoc} */ - public function withFragment(string $fragment): static + public function withFragment(string $fragment): self { $self = clone $this; $self->fragment = $fragment; From afcfecebb4db811d2a8fc96b9f05b9007d928606 Mon Sep 17 00:00:00 2001 From: Yurun Date: Tue, 17 Oct 2023 19:33:55 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20Swoole=20v5.1.0=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 05567140d4..8cc776642e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,6 +20,10 @@ jobs: fail-fast: false matrix: swoole: + - version: 5.1-php8.2 + postgresql_version: "" + - version: 5.1-php8.1 + postgresql_version: "" - version: 5.0-php8.2 postgresql_version: "" - version: 5.0-php8.1 @@ -104,7 +108,7 @@ jobs: fail-fast: false matrix: swoole: - - version: 5.0-php8.2 + - version: 5.1-php8.2 postgresql_version: "" roadrunner: [2.7.*] env: @@ -274,7 +278,7 @@ jobs: fail-fast: false matrix: php: ["8.1", "8.2"] - swoole: [v5.0.3] + swoole: [v5.1.0, v5.0.3] roadrunner: [2.7.*] env: MYSQL_SERVER_PASSWORD: "root" From 368371a2dc6f3b0daa5e042a99716bef431fd7ef Mon Sep 17 00:00:00 2001 From: Yurun Date: Wed, 18 Oct 2023 09:39:36 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=20phpunit=20dev=20=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Components/amqp/composer.json | 5 ++--- src/Components/fpm/composer.json | 4 +--- src/Components/jwt/composer.json | 4 +--- src/Components/phar/tests/project/composer.json | 2 +- src/Components/queue/composer.json | 3 +-- src/Components/roadrunner/composer.json | 4 +--- src/Components/smarty/composer.json | 4 +--- src/Components/snowflake/composer.json | 4 +--- src/Components/swoole/composer.json | 1 - src/Components/workerman-gateway/composer.json | 1 - src/Components/workerman/composer.json | 1 - 11 files changed, 9 insertions(+), 24 deletions(-) diff --git a/src/Components/amqp/composer.json b/src/Components/amqp/composer.json index f769b09bb5..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": "~5.0", - "phpunit/phpunit": "~9.6" + "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/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/phar/tests/project/composer.json b/src/Components/phar/tests/project/composer.json index c1ab112857..529182d265 100644 --- a/src/Components/phar/tests/project/composer.json +++ b/src/Components/phar/tests/project/composer.json @@ -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/composer.json b/src/Components/queue/composer.json index 9f0dd8e436..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": "~5.0", - "phpunit/phpunit": "~9.6" + "swoole/ide-helper": "~5.0" }, "autoload": { "psr-4": { 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/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/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/swoole/composer.json b/src/Components/swoole/composer.json index db6dad21ad..368152be07 100644 --- a/src/Components/swoole/composer.json +++ b/src/Components/swoole/composer.json @@ -8,7 +8,6 @@ "yurunsoft/swoole-co-pool": "~1.0|~2.0" }, "require-dev": { - "phpunit/phpunit": "~9.6", "swoole/ide-helper": "~5.0" }, "autoload": { 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": { From c8ab1a28073096d8dff9124574bfae22b4c76a10 Mon Sep 17 00:00:00 2001 From: Yurun Date: Wed, 18 Oct 2023 09:57:47 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 16 ++++++++-------- dev/test-coverage-actions.sh | 6 +++--- dev/test-coverage.sh | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/composer.json b/composer.json index e96bd90388..ba40c4210e 100644 --- a/composer.json +++ b/composer.json @@ -87,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", @@ -107,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 From ed775ca792dcb69faf015b6eda22105c59d65eff Mon Sep 17 00:00:00 2001 From: Yurun Date: Wed, 18 Oct 2023 10:19:17 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Components/jwt/tests/bootstrap.php | 5 +++++ src/Components/jwt/tests/phpunit.xml | 1 + src/Components/snowflake/tests/bootstrap.php | 5 +++++ src/Components/snowflake/tests/phpunit.xml | 1 + 4 files changed, 12 insertions(+) create mode 100644 src/Components/jwt/tests/bootstrap.php create mode 100644 src/Components/snowflake/tests/bootstrap.php 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 @@ +