Huyy
3
/**
* @template T
* @param callable(): (T|false) $function
* @return T
* @throws \ErrorException
*/
function exceptionally(
callable $function,
int $errorLevels = E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED,
): mixed {}
// PHP < 8.6
$contents = exceptionally(static fn () => file_get_contents($file));
// PHP >= 8.6 с partial function application
$contents = exceptionally(file_get_contents($file, ...));
Plp
/**
* @template T
* @param callable(): (T|false) $function
* @return T
* @throws \ErrorException
*/
function exceptionally(
callable $function,
int $errorLevels = E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED,
): mixed {}
// PHP < 8.6
$contents = exceptionally(static fn () => file_get_contents($file));
// PHP >= 8.6 с partial function application
$contents = exceptionally(file_get_contents($file, ...));
/** * @template T * @param callable(): (T|false) $function * @return T * @throws \ErrorException */ function exceptionally( callable $function, int $errorLevels = E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED, ): mixed {} // PHP < 8.6 $contents = exceptionally(static fn () => file_get_contents($file)); // PHP >= 8.6 с partial function application $contents = exceptionally(file_get_contents($file, ...));Комментарий