File tree 2 files changed +21
-2
lines changed
2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,9 @@ final class ClassMethodBuilder
66
66
/** @var bool */
67
67
private $ abstract = false ;
68
68
69
+ /** @var bool */
70
+ private $ isStatic = false ;
71
+
69
72
private function __construct ()
70
73
{
71
74
}
@@ -279,6 +282,13 @@ public function setAbstract(bool $abstract): self
279
282
return $ this ;
280
283
}
281
284
285
+ public function setStatic (bool $ isStatic ): self
286
+ {
287
+ $ this ->isStatic = $ isStatic ;
288
+
289
+ return $ this ;
290
+ }
291
+
282
292
public function isFinal (): bool
283
293
{
284
294
return $ this ->final ;
@@ -289,6 +299,11 @@ public function isAbstract(): bool
289
299
return $ this ->abstract ;
290
300
}
291
301
302
+ public function isStatic (): bool
303
+ {
304
+ return $ this ->isStatic ;
305
+ }
306
+
292
307
public function generate (Parser $ parser ): NodeVisitor
293
308
{
294
309
return new ClassMethod ($ this ->methodGenerator ($ parser ));
@@ -304,6 +319,9 @@ private function methodGenerator(Parser $parser): MethodGenerator
304
319
if ($ this ->abstract ) {
305
320
$ flags |= MethodGenerator::FLAG_ABSTRACT ;
306
321
}
322
+ if ($ this ->isStatic ) {
323
+ $ flags |= MethodGenerator::FLAG_STATIC ;
324
+ }
307
325
308
326
$ body = null ;
309
327
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ public function it_generates_method_for_empty_class(): void
46
46
47
47
$ classFactory = ClassBuilder::fromScratch ('TestClass ' , 'My \\Awesome \\Service ' );
48
48
$ classFactory ->setMethods (
49
- ClassMethodBuilder::fromScratch ('setActive ' )->setReturnType ('void ' )
49
+ ClassMethodBuilder::fromScratch ('setActive ' )->setReturnType ('void ' )-> setStatic ( true )
50
50
);
51
51
$ classFactory ->addMethod (
52
52
ClassMethodBuilder::fromScratch ('doSomething ' )->setReturnType ('void ' )->setFinal (true )
@@ -62,6 +62,7 @@ public function it_generates_method_for_empty_class(): void
62
62
$ this ->assertSame ('setActive ' , $ methods ['setActive ' ]->getName ());
63
63
$ this ->assertFalse ($ methods ['setActive ' ]->isAbstract ());
64
64
$ this ->assertFalse ($ methods ['setActive ' ]->isFinal ());
65
+ $ this ->assertTrue ($ methods ['setActive ' ]->isStatic ());
65
66
66
67
$ this ->assertSame ('doSomething ' , $ methods ['doSomething ' ]->getName ());
67
68
$ this ->assertFalse ($ methods ['doSomething ' ]->isAbstract ());
@@ -78,7 +79,7 @@ public function it_generates_method_for_empty_class(): void
78
79
79
80
class TestClass
80
81
{
81
- public function setActive() : void
82
+ public static function setActive() : void
82
83
{
83
84
}
84
85
public final function doSomething() : void
You can’t perform that action at this time.
0 commit comments