Skip to content

Commit c538257

Browse files
chore: more phpstan fixes
1 parent 078b1a6 commit c538257

File tree

7 files changed

+20
-15
lines changed

7 files changed

+20
-15
lines changed

phpstan.neon.dist

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,18 @@ parameters:
5454
- tests/Fixtures/TestBundle/Document/
5555
- tests/Fixtures/TestBundle/Entity/
5656
- src/OpenApi/Factory/OpenApiFactory.php
57+
-
58+
message: '#is never assigned .* so it can be removed from the property type.#'
59+
paths:
60+
- src/Doctrine/Common/Tests/Fixtures/
61+
- src/Doctrine/Orm/Tests/Fixtures/
62+
- src/Doctrine/Odm/Tests/Fixtures/
63+
- src/Elasticsearch/Tests/Fixtures/
64+
- src/GraphQl/Tests/Fixtures/
65+
- src/JsonSchema/Tests/Fixtures/
66+
- src/Metadata/Tests/Fixtures/
67+
- src/Serializer/Tests/Fixtures/
68+
- tests/Fixtures/
5769
-
5870
message: '#is never written, only read.#'
5971
paths:
@@ -101,14 +113,5 @@ parameters:
101113
- '#^Call to (static )?method PHPUnit\\Framework\\Assert::.* will always evaluate to true\.$#'
102114

103115
# TODO For PHPStan 2.0
104-
-
105-
path: tests/
106-
identifier: function.alreadyNarrowedType
107-
-
108-
identifier: property.unusedType
109116
-
110117
identifier: varTag.nativeType
111-
-
112-
identifier: trait.unused
113-
-
114-
identifier: catch.neverThrown

src/Metadata/ApiProperty.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public function __construct(
230230
private array $extraProperties = [],
231231
) {
232232
$this->types = \is_string($types) ? (array) $types : $types;
233-
$this->serialize = \is_array($serialize) ? $serialize : [$serialize];
233+
$this->serialize = (null === $serialize || \is_array($serialize)) ? $serialize : [$serialize];
234234
$this->nativeType = $nativeType;
235235

236236
if ($this->builtinTypes) {

src/Metadata/IdentifiersExtractorInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace ApiPlatform\Metadata;
1515

16+
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
1617
use ApiPlatform\Metadata\Exception\RuntimeException;
1718

1819
/**
@@ -28,6 +29,7 @@ interface IdentifiersExtractorInterface
2829
* @param array<string, mixed> $context
2930
*
3031
* @throws RuntimeException
32+
* @throws InvalidArgumentException
3133
*
3234
* @return array<string, mixed>
3335
*/

src/Metadata/IriConverterInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
1717
use ApiPlatform\Metadata\Exception\ItemNotFoundException;
18+
use ApiPlatform\Metadata\Exception\OperationNotFoundException;
1819
use ApiPlatform\Metadata\Exception\RuntimeException;
1920

2021
/**
@@ -40,6 +41,7 @@ public function getResourceFromIri(string $iri, array $context = [], ?Operation
4041
* @param object|class-string $resource
4142
* @param array<string, mixed>|array{force_resource_class?: string|class-string, item_uri_template?: string, uri_variables?: array<string, string>} $context
4243
*
44+
* @throws OperationNotFoundException
4345
* @throws InvalidArgumentException
4446
* @throws RuntimeException
4547
*/

src/Metadata/IsApiResource.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
/**
1717
* @author Kévin Dunglas <[email protected]>
18+
*
19+
* @phpstan-ignore trait.unused
1820
*/
1921
trait IsApiResource
2022
{

tests/Behat/JsonApiContext.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,6 @@ public function theJsonNodeShouldBeSorted(string $node = ''): void
121121
{
122122
$actual = (array) $this->getValueOfNode($node);
123123

124-
if (!\is_array($actual)) {
125-
throw new \Exception(\sprintf('The "%s" node value is not an array', $node));
126-
}
127-
128124
$expected = $actual;
129125
ksort($expected);
130126

tests/Fixtures/TestBundle/Security/SecuredDummyAttributeBasedVoter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ protected function voteOnAttribute(string $attribute, mixed $subject, TokenInter
4545
return false;
4646
}
4747

48-
if (!\in_array($subject, array_keys(self::RBAC), true) || !\is_array(self::RBAC[$subject])) {
48+
if (!array_key_exists($subject, self::RBAC)) {
4949
return false;
5050
}
5151

0 commit comments

Comments
 (0)