Skip to content

Commit

Permalink
[PHPStan] Fixed parser list type hinting in ParserDispatcher (#92)
Browse files Browse the repository at this point in the history
For more details see #92

* [PHPDoc] Fixed type hinting related to parser list in ParsingDispatcher

* [PHPStan] Aligned baseline with the changes

* [PHPStan] Fixed deprecated checkGenericClassInNonGenericObjectType conf
  • Loading branch information
alongosz authored May 17, 2024
1 parent 8df1859 commit 14f4d9b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
10 changes: 0 additions & 10 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,6 @@ parameters:
count: 1
path: src/contracts/Input/Handler.php

-
message: "#^Cannot access offset mixed on Ibexa\\\\Contracts\\\\Rest\\\\Input\\\\Parser\\.$#"
count: 1
path: src/contracts/Input/ParsingDispatcher.php

-
message: "#^Method Ibexa\\\\Contracts\\\\Rest\\\\Input\\\\ParsingDispatcher\\:\\:__construct\\(\\) has parameter \\$parsers with no value type specified in iterable type array\\.$#"
count: 1
Expand All @@ -310,11 +305,6 @@ parameters:
count: 1
path: src/contracts/Input/ParsingDispatcher.php

-
message: "#^Method Ibexa\\\\Contracts\\\\Rest\\\\Input\\\\ParsingDispatcher\\:\\:parseMediaTypeVersion\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/contracts/Input/ParsingDispatcher.php

-
message: "#^Method Ibexa\\\\Contracts\\\\Rest\\\\Output\\\\Exceptions\\\\NoVisitorFoundException\\:\\:__construct\\(\\) has parameter \\$classes with no value type specified in iterable type array\\.$#"
count: 1
Expand Down
4 changes: 3 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ parameters:
paths:
- src
- tests
checkGenericClassInNonGenericObjectType: false
treatPhpDocTypesAsCertain: false
ignoreErrors:
-
identifier: missingType.generics
6 changes: 3 additions & 3 deletions src/contracts/Input/ParsingDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ParsingDispatcher
* )
* </code>
*
* @var \Ibexa\Contracts\Rest\Input\Parser[]
* @var array<string, array<string, \Ibexa\Contracts\Rest\Input\Parser>>
*/
protected array $parsers = [];

Expand All @@ -56,7 +56,7 @@ public function __construct(EventDispatcherInterface $eventDispatcher, array $pa
*/
public function addParser(string $mediaType, Parser $parser): void
{
list($mediaType, $version) = $this->parseMediaTypeVersion($mediaType);
[$mediaType, $version] = $this->parseMediaTypeVersion($mediaType);

$this->parsers[$mediaType][$version] = $parser;
}
Expand Down Expand Up @@ -116,7 +116,7 @@ protected function internalParse(array $data, string $mediaType)
*
* @param string $mediaType Ex: text/html; version=1.1
*
* @return array An array with the media-type string, stripped from the version, and the version (1.0 by default)
* @return array{string, string} An array with the media-type string, stripped from the version, and the version (1.0 by default)
*/
protected function parseMediaTypeVersion(string $mediaType): array
{
Expand Down

0 comments on commit 14f4d9b

Please sign in to comment.