Psalm
Get started
Documentation
Paid support
Plugins
Blog
GitHub
<?php class A { /** @var array[] */ private static array $cache = []; /** * @psalm-suppress MixedReturnStatement * @psalm-suppress MixedInferredReturnType */ public function getCachedString(string $language, string $key) : string { if (!isset(self::$cache[$language][$key])) { self::$cache[$language][$key] = self::doTranslation($language, $key); } return self::$cache[$language][$key]; } public static function doTranslation(string $language, string $key) : ?string { return rand(0, 1) ? "some string" : null; } }
Snippet created on April 12 2020 at 18:45 UTC
Settings
Get link