You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Simple code, simple PHP typecasting. Do we really want to enforce everyone to code like this?
\Atk4\Ui\Header::addTo($app, [(string) $model->get('stock')]);
Either, any view which is set a value to should continue to use PHP-default typecasting or it should behind the scenes use uiPersistence typecasting.
The text was updated successfully, but these errors were encountered:
mkrecek234
changed the title
Default PHP typecasting should be possible
Default typecasting should be applied for any View on set
Feb 1, 2023
with hintable, such problem is detected by phpstan, and was before #1989
in 95% of atk4/ui code we do accept string (strongly typed) strictly, so even if we fix this for Header/View constructor content/label, the issue will remain for other 95% cases
Also, opinionated, I wonder how purely numeric header is common/helpful to be supported - 'Stock #' . $model->get('stock') will cast the integer implicitly...
It may be implemented in the future, but we need reliable idea how to address this. So far requiring everything typecasted to string is the best and the safest.
Enforcing HTMLTemplate in #1989 to accept string only, makes coding unnecessarily cumbersome.
Why is PHP-standard typecasting not allowed here where model field is an integer?
\Atk4\Ui\Header::addTo($app, [$model->get('stock')]);
Simple code, simple PHP typecasting. Do we really want to enforce everyone to code like this?
\Atk4\Ui\Header::addTo($app, [(string) $model->get('stock')]);
Either, any view which is set a value to should continue to use PHP-default typecasting or it should behind the scenes use uiPersistence typecasting.
The text was updated successfully, but these errors were encountered: