Skip to content

Commit a758e6f

Browse files
committed
Escapes */ in comments
1 parent 7880996 commit a758e6f

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/PhpGenerator/Helpers.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ public static function formatArgs(string $statement, array $args): string
4545

4646
public static function formatDocComment(string $content): string
4747
{
48-
if (($s = trim($content)) === '') {
48+
$s = trim($content);
49+
$s = str_replace('*/', '* /', $s);
50+
if ($s === '') {
4951
return '';
5052
} elseif (strpos($content, "\n") === false) {
5153
return "/** $s */\n";

tests/PhpGenerator/ClassType.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ $class
3333
->addImplement('IOne')
3434
->setTraits(['ObjectTrait'])
3535
->addTrait('AnotherTrait', ['sayHello as protected'])
36-
->addComment("Description of class.\nThis is example\n")
36+
->addComment("Description of class.\nThis is example\n /**/")
3737
->addComment('@property-read Nette\Forms\Form $form')
3838
->setConstants(['ROLE' => 'admin'])
3939
->addConstant('ACTIVE', false)

tests/PhpGenerator/expected/ClassType.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Description of class.
33
* This is example
4-
*
4+
* /** /
55
* @property-read Nette\Forms\Form $form
66
*/
77
abstract class Example extends ParentClass implements IExample, IOne

0 commit comments

Comments
 (0)