@@ -29,6 +29,57 @@ public function setUp(): void
29
29
$ this ->printer = new Standard (['shortArraySyntax ' => true ]);
30
30
}
31
31
32
+ /**
33
+ * @test
34
+ */
35
+ public function it_generates_method_without_doc_block_if_typed (): void
36
+ {
37
+ $ method = new MethodGenerator (
38
+ 'setType ' ,
39
+ [
40
+ new ParameterGenerator ('type ' , '?string ' ),
41
+ ]
42
+ );
43
+ $ method ->setTyped (true );
44
+ $ method ->setReturnType ('void ' );
45
+
46
+ $ expectedOutput = <<<'EOF'
47
+ <?php
48
+
49
+ public function setType(?string $type) : void;
50
+ EOF;
51
+
52
+ $ this ->assertSame ($ expectedOutput , $ this ->printer ->prettyPrintFile ([$ method ->generate ()]));
53
+ }
54
+
55
+ /**
56
+ * @test
57
+ */
58
+ public function it_generates_method_with_doc_block_comment_if_typed (): void
59
+ {
60
+ $ method = new MethodGenerator (
61
+ 'setType ' ,
62
+ [
63
+ new ParameterGenerator ('type ' , '?string ' ),
64
+ ]
65
+ );
66
+ $ method ->setTyped (true );
67
+ $ method ->setDocBlockComment ('Sets an awesome type ' );
68
+
69
+ $ expectedOutput = <<<'EOF'
70
+ <?php
71
+
72
+ /**
73
+ * Sets an awesome type
74
+ *
75
+ * @var string|null $type
76
+ */
77
+ public function setType(?string $type);
78
+ EOF;
79
+
80
+ $ this ->assertSame ($ expectedOutput , $ this ->printer ->prettyPrintFile ([$ method ->generate ()]));
81
+ }
82
+
32
83
/**
33
84
* @test
34
85
*/
@@ -41,6 +92,7 @@ public function it_generates_method_with_doc_block(): void
41
92
]
42
93
);
43
94
$ method ->setDocBlockComment ('Sets an awesome type ' );
95
+ $ method ->setTyped (true );
44
96
45
97
$ expectedOutput = <<<'EOF'
46
98
<?php
0 commit comments