Skip to content

Commit 32f9c23

Browse files
phpstan-botclaude
andcommitted
Add non-regression test for bug 8048
Ensures template type T with class-string parameter is correctly resolved and does not produce false "Unable to resolve the template type T" errors. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c30702d commit 32f9c23

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4070,4 +4070,12 @@ public function testBug11894(): void
40704070
$this->analyse([__DIR__ . '/data/bug-11894.php'], []);
40714071
}
40724072

4073+
public function testBug8048(): void
4074+
{
4075+
$this->checkThisOnly = false;
4076+
$this->checkNullables = true;
4077+
$this->checkUnionTypes = true;
4078+
$this->analyse([__DIR__ . '/data/bug-8048.php'], []);
4079+
}
4080+
40734081
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace Bug8048;
4+
5+
interface CustomResponseInterface
6+
{
7+
}
8+
9+
final class CustomResponse implements CustomResponseInterface
10+
{
11+
}
12+
13+
final class ApiService
14+
{
15+
/**
16+
* @template T of CustomResponseInterface
17+
* @param class-string<T> $class
18+
* @return T|null
19+
*/
20+
public function request(string $class): ?CustomResponseInterface
21+
{
22+
return new CustomResponse();
23+
}
24+
}
25+
26+
final class Consumer
27+
{
28+
public function test(): void
29+
{
30+
$apiService = new ApiService();
31+
$result = $apiService->request(CustomResponse::class);
32+
}
33+
}

0 commit comments

Comments
 (0)