Re: [Initial Feedback] PHP User Modules - An Adaptation of ES6 from JavaScript

From: Date: Thu, 27 Jun 2024 14:56:07 +0000
Subject: Re: [Initial Feedback] PHP User Modules - An Adaptation of ES6 from JavaScript
References: 1 2  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message


> Le 27 juin 2024 à 09:41, Rob Landers <[email protected]> a écrit :
> 
>> 
>> PHP User Modules are php files that are brought into the runtime through a new parser that
>> is able to generate faster and more concise runtime code by removing support for problematic
>> features and imposing a strict mode by default. They focus on PHP as a language and not as a
>> template engine.
> 
> FYI, in non-strict mode, this produces a deprecation warning that can be caught and thrown
> from:
> 
> (fn(int $x) => print($x))(123.456); // deprecation warning
> 
> but this will work
> 
> (fn(int $x) => print($x))(123.000); // this is fine
> 
> Both of those are errors in strict types, so you might be tempted to do
> 
> fn(int $x) => print($x))((int)$some_var);
> 
> but $some_var might not actually be an integer-like (such as null or a string that becomes
> zero).
> 
> Some of us prefer the more strict, non-strict mode as the built-in strict mode is actually ...
> uhh, problematic, to say the least, in some business cases. So forcing strict mode is probably a
> non-starter.
> 


Hi,

There is no equivalent of “strict mode” in PHP. Do not confuse it with “strict_types”, which
has nothing in common except the word “strict” in its name..

Strict mode in JS was introduced to disable design mistakes that couldn’t be removed due to very
strong (almost inflexible) BC contraints. In PHP, we have deprecations followed by removals in next
major version.

(And some people, including me, will argue: while JS strict mode disables design mistakes, PHP
strict_types mode *is* a design mistake.) 

—Claude



Thread (128 messages)