Skip to content

Commit 72cf8ba

Browse files
janedbalondrejmirtes
authored andcommitted
ImmediatelyCalledFunctionWithoutImplicitThrowTest
1 parent 70a75f6 commit 72cf8ba

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace PHPStan\Analyser;
4+
5+
use PHPStan\Testing\TypeInferenceTestCase;
6+
7+
class ImmediatelyCalledFunctionWithoutImplicitThrowTest extends TypeInferenceTestCase
8+
{
9+
10+
public function dataFileAsserts(): iterable
11+
{
12+
yield from $this->gatherAssertTypes(__DIR__ . '/data/immediately-called-function-without-implicit-throw.php');
13+
}
14+
15+
/**
16+
* @dataProvider dataFileAsserts
17+
* @param mixed ...$args
18+
*/
19+
public function testFileAsserts(
20+
string $assertType,
21+
string $file,
22+
...$args,
23+
): void
24+
{
25+
$this->assertFileAsserts($assertType, $file, ...$args);
26+
}
27+
28+
public static function getAdditionalConfigFiles(): array
29+
{
30+
return array_merge(
31+
parent::getAdditionalConfigFiles(),
32+
[__DIR__ . '/data/immediately-called-function-without-implicit-throw.neon']
33+
);
34+
}
35+
36+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
parameters:
2+
exceptions:
3+
implicitThrows: false
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace ImmediatelyCalledFunctionWithoutImplicitThrow;
4+
5+
use PHPStan\TrinaryLogic;
6+
use function PHPStan\Testing\assertVariableCertainty;
7+
8+
try {
9+
$result = array_map('ucfirst', []);
10+
} finally {
11+
assertVariableCertainty(TrinaryLogic::createYes(), $result);
12+
}
13+
14+
class SomeClass
15+
{
16+
17+
public function noThrow(): void
18+
{
19+
}
20+
21+
public function testFirstClassCallableNoThrow(): void
22+
{
23+
try {
24+
$result = array_map($this->noThrow(...), []);
25+
} finally {
26+
assertVariableCertainty(TrinaryLogic::createYes(), $result);
27+
}
28+
}
29+
30+
}

0 commit comments

Comments
 (0)