Hey Tom, On Tue, Feb 4, 2020 at 1:55 PM Tom Gerrits <t...@inventis.be> wrote:
> "(string) $var" doesn't seem a lot less explicit to me than > "$var->toString()", but if it is coerced automatically when being > passed to e.g. a function taking a string, that is of course a > different story. > `(string) $var` is less explicit because `(string)` is an operation that applies to a wide set of types, whereas any `->` applies only to `object` types, and also has a specific name (the method name) on its right. Restricting that operation to fewer supported types is not feasible at this point, since `(string) null` is very much relied upon. Coercions and implicit casting using the overloaded operators could > perhaps also be limited to non-strict mode, if desired, which is also > the case for scalar types currently, IIRC. > Is there any newly written code that doesn't use non-strict mode at all? Programming without `declare(strict_types=1)` seems anachronistic at this point. Greets, Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/