diff --git a/CHANGELOG.md b/CHANGELOG.md index 521a4900..6240893c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee # Version 2 # 2.0.0 - (unreleased) + - Increased min PHP version to 8.1 - Removed the deprecated `Http\HttplugBundle\ClientFactory\PluginClientFactory`. Use `Http\Client\Common\PluginClientFactory` instead. - Fixed a deprecation when creating a `HttpMethodsClient` via `http_methods_client: true`. Only PSR-17 factories are now passed as constructor arguments. @@ -18,6 +19,7 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee - Changed the type of `httplug.client.default` to `ClientInterface` instead of `HttpClient` - Removed the `DummyClient` interface - Removed the `Http\Client\HttpClient` alias use the `Psr\Http\Client\ClientInterface` typehint in your services for autowiring. +- Changed classes marked as `@final` to be actually `final`. If you extended any of those, instead implement interfaces or decorate the class rather than extending it. Open an issue if you think a class needs to be made non-final to discuss what we should do. # Version 1 diff --git a/src/ClientFactory/AutoDiscoveryFactory.php b/src/ClientFactory/AutoDiscoveryFactory.php index 9578c2dc..8a675696 100644 --- a/src/ClientFactory/AutoDiscoveryFactory.php +++ b/src/ClientFactory/AutoDiscoveryFactory.php @@ -10,10 +10,8 @@ * Use auto discovery to find a HTTP client. * * @author Tobias Nyholm - * - * @final */ -class AutoDiscoveryFactory implements ClientFactory +final class AutoDiscoveryFactory implements ClientFactory { public function createClient(array $config = []) { diff --git a/src/ClientFactory/BuzzFactory.php b/src/ClientFactory/BuzzFactory.php index 0e219c4f..02eadff1 100644 --- a/src/ClientFactory/BuzzFactory.php +++ b/src/ClientFactory/BuzzFactory.php @@ -10,10 +10,8 @@ /** * @author Tobias Nyholm - * - * @final */ -class BuzzFactory implements ClientFactory +final class BuzzFactory implements ClientFactory { public function __construct(private readonly ResponseFactoryInterface $responseFactory) { diff --git a/src/ClientFactory/CurlFactory.php b/src/ClientFactory/CurlFactory.php index db3d667e..054a5c36 100644 --- a/src/ClientFactory/CurlFactory.php +++ b/src/ClientFactory/CurlFactory.php @@ -10,10 +10,8 @@ /** * @author Tobias Nyholm - * - * @final */ -class CurlFactory implements ClientFactory +final class CurlFactory implements ClientFactory { public function __construct( private readonly ResponseFactoryInterface $responseFactory, diff --git a/src/ClientFactory/Guzzle6Factory.php b/src/ClientFactory/Guzzle6Factory.php index 17ca3233..a1930ed5 100644 --- a/src/ClientFactory/Guzzle6Factory.php +++ b/src/ClientFactory/Guzzle6Factory.php @@ -8,10 +8,8 @@ /** * @author Tobias Nyholm - * - * @final */ -class Guzzle6Factory implements ClientFactory +final class Guzzle6Factory implements ClientFactory { public function createClient(array $config = []) { diff --git a/src/ClientFactory/Guzzle7Factory.php b/src/ClientFactory/Guzzle7Factory.php index 90143ab1..8a5cbbe0 100644 --- a/src/ClientFactory/Guzzle7Factory.php +++ b/src/ClientFactory/Guzzle7Factory.php @@ -8,10 +8,8 @@ /** * @author Tobias Nyholm - * - * @final */ -class Guzzle7Factory implements ClientFactory +final class Guzzle7Factory implements ClientFactory { public function createClient(array $config = []) { diff --git a/src/ClientFactory/ReactFactory.php b/src/ClientFactory/ReactFactory.php index b1c66581..f98c9ae5 100644 --- a/src/ClientFactory/ReactFactory.php +++ b/src/ClientFactory/ReactFactory.php @@ -8,10 +8,8 @@ /** * @author Tobias Nyholm - * - * @final */ -class ReactFactory implements ClientFactory +final class ReactFactory implements ClientFactory { public function createClient(array $config = []) { diff --git a/src/ClientFactory/SocketFactory.php b/src/ClientFactory/SocketFactory.php index 2424df3b..b70f8eaa 100644 --- a/src/ClientFactory/SocketFactory.php +++ b/src/ClientFactory/SocketFactory.php @@ -8,10 +8,8 @@ /** * @author Tobias Nyholm - * - * @final */ -class SocketFactory implements ClientFactory +final class SocketFactory implements ClientFactory { public function createClient(array $config = []) { diff --git a/src/ClientFactory/SymfonyFactory.php b/src/ClientFactory/SymfonyFactory.php index 46485bf0..c52568c6 100644 --- a/src/ClientFactory/SymfonyFactory.php +++ b/src/ClientFactory/SymfonyFactory.php @@ -11,10 +11,8 @@ /** * @author Tobias Nyholm - * - * @final */ -class SymfonyFactory implements ClientFactory +final class SymfonyFactory implements ClientFactory { public function __construct( private readonly ResponseFactoryInterface $responseFactory, diff --git a/src/Collector/Collector.php b/src/Collector/Collector.php index f53a0e2a..50a4aa8c 100644 --- a/src/Collector/Collector.php +++ b/src/Collector/Collector.php @@ -18,10 +18,8 @@ * @author Fabien Bourigault * * @internal - * - * @final */ -class Collector extends DataCollector +final class Collector extends DataCollector { private ?Stack $activeStack = null; diff --git a/src/Collector/Formatter.php b/src/Collector/Formatter.php index 701d9243..f2032f24 100644 --- a/src/Collector/Formatter.php +++ b/src/Collector/Formatter.php @@ -4,7 +4,6 @@ namespace Http\HttplugBundle\Collector; -use Exception; use Http\Client\Exception\HttpException; use Http\Client\Exception\TransferException; use Http\Message\Formatter as MessageFormatter; @@ -19,10 +18,8 @@ * @author Fabien Bourigault * * @internal - * - * @final */ -class Formatter implements MessageFormatter +final class Formatter implements MessageFormatter { public function __construct( private readonly MessageFormatter $formatter, diff --git a/src/Collector/ProfileClient.php b/src/Collector/ProfileClient.php index 5c350885..8ea52812 100644 --- a/src/Collector/ProfileClient.php +++ b/src/Collector/ProfileClient.php @@ -21,10 +21,8 @@ * @author Fabien Bourigault * * @internal - * - * @final */ -class ProfileClient implements ClientInterface, HttpAsyncClient +final class ProfileClient implements ClientInterface, HttpAsyncClient { use VersionBridgeClient; diff --git a/src/Collector/ProfileClientFactory.php b/src/Collector/ProfileClientFactory.php index 4140a313..3715fd4d 100644 --- a/src/Collector/ProfileClientFactory.php +++ b/src/Collector/ProfileClientFactory.php @@ -16,10 +16,8 @@ * @author Fabien Bourigault * * @internal - * - * @final */ -class ProfileClientFactory implements ClientFactory +final class ProfileClientFactory implements ClientFactory { /** * @var ClientFactory|callable diff --git a/src/Collector/ProfilePlugin.php b/src/Collector/ProfilePlugin.php index 54f7fd4e..d6ed4a60 100644 --- a/src/Collector/ProfilePlugin.php +++ b/src/Collector/ProfilePlugin.php @@ -15,10 +15,8 @@ * @author Fabien Bourigault * * @internal - * - * @final */ -class ProfilePlugin implements Plugin +final class ProfilePlugin implements Plugin { use Plugin\VersionBridgePlugin; diff --git a/src/Collector/StackPlugin.php b/src/Collector/StackPlugin.php index c4353b36..634aa299 100644 --- a/src/Collector/StackPlugin.php +++ b/src/Collector/StackPlugin.php @@ -15,10 +15,8 @@ * @author Fabien Bourigault * * @internal - * - * @final */ -class StackPlugin implements Plugin +final class StackPlugin implements Plugin { use Plugin\VersionBridgePlugin; diff --git a/src/Collector/Twig/HttpMessageMarkupExtension.php b/src/Collector/Twig/HttpMessageMarkupExtension.php index a373abc3..5876ba74 100644 --- a/src/Collector/Twig/HttpMessageMarkupExtension.php +++ b/src/Collector/Twig/HttpMessageMarkupExtension.php @@ -13,10 +13,8 @@ /** * @author Tobias Nyholm - * - * @final */ -class HttpMessageMarkupExtension extends AbstractExtension +final class HttpMessageMarkupExtension extends AbstractExtension { private ClonerInterface $cloner; diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index b6086ee2..133bee8b 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -31,10 +31,8 @@ * * @author David Buchmann * @author Tobias Nyholm - * - * @final */ -class Configuration implements ConfigurationInterface +final class Configuration implements ConfigurationInterface { /** * Whether to use the debug mode. diff --git a/src/DependencyInjection/HttplugExtension.php b/src/DependencyInjection/HttplugExtension.php index 13dd6f6d..ac032e76 100644 --- a/src/DependencyInjection/HttplugExtension.php +++ b/src/DependencyInjection/HttplugExtension.php @@ -40,10 +40,8 @@ /** * @author David Buchmann * @author Tobias Nyholm - * - * @final */ -class HttplugExtension extends Extension +final class HttplugExtension extends Extension { public const HTTPLUG_CLIENT_TAG = 'httplug.client'; diff --git a/src/Discovery/ConfiguredClientsStrategy.php b/src/Discovery/ConfiguredClientsStrategy.php index 99166abd..50c21b16 100644 --- a/src/Discovery/ConfiguredClientsStrategy.php +++ b/src/Discovery/ConfiguredClientsStrategy.php @@ -14,10 +14,8 @@ * we can use the web debug toolbar for clients found with the discovery. * * @author Tobias Nyholm - * - * @final */ -class ConfiguredClientsStrategy implements DiscoveryStrategy +final class ConfiguredClientsStrategy implements DiscoveryStrategy { private static ?ClientInterface $client = null; diff --git a/src/Discovery/ConfiguredClientsStrategyListener.php b/src/Discovery/ConfiguredClientsStrategyListener.php index 85d9d02b..d57cfc35 100644 --- a/src/Discovery/ConfiguredClientsStrategyListener.php +++ b/src/Discovery/ConfiguredClientsStrategyListener.php @@ -9,10 +9,8 @@ /** * @author Wouter de Jong - * - * @final */ -class ConfiguredClientsStrategyListener implements EventSubscriberInterface +final class ConfiguredClientsStrategyListener implements EventSubscriberInterface { /** * Make sure to use the custom strategy. diff --git a/src/HttplugBundle.php b/src/HttplugBundle.php index c9d09a53..ddb71bfa 100644 --- a/src/HttplugBundle.php +++ b/src/HttplugBundle.php @@ -9,9 +9,7 @@ /** * @author David Buchmann * @author Tobias Nyholm - * - * @final */ -class HttplugBundle extends Bundle +final class HttplugBundle extends Bundle { } diff --git a/tests/Functional/DiscoveredClientsTest.php b/tests/Functional/DiscoveredClientsTest.php index 518029b8..d93ca3f3 100644 --- a/tests/Functional/DiscoveredClientsTest.php +++ b/tests/Functional/DiscoveredClientsTest.php @@ -16,7 +16,7 @@ use Psr\Http\Client\ClientInterface; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -class DiscoveredClientsTest extends WebTestCase +final class DiscoveredClientsTest extends WebTestCase { public function testDiscoveredClient(): void { diff --git a/tests/Functional/Issue206.php b/tests/Functional/Issue206.php index 4539cdbd..852d68af 100644 --- a/tests/Functional/Issue206.php +++ b/tests/Functional/Issue206.php @@ -11,7 +11,7 @@ use Nyholm\Psr7\Factory\Psr17Factory; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -class Issue206 extends WebTestCase +final class Issue206 extends WebTestCase { public function testCustomClientDoesNotCauseException(): void { diff --git a/tests/Functional/ProfilerTest.php b/tests/Functional/ProfilerTest.php index 5239fa2d..3654f4a3 100644 --- a/tests/Functional/ProfilerTest.php +++ b/tests/Functional/ProfilerTest.php @@ -8,7 +8,7 @@ use Psr\Http\Client\ClientInterface; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -class ProfilerTest extends WebTestCase +final class ProfilerTest extends WebTestCase { /** * @group legacy diff --git a/tests/Functional/ProfilingTest.php b/tests/Functional/ProfilingTest.php index 3a227b5a..f9aed161 100644 --- a/tests/Functional/ProfilingTest.php +++ b/tests/Functional/ProfilingTest.php @@ -22,7 +22,7 @@ use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Stopwatch\Stopwatch; -class ProfilingTest extends TestCase +final class ProfilingTest extends TestCase { private Collector $collector; diff --git a/tests/Functional/ServiceInstantiationTest.php b/tests/Functional/ServiceInstantiationTest.php index 243fcc7d..16bc2e2e 100644 --- a/tests/Functional/ServiceInstantiationTest.php +++ b/tests/Functional/ServiceInstantiationTest.php @@ -24,7 +24,7 @@ use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\HttpKernel\Profiler\Profiler; -class ServiceInstantiationTest extends WebTestCase +final class ServiceInstantiationTest extends WebTestCase { public function testHttpClient(): void { diff --git a/tests/Unit/ClientFactory/BuzzFactoryTest.php b/tests/Unit/ClientFactory/BuzzFactoryTest.php index f5b54489..8b877628 100644 --- a/tests/Unit/ClientFactory/BuzzFactoryTest.php +++ b/tests/Unit/ClientFactory/BuzzFactoryTest.php @@ -12,7 +12,7 @@ /** * @author Tobias Nyholm */ -class BuzzFactoryTest extends TestCase +final class BuzzFactoryTest extends TestCase { public function testCreateClient(): void { diff --git a/tests/Unit/ClientFactory/CurlFactoryTest.php b/tests/Unit/ClientFactory/CurlFactoryTest.php index 02913ea3..8660e182 100644 --- a/tests/Unit/ClientFactory/CurlFactoryTest.php +++ b/tests/Unit/ClientFactory/CurlFactoryTest.php @@ -13,7 +13,7 @@ /** * @author Tobias Nyholm */ -class CurlFactoryTest extends TestCase +final class CurlFactoryTest extends TestCase { public function testCreateClient(): void { diff --git a/tests/Unit/ClientFactory/Guzzle6FactoryTest.php b/tests/Unit/ClientFactory/Guzzle6FactoryTest.php index 51307ac3..5d60ba4e 100644 --- a/tests/Unit/ClientFactory/Guzzle6FactoryTest.php +++ b/tests/Unit/ClientFactory/Guzzle6FactoryTest.php @@ -11,7 +11,7 @@ /** * @author Tobias Nyholm */ -class Guzzle6FactoryTest extends TestCase +final class Guzzle6FactoryTest extends TestCase { public function testCreateClient(): void { diff --git a/tests/Unit/ClientFactory/Guzzle7FactoryTest.php b/tests/Unit/ClientFactory/Guzzle7FactoryTest.php index 886ba9a6..dabf1869 100644 --- a/tests/Unit/ClientFactory/Guzzle7FactoryTest.php +++ b/tests/Unit/ClientFactory/Guzzle7FactoryTest.php @@ -11,7 +11,7 @@ /** * @author Tobias Nyholm */ -class Guzzle7FactoryTest extends TestCase +final class Guzzle7FactoryTest extends TestCase { public function testCreateClient(): void { diff --git a/tests/Unit/ClientFactory/MockFactoryTest.php b/tests/Unit/ClientFactory/MockFactoryTest.php index 1c8d243e..8c1f57fa 100644 --- a/tests/Unit/ClientFactory/MockFactoryTest.php +++ b/tests/Unit/ClientFactory/MockFactoryTest.php @@ -17,7 +17,7 @@ /** * @author Gary PEGEOT */ -class MockFactoryTest extends TestCase +final class MockFactoryTest extends TestCase { public function testCreateClient(): void { diff --git a/tests/Unit/ClientFactory/ReactFactoryTest.php b/tests/Unit/ClientFactory/ReactFactoryTest.php index eb09e049..7ce1bda1 100644 --- a/tests/Unit/ClientFactory/ReactFactoryTest.php +++ b/tests/Unit/ClientFactory/ReactFactoryTest.php @@ -11,7 +11,7 @@ /** * @author Tobias Nyholm */ -class ReactFactoryTest extends TestCase +final class ReactFactoryTest extends TestCase { public function testCreateClient(): void { diff --git a/tests/Unit/ClientFactory/SocketFactoryTest.php b/tests/Unit/ClientFactory/SocketFactoryTest.php index 8ea380d5..6b2ce9c5 100644 --- a/tests/Unit/ClientFactory/SocketFactoryTest.php +++ b/tests/Unit/ClientFactory/SocketFactoryTest.php @@ -11,7 +11,7 @@ /** * @author Tobias Nyholm */ -class SocketFactoryTest extends TestCase +final class SocketFactoryTest extends TestCase { public function testCreateClient(): void { diff --git a/tests/Unit/ClientFactory/SymfonyFactoryTest.php b/tests/Unit/ClientFactory/SymfonyFactoryTest.php index fe54c6be..ef73d258 100644 --- a/tests/Unit/ClientFactory/SymfonyFactoryTest.php +++ b/tests/Unit/ClientFactory/SymfonyFactoryTest.php @@ -13,7 +13,7 @@ /** * @author Tobias Nyholm */ -class SymfonyFactoryTest extends TestCase +final class SymfonyFactoryTest extends TestCase { public function testCreateClient(): void { diff --git a/tests/Unit/Collector/CollectorTest.php b/tests/Unit/Collector/CollectorTest.php index a4e0dd65..824860a0 100644 --- a/tests/Unit/Collector/CollectorTest.php +++ b/tests/Unit/Collector/CollectorTest.php @@ -8,7 +8,7 @@ use Http\HttplugBundle\Collector\Stack; use PHPUnit\Framework\TestCase; -class CollectorTest extends TestCase +final class CollectorTest extends TestCase { public function testCollectClientNames(): void { diff --git a/tests/Unit/Collector/FormatterTest.php b/tests/Unit/Collector/FormatterTest.php index 0f66b9e6..09bdb06d 100644 --- a/tests/Unit/Collector/FormatterTest.php +++ b/tests/Unit/Collector/FormatterTest.php @@ -15,7 +15,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class FormatterTest extends TestCase +final class FormatterTest extends TestCase { private MessageFormatter&MockObject $formatter; diff --git a/tests/Unit/Collector/ProfileClientFactoryTest.php b/tests/Unit/Collector/ProfileClientFactoryTest.php index 46b1517c..5b1c0187 100644 --- a/tests/Unit/Collector/ProfileClientFactoryTest.php +++ b/tests/Unit/Collector/ProfileClientFactoryTest.php @@ -15,7 +15,7 @@ use Psr\Http\Client\ClientInterface; use Symfony\Component\Stopwatch\Stopwatch; -class ProfileClientFactoryTest extends TestCase +final class ProfileClientFactoryTest extends TestCase { private Collector $collector; diff --git a/tests/Unit/Collector/ProfileClientTest.php b/tests/Unit/Collector/ProfileClientTest.php index bf7e4ac1..2188fac0 100644 --- a/tests/Unit/Collector/ProfileClientTest.php +++ b/tests/Unit/Collector/ProfileClientTest.php @@ -25,7 +25,7 @@ use Symfony\Component\Stopwatch\Stopwatch; use Symfony\Component\Stopwatch\StopwatchEvent; -class ProfileClientTest extends TestCase +final class ProfileClientTest extends TestCase { private Collector $collector; diff --git a/tests/Unit/Collector/ProfilePluginTest.php b/tests/Unit/Collector/ProfilePluginTest.php index ac6dfdc6..e5dd268a 100644 --- a/tests/Unit/Collector/ProfilePluginTest.php +++ b/tests/Unit/Collector/ProfilePluginTest.php @@ -17,13 +17,14 @@ use Http\Promise\FulfilledPromise; use Http\Promise\Promise; use Http\Promise\RejectedPromise; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; -class ProfilePluginTest extends TestCase +final class ProfilePluginTest extends TestCase { - private Plugin $plugin; + private Plugin&MockObject $plugin; private RequestInterface $request; @@ -74,7 +75,7 @@ public function setUp(): void $this->subject = new ProfilePlugin( $this->plugin, $this->collector, - $formatter + $formatter, ); } diff --git a/tests/Unit/Collector/StackPluginTest.php b/tests/Unit/Collector/StackPluginTest.php index 92f2817e..2ed0ea92 100644 --- a/tests/Unit/Collector/StackPluginTest.php +++ b/tests/Unit/Collector/StackPluginTest.php @@ -14,37 +14,21 @@ use Http\Message\Formatter\SimpleFormatter; use Http\Promise\FulfilledPromise; use Http\Promise\RejectedPromise; -use PHPUnit\Framework\Error\Warning; use PHPUnit\Framework\TestCase; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; -class StackPluginTest extends TestCase +final class StackPluginTest extends TestCase { - /** - * @var Collector - */ - private $collector; - - /** - * @var RequestInterface - */ - private $request; - - /** - * @var ResponseInterface - */ - private $response; - - /** - * @var \Exception - */ - private $exception; - - /** - * @var StackPlugin - */ - private $subject; + private Collector $collector; + + private RequestInterface $request; + + private ResponseInterface $response; + + private \Exception $exception; + + private StackPlugin $subject; public function setUp(): void { @@ -128,11 +112,7 @@ public function testOnException(): void public function testOnError(): void { - if (version_compare(PHP_VERSION, '8.0.0', '>=')) { - $this->expectException(\DivisionByZeroError::class); - } else { - $this->expectException(Warning::class); - } + $this->expectException(\DivisionByZeroError::class); $next = fn () => 2 / 0; diff --git a/tests/Unit/DependencyInjection/ConfigurationTest.php b/tests/Unit/DependencyInjection/ConfigurationTest.php index 08ee1f50..a375ed1f 100644 --- a/tests/Unit/DependencyInjection/ConfigurationTest.php +++ b/tests/Unit/DependencyInjection/ConfigurationTest.php @@ -16,7 +16,7 @@ /** * @author David Buchmann */ -class ConfigurationTest extends AbstractExtensionConfigurationTestCase +final class ConfigurationTest extends AbstractExtensionConfigurationTestCase { private array $emptyConfig = [ 'default_client_autowiring' => true, diff --git a/tests/Unit/DependencyInjection/HttplugExtensionTest.php b/tests/Unit/DependencyInjection/HttplugExtensionTest.php index df3fee11..539dc879 100644 --- a/tests/Unit/DependencyInjection/HttplugExtensionTest.php +++ b/tests/Unit/DependencyInjection/HttplugExtensionTest.php @@ -16,7 +16,7 @@ * @author David Buchmann * @author Tobias Nyholm */ -class HttplugExtensionTest extends AbstractExtensionTestCase +final class HttplugExtensionTest extends AbstractExtensionTestCase { protected function setUp(): void { diff --git a/tests/Unit/Discovery/ConfiguredClientsStrategyTest.php b/tests/Unit/Discovery/ConfiguredClientsStrategyTest.php index b9abe22d..dc1a650f 100644 --- a/tests/Unit/Discovery/ConfiguredClientsStrategyTest.php +++ b/tests/Unit/Discovery/ConfiguredClientsStrategyTest.php @@ -9,7 +9,7 @@ use PHPUnit\Framework\TestCase; use Psr\Http\Client\ClientInterface; -class ConfiguredClientsStrategyTest extends TestCase +final class ConfiguredClientsStrategyTest extends TestCase { public function testGetCandidates(): void {