Skip to content

Strictness of event dispatch result / return values #16854

Closed as not planned
Closed as not planned
@dereuromark

Description

@dereuromark

for ORM checkRules()

Error

Cake\ORM\Table::checkRules(): Return value must be of type bool, null returned

As the signature of that method is:

public function checkRules(...): bool

The code inside checkRules() reads

$event = $this->dispatchEvent(
    'Model.afterRules',
    compact('entity', 'options', 'result', 'operation')
);

if ($event->isStopped()) {
    return $event->getResult();
}

Maybe, to make this less hard to fail, we should allow null as OK value?

return $event->getResult() ?? false;

What do you think?

CakePHP Version

4.4.7

PHP Version

8.1

Seems to also ref #16786

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions