Intellisense idea (again)

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

Intellisense idea (again)

Postby BladeMF » November 30th, 2012, 5:26 pm

Hey,

I was thinking about intellisense. Right now, in our projects (a lot of files) we have a lot of collection classes, whose base class implements Iterator interface. If/when you do foreach loops to search for such interface and infer the item type, there will be one problem: I know for a fact that PHP punishes severly performance-wise for every function entry and more for every class method entry. So, if we want to take advantage of that feature, we would have to override all the members of the interface in every inheriting class, because it has different item type, which might kill us instantly.

I was wondering, maybe we can come up with some comment syntax in the inheriting classes, for example
/*
* @implements Iterator<COrder>
*/
or
/*
* @implements Iterator of COrder
*/

I know that .NET-wise overriding is the way to go, but adding an additional method call (even with empty body) for thousands of operations will add significant overhead (welcome to the PHP world).

Please, everyone, feel free to share your thoughts too.

So, Jakub, Miloslav?
Welcome to the zone where normal things don't happen very often.
BladeMF
 
Posts: 346
Joined: October 10th, 2012, 7:14 am

Re: Intellisense idea (again)

Postby Jakub Misek » December 2nd, 2012, 1:09 pm

Additional PHPDoc tag would be the easiest way how to extend IDE functionality. Also it does not add additional code and overhead to your application.

For typing items of array, there is an unofficial standard of @var ItemType[]. (Which will be supported by our tools soon). This tells IDE how to treat foreach control variable and how to access items thru [] operator.

This could be used for Iterator derived classes too, so foreach and [] would work as expected. But it wouldn't work for Iterator::current().

Maybe we could add something like @var Iterator<ItemType> (it have to be single world, without spaces) over class declaration ...
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: Intellisense idea (again)

Postby BladeMF » December 4th, 2012, 9:00 am

Jakub Misek wrote:Additional PHPDoc tag would be the easiest way how to extend IDE functionality. Also it does not add additional code and overhead to your application.

For typing items of array, there is an unofficial standard of @var ItemType[]. (Which will be supported by our tools soon). This tells IDE how to treat foreach control variable and how to access items thru [] operator.

This could be used for Iterator derived classes too, so foreach and [] would work as expected. But it wouldn't work for Iterator::current().

Maybe we could add something like @var Iterator<ItemType> (it have to be single world, without spaces) over class declaration ...



Agreed. Do you currently support @var inline? And, we should be able to declare a type with this attribute, for example:
/*
* @implements/class/?! Iterator<SomeSort>
* or
* @typeInfo SomeSort[]
*
*/
class ArrayOfSomeSort {
}

There should be a way to add more than one of those attributes (for each interface). What do you think?
Welcome to the zone where normal things don't happen very often.
BladeMF
 
Posts: 346
Joined: October 10th, 2012, 7:14 am

Re: Intellisense idea (again)

Postby Jakub Misek » December 4th, 2012, 4:20 pm

I would rather to avoid defining new PHPDoc tag. For reference these are standard http://en.wikipedia.org/wiki/PHPDoc#Tags .

We can simply use @var over the class declaration. Or we can take a look on other IDE's, whether there is something already being used.
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: Intellisense idea (again)

Postby BladeMF » December 6th, 2012, 12:26 pm

Jakub Misek wrote:I would rather to avoid defining new PHPDoc tag. For reference these are standard http://en.wikipedia.org/wiki/PHPDoc#Tags .

We can simply use @var over the class declaration. Or we can take a look on other IDE's, whether there is something already being used.



Yes. Maybe @var is not such a bad idea, since we are documenting the this[] property... Looking to other IDEs is a good idea - maybe Zend?
Welcome to the zone where normal things don't happen very often.
BladeMF
 
Posts: 346
Joined: October 10th, 2012, 7:14 am

Re: Intellisense idea (again)

Postby Jakub Misek » February 2nd, 2013, 2:39 pm

bump

array intellisense ready for 1.6 release (in private beta already) -> PHPDoc supports following type names for class properties (@var), function parameters (@param), global variables (@global), function return type (@return) etc.

ClassName[] // simple array containing elements of type ClassName
ClassName[][] // and more [] ...
array // generic untyped array

I suggest to add support of @var also above class declaration? Which would override behaviour of instance of such class. For your Iterator classes, common array PHPDoc syntax would fit your needs I guess. E.g.
Code: Select all
/**
 * @var X[] This is Iterator and returns objects of type X.
 */
class A extends Iterator{}
Description of this @var element would appear as a variable tooltip.
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague


Return to PHP Tools

Who is online

Users browsing this forum: No registered users and 45 guests

cron

User Control Panel

Login

Who is online

In total there are 45 users online :: 0 registered, 0 hidden and 45 guests (based on users active over the past 5 minutes)
Most users ever online was 256 on March 28th, 2024, 9:42 am

Users browsing this forum: No registered users and 45 guests