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've heard everything from "it
enables type hints" to "it makes it so that I know I got my class
instead of an int" to getting it right, but thinking it applies to
code calling from another file, and not them calling code.

Granted, I haven't done a scientific poll (though I did one on Reddit
this morning for giggles to ensure it isn't just the people I know).

One thing is clear is that "strict types" may be a bit of poor word
choice and gives people a false sense of security that it is "safe" or
"more correct" when this obviously isn't true. Thus, I'd like to
propose, for PHP 9, simply renaming it from strict_types to
scalar_type_coercion and flipping the value:

<?php declare(strict_types=1);

to

<?php declare(scalar_type_coercion=0);

Perhaps it might even be worth adding a secondary vote to flip the
default, such that if you want to "old" behavior back:

<?php declare(scalar_type_coercion=1);

I'm not attached to the name "scalar_type_coercion" by any stretch,
but I do feel that "strict_types" gives people the wrong idea about
what is going on when they enable it and renaming it to something more
clear might be helpful.

What are your thoughts?

PS. Personally, I would rather unify non-strict and strict in some way
that makes sense ... so, that route sounds nice too.

Robert Landers
Software Engineer
Utrecht NL

Reply via email to