Intelisense Tweak - Static Methods

PHP Tools [?] extends Visual Studio with set of advanced features to work more efficiently with PHP code.

Intelisense Tweak - Static Methods

Postby AndyM84 » August 11th, 2012, 2:09 am

If I call a static method from an instantiated object, Intellisense doesn't work. This seems a little odd, given that I believe it's perfectly acceptable to call a static method as an object method. Can this be tweaked to give the appropriate Intellisense?
User avatar
AndyM84
 
Posts: 69
Joined: August 6th, 2012, 3:24 pm
Location: Boston, MA, USA

Re: Intelisense Tweak - Static Methods

Postby Jakub Misek » August 11th, 2012, 12:55 pm

This was actually intended as a feature, trying to keep your code clean.

PHP allows call of static method on an instance, but we still don't know why would somebody do that :) If it is a common PHP developer scenario, we can enable it.
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: Intelisense Tweak - Static Methods

Postby AndyM84 » August 12th, 2012, 12:13 pm

I usually do it as a matter of convenience. I grab a singleton of a class first to do a couple other things, and then call the doAuth() static method using the singleton instance.

I'm honestly not sure if it's common practice, but it's just something I've used to save myself time (and generally speaking calling methods from an object instance is faster than calling them statically if memory serves).
User avatar
AndyM84
 
Posts: 69
Joined: August 6th, 2012, 3:24 pm
Location: Boston, MA, USA

Re: Intelisense Tweak - Static Methods

Postby Jakub Misek » August 12th, 2012, 1:03 pm

We can allow calling static methods on instance object, I think there might be more users expecting this to work.
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: Intelisense Tweak - Static Methods

Postby virgil66ro » August 21st, 2012, 10:41 am

Hi,

I just downloaded the trial version and I have the same problem.
If I can do something to get the intelisense as I expect, please tell me what should I do.

This is an example of code:
Code: Select all
<?php

class StaticClass
{
   public static $title = '';

   public static $db = null;
   
   function __construct(){}

   public static function InitFunction()
   {
      self::$title = 'test';
      self::Mysql_start();           
   }


   public static function Mysql_start()
   {
      self::$db = new MyDb();
      self::$title = self::$db->DoSomething();        // here intelisense isn't working
   }
}


class MyDb
{
   public $data = '';
   
   public function DoSomething($varData = 'MyData')
   {
      return $varData;
   }
}


class MyProgram
{
   private $db = null;                                 // this is a local copy of the StaticClass::$db
   
   function __construct()
   {
      StaticClass::InitFunction();
      echo(StaticClass::$title."\n");
      
      $this->db = StaticClass::$db;
      StaticClass::$title = $this->db->DoSomething($varData = 'ProgData');    // I am expecting to get intellisense here.
      echo(StaticClass::$title."\n");
   }
   
}

$myp = new MyProgram();


?>


Thank you
virgil66ro
 
Posts: 10
Joined: August 19th, 2012, 9:32 am

Re: Intelisense Tweak - Static Methods

Postby Jakub Misek » August 21st, 2012, 1:01 pm

virgil66ro wrote:If I can do something to get the intelisense as I expect, please tell me what should I do.


Thank You for the sample code. We will update IntelliSense to work nice with your sample case in upcoming update or the next one after.

If you have any other test case, please feel free to attach onto our forum.
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: Intelisense Tweak - Static Methods

Postby Jakub Misek » August 22nd, 2012, 2:20 pm

AndyM84 wrote:If I call a static method from an instantiated object, Intellisense doesn't work.
We have allowed static functions after object operator (->) in the latest update (1.1.3385).

virgil66ro wrote:self::$db->DoSomething();// here intelisense isn't working
$this->db->DoSomething($varData = 'ProgData'); // I am expecting to get intellisense here.
Latest update supports that constructs. You can try and give us a note how it works for you.
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: Intelisense Tweak - Static Methods

Postby virgil66ro » August 22nd, 2012, 4:30 pm

Thank you Jakub,

It's seems to work fine.
I am planning to test this tool for the next 2 weeks so if you don't mind, I will come back with remarks or suggestions.

Thank you again.
virgil66ro
 
Posts: 10
Joined: August 19th, 2012, 9:32 am

Re: Intelisense Tweak - Static Methods

Postby Jakub Misek » August 22nd, 2012, 4:32 pm

virgil66ro wrote:It's seems to work fine.
I am planning to test this tool for the next 2 weeks so if you don't mind, I will come back with remarks or suggestions.
Great! Thanks for checking the feature again. Please give us any feedback You find useful, we are continuously improving the tool based on user's comments.
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: Intelisense Tweak - Static Methods

Postby virgil66ro » August 22nd, 2012, 6:35 pm

Hi again,


Maybe I am not the only one who need this feature, but I would like to have intelisense on a mysql result.
I mean all results are stored on arrays, from where we can extract data based on the column names of the mysql table witch is queried.

ex:

Code: Select all
$sql = "select idUser, firstName, lastName, edge from TableUser order by idUser asc limit 1 ";
$res = mysql_query($sql);
$userName = $res['firstName'].' '.$res['lastName']; // it will be nice to have listed all the column names when after the $res[



Also there will be useful to have intelisense any time we have an array.
Please note that on php we have arrays like $_SERVER witch have many definitions.
http://www.php.net/manual/en/reserved.v ... server.php

Thank you,
Virgil
virgil66ro
 
Posts: 10
Joined: August 19th, 2012, 9:32 am

Next

Return to PHP Tools

Who is online

Users browsing this forum: No registered users and 20 guests

cron

User Control Panel

Login

Who is online

In total there are 20 users online :: 0 registered, 0 hidden and 20 guests (based on users active over the past 5 minutes)
Most users ever online was 787 on May 12th, 2024, 11:50 am

Users browsing this forum: No registered users and 20 guests