Req #4362 [Asn]: prefixing GLOBALS with _ (naming page vs sample page)
| From: | cellog@php.net | Date: | Wed, 18 May 2005 02:54:24 +0000 |
| Subject: | Req #4362 [Asn]: prefixing GLOBALS with _ (naming page vs sample page) | ||
| References: | 1 | Groups: | php.pear.doc |
| Request: | Send a blank email to pear-doc+get-6024@lists.php.net to get a copy of this message | ||
Edit report at http://pear.php.net/bugs/bug.php?id=4362&edit=1
ID: 4362
Updated by: cellog@php.net
Reported By: pear dot php dot net dot tld at coderoom dot nl
Status: Assigned
Type: Feature/Change Request
Package: Documentation
Operating System: any
PHP Version: Irrelevant
Assigned To: danielc
New Comment:
all global variables should be private in PEAR, according to previous
discussions (don't take this as dogma, it's an assumption the early
PEAR dudes had). I can see the logic - it's about hiding implentation
so you aren't bound to it later on.
Previous Comments:
------------------------------------------------------------------------
[2005-05-17 19:21:02] helgi at trance dot is
Think the _ in this case was added to be 100% sure it won't collied
with any other thing in the globals.
So I kinda still think it's a good idea even tho it means private in
other cases.
------------------------------------------------------------------------
[2005-05-17 15:32:13] danielc at analysisandsolutions dot com
Wow. Good catch. I thought you were suggesting the standards be
changed. Now I see there's a conflict between the naming convention
page and the sample file page.
A bigger problem is the packages I've seen (most of which I believe
precede the standards) don't prefix their globals with _, so the
standard doesn't match reality.
On top of all that, I think the naming convention for globals should
match the naming convention for constants, so should not be prefixed
with _. _ in PEAR is meant to prefix private items. Global variables
aren't necessarily private.
Thoughts from others in the community will be appreciated.
------------------------------------------------------------------------
[2005-05-17 13:19:04] pear dot php dot net dot tld at coderoom dot nl
Well,
perhaps the documentation is syntactically correct but the naming
convention is imho wrong. The naming convention for global variables in
http://pear.php.net/manual/en/standards.sample.php
contradicts
http://bugs.pear.php.net/manual/en/standards.naming.php
Well, I know it's just a very minor detail, but by using packages it is
really annoying if you can not garantuee which
global/constant/function/class space is used, since not all packages
follow http://bugs.pear.php.net/manual/en/standards.naming.php
or am I
plain wrong and is there a hidden naming convention rule for global
variables?
------------------------------------------------------------------------
[2005-05-17 09:22:40] danielc at analysisandsolutions dot com
The documentation is correct.
------------------------------------------------------------------------
[2005-05-16 20:49:05] pear dot php dot net dot tld at coderoom dot nl
Description:
------------
To understand PEAR's coding standards, especially by learning from
examples, I was wondering if the naming convention of global variables
in this example is intentionally made wrong?
http://pear.php.net/manual/en/standards.sample.php
Expected result:
----------------
$GLOBALS['_NET_SAMPLE_Count'] = 0;
Actual result:
--------------
$GLOBALS['NET_SAMPLE_Count'] = 0;
------------------------------------------------------------------------
--
Edit this bug report at http://pear.php.net/bugs/bug.php?id=4362&edit=1