Fix TypeError (PHP8) and Warning (PHP7) by casting values in the methods of ColorConverter
This PR references PR #1414. The PR #1414 can be closed as this PR incorporates the changes in #1414.
In PHP8 a type error will be thrown if the array, which is passed to the pack-Method in ColorConverter:convert, contains something other than a float or int. This is behaviour is currently the case as the type hint in the doc block is not honored and the array may contain a string.
This is the case for something like:
'rgba(var(--sk_highlight,18,100,163),1)'
The convert method under PHP7 will throw the following warning:
Warning: A non-numeric value encountered
In PHP8 the following error will be thrown:
Uncaught TypeError: Unsupported operand types
A simplified example of this behaviour can be found here:
https://3v4l.org/hZU29
The produced array for the aforementioned example by the method ColorConverter:convertPlain is this:
In the linked example we see that the value gets interpreted as int(0)
I've added some test cases to reflect on the changes-.
However the changes doesn't adhere to the typehint in the doc block due to the fact that the color mode is included in the array and a casting of this value to float may introduce unexpected behaviour.
@finwe can you merge this?