Skip to content

Commit 92d4d53

Browse files
committed
Psalm fixes.
1 parent 4716ebe commit 92d4d53

25 files changed

+204
-176
lines changed

psalm.xml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
errorLevel="3"
4+
resolveFromConfigFile="true"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xmlns="https://getpsalm.org/schema/config"
7+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
8+
allowStringToStandInForClass="true"
9+
allowCoercionFromStringToClassConst="true"
10+
findUnusedPsalmSuppress="true"
11+
skipChecksOnUnresolvableIncludes="true"
12+
>
13+
<plugins>
14+
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
15+
<pluginClass class="Psalm\MockeryPlugin\Plugin"/>
16+
</plugins>
17+
<projectFiles>
18+
<directory name="/"/>
19+
<ignoreFiles>
20+
<directory name="vendor"/>
21+
<directory name="tests"/>
22+
</ignoreFiles>
23+
</projectFiles>
24+
<issueHandlers>
25+
<InvalidCatch>
26+
<errorLevel type="suppress">
27+
<referencedClass name="Psr\SimpleCache\InvalidArgumentException"/>
28+
<referencedClass name="Psr\Cache\InvalidArgumentException"/>
29+
</errorLevel>
30+
</InvalidCatch>
31+
<InvalidThrow>
32+
<errorLevel type="suppress">
33+
<referencedClass name="Psr\SimpleCache\InvalidArgumentException"/>
34+
<referencedClass name="Psr\Cache\InvalidArgumentException"/>
35+
</errorLevel>
36+
</InvalidThrow>
37+
<UnusedVariable>
38+
<errorLevel type="suppress">
39+
<directory name="/"/>
40+
</errorLevel>
41+
</UnusedVariable>
42+
<UndefinedConstant>
43+
<errorLevel type="suppress">
44+
<directory name="/"/>
45+
</errorLevel>
46+
</UndefinedConstant>
47+
<MissingDependency>
48+
<errorLevel type="suppress">
49+
<directory name="/"/>
50+
</errorLevel>
51+
</MissingDependency>
52+
<UndefinedClass>
53+
<errorLevel type="suppress">
54+
<directory name="/"/>
55+
</errorLevel>
56+
</UndefinedClass>
57+
<UndefinedFunction>
58+
<errorLevel type="suppress">
59+
<directory name="/"/>
60+
</errorLevel>
61+
</UndefinedFunction>
62+
<UnresolvableInclude>
63+
<errorLevel type="suppress">
64+
<directory name="/"/>
65+
</errorLevel>
66+
</UnresolvableInclude>
67+
<PropertyNotSetInConstructor>
68+
<errorLevel type="suppress">
69+
<directory name="/"/>
70+
</errorLevel>
71+
</PropertyNotSetInConstructor>
72+
<MissingReturnType>
73+
<errorLevel type="suppress">
74+
<file name="src/Services/AppKernel.php"/>
75+
</errorLevel>
76+
</MissingReturnType>
77+
<PossiblyInvalidArgument>
78+
<errorLevel type="suppress">
79+
<file name="functions/container.php"/>
80+
</errorLevel>
81+
</PossiblyInvalidArgument>
82+
<PossiblyInvalidOperand>
83+
<errorLevel type="suppress">
84+
<file name="functions/container.php"/>
85+
</errorLevel>
86+
</PossiblyInvalidOperand>
87+
</issueHandlers>
88+
</psalm>

readme.MD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ var_dump(container($micro)->getParameter('example'));
126126

127127
- `service_container` (и alias) - сервис-контейнер целиком
128128
- `app.request` - конвертор глобалов в Request
129-
- `custom.post.type.registrator` - регистратор кастомных типов постов в Wordpress
130129
- синонимы сервиса `kernel`.
131130

132131

src/Bundles/BundlesLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public static function bootAfterCompilingContainer(ContainerInterface $container
181181
/**
182182
* @var Bundle $bundle
183183
*/
184-
foreach ($container->getParameter('kernel.bundles') as $bundle) {
184+
foreach ((array)$container->getParameter('kernel.bundles') as $bundle) {
185185
$bundleObject = new $bundle;
186186
$bundleObject->setContainer($container);
187187
$bundleObject->boot();

src/CompilePasses/AddTaggedCompilerPass.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,19 @@ private function prioritizeTags(array $tags) : array
181181
return $tags;
182182
}
183183

184-
usort($tags, function (array $tag1, array $tag2) {
185-
$tag1Priority = $tag1['attributes'][$this->priorityAttribute] ?? 0;
186-
$tag2Priority = $tag2['attributes'][$this->priorityAttribute] ?? 0;
187-
return $tag1Priority - $tag2Priority;
188-
});
184+
usort($tags,
185+
/**
186+
* @param array $tag1
187+
* @param array $tag2
188+
*
189+
* @return mixed
190+
*/
191+
function (array $tag1, array $tag2) {
192+
$tag1Priority = $tag1['attributes'][$this->priorityAttribute] ?? 0;
193+
$tag2Priority = $tag2['attributes'][$this->priorityAttribute] ?? 0;
194+
195+
return $tag1Priority - $tag2Priority;
196+
});
189197

190198
return $tags;
191199
}

src/CompilePasses/AggregatedTaggedServicesPass.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,14 @@ class AggregatedTaggedServicesPass implements CompilerPassInterface
3434
*/
3535
public function process(ContainerBuilder $container) : void
3636
{
37-
$taggedServices = $container->findTaggedServiceIds(
38-
self::TAG_BOOTSTRAP_SERVICES
39-
);
37+
$taggedServices = $container->findTaggedServiceIds(self::TAG_BOOTSTRAP_SERVICES);
4038

41-
if (empty($taggedServices)) {
39+
if (count($taggedServices) === 0) {
4240
return;
4341
}
4442

4543
$params = $container->hasParameter(self::VARIABLE_CONTAINER) ?
46-
$container->getParameter(self::VARIABLE_CONTAINER)
44+
(array)$container->getParameter(self::VARIABLE_CONTAINER)
4745
: [];
4846

4947
// Сервисы автозапуска.

src/CompilePasses/BaseAggregatedTaggedServicesPass.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
* @since 06.11.2020 Добавление к уже существующим параметрам, а не перезаписывание. Позволяет бандлам
1515
* подмешивать свои добавления.
1616
*/
17-
class BaseAggregatedTaggedServicesPass implements CompilerPassInterface
17+
final class BaseAggregatedTaggedServicesPass implements CompilerPassInterface
1818
{
19-
/** @var string $tag Искомый сервисный тэг. */
19+
/**
20+
* @var string $tag Искомый сервисный тэг.
21+
*/
2022
private $tag;
2123

2224
/**
@@ -52,12 +54,12 @@ public function process(ContainerBuilder $container): void
5254
$this->tag
5355
);
5456

55-
if (empty($taggedServices)) {
57+
if (count($taggedServices) === 0) {
5658
return;
5759
}
5860

5961
$params = $container->hasParameter($this->nameSectionParameterBag) ?
60-
$container->getParameter($this->nameSectionParameterBag)
62+
(array)$container->getParameter($this->nameSectionParameterBag)
6163
: [];
6264

6365
$container->setParameter(

src/CompilePasses/ContainerAwareCompilerPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
* @since 28.09.2020
1515
*/
16-
class ContainerAwareCompilerPass implements CompilerPassInterface
16+
final class ContainerAwareCompilerPass implements CompilerPassInterface
1717
{
1818
/**
1919
* automatically injects the Service Container into all your services that
@@ -22,7 +22,7 @@ class ContainerAwareCompilerPass implements CompilerPassInterface
2222
* @see DummyService
2323
* @inheritDoc
2424
*/
25-
public function process(ContainerBuilder $container)
25+
public function process(ContainerBuilder $container) : void
2626
{
2727
foreach ($container->getServiceIds() as $serviceId) {
2828
$definition = $container->findDefinition($serviceId);

src/CompilePasses/MakePrivateCommandsPublic.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
*
1313
* @since 20.12.2020
1414
*/
15-
class MakePrivateCommandsPublic implements CompilerPassInterface
15+
final class MakePrivateCommandsPublic implements CompilerPassInterface
1616
{
1717
/**
1818
* @inheritDoc
1919
*/
20-
public function process(ContainerBuilder $container)
20+
public function process(ContainerBuilder $container) : void
2121
{
2222
$taggedServices = $container->findTaggedServiceIds(
2323
'console.command'

src/CompilePasses/MakePrivateEventsPublic.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* @since 19.11.2020
1414
* @since 05.04.2021 Публичными делаюься и слушатели ядра.
1515
*/
16-
class MakePrivateEventsPublic implements CompilerPassInterface
16+
final class MakePrivateEventsPublic implements CompilerPassInterface
1717
{
1818
/**
1919
* @inheritDoc

src/CompilePasses/TagPass/AbstractTagPass.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ abstract class AbstractTagPass
2424
*
2525
* @param string $destinationServiceId ID сервиса назначения.
2626
* @param string $method Метод.
27-
* @param string $taggedServiceId Тагированный сервис.
27+
* @param string $taggedServiceId Тэгированный сервис.
2828
*
2929
* @return void
3030
*/
@@ -42,8 +42,14 @@ protected function addCall(
4242

4343
array_splice(
4444
$methodCalls,
45-
array_search('configure',
46-
array_map(function($call) { return $call[0]; }, $methodCalls)
45+
(int)array_search('configure',
46+
array_map(
47+
/**
48+
* @return mixed
49+
*/
50+
function (array $call) {
51+
return $call[0];
52+
}, $methodCalls)
4753
),
4854
0,
4955
[[$method, [new Reference($taggedServiceId)]]]
@@ -63,8 +69,8 @@ protected function addCall(
6369
*/
6470
protected function sortByPriority(array $data) : array
6571
{
66-
if (empty($data)) {
67-
return $data;
72+
if (count($data) === 0) {
73+
return [];
6874
}
6975

7076
// Расставить приоритеты по-умолчанию (0).
@@ -75,7 +81,7 @@ protected function sortByPriority(array $data) : array
7581
}
7682

7783
// Отсортировать по приоритету.
78-
uasort($data, static function ($a, $b) {
84+
uasort($data, static function (array $a, array $b) {
7985
return $a[0]['priority'] > $b[0]['priority'];
8086
});
8187

0 commit comments

Comments
 (0)