NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
OBJ code completion PHP_Ed vs Zend


Joined: 01 Oct 2005
Posts: 2
Reply with quote
i have all of my class files autoloading with PHP5, and i absolutely LOVE Zends code completion. However Zend is slow and quirky where it seems (I've only just begun to try PHPeD) PHPeD is much more stable. My biggest concern is that it seems there is NO auto complete for OBJ methods. In Zend i can type $OBJ->.... and the ... is replaced with a list of all available methods currently in the object. This does not seem to be the case with PHPeD? This is a very useful feature as it saves time ESP when you have 10 - 30 classes and hundreds of functions to remember. I also use require/require_once instead of includes

I am still getting used to the interface of phped4, and so far am really liking it. But the code completion for me is a dealbreaker, please let me know if there is any settings i need know of or whatnot.

thanks in advance

Zach M.
View user's profileFind all posts by plahpoySend private message


Joined: 21 Oct 2004
Posts: 81
Location: UK
Reply with quote
It certainly should do that. Go to Tools > Settings > Code Insight, the Code Completion column is what you want. Make sure it's enabled and has a short delay. Try setting "Min characters" to 1. I don't know what that's for, but code completion (for classes at least) only seems to work when it's set to 1. Perhaps someone from Nusphere can clarify this for me?
View user's profileFind all posts by QuboidSend private message


Joined: 01 Oct 2005
Posts: 2
Reply with quote
ok, i did that, the $OBJ show up .. ie: $_CLA will auto complete to $_CLASS

BUT!!!

it still wont autocomplete $_CLASS->method1
method2
method3
method4
............

arughhh ... hehe

Z
View user's profileFind all posts by plahpoySend private message


Joined: 03 Apr 2004
Posts: 78
Reply with quote
plahpoy wrote:
ok, i did that, the $OBJ show up .. ie: $_CLA will auto complete to $_CLASS

BUT!!!

it still wont autocomplete $_CLASS->method1
method2
method3
method4
............

arughhh ... hehe

Z


phped needs to know how you are including the file. if you include using a variable in the include for example, that is a runtime option and not possible for phped to evaluate it and understand what you want (without also making more bloat)..

instead ddmitrie has a great feature -- in project property you explicitly define what gets included and you have an option to turn this on and off in settings as well.

the file has to have some 'findable' way in a require/include to automatically work in phped like you are talking about.

for instance require($root . '/includes/include1.php'); wouldn't work because phped cannot evaluate the path on it's own without your help using the project property include paths as i just mentioned.

Smile
View user's profileFind all posts by Rick ChristySend private messageYahoo Messenger
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
Quote:
My biggest concern is that it seems there is NO auto complete for OBJ methods

Actually, this is a problem of 4033. When there is no project in the workspace, it does not offer code completion for user objects. It's been fixed in 4035 and whenever you open a file or files from either remote account or local hard disk, its content is parsed by code completion engine.
Also, as Quboid said, PHPED delays autocompletion until at least "MIN CHARACTERS" are typed and its default value is 3. Under "MIN CHARACTERS" we mean number of characters left to cursor up to the closest delimiter or start of the line. In other words it would show drop down if you type ->mym and something like mymethod() exists for current statement.
please also see this post http://forum.nusphere.com/tip-type-hints-t1563.html

Let me know if you have any further concerns.
View user's profileFind all posts by dmitriSend private messageVisit poster's website
where to get this new version


Joined: 12 Oct 2005
Posts: 7
Reply with quote
i'm a existing customer, and i have the same problem as described.
View user's profileFind all posts by GhkarSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
If you have 4033, please contact support and get the latest hotfix.
If you have 4035 or higher, please contact support and describe the problem.
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 24 Oct 2005
Posts: 1
Reply with quote
I have a similar question (note I'm using the trial version):

I'm using the singleton pattern in my script and I can't get the autocomplete working for my singleton-objects.

Eg I have the following code:

Code:

class A {

/* constructor etc */

function do_something()
{
    /* stuff */
}

}

function &get_A()
{
/* creates a new A if no A has been created before and returns the object */
/* so: @return: object A
}

$my_A =& get_A(); //object_type of $my_A is A


However, code completion for $my_A doesn't work, if I type $my_A-> <ctrl-space>, no suggestions are available.

Is there a solution for this?

thanks
View user's profileFind all posts by jvhSend private message


Joined: 09 Dec 2003
Posts: 92
Reply with quote
The problem is rooted in PHP's weakly typed nature... You cannot tell from looking at $my_A only what it is. In your simple case, you can easily guess it from looking at the code, but it's not generally possible.

PHPEd seems to heuristically handle a few cases, e. g.

<?php
class foo {
function bar() {}
}

$x = new foo();
$x->|
?>

where you will get foo::bar as suggestion. A simple modification will already get it wrong:

<?php
class foo {
function bar() {}
}

class foo2 {
function bar2() {}
}


if (true)
$x = new foo();
else
$x = new foo2();

$x->|
?>

It suggests foo2::bar2 here... You "know" the right answer, but what should PhpED do? Execute the code up to the current spot and find out? But where to start? What if your code has side effects (database queries)? What if the decision for foo or foo2 was not as obvious as above, but based on a random choice?

Or, to come back to your question - how should PhpEd know from looking at "get_A()" only that it will always return an instance of A?

The same problem applies to class members and function parameters; in these cases, PhpED allows for parsing phpdoc-style comments and provides code completion (relying on correct documentation Wink. Actually, I don't know if it also makes use of PHP5 type hints? Ddmitrie Wink?

With strictly typed languages like C, C++, Java, C#... you don't have these problems because if you find a symbol like "my_A" you can look it up and fill find that it will always be of type "A", so you can provide code completion for it.
View user's profileFind all posts by mpSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
Code:
<?php

class A {
  function do_something()  {
    /* stuff */
  }
}

function &get_A() {
  $a = &new A();
  // ...
  return $a;
}

$my_A =& get_A();
$my_A->

?>


Works well in phped build 4042.
This hotfix will be available to our customers soon.

Quote:
I don't know if it also makes use of PHP5 type hints? Ddmitrie ?

type hints work too.
Actually they are working in the following order of priorities:
-PHPDOC comments (the first b'ze you'd have full control on what you need to be "recognized" in your code)
-function/method type-hints
-recognized from new and all other lang constructs where class is known.
View user's profileFind all posts by dmitriSend private messageVisit poster's website
OBJ code completion PHP_Ed vs Zend
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