Skip to content

Commit 0ee1c3a

Browse files
committed
add test for a default template type above a method
1 parent 1ba4beb commit 0ee1c3a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/PHPStan/Analyser/data/template-default.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,22 @@ public function execute(): void
5353
}
5454
}
5555

56+
class FormData {}
57+
class Form
58+
{
59+
/**
60+
* @template Data of object = \stdClass
61+
* @param Data|null $values
62+
* @return Data
63+
*/
64+
public function mapValues(object|null $values = null): object
65+
{
66+
$values ??= new \stdClass;
67+
// ... map into $values ...
68+
return $values;
69+
}
70+
}
71+
5672
function () {
5773
$qb = new Builder();
5874
assertType('TemplateDefault\\Builder<false, false>', $qb);
@@ -80,3 +96,10 @@ function () {
8096
assertType('TemplateDefault\\Builder<true, false>', $qb);
8197
assertType('never', $qb->execute());
8298
};
99+
100+
function () {
101+
$form = new Form();
102+
103+
assertType('TemplateDefault\\FormData', $form->mapValues(new FormData));
104+
assertType('stdClass', $form->mapValues());
105+
};

0 commit comments

Comments
 (0)