Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » PHP
  • » [PHP-DEV] Deprecating "global" + $GLOBALS, making $_REQUEST, $_GET, $_POST read-only [RSS Feed]

#1 Dec. 9, 2010 10:20:37

Reindl H.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Deprecating "global" + $GLOBALS, making $_REQUEST, $_GET, $_POST read-only


Please do not

global + GLOBALS can be used in so many ways and you would break
200.000 LOC only here which is running with reporting E_STRICT
in a production environment

The same for making $_GET/$_POST/$_REQUEST readonly
I know that it is not best practice, but sometimes
it makes life easier to fetch $_POST in a method
which overwrites a parent method and add a single
item before the parent is processing $_POST

Yes, there are many other ways to do the same but
BC-breaking trigger a lot of work and testing

Am 09.12.2010 11:14, schrieb Andrey Hristov:
> 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


--

Mit besten Grüßen, Reindl Harald
the lounge interactive design GmbH
A-1060 Vienna, Hofmühlgasse 17
CTO / software-development / cms-solutions
p: +43 (1) 595 3999 33, m: +43 (676) 40 221 40
icq: 154546673,http://www.thelounge.net/signature.ascDescription:OpenPGP digital signature

Attachments:
attachment signature.asc (261 bytes)

Offline

#2 Dec. 9, 2010 10:23:06

James B.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Deprecating "global" + $GLOBALS, making $_REQUEST, $_GET, $_POST read-only


+1 million because GLOBAL scope is horrid (generally) and is thoroughly abused
-1 million because it will be the most horrific BC break since time began and I
imagine it will break so much code that is currently in the wild...

In short I like it but I'm not sure how it would ever get implemented without
breaking stuff... (this is where the clever core developers can propose some
easy method I can't think of right now)


-----Original Message-----
From: Andrey Hristov
Sent: 09 December 2010 10:14
To: PHP Internals List
Subject: Deprecating "global" + $GLOBALS, making $_REQUEST, $_GET,
$_POST read-only

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

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#3 Dec. 9, 2010 10:24:06

Andrey H.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Deprecating "global" + $GLOBALS, making $_REQUEST, $_GET, $_POST read-only


Reindl Harald wrote:Please do not

global + GLOBALS can be used in so many ways and you would break
200.000 LOC only here which is running with reporting E_STRICT
in a production environmentwhat happened after register_globals was introduced and registering ofglobals was switched off?The same for making $_GET/$_POST/$_REQUEST readonly
I know that it is not best practice, but sometimes
it makes life easier to fetch $_POST in a method
which overwrites a parent method and add a single
item before the parent is processing $_POSTIt's bad practice.Yes, there are many other ways to do the same but
BC-breaking trigger a lot of work and testing

Am 09.12.2010 11:14, schrieb Andrey Hristov: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,
AndreyBest,
Andrey

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#4 Dec. 9, 2010 10:27:14

Andrey H.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Deprecating "global" + $GLOBALS, making $_REQUEST, $_GET, $_POST read-only


James Butler wrote:+1 million because GLOBAL scope is horrid (generally) and is thoroughly abused
-1 million because it will be the most horrific BC break since time began and I
imagine it will break so much code that is currently in the wild...how hard it will be to grep for "global" and $GLOBALS?In short I like it but I'm not sure how it would ever get implemented without
breaking stuff... (this is where the clever core developers can propose some
easy method I can't think of right now)INI variable, like register_globals-----Original Message-----From: Andrey Hristov Sent: 09 December 2010 10:14To: PHP Internals List
Subject: Deprecating "global" + $GLOBALS, making $_REQUEST, $_GET,
$_POST read-only

Hi guys,the topic says most of it. What do you think about deprecating theglobal keyword and $GLOBALS with it? Together with this making$_REQUEST, $_GET and $_POST read-only as they should be used only toread-only anyway.The reason for global + GLOBALS is that these are abused and which leadsto spaghetti programs, when used by unexperienced users. Also they haveimpact on side effects from functions that don't only rely their parameters.Best,
AndreyBest,
Andrey

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#5 Dec. 9, 2010 10:32:41

James B.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Deprecating "global" + $GLOBALS, making $_REQUEST, $_GET, $_POST read-only


-----Original Message-----
From: Andrey Hristov

>James Butler wrote:
>> +1 million because GLOBAL scope is horrid (generally) and is thoroughly
>> abused
>> -1 million because it will be the most horrific BC break since time began
>> and I imagine it will break so much code that is currently in the wild...

>how hard it will be to grep for "global" and $GLOBALS?

Not hard for you or I but what about the beginners out there, will they know
how to find them or work around the use of globals?

>> In short I like it but I'm not sure how it would ever get implemented
>> without breaking stuff... (this is where the clever core developers can
>> propose some easy method I can't think of right now)

>INI variable, like register_globals

Sorry, I wasn't being very clear there, what I really meant to say was will
there be the will to remove it considering the effects.
I suppose INI is enough to allow it to be easily changed, but would it ever
become a default setting of off, rather than something that can be optionally
off?



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#6 Dec. 9, 2010 10:39:08

Andrey H.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Deprecating "global" + $GLOBALS, making $_REQUEST, $_GET, $_POST read-only


James Butler wrote:-----Original Message-----From: Andrey Hristov James Butler wrote:+1 million because GLOBAL scope is horrid (generally) and is thoroughly abused
-1 million because it will be the most horrific BC break since time began and I
imagine it will break so much code that is currently in the wild...how hard it will be to grep for "global" and $GLOBALS?Not hard for you or I but what about the beginners out there, will they know
how to find them or work around the use of globals?Yes, as the documentation will mention how to do it, for oldapplications. For new apps it is easy - pass all the information youneed as parameter to the function. It works in other languages, whyshouldn't it work for PHP?In short I like it but I'm not sure how it would ever get implemented without
breaking stuff... (this is where the clever core developers can propose some
easy method I can't think of right now)INI variable, like register_globalsSorry, I wasn't being very clear there, what I really meant to say was will
there be the will to remove it considering the effects.
I suppose INI is enough to allow it to be easily changed, but would it ever
become a default setting of off, rather than something that can be optionally
off?mild migration path--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#7 Dec. 9, 2010 10:43:58

Michael S.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Deprecating "global" + $GLOBALS, making $_REQUEST, $_GET, $_POST read-only


On Thu, Dec 9, 2010 at 2:31 AM, James Butler
<james.but***@*digitalresearch.com> wrote:

> Sorry, I wasn't being very clear there, what I really meant to say was will
> there be the will to remove it considering the effects.
> I suppose INI is enough to allow it to be easily changed, but would it ever
> become a default setting of off, rather than something that can be optionally
> off?

If you are aware of what to change in your configuration, why can't
you make the change?

Those of us having to support code we do not control, the numerous
widely used open source projects and billions of lines of code would
have bc issues if a change like this was to be changed to default =
off, and only on if people have ini access.

Not to mention, I have had issues (and I can't reproduce it properly
or I would report it) where sometimes i will have a variable in global
scope in one file, and I have to reference it as $GLOBALS
in another include, or I have to global $variable; in the include to
be able to get to it, and I'm not quite sure why.

I also like being able to grab a single variable out of global scope
(or single array item) without global $array; and then only using
$array, I can just shorthand it to $GLOBALS
inside of function scope.

Globals are bad practice, but I use one or two global arrays to track
state / configuration throughout the application, very minimal, and
sure, I could figure out creative ways to never expose anything in
global scope, but why bother? While I am not as low-level in opcode
knowledge, isn't global constant definition almost as expensive (+/-
maybe a few opcodes?)

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#8 Dec. 9, 2010 10:46:51

Michael S.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Deprecating "global" + $GLOBALS, making $_REQUEST, $_GET, $_POST read-only


On Thu, Dec 9, 2010 at 2:38 AM, Andrey Hristov <p***@*ristov.com> wrote:

> Yes, as the documentation will mention how to do it, for old applications.
> For new apps it is easy - pass all the information you need as parameter to
> the function. It works in other languages, why shouldn't it work for PHP?

named parameters would help here. otherwise you wind up with a mess of
argument hell. or passing a single array in and then in the function
parsing that for the items (which is what I do, sort of a userland way
of doing named parameters)

but adding more and more parameters to functions over time leads to
issues if they do not have default values and if you have to pass say,
the 6th parameter, but don't need to pass the rest, etc.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#9 Dec. 9, 2010 10:47:58

Eloy B.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Deprecating "global" + $GLOBALS, making $_REQUEST, $_GET, $_POST read-only


2010/12/9 Andrey Hristov <p***@*ristov.com>

> Reindl Harald wrote:
>
>> Please do not
>>
>> global + GLOBALS can be used in so many ways and you would break
>> 200.000 LOC only here which is running with reporting E_STRICT
>> in a production environment
>>
>
> what happened after register_globals was introduced and registering of
> globals was switched off?
>
>
> The same for making $_GET/$_POST/$_REQUEST readonly
>> I know that it is not best practice, but sometimes
>> it makes life easier to fetch $_POST in a method
>> which overwrites a parent method and add a single
>> item before the parent is processing $_POST
>>
>
> It's bad practice.
>
>
> Yes, there are many other ways to do the same but
>> BC-breaking trigger a lot of work and testing
>>
>> Am 09.12.2010 11:14, schrieb Andrey Hristov:
>>
>>> 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
>>>
>>
>>
>>
> Best,
> Andrey
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit:http://www.php.net/unsub.php>
>


Is copying the POST variables into another variables best practice (like a
manual register_globals)? In the global scope of the application I think
it's cleaner to work with $_POST to overwrite the values than copying the
items into variables. Inside a function/method, I agree that it's best
practice to pass $_POST as a parameter and then overwrite the values as you
need.


Regards,

Eloy Bote Falcon.

Offline

#10 Dec. 9, 2010 10:51:12

Andrey H.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Deprecating "global" + $GLOBALS, making $_REQUEST, $_GET, $_POST read-only


Michael Shadle wrote:On Thu, Dec 9, 2010 at 2:38 AM, Andrey Hristov <p***@*ristov.com> wrote:Yes, as the documentation will mention how to do it, for old applications.
For new apps it is easy - pass all the information you need as parameter to
the function. It works in other languages, why shouldn't it work for PHP?named parameters would help here. otherwise you wind up with a mess of
argument hell. or passing a single array in and then in the function
parsing that for the items (which is what I do, sort of a userland way
of doing named parameters)

but adding more and more parameters to functions over time leads to
issues if they do not have default values and if you have to pass say,
the 6th parameter, but don't need to pass the rest, etc.You can be creative and create ad-hoc objects with properties thevariables you pass, but this is a kind of hack. Also reorganizing yourcode so not every function needs 6 parameters can help your code.Globals definitely don't help reusability.

Best,
Andrey

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

  • Root
  • » PHP
  • » [PHP-DEV] Deprecating "global" + $GLOBALS, making $_REQUEST, $_GET, $_POST read-only [RSS Feed]

Board footer

Moderator control

Enjoy the 17th of August
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support