Re: Typed properties problems

From: Date: Tue, 17 Jan 2017 22:03:27 +0000
Subject: Re: Typed properties problems
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-97839@lists.php.net to get a copy of this message
On Tue, Jan 17, 2017 at 4:52 PM, Stanislav Malyshev <smalyshev@gmail.com> wrote: > Hi! > > > That's pretty messed-up right there. At least in the object cases there's > > an E_WARNING "Creating default object from empty value" - with the array > > case, nothing, it just converts your boolean into an array. Yiiiiikes. > > You told PHP you want an array, you get an array. > > Exactly. Scalars can change datatypes without warning. That's powerful, but also migrane inducing when not used properly. I taught myself PHP. For the first two years I had no real grasp of the significance of datatypes, and it would be another two before I felt a need to want to control datatypes. Strict datatyping makes a language harder to use for beginners. Loose datatyping can make debugging harder on veterans. For that reason PHP should ideally be able to do both. A step in that direction was taken in 7 with the strict type declarations for function arguments and returns. Applying this to properties would be nice, but the coercion rules for situations like Stanislav gave are going to be difficult.

« previous php.internals (#97839) next »