Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Lib\\Models\\RobotError::findFirst(): Return value must be of type ?Phalcon\\Mvc\\ModelInterface, Phalcon\\Mvc\\Model\\Row returned #15883

Closed
kvityasya opened this issue Feb 1, 2022 · 2 comments · Fixed by #15890
Assignees
Labels
5.0 The issues we want to solve in the 5.0 release bug A bug report status: high High

Comments

@kvityasya
Copy link

kvityasya commented Feb 1, 2022

When overriding the findFirst method with columns I get an error:
"Lib\\Models\\RobotError::findFirst(): Return value must be of type ?Phalcon\\Mvc\\ModelInterface, Phalcon\\Mvc\\Model\\Row returned"

Steps to reproduce the behavior:

Model without redefining method findFirst

<?php

namespace Lib\Models;

use Phalcon\Mvc\Model;

class RobotCorrect extends Model
{
    public $id;
    public $title;
    public $deleted;
}

RobotCorrect::findFirst(['columns' => 'title']); 

// Result: correct behavior 

Model with redefining method findFirst

<?php

namespace Lib\Models;

use Phalcon\Mvc\Model;

class RobotError extends Model
{
    public $id;
    public $title;
    public $deleted;

    public static function findFirst($params = null): ?ModelInterface
    {
        return parent::findFirst($params);
    }
}

RobotError::findFirst(['columns' => 'title']);

// Result: error "Lib\\Models\\RobotError::findFirst(): Return value 
// must be of type ?Phalcon\\Mvc\\ModelInterface, Phalcon\\Mvc\\Model\\Row returned"

Details

  • Phalcon version: 5.0.0beta2
  • PHP Version: 8.0.15
  • Operating System: Docker from php:8.0-fpm-alpine
  • Installation type: pecl package
  • Server: Nginx + fpm
  • Database: Mysql 8
@kvityasya kvityasya added bug A bug report status: unverified Unverified labels Feb 1, 2022
@niden niden self-assigned this Feb 5, 2022
@niden niden added 5.0 The issues we want to solve in the 5.0 release status: high High and removed status: unverified Unverified labels Feb 5, 2022
@niden niden added this to Working on it in Phalcon Roadmap Feb 5, 2022
@niden niden mentioned this issue Feb 5, 2022
5 tasks
@niden niden linked a pull request Feb 5, 2022 that will close this issue
5 tasks
@niden
Copy link
Sponsor Member

niden commented Feb 6, 2022

Resolved in #15890

Thank you @kvityasya

@niden niden closed this as completed Feb 6, 2022
Phalcon Roadmap automation moved this from Working on it to Implemented Feb 6, 2022
@HL56
Copy link

HL56 commented Feb 26, 2024

I also get this error using phalcon 4, Can we merge #15890 together into 4? For some reason, I was unable to upgrade to 5. Thanks for any answers. @niden

Details

Phalcon version: 4.1.2
PHP Version: 7.3.33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5.0 The issues we want to solve in the 5.0 release bug A bug report status: high High
Projects
Archived in project
Phalcon Roadmap
  
Implemented
Development

Successfully merging a pull request may close this issue.

3 participants