From f8a95dd3601ed475aa6fff0d0d90e7adc6e61253 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Sun, 28 Apr 2024 16:13:04 +0200 Subject: [PATCH] added CommentAware::removeComment() --- src/PhpGenerator/Traits/CommentAware.php | 7 +++++++ tests/PhpGenerator/ClassType.phpt | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/PhpGenerator/Traits/CommentAware.php b/src/PhpGenerator/Traits/CommentAware.php index 38879587..deff6a5a 100644 --- a/src/PhpGenerator/Traits/CommentAware.php +++ b/src/PhpGenerator/Traits/CommentAware.php @@ -39,4 +39,11 @@ public function addComment(string $val): static $this->comment .= $this->comment ? "\n$val" : $val; return $this; } + + + public function removeComment(): static + { + $this->comment = null; + return $this; + } } diff --git a/tests/PhpGenerator/ClassType.phpt b/tests/PhpGenerator/ClassType.phpt index 9c5fac66..a8e81eee 100644 --- a/tests/PhpGenerator/ClassType.phpt +++ b/tests/PhpGenerator/ClassType.phpt @@ -59,7 +59,9 @@ $class->addProperty('handle') ->addComment('@var resource orignal file handle'); $class->addProperty('order') - ->setValue(new Literal('RecursiveIteratorIterator::SELF_FIRST')); + ->setValue(new Literal('RecursiveIteratorIterator::SELF_FIRST')) + ->addComment('foo') + ->removeComment(); $class->addProperty('typed1') ->setType(Type::Array)