New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch regression? #3603
Labels
Comments
I found these snippets: https://psalm.dev/r/6614a43b21<?php
/**
* @psalm-immutable
* @template T of self::READ_UNCOMMITTED|self::READ_COMMITTED|self::REPEATABLE_READ|self::SERIALIZABLE
*/
final class TransactionIsolationLevel
{
private const READ_UNCOMMITTED = 'read uncommitted';
private const READ_COMMITTED = 'read committed';
private const REPEATABLE_READ = 'repeatable read';
private const SERIALIZABLE = 'serializable';
/**
* @psalm-var T $level
*/
private string $level;
/**
* @psalm-param T $level
*/
private function __construct(string $level)
{
$this->level = $level;
}
/**
* @psalm-return self<self::READ_UNCOMMITTED>
*/
public static function readUncommitted(): self
{
return new self(self::READ_UNCOMMITTED);
}
/**
* @psalm-return self<self::READ_COMMITTED>
*/
public static function readCommitted(): self
{
return new self(self::READ_COMMITTED);
}
/**
* @psalm-return self<self::REPEATABLE_READ>
*/
public static function repeatableRead(): self
{
return new self(self::REPEATABLE_READ);
}
/**
* @psalm-return self<self::SERIALIZABLE>
*/
public static function serializable(): self
{
return new self(self::SERIALIZABLE);
}
/**
* @psalm-return T
*/
public function toString(): string
{
return $this->level;
}
/**
* @psalm-template TResult
* @psalm-param callable(self::READ_UNCOMMITTED): TResult $readUncommitted
* @psalm-param callable(self::READ_COMMITTED): TResult $readCommitted
* @psalm-param callable(self::REPEATABLE_READ): TResult $repeatableRead
* @psalm-param callable(self::SERIALIZABLE): TResult $serializable
* @psalm-return TResult
*/
public function resolve(
callable $readUncommitted,
callable $readCommitted,
callable $repeatableRead,
callable $serializable
) {
switch ($this->level) {
case self::READ_UNCOMMITTED:
return $readUncommitted($this->level);
case self::READ_COMMITTED:
return $readCommitted($this->level);
case self::REPEATABLE_READ:
return $repeatableRead($this->level);
case self::SERIALIZABLE:
return $serializable($this->level);
default:
throw new \LogicException(sprintf('Level "%s" is an invalid transaction isolation level.', $this->level));
}
}
}
|
narrowed to https://psalm.dev/r/321fb79d3f (without switch, but with |
I found these snippets: https://psalm.dev/r/321fb79d3f<?php
/**
* @psalm-immutable
* @template T of self::READ_UNCOMMITTED|self::READ_COMMITTED|self::REPEATABLE_READ|self::SERIALIZABLE
*/
final class TransactionIsolationLevel
{
private const READ_UNCOMMITTED = 'read uncommitted';
private const READ_COMMITTED = 'read committed';
private const REPEATABLE_READ = 'repeatable read';
private const SERIALIZABLE = 'serializable';
/**
* @psalm-var T $level
*/
private string $level;
/**
* @psalm-param T $level
*/
private function __construct(string $level)
{
$this->level = $level;
}
/**
* @psalm-return self<self::READ_UNCOMMITTED>
*/
public static function readUncommitted(): self
{
return new self(self::READ_UNCOMMITTED);
}
/**
* @psalm-return T
*/
public function toString(): string
{
return $this->level;
}
/**
* @psalm-template TResult
* @psalm-param callable(self::READ_UNCOMMITTED): TResult $readUncommitted
* @psalm-return TResult
*/
public function resolve(callable $readUncommitted) {
if ($this->level == self::READ_UNCOMMITTED) {
return $readUncommitted($this->level);
}
throw new \LogicException(sprintf('Level "%s" is an invalid transaction isolation level.', $this->level));
}
}
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://psalm.dev/r/6614a43b21
The text was updated successfully, but these errors were encountered: