@@ -445,4 +445,66 @@ public function setActive(bool $active = null) : void
445445
446446 $ this ->assertSame ($ expected , $ this ->printer ->prettyPrintFile ($ nodeTraverser ->traverse ($ ast )));
447447 }
448+
449+ /**
450+ * @test
451+ */
452+ public function it_generates_method_with_doc_block_from_builder (): void
453+ {
454+ $ ast = $ this ->parser ->parse ('' );
455+
456+ $ docBlockComment = <<<'EOF'
457+ Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's
458+ standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a
459+ type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting,
460+ remaining essentially unchanged.
461+
462+ It is a long established fact that a reader will be distracted by the readable content of a page when looking at
463+ its layout.
464+ EOF;
465+
466+ $ methodBuilder = ClassMethodBuilder::fromScratch ('setActive ' )->setReturnType ('void ' );
467+ $ methodBuilder ->setDocBlockComment ($ docBlockComment );
468+ $ methodBuilder ->setParameters (ParameterBuilder::fromScratch ('active ' , 'bool ' )->setDefaultValue (null )->setTypeDocBlockHint ('bool ' ));
469+
470+ $ classBuilder = ClassBuilder::fromScratch ('TestClass ' , 'My \\Awesome \\Service ' );
471+ $ classBuilder ->setMethods ($ methodBuilder );
472+
473+ $ nodeTraverser = new NodeTraverser ();
474+ $ classBuilder ->injectVisitors ($ nodeTraverser , $ this ->parser );
475+
476+ $ expected = <<<'EOF'
477+ <?php
478+
479+ declare (strict_types=1);
480+ namespace My\Awesome\Service;
481+
482+ class TestClass
483+ {
484+ /**
485+ * Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's
486+ * standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a
487+ * type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting,
488+ * remaining essentially unchanged.
489+ *
490+ * It is a long established fact that a reader will be distracted by the readable content of a page when looking at
491+ * its layout.
492+ *
493+ * @param bool $active
494+ */
495+ public function setActive(bool $active = null) : void
496+ {
497+ }
498+ }
499+ EOF;
500+
501+ $ this ->assertSame ($ expected , $ this ->printer ->prettyPrintFile ($ nodeTraverser ->traverse ($ ast )));
502+
503+ $ classBuilder = ClassBuilder::fromNodes (...$ this ->parser ->parse ($ expected ));
504+
505+ $ nodeTraverser = new NodeTraverser ();
506+ $ classBuilder ->injectVisitors ($ nodeTraverser , $ this ->parser );
507+
508+ $ this ->assertSame ($ expected , $ this ->printer ->prettyPrintFile ($ nodeTraverser ->traverse ([])));
509+ }
448510}
0 commit comments