Bug #67767 [Opn->Csd]: Scope confusion
| From: | stas@php.net | Date: | Mon, 18 Aug 2014 07:49:29 +0000 |
| Subject: | Bug #67767 [Opn->Csd]: Scope confusion | ||
| References: | 1 | Groups: | php.standards |
| Request: | Send a blank email to standards-+get-386@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67767&edit=1
ID: 67767
Updated by: stas@php.net
Reported by: joelm at fb dot com
Summary: Scope confusion
-Status: Open
+Status: Closed
Type: Bug
Package: PHP Language Specification
PHP Version: Irrelevant
-Assigned To:
+Assigned To: stas
Block user comment: N
Private report: N
New Comment:
The fix for this bug has been committed.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
For Windows:
http://windows.php.net/snapshots/
Thank you for the report, and for helping us make PHP better.
Should be fixed now in new redaction of basic concepts.
Previous Comments:
------------------------------------------------------------------------
[2014-08-05 16:17:54] joelm at fb dot com
Description:
------------
https://github.com/php/php-langspec/blob/master/spec/04-basic-concepts.md#scope
This section and the way "scope" is discussed throughout the spec is confusing. I think
there are 3 separate issues at work here. The first issue is whether something is accessible just
within part of the code, or whether it's accessible somehow from virtually everywhere in the
program. The second issue is when a qualifier (such as "Foo::" where Foo is a class) is
required to refer to something, and when it is not required. The third issue is the scope within
which another construct of the same kind with the same name cannot be declared (example if you
define an instance property $x inside the definition of class C, you cannot define another instance
property $x inside that same class definition, though you can define an instance property $x in a
class that derives from D). We get very different behavior for variables vs. class constants for
examples. For local variables in a regular function (i.e. not a pseudomain), the local variables are
only accessible within a given fun!
ction, no qualifier is needed, and re-definition is not possible really (except for parameters
where PHP5 weirdly tolerates multiple parameters with the same name). For class constants, they are
accessible virtually everywhere, a qualifier is ALWAYS needed even inside methods of the class, and
there cannot be another constant definition with the same name in that same class definition.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67767&edit=1