Merge pull request #28 from weirdan/dont-crash-on-untyped-providers

Fix psalm/phpunit-psalm-plugin#27
This commit is contained in:
Bruce Weirdan 2019-03-06 23:06:03 +02:00 committed by GitHub
commit c370c35cfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View File

@ -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();

View File

@ -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