TLDR
Background / history
In some places we need to check if an array key starts with '#', which has a special meaning in render elements.
Currently we mostly do this with $key !== '' && $key[0] === '#'.
Problem
The condition causes a warning in PHP 7.4+ if the key is an integer:
Notice: Trying to access array offset on value of type int in arrayStripDangerousKeysRecursive() (line 75 of /[..]/cfrplugin/src/Util/DataUtil.php).
Steps to reproduce
Not sure, I did this with some custom code :)
Solution / Proposed change
Make the condition more robust, like in core element_children() or element_properties():
if (is_int($key) || $key === '' || $key[0] !== '#') {
Risks
Not really. The proposed code still works in older PHP versions.
Comments
Comment #3
donquixote commented