Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66276 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4049 invoked from network); 27 Feb 2013 15:58:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Feb 2013 15:58:35 -0000 Authentication-Results: pb1.pair.com smtp.mail=pencap@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=pencap@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.210.173 as permitted sender) X-PHP-List-Original-Sender: pencap@gmail.com X-Host-Fingerprint: 209.85.210.173 mail-ia0-f173.google.com Received: from [209.85.210.173] ([209.85.210.173:47158] helo=mail-ia0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7E/A0-33355-A2D2E215 for ; Wed, 27 Feb 2013 10:58:34 -0500 Received: by mail-ia0-f173.google.com with SMTP id h37so599285iak.18 for ; Wed, 27 Feb 2013 07:58:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=wCfvbvvmqRLGeQvye6yWy/qxbdu+HpmbQXDihpRavU4=; b=QLjjPXVA34zRXtauN6qKnOITVQO/dJI7i53KZ8PqVLGdTo9AWFVANzf8c1O+zHdozZ kIHsaTnLHVWsvj6d4/aYqutgucw3aOz+gMl5DJA9QaVKkTe0infqlIimqkkNHVZ1U1vk ib7TV80RyUV7aNQsxTf2lL97rM6Q+nB0ATnwrpANievx7Djr2Q1L0c94yb4cZgWEL6xe C/YGfr4XAq90zpnbflpgOkMTZGgowvh1vyKMOwwxV7QpkpJL57jUlYlIJpeGEF/0nzr8 EESkHHQEYVpXfz+tg1z+8W6O3IilOOKey2vdkP/vWo25/GTG8njlVrBAOJHPo/ttZ6iD mUMQ== MIME-Version: 1.0 X-Received: by 10.43.83.74 with SMTP id af10mr1169225icc.38.1361980710639; Wed, 27 Feb 2013 07:58:30 -0800 (PST) Received: by 10.50.85.232 with HTTP; Wed, 27 Feb 2013 07:58:30 -0800 (PST) In-Reply-To: <512E2278.3070406@2e-systems.com> References: <512DB820.6060908@sugarcrm.com> <512E1E1B.6020007@googlemail.com> <512E2278.3070406@2e-systems.com> Date: Wed, 27 Feb 2013 07:58:30 -0800 Message-ID: To: Frank Schenk Cc: PHP Internals Content-Type: multipart/alternative; boundary=bcaec5186aaa72eea404d6b6d81d Subject: Re: [PHP-DEV] Add get_object_constants and get_class_constants From: pencap@gmail.com (Mike Willbanks) --bcaec5186aaa72eea404d6b6d81d Content-Type: text/plain; charset=UTF-8 > > > thank you! It is a useful feature to me. > > > > class MyBitmask { > > const POS_1 = 1; > > // const POS_2 = 2; // reserved/undefined > > // const POS_3 = 3; // reserved/undefined > > const POS_4 = 4; > > I'm developing software with PHP since version 2 and i'm still easily > impressed by such code. So we need get_object_constants and > get_class_constants for such fancy stuff? > > Where's the good old > $flag == true; or FLAG == true;? > > A bitmask class to shuffle around with class constants using reflection > of itself and a magic method get_class_constants to check a boolean flag? > > I just don't get it but maybe i'm to focused to doing things the most > simple and readable/maintainable way. > The simple case of things like this is to be able to read extended classes; say you are enforcing some type of bitmask checking; well extended classes may not have the same signature. Bitmasks are nothing new; PHP uses several of them internally and several of them inside of various functions (generally a bitmask would look more like: 00000 = 0 00001 = 1 00010 = 2 00100 = 4 01000 = 8 10000 = 16 > > Maybe, in a few years, c++ will be a beginners language compared to PHP > which gets added new shiny features every day which will only be used by > even more shiny frameworks and the most shiniest, bloated objects one > can imagine. > > With every fancy feature added to PHP you kill a kitten! > This is not necessarily a new feature; it's simply rounding out some of the already existing functions. We're not talking about new "framework" features; we are talking about ways to get things done quicker (although the fractions of microseconds don't made a huge difference). If you think this is a new fancy feature; you likely think that this is the shiniest: $class = new Reflection('MyClass'); $constants = $class->getConstants(); I'm more with this "Give PHP and it's core developers a rest" so that > the core can be improved/cleaned up instead of adding Java features > people have seen on the university and like them but now they're forced > to use PHP which is like the opposite of Java. Java has it's good > reasons too. Just a tool. Use the tool that fits best, don't use the > hammer as a saw by adding teeth to it. > Funny enough; this is more PHP like than Java; the Reflection class is more java oriented and already exists and is not touched in this. We're talking about global functions. Sure give PHP a rest; but you know... I was raising this simply for consistency; speed. I am not asking anyone else to work on this; hell part of the reason I submitted the PR before even writing an RFC. I am simply suggesting an alternative to using Reflection whereas: get_class_constants([object|string]); get_object_constants([object]); Do we need both; probably not; the first would likely do. --bcaec5186aaa72eea404d6b6d81d--