No description provided.
fix #1330 add intval() to improve PHP 7.1 compatibility
I think we should go ahead and cast to float rather than int. The affect is small (maybe even unnoticeable), but accuracy is important.
Also, where possible let's use type casting ((float)$var) rather than a function call (floatval($var)).
Also, any opinion on casting to float instead of int (as in #1339)?
Didn't mean to approve just yet.
In the method Style::length_in_pt, there are more (float) casts required. For some reason, its code for handling the units pt, %, rem, em, in and pc uses a (float) cast but the code for the units px, cm, mm and ex does not (example).
Adding the (float) casts fixes for example the following error:
A non well formed numeric value encountered in vendor/dompdf/dompdf/src/Css/Style.php:515
In my case the root cause for this error was the HTML code <img src="..." width="177" height="84" alt="..."> whose height attribute for some reason arrived in Style::length_in_pt as 84 px (notice the whitespace between the number and the unit).
<img src="..." width="177" height="84" alt="...">
@steffenweber could be an issue in the attribute translator. I'll be sure to take a look at that in conjunction with this update.
Yeah, removing the whitespace before px in line 36 and in line 39 of AttributeSelector.php solves this issue. (It seems odd that it exists in the first place but I'm not sure whether removing it could maybe break something else.)
I imagine it was added to avoid issues with the sprintf format string. I don't think the change will break anything, but I'll look into it a bit more.
Clean up format string spacing in AttributeTranslator
Resolves an issue brought up in the comments of #1330