Passed
Push — master ( 08d6dd...56a660 )
by
unknown
06:26 queued 05:18
created
src/Css/Style.php 2 patches
Braces   +12 added lines, -36 removed lines patch added patch discarded remove patch
@@ -1033,22 +1033,14 @@  discard block
 block discarded – undo
1033 1033
             // Legacy support for unitless values, not covered by spec. Might
1034 1034
             // want to restrict this to unitless `0` in the future
1035 1035
             $value = $v;
1036
-        }
1037
-
1038
-        elseif ($unit === "%") {
1036
+        } elseif ($unit === "%") {
1039 1037
             $value = $v / 100 * $ref_size;
1040
-        }
1041
-
1042
-        elseif ($unit === "px") {
1038
+        } elseif ($unit === "px") {
1043 1039
             $dpi = $this->_stylesheet->get_dompdf()->getOptions()->getDpi();
1044 1040
             $value = ($v * 72) / $dpi;
1045
-        }
1046
-
1047
-        elseif ($unit === "pt") {
1041
+        } elseif ($unit === "pt") {
1048 1042
             $value = $v;
1049
-        }
1050
-
1051
-        elseif ($unit === "rem") {
1043
+        } elseif ($unit === "rem") {
1052 1044
             $tree = $this->_stylesheet->get_dompdf()->getTree();
1053 1045
             $root_style = $tree !== null ? $tree->get_root()->get_style() : null;
1054 1046
             $root_font_size = $root_style === null || $root_style === $this
@@ -1062,34 +1054,20 @@  discard block
 block discarded – undo
1062 1054
             if ($root_style === null) {
1063 1055
                 return $value;
1064 1056
             }
1065
-        }
1066
-
1067
-        elseif ($unit === "em") {
1057
+        } elseif ($unit === "em") {
1068 1058
             $value = $v * $font_size;
1069
-        }
1070
-
1071
-        elseif ($unit === "cm") {
1059
+        } elseif ($unit === "cm") {
1072 1060
             $value = $v * 72 / 2.54;
1073
-        }
1074
-
1075
-        elseif ($unit === "mm") {
1061
+        } elseif ($unit === "mm") {
1076 1062
             $value = $v * 72 / 25.4;
1077
-        }
1078
-
1079
-        elseif ($unit === "ex") {
1063
+        } elseif ($unit === "ex") {
1080 1064
             // FIXME: em:ex ratio?
1081 1065
             $value = $v * $font_size / 2;
1082
-        }
1083
-
1084
-        elseif ($unit === "in") {
1066
+        } elseif ($unit === "in") {
1085 1067
             $value = $v * 72;
1086
-        }
1087
-
1088
-        elseif ($unit === "pc") {
1068
+        } elseif ($unit === "pc") {
1089 1069
             $value = $v * 12;
1090
-        }
1091
-
1092
-        else {
1070
+        } else {
1093 1071
             // Invalid or unsupported declaration
1094 1072
             $value = null;
1095 1073
         }
@@ -3674,9 +3652,7 @@  discard block
 block discarded – undo
3674 3652
             elseif ($function === "url") {
3675 3653
                 $url = $this->parse_string($arguments);
3676 3654
                 $parts[] = new Url($url);
3677
-            }
3678
-
3679
-            else {
3655
+            } else {
3680 3656
                 return null;
3681 3657
             }
3682 3658
         }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
     protected const CSS_NUMBER = "[+-]?\d*\.?\d+(?:[eE][+-]?\d+)?";
186 186
     protected const CSS_STRING = "" .
187 187
         '"(?:[^"]|\\\\["])*(?<!\\\\)"|' . // String ""
188
-        "'(?:[^']|\\\\['])*(?<!\\\\)'";   // String ''
188
+        "'(?:[^']|\\\\['])*(?<!\\\\)'"; // String ''
189 189
 
190 190
     /**
191 191
      * https://www.w3.org/TR/css-values-3/#custom-idents
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
         if (!isset(self::$_defaults)) {
653 653
 
654 654
             // Shorthand
655
-            $d =& self::$_defaults;
655
+            $d = & self::$_defaults;
656 656
 
657 657
             // All CSS 2.1 properties, and their default values
658 658
             // Some properties are specified with their computed value for
@@ -990,11 +990,11 @@  discard block
 block discarded – undo
990 990
 
991 991
             // Assume numeric values are already in points
992 992
             if (is_numeric($l)) {
993
-                $ret += (float) $l;
993
+                $ret += (float)$l;
994 994
                 continue;
995 995
             }
996 996
 
997
-            $val = $this->single_length_in_pt((string) $l, $ref_size, $font_size);
997
+            $val = $this->single_length_in_pt((string)$l, $ref_size, $font_size);
998 998
             $ret += $val ?? 0;
999 999
         }
1000 1000
 
@@ -1029,7 +1029,7 @@  discard block
 block discarded – undo
1029 1029
             return null;
1030 1030
         }
1031 1031
 
1032
-        $v = (float) $matches[1];
1032
+        $v = (float)$matches[1];
1033 1033
         $unit = strtolower($matches[2]);
1034 1034
 
1035 1035
         if ($unit === "") {
@@ -1484,7 +1484,7 @@  discard block
 block discarded – undo
1484 1484
             if (self::$_methods_cache[$method]) {
1485 1485
                 return $this->$method();
1486 1486
             } else {
1487
-                return implode(" ", array_map(function ($sub_prop) {
1487
+                return implode(" ", array_map(function($sub_prop) {
1488 1488
                     $val = $this->__get($sub_prop);
1489 1489
                     return \is_array($val) ? implode(" ", $val) : $val;
1490 1490
                 }, self::$_props_shorthand[$prop]));
@@ -1712,7 +1712,7 @@  discard block
 block discarded – undo
1712 1712
         $font_size = $this->__get("font_size");
1713 1713
         $factor = $computed === "normal"
1714 1714
             ? self::$default_line_height
1715
-            : (float) $computed;
1715
+            : (float)$computed;
1716 1716
 
1717 1717
         return $factor * $font_size;
1718 1718
     }
@@ -1931,10 +1931,10 @@  discard block
 block discarded – undo
1931 1931
         // Use a fixed ref size here. We don't know the border-box width here
1932 1932
         // and font size might be 0. Since we are only interested in whether
1933 1933
         // there is any border radius at all, this should do
1934
-        $tl = (float) $this->length_in_pt($this->border_top_left_radius, 12);
1935
-        $tr = (float) $this->length_in_pt($this->border_top_right_radius, 12);
1936
-        $br = (float) $this->length_in_pt($this->border_bottom_right_radius, 12);
1937
-        $bl = (float) $this->length_in_pt($this->border_bottom_left_radius, 12);
1934
+        $tl = (float)$this->length_in_pt($this->border_top_left_radius, 12);
1935
+        $tr = (float)$this->length_in_pt($this->border_top_right_radius, 12);
1936
+        $br = (float)$this->length_in_pt($this->border_bottom_right_radius, 12);
1937
+        $bl = (float)$this->length_in_pt($this->border_bottom_left_radius, 12);
1938 1938
 
1939 1939
         $this->has_border_radius_cache = $tl + $tr + $br + $bl > 0;
1940 1940
         return $this->has_border_radius_cache;
@@ -1967,10 +1967,10 @@  discard block
 block discarded – undo
1967 1967
 
1968 1968
         // Resolve percentages relative to width, as long as we have no support
1969 1969
         // for per-axis radii
1970
-        $tl = (float) $this->length_in_pt($this->border_top_left_radius, $w);
1971
-        $tr = (float) $this->length_in_pt($this->border_top_right_radius, $w);
1972
-        $br = (float) $this->length_in_pt($this->border_bottom_right_radius, $w);
1973
-        $bl = (float) $this->length_in_pt($this->border_bottom_left_radius, $w);
1970
+        $tl = (float)$this->length_in_pt($this->border_top_left_radius, $w);
1971
+        $tr = (float)$this->length_in_pt($this->border_top_right_radius, $w);
1972
+        $br = (float)$this->length_in_pt($this->border_bottom_right_radius, $w);
1973
+        $bl = (float)$this->length_in_pt($this->border_bottom_left_radius, $w);
1974 1974
 
1975 1975
         if ($tl + $tr + $br + $bl > 0) {
1976 1976
             [$rx, $ry, $rw, $rh] = $render_box;
@@ -2118,7 +2118,7 @@  discard block
 block discarded – undo
2118 2118
         // Convert escaped hex characters into ascii characters (e.g. \A => newline)
2119 2119
         return preg_replace_callback(
2120 2120
             "/\\\\([0-9a-fA-F]{0,6})/",
2121
-            function ($matches) { return Helpers::unichr(hexdec($matches[1])); },
2121
+            function($matches) { return Helpers::unichr(hexdec($matches[1])); },
2122 2122
             $string
2123 2123
         ) ?? "";
2124 2124
     }
@@ -2187,7 +2187,7 @@  discard block
 block discarded – undo
2187 2187
     {
2188 2188
         $integer = self::CSS_INTEGER;
2189 2189
         return preg_match("/^$integer$/", $val)
2190
-            ? (int) $val
2190
+            ? (int)$val
2191 2191
             : null;
2192 2192
     }
2193 2193
 
@@ -2733,7 +2733,7 @@  discard block
 block discarded – undo
2733 2733
             default:
2734 2734
                 $number = self::CSS_NUMBER;
2735 2735
                 $weight = preg_match("/^$number$/", $val)
2736
-                    ? (int) $val
2736
+                    ? (int)$val
2737 2737
                     : null;
2738 2738
                 return $weight !== null && $weight >= 1 && $weight <= 1000
2739 2739
                     ? $weight
@@ -2888,7 +2888,7 @@  discard block
 block discarded – undo
2888 2888
 
2889 2889
         // Compute number values to string and lengths to float (in pt)
2890 2890
         if (is_numeric($val)) {
2891
-            return (string) $val;
2891
+            return (string)$val;
2892 2892
         }
2893 2893
 
2894 2894
         $font_size = $this->__get("font_size");
@@ -3560,7 +3560,7 @@  discard block
 block discarded – undo
3560 3560
                 return null;
3561 3561
             }
3562 3562
 
3563
-            $value = isset($match[2]) ? (int) $match[2] : $default;
3563
+            $value = isset($match[2]) ? (int)$match[2] : $default;
3564 3564
             $counters[$name] = $sumDuplicates
3565 3565
                 ? ($counters[$name] ?? 0) + $value
3566 3566
                 : $value;
@@ -3855,9 +3855,9 @@  discard block
 block discarded – undo
3855 3855
 
3856 3856
                             foreach ($values as $i => $value) {
3857 3857
                                 if (strpos($value, "rad")) {
3858
-                                    $values[$i] = rad2deg((float) $value);
3858
+                                    $values[$i] = rad2deg((float)$value);
3859 3859
                                 } else {
3860
-                                    $values[$i] = (float) $value;
3860
+                                    $values[$i] = (float)$value;
3861 3861
                                 }
3862 3862
                             }
3863 3863
 
@@ -3940,7 +3940,7 @@  discard block
 block discarded – undo
3940 3940
 
3941 3941
         $values = preg_split("/\s+/", $computed);
3942 3942
 
3943
-        $values = array_map(function ($value) {
3943
+        $values = array_map(function($value) {
3944 3944
             if (\in_array($value, ["top", "left"], true)) {
3945 3945
                 return 0;
3946 3946
             } elseif (\in_array($value, ["bottom", "right"], true)) {
@@ -4020,7 +4020,7 @@  discard block
 block discarded – undo
4020 4020
             return null;
4021 4021
         }
4022 4022
 
4023
-        $v = (float) $matches[1];
4023
+        $v = (float)$matches[1];
4024 4024
         $percent = $matches[2] === "%";
4025 4025
         $opacity = $percent ? ($v / 100) : $v;
4026 4026
 
Please login to merge, or discard this patch.
src/FrameReflower/AbstractFrameReflower.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
         // Collapse vertical margins:
158 158
         $n = $frame->get_next_sibling();
159
-        if ( $n && !($n->is_block_level() && $n->is_in_flow()) ) {
159
+        if ($n && !($n->is_block_level() && $n->is_in_flow())) {
160 160
             while ($n = $n->get_next_sibling()) {
161 161
                 if ($n->is_block_level() && $n->is_in_flow()) {
162 162
                     break;
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
         // Collapse our first child's margin, if there is no border or padding
182 182
         if ($style->border_top_width == 0 && $style->length_in_pt($style->padding_top) == 0) {
183 183
             $f = $this->_frame->get_first_child();
184
-            if ( $f && !($f->is_block_level() && $f->is_in_flow()) ) {
184
+            if ($f && !($f->is_block_level() && $f->is_in_flow())) {
185 185
                 while ($f = $f->get_next_sibling()) {
186 186
                     if ($f->is_block_level() && $f->is_in_flow()) {
187 187
                         break;
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
         // Collapse our last child's margin, if there is no border or padding
209 209
         if ($style->border_bottom_width == 0 && $style->length_in_pt($style->padding_bottom) == 0) {
210 210
             $l = $this->_frame->get_last_child();
211
-            if ( $l && !($l->is_block_level() && $l->is_in_flow()) ) {
211
+            if ($l && !($l->is_block_level() && $l->is_in_flow())) {
212 212
                 while ($l = $l->get_prev_sibling()) {
213 213
                     if ($l->is_block_level() && $l->is_in_flow()) {
214 214
                         break;
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
         ];
476 476
 
477 477
         // The containing block is not defined yet, treat percentages as 0
478
-        $delta = (float) $style->length_in_pt($dims, 0);
478
+        $delta = (float)$style->length_in_pt($dims, 0);
479 479
         $min += $delta;
480 480
         $max += $delta;
481 481
 
Please login to merge, or discard this patch.
Braces   +7 added lines, -21 removed lines patch added patch discarded remove patch
@@ -505,40 +505,26 @@
 block discarded – undo
505 505
         foreach ($content as $val) {
506 506
             if ($val instanceof StringPart) {
507 507
                 $text .= $val->string;
508
-            }
509
-
510
-            elseif ($val instanceof OpenQuote) {
508
+            } elseif ($val instanceof OpenQuote) {
511 509
                 // FIXME: Take quotation depth into account
512 510
                 if ($quotes !== "none" && isset($quotes[0][0])) {
513 511
                     $text .= $quotes[0][0];
514 512
                 }
515
-            }
516
-
517
-            elseif ($val instanceof CloseQuote) {
513
+            } elseif ($val instanceof CloseQuote) {
518 514
                 // FIXME: Take quotation depth into account
519 515
                 if ($quotes !== "none" && isset($quotes[0][1])) {
520 516
                     $text .= $quotes[0][1];
521 517
                 }
522
-            }
523
-            
524
-            elseif ($val instanceof NoOpenQuote) {
518
+            } elseif ($val instanceof NoOpenQuote) {
525 519
                 // FIXME: Increment quotation depth
526
-            }
527
-
528
-            elseif ($val instanceof NoCloseQuote) {
520
+            } elseif ($val instanceof NoCloseQuote) {
529 521
                 // FIXME: Decrement quotation depth
530
-            }
531
-
532
-            elseif ($val instanceof Attr) {
522
+            } elseif ($val instanceof Attr) {
533 523
                 $text .= $frame->get_parent()->get_node()->getAttribute($val->attribute);
534
-            }
535
-
536
-            elseif ($val instanceof Counter) {
524
+            } elseif ($val instanceof Counter) {
537 525
                 $p = $frame->lookup_counter_frame($val->name, true);
538 526
                 $text .= $p->counter_value($val->name, $val->style);
539
-            }
540
-
541
-            elseif ($val instanceof Counters) {
527
+            } elseif ($val instanceof Counters) {
542 528
                 $p = $frame->lookup_counter_frame($val->name, true);
543 529
                 $tmp = [];
544 530
                 while ($p) {
Please login to merge, or discard this patch.