Skip to content

Commit 60840c0

Browse files
committed
Upgrade PHPStan version
Also install "phpstan/extension-installer" to make it simpler to install extensions.
1 parent a974c0c commit 60840c0

File tree

8 files changed

+17
-19
lines changed

8 files changed

+17
-19
lines changed

composer.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"config": {
1515
"sort-packages": true,
1616
"allow-plugins": {
17-
"dealerdirect/phpcodesniffer-composer-installer": true
17+
"dealerdirect/phpcodesniffer-composer-installer": true,
18+
"phpstan/extension-installer": true
1819
}
1920
},
2021
"require": {
@@ -28,9 +29,10 @@
2829
"malukenho/docheader": "^1.0",
2930
"mikey179/vfsstream": "^1.6",
3031
"nette/php-generator": "^4.1",
31-
"phpstan/phpstan": "^1.10",
32-
"phpstan/phpstan-deprecation-rules": "^1.1",
33-
"phpstan/phpstan-phpunit": "^1.3",
32+
"phpstan/extension-installer": "^1.4",
33+
"phpstan/phpstan": "^2.0",
34+
"phpstan/phpstan-deprecation-rules": "^2.0",
35+
"phpstan/phpstan-phpunit": "^2.0",
3436
"phpunit/phpunit": "^10.5",
3537
"psr/http-message": "^1.0 || ^2.0",
3638
"respect/coding-standard": "^4.0",

library/Rules/ContainsAny.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ final class ContainsAny extends Envelope
2525
/** @param non-empty-array<mixed> $needles */
2626
public function __construct(array $needles, bool $identical = false)
2727
{
28-
// @phpstan-ignore-next-line
2928
if (empty($needles)) {
3029
throw new InvalidRuleConstructorException('At least one value must be provided');
3130
}

library/Rules/Ip.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ private function parseRange(string $input): void
102102
if (mb_strpos($input, '-') !== false) {
103103
[$this->startAddress, $this->endAddress] = explode('-', $input);
104104

105-
if ($this->startAddress !== null && !$this->verifyAddress($this->startAddress)) {
105+
if (is_string($this->startAddress) && !$this->verifyAddress($this->startAddress)) {
106106
throw new InvalidRuleConstructorException('Invalid network range');
107107
}
108108

109-
if ($this->endAddress !== null && !$this->verifyAddress($this->endAddress)) {
109+
if (is_string($this->endAddress) && !$this->verifyAddress($this->endAddress)) {
110110
throw new InvalidRuleConstructorException('Invalid network range');
111111
}
112112

library/Rules/Nif.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ private function validateCif(string $number, string $control): bool
7272
{
7373
$code = 0;
7474
$position = 1;
75-
/** @var int $digit */
7675
foreach (str_split($number) as $digit) {
76+
$digit = (int) $digit;
7777
$increaser = $digit;
7878
if ($position % 2 !== 0) {
7979
$increaser = array_sum(str_split((string) ($digit * 2)));

library/Rules/NotBlank.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ private function isBlank(mixed $input): bool
5656
}
5757

5858
if (is_array($input)) {
59-
$input = array_filter($input, __METHOD__);
59+
$input = array_filter($input, fn($value) => $this->isBlank($value));
6060
}
6161

6262
return !empty($input);

phpstan.neon.dist

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
includes:
2-
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
3-
- vendor/phpstan/phpstan-phpunit/extension.neon
4-
- vendor/phpstan/phpstan-phpunit/rules.neon
51
parameters:
62
fileExtensions:
73
- php
@@ -34,6 +30,7 @@ parameters:
3430
- message: '/Call to an undefined static method Respect\\Validation\\Validator::type\(\)./'
3531
path: tests/integration/transformers/deprecated_type.phpt
3632
level: 8
33+
treatPhpDocTypesAsCertain: false
3734
paths:
3835
- library/
3936
- tests/

tests/library/Stubs/CountableStub.php

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

1414
final class CountableStub implements Countable
1515
{
16+
/**
17+
* @param positive-int $value
18+
*/
1619
public function __construct(
1720
private readonly int $value
1821
) {
1922
}
2023

24+
/**
25+
* @return positive-int
26+
*/
2127
public function count(): int
2228
{
2329
return $this->value;

tests/unit/ValidatorTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@
2020
#[CoversClass(Validator::class)]
2121
final class ValidatorTest extends TestCase
2222
{
23-
#[Test]
24-
public function staticCreateShouldReturnNewValidator(): void
25-
{
26-
self::assertInstanceOf(Validator::class, Validator::create());
27-
}
28-
2923
#[Test]
3024
public function invalidRuleClassShouldThrowComponentException(): void
3125
{

0 commit comments

Comments
 (0)