CakePHP 4.The beforeSave callback must return false or EntityInterface instance

Hello guys.
I’m using CakePHP 4.1.1. I have been translating some plugins since version 3.9. Having trouble with the beforeSave callback.

When the condition shown in the image is met:

Gives an error message:

RuntimeException throws the message:

The beforeSave callback must return false or EntityInterface instance. Got boolean instead.

A little confused. I ask for advice. Thank.

It looks like the code on line 106 should read

return false;

I’m not sure why the error message reads like it does. But one of the general changes in 4.x relative to 3.x is overall more rigorous type checking.

It’s easy to imagine this 3.x code was happy with a void return but now requires the actual value false.