Skip to content

Commit 7e1f389

Browse files
authored
Merge pull request #878 from stof/improve_phpstan
Improve the phpstan setup
2 parents 4897dc4 + 05ffb4e commit 7e1f389

7 files changed

Lines changed: 23 additions & 2 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
},
2121

2222
"require-dev": {
23-
"phpstan/phpstan": "^1.10",
23+
"phpstan/phpstan": "^1.12.32",
2424
"phpstan/phpstan-phpunit": "^1.3",
2525
"phpunit/phpunit": "^8.5.22 || ^9.5.11",
2626
"symfony/error-handler": "^4.4 || ^5.0 || ^6.0 || ^7.0",

phpstan.dist.neon

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@ parameters:
33
paths:
44
- src
55
- tests
6-
checkMissingIterableValueType: false
76
checkMissingCallableSignature: true
87
treatPhpDocTypesAsCertain: false
98
ignoreErrors:
109
- '#^Method Behat\\Mink\\Tests\\[^:]+Test(Case)?\:\:test\w*\(\) has no return type specified\.$#'
1110
- '#^Method Behat\\Mink\\Tests\\[^:]+Test(Case)?\:\:provide\w*\(\) has no return type specified\.$#'
1211
- '#^Method Behat\\Mink\\Tests\\[^:]+Test(Case)?\:\:get\w*\(\) has no return type specified\.$#'
12+
-
13+
message: '#^Method Behat\\Mink\\[^:]+\:\:\w+\(\) has parameter \$selector with no value type specified in iterable type array\.$#'
14+
identifier: missingType.iterableValue
15+
-
16+
message: '#^Method Behat\\Mink\\[^:]+\:\:\w+\(\) has parameter \$locator with no value type specified in iterable type array\.$#'
17+
identifier: missingType.iterableValue
1318

1419
includes:
1520
- vendor/phpstan/phpstan-phpunit/extension.neon

src/Driver/CoreDriver.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,8 @@ public function getAttribute(string $xpath, string $name)
388388
*
389389
* @return string|bool|array|null
390390
*
391+
* @phpstan-return string|bool|list<string>|null
392+
*
391393
* @throws UnsupportedDriverActionException When operation not supported by the driver
392394
* @throws DriverException When the operation cannot be done
393395
*/
@@ -400,6 +402,8 @@ public function getValue(string $xpath)
400402
* @param string $xpath
401403
* @param string|bool|array $value
402404
*
405+
* @phpstan-param string|bool|list<string> $value
406+
*
403407
* @return void
404408
*
405409
* @throws UnsupportedDriverActionException When operation not supported by the driver

src/Driver/DriverInterface.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,8 @@ public function getAttribute(
396396
*
397397
* @return string|bool|array|null
398398
*
399+
* @phpstan-return string|bool|list<string>|null
400+
*
399401
* @throws UnsupportedDriverActionException When operation not supported by the driver
400402
* @throws DriverException When the operation cannot be done
401403
*/
@@ -412,6 +414,8 @@ public function getValue(
412414
* @param string $xpath
413415
* @param string|bool|array $value
414416
*
417+
* @phpstan-param string|bool|list<string> $value
418+
*
415419
* @return void
416420
*
417421
* @throws UnsupportedDriverActionException When operation not supported by the driver

src/Element/NodeElement.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ public function getTagName()
9696
* Calling this method on other elements than form fields or option elements is not allowed.
9797
*
9898
* @return string|bool|array|null
99+
*
100+
* @phpstan-return string|bool|list<string>|null
99101
*/
100102
public function getValue()
101103
{
@@ -109,6 +111,8 @@ public function getValue()
109111
*
110112
* @param string|bool|array $value
111113
*
114+
* @phpstan-param string|bool|list<string> $value
115+
*
112116
* @return void
113117
*
114118
* @see NodeElement::getValue for the format of the value for each type of field

src/Element/TraversableElement.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ public function findField(string $locator)
149149
* @param string $locator input id, name or label
150150
* @param string|bool|array $value value
151151
*
152+
* @phpstan-param string|bool|list<string> $value
153+
*
152154
* @return void
153155
*
154156
* @throws ElementNotFoundException

tests/SessionTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ public function testGetResponseHeaders()
175175
}
176176

177177
/**
178+
* @param array<string, string|list<string>> $headers
179+
*
178180
* @dataProvider provideResponseHeader
179181
*/
180182
public function testGetResponseHeader(?string $expected, string $name, array $headers)

0 commit comments

Comments
 (0)