Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:102629
Return-Path: <nicolas.grekas@gmail.com>
Mailing-List: contact internals-help@lists.php.net; run by ezmlm
Delivered-To: mailing list internals@lists.php.net
Received: (qmail 94452 invoked from network); 6 Jul 2018 20:57:42 -0000
Received: from unknown (HELO lists.php.net) (127.0.0.1)
  by localhost with SMTP; 6 Jul 2018 20:57:42 -0000
Authentication-Results: pb1.pair.com header.from=nicolas.grekas+php@gmail.com; sender-id=pass
Authentication-Results: pb1.pair.com smtp.mail=nicolas.grekas@gmail.com; spf=pass; sender-id=pass
Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.52 as permitted sender)
X-PHP-List-Original-Sender: nicolas.grekas@gmail.com
X-Host-Fingerprint: 209.85.218.52 mail-oi0-f52.google.com  
Received: from [209.85.218.52] ([209.85.218.52:46836] helo=mail-oi0-f52.google.com)
	by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP
	id 86/CE-55607-5C7DF3B5 for <internals@lists.php.net>; Fri, 06 Jul 2018 16:57:41 -0400
Received: by mail-oi0-f52.google.com with SMTP id y207-v6so25800622oie.13
        for <internals@lists.php.net>; Fri, 06 Jul 2018 13:57:41 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=mime-version:references:in-reply-to:from:date:message-id:subject:to
         :cc;
        bh=KML/sEKgD6zVi28yR4pClmG2bDlIu1d1zQqg3T4s8Ic=;
        b=VloRoRwFaw+VVD7r2CqlMqfEhSyuIFvOH3wiJgD1pbILF6ICHu9wrNUkIlvF50KVB4
         ULZIw/tZy+ZRiJ2+cvvJ2BoVgSsqxDvS8kXjZTROesAlp2xyjdr8KopmsBFV0FodyEis
         W00rU/O4vZBtsAH9lz4gk3DWIdw+ll11NTZGkkf/I0ZHEfOMnDzlTqStPchai+cZRd1u
         CueHqXojyHXCY5kdlGGxWkWilJoRf/6mi7ZWU6fUe+myVzco4dXj68xmteepxbgzqCVD
         WujLWOie/F7pgO5ES8MAXTxovFUmDpULHCkQU9kTHPLZmRdAgWvERj3qHbrl1tepjWfy
         LSUw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:references:in-reply-to:from:date
         :message-id:subject:to:cc;
        bh=KML/sEKgD6zVi28yR4pClmG2bDlIu1d1zQqg3T4s8Ic=;
        b=lGEw0GxCfvHaeBovnhlQ/jh0YIHkexGB/8LRSOI/3wfYjFc5yRowrd3tVKSbuUp73J
         cj/s4mSInAL2lh16p9QYsmeXpi3axPvyJLuy/DoWVDV7FgOlVS+zHx/fSBl96XJ5hx4Z
         69EErJHQ2ya3bCmdOIdjR1cVBw3fXMXNaAPpnD7OngrjjrwbVDZLrYuC1VFUQMrpECCs
         CknTXeh9mt+7pga+Y6+7Aw12tqh77/2Y52jPpafOLIrr3zsR86lluJNS3sixgkQKkjXq
         bNcaJMr4qfrdbrkFoMnU//pYPrGSZvoMDpWTBBClHvJSUkmI8GpceEbuy46w1bHvAAF1
         Bbew==
X-Gm-Message-State: APt69E2Qu3WursjTDW9nngNlanSiJh9xtEtTk8l6mLAANLZYxaErofe+
	YGEbJXXrTCcwAlAzDYexAvXCvbZahkxM77A/kwU=
X-Google-Smtp-Source: AAOMgpcRHKF+42oV6NCHYzRXYz7JEmcSW5igoqWkmqE29KUFoJCCaiYF9VHw1GZ/6wbmeiTiL+/saTfM/Lak0GQeXR0=
X-Received: by 2002:aca:42:: with SMTP id 63-v6mr11965120oia.154.1530910659004;
 Fri, 06 Jul 2018 13:57:39 -0700 (PDT)
MIME-Version: 1.0
References: <CAF+90c_L7S+EB8YxdNNpNZ7NhhYwCbwEw5_TSnSwUNN-zLVvCg@mail.gmail.com>
 <CAOWwgpkJyceDjKoSZ+PDcCjvUvgp=FeDV9aWE2m2jjtVuhP1Tw@mail.gmail.com>
 <AM0PR0702MB36847FDEDE273866A7824ED8E2760@AM0PR0702MB3684.eurprd07.prod.outlook.com>
 <CAOWwgp=icysgYCyPxF2eUuVtc1Kp5vv69n77JbmEM+GPfJJ-1g@mail.gmail.com>
 <AM0PR0702MB3684C920F3A3E1A0EC4BA8B2E2760@AM0PR0702MB3684.eurprd07.prod.outlook.com>
 <CAOWwgpnutsqeAzSmHyvxqasjn3y8COG2_TY7RNjxoDq76Wq=Ng@mail.gmail.com>
In-Reply-To: <CAOWwgpnutsqeAzSmHyvxqasjn3y8COG2_TY7RNjxoDq76Wq=Ng@mail.gmail.com>
Date: Fri, 6 Jul 2018 22:57:26 +0200
Message-ID: <CAOWwgpn-W+1b=Yme_w-uDdsqp7wqhR9WpcO3KTX9ofNLVOwyew@mail.gmail.com>
To: Bob Weinand <bobwei9@hotmail.com>
Cc: Nikita Popov <nikita.ppv@gmail.com>, PHP Internals List <internals@lists.php.net>
Content-Type: multipart/alternative; boundary="000000000000034ccd05705aea4c"
Subject: Re: [PHP-DEV] [RFC] Typed Properties
From: nicolas.grekas+php@gmail.com (Nicolas Grekas)

--000000000000034ccd05705aea4c
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Le jeu. 21 juin 2018 =C3=A0 19:37, Nicolas Grekas <nicolas.grekas+php@gmail=
.com>
a =C3=A9crit :

> if ((new ReflectionReference($array[$key]))->getRefcount() > 2) { /* is
>> ref */ } else { /* not a ref */ }, for computing the allowed types you=
=E2=80=99d
>> intersect the types of the ReflectionProperties returned by
>> getReferencingProperties().
>>
>

I just realized that this interface would suffer from a significant
drawback: it would trigger COW when iterating over immutable arrays,
defeating the shared-memory optimization provided by OPcache.

An interface like new ReflectionReference($array, $key) would be free from
the issue. Combined with get_defined_vars() and the (array) operator for
objects, we can inspect any PHP data structure or scope also this way.

Nicolas

>

--000000000000034ccd05705aea4c--