#39091 [Opn]: Need to force variables to be declared
| From: | addw at phcomp dot co dot uk | Date: | Thu, 12 Oct 2006 10:34:41 +0000 |
| Subject: | #39091 [Opn]: Need to force variables to be declared | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-103469@lists.php.net to get a copy of this message | ||
ID: 39091
User updated by: addw at phcomp dot co dot uk
Reported By: addw at phcomp dot co dot uk
Status: Open
Bug Type: Feature/Change Request
Operating System: any
PHP Version: 5.2.0RC5
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[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 http://bugs.php.net/?id=39091&edit=1