Skip to content

Commit 30f8f1c

Browse files
committed
Add regression bugs
1 parent ed9d037 commit 30f8f1c

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug12894;
4+
5+
/**
6+
* @template TValue of object|null
7+
*/
8+
interface Dependency {
9+
/**
10+
* @return TValue
11+
*/
12+
public function __invoke(): object|null;
13+
}
14+
15+
interface DependencyResolver {
16+
/**
17+
* @template V of object|null
18+
* @template D of Dependency<V>
19+
*
20+
* @param D $dependency
21+
*
22+
* @return V
23+
*/
24+
public function resolve(Dependency $dependency): object|null;
25+
}
26+
27+
/**
28+
* @internal
29+
*/
30+
class Resolver implements DependencyResolver {
31+
public function __construct(
32+
/**
33+
* @var Closure(object|null): void
34+
*/
35+
protected readonly Closure $run,
36+
) {
37+
// empty
38+
}
39+
40+
public function resolve(Dependency $dependency): object|null {
41+
$resolved = $dependency();
42+
$result = is_object($resolved) ? 1 : 2;
43+
($this->run)($resolved);
44+
return $resolved;
45+
}
46+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug12989;
4+
5+
/**
6+
* @template T of int|null
7+
* @phpstan-param T $b
8+
* @phpstan-return int|T
9+
*/
10+
function a(?int $b): ?int
11+
{
12+
if ($b === null) {
13+
return $b;
14+
}
15+
return $b;
16+
}
17+

0 commit comments

Comments
 (0)