Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70638 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11592 invoked from network); 14 Dec 2013 13:59:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Dec 2013 13:59:44 -0000 Authentication-Results: pb1.pair.com header.from=php@tutteli.ch; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=php@tutteli.ch; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain tutteli.ch designates 80.74.154.78 as permitted sender) X-PHP-List-Original-Sender: php@tutteli.ch X-Host-Fingerprint: 80.74.154.78 ns73.kreativmedia.ch Linux 2.6 Received: from [80.74.154.78] ([80.74.154.78:53074] helo=hyperion.kreativmedia.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EE/84-11187-D446CA25 for ; Sat, 14 Dec 2013 08:59:43 -0500 Received: (qmail 9845 invoked from network); 14 Dec 2013 14:59:39 +0100 Received: from heim-032-99.raab-heim.uni-linz.ac.at (HELO RoLaptop) (193.171.32.99) by ns73.kreativmedia.ch with (AES128-SHA encrypted) SMTP; 14 Dec 2013 14:59:39 +0100 To: "'Marco Pivetta'" , "'Lester Caine'" Cc: "'PHP Internals List'" References: <52ABA642.9090206@php.net> <52ABA947.4030908@ajf.me> <52AC5E19.8060203@lsces.co.uk> In-Reply-To: Date: Sat, 14 Dec 2013 14:59:35 +0100 Message-ID: <000f01cef8d4$b94c3ea0$2be4bbe0$@tutteli.ch> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQJqmiCp3inJEzlo3iP7b3VBM67XbAH7c6DgAdvygV0BUXQJXpjzLJwQ Content-Language: de-ch Subject: RE: [PHP-DEV] Proposal for RFC: get_class_constants() From: php@tutteli.ch ("Robert Stoll") > -----Original Message----- > From: Marco Pivetta [mailto:ocramius@gmail.com] > Sent: Saturday, December 14, 2013 2:51 PM > To: Lester Caine > Cc: PHP Internals List > Subject: Re: [PHP-DEV] Proposal for RFC: get_class_constants() >=20 > On 14 December 2013 14:33, Lester Caine wrote: >=20 > If it is the only reason you are having to activate reflections? > Reflections would seem to have a place, but is it really necessary to = add > yet another layer when most of the time it's function is provided = better by > IDE tools anyway? This is a simple example of a current hole in the = core > PHP tools which would help a section of developers who don't need the > overheads of additional layers. >=20 > @Lester additional layer is still better than *yet another shortcut*. >=20 > Since we already have the feature, introducing another flavor for it = seems > a bit of an overkill, especially if it also has to be maintained. >=20 > Any userland implementation can handle this by also being fast enuff: >=20 > function get_class_constants($className) > { > static $cached =3D []; >=20 > if (isset($cached[$className])) { > return $cached[$className]; > } >=20 > return $cached[$class] =3D (new = \ReflectionClass($class))->getConstants(); > } >=20 >=20 > Marco Pivetta >=20 > http://twitter.com/Ocramius >=20 > http://ocramius.github.com/ I am asking myself why PHP hasn't implement ReflectionClass the way = Stefan wants to implement get_class_constants() if his approach is = faster.=20 I agree that it is somewhat an overkill to have another function for = this but maybe Stefan can instead propose to change the implementation = for ReflectionClass and all would benefit from it? On the other hand, it's quite inconsistent to have get_class_methods(), = get_class_vars() but not get_class_constants().=20