Skip to content

Commit

Permalink
phpstan level 6
Browse files Browse the repository at this point in the history
  • Loading branch information
christeredvartsen committed Jan 7, 2025
1 parent e0a8e8f commit 81aa968
Show file tree
Hide file tree
Showing 13 changed files with 136 additions and 18 deletions.
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
},
"require-dev": {
"imbo/imbo-coding-standard": "^2.0",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-phpunit": "^2.0",
"phpunit/phpunit": "^11.5",
"slim/psr7": "^1.3",
"slim/slim": "^4.7",
Expand Down Expand Up @@ -65,6 +67,9 @@
"docs": "cd docs; make html"
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"phpstan/extension-installer": true
}
}
}
101 changes: 100 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
parameters:
level: 5
level: 6
paths:
- src
- tests
- tests
ignoreErrors:
-
message: '#Method [a-zA-Z0-9\\_]+::test#'
identifier: missingType.iterableValue
path: tests
10 changes: 7 additions & 3 deletions src/ArrayContainsComparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function getMatcherFunction(string $name): callable
* To clarify, the method (and other methods in the class) refers to "lists" and "objects". A
* "list" is a numerically indexed array, and an "object" is an associative array.
*
* @param array<scalar|array> $needle
* @param array<scalar|array<mixed>> $needle
* @param array<mixed> $haystack
*/
public function compare(array $needle, array $haystack): bool
Expand Down Expand Up @@ -239,8 +239,8 @@ protected function compareValues(mixed $needleValue, mixed $haystackValue): bool
/**
* Make sure all values in the $needle array is present in the $haystack array
*
* @param array<array|scalar> $needle
* @param array $haystack
* @param array<array<mixed>|scalar> $needle
* @param array<mixed> $haystack
*/
protected function inArray(array $needle, array $haystack): bool
{
Expand Down Expand Up @@ -350,6 +350,8 @@ protected function inArray(array $needle, array $haystack): bool

/**
* See if a PHP array is a JSON array
*
* @param array<mixed> $array
*/
protected function arrayIsList(array $array): bool
{
Expand All @@ -360,6 +362,8 @@ protected function arrayIsList(array $array): bool

/**
* See if a PHP array is a JSON object
*
* @param array<mixed> $array
*/
protected function arrayIsObject(array $array): bool
{
Expand Down
2 changes: 1 addition & 1 deletion src/ArrayContainsComparator/Matcher/ArrayLength.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ArrayLength
/**
* Match the exact length of an array
*
* @param array $array An array
* @param array<mixed> $array An array
* @param int|string $length The expected exact length of $array
* @throws InvalidArgumentException
*/
Expand Down
2 changes: 1 addition & 1 deletion src/ArrayContainsComparator/Matcher/ArrayMaxLength.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ArrayMaxLength
/**
* Match the max length of an array
*
* @param array $array An array
* @param array<mixed> $array An array
* @param int|string $maxLength The expected maximum length of $array
* @throws InvalidArgumentException
*/
Expand Down
2 changes: 1 addition & 1 deletion src/ArrayContainsComparator/Matcher/ArrayMinLength.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ArrayMinLength
/**
* Match the min length of an array
*
* @param array $array An array
* @param array<mixed> $array An array
* @param int|string $minLength The expected minimum length of $array
* @throws InvalidArgumentException
*/
Expand Down
4 changes: 3 additions & 1 deletion src/ArrayContainsComparator/Matcher/JWT.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class JWT
/**
* JWT tokens present in the response body
*
* @var array<string,array{payload:array,secret:string}>
* @var array<string,array{payload:array<mixed>,secret:string}>
*/
private array $jwtTokens = [];

Expand All @@ -41,6 +41,8 @@ public function __construct(Comparator $comparator)

/**
* Add a JWT token that can be matched
*
* @param array<mixed> $payload
*/
public function addToken(string $name, array $payload, string $secret): self
{
Expand Down
2 changes: 2 additions & 0 deletions src/Context/ApiClientAwareContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ interface ApiClientAwareContext extends Context
{
/**
* Initialize the Guzzle client
*
* @param array<mixed> $config
*/
public function initializeClient(array $config): self;
}
3 changes: 2 additions & 1 deletion src/Context/ApiContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class ApiContext implements ApiClientAwareContext, ArrayContainsComparatorAwareC
/**
* Set the client instance
*
* @param array<mixed> $config
* @throws InvalidArgumentException
*/
public function initializeClient(array $config): static
Expand Down Expand Up @@ -1409,7 +1410,7 @@ protected function getResponseBody(): array|stdClass
* Get the response body as an array
*
* @throws InvalidArgumentException
* @return array
* @return array<mixed>
*/
protected function getResponseBodyArray(): array
{
Expand Down
4 changes: 2 additions & 2 deletions src/Context/Initializer/ApiClientAwareInitializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
class ApiClientAwareInitializer implements ContextInitializer
{
/**
* @var array Guzzle client configuration array
* @var array<mixed> Guzzle client configuration array
* @see http://docs.guzzlephp.org/ Check out the Guzzle docs for a complete overview of available configuration parameters
*/
private array $config = [];

/**
* Class constructor
*
* @param array $config Guzzle client configuration array
* @param array<mixed> $config Guzzle client configuration array
*/
public function __construct(array $config)
{
Expand Down
2 changes: 1 addition & 1 deletion src/ServiceContainer/BehatApiExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function configure(ArrayNodeDefinition $builder): void
}

/**
* @param array $config Guzzle client configuration array
* @param array{apiClient:array<mixed>} $config Guzzle client configuration array
* @see http://docs.guzzlephp.org/ Check out the Guzzle docs for a complete overview of available configuration parameters
*/
public function load(ContainerBuilder $container, array $config): void
Expand Down
6 changes: 3 additions & 3 deletions tests/ArrayContainsComparatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function setUp(): void
}

/**
* @return array<string,array{needle:array,haystack:array}>
* @return array<string,array{needle:array<mixed>,haystack:array<mixed>}>
*/
public static function getDataForInArrayCheck(): array
{
Expand Down Expand Up @@ -165,7 +165,7 @@ public static function getDataForInArrayCheck(): array
}

/**
* @return array<string,array{needle:array,haystack:array}>
* @return array<string,array{needle:array<mixed>,haystack:array<mixed>}>
*/
public static function getDataForCompareCheck(): array
{
Expand Down Expand Up @@ -210,7 +210,7 @@ public static function getDataForCompareCheck(): array
}

/**
* @return array<array{needle:array,haystack:array}>
* @return array<array{needle:array<mixed>,haystack:array<mixed>}>
*/
public static function getDataForSpecificKeyInListChecks(): array
{
Expand Down

0 comments on commit 81aa968

Please sign in to comment.