Skip to content

Commit 9b44b74

Browse files
committed
Move to PHPStan level 6
1 parent 5e1d9b0 commit 9b44b74

File tree

10 files changed

+47
-18
lines changed

10 files changed

+47
-18
lines changed

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
parameters:
2-
level: 5
2+
level: 6
33
paths:
44
- src/
55
- tests/

src/DependencyInjection/StofDoctrineExtensionsExtension.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ class StofDoctrineExtensionsExtension extends Extension
8181
),
8282
);
8383

84+
/** @var list<string> */
8485
private $entityManagers = array();
86+
/** @var list<string> */
8587
private $documentManagers = array();
8688

8789
/**
@@ -150,7 +152,7 @@ public function load(array $configs, ContainerBuilder $container)
150152
/**
151153
* @internal
152154
*/
153-
public function configValidate(ContainerBuilder $container)
155+
public function configValidate(ContainerBuilder $container): void
154156
{
155157
foreach ($this->entityManagers as $name) {
156158
if (!$container->hasDefinition(sprintf('doctrine.dbal.%s_connection', $name))) {
@@ -166,13 +168,13 @@ public function configValidate(ContainerBuilder $container)
166168
}
167169

168170
/**
169-
* @param array $configs
170-
* @param ContainerBuilder $container
171-
* @param LoaderInterface $loader
172-
* @param array $loaded
173-
* @param string $doctrineListenerTag
171+
* @param array<string, array<string, bool>> $configs
172+
* @param ContainerBuilder $container
173+
* @param LoaderInterface $loader
174+
* @param array<string, true> $loaded
175+
* @param string $doctrineListenerTag
174176
*
175-
* @return array
177+
* @return list<string>
176178
*/
177179
private function processObjectManagerConfigurations(array $configs, ContainerBuilder $container, LoaderInterface $loader, array &$loaded, string $doctrineListenerTag)
178180
{

src/EventListener/BlameListener.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@
1818
*/
1919
class BlameListener implements EventSubscriberInterface
2020
{
21+
/** @var AuthorizationCheckerInterface|null */
2122
private $authorizationChecker;
23+
/** @var TokenStorageInterface|null */
2224
private $tokenStorage;
25+
/** @var BlameableListener */
2326
private $blameableListener;
2427

2528
public function __construct(BlameableListener $blameableListener, TokenStorageInterface $tokenStorage = null, AuthorizationCheckerInterface $authorizationChecker = null)
@@ -32,7 +35,7 @@ public function __construct(BlameableListener $blameableListener, TokenStorageIn
3235
/**
3336
* @internal
3437
*/
35-
public function onKernelRequest(RequestEvent $event)
38+
public function onKernelRequest(RequestEvent $event): void
3639
{
3740
if (!$event->isMainRequest()) {
3841
return;

src/EventListener/IpTraceListener.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
*/
1414
final class IpTraceListener implements EventSubscriberInterface
1515
{
16+
/** @var IpTraceableListener */
1617
private $ipTraceableListener;
1718

1819
public function __construct(IpTraceableListener $ipTraceableListener)
1920
{
2021
$this->ipTraceableListener = $ipTraceableListener;
2122
}
2223

23-
public function onKernelRequest(RequestEvent $event)
24+
public function onKernelRequest(RequestEvent $event): void
2425
{
2526
if (!$event->isMainRequest()) {
2627
return;

src/EventListener/LocaleListener.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515
class LocaleListener implements EventSubscriberInterface
1616
{
17+
/** @var TranslatableListener */
1718
private $translatableListener;
1819

1920
public function __construct(TranslatableListener $translatableListener)
@@ -24,7 +25,7 @@ public function __construct(TranslatableListener $translatableListener)
2425
/**
2526
* @internal
2627
*/
27-
public function onKernelRequest(RequestEvent $event)
28+
public function onKernelRequest(RequestEvent $event): void
2829
{
2930
$this->translatableListener->setTranslatableLocale($event->getRequest()->getLocale());
3031
}

src/EventListener/LoggerListener.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Stof\DoctrineExtensionsBundle\EventListener;
44

5+
use Gedmo\Loggable\Loggable;
56
use Gedmo\Loggable\LoggableListener;
67
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
78
use Symfony\Component\HttpKernel\Event\RequestEvent;
@@ -14,13 +15,21 @@
1415
* Sets the username from the security context by listening on kernel.request
1516
*
1617
* @author Christophe Coevoet <[email protected]>
18+
*
19+
* @phpstan-template T of Loggable|object
1720
*/
1821
class LoggerListener implements EventSubscriberInterface
1922
{
23+
/** @var AuthorizationCheckerInterface|null */
2024
private $authorizationChecker;
25+
/** @var TokenStorageInterface|null */
2126
private $tokenStorage;
27+
/** @var LoggableListener<T> */
2228
private $loggableListener;
2329

30+
/**
31+
* @param LoggableListener<T> $loggableListener
32+
*/
2433
public function __construct(LoggableListener $loggableListener, TokenStorageInterface $tokenStorage = null, AuthorizationCheckerInterface $authorizationChecker = null)
2534
{
2635
$this->loggableListener = $loggableListener;
@@ -31,7 +40,7 @@ public function __construct(LoggableListener $loggableListener, TokenStorageInte
3140
/**
3241
* @internal
3342
*/
34-
public function onKernelRequest(RequestEvent $event)
43+
public function onKernelRequest(RequestEvent $event): void
3544
{
3645
if (!$event->isMainRequest()) {
3746
return;

src/Uploadable/UploadableManager.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@
33
namespace Stof\DoctrineExtensionsBundle\Uploadable;
44

55
use Symfony\Component\HttpFoundation\File\UploadedFile;
6+
use Gedmo\Uploadable\FileInfo\FileInfoInterface;
67
use Gedmo\Uploadable\UploadableListener;
78

89
class UploadableManager
910
{
1011
/** @var \Gedmo\Uploadable\UploadableListener */
1112
private $listener;
13+
/** @var class-string<FileInfoInterface> */
1214
private $fileInfoClass;
1315

16+
/**
17+
* @param UploadableListener $listener
18+
* @param class-string<FileInfoInterface> $fileInfoClass
19+
*/
1420
public function __construct(UploadableListener $listener, $fileInfoClass)
1521
{
1622
$this->listener = $listener;
@@ -24,6 +30,8 @@ public function __construct(UploadableListener $listener, $fileInfoClass)
2430
*
2531
* @param object $entity - The entity you are marking to "Upload" as soon as you call "flush".
2632
* @param mixed $fileInfo - The file info object or array. In Symfony, this will be typically an UploadedFile instance.
33+
*
34+
* @return void
2735
*/
2836
public function markEntityToUpload($entity, $fileInfo)
2937
{

src/Uploadable/UploadedFileInfo.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
class UploadedFileInfo implements FileInfoInterface
99
{
10+
/** @var UploadedFile */
1011
private $uploadedFile;
1112

1213
public function __construct(UploadedFile $uploadedFile)
@@ -31,7 +32,7 @@ public function getName()
3132
}
3233

3334
/**
34-
* @return ?string
35+
* @return int|false
3536
*/
3637
public function getSize()
3738
{

src/Uploadable/ValidatorConfigurator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010
class ValidatorConfigurator
1111
{
12+
/** @var bool */
1213
private $validateWritableDirectory;
1314

1415
/**
@@ -19,7 +20,7 @@ public function __construct($validateWritableDirectory)
1920
$this->validateWritableDirectory = $validateWritableDirectory;
2021
}
2122

22-
public function configure()
23+
public function configure(): void
2324
{
2425
Validator::$validateWritableDirectory = $this->validateWritableDirectory;
2526
}

tests/DependencyInjection/StofDoctrineExtensionsExtensionTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
class StofDoctrineExtensionsExtensionTest extends TestCase
1212
{
13+
/**
14+
* @return iterable<array{string}>
15+
*/
1316
public static function provideExtensions()
1417
{
1518
return array(
@@ -30,7 +33,7 @@ public static function provideExtensions()
3033
/**
3134
* @dataProvider provideExtensions
3235
*/
33-
public function testLoadORMConfig($listener)
36+
public function testLoadORMConfig(string $listener): void
3437
{
3538
$extension = new StofDoctrineExtensionsExtension();
3639
$container = new ContainerBuilder();
@@ -57,7 +60,7 @@ public function testLoadORMConfig($listener)
5760
/**
5861
* @dataProvider provideExtensions
5962
*/
60-
public function testLoadMongodbConfig($listener)
63+
public function testLoadMongodbConfig(string $listener): void
6164
{
6265
$extension = new StofDoctrineExtensionsExtension();
6366
$container = new ContainerBuilder();
@@ -84,7 +87,7 @@ public function testLoadMongodbConfig($listener)
8487
/**
8588
* @dataProvider provideExtensions
8689
*/
87-
public function testLoadBothConfig($listener)
90+
public function testLoadBothConfig(string $listener): void
8891
{
8992
$extension = new StofDoctrineExtensionsExtension();
9093
$container = new ContainerBuilder();
@@ -110,7 +113,7 @@ public function testLoadBothConfig($listener)
110113
/**
111114
* @dataProvider provideExtensions
112115
*/
113-
public function testEventConsistency(string $listener)
116+
public function testEventConsistency(string $listener): void
114117
{
115118
$extension = new StofDoctrineExtensionsExtension();
116119
$container = new ContainerBuilder();

0 commit comments

Comments
 (0)