We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

the error in the model

Hi! I have a model of "Users"

it contains the code:

public static function find($parameters = null) { return parent::findFirst($parameters); }

on the way out, I get the error:

Declaration of App\Models\Users::find($parameters = NULL) must be compatible with Phalcon\Mvc\Model::find($parameters = NULL)

where did I go wrong?



6.8k
Accepted
answer

Re-declaration of method must contain return type - https://github.com/phalcon/cphalcon/blob/master/phalcon/Mvc/Model.zep#L1401

So it need to be like this:

public static function find($parameters = null): \Phalcon\Mvc\Model\ResultsetInterface


4.3k

thanks!

Re-declaration of method must contain return type - https://github.com/phalcon/cphalcon/blob/master/phalcon/Mvc/Model.zep#L1401

So it need to be like this:

public static function find($parameters = null): \Phalcon\Mvc\Model\ResultsetInterface