yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework

Home Page:http://www.yiiframework.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RequiredValidator with typed properties

DplusG opened this issue · comments

Q A
Yii version 2.0.49
PHP version 7.4
Is bugfix Yes
Breaks BC? No (not sure)

What steps will reproduce the problem?

$model = SomeModelWithTypedProperties();
$model->setAttributes([]);
$model->validate();

What is the expected result?

Validation error, Prop1 cannot be blank.

What do you get instead?

Typed property prop1 must not be accessed before initialization

Solution

Change RequiredValidator. See @DplusG/yii2-required-validator