File tree 2 files changed +16
-3
lines changed
stubs/Symfony/Component/Form
tests/Stubs/Symfony/Component/Form
2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ interface FormFactoryInterface
14
14
* @param TData $data
15
15
* @param array<string, mixed> $options
16
16
*
17
- * @phpstan-return FormInterface<TData>
17
+ * @phpstan-return ($data is null ? FormInterface<null| TData> : FormInterface<TData>)
18
18
*
19
19
* @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
20
20
*/
@@ -27,8 +27,8 @@ interface FormFactoryInterface
27
27
* @param class-string<TFormType> $type
28
28
* @param TData $data
29
29
* @param array<string, mixed> $options
30
- *
31
- * @phpstan-return FormInterface<TData>
30
+ *
31
+ * @phpstan-return ($data is null ? FormInterface<null| TData> : FormInterface<TData>)
32
32
*
33
33
* @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
34
34
*/
Original file line number Diff line number Diff line change @@ -22,9 +22,22 @@ public function doSomething(): void
22
22
$ form = $ this ->formFactory ->create (DataClassType::class, new DataClass ());
23
23
$ data = $ form ->getData ();
24
24
$ this ->thisOnlyAcceptsDataClass ($ data );
25
+ $ this ->thisOnlyAcceptsDataClassOrNull ($ data );
26
+ }
27
+
28
+ public function doSomethingNullable (): void
29
+ {
30
+ $ form = $ this ->formFactory ->create (DataClassType::class);
31
+ $ data = $ form ->getData ();
32
+ // $this->thisOnlyAcceptsDataClass($data); // ERROR!
33
+ $ this ->thisOnlyAcceptsDataClassOrNull ($ data );
25
34
}
26
35
27
36
private function thisOnlyAcceptsDataClass (DataClass $ data ): void
28
37
{
29
38
}
39
+
40
+ private function thisOnlyAcceptsDataClassOrNull (?DataClass $ data ): void
41
+ {
42
+ }
30
43
}
You can’t perform that action at this time.
0 commit comments