NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
[resolved] Features Requests for PhPED


Joined: 22 Dec 2006
Posts: 42
Reply with quote
2 Requests - one echoed a zillion times in this forum Smile Code collapsing.

Second request is more advanced code hints:

THIS WIL PROVIDE ACCURATE CODE HINTS:

class myObj(){

public function getObjX(){

return new objX();

}

}

$myObj = new obj();
$myObj-> (code hints here );

BUT, THIS WONT PROVIDE CODE HINTS

$myObj->getObjX()-> (no code hints, even though it is returning an object)

This would be VERY useful!
View user's profileFind all posts by bholbrookSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8351
Reply with quote
hmm, your code sample is just incorrect in two ways:
1) no () braces are allowed after class myObj
2) you tried to define myObj, but myObj is assigned with instance of obj which is not defined. I assume that it must be myObj, not obj because later you're calling getObjX method defined in myObj.
3) getObjX returns instance of undefined class objX. Isn't you're expecting to see objX's methods there $myObj->getObjX()-> ?

If you get it all done correctly, you'll see that Code Completion works pefectly well in PhpED Smile
Code:
<?php

class objX {
  function somefun() {
  }
}

class myObj{
  public function getObjX(){
    return new objX();
  }
}
$myObj = new myObj();
$myObj->getObjX()->

?>


_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 22 Dec 2006
Posts: 42
Reply with quote
So there were enough mistakes in my example to make me look like a rookie Sad

I think i narrowed the problem below. $objUtilities is an object being passed in (PHP5, naturally a reference).
It returns a 'failed to identify type' error

Code:


class myClass{

    public function __construct($objUtilities)
    {
        $this->objUtilities  = $objUtilities;
    }

    public function readUtil()
    {
        $this->objUtilities-> //NO CODE HINTS

    }

}

View user's profileFind all posts by bholbrookSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8351
Reply with quote
sorry, if I made you feeling like a rookie. My bad.
Regarding your 2nd code sample, I can not say what class instance is passed in $objUtilities argument passed to myClass constructor. Therefore, it's unclear what class instance will be stored in objUtilities property. Property itself is not defined at all.
I'd recommend you to either use type hints or phpdoc to tell the IDE how it should handle objUtilities.
Try this: http://forum.nusphere.com/tip-type-hints-t1563.html

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 22 Dec 2006
Posts: 42
Reply with quote
dmitri wrote:
sorry, if I made you feeling like a rookie. My bad.


Nope, after re-reading it - it looked like a rookie wrote it, so my bad.

dmitri wrote:

Regarding your 2nd code sample, I can not say what class instance is passed in $objUtilities argument passed to myClass constructor. Therefore, it's unclear what class instance will be stored in objUtilities property. Property itself is not defined at all.
I'd recommend you to either use type hints or phpdoc to tell the IDE how it should handle objUtilities.
Try this: http://forum.nusphere.com/tip-type-hints-t1563.html


Wonderful, this will do exactly what I want, except it cant find my class instances. Is there a way to show it WHERE the class resides. Does this also work in a interface for all classes implementing it (that would be really cool)
View user's profileFind all posts by bholbrookSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8351
Reply with quote
it works for interfances and clasess and you do not need to take any special actions, just make sure that all files with classes are in the project or if they are in stand-alone libraries, just add corresponding path to the Code Insight Includes list (see project properties).

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 22 Dec 2006
Posts: 42
Reply with quote
Okay, I must be not doing something wrong at a very basic level, cause it aint reading it. I'll do a walk through of one of our components and where it is getting its variables etc.

The Workspace has 2 projects, the 'CORE' which has the class libraries and the 'SITE' which is the site using the library.

ALL classes reside in the CORE project, only index.php and config.php reside on the SITE

1. The index.php page calls a config.php script which initializes the config class and subsequently initiats any classes required for global functionality.
2. The index.php page uses the CORE class which looks for listeners on available variables then matches the variables to the listener and uses the eval() function to initiate the cooresponding 'COMPONENT' class(es).
3. Every COMPONENT __constuct reads three variables, all objects.

In step three is where the code hints are lost. They are not readable in the COMPONENT classes for the three obects passed in (before and after following all instructions from this post). The three classes are all at the root level of the CORE project and the classes calling them are in child folders (each with there own component folder).

Now, based on what your 2nd to last post says, all of this shouldn't matter because the @param classname $objVariable should help it to the right class, but it can't find it.

Any more ideas?
View user's profileFind all posts by bholbrookSend private message


Joined: 22 Dec 2006
Posts: 42
Reply with quote
Okay, I think I figured out where the code hints are lost. See the code below.

Code:


/**
* @desc constructor
* @param utilities $objUtilities
* @param servillian $objServillian
* @param security $objSecurity
*/
public function __construct( $objUtilities, $objServillian, $objSecurity ){

   $this->objUtilities = $objUtilities;
   $this->objServillian = $objServillian;
   $this->objSecurity = $objSecurity;
   $this->objConfig = $GLOBALS['objConfig'];
   $this->filePath = $this->objConfig->getFilePath( "0001" );

   $objUtilities->CODE HINTS WORK
   $this->objUtilities->CODE HINTS DON'T WORK

   $this->objUtilities =& $objUtilities;
   $this->objUtilities->CODE HINTS DON'T WORK

}
View user's profileFind all posts by bholbrookSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8351
Reply with quote
You may want to add path to the classes to let Code Insight know where to find them.
With your case, add path to CORE directory into "Code Insight Includes" list in the project properties for SITE project.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 22 Dec 2006
Posts: 42
Reply with quote
Case Closed. Thanks Dmitri. All of the code hinting is working perfect now. I had to make sure that i followed all of the classes down the tree to make sure that they effected each other (i was going 5 - 6 classes deep each time) - but it works and I'm happy.

Thanks

( hey - has anyone mentioned how cool code collapsing would be? ) Very Happy
View user's profileFind all posts by bholbrookSend private message
[resolved] Features Requests for PhPED
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