From 9e537d2d0049133c0c2b59a0d5b7ec7124e38a6f Mon Sep 17 00:00:00 2001 From: Massimiliano Torromeo Date: Tue, 14 Dec 2021 12:14:18 +0100 Subject: [PATCH 1/2] Fixed deprecated null parameter in trim 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 --- phpunit.xml.dist | 1 + src/Scanner/DocBlockScanner.php | 2 +- test/Scanner/DocBlockScannerTest.php | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 84ca6caf..f222c747 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,6 +2,7 @@ diff --git a/src/Scanner/DocBlockScanner.php b/src/Scanner/DocBlockScanner.php index 955bb6c2..de13ef1a 100644 --- a/src/Scanner/DocBlockScanner.php +++ b/src/Scanner/DocBlockScanner.php @@ -25,7 +25,7 @@ class DocBlockScanner protected $docComment; /** @var string */ - protected $shortDescription; + protected $shortDescription = ''; /** @var string */ protected $longDescription = ''; diff --git a/test/Scanner/DocBlockScannerTest.php b/test/Scanner/DocBlockScannerTest.php index b1d9f6f4..0a696564 100644 --- a/test/Scanner/DocBlockScannerTest.php +++ b/test/Scanner/DocBlockScannerTest.php @@ -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()); + } } From cfa95242585c8f2bc7121ed9ed3fe562e0054427 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sun, 19 Dec 2021 19:05:20 +0100 Subject: [PATCH 2/2] Run `vimeo/psalm` checks against PHP 8.1, re-generate baseline according to upstream type improvements Signed-off-by: Marco Pivetta --- .github/workflows/psalm.yml | 2 +- psalm-baseline.xml | 31 +++++++++++++++---------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml index 138ccdc8..58178a3a 100644 --- a/.github/workflows/psalm.yml +++ b/.github/workflows/psalm.yml @@ -15,7 +15,7 @@ jobs: dependencies: - "locked" php-version: - - "8.0" + - "8.1" operating-system: - "ubuntu-latest" diff --git a/psalm-baseline.xml b/psalm-baseline.xml index fe5f1c35..2606c946 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -103,6 +103,9 @@ $namespaceAlias + + method_exists($constReflection, 'isFinal') + is_array($constant) @@ -278,9 +281,6 @@ getName getName - - ReflectionEnumUnitCase - getBackingType getCases @@ -367,9 +367,10 @@ - + $array['name'] $parameterOutput + $reflectionMethod->isStatic() $value $value $value @@ -459,6 +460,9 @@ $reflectionProperty->getDocBlock() + + method_exists($reflectionProperty, 'isReadonly') + new static($array['name']) new static() @@ -592,18 +596,14 @@ - + allowsNull getName getName getParentClass + getTypes - - - - ReflectionIntersectionType - ReflectionIntersectionType - + @@ -1086,9 +1086,6 @@ $tokens - - $shortDescription - $context === 0x00 $this->shortDescription != '' && $tagIndex === null @@ -2304,14 +2301,16 @@ - + + new DocBlockScanner($docComment) new DocBlockScanner($docComment) new DocBlockScanner($docComment) new DocBlockScanner($docComment) - + testDocBlockScannerDescriptions testDocBlockScannerParsesTagsWithNoValuesProperly + testInvalidDocBlock $tags[0]