[TYPO3-v4] Something for CGL?

Jigal van Hemert jigal at xs4all.nl
Fri Nov 26 19:56:12 CET 2010


Hi,

On 26-11-2010 17:38, Steffen Kamper wrote:
> /**
> * @var array with members of tslib_content_abstract
> */
> protected $contentObjects = array();
>
> How to do that correct so IDE knows if you type
>
> $this->contentObjects[0]-> ?

phpStorm 1.02 recognizes the following construction:

/** @var $contentObjects tslib_content_abstract[] */
protected $contentObjects = array();

$contentObjects[0]->... triggers autocomplete for the correct class.

Despite various suggestions on sites like [1] I couldn't get any type 
hinting to work for foreach loops:

foreach ($contentObjects as $contentObject) {
	$contentObject->...

Both phpStorm 1.02 and NetBeans 6.9.1 couldn't be convinced to know the 
type of $contentObject. The only thing that worked was a temporary cast 
to the type, although this was labelled as an error by phpStorm:

foreach ($contentObjects as (tslib_content_abstract)$contentObject) {


[1] 
http://stackoverflow.com/questions/778564/phpdoc-type-hinting-for-array-of-objects

-- 
Kind regards / met vriendelijke groet,

Jigal van Hemert
skype:jigal.van.hemert
msn: jigal at xs4all.nl
http://twitter.com/jigalvh


More information about the TYPO3-project-v4 mailing list