Skip to content

Commit 601a2b6

Browse files
committed
make Comment constructor attributes optional
1 parent 0f50b6d commit 601a2b6

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

samples/Sample_37_Comments.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
$section->addTextBreak(2);
2222

2323
// Let's create a comment that we will link to a start element and an end element
24-
$commentWithStartAndEnd = new \PhpOffice\PhpWord\Element\Comment('Foo Bar', new \DateTime(), '');
24+
$commentWithStartAndEnd = new \PhpOffice\PhpWord\Element\Comment('Foo Bar', new \DateTime());
2525
$commentWithStartAndEnd->addText('A comment with a start and an end');
2626
$phpWord->addComment($commentWithStartAndEnd);
2727

@@ -36,7 +36,7 @@
3636
$section->addTextBreak(2);
3737

3838
// Let's add a comment on an image
39-
$commentOnImage = new \PhpOffice\PhpWord\Element\Comment('Mr Smart', new \DateTime(), '');
39+
$commentOnImage = new \PhpOffice\PhpWord\Element\Comment('Mr Smart', new \DateTime());
4040
$imageComment = $commentOnImage->addTextRun();
4141
$imageComment->addText('Hey, Mars does look ');
4242
$imageComment->addText('red', array('color' => 'FF0000'));

src/PhpWord/Element/Comment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class Comment extends TrackChange
5757
* @param \DateTime $date
5858
* @param string $initials
5959
*/
60-
public function __construct($author, $date, $initials)
60+
public function __construct($author, $date = null, $initials = null)
6161
{
6262
parent::__construct($author, $date);
6363
$this->initials = $initials;

src/PhpWord/Element/TrackChange.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class TrackChange extends AbstractContainer
4747
* @param string $author
4848
* @param \DateTime $date
4949
*/
50-
public function __construct($author, \DateTime $date)
50+
public function __construct($author, \DateTime $date = null)
5151
{
5252
$this->author = $author;
5353
$this->date = $date;

0 commit comments

Comments
 (0)