Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101302 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6651 invoked from network); 11 Dec 2017 03:04:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Dec 2017 03:04:12 -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.44 cause and error) X-PHP-List-Original-Sender: andreas@dqxtech.net X-Host-Fingerprint: 209.85.215.44 mail-lf0-f44.google.com Received: from [209.85.215.44] ([209.85.215.44:41387] helo=mail-lf0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 09/A5-53433-BA5FD2A5 for ; Sun, 10 Dec 2017 22:04:12 -0500 Received: by mail-lf0-f44.google.com with SMTP id f18so17530680lfg.8 for ; Sun, 10 Dec 2017 19:04:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dqxtech-net.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=MTL0ZfI/1vvFrmrFq/lTEo1sxazGEgXGgbYTk0gCA9I=; b=osUpID3zT77CQIld0ZdFPz0S9852+IX4dv6zSJSLJEJdT0kVunWTuqSLJeWV/Gey/r G1cdBsuWE8qNqlyFI2aGyIa6jpiTBFrsS3QtLGzRQECPKO8h4enO2ed6lfKTO0eoIYxa +0z5oMXhwCz/a7KDyel8GfjwLd42sttQNW1evU9U5zhgFGk5lj+OZgQ3i/kLKLyMX7x7 9HehuH8YhF09Z4rJBb1KlLfqF023w2y7ZjbxQ8NNKL9bExWSqMF2o3OmPJy9U5kOE0Tt b3Gq2ZE2XS/MXlJzdme5JhAcPPvdQYShNa5iwoeVnIHloFN3WZfNa1L/gch7IuMc9pDa jpcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=MTL0ZfI/1vvFrmrFq/lTEo1sxazGEgXGgbYTk0gCA9I=; b=aNBPcvMULlGWAj18XdOo2yormU216EeYkT3XoKXwFcJK+c034BEoVaHGX3OWI62+Hg LbhbTqxCUwJ8sTaWBMuP+bS9v60McMtCap8mZVg7mDiI+b/0liMsShKeS6bzqoE70jew OHcKCmxKNOZGTY//+yrHYPlRh8xbjvfcaf1EZ9o8rioew4fXecvUrjEUYWsik6ZMmiIy sJIYA6RoASBFvY19c4jCh9CKthKgyDlfZIG6VEN25QI706SnphHSYLyz/21sJBrHWTTY VbcGTEtzH5P1+57g/p4C8R77tbLkTDBLPgu5giqGWVPOAmLmqMjP2r2vBeLQgoofyUGF K/Kw== X-Gm-Message-State: AJaThX5+GrY8HQFkmTMEqrSXi6y9fI6GMWRxuGXFvQLRztmuWZj79BEH DakuLwc4vRm+dTBRZ562uFtiD4uf X-Google-Smtp-Source: AGs4zMbEjGScWxOTLLXDw9t/Ay+hl9k9xUhZe65V4JlDQ6VVWnTc03JtHLYeWljmYH18Zd5QKbNrSw== X-Received: by 10.46.93.27 with SMTP id r27mr18452215ljb.96.1512961448629; Sun, 10 Dec 2017 19:04:08 -0800 (PST) Received: from mail-lf0-f54.google.com (mail-lf0-f54.google.com. [209.85.215.54]) by smtp.googlemail.com with ESMTPSA id e16sm2563538lja.29.2017.12.10.19.04.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Dec 2017 19:04:07 -0800 (PST) Received: by mail-lf0-f54.google.com with SMTP id j124so17549146lfg.2 for ; Sun, 10 Dec 2017 19:04:07 -0800 (PST) X-Received: by 10.25.31.146 with SMTP id f140mr15686764lff.156.1512961447231; Sun, 10 Dec 2017 19:04:07 -0800 (PST) MIME-Version: 1.0 Received: by 10.25.170.16 with HTTP; Sun, 10 Dec 2017 19:03:46 -0800 (PST) In-Reply-To: References: Date: Mon, 11 Dec 2017 04:03:46 +0100 X-Gmail-Original-Message-ID: Message-ID: To: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: Add \Reflection*::getHash() From: andreas@dqxtech.net (Andreas Hennings) So far this proposal only discusses reflections of PHP declarations / symbols. What would we do for e.g. ReflectionObject? Return the spl_object_hash()? Or return the hash of the instantiated class? Or a hash of the serialized object? We need to return something, because ReflectionObject extends ReflectionClass. On 11 December 2017 at 03:11, Andreas Hennings wrote: > 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.