Skip to content

Commit

Permalink
Fixed deprecated null parameter in trim
Browse files Browse the repository at this point in the history
DocScanner may raise a Deprecated error with PHP 8.1 if shortDescription is used before initialization, the default value being null

Signed-off-by: Massimiliano Torromeo <[email protected]>
  • Loading branch information
mtorromeo committed Dec 14, 2021
1 parent c99ef8e commit 9e537d2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
convertDeprecationsToExceptions="true"
colors="true">
<testsuites>
<testsuite name="laminas-code Test Suite">
Expand Down
2 changes: 1 addition & 1 deletion src/Scanner/DocBlockScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DocBlockScanner
protected $docComment;

/** @var string */
protected $shortDescription;
protected $shortDescription = '';

/** @var string */
protected $longDescription = '';
Expand Down
7 changes: 7 additions & 0 deletions test/Scanner/DocBlockScannerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,11 @@ public function testDocBlockScannerDescriptions()
self::assertEquals('Short Description', $tokenScanner->getShortDescription());
self::assertEquals('Long Description continued in the second line', $tokenScanner->getLongDescription());
}

public function testInvalidDocBlock()
{
$docComment = '/**';
$tokenScanner = new DocBlockScanner($docComment);
self::assertEquals('', $tokenScanner->getShortDescription());
}
}

0 comments on commit 9e537d2

Please sign in to comment.