[TYPO3-core] RFC: Bug #7203: Hook cObjTypeAndClassDefault in tslib_content somtimes fails

Dmitry Dulepov [typo3] dmitry at typo3.org
Tue Jan 22 11:51:08 CET 2008


Hi!

Stefan Geith wrote:
> Where and when has this coment to be added ?
> Can I find this in the coding guidelines ?

This is not official yet. Basically if you obtain object instance from "new" operator, it is clear for IDEs what object type is and they can propose methods and attributes in code assist. If you obtain instance from another function (like t3lib_div::makeInstance), IDEs have no idea what it is and code assist does not work. So we do this:

$obj = t3lib_div::makeInstance('tx_myClass');
/* @var $obj tx_myClass */
$obj->.....

So comment should appear between object creation and first use. It does not harm too much to place it after first use (you just do not get code assist for first use) but useless to put it before assignment because assignment "wipes" information from this comment. I.e. this is useless:

/* @var $obj tx_myClass */
$obj = t3lib_div::makeInstance('tx_myClass');
$obj->.....

because IDEs think that assignment changed type of $obj.

Such comments really help in development: you always know what type is (just however mouse over variable) and you can alsways get correct names for methods and attributes.

I hope to review patch soon.

-- 
Dmitry Dulepov
TYPO3 core team
Web: http://typo3bloke.net/
Skype: callto:liels_bugs
"Nothing is impossible. There are only limits to our knowledge"


More information about the TYPO3-team-core mailing list