From 7e545f8c5219a0bd7d106c082c4fc57fec872a4d Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Sun, 5 May 2024 12:33:57 +0200 Subject: [PATCH 01/12] install flex in shivammathur --- .github/workflows/continuous-integration.yml | 8 ++++---- .github/workflows/static-analysis.yml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index b2a550e9..972b562e 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -78,7 +78,7 @@ jobs: steps: - name: "Checkout" - uses: "actions/checkout@v3" + uses: "actions/checkout@v4" with: fetch-depth: 2 @@ -88,6 +88,7 @@ jobs: php-version: "${{ matrix.php-version }}" coverage: "pcov" ini-values: "zend.assertions=1" + tools: "flex" - name: "Enforce using stable dependencies" run: "composer config minimum-stability stable" @@ -95,11 +96,10 @@ jobs: - name: "Add dependencies and enable flex" run: | - composer require --no-update symfony/flex ${{ matrix.dependencies }} - composer config --no-plugins allow-plugins.symfony/flex true + composer require --no-update ${{ matrix.dependencies }} - name: "Install dependencies with Composer" - uses: "ramsey/composer-install@v2" + uses: "ramsey/composer-install@v3" with: dependency-versions: "${{ matrix.dependency-versions }}" composer-options: "${{ matrix.composer-options }}" diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 9703d7de..99c2b1f2 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -15,7 +15,7 @@ jobs: steps: - name: "Checkout" - uses: "actions/checkout@v3" + uses: "actions/checkout@v4" - name: "PHP-CS-Fixer" uses: "docker://oskarstark/php-cs-fixer-ga:2.19.0" with: From 2905f7e10250ff3992c442c0a5e9a474e4e20b88 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Wed, 22 May 2024 12:46:18 +0200 Subject: [PATCH 02/12] use extension class from di component instead of the kernel --- CHANGELOG.md | 4 ++++ src/DependencyInjection/HttplugExtension.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bfd08e6..fbd72e79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee # Version 1 +# unreleased + +- Fixed extension to depend on the DependencyInjection component rather than the HttpKernel. + # 1.33.0 - 2024-02-27 - Support php-http/cache-plugin 2.0 and bump minimal version to 1.7 by defaulting the stream factory for cache to `httplug.psr17_stream_factory` (#448). diff --git a/src/DependencyInjection/HttplugExtension.php b/src/DependencyInjection/HttplugExtension.php index a70e0b6c..3fea496c 100644 --- a/src/DependencyInjection/HttplugExtension.php +++ b/src/DependencyInjection/HttplugExtension.php @@ -31,9 +31,9 @@ use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; +use Symfony\Component\DependencyInjection\Extension\Extension; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\HttpKernel\Kernel; use Twig\Environment as TwigEnvironment; From b7ad2c1951edec36ef0bd9897e309b0038c59a54 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Mon, 27 May 2024 13:35:05 +0200 Subject: [PATCH 03/12] prepare release --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fbd72e79..f24cbc4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee # Version 1 -# unreleased +# 1.33.1 - 2024-05-27 - Fixed extension to depend on the DependencyInjection component rather than the HttpKernel. From 58223ebb719ef09dd721a581cde87ccfe95397a9 Mon Sep 17 00:00:00 2001 From: Maxim Date: Mon, 17 Jun 2024 10:05:08 +0200 Subject: [PATCH 04/12] add configuration for ThrottlePlugin (#460) --- composer.json | 3 ++- src/DependencyInjection/Configuration.php | 12 +++++++++++ src/DependencyInjection/HttplugExtension.php | 20 +++++++++++++++++++ src/Resources/config/plugins.xml | 3 +++ .../DependencyInjection/ConfigurationTest.php | 12 +++++++++++ 5 files changed, 49 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 27111a4a..3daeef71 100644 --- a/composer.json +++ b/composer.json @@ -45,7 +45,8 @@ "php-http/guzzle6-adapter": "<1.1", "php-http/cache-plugin": "<1.7.0", "php-http/curl-client": "<2.0", - "php-http/socket-client": "<2.0" + "php-http/socket-client": "<2.0", + "php-http/throttle-plugin": "<1.1" }, "require-dev": { "guzzlehttp/psr7": "^1.7 || ^2.0", diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 4b842990..bd70c712 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -624,6 +624,18 @@ private function addSharedPluginNodes(ArrayNodeDefinition $pluginNode, $disableA ->end() ->end(); // End error plugin + + $throttle = $children->arrayNode('throttle') + ->canBeEnabled() + ->addDefaultsIfNotSet() + ->children() + ->scalarNode('name')->end() + ->scalarNode('key')->defaultNull()->end() + ->integerNode('tokens')->defaultValue(1)->end() + ->floatNode('max_time')->defaultNull()->end() + ->end() + ->end(); + // End throttle plugin } /** diff --git a/src/DependencyInjection/HttplugExtension.php b/src/DependencyInjection/HttplugExtension.php index 3fea496c..cdcbfcf0 100644 --- a/src/DependencyInjection/HttplugExtension.php +++ b/src/DependencyInjection/HttplugExtension.php @@ -10,6 +10,7 @@ use Http\Client\Common\HttpMethodsClient; use Http\Client\Common\HttpMethodsClientInterface; use Http\Client\Common\Plugin\AuthenticationPlugin; +use Http\Client\Common\Plugin\ThrottlePlugin; use Http\Client\Common\PluginClient; use Http\Client\Common\PluginClientFactory; use Http\Client\HttpAsyncClient; @@ -35,6 +36,7 @@ use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\HttpKernel\Kernel; +use Symfony\Component\RateLimiter\LimiterInterface; use Twig\Environment as TwigEnvironment; /** @@ -292,6 +294,24 @@ private function configurePluginByName($name, Definition $definition, array $con break; + case 'throttle': + if (!\class_exists(ThrottlePlugin::class)) { + throw new InvalidConfigurationException('You need to require the Throttle Plugin to be able to use it: "composer require php-http/throttle-plugin".'); + } + + $key = $config['name'] ? '.'.$config['name'] : ''; + $container + ->register($serviceId.$key, LimiterInterface::class) + ->setFactory([new Reference('limiter.'.$config['name']), 'create']) + ->addArgument($config['key']) + ->setPublic(false); + + $definition->replaceArgument(0, new Reference($serviceId.$key)); + $definition->setArgument('$tokens', $config['tokens']); + $definition->setArgument('$maxTime', $config['max_time']); + + break; + /* client specific plugins */ case 'add_host': diff --git a/src/Resources/config/plugins.xml b/src/Resources/config/plugins.xml index 749407c4..9f9c0ec1 100644 --- a/src/Resources/config/plugins.xml +++ b/src/Resources/config/plugins.xml @@ -28,6 +28,9 @@ + + + diff --git a/tests/Unit/DependencyInjection/ConfigurationTest.php b/tests/Unit/DependencyInjection/ConfigurationTest.php index 447efe1a..999c813b 100644 --- a/tests/Unit/DependencyInjection/ConfigurationTest.php +++ b/tests/Unit/DependencyInjection/ConfigurationTest.php @@ -98,6 +98,12 @@ class ConfigurationTest extends AbstractExtensionConfigurationTestCase 'enabled' => false, 'only_server_exception' => false, ], + 'throttle' => [ + 'enabled' => false, + 'key' => null, + 'tokens' => 1, + 'max_time' => null, + ], ], 'discovery' => [ 'client' => 'auto', @@ -308,6 +314,12 @@ public function testSupportsAllConfigFormats(): void 'enabled' => false, 'only_server_exception' => false, ], + 'throttle' => [ + 'enabled' => false, + 'key' => null, + 'tokens' => 1, + 'max_time' => null, + ], ], 'discovery' => [ 'client' => 'auto', From 5380dadb3ca75be5aa54983db86e0e8fa4c7e7ca Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Mon, 17 Jun 2024 10:06:25 +0200 Subject: [PATCH 05/12] prepare release --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f24cbc4f..ccaff89d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee # Version 1 +# 1.34.0 - 2024-06-17 + +- Support to configure the throttle plugin. + # 1.33.1 - 2024-05-27 - Fixed extension to depend on the DependencyInjection component rather than the HttpKernel. From 5c3e184b1e96058c074c8d20a09ee3a708ba1f50 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Sun, 1 Sep 2024 09:07:16 +0200 Subject: [PATCH 06/12] throttle plugin requires a name --- CHANGELOG.md | 4 ++++ src/DependencyInjection/Configuration.php | 9 ++++++--- src/DependencyInjection/HttplugExtension.php | 5 ++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ccaff89d..a4012550 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee # Version 1 +# 1.34.1 - 2024-09-01 + +- The rate-limiter name in the throttle plugin configuration is required. + # 1.34.0 - 2024-06-17 - Support to configure the throttle plugin. diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index bd70c712..76b13751 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -616,7 +616,7 @@ private function addSharedPluginNodes(ArrayNodeDefinition $pluginNode, $disableA ->end(); // End stopwatch plugin - $error = $children->arrayNode('error') + $children->arrayNode('error') ->canBeEnabled() ->addDefaultsIfNotSet() ->children() @@ -625,11 +625,14 @@ private function addSharedPluginNodes(ArrayNodeDefinition $pluginNode, $disableA ->end(); // End error plugin - $throttle = $children->arrayNode('throttle') + $children->arrayNode('throttle') ->canBeEnabled() ->addDefaultsIfNotSet() ->children() - ->scalarNode('name')->end() + ->scalarNode('name') + ->info('The name of the configured symfony/rate-limiter to use') + ->isRequired() + ->end() ->scalarNode('key')->defaultNull()->end() ->integerNode('tokens')->defaultValue(1)->end() ->floatNode('max_time')->defaultNull()->end() diff --git a/src/DependencyInjection/HttplugExtension.php b/src/DependencyInjection/HttplugExtension.php index cdcbfcf0..ce88c008 100644 --- a/src/DependencyInjection/HttplugExtension.php +++ b/src/DependencyInjection/HttplugExtension.php @@ -299,14 +299,13 @@ private function configurePluginByName($name, Definition $definition, array $con throw new InvalidConfigurationException('You need to require the Throttle Plugin to be able to use it: "composer require php-http/throttle-plugin".'); } - $key = $config['name'] ? '.'.$config['name'] : ''; $container - ->register($serviceId.$key, LimiterInterface::class) + ->register($serviceId.$config['name'], LimiterInterface::class) ->setFactory([new Reference('limiter.'.$config['name']), 'create']) ->addArgument($config['key']) ->setPublic(false); - $definition->replaceArgument(0, new Reference($serviceId.$key)); + $definition->replaceArgument(0, new Reference($serviceId.$config['name'])); $definition->setArgument('$tokens', $config['tokens']); $definition->setArgument('$maxTime', $config['max_time']); From 64362f16b2aed00c5aedd4c8afcae0489e85f9e9 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Sun, 1 Sep 2024 09:16:43 +0200 Subject: [PATCH 07/12] fix build --- composer.json | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 3daeef71..adb2ed91 100644 --- a/composer.json +++ b/composer.json @@ -50,18 +50,19 @@ }, "require-dev": { "guzzlehttp/psr7": "^1.7 || ^2.0", - "matthiasnoback/symfony-dependency-injection-test": "^4.0 || ^5.0", + "matthiasnoback/symfony-config-test": "^4.3 || ^5.0", + "matthiasnoback/symfony-dependency-injection-test": "^4.3.1 || ^5.0", "nyholm/nsa": "^1.1", "nyholm/psr7": "^1.2.1", "php-http/cache-plugin": "^1.7", "php-http/mock-client": "^1.2", "php-http/promise": "^1.0", + "phpunit/phpunit": "^9.6", "symfony/browser-kit": "^4.4 || ^5.0 || ^6.0 || ^7.0", "symfony/cache": "^4.4 || ^5.0 || ^6.0 || ^7.0", "symfony/dom-crawler": "^4.4 || ^5.0 || ^6.0 || ^7.0", "symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0 || ^7.0", "symfony/http-foundation": "^4.4.19 || ^5.0 || ^6.0 || ^7.0", - "symfony/phpunit-bridge": "^6.4.1", "symfony/stopwatch": "^4.4 || ^5.0 || ^6.0 || ^7.0", "symfony/twig-bundle": "^4.4 || ^5.0 || ^6.0 || ^7.0", "symfony/web-profiler-bundle": "^4.4.19 || ^5.0 || ^6.0 || ^7.0", @@ -97,7 +98,7 @@ }, "prefer-stable": false, "scripts": { - "test": "vendor/bin/simple-phpunit", - "test-ci": "vendor/bin/simple-phpunit --coverage-text --coverage-clover=build/coverage.xml" + "test": "vendor/bin/phpunit", + "test-ci": "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml" } } From 2ffa2302d6ec53e604c286f4964e237db3b3a786 Mon Sep 17 00:00:00 2001 From: Maxim Solovev Date: Mon, 17 Jun 2024 11:59:33 +0200 Subject: [PATCH 08/12] Throttle plugin configuration documentation --- .github/workflows/continuous-integration.yml | 2 +- src/DependencyInjection/Configuration.php | 17 ++++++++--- src/DependencyInjection/HttplugExtension.php | 7 +++-- .../HttplugExtensionTest.php | 29 ++++++++++++++----- 4 files changed, 39 insertions(+), 16 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 972b562e..1f872754 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -43,7 +43,7 @@ jobs: - dependencies: "php-http/guzzle7-adapter" php-version: "8.2" symfony-deprecations-helper: "weak" - - dependencies: "php-http/guzzle7-adapter" + - dependencies: "php-http/guzzle7-adapter php-http/throttle-plugin" php-version: "8.3" symfony-deprecations-helper: "weak" diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 76b13751..62276584 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -630,12 +630,21 @@ private function addSharedPluginNodes(ArrayNodeDefinition $pluginNode, $disableA ->addDefaultsIfNotSet() ->children() ->scalarNode('name') - ->info('The name of the configured symfony/rate-limiter to use') ->isRequired() + ->info('Rate limiter service name from symfony/rate-limiter configuration. E.g. for a rate limiter http_client you specify limiter.http_client here') + ->end() + ->scalarNode('key') + ->defaultNull() + ->info('Key to avoid sharing this rate limiter with other clients or other services. You can use the name of the client for example.') + ->end() + ->integerNode('tokens') + ->defaultValue(1) + ->info('How many tokens spending per request') + ->end() + ->floatNode('max_time') + ->defaultNull() + ->info('Maximum accepted waiting time in seconds') ->end() - ->scalarNode('key')->defaultNull()->end() - ->integerNode('tokens')->defaultValue(1)->end() - ->floatNode('max_time')->defaultNull()->end() ->end() ->end(); // End throttle plugin diff --git a/src/DependencyInjection/HttplugExtension.php b/src/DependencyInjection/HttplugExtension.php index ce88c008..f5d63ceb 100644 --- a/src/DependencyInjection/HttplugExtension.php +++ b/src/DependencyInjection/HttplugExtension.php @@ -299,13 +299,14 @@ private function configurePluginByName($name, Definition $definition, array $con throw new InvalidConfigurationException('You need to require the Throttle Plugin to be able to use it: "composer require php-http/throttle-plugin".'); } + $limiterServiceId = $serviceId.'.'.$config['name']; $container - ->register($serviceId.$config['name'], LimiterInterface::class) - ->setFactory([new Reference('limiter.'.$config['name']), 'create']) + ->register($limiterServiceId, LimiterInterface::class) + ->setFactory([new Reference($config['name']), 'create']) ->addArgument($config['key']) ->setPublic(false); - $definition->replaceArgument(0, new Reference($serviceId.$config['name'])); + $definition->replaceArgument(0, new Reference($limiterServiceId)); $definition->setArgument('$tokens', $config['tokens']); $definition->setArgument('$maxTime', $config['max_time']); diff --git a/tests/Unit/DependencyInjection/HttplugExtensionTest.php b/tests/Unit/DependencyInjection/HttplugExtensionTest.php index 3b65c540..016085aa 100644 --- a/tests/Unit/DependencyInjection/HttplugExtensionTest.php +++ b/tests/Unit/DependencyInjection/HttplugExtensionTest.php @@ -5,6 +5,7 @@ namespace Http\HttplugBundle\Tests\Unit\DependencyInjection; use Http\Adapter\Guzzle7\Client; +use Http\Client\Common\Plugin\ThrottlePlugin; use Http\Client\HttpClient; use Http\Client\Plugin\Vcr\Recorder\InMemoryRecorder; use Http\HttplugBundle\Collector\PluginClientFactoryListener; @@ -79,7 +80,7 @@ public function testConfigLoadService(): void public function testClientPlugins(): void { - $this->load([ + $config = [ 'clients' => [ 'acme' => [ 'factory' => 'httplug.factory.curl', @@ -130,6 +131,11 @@ public function testClientPlugins(): void 'headers' => ['X-FOO'], ], ], + [ + 'query_defaults' => [ + 'parameters' => ['locale' => 'en'], + ], + ], [ 'request_seekable_body' => [ 'use_file_buffer' => true, @@ -138,11 +144,6 @@ public function testClientPlugins(): void [ 'response_seekable_body' => true, ], - [ - 'query_defaults' => [ - 'parameters' => ['locale' => 'en'], - ], - ], [ 'authentication' => [ 'my_basic' => [ @@ -165,7 +166,16 @@ public function testClientPlugins(): void ], ], ], - ]); + ]; + if (class_exists(ThrottlePlugin::class)) { + $config['clients']['acme']['plugins'][] = [ + 'throttle' => [ + 'name' => 'limiter.test', + ], + ]; + } + + $this->load($config); $plugins = [ 'httplug.client.acme.plugin.decoder', @@ -178,13 +188,16 @@ public function testClientPlugins(): void 'httplug.client.acme.plugin.header_defaults', 'httplug.client.acme.plugin.header_set', 'httplug.client.acme.plugin.header_remove', + 'httplug.client.acme.plugin.query_defaults', 'httplug.client.acme.plugin.request_seekable_body', 'httplug.client.acme.plugin.response_seekable_body', - 'httplug.client.acme.plugin.query_defaults', 'httplug.client.acme.authentication.my_basic', 'httplug.client.acme.plugin.cache', 'httplug.client.acme.plugin.error', ]; + if (\class_exists(ThrottlePlugin::class)) { + $plugins[] = 'httplug.client.acme.plugin.throttle'; + } $pluginReferences = array_map(function ($id) { return new Reference($id); }, $plugins); From 87c61d27c025dd9d699a2208a6d06be58061e433 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Sun, 1 Sep 2024 10:25:40 +0200 Subject: [PATCH 09/12] prepare release --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4012550..32976fd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee # Version 1 +# 1.34.3 - 2024-09-01 + +- Same as 1.34.2 but tagged on the 1.x banch instead of the feature branch. + +# 1.34.2 - 2024-09-01 + +- More cleanup of the rate-limiter configuration. The service name is the full service name of the rate limiter, e.g. `limiter.my_name` when configuring `framework.rate_limiter.my_name`. + # 1.34.1 - 2024-09-01 - The rate-limiter name in the throttle plugin configuration is required. From 745ab833c716a9f0871242bdb4a0a0a3c9fd6c71 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Sun, 1 Sep 2024 13:25:50 +0200 Subject: [PATCH 10/12] annotate classes that are not meant to be extended as final --- src/ClientFactory/AutoDiscoveryFactory.php | 2 ++ src/ClientFactory/BuzzFactory.php | 2 ++ src/ClientFactory/CurlFactory.php | 2 ++ src/ClientFactory/Guzzle5Factory.php | 2 ++ src/ClientFactory/Guzzle6Factory.php | 2 ++ src/ClientFactory/Guzzle7Factory.php | 2 ++ src/ClientFactory/ReactFactory.php | 2 ++ src/ClientFactory/SocketFactory.php | 2 ++ src/ClientFactory/SymfonyFactory.php | 2 ++ src/Collector/Collector.php | 1 + src/Collector/Formatter.php | 1 + src/Collector/ProfileClient.php | 1 + src/Collector/ProfileClientFactory.php | 1 + src/Collector/ProfilePlugin.php | 1 + src/Collector/StackPlugin.php | 1 + src/Collector/Twig/HttpMessageMarkupExtension.php | 2 ++ src/DependencyInjection/Configuration.php | 2 ++ src/DependencyInjection/HttplugExtension.php | 2 ++ src/Discovery/ConfiguredClientsStrategy.php | 2 ++ src/Discovery/ConfiguredClientsStrategyListener.php | 2 ++ src/HttplugBundle.php | 2 ++ 21 files changed, 36 insertions(+) diff --git a/src/ClientFactory/AutoDiscoveryFactory.php b/src/ClientFactory/AutoDiscoveryFactory.php index 1c2bf5b9..132a305d 100644 --- a/src/ClientFactory/AutoDiscoveryFactory.php +++ b/src/ClientFactory/AutoDiscoveryFactory.php @@ -10,6 +10,8 @@ * Use auto discovery to find a HTTP client. * * @author Tobias Nyholm + * + * @final */ class AutoDiscoveryFactory implements ClientFactory { diff --git a/src/ClientFactory/BuzzFactory.php b/src/ClientFactory/BuzzFactory.php index 1a0f148d..fc6dd7ed 100644 --- a/src/ClientFactory/BuzzFactory.php +++ b/src/ClientFactory/BuzzFactory.php @@ -11,6 +11,8 @@ /** * @author Tobias Nyholm + * + * @final */ class BuzzFactory implements ClientFactory { diff --git a/src/ClientFactory/CurlFactory.php b/src/ClientFactory/CurlFactory.php index 1d663cb7..6424b737 100644 --- a/src/ClientFactory/CurlFactory.php +++ b/src/ClientFactory/CurlFactory.php @@ -10,6 +10,8 @@ /** * @author Tobias Nyholm + * + * @final */ class CurlFactory implements ClientFactory { diff --git a/src/ClientFactory/Guzzle5Factory.php b/src/ClientFactory/Guzzle5Factory.php index 38eb6d28..995c434a 100644 --- a/src/ClientFactory/Guzzle5Factory.php +++ b/src/ClientFactory/Guzzle5Factory.php @@ -10,6 +10,8 @@ /** * @author Tobias Nyholm + * + * @final */ class Guzzle5Factory implements ClientFactory { diff --git a/src/ClientFactory/Guzzle6Factory.php b/src/ClientFactory/Guzzle6Factory.php index 92d9da46..2a511f6d 100644 --- a/src/ClientFactory/Guzzle6Factory.php +++ b/src/ClientFactory/Guzzle6Factory.php @@ -8,6 +8,8 @@ /** * @author Tobias Nyholm + * + * @final */ class Guzzle6Factory implements ClientFactory { diff --git a/src/ClientFactory/Guzzle7Factory.php b/src/ClientFactory/Guzzle7Factory.php index 6045ab03..25741cbd 100644 --- a/src/ClientFactory/Guzzle7Factory.php +++ b/src/ClientFactory/Guzzle7Factory.php @@ -8,6 +8,8 @@ /** * @author Tobias Nyholm + * + * @final */ class Guzzle7Factory implements ClientFactory { diff --git a/src/ClientFactory/ReactFactory.php b/src/ClientFactory/ReactFactory.php index 489467ca..2fd715e6 100644 --- a/src/ClientFactory/ReactFactory.php +++ b/src/ClientFactory/ReactFactory.php @@ -9,6 +9,8 @@ /** * @author Tobias Nyholm + * + * @final */ class ReactFactory implements ClientFactory { diff --git a/src/ClientFactory/SocketFactory.php b/src/ClientFactory/SocketFactory.php index 7407f6fb..26432355 100644 --- a/src/ClientFactory/SocketFactory.php +++ b/src/ClientFactory/SocketFactory.php @@ -9,6 +9,8 @@ /** * @author Tobias Nyholm + * + * @final */ class SocketFactory implements ClientFactory { diff --git a/src/ClientFactory/SymfonyFactory.php b/src/ClientFactory/SymfonyFactory.php index 31d89fa1..1b52e620 100644 --- a/src/ClientFactory/SymfonyFactory.php +++ b/src/ClientFactory/SymfonyFactory.php @@ -11,6 +11,8 @@ /** * @author Tobias Nyholm + * + * @final */ class SymfonyFactory implements ClientFactory { diff --git a/src/Collector/Collector.php b/src/Collector/Collector.php index 5551d804..215dbdd9 100644 --- a/src/Collector/Collector.php +++ b/src/Collector/Collector.php @@ -18,6 +18,7 @@ * @author Fabien Bourigault * * @internal + * @final */ class Collector extends DataCollector { diff --git a/src/Collector/Formatter.php b/src/Collector/Formatter.php index 29be2d96..a7ce58c8 100644 --- a/src/Collector/Formatter.php +++ b/src/Collector/Formatter.php @@ -20,6 +20,7 @@ * @author Fabien Bourigault * * @internal + * @final */ class Formatter implements MessageFormatter { diff --git a/src/Collector/ProfileClient.php b/src/Collector/ProfileClient.php index ba796a76..8b43f9ff 100644 --- a/src/Collector/ProfileClient.php +++ b/src/Collector/ProfileClient.php @@ -22,6 +22,7 @@ * @author Fabien Bourigault * * @internal + * @final */ class ProfileClient implements HttpClient, HttpAsyncClient { diff --git a/src/Collector/ProfileClientFactory.php b/src/Collector/ProfileClientFactory.php index 23d17fdc..6adf7e83 100644 --- a/src/Collector/ProfileClientFactory.php +++ b/src/Collector/ProfileClientFactory.php @@ -17,6 +17,7 @@ * @author Fabien Bourigault * * @internal + * @final */ class ProfileClientFactory implements ClientFactory { diff --git a/src/Collector/ProfilePlugin.php b/src/Collector/ProfilePlugin.php index 3f362b32..b3cd3100 100644 --- a/src/Collector/ProfilePlugin.php +++ b/src/Collector/ProfilePlugin.php @@ -16,6 +16,7 @@ * @author Fabien Bourigault * * @internal + * @final */ class ProfilePlugin implements Plugin { diff --git a/src/Collector/StackPlugin.php b/src/Collector/StackPlugin.php index a71e2f0b..cdcc9828 100644 --- a/src/Collector/StackPlugin.php +++ b/src/Collector/StackPlugin.php @@ -16,6 +16,7 @@ * @author Fabien Bourigault * * @internal + * @final */ class StackPlugin implements Plugin { diff --git a/src/Collector/Twig/HttpMessageMarkupExtension.php b/src/Collector/Twig/HttpMessageMarkupExtension.php index 562ebece..37cad424 100644 --- a/src/Collector/Twig/HttpMessageMarkupExtension.php +++ b/src/Collector/Twig/HttpMessageMarkupExtension.php @@ -13,6 +13,8 @@ /** * @author Tobias Nyholm + * + * @final */ class HttpMessageMarkupExtension extends AbstractExtension { diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 62276584..859cdd4c 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -31,6 +31,8 @@ * * @author David Buchmann * @author Tobias Nyholm + * + * @final */ class Configuration implements ConfigurationInterface { diff --git a/src/DependencyInjection/HttplugExtension.php b/src/DependencyInjection/HttplugExtension.php index f5d63ceb..6b91193e 100644 --- a/src/DependencyInjection/HttplugExtension.php +++ b/src/DependencyInjection/HttplugExtension.php @@ -42,6 +42,8 @@ /** * @author David Buchmann * @author Tobias Nyholm + * + * @final */ class HttplugExtension extends Extension { diff --git a/src/Discovery/ConfiguredClientsStrategy.php b/src/Discovery/ConfiguredClientsStrategy.php index 1739d7b6..7870ef46 100644 --- a/src/Discovery/ConfiguredClientsStrategy.php +++ b/src/Discovery/ConfiguredClientsStrategy.php @@ -14,6 +14,8 @@ * we can use the web debug toolbar for clients found with the discovery. * * @author Tobias Nyholm + * + * @final */ class ConfiguredClientsStrategy implements DiscoveryStrategy { diff --git a/src/Discovery/ConfiguredClientsStrategyListener.php b/src/Discovery/ConfiguredClientsStrategyListener.php index 82cefcd8..7f0f7fc5 100644 --- a/src/Discovery/ConfiguredClientsStrategyListener.php +++ b/src/Discovery/ConfiguredClientsStrategyListener.php @@ -9,6 +9,8 @@ /** * @author Wouter de Jong + * + * @final */ class ConfiguredClientsStrategyListener implements EventSubscriberInterface { diff --git a/src/HttplugBundle.php b/src/HttplugBundle.php index d6aa836d..c9d09a53 100644 --- a/src/HttplugBundle.php +++ b/src/HttplugBundle.php @@ -9,6 +9,8 @@ /** * @author David Buchmann * @author Tobias Nyholm + * + * @final */ class HttplugBundle extends Bundle { From a5b788556cdf18cf01cf0271bd35bc7857d099f0 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Mon, 2 Sep 2024 08:18:22 +0200 Subject: [PATCH 11/12] always test with throttle plugin as all supported PHP versions are compatible now --- .github/workflows/continuous-integration.yml | 2 +- composer.json | 3 ++- .../HttplugExtensionTest.php | 17 ++++++----------- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 478d2458..cb0e76bc 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -34,7 +34,7 @@ jobs: - dependencies: "php-http/guzzle7-adapter" php-version: "8.2" symfony-deprecations-helper: "weak" - - dependencies: "php-http/guzzle7-adapter php-http/throttle-plugin" + - dependencies: "php-http/guzzle7-adapter" php-version: "8.3" symfony-deprecations-helper: "weak" diff --git a/composer.json b/composer.json index 1907b1c0..7d89d691 100644 --- a/composer.json +++ b/composer.json @@ -42,11 +42,11 @@ "symfony/options-resolver": "^6.4 || ^7.1" }, "conflict": { + "kriswallsmith/buzz": "<0.17", "php-http/guzzle6-adapter": "<1.1", "php-http/cache-plugin": "<1.7", "php-http/curl-client": "<2.0", "php-http/socket-client": "<2.0", - "kriswallsmith/buzz": "<0.17", "php-http/react-adapter": "<3.0", "php-http/throttle-plugin": "<1.1" }, @@ -59,6 +59,7 @@ "php-http/cache-plugin": "^1.7", "php-http/mock-client": "^1.2", "php-http/promise": "^1.0", + "php-http/throttle-plugin": "^1.1", "phpunit/phpunit": "^9", "symfony/browser-kit": "^6.4 || ^7.1", "symfony/cache": "^6.4 || ^7.1", diff --git a/tests/Unit/DependencyInjection/HttplugExtensionTest.php b/tests/Unit/DependencyInjection/HttplugExtensionTest.php index 152ee360..df3fee11 100644 --- a/tests/Unit/DependencyInjection/HttplugExtensionTest.php +++ b/tests/Unit/DependencyInjection/HttplugExtensionTest.php @@ -5,7 +5,6 @@ namespace Http\HttplugBundle\Tests\Unit\DependencyInjection; use Http\Adapter\Guzzle7\Client; -use Http\Client\Common\Plugin\ThrottlePlugin; use Http\Client\Plugin\Vcr\Recorder\InMemoryRecorder; use Http\HttplugBundle\Collector\PluginClientFactoryListener; use Http\HttplugBundle\DependencyInjection\HttplugExtension; @@ -145,6 +144,11 @@ public function testClientPlugins(): void [ 'response_seekable_body' => true, ], + [ + 'throttle' => [ + 'name' => 'limiter.test', + ], + ], [ 'authentication' => [ 'my_basic' => [ @@ -168,13 +172,6 @@ public function testClientPlugins(): void ], ], ]; - if (class_exists(ThrottlePlugin::class)) { - $config['clients']['acme']['plugins'][] = [ - 'throttle' => [ - 'name' => 'limiter.test', - ], - ]; - } $this->load($config); @@ -192,13 +189,11 @@ public function testClientPlugins(): void 'httplug.client.acme.plugin.query_defaults', 'httplug.client.acme.plugin.request_seekable_body', 'httplug.client.acme.plugin.response_seekable_body', + 'httplug.client.acme.plugin.throttle', 'httplug.client.acme.authentication.my_basic', 'httplug.client.acme.plugin.cache', 'httplug.client.acme.plugin.error', ]; - if (\class_exists(ThrottlePlugin::class)) { - $plugins[] = 'httplug.client.acme.plugin.throttle'; - } $pluginReferences = array_map(fn ($id) => new Reference($id), $plugins); $this->assertContainerBuilderHasService('httplug.client.acme'); From 4e6ecf1f48f478373f289108a46eafa7db4ecc31 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Mon, 2 Sep 2024 08:24:08 +0200 Subject: [PATCH 12/12] use latest checkout also for phpstan --- .github/workflows/coding-standards.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 564da8b4..76f6f698 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -15,7 +15,7 @@ jobs: steps: - name: "Checkout" - uses: "actions/checkout@v3" + uses: "actions/checkout@v4" - name: PHPStan uses: "docker://oskarstark/phpstan-ga" env: