Professional Web Applications Themes

#39091 [NEW]: Need to force variables to be declared - PHP Bugs

From: addw at phcomp dot co dot uk Operating system: any PHP version: 5.2.0RC5 PHP Bug Type: Variables related Bug description: Need to force variables to be declared 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 ...

  1. #1

    Default #39091 [NEW]: Need to force variables to be declared

    From: addw at phcomp dot co dot uk
    Operating system: any
    PHP version: 5.2.0RC5
    PHP Bug Type: Variables related
    Bug description: Need to force variables to be declared

    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 bug report at [url]http://bugs.php.net/?id=39091&edit=1[/url]
    --
    Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=39091&r=trysnapshot44[/url]
    Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=39091&r=trysnapshot52[/url]
    Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=39091&r=trysnapshot60[/url]
    Fixed in CVS: [url]http://bugs.php.net/fix.php?id=39091&r=fixedcvs[/url]
    Fixed in release: [url]http://bugs.php.net/fix.php?id=39091&r=alreadyfixed[/url]
    Need backtrace: [url]http://bugs.php.net/fix.php?id=39091&r=needtrace[/url]
    Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=39091&r=needscript[/url]
    Try newer version: [url]http://bugs.php.net/fix.php?id=39091&r=oldversion[/url]
    Not developer issue: [url]http://bugs.php.net/fix.php?id=39091&r=support[/url]
    Expected behavior: [url]http://bugs.php.net/fix.php?id=39091&r=notwrong[/url]
    Not enough info: [url]http://bugs.php.net/fix.php?id=39091&r=notenoughinfo[/url]
    Submitted twice: [url]http://bugs.php.net/fix.php?id=39091&r=submittedtwice[/url]
    register_globals: [url]http://bugs.php.net/fix.php?id=39091&r=globals[/url]
    PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=39091&r=php3[/url]
    Daylight Savings: [url]http://bugs.php.net/fix.php?id=39091&r=dst[/url]
    IIS Stability: [url]http://bugs.php.net/fix.php?id=39091&r=isapi[/url]
    Install GNU Sed: [url]http://bugs.php.net/fix.php?id=39091&r=gnused[/url]
    Floating point limitations: [url]http://bugs.php.net/fix.php?id=39091&r=float[/url]
    No Zend Extensions: [url]http://bugs.php.net/fix.php?id=39091&r=nozend[/url]
    MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=39091&r=mysqlcfg[/url]
    addw at phcomp dot co dot uk Guest

  2. #2

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

    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 [url]http://bugs.php.net/?id=39091&edit=1[/url]
    ceo at l-i-e dot com Guest

  3. #3

    Default #39091 [Opn]: Need to force variables to be declared

    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 [url]http://bugs.php.net/?id=39091&edit=1[/url]
    addw at phcomp dot co dot uk Guest

Similar Threads

  1. how to force variables declaration??
    By Mack Paul in forum PHP Development
    Replies: 3
    Last Post: September 3rd, 03:00 PM
  2. Variables Declared in a .cfc
    By jeby in forum Coldfusion - Advanced Techniques
    Replies: 1
    Last Post: June 30th, 10:44 PM
  3. Name is not declared
    By DC Gringo in forum ASP.NET Building Controls
    Replies: 1
    Last Post: March 2nd, 12:16 AM
  4. BC30451: Name 'BindDataGrid' is not declared.
    By TJS in forum ASP.NET Data Grid Control
    Replies: 1
    Last Post: November 23rd, 03:15 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139