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]: Operands have incompatible types in Validation:validate() method #16337

Closed
Jeckerson opened this issue May 14, 2023 · 1 comment
Closed
Assignees
Labels
5.0 The issues we want to solve in the 5.0 release bug A bug report status: medium Medium

Comments

@Jeckerson
Copy link
Member

Describe the bug
Incorrect return type is defined in Phalcon\Filter\Validation:validate() method.
It also can return false in line https://github.com/phalcon/cphalcon/blob/fc183e11e8b96c43daf7d893244846206dc2aa73/phalcon/Filter/Validation.zep#LL515C26-L515C26

To Reproduce
You need to define beforeValidation() method, which requires bool return type and is called in lines above.

<?php

use Phalcon\Filter\Validation;

class MyValidator extends Validation
{
    public function beforeValidation(array|object $data, $entity, Messages $messages): bool
    {
        return false;
    }

    public function initialize(): void
    {
        // Validation rules...
    }
}

Provide minimal script to reproduce the issue

$validator = new MyValidator();
if ($validator->validate() === false) {
    // This is valid.
}

Expected behavior

Return type of Phalcon\Filter\Validation\ValidationInterface:validate() must be Messages|false

Details

  • Phalcon version: 5.2
  • PHP Version: 8.1
  • Operating System: any
@Jeckerson Jeckerson added bug A bug report status: unverified Unverified labels May 14, 2023
@Jeckerson Jeckerson self-assigned this May 14, 2023
@Jeckerson Jeckerson added 5.0 The issues we want to solve in the 5.0 release and removed status: unverified Unverified labels May 14, 2023
niden added a commit that referenced this issue Jan 11, 2024
@niden niden added the status: medium Medium label Jan 12, 2024
@niden
Copy link
Member

niden commented Jan 12, 2024

Resolved in #16338

@niden niden closed this as completed Jan 12, 2024
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: medium Medium
Projects
Status: Released
Development

No branches or pull requests

2 participants