You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The ResultInterface is missing methods that are available to all result sets. Simple and Complex both only extend Resultset. Resultset is the only Class that implements ResultsetInterface. Therefor all methods from Resultset should also be in ResultsetInterface. For example currently the count() method is missing. So to make static code analyzer happy, we need to add a phpdoc overwrite of the type, or use count($model->toArray()).
To Reproduce
Read code
Expected behavior
In general all Interfaces should be checked for missing methods.
Screenshots
Details
Phalcon version: 5.6.1
PHP Version: 8.1
Operating System: debian
Installation type: sury
Zephir version (if any): -
Server: nginx
Other related info (Database, table schema): mariadb
The text was updated successfully, but these errors were encountered:
I strongly agree for this one. I was about to open another issue but it seems to be exactly my problem as well. Static code analyzers such as Psalm, PHPStan will report false-positive error when iterating results from "Model::find()" requests.
Argument of an invalid type Phalcon\Mvc\Model\ResultsetInterface supplied for foreach, only iterables are supported.
\Phalcon\Mvc\Model\ResultsetInterface should extend \Iterator, \SeekableIterator, \Countable, \ArrayAccess, \Serializable, \JsonSerializable directly from the interface definition instead of implementing those in the "Resultset" class.
Using the current Phalcon version 5.6.2, just to make the static code analyzers happy, we have to do unnecessary ignores or assertations like this:
If it's not possible to alter the \Phalcon\Mvc\Model\ResultsetInterface, then I would opt for another interface \Phalcon\Mvc\Model\IterableResultsetInterface which would extend \Phalcon\Mvc\Model\ResultsetInterface, \Iterator, \SeekableIterator, \Countable, \ArrayAccess, \Serializable, \JsonSerializable.
Describe the bug
The ResultInterface is missing methods that are available to all result sets. Simple and Complex both only extend Resultset. Resultset is the only Class that implements ResultsetInterface. Therefor all methods from Resultset should also be in ResultsetInterface. For example currently the
count()
method is missing. So to make static code analyzer happy, we need to add a phpdoc overwrite of the type, or usecount($model->toArray())
.To Reproduce
Read code
Expected behavior
In general all Interfaces should be checked for missing methods.
Screenshots
Details
The text was updated successfully, but these errors were encountered: