Skip to content

Commit

Permalink
Fix errors of phpstan 2.1+
Browse files Browse the repository at this point in the history
  • Loading branch information
SerafimArts committed Jan 11, 2025
1 parent f549a83 commit 036ece2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/NativeTypePrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@ public function __construct(
parent::__construct($newLine, $indention);

// preload phan type aliases
// @phpstan-ignore-next-line : PHPStan false-positive, not a bug
$this->aliases += require __DIR__ . '/../resources/aliases/phan.php';
// preload psalm type aliases
// @phpstan-ignore-next-line : PHPStan false-positive, not a bug
$this->aliases += require __DIR__ . '/../resources/aliases/psalm.php';
// preload phpstan type aliases
// @phpstan-ignore-next-line : PHPStan false-positive, not a bug
$this->aliases += require __DIR__ . '/../resources/aliases/phpstan.php';

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

/** @var non-empty-string */
return \vsprintf($shouldWrap ? '(%s)' : '%s', [
\implode('|', [...\array_unique($result)]),
]);
Expand Down Expand Up @@ -191,6 +195,7 @@ private function formatUnionWithMixed(array $result): array
#[\Override]
protected function printIntersectionTypeNode(IntersectionTypeNode $node): string
{
/** @var non-empty-string */
return \vsprintf($this->nesting++ > 0 ? '(%s)' : '%s', [
\implode('&', [...$this->unwrapAndPrint($node)]),
]);
Expand Down
2 changes: 2 additions & 0 deletions src/PrettyPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ protected function printUnionTypeNode(UnionTypeNode $node): string
{
$delimiter = $this->wrapUnionType ? ' | ' : '|';

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

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

0 comments on commit 036ece2

Please sign in to comment.