Problem/Motivation
The code contains non-canonical scalar type casts, like (boolean) and (integer), which are deprecated in PHP 8.5. The alternate type names are not supported in parameter, return, or property types, either.
https://php.watch/versions/8.5/boolean-double-integer-binary-casts-depre...
Steps to reproduce
protected function applyFormStateToConfiguration(FormStateInterface $form_state) {
$values = $form_state->getValues();
$default_configuration = $this->defaultConfiguration();
foreach ($values as $key => $value) {
if (array_key_exists($key, $this->configuration)) {
if (is_bool($default_configuration[$key])) {
$this->configuration[$key] = (boolean) $value;
}
elseif (is_int($default_configuration[$key])) {
$this->configuration[$key] = (integer) $value;
}
else {
$this->configuration[$key] = $value;
}
}
}
}
and
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
$this->configuration = $form_state->getValues();
$this->configuration['debug'] = (boolean) $this->configuration['debug'];
}
and more.
Search the code using the regex \(integer\)|\(boolean\)|\(double\)|\(binary\) to find type casts. There may be parameters, return types, or property types that need to be updated as well.
Proposed resolution
int instead of integer
float instead of double
bool instead of boolean
string instead of binary
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork webform-3558621
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
solideogloria commentedComment #3
solideogloria commentedComment #4
solideogloria commentedComment #5
liam morlandThe proposed resolution looks good to me.
Comment #7
solideogloria commentedThis is a section I'm not sure about:
Should the allowed casts be updated in this element? I left this as-is.
Comment #9
solideogloria commentedComment #11
liam morlandI committed the merge request. That is the easy one. I think the text referred-to in #7 should be updated so that it only suggests using the modern casts or perhaps has the old ones in brackets.
Comment #12
solideogloria commentedIf the text is updated, then should the casts themselves be deprecated if an old type? Currently, it has this:
We could log a warning or something if an old type is used.
Comment #13
liam morlandIt should still support the old way so that current forms will continue to work. The documentation should suggest that people use the new way.
Comment #14
solideogloria commentedComment #17
liam morlandThanks!