This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 164158 - Type hinting for php doc blocks
Summary: Type hinting for php doc blocks
Status: RESOLVED WORKSFORME
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.3
Hardware: All All
: P3 blocker with 1 vote (vote)
Assignee: Ondrej Brejla
URL:
Keywords:
: 164221 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-04-30 09:53 UTC by djungowski
Modified: 2013-03-07 08:25 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description djungowski 2009-04-30 09:53:28 UTC
Example: I have a class like this:
class Test
{
    public function run(Zend_Http_Client $client)
    {
        
    }
}

When I create a php doc block for the function run now, I get
/**
 *
 * @param <type> $client 
 */

Although $client is already type-hinted as Zend_Http_Client in the parameter declaration I have to enter the same in the
php doc block again. It would be great if the php doc block could already be generated like this:
/**
 *
 * @param Zend_Http_Client $client 
 */
Comment 1 radalin 2009-06-10 12:55:11 UTC
It would be cool to see such a thing. As Frameworks like Zend Framework, getting wider to use, this kind of type
hintings will be more used. I guess this would be a cool addition to see this :) 
Comment 2 radalin 2009-06-10 13:07:52 UTC
Sorry this has come to my mind just a bit later I have written the last comment. This might a bit extend to this:

I have a function/method such as this:
class Foo 
{
    public function bar(Test $var)
    {
        //Some code here
        return new Foo();
    }
}

And when I insert the doc block it enters like this:
/**
 *
 * @param <type> $var
 * @return <type> 
 */

As I have indicated the return type by calling of a constructor (or new keyword), it might be easy to find out which
class this was and insert a block like this:

/**
 *
 * @param Test $var
 * @return Foo
 */

Another thing might be in usage of this:

class Foo 
{
    public function bar(Test $var)
    {
        /**
         * @var array
         */
        $var2 = $var->getAsArray();
        //Some code here
        return $var2;
    }
}

As the type hinting is done via a doc block, it might be not that hard to create a doc block such as:

/**
 *
 * @param Test $var
 * @return array
 */

It might not be required to hint the type of $var2 as I know from another doc block that getAsArray() returns a variable
of type array.

Sorry if this has gone a bit crazy, I just thought, these might be cool :)
Comment 3 Tomasz Slota 2010-02-10 08:46:25 UTC
reassigning to default owner
Comment 4 Filip Zamboj 2010-09-15 12:28:55 UTC
batch reassigning
Comment 5 miau 2012-02-05 04:34:06 UTC
*** Bug 164221 has been marked as a duplicate of this bug. ***
Comment 6 Ondrej Brejla 2012-04-24 11:48:40 UTC
Works properly in 7.2.
Comment 7 flod1 2013-03-07 08:17:14 UTC
Hy, sry but i have the same problem @7.3


public function test(){
    /**
      * @var array
      */
   $testArray= array();
   return $testArray;
}

if i gen the doc with /**<tab> over the function, it will be generate follow documantation


/**
  * @return type
  */
public function test(){
    /**
      * @var array
      */
   $testArray= array();
   return $testArray;
}
Comment 8 Ondrej Brejla 2013-03-07 08:25:25 UTC
There are more things. The phpdoc inside a function is improper. It can't be there. If you want to use some doc to define a type of a variable, use VARDoc, i.e.

/* @var $testArray array */

(1 asterisk, @var annotation, variable name and variable type).

But in this case it works for me even without any vardoc comment, just with:

<?php

/**^
function test(){
   $testArray= array();
   return $testArray;
}
?>

If I enter on caret (^), then the result is proper.

<?php

/**
 * 
 * @return array
 */
function test(){
   $testArray= array();
   return $testArray;
}
?>

So sorry, it has to be an issue on your side. Try fresh reinstal of NB without importing of old settings.

Product Version: NetBeans IDE 7.3 (Build 201302132200)
Java: 1.6.0_34; Java HotSpot(TM) Client VM 20.9-b04
Runtime: Java(TM) SE Runtime Environment 1.6.0_34-b04
System: Linux version 3.5.0-25-generic running on i386; UTF-8; cs_CZ (nb)