Skip to content

Commit 036ece2

Browse files
author
Kirill Nesmeyanov
committed
Fix errors of phpstan 2.1+
1 parent f549a83 commit 036ece2

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/NativeTypePrinter.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,13 @@ public function __construct(
4141
parent::__construct($newLine, $indention);
4242

4343
// preload phan type aliases
44+
// @phpstan-ignore-next-line : PHPStan false-positive, not a bug
4445
$this->aliases += require __DIR__ . '/../resources/aliases/phan.php';
4546
// preload psalm type aliases
47+
// @phpstan-ignore-next-line : PHPStan false-positive, not a bug
4648
$this->aliases += require __DIR__ . '/../resources/aliases/psalm.php';
4749
// preload phpstan type aliases
50+
// @phpstan-ignore-next-line : PHPStan false-positive, not a bug
4851
$this->aliases += require __DIR__ . '/../resources/aliases/phpstan.php';
4952

5053
foreach ($aliases as $alias => $type) {
@@ -142,6 +145,7 @@ protected function printUnionTypeNode(UnionTypeNode $node): string
142145
$result = $this->formatUnionWithMixed($result);
143146
$result = $this->formatBoolWithTrueAndFalse($result);
144147

148+
/** @var non-empty-string */
145149
return \vsprintf($shouldWrap ? '(%s)' : '%s', [
146150
\implode('|', [...\array_unique($result)]),
147151
]);
@@ -191,6 +195,7 @@ private function formatUnionWithMixed(array $result): array
191195
#[\Override]
192196
protected function printIntersectionTypeNode(IntersectionTypeNode $node): string
193197
{
198+
/** @var non-empty-string */
194199
return \vsprintf($this->nesting++ > 0 ? '(%s)' : '%s', [
195200
\implode('&', [...$this->unwrapAndPrint($node)]),
196201
]);

src/PrettyPrinter.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ protected function printUnionTypeNode(UnionTypeNode $node): string
475475
{
476476
$delimiter = $this->wrapUnionType ? ' | ' : '|';
477477

478+
/** @var non-empty-string */
478479
return \vsprintf($this->nesting++ > 0 ? '(%s)' : '%s', [
479480
\implode($delimiter, [
480481
...$this->unwrapAndPrint($node),
@@ -491,6 +492,7 @@ protected function printIntersectionTypeNode(IntersectionTypeNode $node): string
491492
{
492493
$delimiter = $this->wrapIntersectionType ? ' & ' : '&';
493494

495+
/** @var non-empty-string */
494496
return \vsprintf($this->nesting++ > 0 ? '(%s)' : '%s', [
495497
\implode($delimiter, [
496498
...$this->unwrapAndPrint($node),

0 commit comments

Comments
 (0)