Skip to content

Commit 36ae70a

Browse files
committed
Fix issues reported by PHPStan 1.1
1 parent cadec80 commit 36ae70a

File tree

12 files changed

+29
-28
lines changed

12 files changed

+29
-28
lines changed

bundle/Controller/Admin/SynonymController.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use Netgen\TagsBundle\Form\Type\SynonymCreateType;
1010
use Symfony\Component\HttpFoundation\Request;
1111
use Symfony\Component\HttpFoundation\Response;
12-
use Symfony\Contracts\Translation\TranslatorInterface;
1312
use function count;
1413

1514
final class SynonymController extends Controller
@@ -19,15 +18,9 @@ final class SynonymController extends Controller
1918
*/
2019
private $tagsService;
2120

22-
/**
23-
* @var \Symfony\Contracts\Translation\TranslatorInterface
24-
*/
25-
private $translator;
26-
27-
public function __construct(TagsService $tagsService, TranslatorInterface $translator)
21+
public function __construct(TagsService $tagsService)
2822
{
2923
$this->tagsService = $tagsService;
30-
$this->translator = $translator;
3124
}
3225

3326
/**

bundle/Controller/Admin/TagController.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use Pagerfanta\Adapter\AdapterInterface;
2020
use Symfony\Component\HttpFoundation\Request;
2121
use Symfony\Component\HttpFoundation\Response;
22-
use Symfony\Contracts\Translation\TranslatorInterface;
2322
use function count;
2423
use function in_array;
2524
use function trim;
@@ -36,11 +35,6 @@ final class TagController extends Controller
3635
*/
3736
private $contentTypeService;
3837

39-
/**
40-
* @var \Symfony\Contracts\Translation\TranslatorInterface
41-
*/
42-
private $translator;
43-
4438
/**
4539
* @var \Pagerfanta\Adapter\AdapterInterface
4640
*/
@@ -54,13 +48,11 @@ final class TagController extends Controller
5448
public function __construct(
5549
TagsService $tagsService,
5650
ContentTypeService $contentTypeService,
57-
TranslatorInterface $translator,
5851
AdapterInterface $tagChildrenAdapter,
5952
SearchTagsAdapter $searchTagsAdapter
6053
) {
6154
$this->tagsService = $tagsService;
6255
$this->contentTypeService = $contentTypeService;
63-
$this->translator = $translator;
6456
$this->tagChildrenAdapter = $tagChildrenAdapter;
6557
$this->searchTagsAdapter = $searchTagsAdapter;
6658
}
@@ -492,7 +484,7 @@ public function translationAction(Request $request, Tag $tag): Response
492484
*/
493485
public function childrenAction(Request $request, ?Tag $tag = null): Response
494486
{
495-
if (count((array) $request->request->get('Tags') ?? []) === 0) {
487+
if (count((array) $request->request->get('Tags')) === 0) {
496488
$this->addFlashMessage('errors', 'no_selected_tags');
497489

498490
return $this->redirectToTag($tag);

bundle/Core/Pagination/Pagerfanta/ChildrenTagsAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ final class ChildrenTagsAdapter implements AdapterInterface, TagAdapterInterface
2121
private $tagsService;
2222

2323
/**
24-
* @var int
24+
* @var int|null
2525
*/
2626
private $nbResults;
2727

bundle/Core/Pagination/Pagerfanta/RelatedContentAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ final class RelatedContentAdapter implements AdapterInterface, TagAdapterInterfa
3131
private $configResolver;
3232

3333
/**
34-
* @var int
34+
* @var int|null
3535
*/
3636
private $nbResults;
3737

bundle/Form/Type/FieldType/FieldValueTransformer.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ public function __construct(FieldType $fieldType, Field $field)
3131
$this->field = $field;
3232
}
3333

34+
/**
35+
* @param \Netgen\TagsBundle\Core\FieldType\Tags\Value|null $value
36+
*/
3437
public function transform($value): ?array
3538
{
3639
if (!$value instanceof Value) {
@@ -60,6 +63,9 @@ public function transform($value): ?array
6063
];
6164
}
6265

66+
/**
67+
* @param mixed[]|null $value
68+
*/
6369
public function reverseTransform($value): Value
6470
{
6571
if ($value === null) {

bundle/Form/Type/TagTreeType.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,20 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
5757
{
5858
$builder->addModelTransformer(
5959
new class() implements DataTransformerInterface {
60+
/**
61+
* @param mixed $value
62+
*
63+
* @return mixed
64+
*/
6065
public function transform($value)
6166
{
6267
return $value;
6368
}
6469

65-
public function reverseTransform($value)
70+
/**
71+
* @param mixed $value
72+
*/
73+
public function reverseTransform($value): int
6674
{
6775
return (int) $value;
6876
}

bundle/Resources/config/admin/controllers.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ services:
1515
arguments:
1616
- "@eztags.api.service.tags"
1717
- "@ezpublish.api.service.content_type"
18-
- "@translator"
1918
- "@eztags.pagerfanta.children_tags_adapter"
2019
- "@eztags.pagerfanta.search_tags_adapter"
2120

@@ -33,7 +32,6 @@ services:
3332
public: true
3433
arguments:
3534
- "@eztags.api.service.tags"
36-
- "@translator"
3735

3836
eztags.admin.controller.tree:
3937
class: Netgen\TagsBundle\Controller\Admin\TreeController

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
"require-dev": {
3535
"symfony/var-dumper": "^5.0",
3636
"phpunit/phpunit": "^9.0",
37-
"phpstan/phpstan": "^0.12",
38-
"phpstan/phpstan-strict-rules": "^0.12",
39-
"phpstan/phpstan-symfony": "^0.12",
40-
"phpstan/phpstan-phpunit": "^0.12"
37+
"phpstan/phpstan": "^1.1",
38+
"phpstan/phpstan-strict-rules": "^1.0",
39+
"phpstan/phpstan-symfony": "^1.0",
40+
"phpstan/phpstan-phpunit": "^1.0"
4141
},
4242
"minimum-stability": "dev",
4343
"prefer-stable": true,

phpstan.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ includes:
44

55
parameters:
66
checkMissingIterableValueType: false
7+
checkGenericClassInNonGenericObjectType: false
78

89
ignoreErrors:
910
-
@@ -20,6 +21,7 @@ parameters:
2021
- '#Method .*::getRelatedContent\(\) should return .* but returns .*#'
2122

2223
# Errors caused by public properties in eZ Platform
24+
- '#Property eZ\\Publish\\API\\Repository\\Values\\User\\Limitation::\$limitationValues \(array\) on left side of \?\? is not nullable.#'
2325
- '#eZ\\Publish\\API\\Repository\\Values\\Content\\Query\\Criterion::\$value#'
2426
- '#Call to function is_string\(\) with string will always evaluate to true.#'
2527
- '#Call to function is_array\(\) with array(<.*>)? will always evaluate to true.#'

phpstan.tests.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ parameters:
1111
- '#Access to an undefined property Netgen\\TagsBundle\\API\\Repository\\Values\\Tags\\Tag::\$notDefined.#'
1212
- '#Property Netgen\\TagsBundle\\API\\Repository\\Values\\Tags\\Tag::\$id is not writable.#'
1313
- '#Property Netgen\\TagsBundle\\API\\Repository\\Values\\Tags\\Tag::\$id \(int\) does not accept null.#'
14+
- '#Missing call to parent::setUp\(\) method.#'
15+
- '#Static property .+ is not nullable.#'

0 commit comments

Comments
 (0)