On Tue, 18 Jun 2024, 17:40 Robert Landers, <landers.rob...@gmail.com> wrote:

> Hello internals,
>
> Many, many people start their files fairly religiously:
>
> <?php declare(strict_types=1);
>
> and I say "religiously" because from talking to people in real life,
> reddit, workplaces, etc, very few php programmers actually know what
> this does but do it nonetheless.
>

I think there's almost certainly a degree of truth, not just in PHP but
programming in general, in the idea that there are many people who will
blindly follow a convention for no better reason they once heard someone
they considered more senior than themselves say the words "best practice"

But I don't think the meaning of strict_types in PHP is unclear. It's right
there in the manual
https://www.php.net/manual/en/language.types.declarations.php#language.types.declarations.strict

If anyone is daft enough to use a language feature without referencing what
it means or what it does, let them clean up any problems which arise for
them as a result.

If I were to support any change to how this feature works for PHP 9, I
think it would be providing a mechanism to enable it for all files at once,
maybe either via a .ini setting such as strict_types_default=1 or a new
declare which applies to all files included or autoloaded from that point
on, i.e. a declare that could be used as the first line of an entrypoint
script to make all files in a project have strict typing mode
enabled/disabled (unless a particular file overrides for its own scope with
its own declare).

Changing the name to anything other than what it is now, with or without
flipping the value, just seems like a major BC headache for no gain.

-Dave

>

Reply via email to