Intellisense idea (again)
6 posts
• Page 1 of 1
Intellisense idea (again)
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?
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)
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 ...
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. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
Re: Intellisense idea (again)
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)
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.
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. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
Re: Intellisense idea (again)
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)
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.
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{}
Jakub Misek │ DEVSENSE s.r.o. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
6 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 36 guests