On Mon, Nov 6, 2023 at 3:08 AM David Gebler <[email protected]> wrote:
>
> On Sun, Nov 5, 2023 at 1:37 PM Oladoyinbo Vincent <[email protected]>
> wrote:
>
> > Hello Internals,
> >
> > I was wondering if php could introduce this feature or if any experienced C
> > dev here can work on the implementation of this feature.
> >
> >
> I think this is a much bigger issue than bikeshedding over syntax. The idea
> of typed variables has been discussed a few times in recent years but the
> roadblocks have been efficiency of any possible implementation, BC in
> respect of places type hinting can already be used and the overall
> usefulness / desirability of the feature. It's one of those things that's
> been filled in reasonably well by third party static analysis tools. Tbh
> I'd be more interested in an official static analyzer than more type checks
> at runtime.
It's also worth adding that many times, certain functions cannot be
chained elegantly or the nesting level gets out of hand, making
reusing variables a way to handle that:
$name = implode(' ', array_map(ucfirst(...), $name));
might be more readable to write as:
$name = array_map(ucfirst(...), $name);
$name = implode(' ', $name);
In this case, $name turns from an array to a string. Having to come up
with unique enough variable names just to satisfy type-checking would
be rather annoying (and it is in other languages).
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php