#39091 [Com]: Need to force variables to be declared

From: Date: Wed, 11 Oct 2006 19:08:09 +0000
Subject: #39091 [Com]: Need to force variables to be declared
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-103440@lists.php.net to get a copy of this message
 ID:               39091
 Comment by:       ceo at l-i-e dot com
 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:

Turn error_reporting to E_ALL, and you have exactly what you asked for,
and so much more.


Previous Comments:
------------------------------------------------------------------------

[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


Thread (5 messages)

« previous php.bugs (#103440) next »