Skip to content

Commit 7ab2d62

Browse files
author
Michael Garifullin
committed
bump phpstan level up to 7
1 parent 658a73e commit 7ab2d62

File tree

15 files changed

+164
-49
lines changed

15 files changed

+164
-49
lines changed

.github/workflows/tests.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ jobs:
1515
- 8.1
1616
symfony-version:
1717
- 4.4.*
18-
- 5.3.*
1918
- 5.4.*
2019
include:
2120
- php-version: 7.1
2221
symfony-version: 4.4.*
2322
- php-version: 8.1
2423
symfony-version: 6.0.*
24+
- php-version: 8.2
25+
symfony-version: 5.4.*
26+
- php-version: 8.2
27+
symfony-version: 6.0.*
2528

2629
steps:
2730
- uses: actions/checkout@v2

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ vendor/
66
bin/
77
.php-cs-fixer.cache
88
composer.lock
9+
phpstan.neon

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"require-dev": {
3131
"atoum/atoum": "^3.4 || ^4.0",
3232
"m6web/php-cs-fixer-config": "2.1.0",
33-
"phpstan/phpstan": "1.4.10",
33+
"phpstan/phpstan": "^1.4.10",
3434
"symfony/console": "^4.4 || ^5.0 || ^6.0",
3535
"symfony/http-foundation": "^4.4 || ^5.0 || ^6.0"
3636
},

phpstan-baseline.neon

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: "#^Method M6Web\\\\Bundle\\\\StatsdBundle\\\\Client\\\\Client\\:\\:addEventToListen\\(\\) has parameter \\$eventConfig with no value type specified in iterable type array\\.$#"
5+
count: 1
6+
path: src/Client/Client.php
7+
8+
-
9+
message: "#^Method M6Web\\\\Bundle\\\\StatsdBundle\\\\Client\\\\Client\\:\\:addTiming\\(\\) has parameter \\$tags with no value type specified in iterable type array\\.$#"
10+
count: 1
11+
path: src/Client/Client.php
12+
13+
-
14+
message: "#^Method M6Web\\\\Bundle\\\\StatsdBundle\\\\Client\\\\Client\\:\\:getEventValue\\(\\) has no return type specified\\.$#"
15+
count: 1
16+
path: src/Client/Client.php
17+
18+
-
19+
message: "#^Method M6Web\\\\Bundle\\\\StatsdBundle\\\\Client\\\\Client\\:\\:getListenedEvents\\(\\) return type has no value type specified in iterable type array\\.$#"
20+
count: 1
21+
path: src/Client/Client.php
22+
23+
-
24+
message: "#^Method M6Web\\\\Bundle\\\\StatsdBundle\\\\Client\\\\Client\\:\\:mergeTags\\(\\) has parameter \\$config with no value type specified in iterable type array\\.$#"
25+
count: 1
26+
path: src/Client/Client.php
27+
28+
-
29+
message: "#^Method M6Web\\\\Bundle\\\\StatsdBundle\\\\Client\\\\Client\\:\\:mergeTags\\(\\) has parameter \\$event with no type specified\\.$#"
30+
count: 1
31+
path: src/Client/Client.php
32+
33+
-
34+
message: "#^Method M6Web\\\\Bundle\\\\StatsdBundle\\\\Client\\\\Client\\:\\:mergeTags\\(\\) return type has no value type specified in iterable type array\\.$#"
35+
count: 1
36+
path: src/Client/Client.php
37+
38+
-
39+
message: "#^Property M6Web\\\\Bundle\\\\StatsdBundle\\\\Client\\\\Client\\:\\:\\$listenedEvents type has no value type specified in iterable type array\\.$#"
40+
count: 1
41+
path: src/Client/Client.php
42+
43+
-
44+
message: "#^Method M6Web\\\\Bundle\\\\StatsdBundle\\\\DataCollector\\\\StatsdDataCollector\\:\\:getClients\\(\\) return type has no value type specified in iterable type array\\.$#"
45+
count: 1
46+
path: src/DataCollector/StatsdDataCollector.php
47+
48+
-
49+
message: "#^Property M6Web\\\\Bundle\\\\StatsdBundle\\\\DataCollector\\\\StatsdDataCollector\\:\\:\\$statsdClients type has no value type specified in iterable type array\\.$#"
50+
count: 1
51+
path: src/DataCollector/StatsdDataCollector.php
52+
53+
-
54+
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#"
55+
count: 2
56+
path: src/DependencyInjection/Configuration.php
57+
58+
-
59+
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeParentInterface\\:\\:booleanNode\\(\\)\\.$#"
60+
count: 1
61+
path: src/DependencyInjection/Configuration.php
62+
63+
-
64+
message: "#^Method M6Web\\\\Bundle\\\\StatsdBundle\\\\DependencyInjection\\\\M6WebStatsdExtension\\:\\:load\\(\\) has parameter \\$configs with no value type specified in iterable type array\\.$#"
65+
count: 1
66+
path: src/DependencyInjection/M6WebStatsdExtension.php
67+
68+
-
69+
message: "#^Method M6Web\\\\Bundle\\\\StatsdBundle\\\\DependencyInjection\\\\M6WebStatsdExtension\\:\\:loadClient\\(\\) has parameter \\$config with no value type specified in iterable type array\\.$#"
70+
count: 1
71+
path: src/DependencyInjection/M6WebStatsdExtension.php
72+
73+
-
74+
message: "#^Method M6Web\\\\Bundle\\\\StatsdBundle\\\\DependencyInjection\\\\M6WebStatsdExtension\\:\\:loadClient\\(\\) has parameter \\$servers with no value type specified in iterable type array\\.$#"
75+
count: 1
76+
path: src/DependencyInjection/M6WebStatsdExtension.php
77+
78+
-
79+
message: "#^Method M6Web\\\\Bundle\\\\StatsdBundle\\\\Event\\\\ConsoleEvent\\:\\:__call\\(\\) has no return type specified\\.$#"
80+
count: 1
81+
path: src/Event/ConsoleEvent.php
82+
83+
-
84+
message: "#^Method M6Web\\\\Bundle\\\\StatsdBundle\\\\Event\\\\ConsoleEvent\\:\\:__call\\(\\) has parameter \\$parameters with no value type specified in iterable type array\\.$#"
85+
count: 1
86+
path: src/Event/ConsoleEvent.php
87+
88+
-
89+
message: "#^Method M6Web\\\\Bundle\\\\StatsdBundle\\\\Statsd\\\\MonitorableEventInterface\\:\\:getValue\\(\\) has no return type specified\\.$#"
90+
count: 1
91+
path: src/Statsd/MonitorableEventInterface.php
92+
93+
-
94+
message: "#^Method M6Web\\\\Bundle\\\\StatsdBundle\\\\Statsd\\\\StatsdEvent\\:\\:getTiming\\(\\) has no return type specified\\.$#"
95+
count: 1
96+
path: src/Statsd/StatsdEvent.php
97+
98+
-
99+
message: "#^Method M6Web\\\\Bundle\\\\StatsdBundle\\\\Statsd\\\\StatsdEvent\\:\\:getValue\\(\\) has no return type specified\\.$#"
100+
count: 1
101+
path: src/Statsd/StatsdEvent.php
102+
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
includes:
2+
- phpstan-baseline.neon
13
parameters:
2-
level: 5
4+
level: 6
35
paths:
46
- src
57
excludePaths:
68
- src/Tests
9+
- src/Statsd/Listener.php
710
treatPhpDocTypesAsCertain: false

src/Client/Client.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function getListenedEvents()
3939
* @param string $eventName The event name to listen
4040
* @param array $eventConfig The event handler configuration
4141
*/
42-
public function addEventToListen($eventName, $eventConfig)
42+
public function addEventToListen($eventName, $eventConfig): void
4343
{
4444
$this->listenedEvents[$eventName] = $eventConfig;
4545
}
@@ -160,7 +160,7 @@ private function getEventValue($event, $method)
160160
*
161161
* @throws Exception
162162
*/
163-
private function addTiming($event, $timingMethod, $node, $tags = [])
163+
private function addTiming($event, $timingMethod, $node, $tags = []): void
164164
{
165165
$timing = $this->getEventValue($event, $timingMethod);
166166
if ($timing > 0) {
@@ -200,7 +200,7 @@ private function replaceConfigPlaceholder($event, $eventName, $string)
200200
*
201201
* @return array of tags
202202
*/
203-
private function mergeTags($event, $config)
203+
private function mergeTags($event, $config): array
204204
{
205205
$configTags = isset($config['tags']) ? $config['tags'] : [];
206206

src/DataCollector/StatsdDataCollector.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717
class StatsdDataCollector extends DataCollector
1818
{
19+
/** @var array */
1920
private $statsdClients;
2021

2122
/**
@@ -29,7 +30,7 @@ public function __construct()
2930
/**
3031
* Reset the data collector to initial state
3132
*/
32-
public function reset()
33+
public function reset(): void
3334
{
3435
$this->statsdClients = [];
3536
$this->data = [
@@ -43,7 +44,7 @@ public function reset()
4344
*
4445
* @param Event $event The received event
4546
*/
46-
public function onKernelResponse($event)
47+
public function onKernelResponse($event): void
4748
{
4849
if ($event instanceof KernelEvent && HttpKernelInterface::MASTER_REQUEST == $event->getRequestType()) {
4950
foreach ($this->statsdClients as $clientName => $client) {
@@ -76,17 +77,19 @@ public function onKernelResponse($event)
7677
* @param string $clientAlias The client alias
7778
* @param object $statsdClient A statsd client instance
7879
*/
79-
public function addStatsdClient($clientAlias, $statsdClient)
80+
public function addStatsdClient($clientAlias, $statsdClient): void
8081
{
8182
$this->statsdClients[$clientAlias] = $statsdClient;
8283
}
8384

8485
/**
8586
* Collect the data
8687
*
87-
* @param Request $request The request object
88-
* @param Response $response The response object
89-
* @param \Throwable $exception An exception
88+
* @param Request $request The request object
89+
* @param Response $response The response object
90+
* @param \Throwable|null $exception An exception
91+
*
92+
* @return void
9093
*/
9194
public function collect(Request $request, Response $response, \Throwable $exception = null)
9295
{
@@ -97,7 +100,7 @@ public function collect(Request $request, Response $response, \Throwable $except
97100
*
98101
* @return array operations list
99102
*/
100-
public function getClients()
103+
public function getClients(): array
101104
{
102105
return $this->data['clients'];
103106
}

src/DependencyInjection/Configuration.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace M6Web\Bundle\StatsdBundle\DependencyInjection;
66

7+
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
78
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
89
use Symfony\Component\Config\Definition\ConfigurationInterface;
910

@@ -15,9 +16,13 @@
1516
*/
1617
class Configuration implements ConfigurationInterface
1718
{
19+
/**
20+
* @return TreeBuilder
21+
*/
1822
public function getConfigTreeBuilder()
1923
{
2024
$treeBuilder = new TreeBuilder('m6_statsd');
25+
/** @var ArrayNodeDefinition $rootNode */
2126
$rootNode = $treeBuilder->getRootNode();
2227

2328
$this->addServersSection($rootNode);
@@ -27,7 +32,10 @@ public function getConfigTreeBuilder()
2732
return $treeBuilder;
2833
}
2934

30-
private function addServersSection($rootNode)
35+
/**
36+
* @param ArrayNodeDefinition $rootNode
37+
*/
38+
private function addServersSection($rootNode): void
3139
{
3240
$rootNode
3341
->children()
@@ -53,7 +61,10 @@ function ($v) {
5361
->end();
5462
}
5563

56-
private function addClientsSection($rootNode)
64+
/**
65+
* @param ArrayNodeDefinition $rootNode
66+
*/
67+
private function addClientsSection($rootNode): void
5768
{
5869
$rootNode
5970
->children()
@@ -97,8 +108,10 @@ private function addClientsSection($rootNode)
97108

98109
/**
99110
* addDefaultEventSection
111+
*
112+
* @param ArrayNodeDefinition $rootNode
100113
*/
101-
private function addDefaultEventSection($rootNode)
114+
private function addDefaultEventSection($rootNode): void
102115
{
103116
$rootNode
104117
->children()

src/DependencyInjection/M6WebStatsdExtension.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
*/
2020
class M6WebStatsdExtension extends Extension
2121
{
22+
/**
23+
* @return void
24+
*
25+
* @throws \Exception
26+
*/
2227
public function load(array $configs, ContainerBuilder $container)
2328
{
2429
$configuration = new Configuration();

src/Listener/ConsoleListener.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ public function __construct()
3434
/**
3535
* Define event dispatch
3636
*/
37-
public function setEventDispatcher(EventDispatcherInterface $ev)
37+
public function setEventDispatcher(EventDispatcherInterface $ev): void
3838
{
3939
$this->eventDispatcher = $ev;
4040
}
4141

42-
public function onCommand(BaseConsoleEvent $e)
42+
public function onCommand(BaseConsoleEvent $e): void
4343
{
4444
$this->startTime = microtime(true);
4545

4646
$this->dispatch($e, ConsoleEvent::COMMAND);
4747
}
4848

49-
public function onTerminate(ConsoleTerminateEvent $e)
49+
public function onTerminate(ConsoleTerminateEvent $e): void
5050
{
5151
// For non-0 exit command, fire an ERROR event
5252
if ($e->getExitCode() != 0) {
@@ -56,7 +56,7 @@ public function onTerminate(ConsoleTerminateEvent $e)
5656
$this->dispatch($e, ConsoleEvent::TERMINATE);
5757
}
5858

59-
public function onException(BaseConsoleEvent $e)
59+
public function onException(BaseConsoleEvent $e): void
6060
{
6161
$this->dispatch($e, ConsoleEvent::EXCEPTION);
6262
}

0 commit comments

Comments
 (0)