Skip to content

Commit ffeb988

Browse files
authored
make classes final for 2.0 (#321)
1 parent 4d1ca68 commit ffeb988

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+57
-115
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee
55
# Version 2
66

77
# 2.0.0 - (unreleased)
8+
89
- Increased min PHP version to 8.1
910
- Removed the deprecated `Http\HttplugBundle\ClientFactory\PluginClientFactory`. Use `Http\Client\Common\PluginClientFactory` instead.
1011
- 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
1819
- Changed the type of `httplug.client.default` to `ClientInterface` instead of `HttpClient`
1920
- Removed the `DummyClient` interface
2021
- Removed the `Http\Client\HttpClient` alias use the `Psr\Http\Client\ClientInterface` typehint in your services for autowiring.
22+
- 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.
2123

2224
# Version 1
2325

src/ClientFactory/AutoDiscoveryFactory.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010
* Use auto discovery to find a HTTP client.
1111
*
1212
* @author Tobias Nyholm <[email protected]>
13-
*
14-
* @final
1513
*/
16-
class AutoDiscoveryFactory implements ClientFactory
14+
final class AutoDiscoveryFactory implements ClientFactory
1715
{
1816
public function createClient(array $config = [])
1917
{

src/ClientFactory/BuzzFactory.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010

1111
/**
1212
* @author Tobias Nyholm <[email protected]>
13-
*
14-
* @final
1513
*/
16-
class BuzzFactory implements ClientFactory
14+
final class BuzzFactory implements ClientFactory
1715
{
1816
public function __construct(private readonly ResponseFactoryInterface $responseFactory)
1917
{

src/ClientFactory/CurlFactory.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010

1111
/**
1212
* @author Tobias Nyholm <[email protected]>
13-
*
14-
* @final
1513
*/
16-
class CurlFactory implements ClientFactory
14+
final class CurlFactory implements ClientFactory
1715
{
1816
public function __construct(
1917
private readonly ResponseFactoryInterface $responseFactory,

src/ClientFactory/Guzzle6Factory.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88

99
/**
1010
* @author Tobias Nyholm <[email protected]>
11-
*
12-
* @final
1311
*/
14-
class Guzzle6Factory implements ClientFactory
12+
final class Guzzle6Factory implements ClientFactory
1513
{
1614
public function createClient(array $config = [])
1715
{

src/ClientFactory/Guzzle7Factory.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88

99
/**
1010
* @author Tobias Nyholm <[email protected]>
11-
*
12-
* @final
1311
*/
14-
class Guzzle7Factory implements ClientFactory
12+
final class Guzzle7Factory implements ClientFactory
1513
{
1614
public function createClient(array $config = [])
1715
{

src/ClientFactory/ReactFactory.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88

99
/**
1010
* @author Tobias Nyholm <[email protected]>
11-
*
12-
* @final
1311
*/
14-
class ReactFactory implements ClientFactory
12+
final class ReactFactory implements ClientFactory
1513
{
1614
public function createClient(array $config = [])
1715
{

src/ClientFactory/SocketFactory.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88

99
/**
1010
* @author Tobias Nyholm <[email protected]>
11-
*
12-
* @final
1311
*/
14-
class SocketFactory implements ClientFactory
12+
final class SocketFactory implements ClientFactory
1513
{
1614
public function createClient(array $config = [])
1715
{

src/ClientFactory/SymfonyFactory.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111

1212
/**
1313
* @author Tobias Nyholm <[email protected]>
14-
*
15-
* @final
1614
*/
17-
class SymfonyFactory implements ClientFactory
15+
final class SymfonyFactory implements ClientFactory
1816
{
1917
public function __construct(
2018
private readonly ResponseFactoryInterface $responseFactory,

src/Collector/Collector.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@
1818
* @author Fabien Bourigault <[email protected]>
1919
*
2020
* @internal
21-
*
22-
* @final
2321
*/
24-
class Collector extends DataCollector
22+
final class Collector extends DataCollector
2523
{
2624
private ?Stack $activeStack = null;
2725

src/Collector/Formatter.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Http\HttplugBundle\Collector;
66

7-
use Exception;
87
use Http\Client\Exception\HttpException;
98
use Http\Client\Exception\TransferException;
109
use Http\Message\Formatter as MessageFormatter;
@@ -19,10 +18,8 @@
1918
* @author Fabien Bourigault <[email protected]>
2019
*
2120
* @internal
22-
*
23-
* @final
2421
*/
25-
class Formatter implements MessageFormatter
22+
final class Formatter implements MessageFormatter
2623
{
2724
public function __construct(
2825
private readonly MessageFormatter $formatter,

src/Collector/ProfileClient.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@
2121
* @author Fabien Bourigault <[email protected]>
2222
*
2323
* @internal
24-
*
25-
* @final
2624
*/
27-
class ProfileClient implements ClientInterface, HttpAsyncClient
25+
final class ProfileClient implements ClientInterface, HttpAsyncClient
2826
{
2927
use VersionBridgeClient;
3028

src/Collector/ProfileClientFactory.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
* @author Fabien Bourigault <[email protected]>
1717
*
1818
* @internal
19-
*
20-
* @final
2119
*/
22-
class ProfileClientFactory implements ClientFactory
20+
final class ProfileClientFactory implements ClientFactory
2321
{
2422
/**
2523
* @var ClientFactory|callable

src/Collector/ProfilePlugin.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@
1515
* @author Fabien Bourigault <[email protected]>
1616
*
1717
* @internal
18-
*
19-
* @final
2018
*/
21-
class ProfilePlugin implements Plugin
19+
final class ProfilePlugin implements Plugin
2220
{
2321
use Plugin\VersionBridgePlugin;
2422

src/Collector/StackPlugin.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@
1515
* @author Fabien Bourigault <[email protected]>
1616
*
1717
* @internal
18-
*
19-
* @final
2018
*/
21-
class StackPlugin implements Plugin
19+
final class StackPlugin implements Plugin
2220
{
2321
use Plugin\VersionBridgePlugin;
2422

src/Collector/Twig/HttpMessageMarkupExtension.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@
1313

1414
/**
1515
* @author Tobias Nyholm <[email protected]>
16-
*
17-
* @final
1816
*/
19-
class HttpMessageMarkupExtension extends AbstractExtension
17+
final class HttpMessageMarkupExtension extends AbstractExtension
2018
{
2119
private ClonerInterface $cloner;
2220

src/DependencyInjection/Configuration.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@
3131
*
3232
* @author David Buchmann <[email protected]>
3333
* @author Tobias Nyholm <[email protected]>
34-
*
35-
* @final
3634
*/
37-
class Configuration implements ConfigurationInterface
35+
final class Configuration implements ConfigurationInterface
3836
{
3937
/**
4038
* Whether to use the debug mode.

src/DependencyInjection/HttplugExtension.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@
4040
/**
4141
* @author David Buchmann <[email protected]>
4242
* @author Tobias Nyholm <[email protected]>
43-
*
44-
* @final
4543
*/
46-
class HttplugExtension extends Extension
44+
final class HttplugExtension extends Extension
4745
{
4846
public const HTTPLUG_CLIENT_TAG = 'httplug.client';
4947

src/Discovery/ConfiguredClientsStrategy.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414
* we can use the web debug toolbar for clients found with the discovery.
1515
*
1616
* @author Tobias Nyholm <[email protected]>
17-
*
18-
* @final
1917
*/
20-
class ConfiguredClientsStrategy implements DiscoveryStrategy
18+
final class ConfiguredClientsStrategy implements DiscoveryStrategy
2119
{
2220
private static ?ClientInterface $client = null;
2321

src/Discovery/ConfiguredClientsStrategyListener.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@
99

1010
/**
1111
* @author Wouter de Jong <[email protected]>
12-
*
13-
* @final
1412
*/
15-
class ConfiguredClientsStrategyListener implements EventSubscriberInterface
13+
final class ConfiguredClientsStrategyListener implements EventSubscriberInterface
1614
{
1715
/**
1816
* Make sure to use the custom strategy.

src/HttplugBundle.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
/**
1010
* @author David Buchmann <[email protected]>
1111
* @author Tobias Nyholm <[email protected]>
12-
*
13-
* @final
1412
*/
15-
class HttplugBundle extends Bundle
13+
final class HttplugBundle extends Bundle
1614
{
1715
}

tests/Functional/DiscoveredClientsTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Psr\Http\Client\ClientInterface;
1717
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
1818

19-
class DiscoveredClientsTest extends WebTestCase
19+
final class DiscoveredClientsTest extends WebTestCase
2020
{
2121
public function testDiscoveredClient(): void
2222
{

tests/Functional/Issue206.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Nyholm\Psr7\Factory\Psr17Factory;
1212
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
1313

14-
class Issue206 extends WebTestCase
14+
final class Issue206 extends WebTestCase
1515
{
1616
public function testCustomClientDoesNotCauseException(): void
1717
{

tests/Functional/ProfilerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Psr\Http\Client\ClientInterface;
99
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
1010

11-
class ProfilerTest extends WebTestCase
11+
final class ProfilerTest extends WebTestCase
1212
{
1313
/**
1414
* @group legacy

tests/Functional/ProfilingTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
use Symfony\Component\Cache\Adapter\ArrayAdapter;
2323
use Symfony\Component\Stopwatch\Stopwatch;
2424

25-
class ProfilingTest extends TestCase
25+
final class ProfilingTest extends TestCase
2626
{
2727
private Collector $collector;
2828

tests/Functional/ServiceInstantiationTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
use Symfony\Component\HttpKernel\KernelInterface;
2525
use Symfony\Component\HttpKernel\Profiler\Profiler;
2626

27-
class ServiceInstantiationTest extends WebTestCase
27+
final class ServiceInstantiationTest extends WebTestCase
2828
{
2929
public function testHttpClient(): void
3030
{

tests/Unit/ClientFactory/BuzzFactoryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/**
1313
* @author Tobias Nyholm <[email protected]>
1414
*/
15-
class BuzzFactoryTest extends TestCase
15+
final class BuzzFactoryTest extends TestCase
1616
{
1717
public function testCreateClient(): void
1818
{

tests/Unit/ClientFactory/CurlFactoryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/**
1414
* @author Tobias Nyholm <[email protected]>
1515
*/
16-
class CurlFactoryTest extends TestCase
16+
final class CurlFactoryTest extends TestCase
1717
{
1818
public function testCreateClient(): void
1919
{

tests/Unit/ClientFactory/Guzzle6FactoryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* @author Tobias Nyholm <[email protected]>
1313
*/
14-
class Guzzle6FactoryTest extends TestCase
14+
final class Guzzle6FactoryTest extends TestCase
1515
{
1616
public function testCreateClient(): void
1717
{

tests/Unit/ClientFactory/Guzzle7FactoryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* @author Tobias Nyholm <[email protected]>
1313
*/
14-
class Guzzle7FactoryTest extends TestCase
14+
final class Guzzle7FactoryTest extends TestCase
1515
{
1616
public function testCreateClient(): void
1717
{

tests/Unit/ClientFactory/MockFactoryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/**
1818
* @author Gary PEGEOT <[email protected]>
1919
*/
20-
class MockFactoryTest extends TestCase
20+
final class MockFactoryTest extends TestCase
2121
{
2222
public function testCreateClient(): void
2323
{

tests/Unit/ClientFactory/ReactFactoryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* @author Tobias Nyholm <[email protected]>
1313
*/
14-
class ReactFactoryTest extends TestCase
14+
final class ReactFactoryTest extends TestCase
1515
{
1616
public function testCreateClient(): void
1717
{

tests/Unit/ClientFactory/SocketFactoryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* @author Tobias Nyholm <[email protected]>
1313
*/
14-
class SocketFactoryTest extends TestCase
14+
final class SocketFactoryTest extends TestCase
1515
{
1616
public function testCreateClient(): void
1717
{

tests/Unit/ClientFactory/SymfonyFactoryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/**
1414
* @author Tobias Nyholm <[email protected]>
1515
*/
16-
class SymfonyFactoryTest extends TestCase
16+
final class SymfonyFactoryTest extends TestCase
1717
{
1818
public function testCreateClient(): void
1919
{

tests/Unit/Collector/CollectorTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Http\HttplugBundle\Collector\Stack;
99
use PHPUnit\Framework\TestCase;
1010

11-
class CollectorTest extends TestCase
11+
final class CollectorTest extends TestCase
1212
{
1313
public function testCollectClientNames(): void
1414
{

tests/Unit/Collector/FormatterTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use PHPUnit\Framework\MockObject\MockObject;
1616
use PHPUnit\Framework\TestCase;
1717

18-
class FormatterTest extends TestCase
18+
final class FormatterTest extends TestCase
1919
{
2020
private MessageFormatter&MockObject $formatter;
2121

0 commit comments

Comments
 (0)