Re: Strict switch statements
| From: | Rowan Collins | Date: | Thu, 14 Jun 2018 16:44:56 +0000 |
| Subject: | Re: Strict switch statements | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-102265@lists.php.net to get a copy of this message | ||
On 14 June 2018 at 17:16, Alice Wonder <alice@librelamp.com> wrote:
>
> Should declare(strict_types = 1) do that?
>
> I haven't tried, but I would think it should.
No, it doesn't, and shouldn't. "strict_types" actually means
"non_coercive_scalar_type_hints"; it's a very specific feature, controlling
a specific set of situations, not a catch-all "strict mode" for anything
type-related.
I suppose we could have a new directive that magically changed the default
for the "strict" parameter of array_search, et al. But if that converted
switch, would it also convert == itself? And then would we need a new
syntax for "opting out" and using the loose comparison? Would the resulting
confusion of people not seeing which mode a file was in be worth it?
This is exactly why I think the word "strict" should be avoided at all
costs; it's just far too ambiguous.
Regards,
--
Rowan Collins
[IMSoP]