Closed LordSimal closed 8 months ago
It probably cannot read the correct class from just "regex" or tokenize. In that case it would need to use AST and actually get the result via this. Might not be too trivial. Would you want to give it a shot?
We also might reach the limit of what static annotations can do What if you have two or three different paginations in a controller?
In that case it would be better to use the IDEs meta capability to get return based on param type. But that would be PHPStorm part of the plugin then.
I would agree that having the correct return type of paginate()
being inferred by the given param type is the better approach.
But then we are back at it again to not having a table specific query class...
Could we use AST to determine the object going into paginate() and then add inline annotations here?
I have to play arround more with php-parser to truly understand how to work with the AST
Since you could have multiple different models with
$this->paginate($query);
now I feal like we should then only annotate it abstractly if possible. So no concrete collection but whatever subset as interface would always be correct inside docblock method What do you think?
On the other side, the PHPStorm meta data maybe could be more concrete on the type of query and model being used, but that would be static and not runtime, so also hard to accomplish.
For some reason the
bin/cake annotate all
command doesn't seem to generate controller annotations for thepaginate()
method on all controllers.I only seem to get them on controllers which do a paginate via
$this->paginate($this->TableName);
but not for something like