From 797ec357d920a54de5a9665ff3b3d0923360799e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Wed, 5 Jun 2024 19:18:29 +0200 Subject: [PATCH 1/2] Improve PHP 8.4+ support by avoiding implicitly nullable types --- composer.json | 10 +++++----- src/ProxyConnector.php | 6 +++++- tests/ProxyConnectorTest.php | 6 ++++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 2923c55..7788b7d 100644 --- a/composer.json +++ b/composer.json @@ -12,16 +12,16 @@ ], "require": { "php": ">=5.3", - "react/promise": "^3 || ^2.1 || ^1.2.1", - "react/socket": "^1.12", + "react/promise": "^3.2 || ^2.1 || ^1.2.1", + "react/socket": "^1.16", "ringcentral/psr7": "^1.2" }, "require-dev": { "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36", - "react/async": "^4 || ^3 || ^2", + "react/async": "^4.3 || ^3 || ^2", "react/event-loop": "^1.2", - "react/http": "^1.5", - "react/promise-timer": "^1.10" + "react/http": "^1.11", + "react/promise-timer": "^1.11" }, "autoload": { "psr-4": { diff --git a/src/ProxyConnector.php b/src/ProxyConnector.php index d7f2863..0e7bcdb 100644 --- a/src/ProxyConnector.php +++ b/src/ProxyConnector.php @@ -60,7 +60,7 @@ class ProxyConnector implements ConnectorInterface public function __construct( #[\SensitiveParameter] $proxyUrl, - ConnectorInterface $connector = null, + $connector = null, array $httpHeaders = array() ) { // support `http+unix://` scheme for Unix domain socket (UDS) paths @@ -84,6 +84,10 @@ public function __construct( throw new InvalidArgumentException('Invalid proxy URL "' . $proxyUrl . '"'); } + if ($connector !== null && !$connector instanceof ConnectorInterface) { // manual type check to support legacy PHP < 7.1 + throw new \InvalidArgumentException('Argument #2 ($connector) expected null|React\Socket\ConnectorInterface'); + } + // apply default port and TCP/TLS transport for given scheme if (!isset($parts['port'])) { $parts['port'] = $parts['scheme'] === 'https' ? 443 : 80; diff --git a/tests/ProxyConnectorTest.php b/tests/ProxyConnectorTest.php index f2d5795..0839692 100644 --- a/tests/ProxyConnectorTest.php +++ b/tests/ProxyConnectorTest.php @@ -48,6 +48,12 @@ public function testInvalidHttpsUnixScheme() new ProxyConnector('https+unix:///tmp/proxy.sock', $this->connector); } + public function testContructorThrowsExceptionForInvalidConnector() + { + $this->setExpectedException('InvalidArgumentException', 'Argument #2 ($connector) expected null|React\Socket\ConnectorInterface'); + new ProxyConnector('proxy.example.com', 'connector'); + } + public function testCreatesConnectionToHttpPort() { $promise = new Promise(function () { }); From d0dae6f63a3288e5dba95a716c7fc7b29ebf72f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Fri, 6 Dec 2024 16:37:46 +0100 Subject: [PATCH 2/2] Run tests on PHP 8.4 and update test environment --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c6239b6..98ceb2a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,10 +7,11 @@ on: jobs: PHPUnit: name: PHPUnit (PHP ${{ matrix.php }}) - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 strategy: matrix: php: + - 8.4 - 8.3 - 8.2 - 8.1 @@ -38,7 +39,7 @@ jobs: PHPUnit-hhvm: name: PHPUnit (HHVM) - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 continue-on-error: true steps: - uses: actions/checkout@v4 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy