Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 182693

Summary: Autocomplete by PHPdoc hint (comment placing)
Product: z_Archived Reporter: Emil Ivanov <emil.vladev>
Component: PDTAssignee: PHP UI <php.ui-inbox>
Status: CLOSED WONTFIX QA Contact: Sylvia Tancheva <silviya>
Severity: enhancement    
Priority: P5 CC: gadi, ganoro, mikko.rantalainen, spektom
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Emil Ivanov CLA 2007-04-17 02:53:01 EDT
Currently, as from my observations, the PHPdoc block should be after the variable that it comments, when it comes to code in a function/method. If it's before it, the auto-complete fails to use it an display proper results.
I'll give you and example.

class A {
    function dosmth() {
        /** @var $db PDO */ // <- doesn't seem to work
        $db = someFunctionThatReturnsAPDOObject();
        /** @var $db PDO *? // <- this one, though, does
    }
}
Comment 1 exceptione CLA 2007-04-17 10:40:41 EDT
I think this is a bug. You should therefore not list this as an enhancement request. Once this bug is fixed, you need to change all your variable documentation. In addition, php documentation tools won't process comments below variables. This is critical, if not blocker!
Comment 2 Emil Ivanov CLA 2007-04-17 17:10:34 EDT
It turns out this isn't what I thought. 

When the comment is in format /* @var $db PDO */ it seems to work regardless of the possiotion, but when it's like /** @var $db PDO */ (note the 2nd asterik) it fails - again regardless of the possiotion. And with the second syntax I get nice coloring.

I'll leave it as an enchantment request so you make it possible for both type to work or highlight the 1st format, also.
Comment 3 Michael Spector CLA 2009-05-08 18:08:04 EDT

*** This bug has been marked as a duplicate of bug 260330 ***
Comment 4 Gadi Goldbarg CLA 2010-01-18 07:12:30 EST
Not exactly a duplicate.
The already closed 'duplicate' is about /* comments */ - it is fixed and verified.
The mentioned example here is about /** comment*/ which is not working. Note the double asterisk.
Leaving the enhancement open.

[Sylvia Tancheva]
Comment 5 Roy Ganor CLA 2010-01-30 01:48:48 EST
(In reply to comment #4)
> Not exactly a duplicate.
> The already closed 'duplicate' is about /* comments */ - it is fixed and
> verified.
> The mentioned example here is about /** comment*/ which is not working. Note
> the double asterisk.
> Leaving the enhancement open.
> 
> [Sylvia Tancheva]

Since PHP specifically declares type hints by @var in line comments (rather than in DocBlocks) I see small value in adding this enhancement as few people would use it. 

Moreover according to the PHPDoc @var documentation (see http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_tags.var.pkg.html) the proposed use case is not supported
Comment 6 Roy Ganor CLA 2010-02-08 08:57:21 EST
BTW - this works

<?php 

class A {
	/**
	 * @var A
	 */	
	public $myVar;
}

$a = new A();
$a->myVar->


?>
Comment 7 Sylvia Tancheva CLA 2010-02-08 09:07:59 EST
Closing according to the above comment.