Frage

It's one of those things that annoys me.

I retrieve data using find() method, and iterate using foreach :

$ladies = ValentineQuery::create()->find();

foreach ($ladies as $maybe) 
{
    echo $maybe->getSeconddate();  //<-- DOES NOT AUTO HINT AT GETTER METHODS!!! arg
}

getSeconddate() actually works fine but does not auto hint at available getters.

If I usefindPk() method, my IDE will auto hint at the getters.

Anyone having same issues? I hope it's just my editor.

Propel 1.7, PhpStorm 4.0.3, PHP 5.3 on WIN7

War es hilfreich?

Lösung

One of these PHPDoc comments will do the job for you (if you do not mind little bit of manual type hinting, of course):

/** @var MyClass[] $ladies */
$ladies = ValentineQuery::create()->find();

/** @var MyClass $maybe */
foreach ($ladies as $maybe) 
{
    /** @var MyClass $maybe */
    echo $maybe->getSeconddate();  //<-- DOES NOT AUTO HINT AT GETTER METHODS!!! arg
}

For more automated stuff (so that you do not have to place such type hints everywhere), check PHPDocs for those methods -- maybe it will be possible to place them there (e.g. @return MyClass[]) .. or via @method tag in the class PHPDoc (it all depends on how it's implemented -- cannot say for sure as I'm not good with Propel at all).

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top