mirror of
https://github.com/danog/psalm-plugin-phpunit.git
synced 2024-11-30 04:29:08 +01:00
Merge pull request #28 from weirdan/dont-crash-on-untyped-providers
Fix psalm/phpunit-psalm-plugin#27
This commit is contained in:
commit
c370c35cfe
@ -175,7 +175,10 @@ class TestCaseHandler implements
|
||||
}
|
||||
|
||||
$provider_return_type = $codebase->getMethodReturnType($provider_method_id, $_);
|
||||
assert(null !== $provider_return_type);
|
||||
|
||||
if (!$provider_return_type) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$provider_return_type_string = $provider_return_type->getId();
|
||||
|
||||
|
@ -981,3 +981,21 @@ Feature: TestCase
|
||||
| Type | Message |
|
||||
| InvalidArgument | Argument 2 of NS\MyTestCase::testSomething expects float, string provided by NS\MyTestCase::provide():(iterable<string, array{0:float, 1?:string}>) |
|
||||
And I see no other errors
|
||||
|
||||
Scenario: Untyped providers returns are not checked against test method signatures
|
||||
Given I have the following code
|
||||
"""
|
||||
class MyTestCase extends TestCase {
|
||||
/** @psalm-suppress MissingReturnType */
|
||||
public function provide() {
|
||||
yield "data set" => ["a"];
|
||||
}
|
||||
/**
|
||||
* @dataProvider provide
|
||||
* @return void
|
||||
*/
|
||||
public function testSomething(string $_s) {}
|
||||
}
|
||||
"""
|
||||
When I run Psalm with dead code detection
|
||||
Then I see no errors
|
||||
|
Loading…
Reference in New Issue
Block a user