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

Accept only string|null as template value strictly #1989

Merged
merged 5 commits into from
Jan 31, 2023
Merged

Conversation

mvorisek
Copy link
Member

@mvorisek mvorisek commented Jan 31, 2023

part of #1987

template cannot judge what persistence/type to use for typecasting

@mvorisek mvorisek marked this pull request as ready for review January 31, 2023 10:48
@mvorisek mvorisek merged commit f288153 into develop Jan 31, 2023
@mvorisek mvorisek deleted the stricter_template branch January 31, 2023 11:03
@mkrecek234
Copy link
Contributor

mkrecek234 commented Feb 1, 2023

@mvorisek Why do we need this BC-break? It is very common to run set and just pass any model field to fill in template variables. The BC-break leads to an error because each and every set variable has to be first converted to string.

Use Case:
You have a HTML invoice template and want to set the integer order number.

Before:
$template->set('invoice_no', $model->get('invoice_no'))

Now:
$template->set('invoice_no', (string) $model->get('invoice_no'))

What is the benefit justifying this BC-break?

@mvorisek
Copy link
Member Author

mvorisek commented Feb 1, 2023

Please read the PR description and let's continue the discussion in a private chat, as the real impact should be minimal with the best atk4/ui usage.

@mvorisek
Copy link
Member Author

mvorisek commented Feb 1, 2023

image

@mkrecek234
Copy link
Contributor

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')]); 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants