gulasz101/gettype

提供gettype函数的微质量生活改进包,该函数返回枚举类型。

v1.0.0 2023-10-04 21:36 UTC

This package is not auto-updated.

Last update: 2024-09-20 00:37:26 UTC


README

微质量生活改进。

提供小的枚举类型和gettype函数,该函数与原始的\gettype不同,返回适当的枚举值。

尤其是在您以phpstan最大级别运行时。

所以为了避免烦恼

Diagnostics:
1. Parameter #1 $externalUrl of class CLI\SayHelloFromExternalServerCommand constructor expects string, string|false given.

执行以下操作

use function gulasz101\gettype;

$app->add(new SayHalloFromDBCommand(
    new PDO(
        match (gettype($dsn = getenv('CLI_DB_DSN'))) {
            Type::BOOLEAN => throw new RuntimeException('CLI_DB_DSN env is missing'),
            Type::STRING => $dsn,
            default => throw new RuntimeException('CLI_DB_DSN env is setup with wrong type'),
        }
    ))
);

使用以下命令安装它

composer require gulasz101/gettype