@@ -859,6 +859,10 @@ |
||
859 | 859 | return $this->_downscale($height); |
860 | 860 | } |
861 | 861 | |
862 | + /** |
|
863 | + * @param string $font |
|
864 | + * @param double $size |
|
865 | + */ |
|
862 | 866 | private function get_font_height_actual($font, $size) |
863 | 867 | { |
864 | 868 | $font = $this->get_ttf_file($font); |
@@ -866,7 +866,7 @@ discard block |
||
866 | 866 | $text = mb_encode_numericentity($text, array(0x0080, 0xffff, 0, 0xffff), 'UTF-8'); |
867 | 867 | |
868 | 868 | // FIXME: word spacing |
869 | - list($x1, , $x2) = imagettfbbox($size, 0, $font, $text); |
|
869 | + list($x1,, $x2) = imagettfbbox($size, 0, $font, $text); |
|
870 | 870 | |
871 | 871 | // Add additional 1pt to prevent text overflow issues |
872 | 872 | return $this->_downscale($x2 - $x1) + 1; |
@@ -878,7 +878,7 @@ discard block |
||
878 | 878 | */ |
879 | 879 | public function get_ttf_file($font) |
880 | 880 | { |
881 | - if ( stripos($font, ".ttf") === false ) { |
|
881 | + if (stripos($font, ".ttf") === false) { |
|
882 | 882 | $font .= ".ttf"; |
883 | 883 | } |
884 | 884 | |
@@ -923,7 +923,7 @@ discard block |
||
923 | 923 | $ratio = $this->_dompdf->getOptions()->getFontHeightRatio(); |
924 | 924 | |
925 | 925 | // FIXME: word spacing |
926 | - list(, $y2, , , , $y1) = imagettfbbox($size, 0, $font, "MXjpqytfhl"); // Test string with ascenders, descenders and caps |
|
926 | + list(, $y2,,,, $y1) = imagettfbbox($size, 0, $font, "MXjpqytfhl"); // Test string with ascenders, descenders and caps |
|
927 | 927 | return ($y2 - $y1) * $ratio; |
928 | 928 | } |
929 | 929 |
@@ -991,8 +991,12 @@ discard block |
||
991 | 991 | die("Unable to stream image: headers already sent"); |
992 | 992 | } |
993 | 993 | |
994 | - if (!isset($options["type"])) $options["type"] = "png"; |
|
995 | - if (!isset($options["Attachment"])) $options["Attachment"] = true; |
|
994 | + if (!isset($options["type"])) { |
|
995 | + $options["type"] = "png"; |
|
996 | + } |
|
997 | + if (!isset($options["Attachment"])) { |
|
998 | + $options["Attachment"] = true; |
|
999 | + } |
|
996 | 1000 | $type = strtolower($options["type"]); |
997 | 1001 | |
998 | 1002 | switch ($type) { |
@@ -1043,8 +1047,12 @@ discard block |
||
1043 | 1047 | */ |
1044 | 1048 | private function _output($options = array()) |
1045 | 1049 | { |
1046 | - if (!isset($options["type"])) $options["type"] = "png"; |
|
1047 | - if (!isset($options["page"])) $options["page"] = 1; |
|
1050 | + if (!isset($options["type"])) { |
|
1051 | + $options["type"] = "png"; |
|
1052 | + } |
|
1053 | + if (!isset($options["page"])) { |
|
1054 | + $options["page"] = 1; |
|
1055 | + } |
|
1048 | 1056 | $type = strtolower($options["type"]); |
1049 | 1057 | |
1050 | 1058 | if (isset($this->_imgs[$options["page"] - 1])) { |
@@ -13,9 +13,7 @@ |
||
13 | 13 | use Dompdf\Dompdf; |
14 | 14 | use Dompdf\Helpers; |
15 | 15 | use Dompdf\Exception; |
16 | -use Dompdf\FontMetrics; |
|
17 | 16 | use Dompdf\Image\Cache; |
18 | -use Dompdf\PhpEvaluator; |
|
19 | 17 | |
20 | 18 | /** |
21 | 19 | * PDF rendering interface |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | } |
402 | 402 | |
403 | 403 | /** |
404 | - * @return float|mixed |
|
404 | + * @return double |
|
405 | 405 | */ |
406 | 406 | public function get_width() |
407 | 407 | { |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | } |
410 | 410 | |
411 | 411 | /** |
412 | - * @return float|mixed |
|
412 | + * @return double |
|
413 | 413 | */ |
414 | 414 | public function get_height() |
415 | 415 | { |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | * Sets the line style |
453 | 453 | * |
454 | 454 | * @param float $width |
455 | - * @param $cap |
|
455 | + * @param string $cap |
|
456 | 456 | * @param string $join |
457 | 457 | * @param array $dash |
458 | 458 | * |
@@ -1102,7 +1102,7 @@ discard block |
||
1102 | 1102 | * @param float $size |
1103 | 1103 | * @param int $word_spacing |
1104 | 1104 | * @param int $letter_spacing |
1105 | - * @return mixed |
|
1105 | + * @return integer |
|
1106 | 1106 | */ |
1107 | 1107 | public function get_text_width($text, $font, $size, $word_spacing = 0, $letter_spacing = 0) |
1108 | 1108 | { |
@@ -1282,8 +1282,12 @@ discard block |
||
1282 | 1282 | die("Unable to stream pdf: headers already sent"); |
1283 | 1283 | } |
1284 | 1284 | |
1285 | - if (!isset($options["compress"])) $options["compress"] = true; |
|
1286 | - if (!isset($options["Attachment"])) $options["Attachment"] = true; |
|
1285 | + if (!isset($options["compress"])) { |
|
1286 | + $options["compress"] = true; |
|
1287 | + } |
|
1288 | + if (!isset($options["Attachment"])) { |
|
1289 | + $options["Attachment"] = true; |
|
1290 | + } |
|
1287 | 1291 | |
1288 | 1292 | $this->_add_page_text(); |
1289 | 1293 | |
@@ -1349,7 +1353,9 @@ discard block |
||
1349 | 1353 | */ |
1350 | 1354 | public function output($options = array()) |
1351 | 1355 | { |
1352 | - if (!isset($options["compress"])) $options["compress"] = true; |
|
1356 | + if (!isset($options["compress"])) { |
|
1357 | + $options["compress"] = true; |
|
1358 | + } |
|
1353 | 1359 | |
1354 | 1360 | $this->_add_page_text(); |
1355 | 1361 |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | |
614 | 614 | // Set methods |
615 | 615 | /** |
616 | - * @param $id |
|
616 | + * @param integer $id |
|
617 | 617 | */ |
618 | 618 | public function set_id($id) |
619 | 619 | { |
@@ -649,10 +649,10 @@ discard block |
||
649 | 649 | } |
650 | 650 | |
651 | 651 | /** |
652 | - * @param null $x |
|
653 | - * @param null $y |
|
654 | - * @param null $w |
|
655 | - * @param null $h |
|
652 | + * @param double|null $x |
|
653 | + * @param double|null $y |
|
654 | + * @param double|null $w |
|
655 | + * @param double|null $h |
|
656 | 656 | */ |
657 | 657 | public function set_containing_block($x = null, $y = null, $w = null, $h = null) |
658 | 658 | { |
@@ -195,18 +195,18 @@ |
||
195 | 195 | "h" => null, |
196 | 196 | ); |
197 | 197 | |
198 | - $this->_containing_block[0] =& $this->_containing_block["x"]; |
|
199 | - $this->_containing_block[1] =& $this->_containing_block["y"]; |
|
200 | - $this->_containing_block[2] =& $this->_containing_block["w"]; |
|
201 | - $this->_containing_block[3] =& $this->_containing_block["h"]; |
|
198 | + $this->_containing_block[0] = & $this->_containing_block["x"]; |
|
199 | + $this->_containing_block[1] = & $this->_containing_block["y"]; |
|
200 | + $this->_containing_block[2] = & $this->_containing_block["w"]; |
|
201 | + $this->_containing_block[3] = & $this->_containing_block["h"]; |
|
202 | 202 | |
203 | 203 | $this->_position = array( |
204 | 204 | "x" => null, |
205 | 205 | "y" => null, |
206 | 206 | ); |
207 | 207 | |
208 | - $this->_position[0] =& $this->_position["x"]; |
|
209 | - $this->_position[1] =& $this->_position["y"]; |
|
208 | + $this->_position[0] = & $this->_position["x"]; |
|
209 | + $this->_position[1] = & $this->_position["y"]; |
|
210 | 210 | |
211 | 211 | $this->_opacity = 1.0; |
212 | 212 | $this->_decorator = null; |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @param DOMNode $node |
130 | 130 | * |
131 | - * @return Frame |
|
131 | + * @return AbstractFrameDecorator|null |
|
132 | 132 | */ |
133 | 133 | function copy(DOMNode $node) |
134 | 134 | { |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | /** |
142 | 142 | * Create a deep copy: copy this node and all children |
143 | 143 | * |
144 | - * @return Frame |
|
144 | + * @return AbstractFrameDecorator|null |
|
145 | 145 | */ |
146 | 146 | function deep_copy() |
147 | 147 | { |
@@ -40,7 +40,7 @@ |
||
40 | 40 | * Class constructor |
41 | 41 | * |
42 | 42 | * @param Frame $frame the frame to decorate |
43 | - * @param DOMPDF $dompdf the document's dompdf object (required to resolve relative & remote urls) |
|
43 | + * @param Dompdf $dompdf the document's dompdf object (required to resolve relative & remote urls) |
|
44 | 44 | */ |
45 | 45 | function __construct(Frame $frame, Dompdf $dompdf) |
46 | 46 | { |
@@ -10,7 +10,6 @@ |
||
10 | 10 | |
11 | 11 | use Dompdf\Dompdf; |
12 | 12 | use Dompdf\Frame; |
13 | -use Dompdf\FontMetrics; |
|
14 | 13 | use Dompdf\Image\Cache; |
15 | 14 | |
16 | 15 | /** |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | /** |
80 | 80 | * Return the bullet's width |
81 | 81 | * |
82 | - * @return int |
|
82 | + * @return double |
|
83 | 83 | */ |
84 | 84 | function get_width() |
85 | 85 | { |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | /** |
134 | 134 | * Override get_margin_height() |
135 | 135 | * |
136 | - * @return int |
|
136 | + * @return double |
|
137 | 137 | */ |
138 | 138 | function get_margin_height() |
139 | 139 | { |
@@ -12,8 +12,6 @@ |
||
12 | 12 | use Dompdf\Dompdf; |
13 | 13 | use Dompdf\Frame; |
14 | 14 | use Dompdf\Exception; |
15 | -use DOMText; |
|
16 | -use Dompdf\FontMetrics; |
|
17 | 15 | |
18 | 16 | /** |
19 | 17 | * Decorates Frame objects for text layout |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
130 | - * @param $spacing |
|
130 | + * @param double $spacing |
|
131 | 131 | */ |
132 | 132 | function set_text_spacing($spacing) |
133 | 133 | { |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | * split the text in this frame at the offset specified. The remaining |
164 | 164 | * text is added a sibling frame following this one and is returned. |
165 | 165 | * |
166 | - * @param $offset |
|
167 | - * @return Frame|null |
|
166 | + * @param integer $offset |
|
167 | + * @return null|AbstractFrameDecorator |
|
168 | 168 | */ |
169 | 169 | function split_text($offset) |
170 | 170 | { |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | /** |
228 | 228 | * Parses a CSS string containing quotes and escaped hex characters |
229 | 229 | * |
230 | - * @param $string string The CSS string to parse |
|
230 | + * @param string $string string The CSS string to parse |
|
231 | 231 | * @param $single_trim |
232 | 232 | * @return string |
233 | 233 | */ |
@@ -245,6 +245,10 @@ discard block |
||
245 | 245 | |
246 | 246 | // Convert escaped hex characters into ascii characters (e.g. \A => newline) |
247 | 247 | $string = preg_replace_callback("/\\\\([0-9a-fA-F]{0,6})/", |
248 | + |
|
249 | + /** |
|
250 | + * @param string $matches |
|
251 | + */ |
|
248 | 252 | function ($matches) { return \Dompdf\Helpers::unichr(hexdec($matches[1])); }, |
249 | 253 | $string); |
250 | 254 | return $string; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | |
94 | 94 | // Collapse vertical margins: |
95 | 95 | $n = $frame->get_next_sibling(); |
96 | - if ( $n && !$n->is_block() & !$n->is_table() ) { |
|
96 | + if ($n && !$n->is_block() & !$n->is_table()) { |
|
97 | 97 | while ($n = $n->get_next_sibling()) { |
98 | 98 | if ($n->is_block() || $n->is_table()) { |
99 | 99 | break; |
@@ -116,13 +116,13 @@ discard block |
||
116 | 116 | // Collapse our first child's margin, if there is no border or padding |
117 | 117 | if ($style->get_border_top_width() == 0 && $style->length_in_pt($style->padding_top) == 0) { |
118 | 118 | $f = $this->_frame->get_first_child(); |
119 | - if ( $f && !$f->is_block() && !$f->is_table() ) { |
|
120 | - while ( $f = $f->get_next_sibling() ) { |
|
121 | - if ( $f->is_block() || $f->is_table() ) { |
|
119 | + if ($f && !$f->is_block() && !$f->is_table()) { |
|
120 | + while ($f = $f->get_next_sibling()) { |
|
121 | + if ($f->is_block() || $f->is_table()) { |
|
122 | 122 | break; |
123 | 123 | } |
124 | 124 | |
125 | - if ( !$f->get_first_child() ) { |
|
125 | + if (!$f->get_first_child()) { |
|
126 | 126 | $f = null; |
127 | 127 | break; |
128 | 128 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | if ($f) { |
134 | 134 | $f_style = $f->get_style(); |
135 | 135 | $t = max($t, (float)$f_style->length_in_pt($f_style->margin_top, $cb["h"])); |
136 | - $style->margin_top = $t."pt"; |
|
136 | + $style->margin_top = $t . "pt"; |
|
137 | 137 | $f_style->margin_top = "0pt"; |
138 | 138 | } |
139 | 139 | } |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | // Collapse our last child's margin, if there is no border or padding |
142 | 142 | if ($style->get_border_bottom_width() == 0 && $style->length_in_pt($style->padding_bottom) == 0) { |
143 | 143 | $l = $this->_frame->get_last_child(); |
144 | - if ( $l && !$l->is_block() && !$l->is_table() ) { |
|
145 | - while ( $l = $l->get_prev_sibling() ) { |
|
146 | - if ( $l->is_block() || $l->is_table() ) { |
|
144 | + if ($l && !$l->is_block() && !$l->is_table()) { |
|
145 | + while ($l = $l->get_prev_sibling()) { |
|
146 | + if ($l->is_block() || $l->is_table()) { |
|
147 | 147 | break; |
148 | 148 | } |
149 | 149 | |
150 | - if ( !$l->get_last_child() ) { |
|
150 | + if (!$l->get_last_child()) { |
|
151 | 151 | $l = null; |
152 | 152 | break; |
153 | 153 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | if ($l) { |
159 | 159 | $l_style = $l->get_style(); |
160 | 160 | $b = max($b, (float)$l_style->length_in_pt($l_style->margin_bottom, $cb["h"])); |
161 | - $style->margin_bottom = $b."pt"; |
|
161 | + $style->margin_bottom = $b . "pt"; |
|
162 | 162 | $l_style->margin_bottom = "0pt"; |
163 | 163 | } |
164 | 164 | } |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | |
284 | 284 | // Convert escaped hex characters into ascii characters (e.g. \A => newline) |
285 | 285 | $string = preg_replace_callback("/\\\\([0-9a-fA-F]{0,6})/", |
286 | - function ($matches) { return \Dompdf\Helpers::unichr(hexdec($matches[1])); }, |
|
286 | + function($matches) { return \Dompdf\Helpers::unichr(hexdec($matches[1])); }, |
|
287 | 287 | $string); |
288 | 288 | return $string; |
289 | 289 | } |
@@ -168,6 +168,10 @@ |
||
168 | 168 | self::$_cache = array(); |
169 | 169 | } |
170 | 170 | |
171 | + /** |
|
172 | + * @param string $file |
|
173 | + * @param resource $context |
|
174 | + */ |
|
171 | 175 | static function detect_type($file, $context = null) |
172 | 176 | { |
173 | 177 | list(, , $type) = Helpers::dompdf_getimagesize($file, $context); |
@@ -170,7 +170,7 @@ |
||
170 | 170 | |
171 | 171 | static function detect_type($file, $context = null) |
172 | 172 | { |
173 | - list(, , $type) = Helpers::dompdf_getimagesize($file, $context); |
|
173 | + list(,, $type) = Helpers::dompdf_getimagesize($file, $context); |
|
174 | 174 | |
175 | 175 | return $type; |
176 | 176 | } |