Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102694 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79547 invoked from network); 10 Jul 2018 10:16:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Jul 2018 10:16:11 -0000 Authentication-Results: pb1.pair.com header.from=nicolas.grekas@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.49 as permitted sender) X-PHP-List-Original-Sender: nicolas.grekas@gmail.com X-Host-Fingerprint: 209.85.218.49 mail-oi0-f49.google.com Received: from [209.85.218.49] ([209.85.218.49:41785] helo=mail-oi0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1A/01-49043-967844B5 for ; Tue, 10 Jul 2018 06:16:09 -0400 Received: by mail-oi0-f49.google.com with SMTP id k12-v6so41528702oiw.8 for ; Tue, 10 Jul 2018 03:16:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=mfcNDDk/2T9nTF/EZGAZ+AHijXFTVfW8rYkzmtJLh3w=; b=W/JZK/bY5nmnoVBdLXgRSuxXYlMnsHbYpgJCDT0aJZcY7QZlo5QqoxxuLhhPynLPJo RbSVvkTGbR8+X+QOuPcMHNfRuzPdstHG9M7RcTPkmVzwSa3SIY/4oMRoMyVfaWDLClJT ZotV1IFwPPwSVGDyvIZj9pME0XVkjCtGJCLWqh8ilyVJP+MpFq9drXl0/2mM56BSezb7 WvfJlaTwJrjJTYibOgAongAs4BL+KvVl/Dvmo49TJqryiLbAcz+IbQbpmT+YQdoUSE2X I0NhjC5LGuTNZ9Yf/qs+to6sOz6/WhJDjQHeE9NabqC3YWVoEICZa34++Px7W59Kh+tS rH4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=mfcNDDk/2T9nTF/EZGAZ+AHijXFTVfW8rYkzmtJLh3w=; b=nRf2gRvRQXAChlNfQWatgOoJFM4vsnFQ4uAAVhfIXEXBjxHmOcEP4IxL9deJkwp4cA POR8uFutCRoQk26Abvm0TnpAxHIoXwER2bQlwmmY0dqzbpIsI108SPw4CTEVibNzsNoy /uMSWsIKnVUp5mSnouGNlVvo3s5Fhqew4ddTUPHVtFExKGQOexCaeQ2nKiZx+jzrYyLl TijpW74WiUTwlKXcJccDl38r+v1UYX5XY+73KCyaqlJMVSL6kdgyJarfnzyTBJQbAJRc qpXJkYa3XJqKqAng/BZ2wP2jCme43QNN0/T2Z9mTKlUbe0VhqTFkoVNwZ9C3Qe7842Ss QAuA== X-Gm-Message-State: APt69E0CcXw99Gk1fzXGqM6heLQMtHwByaZnn7ujDQmjwmw0lZsr09Qh 5GAW1gKesDol+HVZGvu17DzfS2C2+aYm2tlNmI0= X-Google-Smtp-Source: AAOMgpf9kxJ8b8GG3pCKYmIojlFmduF4moCzYFm0fkRt8rACaZAvgdwMuzvWo52qMNPii2aqXNfctuBXiFdLKTxv0kA= X-Received: by 2002:aca:e142:: with SMTP id y63-v6mr28490984oig.128.1531217766664; Tue, 10 Jul 2018 03:16:06 -0700 (PDT) MIME-Version: 1.0 Sender: nicolas.grekas@gmail.com Received: by 2002:a4a:1e45:0:0:0:0:0 with HTTP; Tue, 10 Jul 2018 03:15:46 -0700 (PDT) In-Reply-To: References: Date: Tue, 10 Jul 2018 12:15:46 +0200 X-Google-Sender-Auth: b0HP8aI2h4mdAwV7HsUfVJZtxVo Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000000e4f850570a26b11" Subject: Re: [PHP-DEV] Introspection for references From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --0000000000000e4f850570a26b11 Content-Type: text/plain; charset="UTF-8" > > If we're seeking for a benefit, it would be by turning this to a >> ReflectionZval insteaf of ReflectionReference. There would be isRef, but >> also getType, etc. But honeslty I'm with you on this, only refs make sense. >> > > I'm wondering if there is any legitimate use for something like this. The > only thing that comes to mind is comparing arrays by identity. E.g. > https://github.com/symfony/symfony/blob/master/src/ > Symfony/Component/VarDumper/Cloner/VarCloner.php#L153 could check > directly check whether an array is the $GLOBALS array. It would also allow > direct recursion detection on arrays (ref https://stackoverflow.com/ > questions/9105816/is-there-a-way-to-detect-circular-arrays-in-pure-php). > Doing the same on just references is nearly the same, but doesn't handle > the $GLOBALS case correctly. > Note that AFAIK, not only $GLOBALS has a special behavior, but also any "scope" array (the deprecated $context argument of error handlers at least, maybe what get_defined_vars() also? If we can return this info, I would definitely leverage it. If not, that's no blocker, I'll let you decide. > There is a 4th possibility: have a "ReflectionReference::getHash" method, >> that would return a unique string/id per reference (what >> symfony_zval_debug() does.) >> > > Is this the same as my 3rd suggestion with a different name > No, it's the same, I read too fast. > we could return the address hashed with a per-process key. This would make > the function somewhat slower though. > That's exactly what we do in our extension, inspired by spl_object_hash(). On the perf side, a XOR should be OK :) Thanks, Nicolas --0000000000000e4f850570a26b11--