Skip to content

Commit 1c2e209

Browse files
committed
Regression test
Closes phpstan/phpstan#6861 Closes phpstan/phpstan#5629
1 parent 5c3871b commit 1c2e209

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace PHPStan\Analyser;
4+
5+
use PHPStan\Rules\Methods\ExistingClassesInTypehintsRule;
6+
use PHPStan\Rules\Rule as TRule;
7+
use PHPStan\Testing\RuleTestCase;
8+
use function array_merge;
9+
10+
/**
11+
* @extends RuleTestCase<ExistingClassesInTypehintsRule>
12+
*/
13+
class UnknownMixedTypeOnOlderPhpTest extends RuleTestCase
14+
{
15+
16+
protected function getRule(): TRule
17+
{
18+
return self::getContainer()->getByType(ExistingClassesInTypehintsRule::class);
19+
}
20+
21+
public function testMixedUnknownType(): void
22+
{
23+
$this->analyse([__DIR__ . '/data/unknown-mixed-type.php'], [
24+
[
25+
'Parameter $m of method UnknownMixedType\Foo::doFoo() has invalid type UnknownMixedType\mixed.',
26+
8,
27+
],
28+
[
29+
'Method UnknownMixedType\Foo::doFoo() has invalid return type UnknownMixedType\mixed.',
30+
8,
31+
],
32+
]);
33+
}
34+
35+
public static function getAdditionalConfigFiles(): array
36+
{
37+
return array_merge(parent::getAdditionalConfigFiles(), [
38+
__DIR__ . '/unknown-mixed-type.neon',
39+
]);
40+
}
41+
42+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace UnknownMixedType;
4+
5+
class Foo
6+
{
7+
8+
public function doFoo(mixed $m): mixed
9+
{
10+
11+
}
12+
13+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
parameters:
2+
phpVersion: 70400

0 commit comments

Comments
 (0)