> -Original Message-
> From: p...@golemon.com [mailto:p...@golemon.com] On Behalf Of Sara
> Golemon
> Sent: Sunday, December 10, 2017 1:50 AM
> To: Andreas Hennings
> Cc: PHP internals
> Subject: Re: [PHP-DEV] instanceof survives non-object variables, but crashes
> on non-object constants
On Sat, Dec 9, 2017 at 1:28 AM, Andreas Hennings wrote:
> The following (https://3v4l.org/A2Tp6) is ok, it simply returns false:
>
> $x = 1;
> $x instanceof \stdClass;
>
>
> The following (https://3v4l.org/IdSBu) gives a fatal error:
>
> 1 instanceof \stdclass;
>
> t think this behavio
On Sun, Dec 10, 2017 at 12:09 AM, Stanislav Malyshev
wrote:
> Hi!
>
> > t think this behavior is inconsistent, and we should consider changing
> it.
> >
> > There are two options, but only one is BC.
> >
> > - Let 1 instanceof \stdClass return false, instead of crashing. -> seems
> BC
> > - Let $
Hi!
> t think this behavior is inconsistent, and we should consider changing it.
>
> There are two options, but only one is BC.
>
> - Let 1 instanceof \stdClass return false, instead of crashing. -> seems BC
> - Let $x instanceof \stdClass crash, if $x is not an object. -> BC break.
Neither of
On 9 December 2017 at 16:19, Aidan Woods wrote:
> > where the three lines return `false`, the third [...]
>
> Oops, that should say "the first two lines return `true`, the third
> `false`" (the point here being that they return something, as opposed to
> the later three, which throw).
>
>
This is
On Fri, Dec 8, 2017 at 11:35 PM, Kalle Sommer Nielsen wrote:
> We should just add a warning to the first example, it seems like an
> oversight that it was left silent
I strongly object! We ought to consider using `instanceof` to support
more type-checks than just classes. I think `1 instanceof in
> where the three lines return `false`, the third [...]
Oops, that should say "the first two lines return `true`, the third
`false`" (the point here being that they return something, as opposed to
the later three, which throw).
On 9 December 2017 at 15:13, Aidan Woods wrote:
> I prefer the inco
I prefer the inconsistency between `$x instanceof \stdClass` and `1
instanceof \stdClass`, than adding a warning (or throwing) to `$x
instanceof \stdClass` when `$x = 1`.
I think `1 instanceof \stdClass === false` would be reasonable.
1. PHP has no means of locking a variable to a type (i.e. the
On Wed, Feb 22, 2017 at 9:03 PM, David Walker wrote:
> On Mon, Feb 6, 2017 at 10:54 AM David Walker wrote:
>
> > Hi all,
> >
> > Having seen no further discussion I'd like to open the RFC[1] for voting.
> > Voting will be given just over 2 weeks ending Feb 22nd. RFC has
> > implementation[2] an
>
> That is fine for code that is broken in the first place. Similarly we added
> a warning some years back about array to string conversions.
>
Code using instanceof on possible non-objects isn't broken. instanceof
simply does an implicit is_object() check without needing an extra function
call.
The typical usage of `instanceof` is checking a `null|object` API that
built an object of a (presumably known) type. Adding a crash there seems
silly and overcomplicated.
On 9 Dec 2017 07:57, "Andreas Hennings" wrote:
> Why is the usage broken? It works :)
> In practice, the current version of i
11 matches
Mail list logo