php-svg-lib icon indicating copy to clipboard operation
php-svg-lib copied to clipboard

Incorrect assignment in if statement

Open mbomb007 opened this issue 5 years ago • 1 comments

Version 0.3.4

I found the following using a code scan:

if ($stroke = $style->stroke && is_array($style->stroke)) {

This is in SurfacePDFLib.php

This is equivalent to the following because assignment happens after the Boolean &&.

if ($stroke = ($style->stroke && is_array($style->stroke))) {

I just want to make sure that this isn't a problem in some way, because this mistake is common. If wrong, it would be fixed by

if (($stroke = $style->stroke) && is_array($style->stroke)) {

or by using and instead of &&.

Another occurrence in the same file:

if ($fill = $style->fill && is_array($style->fill)) {

Previously posted issue: https://github.com/dompdf/dompdf/issues/2113

mbomb007 avatar Mar 11 '20 20:03 mbomb007

Probably a mistake. The logic in the other two adapters is slightly different.

bsweeney avatar Mar 15 '20 17:03 bsweeney