-
-
Notifications
You must be signed in to change notification settings - Fork 968
chore: introduce phpstan level 6 #7269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| parameters: | ||
| level: 5 | ||
| level: 6 | ||
| paths: | ||
| - src | ||
| - tests | ||
|
|
@@ -112,3 +112,63 @@ parameters: | |
|
|
||
| # Allow extra assertions in tests: https://github.com/phpstan/phpstan-strict-rules/issues/130 | ||
| - '#^Call to (static )?method PHPUnit\\Framework\\Assert::.* will always evaluate to true\.$#' | ||
|
|
||
| # Level 6 | ||
| - | ||
| identifier: missingType.iterableValue | ||
| - | ||
| identifier: missingType.generics | ||
| - | ||
| identifier: missingType.property | ||
| paths: | ||
| - src/Doctrine/Common/Tests | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ignored all the tests folder. |
||
| - src/Doctrine/Odm/Tests | ||
| - src/Doctrine/Orm/Tests | ||
| - src/Elasticsearch/Tests | ||
| - src/Hydra/Tests | ||
| - src/JsonApi/Tests | ||
| - src/JsonSchema/Tests | ||
| - src/Metadata/Tests | ||
| - src/Serializer/Tests | ||
| - src/Symfony/Tests | ||
| - tests | ||
| - | ||
| identifier: missingType.parameter | ||
| paths: | ||
| - src/Doctrine/Common/Tests | ||
| - src/Doctrine/Odm/Tests | ||
| - src/Doctrine/Orm/Tests | ||
| - src/Elasticsearch/Tests | ||
| - src/GraphQl/Tests | ||
| - src/Hydra/Tests | ||
| - src/JsonApi/Tests | ||
| - src/JsonSchema/Tests | ||
| - src/Metadata/Tests | ||
| - src/OpenApi/Tests | ||
| - src/Serializer/Tests | ||
| - src/Symfony/Bundle/Test | ||
| - src/Symfony/Tests | ||
| - tests | ||
| - src # TODO | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Parameter is ~150 error, I'll do it in the next PR. |
||
| - | ||
| identifier: missingType.return | ||
| paths: | ||
| - src/Doctrine/Common/Tests | ||
| - src/Doctrine/Odm/Tests | ||
| - src/Doctrine/Orm/Tests | ||
| - src/Elasticsearch/Tests | ||
| - src/GraphQl/Tests | ||
| - src/Hydra/Tests | ||
| - src/JsonApi/Tests | ||
| - src/JsonSchema/Tests | ||
| - src/Metadata/Tests | ||
| - src/OpenApi/Tests | ||
| - src/Serializer/Tests | ||
| - src/Symfony/Tests | ||
| - tests | ||
| - | ||
| identifier: argument.templateType | ||
| paths: | ||
| - src/Symfony/Bundle/Test | ||
| - tests | ||
| - src # TODO | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's around 50 error, I'll try in another PR. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,7 +103,7 @@ | |
| { | ||
| $uriVariables = []; | ||
| foreach ($operation->getUriVariables() ?? [] as $parameterName => $_) { | ||
| $parameter = $request->route($parameterName); | ||
| $parameter = $request->route((string) $parameterName); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mhh actually this is weird, it's a hard problem though maybe we'll leave that for later ^^
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is an error saying that You prefer a phpstan-ignore-line ? |
||
| if (\is_string($parameter) && ($format = $request->attributes->get('_format')) && str_contains($parameter, $format)) { | ||
| $parameter = substr($parameter, 0, \strlen($parameter) - (\strlen($format) + 1)); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,13 +48,13 @@ final class ApiProperty | |
| * @param bool|null $push https://api-platform.com/docs/core/push-relations/ | ||
| * @param string|\Stringable|null $security https://api-platform.com/docs/core/security | ||
| * @param string|\Stringable|null $securityPostDenormalize https://api-platform.com/docs/core/security/#executing-access-control-rules-after-denormalization | ||
| * @param string[] $types the RDF types of this property | ||
| * @param string[] $iris | ||
| * @param LegacyType[] $builtinTypes | ||
| * @param string[]|null $types the RDF types of this property | ||
| * @param string[]|null $iris | ||
| * @param LegacyType[]|null $builtinTypes | ||
| * @param string|null $uriTemplate (experimental) whether to return the subRessource collection IRI instead of an iterable of IRI | ||
| * @param string|null $property The property name | ||
| * @param Context|Groups|Ignore|SerializedName|SerializedPath|MaxDepth|array<array-key, Context|Groups|Ignore|SerializedName|SerializedPath|MaxDepth> $serialize Serializer attributes | ||
| * @param Type $nativeType The internal PHP type | ||
| * @param Type|null $nativeType The internal PHP type | ||
| */ | ||
| public function __construct( | ||
| private ?string $description = null, | ||
|
|
@@ -345,12 +345,12 @@ public function withIdentifier(bool $identifier): static | |
| return $self; | ||
| } | ||
|
|
||
| public function getDefault() | ||
| public function getDefault(): mixed | ||
| { | ||
| return $this->default; | ||
| } | ||
|
|
||
| public function withDefault($default): static | ||
| public function withDefault(mixed $default): static | ||
| { | ||
| $self = clone $this; | ||
| $self->default = $default; | ||
|
|
@@ -507,7 +507,7 @@ public function withTypes(array|string $types = []): static | |
| /** | ||
| * deprecated since 4.2, use "getNativeType" instead. | ||
| * | ||
| * @return LegacyType[] | ||
| * @return LegacyType[]|null | ||
| */ | ||
| public function getBuiltinTypes(): ?array | ||
| { | ||
|
|
@@ -587,6 +587,8 @@ public function withExtraProperties(array $extraProperties = []): static | |
|
|
||
| /** | ||
| * Gets IRI of this property. | ||
| * | ||
| * @return string[]|null | ||
| */ | ||
| public function getIris() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we change the return type to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, done with c29eb43 |
||
| { | ||
|
|
@@ -609,7 +611,7 @@ public function withIris(string|array $iris): static | |
| /** | ||
| * Whether to generate a skolem iri on anonymous resources. | ||
| */ | ||
| public function getGenId() | ||
| public function getGenId(): ?bool | ||
| { | ||
| return $this->genId; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -110,10 +110,10 @@ private function buildValues(\SimpleXMLElement $resource): array | |
| return $data; | ||
| } | ||
|
|
||
| private function buildArrayValue(?\SimpleXMLElement $resource, string $key, mixed $default = null) | ||
| private function buildArrayValue(?\SimpleXMLElement $resource, string $key): ?array | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. default is never used |
||
| { | ||
| if (!isset($resource->{$key.'s'}->{$key})) { | ||
| return $default; | ||
| return null; | ||
| } | ||
|
|
||
| return (array) $resource->{$key.'s'}->{$key}; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iterableValueandgenericsare creating a lot of error, so I prefer to fix missing param/property/return type first