These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace NFePHP\DA\Legacy\FPDF; |
||
4 | |||
5 | class FPDF |
||
0 ignored issues
–
show
|
|||
6 | { |
||
7 | const FPDF_VERSION = '1.81'; |
||
8 | const FPDF_FONTPATH = 'font/'; |
||
9 | |||
10 | protected $page; // current page number |
||
11 | protected $n; // current object number |
||
12 | protected $offsets; // array of object offsets |
||
13 | protected $buffer; // buffer holding in-memory PDF |
||
14 | protected $pages; // array containing pages |
||
15 | protected $state; // current document state |
||
16 | protected $compress; // compression flag |
||
17 | protected $k; // scale factor (number of points in user unit) |
||
18 | protected $defOrientation; // default orientation |
||
19 | protected $curOrientation; // current orientation |
||
20 | protected $stdPageSizes; // standard page sizes |
||
21 | protected $defPageSize; // default page size |
||
22 | protected $curPageSize; // current page size |
||
23 | protected $curRotation; // current page rotation |
||
24 | protected $pageInfo; // page-related data |
||
25 | protected $wPt; |
||
26 | protected $hPt; // dimensions of current page in points |
||
27 | protected $w; |
||
28 | protected $h; // dimensions of current page in user unit |
||
29 | protected $lMargin; // left margin |
||
30 | protected $tMargin; // top margin |
||
31 | protected $rMargin; // right margin |
||
32 | protected $bMargin; // page break margin |
||
33 | protected $cMargin; // cell margin |
||
34 | protected $x; |
||
35 | protected $y; // current position in user unit |
||
36 | protected $lasth; // height of last printed cell |
||
37 | protected $lineWidth; // line width in user unit |
||
38 | protected $fontpath; // path containing fonts |
||
39 | protected $coreFonts; // array of core font names |
||
40 | protected $fonts; // array of used fonts |
||
41 | protected $fontFiles; // array of font files |
||
42 | protected $encodings; // array of encodings |
||
43 | protected $cmaps; // array of ToUnicode CMaps |
||
44 | protected $fontFamily; // current font family |
||
45 | protected $fontStyle; // current font style |
||
46 | protected $underline; // underlining flag |
||
47 | protected $currentFont; // current font info |
||
48 | protected $fontSizePt; // current font size in points |
||
49 | protected $fontSize; // current font size in user unit |
||
50 | protected $drawColor; // commands for drawing color |
||
51 | protected $fillColor; // commands for filling color |
||
52 | protected $textColor; // commands for text color |
||
53 | protected $colorFlag; // indicates whether fill and text colors are different |
||
54 | protected $withAlpha; // indicates whether alpha channel is used |
||
55 | protected $ws; // word spacing |
||
56 | protected $images; // array of used images |
||
57 | protected $pageLinks; // array of links in pages |
||
58 | protected $links; // array of internal links |
||
59 | protected $autoPageBreak; // automatic page breaking |
||
60 | protected $pageBreakTrigger; // threshold used to trigger page breaks |
||
61 | protected $inHeader; // flag set when processing header |
||
62 | protected $infooter; // flag set when processing footer |
||
63 | protected $aliasNbPages; // alias for total number of pages |
||
64 | protected $zoomMode; // zoom display mode |
||
65 | protected $layoutMode; // layout display mode |
||
66 | protected $metadata; // document properties |
||
67 | protected $pdfVersion; // PDF version number |
||
68 | |||
69 | public function __construct($orientation = 'P', $unit = 'mm', $size = 'A4') |
||
70 | { |
||
71 | // Some checks |
||
72 | $this->doChecks(); |
||
73 | // Initialization of properties |
||
74 | $this->state = 0; |
||
75 | $this->page = 0; |
||
76 | $this->n = 2; |
||
77 | $this->buffer = ''; |
||
78 | $this->pages = []; |
||
79 | $this->pageInfo = []; |
||
0 ignored issues
–
show
The property
pageInfo does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
Loading history...
|
|||
80 | $this->fonts = []; |
||
81 | $this->fontFiles = []; |
||
82 | $this->encodings = []; |
||
0 ignored issues
–
show
The property
encodings does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
Loading history...
|
|||
83 | $this->cmaps = []; |
||
0 ignored issues
–
show
The property
cmaps does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
Loading history...
|
|||
84 | $this->images = []; |
||
85 | $this->links = []; |
||
86 | $this->inHeader = false; |
||
87 | $this->infooter = false; |
||
0 ignored issues
–
show
The property
infooter does not seem to exist. Did you mean inFooter ?
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name. If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.
Loading history...
|
|||
88 | $this->lasth = 0; |
||
89 | $this->fontFamily = ''; |
||
90 | $this->fontStyle = ''; |
||
91 | $this->fontSizePt = 12; |
||
92 | $this->underline = false; |
||
93 | $this->drawColor = '0 G'; |
||
94 | $this->fillColor = '0 g'; |
||
95 | $this->textColor = '0 g'; |
||
96 | $this->colorFlag = false; |
||
97 | $this->withAlpha = false; |
||
0 ignored issues
–
show
The property
withAlpha does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
Loading history...
|
|||
98 | $this->ws = 0; |
||
99 | |||
100 | $this->fontpath = __DIR__. FPDF_FONTPATH; |
||
0 ignored issues
–
show
The property
fontpath does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
Loading history...
|
|||
101 | |||
102 | // Core fonts |
||
103 | $this->coreFonts = [ |
||
104 | 'courier', |
||
105 | 'helvetica', |
||
106 | 'times', |
||
107 | 'symbol', |
||
108 | 'zapfdingbats' |
||
109 | ]; |
||
110 | |||
111 | switch ($unit) { |
||
112 | case 'pt': |
||
113 | $this->k = 1; |
||
114 | break; |
||
115 | case 'cm': |
||
116 | $this->k = 72 / 2.54; |
||
117 | break; |
||
118 | case 'in': |
||
119 | $this->k = 72; |
||
120 | break; |
||
121 | case 'mm': |
||
122 | default: |
||
123 | $this->k = 72 / 25.4; |
||
124 | } |
||
125 | |||
126 | // Page sizes |
||
127 | $this->stdPageSizes = [ |
||
0 ignored issues
–
show
The property
stdPageSizes does not seem to exist. Did you mean pageSizes ?
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name. If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.
Loading history...
|
|||
128 | 'a3' => [841.89, 1190.55], |
||
129 | 'a4' => [595.28, 841.89], |
||
130 | 'a5' => [420.94, 595.28], |
||
131 | 'letter' => [612, 792], |
||
132 | 'legal' => [612, 1008] |
||
133 | ]; |
||
134 | |||
135 | $size = $this->getPageSize($size); |
||
0 ignored issues
–
show
The method
getPageSize() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
136 | $this->defPageSize = $size; |
||
0 ignored issues
–
show
The property
defPageSize does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
Loading history...
|
|||
137 | $this->curPageSize = $size; |
||
0 ignored issues
–
show
The property
curPageSize does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
Loading history...
|
|||
138 | // Page orientation |
||
139 | $orientation = strtolower($orientation); |
||
140 | if ($orientation == 'p' || $orientation == 'portrait') { |
||
141 | $this->defOrientation = 'P'; |
||
142 | $this->w = $size[0]; |
||
143 | $this->h = $size[1]; |
||
144 | } elseif ($orientation == 'l' || $orientation == 'landscape') { |
||
145 | $this->defOrientation = 'L'; |
||
146 | $this->w = $size[1]; |
||
147 | $this->h = $size[0]; |
||
148 | } else { |
||
149 | $this->defOrientation = 'P'; |
||
150 | $this->w = $size[0]; |
||
151 | $this->h = $size[1]; |
||
152 | } |
||
153 | $this->curOrientation = $this->defOrientation; |
||
154 | $this->wPt = $this->w * $this->k; |
||
155 | $this->hPt = $this->h * $this->k; |
||
156 | // Page rotation |
||
157 | $this->curRotation = 0; |
||
0 ignored issues
–
show
The property
curRotation does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
Loading history...
|
|||
158 | // Page margins (1 cm) |
||
159 | $margin = 28.35 / $this->k; |
||
160 | $this->setMargins($margin, $margin); |
||
161 | // Interior cell margin (1 mm) |
||
162 | $this->cMargin = $margin / 10; |
||
163 | // Line width (0.2 mm) |
||
164 | $this->lineWidth = .567 / $this->k; |
||
165 | // Automatic page break |
||
166 | $this->setautoPageBreak(true, 2 * $margin); |
||
167 | // Default display mode |
||
168 | $this->setDisplayMode('default'); |
||
169 | // Enable compression |
||
170 | $this->setCompression(true); |
||
171 | // Set default PDF version number |
||
172 | $this->pdfVersion = '1.3'; |
||
173 | } |
||
174 | |||
175 | public function setMargins($left, $top, $right = null) |
||
176 | { |
||
177 | // Set left, top and right margins |
||
178 | $this->lMargin = $left; |
||
179 | $this->tMargin = $top; |
||
180 | if ($right === null) { |
||
181 | $right = $left; |
||
182 | } |
||
183 | $this->rMargin = $right; |
||
184 | } |
||
185 | |||
186 | public function setLeftMargin($margin) |
||
187 | { |
||
188 | // Set left margin |
||
189 | $this->lMargin = $margin; |
||
190 | if ($this->page > 0 && $this->x < $margin) { |
||
191 | $this->x = $margin; |
||
192 | } |
||
193 | } |
||
194 | |||
195 | public function setTopMargin($margin) |
||
196 | { |
||
197 | // Set top margin |
||
198 | $this->tMargin = $margin; |
||
199 | } |
||
200 | |||
201 | public function setRightMargin($margin) |
||
202 | { |
||
203 | // Set right margin |
||
204 | $this->rMargin = $margin; |
||
205 | } |
||
206 | |||
207 | public function setautoPageBreak($auto, $margin = 0) |
||
208 | { |
||
209 | // Set auto page break mode and triggering margin |
||
210 | $this->autoPageBreak = $auto; |
||
211 | $this->bMargin = $margin; |
||
212 | $this->pageBreakTrigger = $this->h - $margin; |
||
213 | } |
||
214 | public function setDisplayMode($zoom, $layout = 'default') |
||
215 | { |
||
216 | // Set display mode in viewer |
||
217 | if ($zoom == 'fullpage' || $zoom == 'fullwidth' || $zoom == 'real' || $zoom == 'default' || !is_string($zoom)) { |
||
218 | $this->zoomMode = $zoom; |
||
219 | } else { |
||
220 | $this->zoomMode = 'fullpage'; |
||
221 | } |
||
222 | if ($layout == 'single' || $layout == 'continuous' || $layout == 'two' || $layout == 'default') { |
||
223 | $this->layoutMode = $layout; |
||
224 | } else { |
||
225 | $this->layoutMode = 'single'; |
||
226 | } |
||
227 | } |
||
228 | |||
229 | public function setCompression($compress) |
||
230 | { |
||
231 | // Set page compression |
||
232 | if (function_exists('gzcompress')) { |
||
233 | $this->compress = $compress; |
||
234 | } else { |
||
235 | $this->compress = false; |
||
236 | } |
||
237 | } |
||
238 | |||
239 | public function setTitle($title, $isUTF8 = false) |
||
240 | { |
||
241 | // Title of document |
||
242 | $this->metadata['Title'] = $isUTF8 ? $title : utf8_encode($title); |
||
0 ignored issues
–
show
The property
metadata does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
Loading history...
|
|||
243 | } |
||
244 | |||
245 | public function setAuthor($author, $isUTF8 = false) |
||
246 | { |
||
247 | // Author of document |
||
248 | $this->metadata['Author'] = $isUTF8 ? $author : utf8_encode($author); |
||
249 | } |
||
250 | |||
251 | public function setSubject($subject, $isUTF8 = false) |
||
252 | { |
||
253 | // Subject of document |
||
254 | $this->metadata['Subject'] = $isUTF8 ? $subject : utf8_encode($subject); |
||
255 | } |
||
256 | |||
257 | public function setKeywords($keywords, $isUTF8 = false) |
||
258 | { |
||
259 | // Keywords of document |
||
260 | $this->metadata['Keywords'] = $isUTF8 ? $keywords : utf8_encode($keywords); |
||
261 | } |
||
262 | |||
263 | public function setCreator($creator, $isUTF8 = false) |
||
264 | { |
||
265 | // Creator of document |
||
266 | $this->metadata['Creator'] = $isUTF8 ? $creator : utf8_encode($creator); |
||
267 | } |
||
268 | |||
269 | public function aliasNbPages($alias = '{nb}') |
||
270 | { |
||
271 | // Define an alias for total number of pages |
||
272 | $this->aliasNbPages = $alias; |
||
273 | } |
||
274 | |||
275 | public function error($msg) |
||
276 | { |
||
277 | // Fatal error |
||
278 | throw new \Exception('FPDF error: ' . $msg); |
||
279 | } |
||
280 | |||
281 | public function close() |
||
282 | { |
||
283 | // Terminate document |
||
284 | if ($this->state == 3) { |
||
285 | return; |
||
286 | } |
||
287 | if ($this->page == 0) { |
||
288 | $this->addPage(); |
||
289 | } |
||
290 | // Page footer |
||
291 | $this->infooter = true; |
||
0 ignored issues
–
show
The property
infooter does not seem to exist. Did you mean inFooter ?
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name. If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.
Loading history...
|
|||
292 | $this->footer(); |
||
293 | $this->infooter = false; |
||
0 ignored issues
–
show
The property
infooter does not seem to exist. Did you mean inFooter ?
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name. If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.
Loading history...
|
|||
294 | // close page |
||
295 | $this->endPage(); |
||
296 | // close document |
||
297 | $this->endDoc(); |
||
298 | } |
||
299 | |||
300 | public function addPage($orientation = '', $size = '', $rotation = 0) |
||
301 | { |
||
302 | // Start a new page |
||
303 | if ($this->state == 3) { |
||
304 | $this->error('The document is closed'); |
||
305 | } |
||
306 | $family = $this->fontFamily; |
||
307 | $style = $this->fontStyle . ($this->underline ? 'U' : ''); |
||
308 | $fontsize = $this->fontSizePt; |
||
309 | $lw = $this->lineWidth; |
||
310 | $dc = $this->drawColor; |
||
311 | $fc = $this->fillColor; |
||
312 | $tc = $this->textColor; |
||
313 | $cf = $this->colorFlag; |
||
314 | if ($this->page > 0) { |
||
315 | // Page footer |
||
316 | $this->infooter = true; |
||
0 ignored issues
–
show
The property
infooter does not seem to exist. Did you mean inFooter ?
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name. If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.
Loading history...
|
|||
317 | $this->footer(); |
||
318 | $this->infooter = false; |
||
0 ignored issues
–
show
The property
infooter does not seem to exist. Did you mean inFooter ?
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name. If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.
Loading history...
|
|||
319 | // close page |
||
320 | $this->endPage(); |
||
321 | } |
||
322 | // Start new page |
||
323 | $this->beginPage($orientation, $size, $rotation); |
||
0 ignored issues
–
show
The call to
Fpdf::beginPage() has too many arguments starting with $rotation .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the
Loading history...
|
|||
324 | // Set line cap style to square |
||
325 | $this->out('2 J'); |
||
326 | // Set line width |
||
327 | $this->lineWidth = $lw; |
||
328 | $this->out(sprintf('%.2F w', $lw * $this->k)); |
||
329 | // Set font |
||
330 | if ($family) { |
||
331 | $this->setFont($family, $style, $fontsize); |
||
332 | } |
||
333 | // Set colors |
||
334 | $this->drawColor = $dc; |
||
335 | if ($dc != '0 G') { |
||
336 | $this->out($dc); |
||
337 | } |
||
338 | $this->fillColor = $fc; |
||
339 | if ($fc != '0 g') { |
||
340 | $this->out($fc); |
||
341 | } |
||
342 | $this->textColor = $tc; |
||
343 | $this->colorFlag = $cf; |
||
344 | // Page header |
||
345 | $this->inHeader = true; |
||
346 | $this->header(); |
||
347 | $this->inHeader = false; |
||
348 | // Restore line width |
||
349 | if ($this->lineWidth != $lw) { |
||
350 | $this->lineWidth = $lw; |
||
351 | $this->out(sprintf('%.2F w', $lw * $this->k)); |
||
352 | } |
||
353 | // Restore font |
||
354 | if ($family) { |
||
355 | $this->setFont($family, $style, $fontsize); |
||
356 | } |
||
357 | // Restore colors |
||
358 | if ($this->drawColor != $dc) { |
||
359 | $this->drawColor = $dc; |
||
360 | $this->out($dc); |
||
361 | } |
||
362 | if ($this->fillColor != $fc) { |
||
363 | $this->fillColor = $fc; |
||
364 | $this->out($fc); |
||
365 | } |
||
366 | $this->textColor = $tc; |
||
367 | $this->colorFlag = $cf; |
||
368 | } |
||
369 | |||
370 | public function header() |
||
371 | { |
||
372 | // To be implemented in your own inherited class |
||
373 | } |
||
374 | |||
375 | public function footer() |
||
376 | { |
||
377 | // To be implemented in your own inherited class |
||
378 | } |
||
379 | |||
380 | public function pageNo() |
||
381 | { |
||
382 | // Get current page number |
||
383 | return $this->page; |
||
384 | } |
||
385 | public function setdrawColor($r, $g = null, $b = null) |
||
386 | { |
||
387 | // Set color for all stroking operations |
||
388 | if (($r == 0 && $g == 0 && $b == 0) || $g === null) { |
||
389 | $this->drawColor = sprintf('%.3F G', $r / 255); |
||
390 | } else { |
||
391 | $this->drawColor = sprintf('%.3F %.3F %.3F RG', $r / 255, $g / 255, $b / 255); |
||
392 | } |
||
393 | if ($this->page > 0) { |
||
394 | $this->out($this->drawColor); |
||
395 | } |
||
396 | } |
||
397 | |||
398 | public function setfillColor($r, $g = null, $b = null) |
||
399 | { |
||
400 | // Set color for all filling operations |
||
401 | if (($r == 0 && $g == 0 && $b == 0) || $g === null) { |
||
402 | $this->fillColor = sprintf('%.3F g', $r / 255); |
||
403 | } else { |
||
404 | $this->fillColor = sprintf('%.3F %.3F %.3F rg', $r / 255, $g / 255, $b / 255); |
||
405 | } |
||
406 | $this->colorFlag = ($this->fillColor != $this->textColor); |
||
407 | if ($this->page > 0) { |
||
408 | $this->out($this->fillColor); |
||
409 | } |
||
410 | } |
||
411 | |||
412 | public function settextColor($r, $g = null, $b = null) |
||
413 | { |
||
414 | // Set color for text |
||
415 | if (($r == 0 && $g == 0 && $b == 0) || $g === null) { |
||
416 | $this->textColor = sprintf('%.3F g', $r / 255); |
||
417 | } else { |
||
418 | $this->textColor = sprintf('%.3F %.3F %.3F rg', $r / 255, $g / 255, $b / 255); |
||
419 | } |
||
420 | $this->colorFlag = ($this->fillColor != $this->textColor); |
||
421 | } |
||
422 | |||
423 | public function getStringWidth($s) |
||
424 | { |
||
425 | // Get width of a string in the current font |
||
426 | $s = (string) $s; |
||
427 | $cw = &$this->currentFont['cw']; |
||
428 | $w = 0; |
||
429 | $l = strlen($s); |
||
430 | for ($i = 0; $i < $l; $i++) { |
||
431 | $w += $cw[$s[$i]]; |
||
432 | } |
||
433 | return $w * $this->fontSize / 1000; |
||
434 | } |
||
435 | |||
436 | public function setlineWidth($width) |
||
437 | { |
||
438 | // Set line width |
||
439 | $this->lineWidth = $width; |
||
440 | if ($this->page > 0) { |
||
441 | $this->out(sprintf('%.2F w', $width * $this->k)); |
||
442 | } |
||
443 | } |
||
444 | |||
445 | public function line($x1, $y1, $x2, $y2) |
||
446 | { |
||
447 | // Draw a line |
||
448 | $this->out( |
||
449 | sprintf( |
||
450 | '%.2F %.2F m %.2F %.2F l S', |
||
451 | $x1 * $this->k, |
||
452 | ($this->h - $y1) * $this->k, |
||
453 | $x2 * $this->k, |
||
454 | ($this->h - $y2) * $this->k |
||
455 | ) |
||
456 | ); |
||
457 | } |
||
458 | |||
459 | public function rect($x, $y, $w, $h, $style = '') |
||
460 | { |
||
461 | // Draw a rectangle |
||
462 | if ($style == 'F') { |
||
463 | $op = 'f'; |
||
464 | } elseif ($style == 'FD' || $style == 'DF') { |
||
465 | $op = 'B'; |
||
466 | } else { |
||
467 | $op = 'S'; |
||
468 | } |
||
469 | $this->out( |
||
470 | sprintf( |
||
471 | '%.2F %.2F %.2F %.2F re %s', |
||
472 | $x * $this->k, |
||
473 | ($this->h - $y) * $this->k, |
||
474 | $w * $this->k, |
||
475 | -$h * $this->k, |
||
476 | $op |
||
477 | ) |
||
478 | ); |
||
479 | } |
||
480 | |||
481 | public function addFont($family, $style = '', $file = '') |
||
482 | { |
||
483 | // Add a TrueType, OpenType or Type1 font |
||
484 | $family = strtolower($family); |
||
485 | if ($file == '') { |
||
486 | $file = str_replace(' ', '', $family) . strtolower($style) . '.php'; |
||
487 | } |
||
488 | $style = strtoupper($style); |
||
489 | if ($style == 'IB') { |
||
490 | $style = 'BI'; |
||
491 | } |
||
492 | $fontkey = $family . $style; |
||
493 | if (isset($this->fonts[$fontkey])) { |
||
494 | return; |
||
495 | } |
||
496 | $info = $this->loadFont($file); |
||
0 ignored issues
–
show
The method
loadFont() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
497 | $info['i'] = count($this->fonts) + 1; |
||
498 | if (!empty($info['file'])) { |
||
499 | // Embedded font |
||
500 | if ($info['type'] == 'TrueType') { |
||
501 | $this->fontFiles[$info['file']] = ['length1' => $info['originalsize']]; |
||
502 | } else { |
||
503 | $this->fontFiles[$info['file']] = ['length1' => $info['size1'], 'length2' => $info['size2']]; |
||
504 | } |
||
505 | } |
||
506 | $this->fonts[$fontkey] = $info; |
||
507 | } |
||
508 | |||
509 | public function setFont($family, $style = '', $size = 0) |
||
510 | { |
||
511 | // Select a font; size given in points |
||
512 | if ($family == '') { |
||
513 | $family = $this->fontFamily; |
||
514 | } else { |
||
515 | $family = strtolower($family); |
||
516 | } |
||
517 | $style = strtoupper($style); |
||
518 | if (strpos($style, 'U') !== false) { |
||
519 | $this->underline = true; |
||
520 | $style = str_replace('U', '', $style); |
||
521 | } else { |
||
522 | $this->underline = false; |
||
523 | } |
||
524 | if ($style == 'IB') { |
||
525 | $style = 'BI'; |
||
526 | } |
||
527 | if ($size == 0) { |
||
528 | $size = $this->fontSizePt; |
||
529 | } |
||
530 | // Test if font is already selected |
||
531 | if ($this->fontFamily == $family && $this->fontStyle == $style && $this->fontSizePt == $size) { |
||
532 | return; |
||
533 | } |
||
534 | // Test if font is already loaded |
||
535 | $fontkey = $family . $style; |
||
536 | if (!isset($this->fonts[$fontkey])) { |
||
537 | // Test if one of the core fonts |
||
538 | if ($family == 'arial') { |
||
539 | $family = 'helvetica'; |
||
540 | } |
||
541 | if (in_array($family, $this->coreFonts)) { |
||
542 | if ($family == 'symbol' || $family == 'zapfdingbats') { |
||
543 | $style = ''; |
||
544 | } |
||
545 | $fontkey = $family . $style; |
||
546 | if (!isset($this->fonts[$fontkey])) { |
||
547 | $this->addFont($family, $style); |
||
548 | } |
||
549 | } else { |
||
550 | $this->error('Undefined font: ' . $family . ' ' . $style); |
||
551 | } |
||
552 | } |
||
553 | // Select it |
||
554 | $this->fontFamily = $family; |
||
555 | $this->fontStyle = $style; |
||
556 | $this->fontSizePt = $size; |
||
557 | $this->fontSize = $size / $this->k; |
||
558 | $this->currentFont = &$this->fonts[$fontkey]; |
||
559 | if ($this->page > 0) { |
||
560 | $this->out(sprintf('BT /F%d %.2F Tf ET', $this->currentFont['i'], $this->fontSizePt)); |
||
561 | } |
||
562 | } |
||
563 | |||
564 | public function setfontSize($size) |
||
565 | { |
||
566 | // Set font size in points |
||
567 | if ($this->fontSizePt == $size) { |
||
568 | return; |
||
569 | } |
||
570 | $this->fontSizePt = $size; |
||
571 | $this->fontSize = $size / $this->k; |
||
572 | if ($this->page > 0) { |
||
573 | $this->out(sprintf('BT /F%d %.2F Tf ET', $this->currentFont['i'], $this->fontSizePt)); |
||
574 | } |
||
575 | } |
||
576 | |||
577 | public function addLink() |
||
578 | { |
||
579 | // Create a new internal link |
||
580 | $n = count($this->links) + 1; |
||
581 | $this->links[$n] = [0, 0]; |
||
582 | return $n; |
||
583 | } |
||
584 | |||
585 | public function setLink($link, $y = 0, $page = -1) |
||
586 | { |
||
587 | // Set destination of internal link |
||
588 | if ($y == -1) { |
||
589 | $y = $this->y; |
||
590 | } |
||
591 | if ($page == -1) { |
||
592 | $page = $this->page; |
||
593 | } |
||
594 | $this->links[$link] = [$page, $y]; |
||
595 | } |
||
596 | |||
597 | public function link($x, $y, $w, $h, $link) |
||
598 | { |
||
599 | // Put a link on the page |
||
600 | $this->pageLinks[$this->page][] = [ |
||
0 ignored issues
–
show
The property
pageLinks does not seem to exist. Did you mean PageLinks ?
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name. If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.
Loading history...
|
|||
601 | $x * $this->k, |
||
602 | $this->hPt - $y * $this->k, |
||
603 | $w * $this->k, |
||
604 | $h * $this->k, |
||
605 | $link |
||
606 | ]; |
||
607 | } |
||
608 | |||
609 | public function text($x, $y, $txt) |
||
610 | { |
||
611 | // output a string |
||
612 | if (!isset($this->currentFont)) { |
||
613 | $this->error('No font has been set'); |
||
614 | } |
||
615 | $s = sprintf( |
||
616 | 'BT %.2F %.2F Td (%s) Tj ET', |
||
617 | $x * $this->k, |
||
618 | ($this->h - $y) * $this->k, |
||
619 | $this->escape($txt) |
||
620 | ); |
||
621 | if ($this->underline && $txt != '') { |
||
622 | $s .= ' ' . $this->doUnderLine($x, $y, $txt); |
||
623 | } |
||
624 | if ($this->colorFlag) { |
||
625 | $s = 'q ' . $this->textColor . ' ' . $s . ' Q'; |
||
626 | } |
||
627 | $this->out($s); |
||
628 | } |
||
629 | |||
630 | public function acceptPageBreak() |
||
631 | { |
||
632 | // Accept automatic page break or not |
||
633 | return $this->autoPageBreak; |
||
634 | } |
||
635 | |||
636 | public function cell($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $fill = false, $link = '') |
||
637 | { |
||
638 | // output a cell |
||
639 | $k = $this->k; |
||
640 | if ($this->y + $h > $this->pageBreakTrigger |
||
641 | && !$this->inHeader |
||
642 | && !$this->infooter |
||
0 ignored issues
–
show
The property
infooter does not seem to exist. Did you mean inFooter ?
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name. If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.
Loading history...
|
|||
643 | && $this->acceptPageBreak() |
||
644 | ) { |
||
645 | // Automatic page break |
||
646 | $x = $this->x; |
||
647 | $ws = $this->ws; |
||
648 | if ($ws > 0) { |
||
649 | $this->ws = 0; |
||
650 | $this->out('0 Tw'); |
||
651 | } |
||
652 | $this->addPage($this->curOrientation, $this->curPageSize, $this->curRotation); |
||
0 ignored issues
–
show
The call to
Fpdf::addPage() has too many arguments starting with $this->curRotation .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the
Loading history...
|
|||
653 | $this->x = $x; |
||
654 | if ($ws > 0) { |
||
655 | $this->ws = $ws; |
||
656 | $this->out(sprintf('%.3F Tw', $ws * $k)); |
||
657 | } |
||
658 | } |
||
659 | if ($w == 0) { |
||
660 | $w = $this->w - $this->rMargin - $this->x; |
||
661 | } |
||
662 | $s = ''; |
||
663 | if ($fill || $border == 1) { |
||
664 | if ($fill) { |
||
665 | $op = ($border == 1) ? 'B' : 'f'; |
||
666 | } else { |
||
667 | $op = 'S'; |
||
668 | } |
||
669 | $s = sprintf( |
||
670 | '%.2F %.2F %.2F %.2F re %s ', |
||
671 | $this->x * $k, |
||
672 | ($this->h - $this->y) * $k, |
||
673 | $w * $k, |
||
674 | -$h * $k, |
||
675 | $op |
||
676 | ); |
||
677 | } |
||
678 | if (is_string($border)) { |
||
679 | $x = $this->x; |
||
680 | $y = $this->y; |
||
681 | if (strpos($border, 'L') !== false) { |
||
682 | $s .= sprintf( |
||
683 | '%.2F %.2F m %.2F %.2F l S ', |
||
684 | $x * $k, |
||
685 | ($this->h - $y) * $k, |
||
686 | $x * $k, |
||
687 | ($this->h - ($y + $h)) * $k |
||
688 | ); |
||
689 | } |
||
690 | if (strpos($border, 'T') !== false) { |
||
691 | $s .= sprintf( |
||
692 | '%.2F %.2F m %.2F %.2F l S ', |
||
693 | $x * $k, |
||
694 | ($this->h - $y) * $k, |
||
695 | ($x + $w) * $k, |
||
696 | ($this->h - $y) * $k |
||
697 | ); |
||
698 | } |
||
699 | if (strpos($border, 'R') !== false) { |
||
700 | $s .= sprintf( |
||
701 | '%.2F %.2F m %.2F %.2F l S ', |
||
702 | ($x + $w) * $k, |
||
703 | ($this->h - $y) * $k, |
||
704 | ($x + $w) * $k, |
||
705 | ($this->h - ($y + $h)) * $k |
||
706 | ); |
||
707 | } |
||
708 | if (strpos($border, 'B') !== false) { |
||
709 | $s .= sprintf( |
||
710 | '%.2F %.2F m %.2F %.2F l S ', |
||
711 | $x * $k, |
||
712 | ($this->h - ($y + $h)) * $k, |
||
713 | ($x + $w) * $k, |
||
714 | ($this->h - ($y + $h)) * $k |
||
715 | ); |
||
716 | } |
||
717 | } |
||
718 | if ($txt !== '') { |
||
719 | if (!isset($this->currentFont)) { |
||
720 | $this->error('No font has been set'); |
||
721 | } |
||
722 | if ($align == 'R') { |
||
723 | $dx = $w - $this->cMargin - $this->getStringWidth($txt); |
||
724 | } elseif ($align == 'C') { |
||
725 | $dx = ($w - $this->getStringWidth($txt)) / 2; |
||
726 | } else { |
||
727 | $dx = $this->cMargin; |
||
728 | } |
||
729 | if ($this->colorFlag) { |
||
730 | $s .= 'q ' . $this->textColor . ' '; |
||
731 | } |
||
732 | $s .= sprintf( |
||
733 | 'BT %.2F %.2F Td (%s) Tj ET', |
||
734 | ($this->x + $dx) * $k, |
||
735 | ($this->h - ($this->y + .5 * $h + .3 * $this->fontSize)) * $k, |
||
736 | $this->escape($txt) |
||
737 | ); |
||
738 | if ($this->underline) { |
||
739 | $s .= ' ' . $this->doUnderLine( |
||
740 | $this->x + $dx, |
||
741 | $this->y + .5 * $h + .3 * $this->fontSize, |
||
742 | $txt |
||
743 | ); |
||
744 | } |
||
745 | if ($this->colorFlag) { |
||
746 | $s .= ' Q'; |
||
747 | } |
||
748 | if ($link) { |
||
749 | $this->link( |
||
750 | $this->x + $dx, |
||
751 | $this->y + .5 * $h - .5 * $this->fontSize, |
||
752 | $this->getStringWidth($txt), |
||
753 | $this->fontSize, |
||
754 | $link |
||
755 | ); |
||
756 | } |
||
757 | } |
||
758 | if ($s) { |
||
759 | $this->out($s); |
||
760 | } |
||
761 | $this->lasth = $h; |
||
762 | if ($ln > 0) { |
||
763 | // Go to next line |
||
764 | $this->y += $h; |
||
765 | if ($ln == 1) { |
||
766 | $this->x = $this->lMargin; |
||
767 | } |
||
768 | } else { |
||
769 | $this->x += $w; |
||
770 | } |
||
771 | } |
||
772 | |||
773 | public function multiCell($w, $h, $txt, $border = 0, $align = 'J', $fill = false) |
||
774 | { |
||
775 | // output text with automatic or explicit line breaks |
||
776 | if (!isset($this->currentFont)) { |
||
777 | $this->error('No font has been set'); |
||
778 | } |
||
779 | $cw = &$this->currentFont['cw']; |
||
780 | if ($w == 0) { |
||
781 | $w = $this->w - $this->rMargin - $this->x; |
||
782 | } |
||
783 | $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->fontSize; |
||
784 | $s = str_replace("\r", '', $txt); |
||
785 | $nb = strlen($s); |
||
786 | if ($nb > 0 && $s[$nb - 1] == "\n") { |
||
787 | $nb--; |
||
788 | } |
||
789 | $b = 0; |
||
790 | if ($border) { |
||
791 | if ($border == 1) { |
||
792 | $border = 'LTRB'; |
||
793 | $b = 'LRT'; |
||
794 | $b2 = 'LR'; |
||
795 | } else { |
||
796 | $b2 = ''; |
||
797 | if (strpos($border, 'L') !== false) { |
||
798 | $b2 .= 'L'; |
||
799 | } |
||
800 | if (strpos($border, 'R') !== false) { |
||
801 | $b2 .= 'R'; |
||
802 | } |
||
803 | $b = (strpos($border, 'T') !== false) ? $b2 . 'T' : $b2; |
||
804 | } |
||
805 | } |
||
806 | $sep = -1; |
||
807 | $i = 0; |
||
808 | $j = 0; |
||
809 | $l = 0; |
||
810 | $ns = 0; |
||
811 | $nl = 1; |
||
812 | while ($i < $nb) { |
||
813 | // Get next character |
||
814 | $c = $s[$i]; |
||
815 | if ($c == "\n") { |
||
816 | // Explicit line break |
||
817 | if ($this->ws > 0) { |
||
818 | $this->ws = 0; |
||
819 | $this->out('0 Tw'); |
||
820 | } |
||
821 | $this->cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill); |
||
822 | $i++; |
||
823 | $sep = -1; |
||
824 | $j = $i; |
||
825 | $l = 0; |
||
826 | $ns = 0; |
||
827 | $nl++; |
||
828 | if ($border && $nl == 2) { |
||
829 | $b = $b2; |
||
0 ignored issues
–
show
The variable
$b2 does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
Loading history...
|
|||
830 | } |
||
831 | continue; |
||
832 | } |
||
833 | if ($c == ' ') { |
||
834 | $sep = $i; |
||
835 | $ls = $l; |
||
836 | $ns++; |
||
837 | } |
||
838 | $l += $cw[$c]; |
||
839 | if ($l > $wmax) { |
||
840 | // Automatic line break |
||
841 | if ($sep == -1) { |
||
842 | if ($i == $j) { |
||
843 | $i++; |
||
844 | } |
||
845 | if ($this->ws > 0) { |
||
846 | $this->ws = 0; |
||
847 | $this->out('0 Tw'); |
||
848 | } |
||
849 | $this->cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill); |
||
850 | } else { |
||
851 | if ($align == 'J') { |
||
852 | $this->ws = ($ns > 1) |
||
853 | ? ($wmax - $ls) / 1000 * $this->fontSize / ($ns - 1) |
||
0 ignored issues
–
show
The variable
$ls does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
Loading history...
|
|||
854 | : 0; |
||
855 | $this->out(sprintf('%.3F Tw', $this->ws * $this->k)); |
||
856 | } |
||
857 | $this->cell($w, $h, substr($s, $j, $sep - $j), $b, 2, $align, $fill); |
||
858 | $i = $sep + 1; |
||
859 | } |
||
860 | $sep = -1; |
||
861 | $j = $i; |
||
862 | $l = 0; |
||
863 | $ns = 0; |
||
864 | $nl++; |
||
865 | if ($border && $nl == 2) { |
||
866 | $b = $b2; |
||
867 | } |
||
868 | } else { |
||
869 | $i++; |
||
870 | } |
||
871 | } |
||
872 | // Last chunk |
||
873 | if ($this->ws > 0) { |
||
874 | $this->ws = 0; |
||
875 | $this->out('0 Tw'); |
||
876 | } |
||
877 | if ($border && strpos($border, 'B') !== false) { |
||
878 | $b .= 'B'; |
||
879 | } |
||
880 | $this->cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill); |
||
881 | $this->x = $this->lMargin; |
||
882 | } |
||
883 | |||
884 | public function write($h, $txt, $link = '') |
||
885 | { |
||
886 | // output text in flowing mode |
||
887 | if (!isset($this->currentFont)) { |
||
888 | $this->error('No font has been set'); |
||
889 | } |
||
890 | $cw = &$this->currentFont['cw']; |
||
891 | $w = $this->w - $this->rMargin - $this->x; |
||
892 | $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->fontSize; |
||
893 | $s = str_replace("\r", '', $txt); |
||
894 | $nb = strlen($s); |
||
895 | $sep = -1; |
||
896 | $i = 0; |
||
897 | $j = 0; |
||
898 | $l = 0; |
||
899 | $nl = 1; |
||
900 | while ($i < $nb) { |
||
901 | // Get next character |
||
902 | $c = $s[$i]; |
||
903 | if ($c == "\n") { |
||
904 | // Explicit line break |
||
905 | $this->cell($w, $h, substr($s, $j, $i - $j), 0, 2, '', false, $link); |
||
906 | $i++; |
||
907 | $sep = -1; |
||
908 | $j = $i; |
||
909 | $l = 0; |
||
910 | if ($nl == 1) { |
||
911 | $this->x = $this->lMargin; |
||
912 | $w = $this->w - $this->rMargin - $this->x; |
||
913 | $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->fontSize; |
||
914 | } |
||
915 | $nl++; |
||
916 | continue; |
||
917 | } |
||
918 | if ($c == ' ') { |
||
919 | $sep = $i; |
||
920 | } |
||
921 | $l += $cw[$c]; |
||
922 | if ($l > $wmax) { |
||
923 | // Automatic line break |
||
924 | if ($sep == -1) { |
||
925 | if ($this->x > $this->lMargin) { |
||
926 | // Move to next line |
||
927 | $this->x = $this->lMargin; |
||
928 | $this->y += $h; |
||
929 | $w = $this->w - $this->rMargin - $this->x; |
||
930 | $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->fontSize; |
||
931 | $i++; |
||
932 | $nl++; |
||
933 | continue; |
||
934 | } |
||
935 | if ($i == $j) { |
||
936 | $i++; |
||
937 | } |
||
938 | $this->cell($w, $h, substr($s, $j, $i - $j), 0, 2, '', false, $link); |
||
939 | } else { |
||
940 | $this->cell($w, $h, substr($s, $j, $sep - $j), 0, 2, '', false, $link); |
||
941 | $i = $sep + 1; |
||
942 | } |
||
943 | $sep = -1; |
||
944 | $j = $i; |
||
945 | $l = 0; |
||
946 | if ($nl == 1) { |
||
947 | $this->x = $this->lMargin; |
||
948 | $w = $this->w - $this->rMargin - $this->x; |
||
949 | $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->fontSize; |
||
950 | } |
||
951 | $nl++; |
||
952 | } else { |
||
953 | $i++; |
||
954 | } |
||
955 | } |
||
956 | // Last chunk |
||
957 | if ($i != $j) { |
||
958 | $this->cell($l / 1000 * $this->fontSize, $h, substr($s, $j), 0, 0, '', false, $link); |
||
959 | } |
||
960 | } |
||
961 | |||
962 | public function ln($h = null) |
||
963 | { |
||
964 | // Line feed; default value is the last cell height |
||
965 | $this->x = $this->lMargin; |
||
966 | if ($h === null) { |
||
967 | $this->y += $this->lasth; |
||
968 | } else { |
||
969 | $this->y += $h; |
||
970 | } |
||
971 | } |
||
972 | |||
973 | public function image($file, $x = null, $y = null, $w = 0, $h = 0, $type = '', $link = '') |
||
974 | { |
||
975 | // Put an image on the page |
||
976 | if ($file == '') { |
||
977 | $this->error('Image file name is empty'); |
||
978 | } |
||
979 | if (!isset($this->images[$file])) { |
||
980 | // First use of this image, get info |
||
981 | if ($type == '') { |
||
982 | $pos = strrpos($file, '.'); |
||
983 | if (!$pos) { |
||
984 | $this->error( |
||
985 | 'Image file has no extension and no type was specified: ' |
||
986 | . $file |
||
987 | ); |
||
988 | } |
||
989 | $type = substr($file, $pos + 1); |
||
990 | } |
||
991 | $type = strtolower($type); |
||
992 | if ($type == 'jpeg') { |
||
993 | $type = 'jpg'; |
||
994 | } |
||
995 | $mtd = '_parse' . $type; |
||
996 | if (!method_exists($this, $mtd)) { |
||
997 | $this->error('Unsupported image type: ' . $type); |
||
998 | } |
||
999 | $info = $this->$mtd($file); |
||
1000 | $info['i'] = count($this->images) + 1; |
||
1001 | $this->images[$file] = $info; |
||
1002 | } else { |
||
1003 | $info = $this->images[$file]; |
||
1004 | } |
||
1005 | // Automatic width and height calculation if needed |
||
1006 | if ($w == 0 && $h == 0) { |
||
1007 | // Put image at 96 dpi |
||
1008 | $w = -96; |
||
1009 | $h = -96; |
||
1010 | } |
||
1011 | if ($w < 0) { |
||
1012 | $w = -$info['w'] * 72 / $w / $this->k; |
||
1013 | } |
||
1014 | if ($h < 0) { |
||
1015 | $h = -$info['h'] * 72 / $h / $this->k; |
||
1016 | } |
||
1017 | if ($w == 0) { |
||
1018 | $w = $h * $info['w'] / $info['h']; |
||
1019 | } |
||
1020 | if ($h == 0) { |
||
1021 | $h = $w * $info['h'] / $info['w']; |
||
1022 | } |
||
1023 | // Flowing mode |
||
1024 | if ($y === null) { |
||
1025 | if ($this->y + $h > $this->pageBreakTrigger |
||
1026 | && !$this->inHeader |
||
1027 | && !$this->infooter |
||
0 ignored issues
–
show
The property
infooter does not seem to exist. Did you mean inFooter ?
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name. If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.
Loading history...
|
|||
1028 | && $this->acceptPageBreak() |
||
1029 | ) { |
||
1030 | // Automatic page break |
||
1031 | $x2 = $this->x; |
||
1032 | $this->addPage( |
||
1033 | $this->curOrientation, |
||
1034 | $this->curPageSize, |
||
1035 | $this->curRotation |
||
0 ignored issues
–
show
The call to
Fpdf::addPage() has too many arguments starting with $this->curRotation .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the
Loading history...
|
|||
1036 | ); |
||
1037 | $this->x = $x2; |
||
1038 | } |
||
1039 | $y = $this->y; |
||
1040 | $this->y += $h; |
||
1041 | } |
||
1042 | if ($x === null) { |
||
1043 | $x = $this->x; |
||
1044 | } |
||
1045 | $this->out( |
||
1046 | sprintf( |
||
1047 | 'q %.2F 0 0 %.2F %.2F %.2F cm /I%d Do Q', |
||
1048 | $w * $this->k, |
||
1049 | $h * $this->k, |
||
1050 | $x * $this->k, |
||
1051 | ($this->h - ($y + $h)) * $this->k, |
||
1052 | $info['i'] |
||
1053 | ) |
||
1054 | ); |
||
1055 | if ($link) { |
||
1056 | $this->link($x, $y, $w, $h, $link); |
||
1057 | } |
||
1058 | } |
||
1059 | |||
1060 | public function getPageWidth() |
||
1061 | { |
||
1062 | // Get current page width |
||
1063 | return $this->w; |
||
1064 | } |
||
1065 | |||
1066 | public function getPageHeight() |
||
1067 | { |
||
1068 | // Get current page height |
||
1069 | return $this->h; |
||
1070 | } |
||
1071 | |||
1072 | public function getX() |
||
1073 | { |
||
1074 | // Get x position |
||
1075 | return $this->x; |
||
1076 | } |
||
1077 | |||
1078 | public function setX($x) |
||
1079 | { |
||
1080 | // Set x position |
||
1081 | if ($x >= 0) { |
||
1082 | $this->x = $x; |
||
1083 | } else { |
||
1084 | $this->x = $this->w + $x; |
||
1085 | } |
||
1086 | } |
||
1087 | |||
1088 | public function getY() |
||
1089 | { |
||
1090 | // Get y position |
||
1091 | return $this->y; |
||
1092 | } |
||
1093 | |||
1094 | public function setY($y, $resetX = true) |
||
1095 | { |
||
1096 | // Set y position and optionally reset x |
||
1097 | if ($y >= 0) { |
||
1098 | $this->y = $y; |
||
1099 | } else { |
||
1100 | $this->y = $this->h + $y; |
||
1101 | } |
||
1102 | if ($resetX) { |
||
1103 | $this->x = $this->lMargin; |
||
1104 | } |
||
1105 | } |
||
1106 | |||
1107 | public function setXY($x, $y) |
||
1108 | { |
||
1109 | // Set x and y positions |
||
1110 | $this->setX($x); |
||
1111 | $this->setY($y, false); |
||
0 ignored issues
–
show
The call to
Fpdf::setY() has too many arguments starting with false .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the
Loading history...
|
|||
1112 | } |
||
1113 | |||
1114 | public function output($dest = '', $name = '', $isUTF8 = false) |
||
1115 | { |
||
1116 | // output PDF to some destination |
||
1117 | $this->close(); |
||
1118 | if (strlen($name) == 1 && strlen($dest) != 1) { |
||
1119 | // Fix parameter order |
||
1120 | $tmp = $dest; |
||
1121 | $dest = $name; |
||
1122 | $name = $tmp; |
||
1123 | } |
||
1124 | if ($dest == '') { |
||
1125 | $dest = 'I'; |
||
1126 | } |
||
1127 | if ($name == '') { |
||
1128 | $name = 'doc.pdf'; |
||
1129 | } |
||
1130 | switch (strtoupper($dest)) { |
||
1131 | case 'I': |
||
1132 | // Send to standard output |
||
1133 | $this->checkOutput(); |
||
0 ignored issues
–
show
The method
checkOutput() does not exist on NFePHP\DA\Legacy\FPDF\Fpdf . Did you maybe mean output() ?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise.
Loading history...
|
|||
1134 | if (PHP_SAPI != 'cli') { |
||
1135 | // We send to a browser |
||
1136 | header('Content-Type: application/pdf'); |
||
1137 | header('Content-Disposition: inline; ' |
||
1138 | . $this->httpencode('filename', $name, $isUTF8)); |
||
0 ignored issues
–
show
The method
httpencode() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1139 | header('Cache-Control: private, max-age=0, must-revalidate'); |
||
1140 | header('Pragma: public'); |
||
1141 | } |
||
1142 | echo $this->buffer; |
||
1143 | break; |
||
1144 | case 'D': |
||
1145 | // Download file |
||
1146 | $this->checkOutput(); |
||
0 ignored issues
–
show
The method
checkOutput() does not exist on NFePHP\DA\Legacy\FPDF\Fpdf . Did you maybe mean output() ?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise.
Loading history...
|
|||
1147 | header('Content-Type: application/x-download'); |
||
1148 | header('Content-Disposition: attachment; ' |
||
1149 | . $this->httpencode('filename', $name, $isUTF8)); |
||
0 ignored issues
–
show
The method
httpencode() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1150 | header('Cache-Control: private, max-age=0, must-revalidate'); |
||
1151 | header('Pragma: public'); |
||
1152 | echo $this->buffer; |
||
1153 | break; |
||
1154 | case 'F': |
||
1155 | // Save to local file |
||
1156 | if (!fileput_contents($name, $this->buffer)) { |
||
1157 | $this->error('Unable to create output file: ' . $name); |
||
1158 | } |
||
1159 | break; |
||
1160 | case 'S': |
||
1161 | // Return as a string |
||
1162 | return $this->buffer; |
||
1163 | default: |
||
1164 | $this->error('Incorrect output destination: ' . $dest); |
||
1165 | } |
||
1166 | return ''; |
||
1167 | } |
||
1168 | |||
1169 | |||
1170 | protected function doChecks() |
||
1171 | { |
||
1172 | // Check mbstring overloading |
||
1173 | if (ini_get('mbstring.func_overload') & 2) { |
||
1174 | $this->error('mbstring overloading must be disabled'); |
||
1175 | } |
||
1176 | } |
||
1177 | |||
1178 | protected function checkOutput() |
||
1179 | { |
||
1180 | if (PHP_SAPI != 'cli') { |
||
1181 | if (headers_sent($file, $line)) { |
||
1182 | $this->error( |
||
1183 | "Some data has already been output, can't send PDF file " |
||
1184 | . "(output started at $file:$line)" |
||
1185 | ); |
||
1186 | } |
||
1187 | } |
||
1188 | if (ob_get_length()) { |
||
1189 | // The output buffer is not empty |
||
1190 | if (preg_match('/^(\xEF\xBB\xBF)?\s*$/', ob_get_contents())) { |
||
1191 | // It contains only a UTF-8 BOM and/or whitespace, let's clean it |
||
1192 | ob_clean(); |
||
1193 | } else { |
||
1194 | $this->error("Some data has already been output, can't send PDF file"); |
||
1195 | } |
||
1196 | } |
||
1197 | } |
||
1198 | |||
1199 | protected function getPageSize($size) |
||
1200 | { |
||
1201 | if (is_string($size)) { |
||
1202 | $size = strtolower($size); |
||
1203 | if (!isset($this->stdPageSizes[$size])) { |
||
0 ignored issues
–
show
The property
stdPageSizes does not seem to exist. Did you mean pageSizes ?
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name. If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.
Loading history...
|
|||
1204 | $this->error('Unknown page size: ' . $size); |
||
1205 | } |
||
1206 | $a = $this->stdPageSizes[$size]; |
||
0 ignored issues
–
show
The property
stdPageSizes does not seem to exist. Did you mean pageSizes ?
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name. If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.
Loading history...
|
|||
1207 | return [$a[0] / $this->k, $a[1] / $this->k]; |
||
1208 | } else { |
||
1209 | if ($size[0] > $size[1]) { |
||
1210 | return [$size[1], $size[0]]; |
||
1211 | } else { |
||
1212 | return $size; |
||
1213 | } |
||
1214 | } |
||
1215 | } |
||
1216 | |||
1217 | protected function beginPage($orientation, $size, $rotation) |
||
1218 | { |
||
1219 | $this->page++; |
||
1220 | $this->pages[$this->page] = ''; |
||
1221 | $this->state = 2; |
||
1222 | $this->x = $this->lMargin; |
||
1223 | $this->y = $this->tMargin; |
||
1224 | $this->fontFamily = ''; |
||
1225 | // Check page size and orientation |
||
1226 | if ($orientation == '') { |
||
1227 | $orientation = $this->defOrientation; |
||
1228 | } else { |
||
1229 | $orientation = strtoupper($orientation[0]); |
||
1230 | } |
||
1231 | if ($size == '') { |
||
1232 | $size = $this->defPageSize; |
||
1233 | } else { |
||
1234 | $size = $this->getPageSize($size); |
||
0 ignored issues
–
show
The method
getPageSize() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1235 | } |
||
1236 | if ($orientation != $this->curOrientation |
||
1237 | || $size[0] != $this->curPageSize[0] |
||
1238 | || $size[1] != $this->curPageSize[1] |
||
1239 | ) { |
||
1240 | // New size or orientation |
||
1241 | if ($orientation == 'P') { |
||
1242 | $this->w = $size[0]; |
||
1243 | $this->h = $size[1]; |
||
1244 | } else { |
||
1245 | $this->w = $size[1]; |
||
1246 | $this->h = $size[0]; |
||
1247 | } |
||
1248 | $this->wPt = $this->w * $this->k; |
||
1249 | $this->hPt = $this->h * $this->k; |
||
1250 | $this->pageBreakTrigger = $this->h - $this->bMargin; |
||
1251 | $this->curOrientation = $orientation; |
||
1252 | $this->curPageSize = $size; |
||
1253 | } |
||
1254 | if ($orientation != $this->defOrientation |
||
1255 | || $size[0] != $this->defPageSize[0] |
||
1256 | || $size[1] != $this->defPageSize[1] |
||
1257 | ) { |
||
1258 | $this->pageInfo[$this->page]['size'] = [$this->wPt, $this->hPt]; |
||
1259 | } |
||
1260 | if ($rotation != 0) { |
||
1261 | if ($rotation % 90 != 0) { |
||
1262 | $this->error('Incorrect rotation value: ' . $rotation); |
||
1263 | } |
||
1264 | $this->curRotation = $rotation; |
||
1265 | $this->pageInfo[$this->page]['rotation'] = $rotation; |
||
1266 | } |
||
1267 | } |
||
1268 | |||
1269 | protected function endPage() |
||
1270 | { |
||
1271 | $this->state = 1; |
||
1272 | } |
||
1273 | |||
1274 | protected function loadFont($font) |
||
1275 | { |
||
1276 | // Load a font definition file from the font directory |
||
1277 | if (strpos($font, '/') !== false || strpos($font, "\\") !== false) { |
||
1278 | $this->error('Incorrect font definition file name: ' . $font); |
||
1279 | } |
||
1280 | include($this->fontpath . $font); |
||
1281 | if (!isset($name)) { |
||
0 ignored issues
–
show
The variable
$name seems to never exist, and therefore isset should always return false . Did you maybe rename this variable?
This check looks for calls to This is most likely caused by the renaming of a variable or the removal of a function/method parameter.
Loading history...
|
|||
1282 | $this->error('Could not include font definition file'); |
||
1283 | } |
||
1284 | if (isset($enc)) { |
||
0 ignored issues
–
show
The variable
$enc seems only to be defined at a later point. As such the call to isset() seems to always evaluate to false .
This check marks calls to This is likely the result of code being shifted around. Consider removing these calls.
Loading history...
|
|||
1285 | $enc = strtolower($enc); |
||
1286 | } |
||
1287 | if (!isset($subsetted)) { |
||
0 ignored issues
–
show
The variable
$subsetted seems only to be defined at a later point. As such the call to isset() seems to always evaluate to false .
This check marks calls to This is likely the result of code being shifted around. Consider removing these calls.
Loading history...
|
|||
1288 | $subsetted = false; |
||
1289 | } |
||
1290 | return get_defined_vars(); |
||
1291 | } |
||
1292 | |||
1293 | protected function isAscii($s) |
||
1294 | { |
||
1295 | // Test if string is ASCII |
||
1296 | $nb = strlen($s); |
||
1297 | for ($i = 0; $i < $nb; $i++) { |
||
1298 | if (ord($s[$i]) > 127) { |
||
1299 | return false; |
||
1300 | } |
||
1301 | } |
||
1302 | return true; |
||
1303 | } |
||
1304 | |||
1305 | protected function httpencode($param, $value, $isUTF8) |
||
1306 | { |
||
1307 | // Encode HTTP header field parameter |
||
1308 | if ($this->isAscii($value)) { |
||
0 ignored issues
–
show
The method
isAscii() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1309 | return $param . '="' . $value . '"'; |
||
1310 | } |
||
1311 | if (!$isUTF8) { |
||
1312 | $value = utf8_encode($value); |
||
1313 | } |
||
1314 | if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) { |
||
1315 | return $param . '="' . rawurlencode($value) . '"'; |
||
1316 | } else { |
||
1317 | return $param . "*=UTF-8''" . rawurlencode($value); |
||
1318 | } |
||
1319 | } |
||
1320 | |||
1321 | protected function utf8ToUtf16($s) |
||
1322 | { |
||
1323 | // Convert UTF-8 to UTF-16BE with BOM |
||
1324 | $res = "\xFE\xFF"; |
||
1325 | $nb = strlen($s); |
||
1326 | $i = 0; |
||
1327 | while ($i < $nb) { |
||
1328 | $c1 = ord($s[$i++]); |
||
1329 | if ($c1 >= 224) { |
||
1330 | // 3-byte character |
||
1331 | $c2 = ord($s[$i++]); |
||
1332 | $c3 = ord($s[$i++]); |
||
1333 | $res .= chr((($c1 & 0x0F) << 4) + (($c2 & 0x3C) >> 2)); |
||
1334 | $res .= chr((($c2 & 0x03) << 6) + ($c3 & 0x3F)); |
||
1335 | } elseif ($c1 >= 192) { |
||
1336 | // 2-byte character |
||
1337 | $c2 = ord($s[$i++]); |
||
1338 | $res .= chr(($c1 & 0x1C) >> 2); |
||
1339 | $res .= chr((($c1 & 0x03) << 6) + ($c2 & 0x3F)); |
||
1340 | } else { |
||
1341 | // Single-byte character |
||
1342 | $res .= "\0" . chr($c1); |
||
1343 | } |
||
1344 | } |
||
1345 | return $res; |
||
1346 | } |
||
1347 | |||
1348 | protected function escape($s) |
||
1349 | { |
||
1350 | // Escape special characters |
||
1351 | if (strpos($s, '(') !== false |
||
1352 | || strpos($s, ')') !== false |
||
1353 | || strpos($s, '\\') !== false |
||
1354 | || strpos($s, "\r") !== false |
||
1355 | ) { |
||
1356 | return str_replace( |
||
1357 | ['\\', '(', ')', "\r"], |
||
1358 | ['\\\\', '\\(', '\\)', '\\r'], |
||
1359 | $s |
||
1360 | ); |
||
1361 | } else { |
||
1362 | return $s; |
||
1363 | } |
||
1364 | } |
||
1365 | |||
1366 | protected function textString($s) |
||
1367 | { |
||
1368 | // Format a text string |
||
1369 | if (!$this->isAscii($s)) { |
||
0 ignored issues
–
show
The method
isAscii() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1370 | $s = $this->utf8ToUtf16($s); |
||
1371 | } |
||
1372 | return '(' . $this->escape($s) . ')'; |
||
1373 | } |
||
1374 | |||
1375 | protected function doUnderLine($x, $y, $txt) |
||
1376 | { |
||
1377 | // Underline text |
||
1378 | $up = $this->currentFont['up']; |
||
1379 | $ut = $this->currentFont['ut']; |
||
1380 | $w = $this->getStringWidth($txt) + $this->ws * substr_count($txt, ' '); |
||
1381 | return sprintf( |
||
1382 | '%.2F %.2F %.2F %.2F re f', |
||
1383 | $x * $this->k, |
||
1384 | ($this->h - ($y - $up / 1000 * $this->fontSize)) * $this->k, |
||
1385 | $w * $this->k, |
||
1386 | -$ut / 1000 * $this->fontSizePt |
||
1387 | ); |
||
1388 | } |
||
1389 | |||
1390 | protected function parseJpg($file) |
||
1391 | { |
||
1392 | // Extract info from a JPEG file |
||
1393 | $a = getimagesize($file); |
||
1394 | if (!$a) { |
||
0 ignored issues
–
show
The expression
$a of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using
Loading history...
|
|||
1395 | $this->error('Missing or incorrect image file: ' . $file); |
||
1396 | } |
||
1397 | if ($a[2] != 2) { |
||
1398 | $this->error('Not a JPEG file: ' . $file); |
||
1399 | } |
||
1400 | if (!isset($a['channels']) || $a['channels'] == 3) { |
||
1401 | $colspace = 'DeviceRGB'; |
||
1402 | } elseif ($a['channels'] == 4) { |
||
1403 | $colspace = 'DeviceCMYK'; |
||
1404 | } else { |
||
1405 | $colspace = 'DeviceGray'; |
||
1406 | } |
||
1407 | $bpc = isset($a['bits']) ? $a['bits'] : 8; |
||
1408 | $data = file_get_contents($file); |
||
1409 | return [ |
||
1410 | 'w' => $a[0], |
||
1411 | 'h' => $a[1], |
||
1412 | 'cs' => $colspace, |
||
1413 | 'bpc' => $bpc, |
||
1414 | 'f' => 'DCTDecode', |
||
1415 | 'data' => $data |
||
1416 | ]; |
||
1417 | } |
||
1418 | |||
1419 | protected function parsePng($file) |
||
1420 | { |
||
1421 | // Extract info from a PNG file |
||
1422 | $f = fopen($file, 'rb'); |
||
1423 | if (!$f) { |
||
1424 | $this->error('Can\'t open image file: ' . $file); |
||
1425 | } |
||
1426 | $info = $this->parsePngstream($f, $file); |
||
0 ignored issues
–
show
The method
parsePngstream() does not exist on NFePHP\DA\Legacy\FPDF\Fpdf . Did you maybe mean parsePNG() ?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise.
Loading history...
|
|||
1427 | fclose($f); |
||
1428 | return $info; |
||
1429 | } |
||
1430 | |||
1431 | protected function parsePngstream($f, $file) |
||
1432 | { |
||
1433 | // Check signature |
||
1434 | if ($this->readStream($f, 8) != chr(137) . 'PNG' |
||
1435 | . chr(13) . chr(10) . chr(26) . chr(10) |
||
1436 | ) { |
||
1437 | $this->error('Not a PNG file: ' . $file); |
||
1438 | } |
||
1439 | // Read header chunk |
||
1440 | $this->readStream($f, 4); |
||
1441 | if ($this->readStream($f, 4) != 'IHDR') { |
||
1442 | $this->error('Incorrect PNG file: ' . $file); |
||
1443 | } |
||
1444 | $w = $this->readInt($f); |
||
1445 | $h = $this->readInt($f); |
||
1446 | $bpc = ord($this->readStream($f, 1)); |
||
1447 | if ($bpc > 8) { |
||
1448 | $this->error('16-bit depth not supported: ' . $file); |
||
1449 | } |
||
1450 | $ct = ord($this->readStream($f, 1)); |
||
1451 | if ($ct == 0 || $ct == 4) { |
||
1452 | $colspace = 'DeviceGray'; |
||
1453 | } elseif ($ct == 2 || $ct == 6) { |
||
1454 | $colspace = 'DeviceRGB'; |
||
1455 | } elseif ($ct == 3) { |
||
1456 | $colspace = 'Indexed'; |
||
1457 | } else { |
||
1458 | $this->error('Unknown color type: ' . $file); |
||
1459 | } |
||
1460 | if (ord($this->readStream($f, 1)) != 0) { |
||
1461 | $this->error('Unknown compression method: ' . $file); |
||
1462 | } |
||
1463 | if (ord($this->readStream($f, 1)) != 0) { |
||
1464 | $this->error('Unknown filter method: ' . $file); |
||
1465 | } |
||
1466 | if (ord($this->readStream($f, 1)) != 0) { |
||
1467 | $this->error('Interlacing not supported: ' . $file); |
||
1468 | } |
||
1469 | $this->readStream($f, 4); |
||
1470 | $dp = '/Predictor 15 /Colors ' |
||
1471 | . ($colspace == 'DeviceRGB' ? 3 : 1) |
||
0 ignored issues
–
show
The variable
$colspace does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
Loading history...
|
|||
1472 | . ' /BitsPerComponent ' |
||
1473 | . $bpc |
||
1474 | . ' /Columns ' |
||
1475 | . $w; |
||
1476 | // Scan chunks looking for palette, transparency and image data |
||
1477 | $pal = ''; |
||
1478 | $trns = ''; |
||
1479 | $data = ''; |
||
1480 | do { |
||
1481 | $n = $this->readInt($f); |
||
1482 | $type = $this->readStream($f, 4); |
||
1483 | if ($type == 'PLTE') { |
||
1484 | // Read palette |
||
1485 | $pal = $this->readStream($f, $n); |
||
1486 | $this->readStream($f, 4); |
||
1487 | } elseif ($type == 'tRNS') { |
||
1488 | // Read transparency info |
||
1489 | $t = $this->readStream($f, $n); |
||
1490 | if ($ct == 0) { |
||
1491 | $trns = [ord(substr($t, 1, 1))]; |
||
1492 | } elseif ($ct == 2) { |
||
1493 | $trns = [ |
||
1494 | ord(substr($t, 1, 1)), |
||
1495 | ord(substr($t, 3, 1)), |
||
1496 | ord(substr($t, 5, 1)) |
||
1497 | ]; |
||
1498 | } else { |
||
1499 | $pos = strpos($t, chr(0)); |
||
1500 | if ($pos !== false) { |
||
1501 | $trns = [$pos]; |
||
1502 | } |
||
1503 | } |
||
1504 | $this->readStream($f, 4); |
||
1505 | } elseif ($type == 'IDAT') { |
||
1506 | // Read image data block |
||
1507 | $data .= $this->readStream($f, $n); |
||
1508 | $this->readStream($f, 4); |
||
1509 | } elseif ($type == 'IEND') { |
||
1510 | break; |
||
1511 | } else { |
||
1512 | $this->readStream($f, $n + 4); |
||
1513 | } |
||
1514 | } while ($n); |
||
1515 | if ($colspace == 'Indexed' && empty($pal)) { |
||
1516 | $this->error('Missing palette in ' . $file); |
||
1517 | } |
||
1518 | $info = [ |
||
1519 | 'w' => $w, |
||
1520 | 'h' => $h, |
||
1521 | 'cs' => $colspace, |
||
1522 | 'bpc' => $bpc, |
||
1523 | 'f' => 'FlateDecode', |
||
1524 | 'dp' => $dp, |
||
1525 | 'pal' => $pal, |
||
1526 | 'trns' => $trns |
||
1527 | ]; |
||
1528 | if ($ct >= 4) { |
||
1529 | // Extract alpha channel |
||
1530 | if (!function_exists('gzuncompress')) { |
||
1531 | $this->error('Zlib not available, can\'t handle alpha channel: ' |
||
1532 | . $file); |
||
1533 | } |
||
1534 | $data = gzuncompress($data); |
||
1535 | $color = ''; |
||
1536 | $alpha = ''; |
||
1537 | if ($ct == 4) { |
||
1538 | // Gray image |
||
1539 | $len = 2 * $w; |
||
1540 | for ($i = 0; $i < $h; $i++) { |
||
1541 | $pos = (1 + $len) * $i; |
||
1542 | $color .= $data[$pos]; |
||
1543 | $alpha .= $data[$pos]; |
||
1544 | $line = substr($data, $pos + 1, $len); |
||
1545 | $color .= preg_replace('/(.)./s', '$1', $line); |
||
1546 | $alpha .= preg_replace('/.(.)/s', '$1', $line); |
||
1547 | } |
||
1548 | } else { |
||
1549 | // RGB image |
||
1550 | $len = 4 * $w; |
||
1551 | for ($i = 0; $i < $h; $i++) { |
||
1552 | $pos = (1 + $len) * $i; |
||
1553 | $color .= $data[$pos]; |
||
1554 | $alpha .= $data[$pos]; |
||
1555 | $line = substr($data, $pos + 1, $len); |
||
1556 | $color .= preg_replace('/(.{3})./s', '$1', $line); |
||
1557 | $alpha .= preg_replace('/.{3}(.)/s', '$1', $line); |
||
1558 | } |
||
1559 | } |
||
1560 | unset($data); |
||
1561 | $data = gzcompress($color); |
||
1562 | $info['smask'] = gzcompress($alpha); |
||
1563 | $this->withAlpha = true; |
||
1564 | if ($this->pdfVersion < '1.4') { |
||
1565 | $this->pdfVersion = '1.4'; |
||
1566 | } |
||
1567 | } |
||
1568 | $info['data'] = $data; |
||
1569 | return $info; |
||
1570 | } |
||
1571 | |||
1572 | protected function readStream($f, $n) |
||
1573 | { |
||
1574 | // Read n bytes from stream |
||
1575 | $res = ''; |
||
1576 | while ($n > 0 && !feof($f)) { |
||
1577 | $s = fread($f, $n); |
||
1578 | if ($s === false) { |
||
1579 | $this->error('Error while reading stream'); |
||
1580 | } |
||
1581 | $n -= strlen($s); |
||
1582 | $res .= $s; |
||
1583 | } |
||
1584 | if ($n > 0) { |
||
1585 | $this->error('Unexpected end of stream'); |
||
1586 | } |
||
1587 | return $res; |
||
1588 | } |
||
1589 | |||
1590 | protected function readInt($f) |
||
1591 | { |
||
1592 | // Read a 4-byte integer from stream |
||
1593 | $a = unpack('Ni', $this->readStream($f, 4)); |
||
1594 | return $a['i']; |
||
1595 | } |
||
1596 | |||
1597 | protected function parseGif($file) |
||
1598 | { |
||
1599 | // Extract info from a GIF file (via PNG conversion) |
||
1600 | if (!function_exists('imagepng')) { |
||
1601 | $this->error('GD extension is required for GIF support'); |
||
1602 | } |
||
1603 | if (!function_exists('imagecreatefromgif')) { |
||
1604 | $this->error('GD has no GIF read support'); |
||
1605 | } |
||
1606 | $im = imagecreatefromgif($file); |
||
1607 | if (!$im) { |
||
1608 | $this->error('Missing or incorrect image file: ' . $file); |
||
1609 | } |
||
1610 | imageinterlace($im, 0); |
||
1611 | ob_start(); |
||
1612 | imagepng($im); |
||
1613 | $data = ob_get_clean(); |
||
1614 | imagedestroy($im); |
||
1615 | $f = fopen('php://temp', 'rb+'); |
||
1616 | if (!$f) { |
||
1617 | $this->error('Unable to create memory stream'); |
||
1618 | } |
||
1619 | fwrite($f, $data); |
||
1620 | rewind($f); |
||
1621 | $info = $this->parsePngstream($f, $file); |
||
0 ignored issues
–
show
The method
parsePngstream() does not exist on NFePHP\DA\Legacy\FPDF\Fpdf . Did you maybe mean parsePNG() ?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise.
Loading history...
|
|||
1622 | fclose($f); |
||
1623 | return $info; |
||
1624 | } |
||
1625 | |||
1626 | protected function out($s) |
||
1627 | { |
||
1628 | // Add a line to the document |
||
1629 | if ($this->state == 2) { |
||
1630 | $this->pages[$this->page] .= $s . "\n"; |
||
1631 | } elseif ($this->state == 1) { |
||
1632 | $this->put($s); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1633 | } elseif ($this->state == 0) { |
||
1634 | $this->error('No page has been added yet'); |
||
1635 | } elseif ($this->state == 3) { |
||
1636 | $this->error('The document is closed'); |
||
1637 | } |
||
1638 | } |
||
1639 | |||
1640 | protected function put($s) |
||
1641 | { |
||
1642 | $this->buffer .= $s . "\n"; |
||
1643 | } |
||
1644 | |||
1645 | protected function getOffset() |
||
1646 | { |
||
1647 | return strlen($this->buffer); |
||
1648 | } |
||
1649 | |||
1650 | protected function newObj($n = null) |
||
1651 | { |
||
1652 | // Begin a new object |
||
1653 | if ($n === null) { |
||
1654 | $n = ++$this->n; |
||
1655 | } |
||
1656 | $this->offsets[$n] = $this->getOffset(); |
||
0 ignored issues
–
show
The method
getOffset() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1657 | $this->put($n . ' 0 obj'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1658 | } |
||
1659 | |||
1660 | protected function putStream($data) |
||
1661 | { |
||
1662 | $this->put('stream'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1663 | $this->put($data); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1664 | $this->put('endstream'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1665 | } |
||
1666 | |||
1667 | protected function putStreamobject($data) |
||
1668 | { |
||
1669 | if ($this->compress) { |
||
1670 | $entries = '/Filter /FlateDecode '; |
||
1671 | $data = gzcompress($data); |
||
1672 | } else { |
||
1673 | $entries = ''; |
||
1674 | } |
||
1675 | $entries .= '/Length ' . strlen($data); |
||
1676 | $this->newObj(); |
||
1677 | $this->put('<<' . $entries . '>>'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1678 | $this->putStream($data); |
||
1679 | $this->put('endobj'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1680 | } |
||
1681 | |||
1682 | protected function putpage($n) |
||
1683 | { |
||
1684 | $this->newObj(); |
||
1685 | $this->put('<</Type /Page'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1686 | $this->put('/Parent 1 0 R'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1687 | if (isset($this->pageInfo[$n]['size'])) { |
||
1688 | $this->put( |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1689 | sprintf( |
||
1690 | '/MediaBox [0 0 %.2F %.2F]', |
||
1691 | $this->pageInfo[$n]['size'][0], |
||
1692 | $this->pageInfo[$n]['size'][1] |
||
1693 | ) |
||
1694 | ); |
||
1695 | } |
||
1696 | if (isset($this->pageInfo[$n]['rotation'])) { |
||
1697 | $this->put('/Rotate ' . $this->pageInfo[$n]['rotation']); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1698 | } |
||
1699 | $this->put('/Resources 2 0 R'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1700 | if (isset($this->pageLinks[$n])) { |
||
0 ignored issues
–
show
The property
pageLinks does not seem to exist. Did you mean PageLinks ?
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name. If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.
Loading history...
|
|||
1701 | // Links |
||
1702 | $annots = '/Annots ['; |
||
1703 | foreach ($this->pageLinks[$n] as $pl) { |
||
0 ignored issues
–
show
The property
pageLinks does not seem to exist. Did you mean PageLinks ?
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name. If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.
Loading history...
|
|||
1704 | $rect = sprintf( |
||
1705 | '%.2F %.2F %.2F %.2F', |
||
1706 | $pl[0], |
||
1707 | $pl[1], |
||
1708 | $pl[0] + $pl[2], |
||
1709 | $pl[1] - $pl[3] |
||
1710 | ); |
||
1711 | $annots .= '<</Type /Annot /Subtype /Link /Rect [' |
||
1712 | . $rect . '] /Border [0 0 0] '; |
||
1713 | if (is_string($pl[4])) { |
||
1714 | $annots .= '/A <</S /URI /URI ' |
||
1715 | . $this->textString($pl[4]) . '>>>>'; |
||
1716 | } else { |
||
1717 | $l = $this->links[$pl[4]]; |
||
1718 | if (isset($this->pageInfo[$l[0]]['size'])) { |
||
1719 | $h = $this->pageInfo[$l[0]]['size'][1]; |
||
1720 | } else { |
||
1721 | $h = ($this->defOrientation == 'P') |
||
1722 | ? $this->defPageSize[1] * $this->k |
||
1723 | : $this->defPageSize[0] * $this->k; |
||
1724 | } |
||
1725 | $annots .= sprintf( |
||
1726 | '/Dest [%d 0 R /XYZ 0 %.2F null]>>', |
||
1727 | $this->pageInfo[$l[0]]['n'], |
||
1728 | $h - $l[1] * $this->k |
||
1729 | ); |
||
1730 | } |
||
1731 | } |
||
1732 | $this->put($annots . ']'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1733 | } |
||
1734 | if ($this->withAlpha) { |
||
1735 | $this->put('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1736 | } |
||
1737 | $this->put('/Contents ' . ($this->n + 1) . ' 0 R>>'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1738 | $this->put('endobj'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1739 | // Page content |
||
1740 | if (!empty($this->aliasNbPages)) { |
||
1741 | $this->pages[$n] = str_replace( |
||
1742 | $this->aliasNbPages, |
||
1743 | $this->page, |
||
1744 | $this->pages[$n] |
||
1745 | ); |
||
1746 | } |
||
1747 | $this->putStreamobject($this->pages[$n]); |
||
0 ignored issues
–
show
The method
putStreamobject() does not exist on NFePHP\DA\Legacy\FPDF\Fpdf . Did you maybe mean putStream() ?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise.
Loading history...
|
|||
1748 | } |
||
1749 | |||
1750 | protected function putPages() |
||
1751 | { |
||
1752 | $nb = $this->page; |
||
1753 | for ($n = 1; $n <= $nb; $n++) { |
||
1754 | $this->pageInfo[$n]['n'] = $this->n + 1 + 2 * ($n - 1); |
||
1755 | } |
||
1756 | for ($n = 1; $n <= $nb; $n++) { |
||
1757 | $this->putpage($n); |
||
0 ignored issues
–
show
The method
putpage() does not exist on NFePHP\DA\Legacy\FPDF\Fpdf . Did you maybe mean putPages() ?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise.
Loading history...
|
|||
1758 | } |
||
1759 | // Pages root |
||
1760 | $this->newObj(1); |
||
0 ignored issues
–
show
The call to
Fpdf::newObj() has too many arguments starting with 1 .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the
Loading history...
|
|||
1761 | $this->put('<</Type /Pages'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1762 | $kids = '/Kids ['; |
||
1763 | for ($n = 1; $n <= $nb; $n++) { |
||
1764 | $kids .= $this->pageInfo[$n]['n'] . ' 0 R '; |
||
1765 | } |
||
1766 | $this->put($kids . ']'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1767 | $this->put('/Count ' . $nb); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1768 | if ($this->defOrientation == 'P') { |
||
1769 | $w = $this->defPageSize[0]; |
||
1770 | $h = $this->defPageSize[1]; |
||
1771 | } else { |
||
1772 | $w = $this->defPageSize[1]; |
||
1773 | $h = $this->defPageSize[0]; |
||
1774 | } |
||
1775 | $this->put( |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1776 | sprintf( |
||
1777 | '/MediaBox [0 0 %.2F %.2F]', |
||
1778 | $w * $this->k, |
||
1779 | $h * $this->k |
||
1780 | ) |
||
1781 | ); |
||
1782 | $this->put('>>'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1783 | $this->put('endobj'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1784 | } |
||
1785 | |||
1786 | protected function putFonts() |
||
1787 | { |
||
1788 | foreach ($this->fontFiles as $file => $info) { |
||
1789 | // Font file embedding |
||
1790 | $this->newObj(); |
||
1791 | $this->fontFiles[$file]['n'] = $this->n; |
||
1792 | $font = file_get_contents($this->fontpath . $file, true); |
||
1793 | if (!$font) { |
||
1794 | $this->error('Font file not found: ' . $file); |
||
1795 | } |
||
1796 | $compressed = (substr($file, -2) == '.z'); |
||
1797 | if (!$compressed && isset($info['length2'])) { |
||
1798 | $font = substr($font, 6, $info['length1']) |
||
1799 | . substr($font, 6 + $info['length1'] + 6, $info['length2']); |
||
1800 | } |
||
1801 | $this->put('<</Length ' . strlen($font)); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1802 | if ($compressed) { |
||
1803 | $this->put('/Filter /FlateDecode'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1804 | } |
||
1805 | $this->put('/Length1 ' . $info['length1']); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1806 | if (isset($info['length2'])) { |
||
1807 | $this->put('/Length2 ' . $info['length2'] . ' /Length3 0'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1808 | } |
||
1809 | $this->put('>>'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1810 | $this->putStream($font); |
||
1811 | $this->put('endobj'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1812 | } |
||
1813 | foreach ($this->fonts as $k => $font) { |
||
1814 | // Encoding |
||
1815 | if (isset($font['diff'])) { |
||
1816 | if (!isset($this->encodings[$font['enc']])) { |
||
1817 | $this->newObj(); |
||
1818 | $this->put('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences [' |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1819 | . $font['diff'] . ']>>'); |
||
1820 | $this->put('endobj'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1821 | $this->encodings[$font['enc']] = $this->n; |
||
1822 | } |
||
1823 | } |
||
1824 | // ToUnicode CMap |
||
1825 | if (isset($font['uv'])) { |
||
1826 | if (isset($font['enc'])) { |
||
1827 | $cmapkey = $font['enc']; |
||
1828 | } else { |
||
1829 | $cmapkey = $font['name']; |
||
1830 | } |
||
1831 | if (!isset($this->cmaps[$cmapkey])) { |
||
1832 | $cmap = $this->toUnicodeCmap($font['uv']); |
||
0 ignored issues
–
show
The method
toUnicodeCmap() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1833 | $this->putStreamobject($cmap); |
||
0 ignored issues
–
show
The method
putStreamobject() does not exist on NFePHP\DA\Legacy\FPDF\Fpdf . Did you maybe mean putStream() ?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise.
Loading history...
|
|||
1834 | $this->cmaps[$cmapkey] = $this->n; |
||
1835 | } |
||
1836 | } |
||
1837 | // Font object |
||
1838 | $this->fonts[$k]['n'] = $this->n + 1; |
||
1839 | $type = $font['type']; |
||
1840 | $name = $font['name']; |
||
1841 | if ($font['subsetted']) { |
||
1842 | $name = 'AAAAAA+' . $name; |
||
1843 | } |
||
1844 | if ($type == 'Core') { |
||
1845 | // Core font |
||
1846 | $this->newObj(); |
||
1847 | $this->put('<</Type /Font'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1848 | $this->put('/BaseFont /' . $name); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1849 | $this->put('/Subtype /Type1'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1850 | if ($name != 'Symbol' && $name != 'ZapfDingbats') { |
||
1851 | $this->put('/Encoding /WinAnsiEncoding'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1852 | } |
||
1853 | if (isset($font['uv'])) { |
||
1854 | $this->put('/ToUnicode ' . $this->cmaps[$cmapkey] . ' 0 R'); |
||
0 ignored issues
–
show
The variable
$cmapkey does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
Loading history...
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1855 | } |
||
1856 | $this->put('>>'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1857 | $this->put('endobj'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1858 | } elseif ($type == 'Type1' || $type == 'TrueType') { |
||
1859 | // Additional Type1 or TrueType/OpenType font |
||
1860 | $this->newObj(); |
||
1861 | $this->put('<</Type /Font'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1862 | $this->put('/BaseFont /' . $name); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1863 | $this->put('/Subtype /' . $type); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1864 | $this->put('/FirstChar 32 /LastChar 255'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1865 | $this->put('/Widths ' . ($this->n + 1) . ' 0 R'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1866 | $this->put('/FontDescriptor ' . ($this->n + 2) . ' 0 R'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1867 | if (isset($font['diff'])) { |
||
1868 | $this->put('/Encoding ' . $this->encodings[$font['enc']] . ' 0 R'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1869 | } else { |
||
1870 | $this->put('/Encoding /WinAnsiEncoding'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1871 | } |
||
1872 | if (isset($font['uv'])) { |
||
1873 | $this->put('/ToUnicode ' . $this->cmaps[$cmapkey] . ' 0 R'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1874 | } |
||
1875 | $this->put('>>'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1876 | $this->put('endobj'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1877 | // Widths |
||
1878 | $this->newObj(); |
||
1879 | $cw = &$font['cw']; |
||
1880 | $s = '['; |
||
1881 | for ($i = 32; $i <= 255; $i++) { |
||
1882 | $s .= $cw[chr($i)] . ' '; |
||
1883 | } |
||
1884 | $this->put($s . ']'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1885 | $this->put('endobj'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1886 | // Descriptor |
||
1887 | $this->newObj(); |
||
1888 | $s = '<</Type /FontDescriptor /FontName /' . $name; |
||
1889 | foreach ($font['desc'] as $k => $v) { |
||
1890 | $s .= ' /' . $k . ' ' . $v; |
||
1891 | } |
||
1892 | if (!empty($font['file'])) { |
||
1893 | $s .= ' /FontFile' . ($type == 'Type1' ? '' : '2') . ' ' |
||
1894 | . $this->fontFiles[$font['file']]['n'] . ' 0 R'; |
||
1895 | } |
||
1896 | $this->put($s . '>>'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1897 | $this->put('endobj'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1898 | } else { |
||
1899 | // Allow for additional types |
||
1900 | $mtd = 'put' . strtolower($type); |
||
1901 | if (!method_exists($this, $mtd)) { |
||
1902 | $this->error('Unsupported font type: ' . $type); |
||
1903 | } |
||
1904 | $this->$mtd($font); |
||
1905 | } |
||
1906 | } |
||
1907 | } |
||
1908 | |||
1909 | protected function toUnicodeCmap($uv) |
||
1910 | { |
||
1911 | $ranges = ''; |
||
1912 | $nbr = 0; |
||
1913 | $chars = ''; |
||
1914 | $nbc = 0; |
||
1915 | foreach ($uv as $c => $v) { |
||
1916 | if (is_array($v)) { |
||
1917 | $ranges .= sprintf( |
||
1918 | "<%02X> <%02X> <%04X>\n", |
||
1919 | $c, |
||
1920 | $c + $v[1] - 1, |
||
1921 | $v[0] |
||
1922 | ); |
||
1923 | $nbr++; |
||
1924 | } else { |
||
1925 | $chars .= sprintf("<%02X> <%04X>\n", $c, $v); |
||
1926 | $nbc++; |
||
1927 | } |
||
1928 | } |
||
1929 | $s = "/CIDInit /ProcSet findresource begin\n"; |
||
1930 | $s .= "12 dict begin\n"; |
||
1931 | $s .= "begincmap\n"; |
||
1932 | $s .= "/CIDSystemInfo\n"; |
||
1933 | $s .= "<</Registry (Adobe)\n"; |
||
1934 | $s .= "/Ordering (UCS)\n"; |
||
1935 | $s .= "/Supplement 0\n"; |
||
1936 | $s .= ">> def\n"; |
||
1937 | $s .= "/CMapName /Adobe-Identity-UCS def\n"; |
||
1938 | $s .= "/CMapType 2 def\n"; |
||
1939 | $s .= "1 begincodespacerange\n"; |
||
1940 | $s .= "<00> <FF>\n"; |
||
1941 | $s .= "endcodespacerange\n"; |
||
1942 | if ($nbr > 0) { |
||
1943 | $s .= "$nbr beginbfrange\n"; |
||
1944 | $s .= $ranges; |
||
1945 | $s .= "endbfrange\n"; |
||
1946 | } |
||
1947 | if ($nbc > 0) { |
||
1948 | $s .= "$nbc beginbfchar\n"; |
||
1949 | $s .= $chars; |
||
1950 | $s .= "endbfchar\n"; |
||
1951 | } |
||
1952 | $s .= "endcmap\n"; |
||
1953 | $s .= "CMapName currentdict /CMap defineresource pop\n"; |
||
1954 | $s .= "end\n"; |
||
1955 | $s .= "end"; |
||
1956 | return $s; |
||
1957 | } |
||
1958 | |||
1959 | protected function putImages() |
||
1960 | { |
||
1961 | foreach (array_keys($this->images) as $file) { |
||
1962 | $this->putImage($this->images[$file]); |
||
0 ignored issues
–
show
The method
putImage() does not exist on NFePHP\DA\Legacy\FPDF\Fpdf . Did you maybe mean putImages() ?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise.
Loading history...
|
|||
1963 | unset($this->images[$file]['data']); |
||
1964 | unset($this->images[$file]['smask']); |
||
1965 | } |
||
1966 | } |
||
1967 | |||
1968 | protected function putImage(&$info) |
||
1969 | { |
||
1970 | $this->newObj(); |
||
1971 | $info['n'] = $this->n; |
||
1972 | $this->put('<</Type /XObject'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1973 | $this->put('/Subtype /Image'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1974 | $this->put('/Width ' . $info['w']); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1975 | $this->put('/Height ' . $info['h']); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1976 | if ($info['cs'] == 'Indexed') { |
||
1977 | $this->put('/ColorSpace [/Indexed /DeviceRGB ' |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1978 | . (strlen($info['pal']) / 3 - 1) . ' ' . ($this->n + 1) . ' 0 R]'); |
||
1979 | } else { |
||
1980 | $this->put('/ColorSpace /' . $info['cs']); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1981 | if ($info['cs'] == 'DeviceCMYK') { |
||
1982 | $this->put('/Decode [1 0 1 0 1 0 1 0]'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1983 | } |
||
1984 | } |
||
1985 | $this->put('/BitsPerComponent ' . $info['bpc']); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1986 | if (isset($info['f'])) { |
||
1987 | $this->put('/Filter /' . $info['f']); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1988 | } |
||
1989 | if (isset($info['dp'])) { |
||
1990 | $this->put('/DecodeParms <<' . $info['dp'] . '>>'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1991 | } |
||
1992 | if (isset($info['trns']) && is_array($info['trns'])) { |
||
1993 | $trns = ''; |
||
1994 | for ($i = 0; $i < count($info['trns']); $i++) { |
||
0 ignored issues
–
show
It seems like you are calling the size function
count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.
If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration: for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}
// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
|
|||
1995 | $trns .= $info['trns'][$i] . ' ' . $info['trns'][$i] . ' '; |
||
1996 | } |
||
1997 | $this->put('/Mask [' . $trns . ']'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
1998 | } |
||
1999 | if (isset($info['smask'])) { |
||
2000 | $this->put('/SMask ' . ($this->n + 1) . ' 0 R'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2001 | } |
||
2002 | $this->put('/Length ' . strlen($info['data']) . '>>'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2003 | $this->putStream($info['data']); |
||
2004 | $this->put('endobj'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2005 | // Soft mask |
||
2006 | if (isset($info['smask'])) { |
||
2007 | $dp = '/Predictor 15 /Colors 1 /BitsPerComponent 8 /Columns ' . $info['w']; |
||
2008 | $smask = [ |
||
2009 | 'w' => $info['w'], |
||
2010 | 'h' => $info['h'], |
||
2011 | 'cs' => 'DeviceGray', |
||
2012 | 'bpc' => 8, |
||
2013 | 'f' => $info['f'], |
||
2014 | 'dp' => $dp, |
||
2015 | 'data' => $info['smask'] |
||
2016 | ]; |
||
2017 | $this->putImage($smask); |
||
0 ignored issues
–
show
The method
putImage() does not exist on NFePHP\DA\Legacy\FPDF\Fpdf . Did you maybe mean putImages() ?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise.
Loading history...
|
|||
2018 | } |
||
2019 | // Palette |
||
2020 | if ($info['cs'] == 'Indexed') { |
||
2021 | $this->putStreamobject($info['pal']); |
||
0 ignored issues
–
show
The method
putStreamobject() does not exist on NFePHP\DA\Legacy\FPDF\Fpdf . Did you maybe mean putStream() ?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise.
Loading history...
|
|||
2022 | } |
||
2023 | } |
||
2024 | |||
2025 | protected function putXobjectDict() |
||
2026 | { |
||
2027 | foreach ($this->images as $image) { |
||
2028 | $this->put('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2029 | } |
||
2030 | } |
||
2031 | |||
2032 | protected function putResourceDict() |
||
2033 | { |
||
2034 | $this->put('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2035 | $this->put('/Font <<'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2036 | foreach ($this->fonts as $font) { |
||
2037 | $this->put('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2038 | } |
||
2039 | $this->put('>>'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2040 | $this->put('/XObject <<'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2041 | $this->putXobjectDict(); |
||
2042 | $this->put('>>'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2043 | } |
||
2044 | |||
2045 | protected function putResources() |
||
2046 | { |
||
2047 | $this->putFonts(); |
||
2048 | $this->putImages(); |
||
2049 | // Resource dictionary |
||
2050 | $this->newObj(2); |
||
0 ignored issues
–
show
The call to
Fpdf::newObj() has too many arguments starting with 2 .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the
Loading history...
|
|||
2051 | $this->put('<<'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2052 | $this->putResourceDict(); |
||
2053 | $this->put('>>'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2054 | $this->put('endobj'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2055 | } |
||
2056 | |||
2057 | protected function putInfo() |
||
2058 | { |
||
2059 | $this->metadata['Producer'] = 'FPDF ' . FPDF_VERSION; |
||
2060 | $this->metadata['CreationDate'] = 'D:' . @date('YmdHis'); |
||
2061 | foreach ($this->metadata as $key => $value) { |
||
2062 | $this->put('/' . $key . ' ' . $this->textString($value)); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2063 | } |
||
2064 | } |
||
2065 | |||
2066 | protected function putCatalog() |
||
2067 | { |
||
2068 | $n = $this->pageInfo[1]['n']; |
||
2069 | $this->put('/Type /Catalog'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2070 | $this->put('/Pages 1 0 R'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2071 | if ($this->zoomMode == 'fullpage') { |
||
2072 | $this->put('/OpenAction [' . $n . ' 0 R /Fit]'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2073 | } elseif ($this->zoomMode == 'fullwidth') { |
||
2074 | $this->put('/OpenAction [' . $n . ' 0 R /FitH null]'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2075 | } elseif ($this->zoomMode == 'real') { |
||
2076 | $this->put('/OpenAction [' . $n . ' 0 R /XYZ null null 1]'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2077 | } elseif (!is_string($this->zoomMode)) { |
||
2078 | $this->put('/OpenAction [' . $n . ' 0 R /XYZ null null ' |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2079 | . sprintf('%.2F', $this->zoomMode / 100) . ']'); |
||
2080 | } |
||
2081 | if ($this->layoutMode == 'single') { |
||
2082 | $this->put('/PageLayout /SinglePage'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2083 | } elseif ($this->layoutMode == 'continuous') { |
||
2084 | $this->put('/PageLayout /OneColumn'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2085 | } elseif ($this->layoutMode == 'two') { |
||
2086 | $this->put('/PageLayout /TwoColumnLeft'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2087 | } |
||
2088 | } |
||
2089 | |||
2090 | protected function putHeader() |
||
2091 | { |
||
2092 | $this->put('%PDF-' . $this->pdfVersion); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2093 | } |
||
2094 | |||
2095 | protected function putTrailer() |
||
2096 | { |
||
2097 | $this->put('/Size ' . ($this->n + 1)); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2098 | $this->put('/Root ' . $this->n . ' 0 R'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2099 | $this->put('/Info ' . ($this->n - 1) . ' 0 R'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2100 | } |
||
2101 | |||
2102 | protected function endDoc() |
||
2103 | { |
||
2104 | $this->putHeader(); |
||
2105 | $this->putPages(); |
||
2106 | $this->putResources(); |
||
2107 | // Info |
||
2108 | $this->newObj(); |
||
2109 | $this->put('<<'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2110 | $this->putInfo(); |
||
2111 | $this->put('>>'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2112 | $this->put('endobj'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2113 | // Catalog |
||
2114 | $this->newObj(); |
||
2115 | $this->put('<<'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2116 | $this->putCatalog(); |
||
2117 | $this->put('>>'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2118 | $this->put('endobj'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2119 | // Cross-ref |
||
2120 | $offset = $this->getOffset(); |
||
0 ignored issues
–
show
The method
getOffset() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2121 | $this->put('xref'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2122 | $this->put('0 ' . ($this->n + 1)); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2123 | $this->put('0000000000 65535 f '); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2124 | for ($i = 1; $i <= $this->n; $i++) { |
||
2125 | $this->put(sprintf('%010d 00000 n ', $this->offsets[$i])); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2126 | } |
||
2127 | // Trailer |
||
2128 | $this->put('trailer'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2129 | $this->put('<<'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2130 | $this->putTrailer(); |
||
2131 | $this->put('>>'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2132 | $this->put('startxref'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2133 | $this->put($offset); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2134 | $this->put('%%EOF'); |
||
0 ignored issues
–
show
The method
put() does not seem to exist on object<NFePHP\DA\Legacy\FPDF\Fpdf> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
2135 | $this->state = 3; |
||
2136 | } |
||
2137 | } |
||
2138 |
This check looks for classes that have been defined more than once.
If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.
This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.