Skip to content

Commit 28f3beb

Browse files
committed
📦 [#458] Switch to php-cs-fixer 3.26 and run it
1 parent d958ead commit 28f3beb

35 files changed

+73
-149
lines changed

.github/workflows/php-cs-fixer.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ jobs:
1717
- name: "Checkout"
1818
uses: "actions/checkout@v3"
1919
- name: "PHP-CS-Fixer"
20-
uses: "docker://oskarstark/php-cs-fixer-ga:2.19.0"
20+
uses: "docker://oskarstark/php-cs-fixer-ga:3.26.0"
2121
with:
2222
args: --diff --dry-run

.php_cs.dist renamed to .php-cs-fixer.dist.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
22

3-
$finder = PhpCsFixer\Finder::create()
3+
$finder = (new PhpCsFixer\Finder())
44
->exclude('src/Resources')
55
->exclude('vendor')
66
->in(__DIR__)
77
;
88

9-
return PhpCsFixer\Config::create()
9+
return (new PhpCsFixer\Config())
1010
->setRiskyAllowed(true)
1111
->setRules([
1212
'@Symfony' => true,

src/ClientFactory/AutoDiscoveryFactory.php

-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
*/
1414
class AutoDiscoveryFactory implements ClientFactory
1515
{
16-
/**
17-
* {@inheritdoc}
18-
*/
1916
public function createClient(array $config = [])
2017
{
2118
return Psr18ClientDiscovery::find();

src/ClientFactory/BuzzFactory.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ public function __construct(private readonly ResponseFactoryInterface $responseF
1717
{
1818
}
1919

20-
/**
21-
* {@inheritdoc}
22-
*/
2320
public function createClient(array $config = [])
2421
{
2522
if (!class_exists('Buzz\Client\FileGetContents')) {
@@ -37,9 +34,9 @@ private function getOptions(array $config = [])
3734
$resolver = new OptionsResolver();
3835

3936
$resolver->setDefaults([
40-
'timeout' => 5,
41-
'verify' => true,
42-
'proxy' => null,
37+
'timeout' => 5,
38+
'verify' => true,
39+
'proxy' => null,
4340
]);
4441

4542
$resolver->setAllowedTypes('timeout', 'int');

src/ClientFactory/CurlFactory.php

-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ public function __construct(private readonly ResponseFactoryInterface $responseF
1717
{
1818
}
1919

20-
/**
21-
* {@inheritdoc}
22-
*/
2320
public function createClient(array $config = [])
2421
{
2522
if (!class_exists('Http\Client\Curl\Client')) {

src/ClientFactory/Guzzle6Factory.php

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
*/
1212
class Guzzle6Factory implements ClientFactory
1313
{
14-
/**
15-
* {@inheritdoc}
16-
*/
1714
public function createClient(array $config = [])
1815
{
1916
if (!class_exists('Http\Adapter\Guzzle6\Client')) {

src/ClientFactory/Guzzle7Factory.php

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
*/
1212
class Guzzle7Factory implements ClientFactory
1313
{
14-
/**
15-
* {@inheritdoc}
16-
*/
1714
public function createClient(array $config = [])
1815
{
1916
if (!class_exists('Http\Adapter\Guzzle7\Client')) {

src/ClientFactory/MockFactory.php

-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ public function setClient(ClientInterface $client)
2424
$this->client = $client;
2525
}
2626

27-
/**
28-
* {@inheritdoc}
29-
*/
3027
public function createClient(array $config = [])
3128
{
3229
if (!class_exists(Client::class)) {

src/ClientFactory/ReactFactory.php

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
*/
1212
class ReactFactory implements ClientFactory
1313
{
14-
/**
15-
* {@inheritdoc}
16-
*/
1714
public function createClient(array $config = [])
1815
{
1916
if (!class_exists('Http\Adapter\React\Client')) {

src/ClientFactory/SocketFactory.php

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
*/
1212
class SocketFactory implements ClientFactory
1313
{
14-
/**
15-
* {@inheritdoc}
16-
*/
1714
public function createClient(array $config = [])
1815
{
1916
if (!class_exists('Http\Client\Socket\Client')) {

src/ClientFactory/SymfonyFactory.php

-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ public function __construct(private readonly ResponseFactoryInterface $responseF
1818
{
1919
}
2020

21-
/**
22-
* {@inheritdoc}
23-
*/
2421
public function createClient(array $config = [])
2522
{
2623
if (!class_exists(HttplugClient::class)) {

src/Collector/Collector.php

+9-22
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,12 @@ public function __wakeup(): void
3535
parent::__wakeup();
3636
}
3737

38-
/**
39-
* {@inheritdoc}
40-
*/
4138
public function reset(): void
4239
{
4340
$this->data['stacks'] = [];
4441
$this->activeStack = null;
4542
}
4643

47-
/**
48-
* {@inheritdoc}
49-
*/
5044
public function getName(): string
5145
{
5246
return 'httplug';
@@ -95,7 +89,7 @@ public function addStack(Stack $stack)
9589
*/
9690
public function getChildrenStacks(Stack $parent)
9791
{
98-
return array_filter($this->data['stacks'], fn(Stack $stack) => $stack->getParent() === $parent);
92+
return array_filter($this->data['stacks'], fn (Stack $stack) => $stack->getParent() === $parent);
9993
}
10094

10195
/**
@@ -111,47 +105,43 @@ public function getStacks()
111105
*/
112106
public function getSuccessfulStacks()
113107
{
114-
return array_filter($this->data['stacks'], fn(Stack $stack) => !$stack->isFailed());
108+
return array_filter($this->data['stacks'], fn (Stack $stack) => !$stack->isFailed());
115109
}
116110

117111
/**
118112
* @return Stack[]
119113
*/
120114
public function getFailedStacks()
121115
{
122-
return array_filter($this->data['stacks'], fn(Stack $stack) => $stack->isFailed());
116+
return array_filter($this->data['stacks'], fn (Stack $stack) => $stack->isFailed());
123117
}
124118

125119
/**
126120
* @return array
127121
*/
128122
public function getClients()
129123
{
130-
$stacks = array_filter($this->data['stacks'], fn(Stack $stack) => null === $stack->getParent());
124+
$stacks = array_filter($this->data['stacks'], fn (Stack $stack) => null === $stack->getParent());
131125

132-
return array_unique(array_map(fn(Stack $stack) => $stack->getClient(), $stacks));
126+
return array_unique(array_map(fn (Stack $stack) => $stack->getClient(), $stacks));
133127
}
134128

135129
/**
136-
* @param $client
137-
*
138130
* @return Stack[]
139131
*/
140132
public function getClientRootStacks($client)
141133
{
142-
return array_filter($this->data['stacks'], fn(Stack $stack) => $stack->getClient() == $client && null == $stack->getParent());
134+
return array_filter($this->data['stacks'], fn (Stack $stack) => $stack->getClient() == $client && null == $stack->getParent());
143135
}
144136

145137
/**
146138
* Count all messages for a client.
147139
*
148-
* @param $client
149-
*
150140
* @return int
151141
*/
152142
public function countClientMessages($client)
153143
{
154-
return array_sum(array_map(fn(Stack $stack) => $this->countStackMessages($stack), $this->getClientRootStacks($client)));
144+
return array_sum(array_map(fn (Stack $stack) => $this->countStackMessages($stack), $this->getClientRootStacks($client)));
155145
}
156146

157147
/**
@@ -161,20 +151,17 @@ public function countClientMessages($client)
161151
*/
162152
private function countStackMessages(Stack $stack)
163153
{
164-
return 1 + array_sum(array_map(fn(Stack $child) => $this->countStackMessages($child), $this->getChildrenStacks($stack)));
154+
return 1 + array_sum(array_map(fn (Stack $child) => $this->countStackMessages($child), $this->getChildrenStacks($stack)));
165155
}
166156

167157
/**
168158
* @return int
169159
*/
170160
public function getTotalDuration()
171161
{
172-
return array_reduce($this->data['stacks'], fn($carry, Stack $stack) => $carry + $stack->getDuration(), 0);
162+
return array_reduce($this->data['stacks'], fn ($carry, Stack $stack) => $carry + $stack->getDuration(), 0);
173163
}
174164

175-
/**
176-
* {@inheritdoc}
177-
*/
178165
public function collect(Request $request, Response $response, $exception = null): void
179166
{
180167
// We do not need to collect any data from the Symfony Request and Response

src/Collector/Formatter.php

-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Http\Client\Exception\HttpException;
99
use Http\Client\Exception\TransferException;
1010
use Http\Message\Formatter as MessageFormatter;
11-
use Http\Message\Formatter\CurlCommandFormatter;
1211
use Psr\Http\Client\NetworkExceptionInterface;
1312
use Psr\Http\Message\RequestInterface;
1413
use Psr\Http\Message\ResponseInterface;
@@ -45,9 +44,6 @@ public function formatException(\Throwable $exception)
4544
return sprintf('Unexpected exception of type "%s": %s', $exception::class, $exception->getMessage());
4645
}
4746

48-
/**
49-
* {@inheritdoc}
50-
*/
5147
public function formatRequest(RequestInterface $request)
5248
{
5349
return $this->formatter->formatRequest($request);

src/Collector/PluginClientFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct(private readonly Collector $collector, private reado
3838
*/
3939
public function createClient($client, array $plugins = [], array $options = [])
4040
{
41-
$plugins = array_map(fn(Plugin $plugin) => new ProfilePlugin($plugin, $this->collector, $this->formatter), $plugins);
41+
$plugins = array_map(fn (Plugin $plugin) => new ProfilePlugin($plugin, $this->collector, $this->formatter), $plugins);
4242

4343
$clientName = $options['client_name'] ?? 'Default';
4444
array_unshift($plugins, new StackPlugin($this->collector, $this->formatter, $clientName));

src/Collector/PluginClientFactoryListener.php

-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ public function onEvent(Event $e)
3131
DefaultPluginClientFactory::setFactory($this->factory->createClient(...));
3232
}
3333

34-
/**
35-
* {@inheritdoc}
36-
*/
3734
public static function getSubscribedEvents(): array
3835
{
3936
return [

src/Collector/ProfileClient.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public function sendAsyncRequest(RequestInterface $request)
5050
$activateStack = true;
5151
$stack = $this->collector->getActiveStack();
5252
if (null === $stack) {
53-
//When using a discovered client not wrapped in a PluginClient, we don't have a stack from StackPlugin. So
54-
//we create our own stack and activate it!
53+
// When using a discovered client not wrapped in a PluginClient, we don't have a stack from StackPlugin. So
54+
// we create our own stack and activate it!
5555
$stack = new Stack('Default', $this->formatter->formatRequest($request));
5656
$this->collector->addStack($stack);
5757
$this->collector->activateStack($stack);
@@ -85,7 +85,7 @@ public function sendAsyncRequest(RequestInterface $request)
8585
throw $e;
8686
} finally {
8787
if ($activateStack) {
88-
//We only activate the stack when created by the StackPlugin.
88+
// We only activate the stack when created by the StackPlugin.
8989
$this->collector->activateStack($stack);
9090
}
9191
}
@@ -95,8 +95,8 @@ protected function doSendRequest(RequestInterface $request)
9595
{
9696
$stack = $this->collector->getActiveStack();
9797
if (null === $stack) {
98-
//When using a discovered client not wrapped in a PluginClient, we don't have a stack from StackPlugin. So
99-
//we create our own stack but don't activate it.
98+
// When using a discovered client not wrapped in a PluginClient, we don't have a stack from StackPlugin. So
99+
// we create our own stack but don't activate it.
100100
$stack = new Stack('Default', $this->formatter->formatRequest($request));
101101
$this->collector->addStack($stack);
102102
}

src/Collector/ProfileClientFactory.php

-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ public function __construct($factory, private readonly Collector $collector, pri
3535
$this->factory = $factory;
3636
}
3737

38-
/**
39-
* {@inheritdoc}
40-
*/
4138
public function createClient(array $config = [])
4239
{
4340
$client = is_callable($this->factory) ? call_user_func($this->factory, $config) : $this->factory->createClient($config);

src/Collector/ProfilePlugin.php

+3-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\Common\Plugin;
98
use Psr\Http\Message\RequestInterface;
109
use Psr\Http\Message\ResponseInterface;
@@ -51,7 +50,7 @@ protected function doHandleRequest(RequestInterface $request, callable $next, ca
5150

5251
try {
5352
$promise = $this->plugin->handleRequest($request, $wrappedNext, $wrappedFirst);
54-
} catch (Exception $e) {
53+
} catch (\Exception $e) {
5554
$this->onException($request, $profile, $e, $stack);
5655

5756
throw $e;
@@ -61,7 +60,7 @@ protected function doHandleRequest(RequestInterface $request, callable $next, ca
6160
$this->onOutgoingResponse($response, $profile, $request, $stack);
6261

6362
return $response;
64-
}, function (Exception $exception) use ($profile, $request, $stack): void {
63+
}, function (\Exception $exception) use ($profile, $request, $stack): void {
6564
$this->onException($request, $profile, $exception, $stack);
6665

6766
throw $exception;
@@ -71,7 +70,7 @@ protected function doHandleRequest(RequestInterface $request, callable $next, ca
7170
private function onException(
7271
RequestInterface $request,
7372
Profile $profile,
74-
Exception $exception,
73+
\Exception $exception,
7574
Stack $stack
7675
): void {
7776
$profile->setFailed(true);

src/Collector/Stack.php

-3
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ public function getParent()
7272
return $this->parent;
7373
}
7474

75-
/**
76-
* @param Stack $parent
77-
*/
7875
public function setParent(self $parent)
7976
{
8077
$this->parent = $parent;

src/Collector/StackPlugin.php

+1-2
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\Common\Plugin;
98
use Psr\Http\Message\RequestInterface;
109
use Psr\Http\Message\ResponseInterface;
@@ -41,7 +40,7 @@ protected function doHandleRequest(RequestInterface $request, callable $next, ca
4140
return $response;
4241
};
4342

44-
$onRejected = function (Exception $exception) use ($stack): void {
43+
$onRejected = function (\Exception $exception) use ($stack): void {
4544
$stack->setResponse($this->formatter->formatException($exception));
4645
$stack->setFailed(true);
4746

src/Collector/Twig/HttpMessageMarkupExtension.php

-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ public function __construct(?ClonerInterface $cloner = null, ?DataDumperInterfac
2727
}
2828

2929
/**
30-
* {@inheritdoc}
31-
*
3230
* @return array
3331
*/
3432
public function getFilters()

0 commit comments

Comments
 (0)