Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110489 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 26907 invoked from network); 11 Jun 2020 21:55:44 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Jun 2020 21:55:44 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3899C1804F2 for ; Thu, 11 Jun 2020 13:39:59 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 11 Jun 2020 13:39:58 -0700 (PDT) Received: by mail-lf1-f43.google.com with SMTP id z206so4266629lfc.6 for ; Thu, 11 Jun 2020 13:39:58 -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=zjgnOjNA7T/1KnBfEW31w8PIZwM8IXxSJw3JRhEt+vo=; b=PsmRkfiuU4O5IBXWXp2GC9Dw/Bh9QFeXbcv4CTBv5+Te5ZlVMnVPhnj9nEAF9qsd1D shzUn5Sk4YBCfWz8LQffbhwomBscvXW/kGPRGdbcEMgmYkb2dofUmVc7VlB/dQ8+y8zZ KZHsbYXFFF+I+ut8ucDkl8ZYNhMbiLsADlLwfFHOwEcRwXHVoq6zmwW3F7ugqgJWqm08 yOGm22/yMcPvCOcbb8KiOjjFr47sd6Yt+I3s9mddnV0zcnqBE5rX2AKNEYABxaLqjEnc /LTOyzG9hw7HlvXQgblFfAOvuRlfIJUbVvtq4qzCZrCAa4vqW9kQ3KN9wPFtdSS9msLn 4mnw== 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=zjgnOjNA7T/1KnBfEW31w8PIZwM8IXxSJw3JRhEt+vo=; b=b3GxTQiLDYdQLTrUhvUbrKpsod1NNVFzpbMzRednNsCjLZ4PDiUNydsA+WYJhpIfq2 AUx4OtcocDLYHpwgJ8/IGmFR8AF+IHn20TAi5WipvN/q6mplDnnFcXKNm1ocbdyLfPNn bmrEZXDsVkLyZMYbV5jnLlFZzA90qDwmDYCiyzHGl0huZYS73JtVQnaR7uep0AXv7vel 3EIOkTaNsyosdeeZlPUKtSyH7Pg7R1IzKO9zWBH1GKWPma20vH6gbRKM98eimEN7Ibg+ p5lr+im1AdE4334W1Bs3cR+r0qmX03sZWWjw/roVMzyrNntd2HGKv4SxxO989P1ZYsrp 92rg== X-Gm-Message-State: AOAM533i9GsrJXTiYc7tqcjX+qQLFxndX66oEDhBeFu4hDHTsCBtJexw Vt17KnmMA1ZEKRsvlzOy6NfQTQuUKW+tI4vlxAo= X-Google-Smtp-Source: ABdhPJxyO+az93QXsqxBJRaBAJmVOUL0forq6Qe/Pqzmc3XDzA36VhGbZyfsYSDVq45PPpP4nQbzUWy190Yhh4MRhjE= X-Received: by 2002:ac2:4a75:: with SMTP id q21mr3867658lfp.190.1591907994087; Thu, 11 Jun 2020 13:39:54 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 11 Jun 2020 22:39:38 +0200 Message-ID: To: Troy McCabe Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000080b51205a7d4f6f0" Subject: Re: [PHP-DEV] Revisiting proposal for addition of `get_class_constants()` From: nikita.ppv@gmail.com (Nikita Popov) --00000000000080b51205a7d4f6f0 Content-Type: text/plain; charset="UTF-8" On Wed, Jun 10, 2020 at 6:33 AM Troy McCabe wrote: > Hi All, > > With several functions (`str_contains()`, `str_[starts|ends]_with()`) added > for PHP8 to make things more clear, it feels like a good time to revisit > the multiple requests to add `get_class_constants(string $class): array`. > This would allow userland code to retrieve constants in the same way as > properties / methods, instead of having to use reflection for constants and > built-in functions for properties / methods. In addition to uniformity, a > bit of fiddling shows close to half the time for 10k executions > > I'm willing to implement if there's interest (curiosity got the best of me > for the aforementioned fiddling) > Could you please explain in more detail *why* we should duplicate existing reflection functionality into free-standing functions? I believe the existence of functions like get_class_methods() is a historical artifact, because they were introduced before Reflection was a thing. Unless there is a strong reason to the contrary, I would prefer reflection functionality to stay inside Reflection... You do mention performance as a benefit, but it's not immediately obvious to me which use-cases are bottlenecked by class constant reflection. Regards, Nikita --00000000000080b51205a7d4f6f0--