Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101299 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 930 invoked from network); 11 Dec 2017 02:11:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Dec 2017 02:11:36 -0000 Authentication-Results: pb1.pair.com header.from=andreas@dqxtech.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=andreas@dqxtech.net; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain dqxtech.net from 209.85.215.47 cause and error) X-PHP-List-Original-Sender: andreas@dqxtech.net X-Host-Fingerprint: 209.85.215.47 mail-lf0-f47.google.com Received: from [209.85.215.47] ([209.85.215.47:44664] helo=mail-lf0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 31/B4-53433-759ED2A5 for ; Sun, 10 Dec 2017 21:11:35 -0500 Received: by mail-lf0-f47.google.com with SMTP id x204so17421182lfa.11 for ; Sun, 10 Dec 2017 18:11:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dqxtech-net.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=rEh12SYiO2xkKJhYLW7uiiQglCiMuGJUZnNFZp6YRhY=; b=hQHMtXCEk2JFu74JCnkzsu/x1t80M4k3aO4xkECDDrQrLIA/0CFPRRvM4HJb76O5Lv gBGKGudYUcusjf7/eJRhjbUPON1GvEsTwkjKzTIPxO0EKTW+GI0GCbbBCSaVreAkfhS6 NWpx+DAT03RlO/RdmlgkVlwzNb1S3yn9nbBQVimGRRKyX7Ku9bn6l2B2dTJyzFo7xxTD mrHKtO3AVd/nxNZK+NfQx0APFGl9UZXFThDkZ3SjTckWEG9kA6o2+qUThg4bwGnfTFyg XwRG/DUIAWo6u3Xg0tecoOrc5HwbbIUJ8ZyTBGpEzdherrHjAPzPz83naRP+8T3rkKSt 3mkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=rEh12SYiO2xkKJhYLW7uiiQglCiMuGJUZnNFZp6YRhY=; b=YAVBAFEFCNIdpKwPIEPWMHbqM2nDwa9VdLiY40xozRCrm9wq0I/TIIAKDa8cP9Vij3 7j2fC5nlUlknkve4E+F8Bq7v89SL8Hl6jgIduo+EgNyk3diszDxJXl4XnqvgV3J1j05E JwkUFScrp8jhPScuGvvZPOh8/QfNyJUMk/S2EkgyKt0QzmecK9RKJvl5k7ztJ8BQ45qt gEe+7RI3RBxeOGgvwSbUiDWyDapdFXl5DXCXaRKnJzecLzEj7Krt11iS7O1y7h7FeWyv QLUyXEiGqmRmT4TDQ8VK3QAzviMQs0lTkQfh24qOm5YjXsgyJQcjCRpWJTwb66WxSnxt 8Kxw== X-Gm-Message-State: AJaThX5Vx54OAv32/ErZgSHp4SN/v/c62dJXCaDgXK0t6ULi6i2F9RWw p3amWJ3JtiqJlu1t6i9TzL6a93ti X-Google-Smtp-Source: AGs4zMaoMc0w8nviZH691jQrl7C5JmFcB2n45Tbe5VucI/ufQ7W75LLDIQkPH/yWWM3BBcaylXvSZA== X-Received: by 10.25.195.211 with SMTP id t202mr15536358lff.53.1512958290873; Sun, 10 Dec 2017 18:11:30 -0800 (PST) Received: from mail-lf0-f45.google.com (mail-lf0-f45.google.com. [209.85.215.45]) by smtp.googlemail.com with ESMTPSA id j85sm2532433lfh.53.2017.12.10.18.11.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Dec 2017 18:11:29 -0800 (PST) Received: by mail-lf0-f45.google.com with SMTP id a12so17447128lfe.4 for ; Sun, 10 Dec 2017 18:11:29 -0800 (PST) X-Received: by 10.25.31.146 with SMTP id f140mr15657596lff.156.1512958288957; Sun, 10 Dec 2017 18:11:28 -0800 (PST) MIME-Version: 1.0 Received: by 10.25.170.16 with HTTP; Sun, 10 Dec 2017 18:11:08 -0800 (PST) Date: Mon, 11 Dec 2017 03:11:08 +0100 X-Gmail-Original-Message-ID: Message-ID: To: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Add \Reflection*::getHash() From: andreas@dqxtech.net (Andreas Hennings) I propose to add a new method ::getHash() to reflection API classes. Such that: Two reflectors return the same hash, if and only if: 1. the reflected items have the same type (class, method, parameter etc), AND. 2. the reflected items have the same names, AND. 3. the reflected items have the same PHP code (e.g. for distinct processes), AND. 4. optionally: Every base class, every implemented interface and every used trait has the same PHP code (and thus, the same hash). 5. optionally: The PHP version and PHP settings are the same. (*) Such an id can be used as a cache key between requests. It would automatically change / become invalid, if: - new code changes are deployed, OR. - different processes include different files that each declare the same class, OR. - php is upgraded, or php settings change. (*) Currently the best way (for practicality and performance) to achieve something like this is to get the timestamp of the file that defines the class. Note: The behavior of a function can change if the code of another function that is being called is modified. The hash would still be the same, because it does not look at functions being called. (*) Maybe for the php version and settings there should instead be a global hash, which can be used as salt for a combined cache key. I was first going to propose to add this new method directly on \Reflector interface. But this would be a BC break, because userland classes that implement this interface would break. So instead, either - add it to each class separately, or - add a new interface \Reflector2 extends \Reflector (yeah, versioned interfaces!), and let all reflection classes implement that.