Skip to content

Commit

Permalink
[phalcon#16577] - refactor: add @template for Model and add to @return
Browse files Browse the repository at this point in the history
…in find and findFirst
  • Loading branch information
noone-silent committed May 3, 2024
1 parent 8722b92 commit e123c15
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
4 changes: 2 additions & 2 deletions phalcon/Mvc/Model.zep
Original file line number Diff line number Diff line change
Expand Up @@ -1631,9 +1631,9 @@ abstract class Model extends AbstractInjectionAware implements EntityInterface,
* ],
* 'hydration' => null
* ]
* @return T[]|\Phalcon\Mvc\Model\ResultsetInterface
* @return T[]|\Phalcon\Mvc\Model\Resultset<int, T>
*/
public static function find(var parameters = null) -> <ResultsetInterface>
public static function find(var parameters = null) -> <Resultset>
{
var params, query, resultset, hydration;

Expand Down
5 changes: 5 additions & 0 deletions phalcon/Mvc/Model/Resultset.zep
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ use Serializable;
* $robots->next();
* }
* ```
* @template TKey
* @template TValue
* @implements Iterator<TKey, TValue>
*/
abstract class Resultset
implements ResultsetInterface, Iterator, SeekableIterator, Countable, ArrayAccess, Serializable, JsonSerializable
Expand Down Expand Up @@ -468,6 +471,8 @@ abstract class Resultset

/**
* Gets pointer number of active row in the resultset
*
* @return TKey|null
*/
public function key() -> int | null
{
Expand Down
5 changes: 4 additions & 1 deletion phalcon/Mvc/Model/Resultset/Complex.zep
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ use stdClass;
*
* Complex resultsets may include complete objects and scalar values.
* This class builds every complex row as it is required
*
* @template TKey of int
* @template TValue of mixed
*/
class Complex extends Resultset implements ResultsetInterface
class Complex extends Resultset
{
/**
* @var array
Expand Down
4 changes: 4 additions & 0 deletions phalcon/Mvc/Model/Resultset/Simple.zep
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ use Phalcon\Storage\Serializer\SerializerInterface;
*
* Simple resultsets only contains a complete objects
* This class builds every complete object as it is required
*
* @template TKey of int
* @template TValue of \Phalcon\Mvc\ModelInterface
*/
class Simple extends Resultset
{
Expand Down Expand Up @@ -71,6 +74,7 @@ class Simple extends Resultset

/**
* Returns current row in the resultset
* @return TValue
*/
final public function current() -> <ModelInterface> | null
{
Expand Down
9 changes: 6 additions & 3 deletions phalcon/Mvc/ModelInterface.zep
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ use Phalcon\Di\DiInterface;
use Phalcon\Messages\MessageInterface;
use Phalcon\Mvc\Model\CriteriaInterface;
use Phalcon\Mvc\Model\MetaDataInterface;
use Phalcon\Mvc\Model\Resultset;
use Phalcon\Mvc\Model\ResultsetInterface;
use Phalcon\Mvc\Model\TransactionInterface;

/**
* Phalcon\Mvc\ModelInterface
*
* Interface for Phalcon\Mvc\Model
*
* @template T
*/
interface ModelInterface
{
Expand Down Expand Up @@ -102,15 +105,15 @@ interface ModelInterface
*
* @param array|string|int|null parameters
*
* @return ResultsetInterface
* @return T[]|\Phalcon\Mvc\Model\Resultset<int, T>
*/
public static function find(var parameters = null) -> <ResultsetInterface>;
public static function find(var parameters = null) -> <Resultset>;

/**
* Allows to query the first record that match the specified conditions
*
* @param array parameters
* @return \Phalcon\Mvc\ModelInterface|\Phalcon\Mvc\Model\Row|null
* @return T|\Phalcon\Mvc\ModelInterface|\Phalcon\Mvc\Model\Row|null
*
* TODO: Current method signature must be reviewed in v5. As it must return only ?ModelInterface (it also returns Row).
* @see https://github.com/phalcon/cphalcon/issues/15212
Expand Down

0 comments on commit e123c15

Please sign in to comment.