Skip to content

Commit e344eaa

Browse files
authored
Merge pull request #142 from nicelocal/master
Switch to MixedReturnStatement, drop Psalm 4 support
2 parents 69d2c9b + 455d96a commit e344eaa

File tree

4 files changed

+24
-67
lines changed

4 files changed

+24
-67
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
}
1111
],
1212
"require": {
13-
"php": "^7.1 || ^8.0",
13+
"php": "^7.4 || ^8.0",
1414
"ext-simplexml": "*",
1515
"composer/semver": "^1.4 || ^2.0 || ^3.0",
1616
"composer/package-versions-deprecated": "^1.10",
17-
"vimeo/psalm": "dev-master || dev-4.x || ^4.7.1 || ^5@beta || ^5.0"
17+
"vimeo/psalm": "dev-master || ^5@beta || ^5.0"
1818
},
1919
"conflict": {
2020
"phpunit/phpunit": "<7.5"

src/Hooks/TestCaseHandler.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ public static function afterClassLikeVisit(AfterClassLikeVisitEvent $event)
106106

107107
/**
108108
* {@inheritDoc}
109+
*
110+
* @psalm-suppress DeprecatedClass TList will be removed soon
109111
*/
110112
public static function afterStatementAnalysis(AfterClassLikeAnalysisEvent $event)
111113
{

tests/acceptance/Prophecy.feature

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -74,27 +74,7 @@ Feature: Prophecy
7474
When I run Psalm
7575
Then I see no errors
7676

77-
Scenario: Argument::that() only accepts callable with boolean return type [Psalm 4]
78-
Given I have the following code
79-
"""
80-
class MyTestCase extends TestCase
81-
{
82-
/** @return void */
83-
public function testSomething() {
84-
$_argument = Argument::that(function (): string {
85-
return 'hello';
86-
});
87-
}
88-
}
89-
"""
90-
And I have Psalm older than "5.0" (because of "changed issue type")
91-
When I run Psalm
92-
Then I see these errors
93-
| Type | Message |
94-
| InvalidScalarArgument | /Argument 1 of Prophecy\\Argument::that expects callable\(mixed...\):bool, (but )?(pure-)?Closure\(\):(string\(hello\)\|"hello"\|'hello') provided/ |
95-
And I see no other errors
96-
97-
Scenario: Argument::that() only accepts callable with boolean return type [Psalm 5]
77+
Scenario: Argument::that() only accepts callable with boolean return type
9878
Given I have the following code
9979
"""
10080
class MyTestCase extends TestCase

tests/acceptance/TestCase.feature

Lines changed: 19 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -612,31 +612,7 @@ Feature: TestCase
612612
When I run Psalm
613613
Then I see no errors
614614

615-
Scenario: Provider omitting offsets is fine when test method has defaults for those params (specified as constants) [Psalm 4]
616-
Given I have the following code
617-
"""
618-
class MyTestCase extends TestCase
619-
{
620-
/** @var string */
621-
const S = "s";
622-
/** @return iterable<string,array{0:int}> */
623-
public function provide() {
624-
yield "data set name" => rand(0,1) ? [1] : [1, "ss"];
625-
}
626-
/**
627-
* @return void
628-
* @dataProvider provide
629-
*/
630-
public function testSomething(int $int, string $_str = self::S) {
631-
$this->assertEquals(1, $int);
632-
}
633-
}
634-
"""
635-
And I have Psalm older than "5.0" (because of "sealed shapes")
636-
When I run Psalm
637-
Then I see no errors
638-
639-
Scenario: Provider omitting offsets is fine when test method has defaults for those params (specified as constants) [Psalm 5]
615+
Scenario: Provider omitting offsets is fine when test method has defaults for those params (specified as constants)
640616
Given I have the following code
641617
"""
642618
class MyTestCase extends TestCase
@@ -1000,7 +976,7 @@ Feature: TestCase
1000976
Given I have the following code
1001977
"""
1002978
class MyTestCase extends TestCase {
1003-
/** @return iterable<string,array{float,1?:string}> */
979+
/** @return iterable<string,array{0: float, 1?:string}> */
1004980
public function provide() {
1005981
yield "data set" => [1., "a"];
1006982
}
@@ -1173,21 +1149,6 @@ Feature: TestCase
11731149
When I run Psalm
11741150
Then I see no errors
11751151

1176-
@ExternalProviders
1177-
Scenario: Missing external provider classes are reported
1178-
Given I have the following code
1179-
"""
1180-
class MyTestCase extends TestCase {
1181-
/** @dataProvider External::provide */
1182-
public function testSomething(int $_p): void {}
1183-
}
1184-
"""
1185-
When I run Psalm
1186-
Then I see these errors
1187-
| Type | Message |
1188-
| UndefinedClass | Class NS\External does not exist |
1189-
1190-
11911152
@ExternalProviders
11921153
Scenario: External providers are not marked as unused
11931154
Given I have the following code
@@ -1260,12 +1221,26 @@ Feature: TestCase
12601221
When I run Psalm on "test.php"
12611222
Then I see no errors
12621223

1224+
@ExternalProviders
1225+
Scenario: Missing external provider classes are reported
1226+
Given I have the following code
1227+
"""
1228+
class MyTestCase extends TestCase {
1229+
/** @dataProvider External::provide */
1230+
public function testSomething(int $_p): void {}
1231+
}
1232+
"""
1233+
When I run Psalm
1234+
Then I see these errors
1235+
| Type | Message |
1236+
| UndefinedClass | Class NS\External does not exist |
1237+
12631238
@List
12641239
Scenario: Providers returning list are ok
12651240
Given I have the following code
12661241
"""
12671242
class MyTestCase extends TestCase {
1268-
/** @return iterable<string, list<int>> */
1243+
/** @return iterable<string, non-empty-list<int>> */
12691244
public function provide(): iterable {
12701245
yield "dataset name" => [1];
12711246
}
@@ -1281,7 +1256,7 @@ Feature: TestCase
12811256
Given I have the following code
12821257
"""
12831258
class MyTestCase extends TestCase {
1284-
/** @return iterable<string, list<string>> */
1259+
/** @return iterable<string, non-empty-list<string>> */
12851260
public function provide(): iterable {
12861261
yield "dataset name" => ["1"];
12871262
}
@@ -1292,7 +1267,7 @@ Feature: TestCase
12921267
When I run Psalm
12931268
Then I see these errors
12941269
| Type | Message |
1295-
| InvalidArgument | Argument 1 of NS\MyTestCase::testSomething expects int, string provided by NS\MyTestCase::provide():(iterable<string, list<string>>) |
1270+
| InvalidArgument | Argument 1 of NS\MyTestCase::testSomething expects int, string provided by NS\MyTestCase::provide():(iterable<string, non-empty-list<string>>) |
12961271

12971272
Scenario: Providers returning nullable generator are ok
12981273
Given I have the following code

0 commit comments

Comments
 (0)