Req #39091 [Opn->Fbk]: Need to force variables to be declared
| From: | heiglandreas@php.net | Date: | Fri, 20 Jan 2017 21:58:01 +0000 |
| Subject: | Req #39091 [Opn->Fbk]: Need to force variables to be declared | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-206805@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=39091&edit=1
ID: 39091
Updated by: heiglandreas@php.net
Reported by: addw at phcomp dot co dot uk
Summary: Need to force variables to be declared
-Status: Open
+Status: Feedback
Type: Feature/Change Request
-Package: Feature/Change Request
+Package: *General Issues
Operating System: any
PHP Version: 5.2.0RC5
Block user comment: N
Private report: N
New Comment:
Is this still relevant?
Previous Comments:
------------------------------------------------------------------------
[2006-10-12 10:34:40] addw at phcomp dot co dot uk
No, E_ALL does not do everything that I need. It will not report mistyped variables who are
assigned, only those that are used. E_ALL only generates a warning when code is executed which is
not useful for infrequently executed code.
------------------------------------------------------------------------
[2006-10-11 19:08:08] ceo at l-i-e dot com
Turn error_reporting to E_ALL, and you have exactly what you asked for, and so much more.
------------------------------------------------------------------------
[2006-10-09 10:40:48] addw at phcomp dot co dot uk
Description:
------------
Could we not use 'var' to declare variables outside of functions and have a config option
or file related pragma that made not declaring a variable an error ?
Yes: there would be a problem with existing code, so why not force variable declaration iff/after a
'var' declaration is seen.
If you really want to do it properly, then we could use 'private' or 'static' to
declare variables with the scope of the file that they are declared in (like in C).
The most recent bug reference that I can find for this is: 14285 (Nov 2001).
This is a MUST HAVE, it is the single most dangerous mis-feature of PHP. Don't get me wrong - I
like PHP, but just hanker after perl's use strict - great at pointing out typeos.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=39091&edit=1