[php-src] Issue #22695: Nullable Casts

From: Date: Sat, 11 Jul 2026 11:46:41 +0000
Subject: [php-src] Issue #22695: Nullable Casts
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-252408@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/22695 Author: rela589n ### Description Hi! From time to time, I come across the desire to have nullable casts: (?string)$value. It should work as follows: ```php $cast = (?string)$value; $cast = nullableString($value); ``` ```php function nullableString(mixed $value): ?string { if (null === $value) { return null; } return (string)$value; } ```

« previous php.bugs (#252408) next »