[php-src] Issue #14386: First class callable type cast

From: Date: Fri, 31 May 2024 10:18:09 +0000
Subject: [php-src] Issue #14386: First class callable type cast
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-246993@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/14386 Author: rela589n ### Description Hi there! I would like to propose first class callable type cast feature: ```php $castToString = (string)(...); ``` That is a more concise version of the following: ```php $castToString = static fn (mixed $value) => (string)$value; ``` With a new syntax map operation would be really nifty: ```php $templateIdStrings = array_map((string)(...), $templateIds); ``` Versus current way of doing things: ```php $templateIdStrings = array_map(static fn (Uuid $id): string => (string)$id, $templateIds); ``` Please, let me know what you think about it.

« previous php.bugs (#246993) next »