File tree Expand file tree Collapse file tree 2 files changed +63
-0
lines changed
tests/PHPStan/Analyser/nsrt Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+
You can’t perform that action at this time.
0 commit comments