Skip to content

Commit b7f8815

Browse files
committed
Added regression test
1 parent 9e4d6d6 commit b7f8815

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3616,4 +3616,14 @@ public function testBug12880(): void
36163616
$this->analyse([__DIR__ . '/data/bug-12880.php'], []);
36173617
}
36183618

3619+
public function testBug12940(): void
3620+
{
3621+
$this->checkThisOnly = false;
3622+
$this->checkNullables = true;
3623+
$this->checkUnionTypes = true;
3624+
$this->checkExplicitMixed = true;
3625+
3626+
$this->analyse([__DIR__ . '/data/bug-12940.php'], []);
3627+
}
3628+
36193629
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace Bug12940;
4+
5+
class GeneralUtility
6+
{
7+
/**
8+
* @template T of object
9+
* @param class-string<T> $className
10+
* @return T
11+
*/
12+
public static function makeInstance(string $className, mixed ...$args): object
13+
{
14+
return new $className(...$args);
15+
}
16+
}
17+
18+
class PageRenderer
19+
{
20+
public function setTemplateFile(string $path): void
21+
{
22+
}
23+
24+
public function setLanguage(string $lang): void
25+
{
26+
}
27+
}
28+
29+
class TypoScriptFrontendController
30+
{
31+
32+
protected ?PageRenderer $pageRenderer = null;
33+
34+
public function initializePageRenderer(): void
35+
{
36+
if ($this->pageRenderer !== null) {
37+
return;
38+
}
39+
$this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
40+
$this->pageRenderer->setTemplateFile('EXT:frontend/Resources/Private/Templates/MainPage.html');
41+
$this->pageRenderer->setLanguage('DE');
42+
}
43+
}

0 commit comments

Comments
 (0)