NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
code completion improvement.
Veteran

Joined: 30 Nov 2006
Posts: 186
Reply with quote
One thing I really miss is somehow you can "Typecast" an object with the only purpose of getting codecompletion better.

Example.

class baseClass
{
public function doSomething() {}
}

class childClass extends baseClass
{
public function doSomething() {}
}


$objects = array();

$base = new baseClass();
$child = new childClass();

$objects[] = $base;
$objects[] = $child;

// At this time we have an array with objects all of type baseClass or extended classes of baseClass

foreach ($objects as $current)
{
$current-> (This will produce an error, because the editor has no chance of knowing which object is in the array
}

But what if you could do something like this

foreach ($objects as $current)
{
/**
* var baseObject $current
*/
$current->dosomething();
}

That is some sort of PHPdoc syntax that can tell the editor that $current is expected to be of the type baseObject, and because of that the code completion will be able to show you the dosomething function.

I have spend almost an hour today switching between files to make sure that I spell the function names correctly and use the right parameters etc. So to be able to tell the editor what type an variable is would be a life saver.
View user's profileFind all posts by hgrSend private message


Joined: 02 Aug 2007
Posts: 12
Location: Hamburg Germany
Reply with quote
Do not use some sort of phpdoc syntax but correct phpdoc syntax

this works:
Code:

foreach ($objects as $current)
{
/**
* @var baseClass
*/
$current->
}


KASI
View user's profileFind all posts by kasiSend private message
Veteran

Joined: 30 Nov 2006
Posts: 186
Reply with quote
Cool, but I thought I tried that.

I will give it a try and see if that actually does it.
View user's profileFind all posts by hgrSend private message
code completion improvement.
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic