Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Oct 19, 2023
1 parent a233e62 commit 5953b1c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1459,7 +1459,7 @@ private function visitEnumDeclaration(

if (!isset($storage->enum_cases[$stmt->name->name])) {
$case = new EnumCaseStorage(
$enum_value?->value,
$enum_value,
$case_location,
);

Expand Down
23 changes: 18 additions & 5 deletions src/Psalm/Storage/EnumCaseStorage.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
<?php

declare(strict_types=1);

namespace Psalm\Storage;

use Psalm\CodeLocation;
use Psalm\Type\Atomic\TLiteralInt;
use Psalm\Type\Atomic\TLiteralString;

final class EnumCaseStorage
{
public bool $deprecated = false;
/**
* @var TLiteralString|TLiteralInt|null
*/
public $value;

/** @var CodeLocation */
public $stmt_location;

/**
* @var bool
*/
public $deprecated = false;

public function __construct(
public int|string|null $value,
public CodeLocation $location,
TLiteralString|TLiteralInt|null $value,
CodeLocation $location,
) {
$this->value = $value;
$this->stmt_location = $location;
}
}
1 change: 1 addition & 0 deletions src/Psalm/Type/UnionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,7 @@ public function isSingleLiteral(): bool

/**
* @psalm-mutation-free
* @psalm-suppress InvalidFalsableReturnType
*/
public function getSingleLiteral(): TLiteralInt|TLiteralString|TLiteralFloat
{
Expand Down

0 comments on commit 5953b1c

Please sign in to comment.