On Tue, Jan 17, 2017 at 4:52 PM, Stanislav Malyshev <smalys...@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.

Reply via email to