Skip to content

Commit 35f1adb

Browse files
Merge pull request #639 from Jean85/phpstan-v2
Bump to PHP 7.4+ and upgrade to PHPStan v2
2 parents 7594ec2 + c25152c commit 35f1adb

File tree

12 files changed

+66
-24
lines changed

12 files changed

+66
-24
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
php: ["7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"]
18+
php: ["7.4", "8.0", "8.1", "8.2", "8.3"]
1919
composer-flags: [ "" ]
2020
experimental: [ false ]
2121
include:
22-
- php: 7.2
22+
- php: 7.4
2323
composer-flags: "--prefer-lowest"
2424
- php: "8.4" # TODO move that to a normal job once phpspec supports PHP 8.4
2525
composer-flags: "--ignore-platform-req=php+"

CHANGES.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Unreleased
22
==========
33

4+
1.22.0
5+
======
6+
7+
**Removed:**
8+
9+
* Support for PHP 7.2 and 7.3 (@jean85)
10+
411
1.21.0
512
======
613

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
],
1919

2020
"require": {
21-
"php": "^7.2 || 8.0.* || 8.1.* || 8.2.* || 8.3.* || 8.4.*",
21+
"php": "^7.4 || 8.0.* || 8.1.* || 8.2.* || 8.3.* || 8.4.*",
2222
"phpdocumentor/reflection-docblock": "^5.2",
2323
"sebastian/comparator": "^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0",
2424
"doctrine/instantiator": "^1.2 || ^2.0",
@@ -28,7 +28,7 @@
2828
"require-dev": {
2929
"friendsofphp/php-cs-fixer": "^3.40",
3030
"phpspec/phpspec": "^6.0 || ^7.0",
31-
"phpstan/phpstan": "^1.9",
31+
"phpstan/phpstan": "^2.1.13",
3232
"phpunit/phpunit": "^8.0 || ^9.0 || ^10.0"
3333
},
3434

phpstan-baseline.neon

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,67 @@
11
parameters:
22
ignoreErrors:
33
-
4-
message: "#^Parameter \\#1 \\$value of function strval expects bool\\|float\\|int\\|resource\\|string\\|null, mixed given\\.$#"
4+
message: '#^Parameter \#1 \$value of function strval expects bool\|float\|int\|resource\|string\|null, mixed given\.$#'
5+
identifier: argument.type
56
count: 2
67
path: src/Prophecy/Argument/Token/ExactValueToken.php
78

89
-
9-
message: "#^Method Prophecy\\\\Doubler\\\\CachedDoubler\\:\\:createDoubleClass\\(\\) should return class\\-string\\<Prophecy\\\\Doubler\\\\DoubleInterface&T of object\\> but returns class\\-string\\.$#"
10+
message: '#^Method Prophecy\\Doubler\\CachedDoubler\:\:createDoubleClass\(\) should return class\-string\<Prophecy\\Doubler\\DoubleInterface&T of object\> but returns class\-string\.$#'
11+
identifier: return.type
1012
count: 1
1113
path: src/Prophecy/Doubler/CachedDoubler.php
1214

1315
-
14-
message: "#^Method Prophecy\\\\Doubler\\\\Doubler\\:\\:createDoubleClass\\(\\) should return class\\-string\\<Prophecy\\\\Doubler\\\\DoubleInterface&T of object\\> but returns class\\-string\\.$#"
16+
message: '#^Method Prophecy\\Doubler\\Doubler\:\:createDoubleClass\(\) should return class\-string\<Prophecy\\Doubler\\DoubleInterface&T of object\> but returns class\-string\.$#'
17+
identifier: return.type
1518
count: 1
1619
path: src/Prophecy/Doubler/Doubler.php
1720

1821
-
19-
message: "#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(ReflectionIntersectionType\\|ReflectionNamedType\\|string\\)\\: mixed\\)\\|null, Closure\\(string\\)\\: string given\\.$#"
22+
message: '#^Call to function method_exists\(\) with ''ReflectionClass'' and ''isReadOnly'' will always evaluate to true\.$#'
23+
identifier: function.alreadyNarrowedType
2024
count: 1
2125
path: src/Prophecy/Doubler/Generator/ClassMirror.php
2226

2327
-
24-
message: "#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(ReflectionIntersectionType\\|ReflectionNamedType\\)\\: mixed\\)\\|null, Closure\\(ReflectionNamedType\\)\\: string given\\.$#"
28+
message: '#^Call to function method_exists\(\) with ReflectionMethod and ''hasTentativeReturnT…'' will always evaluate to true\.$#'
29+
identifier: function.alreadyNarrowedType
30+
count: 1
31+
path: src/Prophecy/Doubler/Generator/ClassMirror.php
32+
33+
-
34+
message: '#^Parameter \#1 \$callback of function array_map expects \(callable\(ReflectionIntersectionType\|ReflectionNamedType\|string\)\: mixed\)\|null, Closure\(string\)\: string given\.$#'
35+
identifier: argument.type
36+
count: 1
37+
path: src/Prophecy/Doubler/Generator/ClassMirror.php
38+
39+
-
40+
message: '#^PHPDoc tag @var with type static\(Prophecy\\Doubler\\LazyDouble\<U of object\>\) is not subtype of native type \$this\(Prophecy\\Doubler\\LazyDouble\<T of object\>\)\.$#'
41+
identifier: varTag.nativeType
42+
count: 1
43+
path: src/Prophecy/Doubler/LazyDouble.php
44+
45+
-
46+
message: '#^Property Prophecy\\Doubler\\LazyDouble\:\:\$class \(ReflectionClass\<T of object\>\|null\) does not accept ReflectionClass\<U of object\>\.$#'
47+
identifier: assign.propertyType
48+
count: 1
49+
path: src/Prophecy/Doubler/LazyDouble.php
50+
51+
-
52+
message: '#^Call to function method_exists\(\) with ReflectionMethod and ''hasTentativeReturnT…'' will always evaluate to true\.$#'
53+
identifier: function.alreadyNarrowedType
54+
count: 1
55+
path: src/Prophecy/Prophecy/MethodProphecy.php
56+
57+
-
58+
message: '#^Parameter \#1 \$callback of function array_map expects \(callable\(ReflectionIntersectionType\|ReflectionNamedType\)\: mixed\)\|null, Closure\(ReflectionNamedType\)\: string given\.$#'
59+
identifier: argument.type
2560
count: 1
2661
path: src/Prophecy/Prophecy/MethodProphecy.php
2762

2863
-
29-
message: "#^Cannot access offset mixed on mixed\\.$#"
64+
message: '#^Cannot access offset mixed on mixed\.$#'
65+
identifier: offsetAccess.nonOffsetAccessible
3066
count: 1
3167
path: src/Prophecy/Util/ExportUtil.php

src/Prophecy/Argument/Token/ArrayEntryToken.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,8 @@ public function scoreArgument($argument)
6060

6161
$keyScores = array_map(array($this->key,'scoreArgument'), array_keys($argument));
6262
$valueScores = array_map(array($this->value,'scoreArgument'), $argument);
63-
/** @var callable(int|false, int|false): (int|false) $scoreEntry */
64-
$scoreEntry = function ($value, $key) {
65-
return $value && $key ? min(8, ($key + $value) / 2) : false;
63+
$scoreEntry = static function ($value, $key) {
64+
return $value && $key ? (int) min(8, ($key + $value) / 2) : false;
6665
};
6766

6867
return max(array_map($scoreEntry, $valueScores, $keyScores));

src/Prophecy/Comparator/ProphecyComparator.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ public function accepts($expected, $actual): bool
3434
* @param float $delta
3535
* @param bool $canonicalize
3636
* @param bool $ignoreCase
37-
* @param array $processed
38-
*
39-
* @phpstan-param list<array{object, object}> $processed
37+
* @param mixed[] $processed
4038
*/
4139
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = array()): void
4240
{

src/Prophecy/Doubler/Generator/ClassMirror.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,6 @@ function (string $type) use ($class) {
281281
$types[] = 'null';
282282
}
283283

284-
return $types;
284+
return array_values($types);
285285
}
286286
}

src/Prophecy/Exception/Prediction/UnexpectedCallsCountException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class UnexpectedCallsCountException extends UnexpectedCallsException
2222
* @param string $message
2323
* @param MethodProphecy $methodProphecy
2424
* @param int $count
25-
* @param list<Call> $calls
25+
* @param array<Call> $calls
2626
*/
2727
public function __construct($message, MethodProphecy $methodProphecy, $count, array $calls)
2828
{

src/Prophecy/Exception/Prediction/UnexpectedCallsException.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,19 @@
1717

1818
class UnexpectedCallsException extends MethodProphecyException implements PredictionException
1919
{
20-
private $calls = array();
20+
/** @var list<Call> */
21+
private $calls;
2122

2223
/**
2324
* @param string $message
2425
* @param MethodProphecy $methodProphecy
25-
* @param list<Call> $calls
26+
* @param array<Call> $calls
2627
*/
2728
public function __construct($message, MethodProphecy $methodProphecy, array $calls)
2829
{
2930
parent::__construct($message, $methodProphecy);
3031

31-
$this->calls = $calls;
32+
$this->calls = array_values($calls);
3233
}
3334

3435
/**

src/Prophecy/Prediction/CallbackPrediction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function check(array $calls, ObjectProphecy $object, MethodProphecy $meth
4848
{
4949
$callback = $this->callback;
5050

51-
if ($callback instanceof Closure && method_exists('Closure', 'bind') && (new ReflectionFunction($callback))->getClosureThis() !== null) {
51+
if ($callback instanceof Closure && (new ReflectionFunction($callback))->getClosureThis() !== null) {
5252
$callback = Closure::bind($callback, $object) ?? $this->callback;
5353
}
5454

0 commit comments

Comments
 (0)