[TYPO3-dev] Small PhpStorm hint for devs

Xavier Perseguers xavier.perseguers at typo3.org
Fri Mar 11 10:02:29 CET 2011


Hi,

> But what if you need to return an array? In the usual phpDoc you just
> write "@return array". But this does not give you autocomplete. With
> PhpStorm do this instead:
>
> /**
> * ...
> *
> * @return tx_class[]
> */
> function foo() {
> return array(
> t3lib_div::makeInstance(...),
> t3lib_div::makeInstance(...)
> );
> }
>
> Voila! You have autocomplete now for arrays too :)

Thanks for writing it down.

Other hint with variable you declare, typically with makeInstance:

$myVar = t3lib_div::makeInstance('t3lib_whatever');

I now always type hint the $myVar like that:

/** @var $myVar t3lib_whatever */
$myVar = t3lib_div::makeInstance('t3lib_whatever');

which provides auto-completion and above all, additional checks too...

HTH

-- 
Xavier Perseguers
Release Manager TYPO3 4.6

TYPO3 .... inspiring people to share!
Get involved: http://typo3.org





More information about the TYPO3-dev mailing list