Aptana Studio
  1. Aptana Studio
  2. APSTUD-3428

PHP code proposals for the static keyword

    Details

      Description

      If I have this code dummy code:

      <?php
      class Dummy {
      	const PI = 3.14159;
      	private static $MagicNumber = 9;
      
      	public static function GetNumber() {
      		return static::$MagicNumber;
      	}
      }
      ?>
      

      When I get to type 'static::' in the function GetNumber() then the code proposals window should pop-up with the PI constant and the static member MagicNumber; but I get nothing (no pop-up proposals window). If I hit Ctrl+Space to manually load the window I get just the 'No proposals' text.

      This happens every time I use the static:: keyword for referencing the class that get called. This should work very much as the self:: keyword.

      This works in ZendStudio and Netbeans...

        Activity

        Hide
        Shalom Gibly added a comment -

        Fixed for 3.0.5
        We now treat it as we treat 'self::'.

        Thanks!

        Show
        Shalom Gibly added a comment - Fixed for 3.0.5 We now treat it as we treat 'self::'. Thanks!
        Hide
        Axel Pardemann added a comment -

        Wow that was fast! I really don't know how nobody else complained about this. Maybe there are few who are using this PHP5.3 feature and Aptana at the same time LOL, anyways it's good to know it's already been fixed.

        Will this be released in the next nightly?

        Show
        Axel Pardemann added a comment - Wow that was fast! I really don't know how nobody else complained about this. Maybe there are few who are using this PHP5.3 feature and Aptana at the same time LOL, anyways it's good to know it's already been fixed. Will this be released in the next nightly?
        Hide
        Shalom Gibly added a comment -


        Should be in the next nightly. It was pushed to the 'master' branch.

        Show
        Shalom Gibly added a comment - Should be in the next nightly. It was pushed to the 'master' branch.
        Hide
        Joel Witt (Inactive) added a comment -

        Aptana Studio 3, build: 3.0.5.201109222016
        Ubuntu 10.10

        Studio proposes constants, but not variables, public or private.

        Show
        Joel Witt (Inactive) added a comment - Aptana Studio 3, build: 3.0.5.201109222016 Ubuntu 10.10 Studio proposes constants, but not variables, public or private.
        Hide
        Shalom Gibly added a comment -

        This issue is fixed.
        You probably tested the code as given in the 'description' part. However, the $MagicNumber will only be proposed when it's defined as 'static'.
        The CA the Studio propose in this case works just like in PDT (and ZendStudio).

        <?php
        class Dummy {
        	const PI = 3.14159;
        	private static $MagicNumber = 9;
        
        	public static function GetNumber() {
        		return static::$MagicNumber;
        	}
        }
        ?>
        
        Show
        Shalom Gibly added a comment - This issue is fixed. You probably tested the code as given in the 'description' part. However, the $MagicNumber will only be proposed when it's defined as 'static'. The CA the Studio propose in this case works just like in PDT (and ZendStudio). <?php class Dummy { const PI = 3.14159; private static $MagicNumber = 9; public static function GetNumber() { return static::$MagicNumber; } } ?>
        Hide
        Axel Pardemann added a comment -

        Indeed, my original code has a bug (I did not test it beforehand) as Shalom states (and proposes a correct fix).

        The static keyword should work pretty much as the self keyword. It's scope is "restricted" to class members (static vars and methods and constants) and no object properties, thus only static members and constants should be proposed.

        The only difference between self and static is the new late static binding introduced with PHP 5.3 and which is best described here.

        I can confirm this has been fixed in Aptana Studio 3, build: 3.1.0.201109211637

        Show
        Axel Pardemann added a comment - Indeed, my original code has a bug (I did not test it beforehand) as Shalom states (and proposes a correct fix). The static keyword should work pretty much as the self keyword. It's scope is "restricted" to class members (static vars and methods and constants) and no object properties, thus only static members and constants should be proposed. The only difference between self and static is the new late static binding introduced with PHP 5.3 and which is best described here . I can confirm this has been fixed in Aptana Studio 3, build: 3.1.0.201109211637
        Hide
        Ingo Muschenetz added a comment -

        Updated top code in description.

        Show
        Ingo Muschenetz added a comment - Updated top code in description.
        Hide
        Joel Witt (Inactive) added a comment -

        Aptana Studio 3, build: 3.0.5.201109231936
        Ubuntu 10.10

        Verified Studio proposes the constant and the variable inside member function.

        Show
        Joel Witt (Inactive) added a comment - Aptana Studio 3, build: 3.0.5.201109231936 Ubuntu 10.10 Verified Studio proposes the constant and the variable inside member function.

          People

          • Assignee:
            Shalom Gibly
            Reporter:
            Axel Pardemann
          • Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development