Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:33208 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42871 invoked by uid 1010); 17 Nov 2007 06:11:05 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 42856 invoked from network); 17 Nov 2007 06:11:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Nov 2007 06:11:04 -0000 Authentication-Results: pb1.pair.com smtp.mail=sam@sambarrow.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=sam@sambarrow.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain sambarrow.com from 205.234.132.11 cause and error) X-PHP-List-Original-Sender: sam@sambarrow.com X-Host-Fingerprint: 205.234.132.11 scottsdale.servershost.net Received: from [205.234.132.11] ([205.234.132.11:49417] helo=scottsdale.servershost.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 35/0E-51194-7F58E374 for ; Sat, 17 Nov 2007 01:11:03 -0500 Received: from [216.15.51.211] (port=50700 helo=[192.168.1.90]) by scottsdale.servershost.net with esmtpsa (SSLv3:RC4-MD5:128) (Exim 4.68) (envelope-from ) id 1ItGtV-0006l8-Rr; Sat, 17 Nov 2007 00:11:05 -0600 To: carl.corliss@xaraya.com Cc: internals@lists.php.net In-Reply-To: References: <8D.46.01128.768AD374@pb1.pair.com> <1195246391.21084.15.camel@sbarrow-desktop> <1195250285.4012.6.camel@johannes.nop> <1195251014.21084.20.camel@sbarrow-desktop> Content-Type: text/plain Date: Sat, 17 Nov 2007 01:11:04 -0500 Message-ID: <1195279864.12249.51.camel@sams-room> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 Content-Transfer-Encoding: 7bit X-Antivirus-Scanner: Clean mail though you should still use an Antivirus X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - scottsdale.servershost.net X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - sambarrow.com X-Source: X-Source-Args: X-Source-Dir: Subject: Re: [PHP-DEV] Re: Question about superglobals From: sam@sambarrow.com (Sam Barrow) Not a bad idea, however in my case (don't know about others) I have very deep arrays i use for my configuration. This would be more of a pain to use with these get and set functions. Also, the performance would probably be worse than just directly accessing the variable. Good point about not fixing what's not broken, but I think in this context it couldn't hurt to fix it. I have already fixed it, my patch is already written and I will continue testing it but I haven't come across any problems using it. On Sat, 2007-11-17 at 01:05 -0500, Carl P. Corliss wrote: > Sam Barrow wrote: > > Thanks everyone, I knew this, but I didn't want to use runkit because it > > is a beta, and i don't want all that other stuff, just superglobals. > > Also, runkit only allows you to use php.ini, but my patch allows you to > > specify superglobals in your script with the keyword "superglobal" by > > saying: > > > > superglobal $var1, $var2 ; > > I don't get why you can't just use a Registry pattern here. Having a > simpleRegistry object that you can throw data into and pull out of not only > allows you to keep your global space clean, but allows you to encapsulate > your "global" data and access it via a simple interface. Sure, it might be a > few extra keystrokes to type something akin to: Registry::get('var1'); but, > personally, I think the trade-off is well worth it. > > simple example class: > -------------------- > class Registry { > protect function __construct() {} // no instantiation - static class > static protected $data = array(); > > static public function get($name) { > return (isset(self::$data[$name]) ? self::$data[$name] : null); > } > > static public function set($name, value) { > self::$data[$name] = $value; > } > } > -------------------- > > summary: why "fix" what ain't really broke...? > > Cheers!, > > -- > Carl >