Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:50941 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99970 invoked from network); 9 Dec 2010 12:15:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Dec 2010 12:15:50 -0000 Authentication-Results: pb1.pair.com header.from=php@hristov.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=php@hristov.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain hristov.com from 85.92.87.36 cause and error) X-PHP-List-Original-Sender: php@hristov.com X-Host-Fingerprint: 85.92.87.36 iko.gotobg.net Linux 2.6 Received: from [85.92.87.36] ([85.92.87.36:40480] helo=iko.gotobg.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 99/50-32433-578C00D4 for ; Thu, 09 Dec 2010 07:15:50 -0500 Received: from [77.0.224.33] (helo=[192.168.1.100]) by iko.gotobg.net with esmtpa (Exim 4.69) (envelope-from ) id 1PQfPN-0002qy-3W; Thu, 09 Dec 2010 14:15:37 +0200 Message-ID: <4D00C86D.70208@hristov.com> Date: Thu, 09 Dec 2010 13:15:41 +0100 User-Agent: Thunderbird 2.0.0.24 (X11/20100411) MIME-Version: 1.0 To: Ferenc Kovacs CC: PHP Internals List References: <4D00ABFE.5070403@hristov.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - iko.gotobg.net X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - hristov.com X-Source: X-Source-Args: X-Source-Dir: Subject: Re: [PHP-DEV] Deprecating "global" + $GLOBALS, making $_REQUEST, $_GET, $_POST read-only From: php@hristov.com (Andrey Hristov) Ferenc Kovacs wrote: > > > On Thu, Dec 9, 2010 at 11:14 AM, Andrey Hristov > wrote: > > Â Hi guys, > the topic says most of it. What do you think about deprecating the > global keyword and $GLOBALS with it? Together with this making > $_REQUEST, $_GET and $_POST read-only as they should be used only to > read-only anyway. > > The reason for global + GLOBALS is that these are abused and which > leads to spaghetti programs, when used by unexperienced users. Also > they have impact on side effects from functions that don't only rely > their parameters. > > Best, > Andrey > > > Please next time write an rfc before starting a thread like this. a RFC can crystalize from this thread. > I'm pretty much against the idea. > That would be the most dramatic change in the language in the history of > php. pretty dramatic change was the change to the object model between 4 and 5. Dropping the usage of references, dropping of exchange of $this. And also register_globals. register_globals was harder to fix, because you can't just grep and find what variables you need from the URLs. Situation is different with $GLOBALS and "global", as a single grep can show you whether an application needs change or not. > The register_globals is/was a much bigger problem/bad practice and it > take 10 years to remove it(we are almost there...). > And to fix the applications, one would either completely restructure all > of the functions/methods to pass all of the required data from the > global scope, or they would do the easy way: export all of the global > variables into a singleton registry. I am not against global variables, I'm against usage of $GLOBALS and "global". > From a Framework point of view, they should save all of the > (super)global variables from the global scope, because the frameworks > doesn't use/run code in the global scope except the bootstrap, so they > couldn't access that either, but they won't know what the developer who > uses the framework want's to access from the global scope. > And what about global constants? They are also screwing up the > Dependency Injection, and the static functions/properties, and the > Â singletons also. Â Should we ban those? no, you got me wrong. I will repeat - global variables won't cease to exist, but $GLOBALS and "global" as means to access them should be removed. If a function needs data it should get it passed to it. > Tyrael Andrey