TCPDF::setHeaderData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 4
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
//============================================================+
3
// File name   : tcpdf.php
4
// Begin       : 2002-08-03
5
// Last Update : 2007-03-20
6
// Author      : Nicola Asuni
7
// Version     : 1.53.0.TC031_PHP4
8
// License     : GNU LGPL (http://www.gnu.org/copyleft/lesser.html)
9
//
10
// Description : This is a PHP4 class for generating PDF files
11
//               on-the-fly without requiring external
12
//               extensions.
13
//
14
// IMPORTANT:
15
// This class is an extension and improvement of the public Domain
16
// FPDF class by Olivier Plathey (http://www.fpdf.org).
17
//
18
// Main changes by Nicola Asuni:
19
//    PHP5 porting;
20
//    UTF-8 Unicode support;
21
//    code refactoring;
22
//    source code clean up;
23
//    code style and formatting;
24
//    source code documentation using phpDocumentor (www.phpdoc.org);
25
//    All ISO page formats were included;
26
//    image scale factor;
27
//    includes methods to parse and printsome XHTML code, supporting the following elements: h1, h2, h3, h4, h5, h6, b, u, i, a, img, p, br, strong, em, font, blockquote, li, ul, ol, hr, td, th, tr, table, sup, sub, small;
28
//    includes a method to print various barcode formats using an improved version of "Generic Barcode Render Class" by Karim Mribti (http://www.mribti.com/barcode/) (require GD library: http://www.boutell.com/gd/);
29
//    defines standard Header() and Footer() methods.
30
//============================================================+
31
32
/**
33
 * TCPDF Class.
34
 * @package com.tecnick.tcpdf
35
 */
36
37
/**
38
 * include configuration file
39
 */
40
require_once(dirname(__FILE__).'/config/tcpdf_config.php');
41
42
/**
43
 * This is a PHP4 class for generating PDF files on-the-fly without requiring external extensions.<br>
44
 * TCPDF project (http://tcpdf.sourceforge.net) is based on the public Domain FPDF class by Olivier Plathey (http://www.fpdf.org).<br>
45
 * <h3>TCPDF main changes from FPDF are:</h3><ul>
46
 * <li>PHP4 porting</li>
47
 * <li>UTF-8 Unicode support</li>
48
 * <li>source code clean up</li>
49
 * <li>code style and formatting</li>
50
 * <li>source code documentation using phpDocumentor (www.phpdoc.org)</li>
51
 * <li>All ISO page formats were included</li>
52
 * <li>image scale factor</li>
53
 * <li>includes methods to parse and printsome XHTML code, supporting the following elements: h1, h2, h3, h4, h5, h6, b, u, i, a, img, p, br, strong, em, font, blockquote, li, ul, ol, hr, td, th, tr, table, sup, sub, small;</li>
54
 * <li>includes a method to print various barcode formats using an improved version of "Generic Barcode Render Class" by Karim Mribti (http://www.mribti.com/barcode/) (require GD library: http://www.boutell.com/gd/)</li>
55
 * <li>defines standard Header() and Footer() methods.</li>
56
 * </ul>
57
 * Tools to encode your unicode fonts are on fonts/ttf2ufm directory.</p>
58
 * @name TCPDF
59
 * @package com.tecnick.tcpdf
60
 * @abstract Class for generating PDF files on-the-fly without requiring external extensions.
61
 * @author Nicola Asuni
62
 * @copyright 2004-2006 Tecnick.com S.r.l (www.tecnick.com) Via Ugo Foscolo n.19 - 09045 Quartu Sant'Elena (CA) - ITALY - www.tecnick.com - [email protected]
63
 * @link http://tcpdf.sourceforge.net
64
 * @license http://www.gnu.org/copyleft/lesser.html LGPL
65
 @version 1.53.0.TC031_PHP4
66
 */
67
68
if(!class_exists('TCPDF')) {
69
	/**
70
	 * define default PDF document producer
71
	 */
72
	//define('PDF_PRODUCER','TCPDF 1.53.0.TC031_PHP4 (http://tcpdf.sourceforge.net)');
73
	define('PDF_PRODUCER','Instant Zero (http://www.instant-zero.com)');
74
75
	/**
76
	* This is a PHP4 class for generating PDF files on-the-fly without requiring external extensions.<br>
77
	* This class is an extension and improvement of the FPDF class by Olivier Plathey (http://www.fpdf.org).<br>
78
	* This version contains some changes: [porting to PHP4, support for UTF-8 Unicode, code style and formatting, php documentation (www.phpdoc.org), ISO page formats, minor improvements, image scale factor]<br>
79
	* TCPDF project (http://tcpdf.sourceforge.net) is based on the public Domain FPDF class by Olivier Plathey (http://www.fpdf.org).<br>
80
	* To add your own TTF fonts please read /fonts/README.TXT
81
	* @name TCPDF
82
	* @package com.tecnick.tcpdf
83
	* @version 1.53.0.TC031_PHP4
84
	* @author Nicola Asuni
85
	* @link http://tcpdf.sourceforge.net
86
	* @license http://www.gnu.org/copyleft/lesser.html LGPL
87
	*/
88
	class TCPDF {
89
		//var properties
90
91
		/**
92
		* @var current page number
93
		* @access protected
94
		*/
95
		var $page;
96
97
		/**
98
		* @var current object number
99
		* @access protected
100
		*/
101
		var $n;
102
103
		/**
104
		* @var array of object offsets
105
		* @access protected
106
		*/
107
		var $offsets;
108
109
		/**
110
		* @var buffer holding in-memory PDF
111
		* @access protected
112
		*/
113
		var $buffer;
114
115
		/**
116
		* @var array containing pages
117
		* @access protected
118
		*/
119
		var $pages;
120
121
		/**
122
		* @var current document state
123
		* @access protected
124
		*/
125
		var $state;
126
127
		/**
128
		* @var compression flag
129
		* @access protected
130
		*/
131
		var $compress;
132
133
		/**
134
		* @var default orientation
135
		* @access protected
136
		*/
137
		var $DefOrientation;
138
139
		/**
140
		* @var current orientation
141
		* @access protected
142
		*/
143
		var $CurOrientation;
144
145
		/**
146
		* @var array indicating orientation changes
147
		* @access protected
148
		*/
149
		var $OrientationChanges;
150
151
		/**
152
		* @var scale factor (number of points in user unit)
153
		* @access protected
154
		*/
155
		var $k;
156
157
		/**
158
		* @var width of page format in points
159
		* @access protected
160
		*/
161
		var $fwPt;
162
163
		/**
164
		* @var height of page format in points
165
		* @access protected
166
		*/
167
		var $fhPt;
168
169
		/**
170
		* @var width of page format in user unit
171
		* @access protected
172
		*/
173
		var $fw;
174
175
		/**
176
		* @var height of page format in user unit
177
		* @access protected
178
		*/
179
		var $fh;
180
181
		/**
182
		* @var current width of page in points
183
		* @access protected
184
		*/
185
		var $wPt;
186
187
		/**
188
		* @var current height of page in points
189
		* @access protected
190
		*/
191
		var $hPt;
192
193
		/**
194
		* @var current width of page in user unit
195
		* @access protected
196
		*/
197
		var $w;
198
199
		/**
200
		* @var current height of page in user unit
201
		* @access protected
202
		*/
203
		var $h;
204
205
		/**
206
		* @var left margin
207
		* @access protected
208
		*/
209
		var $lMargin;
210
211
		/**
212
		* @var top margin
213
		* @access protected
214
		*/
215
		var $tMargin;
216
217
		/**
218
		* @var right margin
219
		* @access protected
220
		*/
221
		var $rMargin;
222
223
		/**
224
		* @var page break margin
225
		* @access protected
226
		*/
227
		var $bMargin;
228
229
		/**
230
		* @var cell margin
231
		* @access protected
232
		*/
233
		var $cMargin;
234
235
		/**
236
		* @var current horizontal position in user unit for cell positioning
237
		* @access protected
238
		*/
239
		var $x;
240
241
		/**
242
		* @var current vertical position in user unit for cell positioning
243
		* @access protected
244
		*/
245
		var $y;
246
247
		/**
248
		* @var height of last cell printed
249
		* @access protected
250
		*/
251
		var $lasth;
252
253
		/**
254
		* @var line width in user unit
255
		* @access protected
256
		*/
257
		var $LineWidth;
258
259
		/**
260
		* @var array of standard font names
261
		* @access protected
262
		*/
263
		var $CoreFonts;
264
265
		/**
266
		* @var array of used fonts
267
		* @access protected
268
		*/
269
		var $fonts;
270
271
		/**
272
		* @var array of font files
273
		* @access protected
274
		*/
275
		var $FontFiles;
276
277
		/**
278
		* @var array of encoding differences
279
		* @access protected
280
		*/
281
		var $diffs;
282
283
		/**
284
		* @var array of used images
285
		* @access protected
286
		*/
287
		var $images;
288
289
		/**
290
		* @var array of links in pages
291
		* @access protected
292
		*/
293
		var $PageLinks;
294
295
		/**
296
		* @var array of internal links
297
		* @access protected
298
		*/
299
		var $links;
300
301
		/**
302
		* @var current font family
303
		* @access protected
304
		*/
305
		var $FontFamily;
306
307
		/**
308
		* @var current font style
309
		* @access protected
310
		*/
311
		var $FontStyle;
312
313
		/**
314
		* @var underlining flag
315
		* @access protected
316
		*/
317
		var $underline;
318
319
		/**
320
		* @var current font info
321
		* @access protected
322
		*/
323
		var $CurrentFont;
324
325
		/**
326
		* @var current font size in points
327
		* @access protected
328
		*/
329
		var $FontSizePt;
330
331
		/**
332
		* @var current font size in user unit
333
		* @access protected
334
		*/
335
		var $FontSize;
336
337
		/**
338
		* @var commands for drawing color
339
		* @access protected
340
		*/
341
		var $DrawColor;
342
343
		/**
344
		* @var commands for filling color
345
		* @access protected
346
		*/
347
		var $FillColor;
348
349
		/**
350
		* @var commands for text color
351
		* @access protected
352
		*/
353
		var $TextColor;
354
355
		/**
356
		* @var indicates whether fill and text colors are different
357
		* @access protected
358
		*/
359
		var $ColorFlag;
360
361
		/**
362
		* @var word spacing
363
		* @access protected
364
		*/
365
		var $ws;
366
367
		/**
368
		* @var automatic page breaking
369
		* @access protected
370
		*/
371
		var $AutoPageBreak;
372
373
		/**
374
		* @var threshold used to trigger page breaks
375
		* @access protected
376
		*/
377
		var $PageBreakTrigger;
378
379
		/**
380
		* @var flag set when processing footer
381
		* @access protected
382
		*/
383
		var $InFooter;
384
385
		/**
386
		* @var zoom display mode
387
		* @access protected
388
		*/
389
		var $ZoomMode;
390
391
		/**
392
		* @var layout display mode
393
		* @access protected
394
		*/
395
		var $LayoutMode;
396
397
		/**
398
		* @var title
399
		* @access protected
400
		*/
401
		var $title;
402
403
		/**
404
		* @var subject
405
		* @access protected
406
		*/
407
		var $subject;
408
409
		/**
410
		* @var author
411
		* @access protected
412
		*/
413
		var $author;
414
415
		/**
416
		* @var keywords
417
		* @access protected
418
		*/
419
		var $keywords;
420
421
		/**
422
		* @var creator
423
		* @access protected
424
		*/
425
		var $creator;
426
427
		/**
428
		* @var alias for total number of pages
429
		* @access protected
430
		*/
431
		var $AliasNbPages;
432
433
		/**
434
		* @var right-bottom corner X coordinate of inserted image
435
		* @since 2002-07-31
436
		* @author Nicola Asuni
437
		* @access protected
438
		*/
439
		var $img_rb_x;
440
441
		/**
442
		* @var right-bottom corner Y coordinate of inserted image
443
		* @since 2002-07-31
444
		* @author Nicola Asuni
445
		* @access protected
446
		*/
447
		var $img_rb_y;
448
449
		/**
450
		* @var image scale factor
451
		* @since 2004-06-14
452
		* @author Nicola Asuni
453
		* @access protected
454
		*/
455
		var $imgscale = 1;
456
457
		/**
458
		* @var boolean set to true when the input text is unicode (require unicode fonts)
459
		* @since 2005-01-02
460
		* @author Nicola Asuni
461
		* @access protected
462
		*/
463
		var $isunicode = false;
464
465
		/**
466
		* @var PDF version
467
		* @since 1.5.3
468
		* @access protected
469
		*/
470
		var $PDFVersion = "1.3";
471
472
473
		// ----------------------
474
475
		/**
476
		 * @var Minimum distance between header and top page margin.
477
		 * @access private
478
		 */
479
		var $header_margin;
480
481
		/**
482
		 * @var Minimum distance between footer and bottom page margin.
483
		 * @access private
484
		 */
485
		var $footer_margin;
486
487
		/**
488
		 * @var original left margin value
489
		 * @access private
490
		 * @since 1.53.0.TC013
491
		 */
492
		var $original_lMargin;
493
494
		/**
495
		 * @var original right margin value
496
		 * @access private
497
		 * @since 1.53.0.TC013
498
		 */
499
		var $original_rMargin;
500
501
		/**
502
		 * @var Header font.
503
		 * @access private
504
		 */
505
		var $header_font;
506
507
		/**
508
		 * @var Footer font.
509
		 * @access private
510
		 */
511
		var $footer_font;
512
513
		/**
514
		 * @var Language templates.
515
		 * @access private
516
		 */
517
		var $l;
518
519
		/**
520
		 * @var Barcode to print on page footer (only if set).
521
		 * @access private
522
		 */
523
		var $barcode = false;
524
525
		/**
526
		 * @var If true prints header
527
		 * @access private
528
		 */
529
		var $print_header = true;
530
531
		/**
532
		 * @var If true prints footer.
533
		 * @access private
534
		 */
535
		var $print_footer = true;
536
537
		/**
538
		 * @var Header width (0 = full page width).
539
		 * @access private
540
		 */
541
		var $header_width = 0;
542
543
		/**
544
		 * @var Header image logo.
545
		 * @access private
546
		 */
547
		var $header_logo = "";
548
549
		/**
550
		 * @var Header image logo width in mm.
551
		 * @access private
552
		 */
553
		var $header_logo_width = 30;
554
555
		/**
556
		 * @var String to print as title on document header.
557
		 * @access private
558
		 */
559
		var $header_title = "";
560
561
		/**
562
		 * @var String to print on document header.
563
		 * @access private
564
		 */
565
		var $header_string = "";
566
567
		/**
568
		 * @var Default number of columns for html table.
569
		 * @access private
570
		 */
571
		var $default_table_columns = 4;
572
573
574
		// variables for html parser
575
576
		/**
577
		 * @var HTML PARSER: store current link.
578
		 * @access private
579
		 */
580
		var $HREF;
581
582
		/**
583
		 * @var HTML PARSER: store font list.
584
		 * @access private
585
		 */
586
		var $fontList;
587
588
		/**
589
		 * @var HTML PARSER: true when font attribute is set.
590
		 * @access private
591
		 */
592
		var $issetfont;
593
594
		/**
595
		 * @var HTML PARSER: true when color attribute is set.
596
		 * @access private
597
		 */
598
		var $issetcolor;
599
600
		/**
601
		 * @var HTML PARSER: true in case of ordered list (OL), false otherwise.
602
		 * @access private
603
		 */
604
		var $listordered = false;
605
606
		/**
607
		 * @var HTML PARSER: count list items.
608
		 * @access private
609
		 */
610
		var $listcount = 0;
611
612
		/**
613
		 * @var HTML PARSER: size of table border.
614
		 * @access private
615
		 */
616
		var $tableborder = 0;
617
618
		/**
619
		 * @var HTML PARSER: true at the beginning of table.
620
		 * @access private
621
		 */
622
		var $tdbegin = false;
623
624
		/**
625
		 * @var HTML PARSER: table width.
626
		 * @access private
627
		 */
628
		var $tdwidth = 0;
629
630
		/**
631
		 * @var HTML PARSER: table height.
632
		 * @access private
633
		 */
634
		var $tdheight = 0;
635
636
		/**
637
		 * @var HTML PARSER: table align.
638
		 * @access private
639
		 */
640
		var $tdalign = "L";
641
642
		/**
643
		 * @var HTML PARSER: table background color.
644
		 * @access private
645
		 */
646
		var $tdbgcolor = false;
647
648
		/**
649
		 * @var Store temporary font size in points.
650
		 * @access private
651
		 */
652
		var $tempfontsize = 10;
653
654
		/**
655
		 * @var Bold font style status.
656
		 * @access private
657
		 */
658
		var $b;
659
660
		/**
661
		 * @var Underlined font style status.
662
		 * @access private
663
		 */
664
		var $u;
665
666
		/**
667
		 * @var Italic font style status.
668
		 * @access private
669
		 */
670
		var $i;
671
672
		/**
673
		 * @var spacer for LI tags.
674
		 * @access private
675
		 */
676
		var $lispacer = "";
677
678
		/**
679
		 * @var default encoding
680
		 * @access private
681
		 * @since 1.53.0.TC010
682
		 */
683
		var $encoding = "UTF-8";
684
685
		/**
686
		 * @var PHP internal encoding
687
		 * @access private
688
		 * @since 1.53.0.TC016
689
		 */
690
		var $internal_encoding;
691
692
		/**
693
		 * @var store previous fill color as RGB array
694
		 * @access private
695
		 * @since 1.53.0.TC017
696
		 */
697
		var $prevFillColor = array(255,255,255);
698
699
		/**
700
		 * @var store previous text color as RGB array
701
		 * @access private
702
		 * @since 1.53.0.TC017
703
		 */
704
		var $prevTextColor = array(0,0,0);
705
706
		/**
707
		 * @var store previous font family
708
		 * @access private
709
		 * @since 1.53.0.TC017
710
		 */
711
		var $prevFontFamily;
712
713
		/**
714
		 * @var store previous font style
715
		 * @access private
716
		 * @since 1.53.0.TC017
717
		 */
718
		var $prevFontStyle;
719
720
		//------------------------------------------------------------
721
		// var methods
722
		//------------------------------------------------------------
723
724
		/**
725
		 * This is the class constructor.
726
		 * It allows to set up the page format, the orientation and
727
		 * the measure unit used in all the methods (except for the font sizes).
728
		 * @since 1.0
729
		 * @param string $orientation page orientation. Possible values are (case insensitive):<ul><li>P or Portrait (default)</li><li>L or Landscape</li></ul>
730
		 * @param string $unit User measure unit. Possible values are:<ul><li>pt: point</li><li>mm: millimeter (default)</li><li>cm: centimeter</li><li>in: inch</li></ul><br />A point equals 1/72 of inch, that is to say about 0.35 mm (an inch being 2.54 cm). This is a very common unit in typography; font sizes are expressed in that unit.
731
		 * @param mixed $format The format used for pages. It can be either one of the following values (case insensitive) or a custom format in the form of a two-element array containing the width and the height (expressed in the unit given by unit).<ul><li>4A0</li><li>2A0</li><li>A0</li><li>A1</li><li>A2</li><li>A3</li><li>A4 (default)</li><li>A5</li><li>A6</li><li>A7</li><li>A8</li><li>A9</li><li>A10</li><li>B0</li><li>B1</li><li>B2</li><li>B3</li><li>B4</li><li>B5</li><li>B6</li><li>B7</li><li>B8</li><li>B9</li><li>B10</li><li>C0</li><li>C1</li><li>C2</li><li>C3</li><li>C4</li><li>C5</li><li>C6</li><li>C7</li><li>C8</li><li>C9</li><li>C10</li><li>RA0</li><li>RA1</li><li>RA2</li><li>RA3</li><li>RA4</li><li>SRA0</li><li>SRA1</li><li>SRA2</li><li>SRA3</li><li>SRA4</li><li>LETTER</li><li>LEGAL</li><li>EXECUTIVE</li><li>FOLIO</li></ul>
732
		 * @param boolean $unicode TRUE means that the input text is unicode (default = true)
733
		 * @param String $encoding charset encoding; default is UTF-8
734
		 */
735
		function TCPDF($orientation='P', $unit='mm', $format='A4', $unicode=true, $encoding="UTF-8") {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
736
737
			/* Set internal character encoding to ASCII */
738
			if (function_exists("mb_internal_encoding") AND mb_internal_encoding()) {
739
				$this->internal_encoding = mb_internal_encoding();
740
				mb_internal_encoding("ASCII");
741
			}
742
743
			//Some checks
744
			$this->_dochecks();
745
			//Initialization of properties
746
			$this->isunicode=$unicode;
747
			$this->page=0;
0 ignored issues
show
Documentation Bug introduced by
It seems like 0 of type integer is incompatible with the declared type object<current> of property $page.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
748
			$this->n=2;
0 ignored issues
show
Documentation Bug introduced by
It seems like 2 of type integer is incompatible with the declared type object<current> of property $n.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
749
			$this->buffer='';
0 ignored issues
show
Documentation Bug introduced by
It seems like '' of type string is incompatible with the declared type object<buffer> of property $buffer.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
750
			$this->pages=array();
751
			$this->OrientationChanges=array();
752
			$this->state=0;
0 ignored issues
show
Documentation Bug introduced by
It seems like 0 of type integer is incompatible with the declared type object<current> of property $state.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
753
			$this->fonts=array();
754
			$this->FontFiles=array();
755
			$this->diffs=array();
756
			$this->images=array();
757
			$this->links=array();
758
			$this->InFooter=false;
0 ignored issues
show
Documentation Bug introduced by
It seems like false of type false is incompatible with the declared type object<flag> of property $InFooter.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
759
			$this->lasth=0;
0 ignored issues
show
Documentation Bug introduced by
It seems like 0 of type integer is incompatible with the declared type object<height> of property $lasth.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
760
			$this->FontFamily='';
0 ignored issues
show
Documentation Bug introduced by
It seems like '' of type string is incompatible with the declared type object<current> of property $FontFamily.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
761
			$this->FontStyle='';
0 ignored issues
show
Documentation Bug introduced by
It seems like '' of type string is incompatible with the declared type object<current> of property $FontStyle.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
762
			$this->FontSizePt=12;
0 ignored issues
show
Documentation Bug introduced by
It seems like 12 of type integer is incompatible with the declared type object<current> of property $FontSizePt.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
763
			$this->underline=false;
0 ignored issues
show
Documentation Bug introduced by
It seems like false of type false is incompatible with the declared type object<underlining> of property $underline.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
764
			$this->DrawColor='0 G';
0 ignored issues
show
Documentation Bug introduced by
It seems like '0 G' of type string is incompatible with the declared type object<commands> of property $DrawColor.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
765
			$this->FillColor='0 g';
0 ignored issues
show
Documentation Bug introduced by
It seems like '0 g' of type string is incompatible with the declared type object<commands> of property $FillColor.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
766
			$this->TextColor='0 g';
0 ignored issues
show
Documentation Bug introduced by
It seems like '0 g' of type string is incompatible with the declared type object<commands> of property $TextColor.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
767
			$this->ColorFlag=false;
0 ignored issues
show
Documentation Bug introduced by
It seems like false of type false is incompatible with the declared type object<indicates> of property $ColorFlag.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
768
			$this->ws=0;
0 ignored issues
show
Documentation Bug introduced by
It seems like 0 of type integer is incompatible with the declared type object<word> of property $ws.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
769
			//Standard Unicode fonts
770
			$this->CoreFonts=array(
771
			'courier'=>'Courier',
772
			'courierB'=>'Courier-Bold',
773
			'courierI'=>'Courier-Oblique',
774
			'courierBI'=>'Courier-BoldOblique',
775
			'helvetica'=>'Helvetica',
776
			'helveticaB'=>'Helvetica-Bold',
777
			'helveticaI'=>'Helvetica-Oblique',
778
			'helveticaBI'=>'Helvetica-BoldOblique',
779
			'times'=>'Times-Roman',
780
			'timesB'=>'Times-Bold',
781
			'timesI'=>'Times-Italic',
782
			'timesBI'=>'Times-BoldItalic',
783
			'symbol'=>'Symbol',
784
			'zapfdingbats'=>'ZapfDingbats'
785
			);
786
787
			//Scale factor
788
			// 2003-06-11 - Nicola Asuni : changed if/else with switch statement
789
			switch (strtolower($unit)){
790
				case 'pt': {$this->k=1; break;}
0 ignored issues
show
Documentation Bug introduced by
It seems like 1 of type integer is incompatible with the declared type object<scale> of property $k.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
791
				case 'mm': {$this->k=72/25.4; break;}
0 ignored issues
show
Documentation Bug introduced by
It seems like 72 / 25.4 of type double is incompatible with the declared type object<scale> of property $k.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
792
				case 'cm': {$this->k=72/2.54; break;}
0 ignored issues
show
Documentation Bug introduced by
It seems like 72 / 2.54 of type double is incompatible with the declared type object<scale> of property $k.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
793
				case 'in': {$this->k=72; break;}
0 ignored issues
show
Documentation Bug introduced by
It seems like 72 of type integer is incompatible with the declared type object<scale> of property $k.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
794
				default : {$this->Error('Incorrect unit: '.$unit); break;}
795
			}
796
797
			//Page format
798
			if(is_string($format)) {
799
				// 2002-07-24 - Nicola Asuni ([email protected])
800
				// Added new page formats (45 standard ISO paper formats and 4 american common formats).
801
				// Paper cordinates are calculated in this way: (inches * 72) where (1 inch = 2.54 cm)
802
				switch (strtoupper($format)){
803
					case '4A0': {$format = array(4767.87,6740.79); break;}
804
					case '2A0': {$format = array(3370.39,4767.87); break;}
805
					case 'A0': {$format = array(2383.94,3370.39); break;}
806
					case 'A1': {$format = array(1683.78,2383.94); break;}
807
					case 'A2': {$format = array(1190.55,1683.78); break;}
808
					case 'A3': {$format = array(841.89,1190.55); break;}
809
					case 'A4': default: {$format = array(595.28,841.89); break;}
810
					case 'A5': {$format = array(419.53,595.28); break;}
0 ignored issues
show
Unused Code introduced by
case 'A5': $format =...53, 595.28); break; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
811
					case 'A6': {$format = array(297.64,419.53); break;}
812
					case 'A7': {$format = array(209.76,297.64); break;}
813
					case 'A8': {$format = array(147.40,209.76); break;}
814
					case 'A9': {$format = array(104.88,147.40); break;}
815
					case 'A10': {$format = array(73.70,104.88); break;}
816
					case 'B0': {$format = array(2834.65,4008.19); break;}
817
					case 'B1': {$format = array(2004.09,2834.65); break;}
818
					case 'B2': {$format = array(1417.32,2004.09); break;}
819
					case 'B3': {$format = array(1000.63,1417.32); break;}
820
					case 'B4': {$format = array(708.66,1000.63); break;}
821
					case 'B5': {$format = array(498.90,708.66); break;}
822
					case 'B6': {$format = array(354.33,498.90); break;}
823
					case 'B7': {$format = array(249.45,354.33); break;}
824
					case 'B8': {$format = array(175.75,249.45); break;}
825
					case 'B9': {$format = array(124.72,175.75); break;}
826
					case 'B10': {$format = array(87.87,124.72); break;}
827
					case 'C0': {$format = array(2599.37,3676.54); break;}
828
					case 'C1': {$format = array(1836.85,2599.37); break;}
829
					case 'C2': {$format = array(1298.27,1836.85); break;}
830
					case 'C3': {$format = array(918.43,1298.27); break;}
831
					case 'C4': {$format = array(649.13,918.43); break;}
832
					case 'C5': {$format = array(459.21,649.13); break;}
833
					case 'C6': {$format = array(323.15,459.21); break;}
834
					case 'C7': {$format = array(229.61,323.15); break;}
835
					case 'C8': {$format = array(161.57,229.61); break;}
836
					case 'C9': {$format = array(113.39,161.57); break;}
837
					case 'C10': {$format = array(79.37,113.39); break;}
838
					case 'RA0': {$format = array(2437.80,3458.27); break;}
839
					case 'RA1': {$format = array(1729.13,2437.80); break;}
840
					case 'RA2': {$format = array(1218.90,1729.13); break;}
841
					case 'RA3': {$format = array(864.57,1218.90); break;}
842
					case 'RA4': {$format = array(609.45,864.57); break;}
843
					case 'SRA0': {$format = array(2551.18,3628.35); break;}
844
					case 'SRA1': {$format = array(1814.17,2551.18); break;}
845
					case 'SRA2': {$format = array(1275.59,1814.17); break;}
846
					case 'SRA3': {$format = array(907.09,1275.59); break;}
847
					case 'SRA4': {$format = array(637.80,907.09); break;}
848
					case 'LETTER': {$format = array(612.00,792.00); break;}
849
					case 'LEGAL': {$format = array(612.00,1008.00); break;}
850
					case 'EXECUTIVE': {$format = array(521.86,756.00); break;}
851
					case 'FOLIO': {$format = array(612.00,936.00); break;}
852
					// default: {$this->Error('Unknown page format: '.$format); break;}
853
					// END CHANGES Nicola Asuni
854
				}
855
				$this->fwPt=$format[0];
0 ignored issues
show
Documentation Bug introduced by
It seems like $format[0] of type double is incompatible with the declared type object<width> of property $fwPt.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
856
				$this->fhPt=$format[1];
0 ignored issues
show
Documentation Bug introduced by
It seems like $format[1] of type double is incompatible with the declared type object<height> of property $fhPt.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
857
			}
858
			else {
859
				$this->fwPt=$format[0]*$this->k;
0 ignored issues
show
Documentation Bug introduced by
It seems like $format[0] * $this->k of type integer or double is incompatible with the declared type object<width> of property $fwPt.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
860
				$this->fhPt=$format[1]*$this->k;
0 ignored issues
show
Documentation Bug introduced by
It seems like $format[1] * $this->k of type integer or double is incompatible with the declared type object<height> of property $fhPt.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
861
			}
862
863
			$this->fw=$this->fwPt/$this->k;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->fwPt / $this->k of type integer or double is incompatible with the declared type object<width> of property $fw.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
864
			$this->fh=$this->fhPt/$this->k;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->fhPt / $this->k of type integer or double is incompatible with the declared type object<height> of property $fh.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
865
866
			//Page orientation
867
			$orientation=strtolower($orientation);
868
			if($orientation=='p' or $orientation=='portrait') {
869
				$this->DefOrientation='P';
0 ignored issues
show
Documentation Bug introduced by
It seems like 'P' of type string is incompatible with the declared type object<default> of property $DefOrientation.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
870
				$this->wPt=$this->fwPt;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->fwPt of type integer or double is incompatible with the declared type object<current> of property $wPt.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
871
				$this->hPt=$this->fhPt;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->fhPt of type integer or double is incompatible with the declared type object<current> of property $hPt.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
872
			}
873
			elseif($orientation=='l' or $orientation=='landscape') {
874
				$this->DefOrientation='L';
0 ignored issues
show
Documentation Bug introduced by
It seems like 'L' of type string is incompatible with the declared type object<default> of property $DefOrientation.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
875
				$this->wPt=$this->fhPt;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->fhPt of type integer or double is incompatible with the declared type object<current> of property $wPt.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
876
				$this->hPt=$this->fwPt;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->fwPt of type integer or double is incompatible with the declared type object<current> of property $hPt.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
877
			}
878
			else {
879
				$this->Error('Incorrect orientation: '.$orientation);
880
			}
881
882
			$this->CurOrientation=$this->DefOrientation;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->DefOrientation of type string or object<default> is incompatible with the declared type object<current> of property $CurOrientation.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
883
			$this->w=$this->wPt/$this->k;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->wPt / $this->k of type integer or double is incompatible with the declared type object<current> of property $w.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
884
			$this->h=$this->hPt/$this->k;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->hPt / $this->k of type integer or double is incompatible with the declared type object<current> of property $h.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
885
			//Page margins (1 cm)
886
			$margin=28.35/$this->k;
887
			$this->SetMargins($margin,$margin);
888
			//Interior cell margin (1 mm)
889
			$this->cMargin=$margin/10;
0 ignored issues
show
Documentation Bug introduced by
It seems like $margin / 10 of type double is incompatible with the declared type object<cell> of property $cMargin.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
890
			//Line width (0.2 mm)
891
			$this->LineWidth=.567/$this->k;
0 ignored issues
show
Documentation Bug introduced by
It seems like 0.5669999999999999 / $this->k of type double is incompatible with the declared type object<line> of property $LineWidth.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
892
			//Automatic page break
893
			$this->SetAutoPageBreak(true,2*$margin);
894
			//Full width display mode
895
			$this->SetDisplayMode('fullwidth');
896
			//Compression
897
			$this->SetCompression(true);
898
			//Set default PDF version number
899
			$this->PDFVersion = "1.3";
0 ignored issues
show
Documentation Bug introduced by
It seems like '1.3' of type string is incompatible with the declared type object<PDF> of property $PDFVersion.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
900
901
			$this->encoding = $encoding;
0 ignored issues
show
Documentation Bug introduced by
It seems like $encoding of type string is incompatible with the declared type object<default> of property $encoding.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
902
			$this->b = 0;
0 ignored issues
show
Documentation Bug introduced by
It seems like 0 of type integer is incompatible with the declared type object<Bold> of property $b.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
903
			$this->i = 0;
0 ignored issues
show
Documentation Bug introduced by
It seems like 0 of type integer is incompatible with the declared type object<Italic> of property $i.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
904
			$this->u = 0;
0 ignored issues
show
Documentation Bug introduced by
It seems like 0 of type integer is incompatible with the declared type object<Underlined> of property $u.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
905
			$this->HREF = '';
0 ignored issues
show
Documentation Bug introduced by
It seems like '' of type string is incompatible with the declared type object<HTML> of property $HREF.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
906
			$this->fontlist = array("arial", "times", "courier", "helvetica", "symbol");
0 ignored issues
show
Bug introduced by
The property fontlist does not seem to exist. Did you mean fontList?

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...
907
			$this->issetfont = false;
0 ignored issues
show
Documentation Bug introduced by
It seems like false of type false is incompatible with the declared type object<HTML> of property $issetfont.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
908
			$this->issetcolor = false;
0 ignored issues
show
Documentation Bug introduced by
It seems like false of type false is incompatible with the declared type object<HTML> of property $issetcolor.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
909
			$this->tableborder = 0;
0 ignored issues
show
Documentation Bug introduced by
It seems like 0 of type integer is incompatible with the declared type object<HTML> of property $tableborder.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
910
			$this->tdbegin = false;
0 ignored issues
show
Documentation Bug introduced by
It seems like false of type false is incompatible with the declared type object<HTML> of property $tdbegin.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
911
			$this->tdwidth=  0;
0 ignored issues
show
Documentation Bug introduced by
It seems like 0 of type integer is incompatible with the declared type object<HTML> of property $tdwidth.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
912
			$this->tdheight = 0;
0 ignored issues
show
Documentation Bug introduced by
It seems like 0 of type integer is incompatible with the declared type object<HTML> of property $tdheight.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
913
			$this->tdalign = "L";
0 ignored issues
show
Documentation Bug introduced by
It seems like 'L' of type string is incompatible with the declared type object<HTML> of property $tdalign.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
914
			$this->tdbgcolor = false;
0 ignored issues
show
Documentation Bug introduced by
It seems like false of type false is incompatible with the declared type object<HTML> of property $tdbgcolor.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
915
916
			$this->SetFillColor(200, 200, 200, true);
917
			$this->SetTextColor(0, 0, 0, true);
918
		}
919
920
		/**
921
		* Set the image scale.
922
		* @param float $scale image scale.
923
		* @author Nicola Asuni
924
		* @since 1.5.2
925
		*/
926
		function setImageScale($scale) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
927
			$this->imgscale=$scale;
0 ignored issues
show
Documentation Bug introduced by
It seems like $scale of type double is incompatible with the declared type object<Image> of property $imgscale.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
928
		}
929
930
		/**
931
		* Returns the image scale.
932
		* @return float image scale.
0 ignored issues
show
Documentation introduced by
Should the return type not be Image?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
933
		* @author Nicola Asuni
934
		* @since 1.5.2
935
		*/
936
		function getImageScale() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
937
			return $this->imgscale;
938
		}
939
940
		/**
941
		* Returns the page width in units.
942
		* @return int page width.
0 ignored issues
show
Documentation introduced by
Should the return type not be current?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
943
		* @author Nicola Asuni
944
		* @since 1.5.2
945
		*/
946
		function getPageWidth() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
947
			return $this->w;
948
		}
949
950
		/**
951
		* Returns the page height in units.
952
		* @return int page height.
0 ignored issues
show
Documentation introduced by
Should the return type not be current?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
953
		* @author Nicola Asuni
954
		* @since 1.5.2
955
		*/
956
		function getPageHeight() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
957
			return $this->h;
958
		}
959
960
		/**
961
		* Returns the page break margin.
962
		* @return int page break margin.
0 ignored issues
show
Documentation introduced by
Should the return type not be page?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
963
		* @author Nicola Asuni
964
		* @since 1.5.2
965
		*/
966
		function getBreakMargin() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
967
			return $this->bMargin;
968
		}
969
970
		/**
971
		* Returns the scale factor (number of points in user unit).
972
		* @return int scale factor.
0 ignored issues
show
Documentation introduced by
Should the return type not be scale?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
973
		* @author Nicola Asuni
974
		* @since 1.5.2
975
		*/
976
		function getScaleFactor() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
977
			return $this->k;
978
		}
979
980
		/**
981
		* Defines the left, top and right margins. By default, they equal 1 cm. Call this method to change them.
982
		* @param float $left Left margin.
983
		* @param float $top Top margin.
984
		* @param float $right Right margin. Default value is the left one.
0 ignored issues
show
Documentation introduced by
Should the type for parameter $right not be integer?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
985
		* @since 1.0
986
		* @see SetLeftMargin(), SetTopMargin(), SetRightMargin(), SetAutoPageBreak()
987
		*/
988
		function SetMargins($left, $top, $right=-1) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
989
			//Set left, top and right margins
990
			$this->lMargin=$left;
0 ignored issues
show
Documentation Bug introduced by
It seems like $left of type double is incompatible with the declared type object<left> of property $lMargin.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
991
			$this->tMargin=$top;
0 ignored issues
show
Documentation Bug introduced by
It seems like $top of type double is incompatible with the declared type object<top> of property $tMargin.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
992
			if($right==-1) {
993
				$right=$left;
994
			}
995
			$this->rMargin=$right;
0 ignored issues
show
Documentation Bug introduced by
It seems like $right of type double or integer is incompatible with the declared type object<right> of property $rMargin.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
996
		}
997
998
		/**
999
		* Defines the left margin. The method can be called before creating the first page. If the current abscissa gets out of page, it is brought back to the margin.
1000
		* @param float $margin The margin.
1001
		* @since 1.4
1002
		* @see SetTopMargin(), SetRightMargin(), SetAutoPageBreak(), SetMargins()
1003
		*/
1004
		function SetLeftMargin($margin) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1005
			//Set left margin
1006
			$this->lMargin=$margin;
0 ignored issues
show
Documentation Bug introduced by
It seems like $margin of type double is incompatible with the declared type object<left> of property $lMargin.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1007
			if(($this->page>0) and ($this->x<$margin)) {
1008
				$this->x=$margin;
0 ignored issues
show
Documentation Bug introduced by
It seems like $margin of type double is incompatible with the declared type object<current> of property $x.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1009
			}
1010
		}
1011
1012
		/**
1013
		* Defines the top margin. The method can be called before creating the first page.
1014
		* @param float $margin The margin.
1015
		* @since 1.5
1016
		* @see SetLeftMargin(), SetRightMargin(), SetAutoPageBreak(), SetMargins()
1017
		*/
1018
		function SetTopMargin($margin) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1019
			//Set top margin
1020
			$this->tMargin=$margin;
0 ignored issues
show
Documentation Bug introduced by
It seems like $margin of type double is incompatible with the declared type object<top> of property $tMargin.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1021
		}
1022
1023
		/**
1024
		* Defines the right margin. The method can be called before creating the first page.
1025
		* @param float $margin The margin.
1026
		* @since 1.5
1027
		* @see SetLeftMargin(), SetTopMargin(), SetAutoPageBreak(), SetMargins()
1028
		*/
1029
		function SetRightMargin($margin) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1030
			//Set right margin
1031
			$this->rMargin=$margin;
0 ignored issues
show
Documentation Bug introduced by
It seems like $margin of type double is incompatible with the declared type object<right> of property $rMargin.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1032
		}
1033
1034
		/**
1035
		* Enables or disables the automatic page breaking mode. When enabling, the second parameter is the distance from the bottom of the page that defines the triggering limit. By default, the mode is on and the margin is 2 cm.
1036
		* @param boolean $auto Boolean indicating if mode should be on or off.
1037
		* @param float $margin Distance from the bottom of the page.
0 ignored issues
show
Documentation introduced by
Should the type for parameter $margin not be integer?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
1038
		* @since 1.0
1039
		* @see Cell(), MultiCell(), AcceptPageBreak()
1040
		*/
1041
		function SetAutoPageBreak($auto, $margin=0) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1042
			//Set auto page break mode and triggering margin
1043
			$this->AutoPageBreak=$auto;
0 ignored issues
show
Documentation Bug introduced by
It seems like $auto of type boolean is incompatible with the declared type object<automatic> of property $AutoPageBreak.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1044
			$this->bMargin=$margin;
0 ignored issues
show
Documentation Bug introduced by
It seems like $margin of type integer is incompatible with the declared type object<page> of property $bMargin.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1045
			$this->PageBreakTrigger=$this->h-$margin;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->h - $margin of type integer or double is incompatible with the declared type object<threshold> of property $PageBreakTrigger.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1046
		}
1047
1048
		/**
1049
		* Defines the way the document is to be displayed by the viewer. The zoom level can be set: pages can be displayed entirely on screen, occupy the full width of the window, use real size, be scaled by a specific zooming factor or use viewer default (configured in the Preferences menu of Acrobat). The page layout can be specified too: single at once, continuous display, two columns or viewer default. By default, documents use the full width mode with continuous display.
1050
		* @param mixed $zoom The zoom to use. It can be one of the following string values or a number indicating the zooming factor to use. <ul><li>fullpage: displays the entire page on screen </li><li>fullwidth: uses maximum width of window</li><li>real: uses real size (equivalent to 100% zoom)</li><li>default: uses viewer default mode</li></ul>
1051
		* @param string $layout The page layout. Possible values are:<ul><li>single: displays one page at once</li><li>continuous: displays pages continuously (default)</li><li>two: displays two pages on two columns</li><li>default: uses viewer default mode</li></ul>
1052
		* @since 1.2
1053
		*/
1054
		function SetDisplayMode($zoom, $layout='continuous') {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1055
			//Set display mode in viewer
1056
			if($zoom=='fullpage' or $zoom=='fullwidth' or $zoom=='real' or $zoom=='default' or !is_string($zoom)) {
1057
				$this->ZoomMode=$zoom;
1058
			}
1059
			else {
1060
				$this->Error('Incorrect zoom display mode: '.$zoom);
1061
			}
1062
			if($layout=='single' or $layout=='continuous' or $layout=='two' or $layout=='default') {
1063
				$this->LayoutMode=$layout;
0 ignored issues
show
Documentation Bug introduced by
It seems like $layout of type string is incompatible with the declared type object<layout> of property $LayoutMode.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1064
			}
1065
			else {
1066
				$this->Error('Incorrect layout display mode: '.$layout);
1067
			}
1068
		}
1069
1070
		/**
1071
		* Activates or deactivates page compression. When activated, the internal representation of each page is compressed, which leads to a compression ratio of about 2 for the resulting document. Compression is on by default.
1072
		* Note: the Zlib extension is required for this feature. If not present, compression will be turned off.
1073
		* @param boolean $compress Boolean indicating if compression must be enabled.
1074
		* @since 1.4
1075
		*/
1076
		function SetCompression($compress) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1077
			//Set page compression
1078
			if(function_exists('gzcompress')) {
1079
				$this->compress=$compress;
0 ignored issues
show
Documentation Bug introduced by
It seems like $compress of type boolean is incompatible with the declared type object<compression> of property $compress.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1080
			}
1081
			else {
1082
				$this->compress=false;
0 ignored issues
show
Documentation Bug introduced by
It seems like false of type false is incompatible with the declared type object<compression> of property $compress.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1083
			}
1084
		}
1085
1086
		/**
1087
		* Defines the title of the document.
1088
		* @param string $title The title.
1089
		* @since 1.2
1090
		* @see SetAuthor(), SetCreator(), SetKeywords(), SetSubject()
1091
		*/
1092
		function SetTitle($title) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1093
			//Title of document
1094
			$this->title=$title;
0 ignored issues
show
Documentation Bug introduced by
It seems like $title of type string is incompatible with the declared type object<title> of property $title.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1095
		}
1096
1097
		/**
1098
		* Defines the subject of the document.
1099
		* @param string $subject The subject.
1100
		* @since 1.2
1101
		* @see SetAuthor(), SetCreator(), SetKeywords(), SetTitle()
1102
		*/
1103
		function SetSubject($subject) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1104
			//Subject of document
1105
			$this->subject=$subject;
0 ignored issues
show
Documentation Bug introduced by
It seems like $subject of type string is incompatible with the declared type object<subject> of property $subject.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1106
		}
1107
1108
		/**
1109
		* Defines the author of the document.
1110
		* @param string $author The name of the author.
1111
		* @since 1.2
1112
		* @see SetCreator(), SetKeywords(), SetSubject(), SetTitle()
1113
		*/
1114
		function SetAuthor($author) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1115
			//Author of document
1116
			$this->author=$author;
0 ignored issues
show
Documentation Bug introduced by
It seems like $author of type string is incompatible with the declared type object<author> of property $author.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1117
		}
1118
1119
		/**
1120
		* Associates keywords with the document, generally in the form 'keyword1 keyword2 ...'.
1121
		* @param string $keywords The list of keywords.
1122
		* @since 1.2
1123
		* @see SetAuthor(), SetCreator(), SetSubject(), SetTitle()
1124
		*/
1125
		function SetKeywords($keywords) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1126
			//Keywords of document
1127
			$this->keywords=$keywords;
0 ignored issues
show
Documentation Bug introduced by
It seems like $keywords of type string is incompatible with the declared type object<keywords> of property $keywords.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1128
		}
1129
1130
		/**
1131
		* Defines the creator of the document. This is typically the name of the application that generates the PDF.
1132
		* @param string $creator The name of the creator.
1133
		* @since 1.2
1134
		* @see SetAuthor(), SetKeywords(), SetSubject(), SetTitle()
1135
		*/
1136
		function SetCreator($creator) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1137
			//Creator of document
1138
			$this->creator=$creator;
0 ignored issues
show
Documentation Bug introduced by
It seems like $creator of type string is incompatible with the declared type object<creator> of property $creator.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1139
		}
1140
1141
		/**
1142
		* Defines an alias for the total number of pages. It will be substituted as the document is closed.<br />
1143
		* <b>Example:</b><br />
1144
		* <pre>
1145
		* class PDF extends TCPDF {
1146
		* 	function Footer() {
1147
		* 		//Go to 1.5 cm from bottom
1148
		* 		$this->SetY(-15);
1149
		* 		//Select Arial italic 8
1150
		* 		$this->SetFont('Arial','I',8);
1151
		* 		//Print current and total page numbers
1152
		* 		$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
1153
		* 	}
1154
		* }
1155
		* $pdf=new PDF();
1156
		* $pdf->AliasNbPages();
1157
		* </pre>
1158
		* @param string $alias The alias. Default value: {nb}.
1159
		* @since 1.4
1160
		* @see PageNo(), Footer()
1161
		*/
1162
		function AliasNbPages($alias='{nb}') {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1163
			//Define an alias for total number of pages
1164
			$this->AliasNbPages = $this->_escapetext($alias);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->_escapetext($alias) of type string is incompatible with the declared type object<alias> of property $AliasNbPages.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1165
		}
1166
1167
		/**
1168
		* This method is automatically called in case of fatal error; it simply outputs the message and halts the execution. An inherited class may override it to customize the error handling but should always halt the script, or the resulting document would probably be invalid.
1169
		* 2004-06-11 :: Nicola Asuni : changed bold tag with strong
1170
		* @param string $msg The error message
1171
		* @since 1.0
1172
		*/
1173
		function Error($msg) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1174
			//Fatal error
1175
			die('<strong>TCPDF error: </strong>'.$msg);
1176
		}
1177
1178
		/**
1179
		* This method begins the generation of the PDF document. It is not necessary to call it explicitly because AddPage() does it automatically.
1180
		* Note: no page is created by this method
1181
		* @since 1.0
1182
		* @see AddPage(), Close()
1183
		*/
1184
		function Open() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1185
			//Begin document
1186
			$this->state=1;
0 ignored issues
show
Documentation Bug introduced by
It seems like 1 of type integer is incompatible with the declared type object<current> of property $state.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1187
		}
1188
1189
		/**
1190
		* Terminates the PDF document. It is not necessary to call this method explicitly because Output() does it automatically. If the document contains no page, AddPage() is called to prevent from getting an invalid document.
1191
		* @since 1.0
1192
		* @see Open(), Output()
1193
		*/
1194
		function Close() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1195
			//Terminate document
1196
			if($this->state==3) {
1197
				return;
1198
			}
1199
			if($this->page==0) {
1200
				$this->AddPage();
1201
			}
1202
			//Page footer
1203
			$this->InFooter=true;
0 ignored issues
show
Documentation Bug introduced by
It seems like true of type boolean is incompatible with the declared type object<flag> of property $InFooter.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1204
			$this->Footer();
1205
			$this->InFooter=false;
0 ignored issues
show
Documentation Bug introduced by
It seems like false of type false is incompatible with the declared type object<flag> of property $InFooter.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1206
			//Close page
1207
			$this->_endpage();
1208
			//Close document
1209
			$this->_enddoc();
1210
		}
1211
1212
		/**
1213
		* Adds a new page to the document. If a page is already present, the Footer() method is called first to output the footer. Then the page is added, the current position set to the top-left corner according to the left and top margins, and Header() is called to display the header.
1214
		* The font which was set before calling is automatically restored. There is no need to call SetFont() again if you want to continue with the same font. The same is true for colors and line width.
1215
		* The origin of the coordinate system is at the top-left corner and increasing ordinates go downwards.
1216
		* @param string $orientation Page orientation. Possible values are (case insensitive):<ul><li>P or Portrait</li><li>L or Landscape</li></ul> The default value is the one passed to the constructor.
1217
		* @since 1.0
1218
		* @see TCPDF(), Header(), Footer(), SetMargins()
1219
		*/
1220
		function AddPage($orientation='') {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1221
			//Start a new page
1222
			if($this->state==0) {
1223
				$this->Open();
1224
			}
1225
			$family=$this->FontFamily;
1226
			$style=$this->FontStyle.($this->underline ? 'U' : '');
1227
			$size=$this->FontSizePt;
1228
			$lw=$this->LineWidth;
1229
			$dc=$this->DrawColor;
1230
			$fc=$this->FillColor;
1231
			$tc=$this->TextColor;
1232
			$cf=$this->ColorFlag;
1233
			if($this->page>0) {
1234
				//Page footer
1235
				$this->InFooter=true;
0 ignored issues
show
Documentation Bug introduced by
It seems like true of type boolean is incompatible with the declared type object<flag> of property $InFooter.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1236
				$this->Footer();
1237
				$this->InFooter=false;
0 ignored issues
show
Documentation Bug introduced by
It seems like false of type false is incompatible with the declared type object<flag> of property $InFooter.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1238
				//Close page
1239
				$this->_endpage();
1240
			}
1241
			//Start new page
1242
			$this->_beginpage($orientation);
1243
			//Set line cap style to square
1244
			$this->_out('2 J');
1245
			//Set line width
1246
			$this->LineWidth=$lw;
1247
			$this->_out(sprintf('%.2f w',$lw*$this->k));
1248
			//Set font
1249
			if($family) {
1250
				$this->SetFont($family,$style,$size);
1251
			}
1252
			//Set colors
1253
			$this->DrawColor=$dc;
1254
			if($dc!='0 G') {
1255
				$this->_out($dc);
1256
			}
1257
			$this->FillColor=$fc;
1258
			if($fc!='0 g') {
1259
				$this->_out($fc);
1260
			}
1261
			$this->TextColor=$tc;
1262
			$this->ColorFlag=$cf;
1263
			//Page header
1264
			$this->Header();
1265
			//Restore line width
1266
			if($this->LineWidth!=$lw) {
1267
				$this->LineWidth=$lw;
0 ignored issues
show
Documentation Bug introduced by
It seems like $lw of type integer or double is incompatible with the declared type object<line> of property $LineWidth.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1268
				$this->_out(sprintf('%.2f w',$lw*$this->k));
1269
			}
1270
			//Restore font
1271
			if($family) {
1272
				$this->SetFont($family,$style,$size);
1273
			}
1274
			//Restore colors
1275
			if($this->DrawColor!=$dc) {
1276
				$this->DrawColor=$dc;
1277
				$this->_out($dc);
1278
			}
1279
			if($this->FillColor!=$fc) {
1280
				$this->FillColor=$fc;
1281
				$this->_out($fc);
1282
			}
1283
			$this->TextColor=$tc;
1284
			$this->ColorFlag=$cf;
1285
		}
1286
1287
1288
1289
		/**
1290
	 	 * Set header data.
1291
		 * @param string $ln header image logo
1292
		 * @param string $lw header image logo width in mm
0 ignored issues
show
Documentation introduced by
Should the type for parameter $lw not be integer?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
1293
		 * @param string $ht string to print as title on document header
1294
		 * @param string $hs string to print on document header
1295
		*/
1296
		function setHeaderData($ln="", $lw=0, $ht="", $hs="") {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1297
			$this->header_logo = $ln;
0 ignored issues
show
Documentation Bug introduced by
It seems like $ln of type string is incompatible with the declared type object<Header> of property $header_logo.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1298
			$this->header_logo_width = $lw;
0 ignored issues
show
Documentation Bug introduced by
It seems like $lw of type integer is incompatible with the declared type object<Header> of property $header_logo_width.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1299
			$this->header_title = $ht;
1300
			$this->header_string = $hs;
1301
		}
1302
1303
		/**
1304
	 	 * Set header margin.
1305
		 * (minimum distance between header and top page margin)
1306
		 * @param int $hm distance in millimeters
1307
		*/
1308
		function setHeaderMargin($hm=10) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1309
			$this->header_margin = $hm;
0 ignored issues
show
Documentation Bug introduced by
It seems like $hm of type integer is incompatible with the declared type object<Minimum> of property $header_margin.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1310
		}
1311
1312
		/**
1313
	 	 * Set footer margin.
1314
		 * (minimum distance between footer and bottom page margin)
1315
		 * @param int $fm distance in millimeters
1316
		*/
1317
		function setFooterMargin($fm=10) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1318
			$this->footer_margin = $fm;
0 ignored issues
show
Documentation Bug introduced by
It seems like $fm of type integer is incompatible with the declared type object<Minimum> of property $footer_margin.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1319
		}
1320
1321
		/**
1322
	 	 * Set a flag to print page header.
1323
		 * @param boolean $val set to true to print the page header (default), false otherwise.
1324
		*/
1325
		function setPrintHeader($val=true) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1326
			$this->print_header = $val;
0 ignored issues
show
Documentation Bug introduced by
It seems like $val of type boolean is incompatible with the declared type object<If> of property $print_header.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1327
		}
1328
1329
		/**
1330
	 	 * Set a flag to print page footer.
1331
		 * @param boolean $value set to true to print the page footer (default), false otherwise.
0 ignored issues
show
Bug introduced by
There is no parameter named $value. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
1332
		*/
1333
		function setPrintFooter($val=true) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1334
			$this->print_footer = $val;
0 ignored issues
show
Documentation Bug introduced by
It seems like $val of type boolean is incompatible with the declared type object<If> of property $print_footer.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1335
		}
1336
1337
		/**
1338
	 	 * This method is used to render the page header.
1339
	 	 * It is automatically called by AddPage() and could be overwritten in your own inherited class.
1340
		 */
1341
		function Header() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1342
			if ($this->print_header) {
1343
1344
				if (!isset($this->original_lMargin)) {
1345
					$this->original_lMargin = $this->lMargin;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->lMargin of type object<left> is incompatible with the declared type object<original> of property $original_lMargin.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1346
				}
1347
				if (!isset($this->original_rMargin)) {
1348
					$this->original_rMargin = $this->rMargin;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->rMargin of type object<right> is incompatible with the declared type object<original> of property $original_rMargin.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1349
				}
1350
1351
				//set current position
1352
				$this->SetXY($this->original_lMargin, $this->header_margin);
1353
1354
				if (($this->header_logo) AND ($this->header_logo != K_BLANK_IMAGE)) {
1355
					$this->Image(K_PATH_IMAGES.$this->header_logo, $this->original_lMargin, $this->header_margin, $this->header_logo_width);
1356
				}
1357
				else {
1358
					$this->img_rb_y = $this->GetY();
1359
				}
1360
1361
				$cell_height = round((K_CELL_HEIGHT_RATIO * $this->header_font[2]) / $this->k, 2);
1362
1363
				$header_x = $this->original_lMargin + ($this->header_logo_width * 1.05); //set left margin for text data cell
1364
1365
				// header title
1366
				$this->SetFont($this->header_font[0], 'B', $this->header_font[2] + 1);
1367
				$this->SetX($header_x);
1368
				$this->Cell($this->header_width, $cell_height, $this->header_title, 0, 1, 'L');
1369
1370
				// header string
1371
				$this->SetFont($this->header_font[0], $this->header_font[1], $this->header_font[2]);
1372
				$this->SetX($header_x);
1373
				$this->MultiCell($this->header_width, $cell_height, $this->header_string, 0, 'L', 0);
1374
1375
				// print an ending header line
1376
				if (empty($this->header_width)) {
1377
					//set style for cell border
1378
					$this->SetLineWidth(0.3);
1379
					$this->SetDrawColor(0, 0, 0);
1380
					$this->SetY(1 + max($this->img_rb_y, $this->GetY()));
1381
					$this->SetX($this->original_lMargin);
1382
					$this->Cell(0, 0, '', 'T', 0, 'C');
1383
				}
1384
1385
				//restore position
1386
				$this->SetXY($this->original_lMargin, $this->tMargin);
1387
			}
1388
		}
1389
1390
		/**
1391
	 	 * This method is used to render the page footer.
1392
	 	 * It is automatically called by AddPage() and could be overwritten in your own inherited class.
1393
		 */
1394
		function Footer() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1395
			if ($this->print_footer) {
1396
1397
				if (!isset($this->original_lMargin)) {
1398
					$this->original_lMargin = $this->lMargin;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->lMargin of type object<left> is incompatible with the declared type object<original> of property $original_lMargin.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1399
				}
1400
				if (!isset($this->original_rMargin)) {
1401
					$this->original_rMargin = $this->rMargin;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->rMargin of type object<right> is incompatible with the declared type object<original> of property $original_rMargin.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1402
				}
1403
1404
				//set font
1405
				$this->SetFont($this->footer_font[0], $this->footer_font[1] , $this->footer_font[2]);
1406
				//set style for cell border
1407
				$line_width = 0.3;
1408
				$this->SetLineWidth($line_width);
1409
				$this->SetDrawColor(0, 0, 0);
1410
1411
				$footer_height = round((K_CELL_HEIGHT_RATIO * $this->footer_font[2]) / $this->k, 2); //footer height
1412
				//get footer y position
1413
				$footer_y = $this->h - $this->footer_margin - $footer_height;
1414
				//set current position
1415
				$this->SetXY($this->original_lMargin, $footer_y);
1416
1417
				//print document barcode
1418
				if ($this->barcode) {
1419
					$this->Ln();
1420
					$barcode_width = round(($this->w - $this->original_lMargin - $this->original_rMargin)); //max width
1421
					$this->writeBarcode($this->original_lMargin, $footer_y + $line_width, $barcode_width, $footer_height - $line_width, "C128B", false, false, 2, $this->barcode);
0 ignored issues
show
Documentation introduced by
false is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1422
				}
1423
1424
				$this->SetXY($this->original_lMargin, $footer_y);
1425
1426
				//Print page number
1427
				$this->Cell(0, $footer_height, $this->l['w_page']." ".$this->PageNo().' / {nb}', 'T', 0, 'R');
1428
			}
1429
		}
1430
1431
		/**
1432
		* Returns the current page number.
1433
		* @return int page number
0 ignored issues
show
Documentation introduced by
Should the return type not be current?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
1434
		* @since 1.0
1435
		* @see AliasNbPages()
1436
		*/
1437
		function PageNo() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1438
			//Get current page number
1439
			return $this->page;
1440
		}
1441
1442
		/**
1443
		* Defines the color used for all drawing operations (lines, rectangles and cell borders). It can be expressed in RGB components or gray scale. The method can be called before the first page is created and the value is retained from page to page.
1444
		* @param int $r If g et b are given, red component; if not, indicates the gray level. Value between 0 and 255
1445
		* @param int $g Green component (between 0 and 255)
1446
		* @param int $b Blue component (between 0 and 255)
1447
		* @since 1.3
1448
		* @see SetFillColor(), SetTextColor(), Line(), Rect(), Cell(), MultiCell()
1449
		*/
1450
		function SetDrawColor($r, $g=-1, $b=-1) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1451
			//Set color for all stroking operations
1452 View Code Duplication
			if(($r==0 and $g==0 and $b==0) or $g==-1) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1453
				$this->DrawColor=sprintf('%.3f G',$r/255);
0 ignored issues
show
Documentation Bug introduced by
It seems like sprintf('%.3f G', $r / 255) of type string is incompatible with the declared type object<commands> of property $DrawColor.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1454
			}
1455
			else {
1456
				$this->DrawColor=sprintf('%.3f %.3f %.3f RG',$r/255,$g/255,$b/255);
0 ignored issues
show
Documentation Bug introduced by
It seems like sprintf('%.3f %.3f %.3f ...55, $g / 255, $b / 255) of type string is incompatible with the declared type object<commands> of property $DrawColor.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1457
			}
1458
			if($this->page>0) {
1459
				$this->_out($this->DrawColor);
1460
			}
1461
		}
1462
1463
		/**
1464
		* Defines the color used for all filling operations (filled rectangles and cell backgrounds). It can be expressed in RGB components or gray scale. The method can be called before the first page is created and the value is retained from page to page.
1465
		* @param int $r If g et b are given, red component; if not, indicates the gray level. Value between 0 and 255
1466
		* @param int $g Green component (between 0 and 255)
1467
		* @param int $b Blue component (between 0 and 255)
1468
		* @param boolean $storeprev if true stores the RGB array on $prevFillColor variable.
1469
		* @since 1.3
1470
		* @see SetDrawColor(), SetTextColor(), Rect(), Cell(), MultiCell()
1471
		*/
1472
		function SetFillColor($r, $g=-1, $b=-1, $storeprev=false) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1473
			//Set color for all filling operations
1474 View Code Duplication
			if(($r==0 and $g==0 and $b==0) or $g==-1) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1475
				$this->FillColor=sprintf('%.3f g',$r/255);
0 ignored issues
show
Documentation Bug introduced by
It seems like sprintf('%.3f g', $r / 255) of type string is incompatible with the declared type object<commands> of property $FillColor.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1476
			}
1477
			else {
1478
				$this->FillColor=sprintf('%.3f %.3f %.3f rg',$r/255,$g/255,$b/255);
0 ignored issues
show
Documentation Bug introduced by
It seems like sprintf('%.3f %.3f %.3f ...55, $g / 255, $b / 255) of type string is incompatible with the declared type object<commands> of property $FillColor.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1479
			}
1480
			$this->ColorFlag=($this->FillColor!=$this->TextColor);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->FillColor != $this->TextColor of type boolean is incompatible with the declared type object<indicates> of property $ColorFlag.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1481
			if($this->page>0) {
1482
				$this->_out($this->FillColor);
1483
			}
1484
			if ($storeprev) {
1485
				// store color as previous value
1486
				$this->prevFillColor = array($r, $g, $b);
0 ignored issues
show
Documentation Bug introduced by
It seems like array($r, $g, $b) of type array<integer,integer,{"...nteger","2":"integer"}> is incompatible with the declared type object<Store> of property $prevFillColor.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1487
			}
1488
		}
1489
1490
		/**
1491
		* Defines the color used for text. It can be expressed in RGB components or gray scale. The method can be called before the first page is created and the value is retained from page to page.
1492
		* @param int $r If g et b are given, red component; if not, indicates the gray level. Value between 0 and 255
1493
		* @param int $g Green component (between 0 and 255)
1494
		* @param int $b Blue component (between 0 and 255)
1495
		* @param boolean $storeprev if true stores the RGB array on $prevTextColor variable.
1496
		* @since 1.3
1497
		* @see SetDrawColor(), SetFillColor(), Text(), Cell(), MultiCell()
1498
		*/
1499
		function SetTextColor($r, $g=-1, $b=-1, $storeprev=false) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1500
			//Set color for text
1501 View Code Duplication
			if(($r==0 and $g==0 and $b==0) or $g==-1) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1502
				$this->TextColor=sprintf('%.3f g',$r/255);
0 ignored issues
show
Documentation Bug introduced by
It seems like sprintf('%.3f g', $r / 255) of type string is incompatible with the declared type object<commands> of property $TextColor.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1503
			}
1504
			else {
1505
				$this->TextColor=sprintf('%.3f %.3f %.3f rg',$r/255,$g/255,$b/255);
0 ignored issues
show
Documentation Bug introduced by
It seems like sprintf('%.3f %.3f %.3f ...55, $g / 255, $b / 255) of type string is incompatible with the declared type object<commands> of property $TextColor.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1506
			}
1507
			$this->ColorFlag=($this->FillColor!=$this->TextColor);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->FillColor != $this->TextColor of type boolean is incompatible with the declared type object<indicates> of property $ColorFlag.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1508
			if ($storeprev) {
1509
				// store color as previous value
1510
				$this->prevTextColor = array($r, $g, $b);
0 ignored issues
show
Documentation Bug introduced by
It seems like array($r, $g, $b) of type array<integer,integer,{"...nteger","2":"integer"}> is incompatible with the declared type object<Store> of property $prevTextColor.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1511
			}
1512
		}
1513
1514
		/**
1515
		* Returns the length of a string in user unit. A font must be selected.<br>
1516
		* Support UTF-8 Unicode [Nicola Asuni, 2005-01-02]
1517
		* @param string $s The string whose length is to be computed
1518
		* @return int
0 ignored issues
show
Documentation introduced by
Should the return type not be integer|double?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
1519
		* @since 1.2
1520
		*/
1521
		function GetStringWidth($s) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1522
			//Get width of a string in the current font
1523
			$s = (string)$s;
1524
			$cw = &$this->CurrentFont['cw'];
1525
			$w = 0;
1526
			if($this->isunicode) {
1527
				$unicode = $this->UTF8StringToArray($s);
1528
				foreach($unicode as $char) {
0 ignored issues
show
Bug introduced by
The expression $unicode of type string|array is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
1529
					if (isset($cw[$char])) {
1530
						$w+=$cw[$char];
1531
					} elseif(isset($cw[ord($char)])) {
1532
						$w+=$cw[ord($char)];
1533
					} elseif(isset($cw[chr($char)])) {
1534
						$w+=$cw[chr($char)];
1535
					} elseif(isset($this->CurrentFont['desc']['MissingWidth'])) {
1536
						$w += $this->CurrentFont['desc']['MissingWidth']; // set default size
1537
					} else {
1538
						$w += 500;
1539
					}
1540
				}
1541
			} else {
1542
				$l = strlen($s);
1543
				for($i=0; $i<$l; $i++) {
1544
					if (isset($cw[$s{$i}])) {
1545
						$w += $cw[$s{$i}];
1546
					} else if (isset($cw[ord($s{$i})])) {
1547
						$w += $cw[ord($s{$i})];
1548
					}
1549
				}
1550
			}
1551
			return ($w * $this->FontSize / 1000);
1552
		}
1553
1554
		/**
1555
		* Defines the line width. By default, the value equals 0.2 mm. The method can be called before the first page is created and the value is retained from page to page.
1556
		* @param float $width The width.
1557
		* @since 1.0
1558
		* @see Line(), Rect(), Cell(), MultiCell()
1559
		*/
1560
		function SetLineWidth($width) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1561
			//Set line width
1562
			$this->LineWidth=$width;
0 ignored issues
show
Documentation Bug introduced by
It seems like $width of type double is incompatible with the declared type object<line> of property $LineWidth.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1563
			if($this->page>0) {
1564
				$this->_out(sprintf('%.2f w',$width*$this->k));
1565
			}
1566
		}
1567
1568
		/**
1569
		* Draws a line between two points.
1570
		* @param float $x1 Abscissa of first point
1571
		* @param float $y1 Ordinate of first point
1572
		* @param float $x2 Abscissa of second point
1573
		* @param float $y2 Ordinate of second point
1574
		* @since 1.0
1575
		* @see SetLineWidth(), SetDrawColor()
1576
		*/
1577
		function Line($x1, $y1, $x2, $y2) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1578
			//Draw a line
1579
			$this->_out(sprintf('%.2f %.2f m %.2f %.2f l S', $x1*$this->k, ($this->h-$y1)*$this->k, $x2*$this->k, ($this->h-$y2)*$this->k));
1580
		}
1581
1582
		/**
1583
		* Outputs a rectangle. It can be drawn (border only), filled (with no border) or both.
1584
		* @param float $x Abscissa of upper-left corner
1585
		* @param float $y Ordinate of upper-left corner
1586
		* @param float $w Width
1587
		* @param float $h Height
1588
		* @param string $style Style of rendering. Possible values are:<ul><li>D or empty string: draw (default)</li><li>F: fill</li><li>DF or FD: draw and fill</li></ul>
1589
		* @since 1.0
1590
		* @see SetLineWidth(), SetDrawColor(), SetFillColor()
1591
		*/
1592
		function Rect($x, $y, $w, $h, $style='') {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1593
			//Draw a rectangle
1594
			if($style=='F') {
1595
				$op='f';
1596
			}
1597
			elseif($style=='FD' or $style=='DF') {
1598
				$op='B';
1599
			}
1600
			else {
1601
				$op='S';
1602
			}
1603
			$this->_out(sprintf('%.2f %.2f %.2f %.2f re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op));
1604
		}
1605
1606
		/**
1607
		* Imports a TrueType or Type1 font and makes it available. It is necessary to generate a font definition file first with the makefont.php utility. The definition file (and the font file itself when embedding) must be present either in the current directory or in the one indicated by FPDF_FONTPATH if the constant is defined. If it could not be found, the error "Could not include font definition file" is generated.
1608
		* Support UTF-8 Unicode [Nicola Asuni, 2005-01-02].
1609
		* <b>Example</b>:<br />
1610
		* <pre>
1611
		* $pdf->AddFont('Comic','I');
1612
		* // is equivalent to:
1613
		* $pdf->AddFont('Comic','I','comici.php');
1614
		* </pre>
1615
		* @param string $family Font family. The name can be chosen arbitrarily. If it is a standard family name, it will override the corresponding font.
1616
		* @param string $style Font style. Possible values are (case insensitive):<ul><li>empty string: regular (default)</li><li>B: bold</li><li>I: italic</li><li>BI or IB: bold italic</li></ul>
1617
		* @param string $file The font definition file. By default, the name is built from the family and style, in lower case with no space.
1618
		* @since 1.5
1619
		* @see SetFont()
1620
		*/
1621
		function AddFont($family, $style='', $file='') {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1622
			if(empty($family)) {
1623
				return;
1624
			}
1625
1626
			//Add a TrueType or Type1 font
1627
			$family = strtolower($family);
1628
			if((!$this->isunicode) AND ($family == 'arial')) {
1629
				$family = 'helvetica';
1630
			}
1631
1632
			$style=strtoupper($style);
1633
			$style=str_replace('U','',$style);
1634
			if($style == 'IB') {
1635
				$style = 'BI';
1636
			}
1637
1638
			$fontkey = $family.$style;
1639
			// check if the font has been already added
1640
			if(isset($this->fonts[$fontkey])) {
1641
				return;
1642
			}
1643
1644
			if($file=='') {
1645
				$file = str_replace(' ', '', $family).strtolower($style).'.php';
1646
			}
1647
			if(!file_exists($this->_getfontpath().$file)) {
1648
				// try to load the basic file without styles
1649
				$file = str_replace(' ', '', $family).'.php';
1650
			}
1651
1652
			include($this->_getfontpath().$file);
1653
1654
			if(!isset($name) AND !isset($fpdf_charwidths)) {
0 ignored issues
show
Bug introduced by
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 isset(...) or empty() on variables that are yet undefined. These calls will always produce the same result and can be removed.

This is most likely caused by the renaming of a variable or the removal of a function/method parameter.

Loading history...
Bug introduced by
The variable $fpdf_charwidths 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 isset(...) or empty(...) that are found before the variable itself is defined. These will always have the same result.

This is likely the result of code being shifted around. Consider removing these calls.

Loading history...
1655
				$this->Error('Could not include font definition file');
1656
			}
1657
1658
			$i = count($this->fonts)+1;
1659
1660 View Code Duplication
			if($this->isunicode) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1661
				$this->fonts[$fontkey] = array('i'=>$i, 'type'=>$type, 'name'=>$name, 'desc'=>$desc, 'up'=>$up, 'ut'=>$ut, 'cw'=>$cw, 'enc'=>$enc, 'file'=>$file, 'ctg'=>$ctg);
0 ignored issues
show
Bug introduced by
The variable $type does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $name 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

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
Bug introduced by
The variable $desc does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $up does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $ut does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $cw does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $enc does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $ctg does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
1662
				$fpdf_charwidths[$fontkey] = $cw;
0 ignored issues
show
Bug introduced by
The variable $fpdf_charwidths 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

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
1663
			} else {
1664
				$this->fonts[$fontkey]=array('i'=>$i, 'type'=>'core', 'name'=>$this->CoreFonts[$fontkey], 'up'=>-100, 'ut'=>50, 'cw'=>$fpdf_charwidths[$fontkey]);
1665
			}
1666
1667
			if(isset($diff) AND (!empty($diff))) {
0 ignored issues
show
Bug introduced by
The variable $diff seems to never exist, and therefore isset should always return false. Did you maybe rename this variable?

This check looks for calls to isset(...) or empty() on variables that are yet undefined. These calls will always produce the same result and can be removed.

This is most likely caused by the renaming of a variable or the removal of a function/method parameter.

Loading history...
1668
				//Search existing encodings
1669
				$d=0;
1670
				$nb=count($this->diffs);
1671
				for($i=1;$i<=$nb;$i++) {
1672
					if($this->diffs[$i]==$diff) {
1673
						$d=$i;
1674
						break;
1675
					}
1676
				}
1677
				if($d==0) {
1678
					$d=$nb+1;
1679
					$this->diffs[$d]=$diff;
1680
				}
1681
				$this->fonts[$fontkey]['diff']=$d;
1682
			}
1683
			if(!empty($file)) {
1684
				if((strcasecmp($type,"TrueType") == 0) OR (strcasecmp($type,"TrueTypeUnicode") == 0)) {
1685
					$this->FontFiles[$file]=array('length1'=>$originalsize);
0 ignored issues
show
Bug introduced by
The variable $originalsize does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
1686
				}
1687
				else {
1688
					$this->FontFiles[$file]=array('length1'=>$size1,'length2'=>$size2);
0 ignored issues
show
Bug introduced by
The variable $size1 does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $size2 does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
1689
				}
1690
			}
1691
		}
1692
1693
		/**
1694
		* Sets the font used to print character strings. It is mandatory to call this method at least once before printing text or the resulting document would not be valid.
1695
		* The font can be either a standard one or a font added via the AddFont() method. Standard fonts use Windows encoding cp1252 (Western Europe).
1696
		* The method can be called before the first page is created and the font is retained from page to page.
1697
		If you just wish to change the current font size, it is simpler to call SetFontSize().
1698
		* Note: for the standard fonts, the font metric files must be accessible. There are three possibilities for this:<ul><li>They are in the current directory (the one where the running script lies)</li><li>They are in one of the directories defined by the include_path parameter</li><li>They are in the directory defined by the FPDF_FONTPATH constant</li></ul><br />
1699
		* Example for the last case (note the trailing slash):<br />
1700
		* <pre>
1701
		* define('FPDF_FONTPATH','/home/www/font/');
1702
		* require('tcpdf.php');
1703
		*
1704
		* //Times regular 12
1705
		* $pdf->SetFont('Times');
1706
		* //Arial bold 14
1707
		* $pdf->SetFont('Arial','B',14);
1708
		* //Removes bold
1709
		* $pdf->SetFont('');
1710
		* //Times bold, italic and underlined 14
1711
		* $pdf->SetFont('Times','BIU');
1712
		* </pre><br />
1713
		* If the file corresponding to the requested font is not found, the error "Could not include font metric file" is generated.
1714
		* @param string $family Family font. It can be either a name defined by AddFont() or one of the standard families (case insensitive):<ul><li>Courier (fixed-width)</li><li>Helvetica or Arial (synonymous; sans serif)</li><li>Times (serif)</li><li>Symbol (symbolic)</li><li>ZapfDingbats (symbolic)</li></ul>It is also possible to pass an empty string. In that case, the current family is retained.
1715
		* @param string $style Font style. Possible values are (case insensitive):<ul><li>empty string: regular</li><li>B: bold</li><li>I: italic</li><li>U: underline</li></ul>or any combination. The default value is regular. Bold and italic styles do not apply to Symbol and ZapfDingbats
1716
		* @param float $size Font size in points. The default value is the current size. If no size has been specified since the beginning of the document, the value taken is 12
0 ignored issues
show
Documentation introduced by
Should the type for parameter $size not be integer?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
1717
		* @since 1.0
1718
		* @see AddFont(), SetFontSize(), Cell(), MultiCell(), Write()
1719
		*/
1720
		function SetFont($family, $style='', $size=0) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1721
			// save previous values
1722
			$this->prevFontFamily = $this->FontFamily;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->FontFamily of type object<current> is incompatible with the declared type object<Store> of property $prevFontFamily.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1723
			$this->prevFontStyle = $this->FontStyle;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->FontStyle of type object<current> is incompatible with the declared type object<Store> of property $prevFontStyle.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1724
1725
			//Select a font; size given in points
1726
			global $fpdf_charwidths;
1727
1728
			$family=strtolower($family);
1729
			if($family=='') {
1730
				$family=$this->FontFamily;
1731
			}
1732
			if((!$this->isunicode) AND ($family == 'arial')) {
1733
				$family = 'helvetica';
1734
			}
1735
			elseif(($family=="symbol") OR ($family=="zapfdingbats")) {
1736
				$style='';
1737
			}
1738
			$style=strtoupper($style);
1739
1740
			if(strpos($style,'U')!==false) {
1741
				$this->underline=true;
0 ignored issues
show
Documentation Bug introduced by
It seems like true of type boolean is incompatible with the declared type object<underlining> of property $underline.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1742
				$style=str_replace('U','',$style);
1743
			}
1744
			else {
1745
				$this->underline=false;
0 ignored issues
show
Documentation Bug introduced by
It seems like false of type false is incompatible with the declared type object<underlining> of property $underline.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1746
			}
1747
			if($style=='IB') {
1748
				$style='BI';
1749
			}
1750
			if($size==0) {
1751
				$size=$this->FontSizePt;
1752
			}
1753
1754
			// try to add font (if not already added)
1755
			if($this->isunicode) {
1756
				$this->AddFont($family, $style);
1757
			}
1758
1759
			//Test if font is already selected
1760
			if(($this->FontFamily == $family) AND ($this->FontStyle == $style) AND ($this->FontSizePt == $size)) {
1761
				return;
1762
			}
1763
1764
			$fontkey = $family.$style;
1765
			//if(!isset($this->fonts[$fontkey]) AND isset($this->fonts[$family])) {
1766
			//	$style='';
1767
			//}
1768
1769
			//Test if used for the first time
1770
			if(!isset($this->fonts[$fontkey])) {
1771
				//Check if one of the standard fonts
1772
				if(isset($this->CoreFonts[$fontkey])) {
1773
					if(!isset($fpdf_charwidths[$fontkey])) {
1774
						//Load metric file
1775
						$file = $family;
1776
						if(($family!='symbol') AND ($family!='zapfdingbats')) {
1777
							$file .= strtolower($style);
1778
						}
1779
						if(!file_exists($this->_getfontpath().$file.'.php')) {
1780
							// try to load the basic file without styles
1781
							$file = $family;
1782
							$fontkey = $family;
1783
						}
1784
						include($this->_getfontpath().$file.'.php');
1785
						if (($this->isunicode AND !isset($ctg)) OR ((!$this->isunicode) AND (!isset($fpdf_charwidths[$fontkey]))) ) {
0 ignored issues
show
Bug introduced by
The variable $ctg seems to never exist, and therefore isset should always return false. Did you maybe rename this variable?

This check looks for calls to isset(...) or empty() on variables that are yet undefined. These calls will always produce the same result and can be removed.

This is most likely caused by the renaming of a variable or the removal of a function/method parameter.

Loading history...
1786
							$this->Error("Could not include font metric file [".$fontkey."]: ".$this->_getfontpath().$file.".php");
1787
						}
1788
					}
1789
					$i = count($this->fonts) + 1;
1790
1791 View Code Duplication
					if($this->isunicode) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1792
						$this->fonts[$fontkey] = array('i'=>$i, 'type'=>$type, 'name'=>$name, 'desc'=>$desc, 'up'=>$up, 'ut'=>$ut, 'cw'=>$cw, 'enc'=>$enc, 'file'=>$file, 'ctg'=>$ctg);
0 ignored issues
show
Bug introduced by
The variable $type does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $name does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $desc does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $up does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $ut does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $cw does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $enc does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $file 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

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
Bug introduced by
The variable $ctg 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

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
1793
						$fpdf_charwidths[$fontkey] = $cw;
1794
					} else {
1795
						$this->fonts[$fontkey]=array('i'=>$i, 'type'=>'core', 'name'=>$this->CoreFonts[$fontkey], 'up'=>-100, 'ut'=>50, 'cw'=>$fpdf_charwidths[$fontkey]);
1796
					}
1797
				}
1798
				else {
1799
					$this->Error('Undefined font: '.$family.' '.$style);
1800
				}
1801
			}
1802
			//Select it
1803
			$this->FontFamily = $family;
0 ignored issues
show
Documentation Bug introduced by
It seems like $family can also be of type string. However, the property $FontFamily is declared as type object<current>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
1804
			$this->FontStyle = $style;
0 ignored issues
show
Documentation Bug introduced by
It seems like $style of type string is incompatible with the declared type object<current> of property $FontStyle.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1805
			$this->FontSizePt = $size;
0 ignored issues
show
Documentation Bug introduced by
It seems like $size can also be of type integer. However, the property $FontSizePt is declared as type object<current>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
1806
			$this->FontSize = $size / $this->k;
0 ignored issues
show
Documentation Bug introduced by
It seems like $size / $this->k of type integer or double is incompatible with the declared type object<current> of property $FontSize.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1807
			$this->CurrentFont = &$this->fonts[$fontkey];
1808 View Code Duplication
			if($this->page>0) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1809
				$this->_out(sprintf('BT /F%d %.2f Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
1810
			}
1811
		}
1812
1813
		/**
1814
		* Defines the size of the current font.
1815
		* @param float $size The size (in points)
1816
		* @since 1.0
1817
		* @see SetFont()
1818
		*/
1819
		function SetFontSize($size) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1820
			//Set font size in points
1821
			if($this->FontSizePt==$size) {
1822
				return;
1823
			}
1824
			$this->FontSizePt = $size;
0 ignored issues
show
Documentation Bug introduced by
It seems like $size of type double is incompatible with the declared type object<current> of property $FontSizePt.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1825
			$this->FontSize = $size / $this->k;
0 ignored issues
show
Documentation Bug introduced by
It seems like $size / $this->k of type double is incompatible with the declared type object<current> of property $FontSize.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1826 View Code Duplication
			if($this->page > 0) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1827
				$this->_out(sprintf('BT /F%d %.2f Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
1828
			}
1829
		}
1830
1831
		/**
1832
		* Creates a new internal link and returns its identifier. An internal link is a clickable area which directs to another place within the document.<br />
1833
		* The identifier can then be passed to Cell(), Write(), Image() or Link(). The destination is defined with SetLink().
1834
		* @since 1.5
1835
		* @see Cell(), Write(), Image(), Link(), SetLink()
1836
		*/
1837
		function AddLink() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1838
			//Create a new internal link
1839
			$n=count($this->links)+1;
1840
			$this->links[$n]=array(0,0);
1841
			return $n;
1842
		}
1843
1844
		/**
1845
		* Defines the page and position a link points to
1846
		* @param int $link The link identifier returned by AddLink()
1847
		* @param float $y Ordinate of target position; -1 indicates the current position. The default value is 0 (top of page)
0 ignored issues
show
Documentation introduced by
Should the type for parameter $y not be integer?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
1848
		* @param int $page Number of target page; -1 indicates the current page. This is the default value
1849
		* @since 1.5
1850
		* @see AddLink()
1851
		*/
1852
		function SetLink($link, $y=0, $page=-1) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1853
			//Set destination of internal link
1854
			if($y==-1) {
1855
				$y=$this->y;
1856
			}
1857
			if($page==-1) {
1858
				$page=$this->page;
1859
			}
1860
			$this->links[$link]=array($page,$y);
1861
		}
1862
1863
		/**
1864
		* Puts a link on a rectangular area of the page. Text or image links are generally put via Cell(), Write() or Image(), but this method can be useful for instance to define a clickable area inside an image.
1865
		* @param float $x Abscissa of the upper-left corner of the rectangle
1866
		* @param float $y Ordinate of the upper-left corner of the rectangle
1867
		* @param float $w Width of the rectangle
1868
		* @param float $h Height of the rectangle
1869
		* @param mixed $link URL or identifier returned by AddLink()
1870
		* @since 1.5
1871
		* @see AddLink(), Cell(), Write(), Image()
1872
		*/
1873
		function Link($x, $y, $w, $h, $link) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1874
			//Put a link on the page
1875
			$this->PageLinks[$this->page][] = array($x * $this->k, $this->hPt - $y * $this->k, $w * $this->k, $h*$this->k, $link);
1876
		}
1877
1878
		/**
1879
		* Prints a character string. The origin is on the left of the first charcter, on the baseline. This method allows to place a string precisely on the page, but it is usually easier to use Cell(), MultiCell() or Write() which are the standard methods to print text.
1880
		* @param float $x Abscissa of the origin
1881
		* @param float $y Ordinate of the origin
1882
		* @param string $txt String to print
1883
		* @since 1.0
1884
		* @see SetFont(), SetTextColor(), Cell(), MultiCell(), Write()
1885
		*/
1886
		function Text($x, $y, $txt) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1887
			//Output a string
1888
			$s=sprintf('BT %.2f %.2f Td (%s) Tj ET', $x * $this->k, ($this->h-$y) * $this->k, $this->_escapetext($txt));
1889
			if($this->underline AND ($txt!='')) {
1890
				$s .= ' '.$this->_dounderline($x,$y,$txt);
1891
			}
1892
			if($this->ColorFlag) {
1893
				$s='q '.$this->TextColor.' '.$s.' Q';
1894
			}
1895
			$this->_out($s);
1896
		}
1897
1898
		/**
1899
		* Whenever a page break condition is met, the method is called, and the break is issued or not depending on the returned value. The default implementation returns a value according to the mode selected by SetAutoPageBreak().<br />
1900
		* This method is called automatically and should not be called directly by the application.<br />
1901
		* <b>Example:</b><br />
1902
		* The method is overriden in an inherited class in order to obtain a 3 column layout:<br />
1903
		* <pre>
1904
		* class PDF extends TCPDF {
1905
		* 	var $col=0;
1906
		*
1907
		* 	function SetCol($col) {
1908
		* 		//Move position to a column
1909
		* 		$this->col=$col;
1910
		* 		$x=10+$col*65;
1911
		* 		$this->SetLeftMargin($x);
1912
		* 		$this->SetX($x);
1913
		* 	}
1914
		*
1915
		* 	function AcceptPageBreak() {
1916
		* 		if($this->col<2) {
1917
		* 			//Go to next column
1918
		* 			$this->SetCol($this->col+1);
1919
		* 			$this->SetY(10);
1920
		* 			return false;
1921
		* 		}
1922
		* 		else {
1923
		* 			//Go back to first column and issue page break
1924
		* 			$this->SetCol(0);
1925
		* 			return true;
1926
		* 		}
1927
		* 	}
1928
		* }
1929
		*
1930
		* $pdf=new PDF();
1931
		* $pdf->Open();
1932
		* $pdf->AddPage();
1933
		* $pdf->SetFont('Arial','',12);
1934
		* for($i=1;$i<=300;$i++) {
1935
		*     $pdf->Cell(0,5,"Line $i",0,1);
1936
		* }
1937
		* $pdf->Output();
1938
		* </pre>
1939
		* @return boolean
0 ignored issues
show
Documentation introduced by
Should the return type not be automatic?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
1940
		* @since 1.4
1941
		* @see SetAutoPageBreak()
1942
		*/
1943
		function AcceptPageBreak() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1944
			//Accept automatic page break or not
1945
			return $this->AutoPageBreak;
1946
		}
1947
1948
		/**
1949
		* Prints a cell (rectangular area) with optional borders, background color and character string. The upper-left corner of the cell corresponds to the current position. The text can be aligned or centered. After the call, the current position moves to the right or to the next line. It is possible to put a link on the text.<br />
1950
		* If automatic page breaking is enabled and the cell goes beyond the limit, a page break is done before outputting.
1951
		* @param float $w Cell width. If 0, the cell extends up to the right margin.
1952
		* @param float $h Cell height. Default value: 0.
0 ignored issues
show
Documentation introduced by
Should the type for parameter $h not be integer?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
1953
		* @param string $txt String to print. Default value: empty string.
1954
		* @param mixed $border Indicates if borders must be drawn around the cell. The value can be either a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul>or a string containing some or all of the following characters (in any order):<ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul>
1955
		* @param int $ln Indicates where the current position should go after the call. Possible values are:<ul><li>0: to the right</li><li>1: to the beginning of the next line</li><li>2: below</li></ul>
1956
		Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: 0.
1957
		* @param string $align Allows to center or align the text. Possible values are:<ul><li>L or empty string: left align (default value)</li><li>C: center</li><li>R: right align</li></ul>
1958
		* @param int $fill Indicates if the cell background must be painted (1) or transparent (0). Default value: 0.
1959
		* @param mixed $link URL or identifier returned by AddLink().
1960
		* @since 1.0
1961
		* @see SetFont(), SetDrawColor(), SetFillColor(), SetTextColor(), SetLineWidth(), AddLink(), Ln(), MultiCell(), Write(), SetAutoPageBreak()
1962
		*/
1963
		function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=0, $link='') {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1964
			//Output a cell
1965
			$k=$this->k;
1966
			if(($this->y + $h) > $this->PageBreakTrigger AND empty($this->InFooter) AND $this->AcceptPageBreak()) {
1967
				//Automatic page break
1968
				$x = $this->x;
1969
				$ws = $this->ws;
1970
				if($ws > 0) {
1971
					$this->ws = 0;
0 ignored issues
show
Documentation Bug introduced by
It seems like 0 of type integer is incompatible with the declared type object<word> of property $ws.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1972
					$this->_out('0 Tw');
1973
				}
1974
				$this->AddPage($this->CurOrientation);
1975
				$this->x = $x;
1976
				if($ws > 0) {
1977
					$this->ws = $ws;
1978
					$this->_out(sprintf('%.3f Tw',$ws * $k));
1979
				}
1980
			}
1981
			if($w == 0) {
1982
				$w = $this->w - $this->rMargin - $this->x;
1983
			}
1984
			$s = '';
1985
			if(($fill == 1) OR ($border == 1)) {
1986
				if($fill == 1) {
1987
					$op = ($border == 1) ? 'B' : 'f';
1988
				}
1989
				else {
1990
					$op = 'S';
1991
				}
1992
				$s = sprintf('%.2f %.2f %.2f %.2f re %s ', $this->x * $k, ($this->h - $this->y) * $k, $w * $k, -$h * $k, $op);
1993
			}
1994
			if(is_string($border)) {
1995
				$x=$this->x;
1996
				$y=$this->y;
1997 View Code Duplication
				if(strpos($border,'L')!==false) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1998
					$s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k);
1999
				}
2000 View Code Duplication
				if(strpos($border,'T')!==false) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2001
					$s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k);
2002
				}
2003 View Code Duplication
				if(strpos($border,'R')!==false) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2004
					$s.=sprintf('%.2f %.2f m %.2f %.2f l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
2005
				}
2006 View Code Duplication
				if(strpos($border,'B')!==false) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2007
					$s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
2008
				}
2009
			}
2010
			if($txt != '') {
2011
				$width = $this->GetStringWidth($txt);
2012
				if($align == 'R') {
2013
					$dx = $w - $this->cMargin - $width;
2014
				}
2015
				elseif($align=='C') {
2016
					$dx = ($w - $width)/2;
2017
				}
2018
				else {
2019
					$dx = $this->cMargin;
2020
				}
2021
				if($this->ColorFlag) {
2022
					$s .= 'q '.$this->TextColor.' ';
2023
				}
2024
				$txt2 = $this->_escapetext($txt);
2025
				$s.=sprintf('BT %.2f %.2f Td (%s) Tj ET', ($this->x + $dx) * $k, ($this->h - ($this->y + 0.5 * $h + 0.3 * $this->FontSize)) * $k, $txt2);
2026
				if($this->underline) {
2027
					$s.=' '.$this->_dounderline($this->x + $dx, $this->y + 0.5 * $h + 0.3 * $this->FontSize, $txt);
2028
				}
2029
				if($this->ColorFlag) {
2030
					$s.=' Q';
2031
				}
2032
				if($link) {
2033
					$this->Link($this->x + $dx, $this->y + 0.5 * $h - 0.5 * $this->FontSize, $width, $this->FontSize, $link);
2034
				}
2035
			}
2036
			if($s) {
2037
				$this->_out($s);
2038
			}
2039
			$this->lasth = $h;
0 ignored issues
show
Documentation Bug introduced by
It seems like $h of type integer is incompatible with the declared type object<height> of property $lasth.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
2040
			if($ln>0) {
2041
				//Go to next line
2042
				$this->y += $h;
2043
				if($ln == 1) {
2044
					$this->x = $this->lMargin;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->lMargin of type object<left> is incompatible with the declared type object<current> of property $x.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
2045
				}
2046
			}
2047
			else {
2048
				$this->x += $w;
2049
			}
2050
		}
2051
2052
		/**
2053
		* This method allows printing text with line breaks. They can be automatic (as soon as the text reaches the right border of the cell) or explicit (via the \n character). As many cells as necessary are output, one below the other.<br />
2054
		* Text can be aligned, centered or justified. The cell block can be framed and the background painted.
2055
		* @param float $w Width of cells. If 0, they extend up to the right margin of the page.
2056
		* @param float $h Height of cells.
2057
		* @param string $txt String to print
2058
		* @param mixed $border Indicates if borders must be drawn around the cell block. The value can be either a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul>or a string containing some or all of the following characters (in any order):<ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul>
2059
		* @param string $align Allows to center or align the text. Possible values are:<ul><li>L or empty string: left align</li><li>C: center</li><li>R: right align</li><li>J: justification (default value)</li></ul>
2060
		* @param int $fill Indicates if the cell background must be painted (1) or transparent (0). Default value: 0.
2061
		* @param int $ln Indicates where the current position should go after the call. Possible values are:<ul><li>0: to the right</li><li>1: to the beginning of the next line [DEFAULT]</li><li>2: below</li></ul>
2062
		* @since 1.3
2063
		* @see SetFont(), SetDrawColor(), SetFillColor(), SetTextColor(), SetLineWidth(), Cell(), Write(), SetAutoPageBreak()
2064
		*/
2065
		function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=0, $ln=1) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
2066
2067
			// save current position
2068
			$prevx = $this->x;
2069
			$prevy = $this->y;
2070
2071
			//Output text with automatic or explicit line breaks
2072
			$cw = &$this->CurrentFont['cw'];
2073
2074
			if($w == 0) {
2075
				$w = $this->w - $this->rMargin - $this->x;
2076
			}
2077
2078
			$wmax = ($w - 2 * $this->cMargin);
2079
2080
			$s = str_replace("\r", '', $txt); // remove carriage returns
2081
			$nb = strlen($s);
2082
2083
			$b=0;
2084
			if($border) {
2085
				if($border==1) {
2086
					$border='LTRB';
2087
					$b='LRT';
2088
					$b2='LR';
2089
				}
2090
				else {
2091
					$b2='';
2092
					if(strpos($border,'L')!==false) {
2093
						$b2.='L';
2094
					}
2095
					if(strpos($border,'R')!==false) {
2096
						$b2.='R';
2097
					}
2098
					$b=(strpos($border,'T')!==false) ? $b2.'T' : $b2;
2099
				}
2100
			}
2101
			$sep=-1;
2102
			$i=0;
2103
			$j=0;
2104
			$l=0;
2105
			$ns=0;
2106
			$nl=1;
2107
			while($i<$nb) {
2108
				//Get next character
2109
				$c = $s{$i};
2110
				if(preg_match("/[\n]/u", $c)) {
2111
					//Explicit line break
2112
					if($this->ws > 0) {
2113
						$this->ws = 0;
0 ignored issues
show
Documentation Bug introduced by
It seems like 0 of type integer is incompatible with the declared type object<word> of property $ws.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
2114
						$this->_out('0 Tw');
2115
					}
2116
					$this->Cell($w, $h, substr($s, $j, $i-$j), $b, 2, $align, $fill);
2117
					$i++;
2118
					$sep=-1;
2119
					$j=$i;
2120
					$l=0;
2121
					$ns=0;
2122
					$nl++;
2123
					if($border and $nl==2) {
2124
						$b = $b2;
0 ignored issues
show
Bug introduced by
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

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
2125
					}
2126
					continue;
2127
				}
2128
				if(preg_match("/[ ]/u", $c)) {
2129
					$sep = $i;
2130
					$ls = $l;
2131
					$ns++;
2132
				}
2133
2134
				$l = $this->GetStringWidth(substr($s, $j, $i-$j));
2135
2136
				if($l > $wmax) {
2137
					//Automatic line break
2138
					if($sep == -1) {
2139
						if($i == $j) {
2140
							$i++;
2141
						}
2142
						if($this->ws > 0) {
2143
							$this->ws = 0;
2144
							$this->_out('0 Tw');
2145
						}
2146
						$this->Cell($w, $h, substr($s, $j, $i-$j), $b, 2, $align, $fill);
2147
					}
2148
					else {
2149
						if($align=='J') {
2150
							$this->ws = ($ns>1) ? ($wmax-$ls)/($ns-1) : 0;
0 ignored issues
show
Bug introduced by
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

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
Documentation Bug introduced by
It seems like $ns > 1 ? ($wmax - $ls) / ($ns - 1) : 0 of type integer or double is incompatible with the declared type object<word> of property $ws.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
2151
							$this->_out(sprintf('%.3f Tw', $this->ws * $this->k));
2152
						}
2153
						$this->Cell($w, $h, substr($s, $j, $sep-$j), $b, 2, $align, $fill);
2154
						$i = $sep + 1;
2155
					}
2156
					$sep=-1;
2157
					$j=$i;
2158
					$l=0;
2159
					$ns=0;
2160
					$nl++;
2161
					if($border AND ($nl==2)) {
2162
						$b=$b2;
2163
					}
2164
				}
2165
				else {
2166
					$i++;
2167
				}
2168
			}
2169
			//Last chunk
2170
			if($this->ws>0) {
2171
				$this->ws=0;
2172
				$this->_out('0 Tw');
2173
			}
2174
			if($border and is_int(strpos($border,'B'))) {
2175
				$b.='B';
2176
			}
2177
			$this->Cell($w, $h, substr($s, $j, $i-$j), $b, 2, $align, $fill);
2178
2179
			// move cursor to specified position
2180
			// since: 2007-03-03
2181
			 if($ln == 1) {
2182
				// go to the beginning of the next line
2183
				$this->x = $this->lMargin;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->lMargin of type object<left> is incompatible with the declared type object<current> of property $x.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
2184
			} elseif($ln == 0) {
2185
				// go to the top-right of the cell
2186
				$this->y = $prevy;
2187
				$this->x = $prevx + $w;
2188
			} elseif($ln == 2) {
2189
				// go to the bottom-left of the cell
2190
				$this->x = $prevx;
2191
			}
2192
		}
2193
2194
		/**
2195
		* This method prints text from the current position. When the right margin is reached (or the \n character is met) a line break occurs and text continues from the left margin. Upon method exit, the current position is left just at the end of the text. It is possible to put a link on the text.<br />
2196
		* <b>Example:</b><br />
2197
		* <pre>
2198
		* //Begin with regular font
2199
		* $pdf->SetFont('Arial','',14);
2200
		* $pdf->Write(5,'Visit ');
2201
		* //Then put a blue underlined link
2202
		* $pdf->SetTextColor(0,0,255);
2203
		* $pdf->SetFont('','U');
2204
		* $pdf->Write(5,'www.tecnick.com','http://www.tecnick.com');
2205
		* </pre>
2206
		* @param float $h Line height
2207
		* @param string $txt String to print
2208
		* @param mixed $link URL or identifier returned by AddLink()
2209
		* @param int $fill Indicates if the background must be painted (1) or transparent (0). Default value: 0.
2210
		* @since 1.5
2211
		* @see SetFont(), SetTextColor(), AddLink(), MultiCell(), SetAutoPageBreak()
2212
		*/
2213
		function Write($h, $txt, $link='', $fill=0) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
2214
2215
			//Output text in flowing mode
2216
			$cw = &$this->CurrentFont['cw'];
2217
			$w = $this->w - $this->rMargin - $this->x;
2218
			$wmax = ($w - 2 * $this->cMargin);
2219
2220
			$s = str_replace("\r", '', $txt);
2221
			$nb = strlen($s);
2222
2223
			// handle single space character
2224
			if(($nb==1) AND preg_match("/[ ]/u", $s)) {
2225
				$this->x += $this->GetStringWidth($s);
2226
				return;
2227
			}
2228
2229
			$sep=-1;
2230
			$i=0;
2231
			$j=0;
2232
			$l=0;
0 ignored issues
show
Unused Code introduced by
$l is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
2233
			$nl=1;
2234
			while($i<$nb) {
2235
				//Get next character
2236
				$c=$s{$i};
2237
				if(preg_match("/[\n]/u", $c)) {
2238
					//Explicit line break
2239
					$this->Cell($w, $h, substr($s, $j, $i-$j), 0, 2, '', $fill, $link);
2240
					$i++;
2241
					$sep = -1;
2242
					$j = $i;
2243
					$l = 0;
0 ignored issues
show
Unused Code introduced by
$l is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
2244 View Code Duplication
					if($nl == 1) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2245
						$this->x = $this->lMargin;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->lMargin of type object<left> is incompatible with the declared type object<current> of property $x.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
2246
						$w = $this->w - $this->rMargin - $this->x;
2247
						$wmax = ($w - 2 * $this->cMargin);
2248
					}
2249
					$nl++;
2250
					continue;
2251
				}
2252
				if(preg_match("/[ ]/u", $c)) {
2253
					$sep= $i;
2254
				}
2255
2256
				$l = $this->GetStringWidth(substr($s, $j, $i-$j));
2257
2258
				if($l > $wmax) {
2259
					//Automatic line break (word wrapping)
2260
					if($sep == -1) {
2261
						if($this->x > $this->lMargin) {
2262
							//Move to next line
2263
							$this->x = $this->lMargin;
2264
							$this->y += $h;
2265
							$w=$this->w - $this->rMargin - $this->x;
2266
							$wmax=($w - 2 * $this->cMargin);
2267
							$i++;
2268
							$nl++;
2269
							continue;
2270
						}
2271
						if($i==$j) {
2272
							$i++;
2273
						}
2274
						$this->Cell($w, $h, substr($s, $j, $i-$j), 0, 2, '', $fill, $link);
2275
					}
2276
					else {
2277
						$this->Cell($w, $h, substr($s, $j, $sep-$j), 0, 2, '', $fill, $link);
2278
						$i=$sep+1;
2279
					}
2280
					$sep = -1;
2281
					$j = $i;
2282
					$l = 0;
0 ignored issues
show
Unused Code introduced by
$l is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
2283 View Code Duplication
					if($nl==1) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2284
						$this->x = $this->lMargin;
2285
						$w = $this->w - $this->rMargin - $this->x;
2286
						$wmax = ($w - 2 * $this->cMargin);
2287
					}
2288
					$nl++;
2289
				}
2290
				else {
2291
					$i++;
2292
				}
2293
			}
2294
2295
			//Last chunk
2296
			if($i!=$j) {
2297
				$this->Cell($this->GetStringWidth(substr($s, $j)), $h, substr($s, $j), 0, 0, '', $fill, $link);
2298
			}
2299
		}
2300
2301
		/**
2302
		* Puts an image in the page. The upper-left corner must be given. The dimensions can be specified in different ways:<ul><li>explicit width and height (expressed in user unit)</li><li>one explicit dimension, the other being calculated automatically in order to keep the original proportions</li><li>no explicit dimension, in which case the image is put at 72 dpi</li></ul>
2303
		* Supported formats are JPEG and PNG.
2304
		* For JPEG, all flavors are allowed:<ul><li>gray scales</li><li>true colors (24 bits)</li><li>CMYK (32 bits)</li></ul>
2305
		* For PNG, are allowed:<ul><li>gray scales on at most 8 bits (256 levels)</li><li>indexed colors</li><li>true colors (24 bits)</li></ul>
2306
		* but are not supported:<ul><li>Interlacing</li><li>Alpha channel</li></ul>
2307
		* If a transparent color is defined, it will be taken into account (but will be only interpreted by Acrobat 4 and above).<br />
2308
		* The format can be specified explicitly or inferred from the file extension.<br />
2309
		* It is possible to put a link on the image.<br />
2310
		* Remark: if an image is used several times, only one copy will be embedded in the file.<br />
2311
		* @param string $file Name of the file containing the image.
2312
		* @param float $x Abscissa of the upper-left corner.
2313
		* @param float $y Ordinate of the upper-left corner.
2314
		* @param float $w Width of the image in the page. If not specified or equal to zero, it is automatically calculated.
0 ignored issues
show
Documentation introduced by
Should the type for parameter $w not be integer?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
2315
		* @param float $h Height of the image in the page. If not specified or equal to zero, it is automatically calculated.
0 ignored issues
show
Documentation introduced by
Should the type for parameter $h not be integer?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
2316
		* @param string $type Image format. Possible values are (case insensitive): JPG, JPEG, PNG. If not specified, the type is inferred from the file extension.
2317
		* @param mixed $link URL or identifier returned by AddLink().
2318
		* @since 1.1
2319
		* @see AddLink()
2320
		*/
2321
		function Image($file, $x, $y, $w=0, $h=0, $type='', $link='') {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
2322
			//Put an image on the page
2323
			if(!isset($this->images[$file])) {
2324
				//First use of image, get info
2325
				if($type == '') {
2326
					$pos = strrpos($file,'.');
2327
					if(empty($pos)) {
2328
						$this->Error('Image file has no extension and no type was specified: '.$file);
2329
					}
2330
					$type = substr($file, $pos+1);
2331
				}
2332
				$type = strtolower($type);
2333
				$mqr = get_magic_quotes_runtime();
2334
				set_magic_quotes_runtime(0);
2335
				if($type == 'jpg' or $type == 'jpeg') {
2336
					$info=$this->_parsejpg($file);
2337
				}
2338
				elseif($type == 'png') {
2339
					$info=$this->_parsepng($file);
2340
				}
2341
				else {
2342
					//Allow for additional formats
2343
					$mtd='_parse'.$type;
2344
					if(!method_exists($this,$mtd)) {
2345
						$this->Error('Unsupported image type: '.$type);
2346
					}
2347
					$info=$this->$mtd($file);
2348
				}
2349
				set_magic_quotes_runtime($mqr);
2350
				$info['i']=count($this->images)+1;
2351
				$this->images[$file]=$info;
2352
			}
2353
			else {
2354
				$info=$this->images[$file];
2355
			}
2356
			//Automatic width and height calculation if needed
2357
			if(($w == 0) and ($h == 0)) {
2358
				//Put image at 72 dpi
2359
				// 2004-06-14 :: Nicola Asuni, scale factor where added
2360
				$w = $info['w'] / ($this->imgscale * $this->k);
2361
				$h = $info['h'] / ($this->imgscale * $this->k);
2362
			}
2363
			if($w == 0) {
2364
				$w = $h * $info['w'] / $info['h'];
2365
			}
2366
			if($h == 0) {
2367
				$h = $w * $info['h'] / $info['w'];
2368
			}
2369
			$this->_out(sprintf('q %.2f 0 0 %.2f %.2f %.2f cm /I%d Do Q', $w*$this->k, $h*$this->k, $x*$this->k, ($this->h-($y+$h))*$this->k, $info['i']));
2370
			if($link) {
2371
				$this->Link($x, $y, $w, $h, $link);
2372
			}
2373
2374
			//2002-07-31 - Nicola Asuni
2375
			// set right-bottom corner coordinates
2376
			$this->img_rb_x = $x + $w;
2377
			$this->img_rb_y = $y + $h;
2378
		}
2379
2380
		/**
2381
		* Performs a line break. The current abscissa goes back to the left margin and the ordinate increases by the amount passed in parameter.
2382
		* @param float $h The height of the break. By default, the value equals the height of the last printed cell.
0 ignored issues
show
Documentation introduced by
Should the type for parameter $h not be string|double?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
2383
		* @since 1.0
2384
		* @see Cell()
2385
		*/
2386
		function Ln($h='') {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
2387
			//Line feed; default value is last cell height
2388
			$this->x=$this->lMargin;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->lMargin of type object<left> is incompatible with the declared type object<current> of property $x.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
2389
			if(is_string($h)) {
2390
				$this->y+=$this->lasth;
2391
			}
2392
			else {
2393
				$this->y+=$h;
2394
			}
2395
		}
2396
2397
		/**
2398
		* Returns the abscissa of the current position.
2399
		* @return float
0 ignored issues
show
Documentation introduced by
Should the return type not be current?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
2400
		* @since 1.2
2401
		* @see SetX(), GetY(), SetY()
2402
		*/
2403
		function GetX() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
2404
			//Get x position
2405
			return $this->x;
2406
		}
2407
2408
		/**
2409
		* Defines the abscissa of the current position. If the passed value is negative, it is relative to the right of the page.
2410
		* @param float $x The value of the abscissa.
2411
		* @since 1.2
2412
		* @see GetX(), GetY(), SetY(), SetXY()
2413
		*/
2414
		function SetX($x) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
2415
			//Set x position
2416
			if($x>=0) {
2417
				$this->x=$x;
0 ignored issues
show
Documentation Bug introduced by
It seems like $x of type double is incompatible with the declared type object<current> of property $x.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
2418
			}
2419
			else {
2420
				$this->x=$this->w+$x;
2421
			}
2422
		}
2423
2424
		/**
2425
		* Returns the ordinate of the current position.
2426
		* @return float
0 ignored issues
show
Documentation introduced by
Should the return type not be current?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
2427
		* @since 1.0
2428
		* @see SetY(), GetX(), SetX()
2429
		*/
2430
		function GetY() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
2431
			//Get y position
2432
			return $this->y;
2433
		}
2434
2435
		/**
2436
		* Moves the current abscissa back to the left margin and sets the ordinate. If the passed value is negative, it is relative to the bottom of the page.
2437
		* @param float $y The value of the ordinate.
2438
		* @since 1.0
2439
		* @see GetX(), GetY(), SetY(), SetXY()
2440
		*/
2441
		function SetY($y) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
2442
			//Set y position and reset x
2443
			$this->x=$this->lMargin;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->lMargin of type object<left> is incompatible with the declared type object<current> of property $x.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
2444
			if($y>=0) {
2445
				$this->y=$y;
0 ignored issues
show
Documentation Bug introduced by
It seems like $y of type double is incompatible with the declared type object<current> of property $y.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
2446
			}
2447
			else {
2448
				$this->y=$this->h+$y;
2449
			}
2450
		}
2451
2452
		/**
2453
		* Defines the abscissa and ordinate of the current position. If the passed values are negative, they are relative respectively to the right and bottom of the page.
2454
		* @param float $x The value of the abscissa
2455
		* @param float $y The value of the ordinate
2456
		* @since 1.2
2457
		* @see SetX(), SetY()
2458
		*/
2459
		function SetXY($x, $y) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
2460
			//Set x and y positions
2461
			$this->SetY($y);
2462
			$this->SetX($x);
2463
		}
2464
2465
		/**
2466
		* Send the document to a given destination: string, local file or browser. In the last case, the plug-in may be used (if present) or a download ("Save as" dialog box) may be forced.<br />
2467
		* The method first calls Close() if necessary to terminate the document.
2468
		* @param string $name The name of the file. If not given, the document will be sent to the browser (destination I) with the name doc.pdf.
2469
		* @param string $dest Destination where to send the document. It can take one of the following values:<ul><li>I: send the file inline to the browser. The plug-in is used if available. The name given by name is used when one selects the "Save as" option on the link generating the PDF.</li><li>D: send to the browser and force a file download with the name given by name.</li><li>F: save to a local file with the name given by name.</li><li>S: return the document as a string. name is ignored.</li></ul>If the parameter is not specified but a name is given, destination is F. If no parameter is specified at all, destination is I.<br />Note: for compatibility with previous versions, a boolean value is also accepted (false for F and true for D).
2470
		* @since 1.0
2471
		* @see Close()
2472
		*/
2473
		function Output($name='',$dest='') {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
2474
			//Output PDF to some destination
2475
			//Finish document if necessary
2476
			if($this->state < 3) {
2477
				$this->Close();
2478
			}
2479
			//Normalize parameters
2480
			if(is_bool($dest)) {
2481
				$dest=$dest ? 'D' : 'F';
2482
			}
2483
			$dest=strtoupper($dest);
2484
			if($dest=='') {
2485
				if($name=='') {
2486
					$name='doc.pdf';
2487
					$dest='I';
2488
				} else {
2489
					$dest='F';
2490
				}
2491
			}
2492
			switch($dest) {
2493
				case 'I': {
2494
					//Send to standard output
2495
					if(ob_get_contents()) {
2496
						$this->Error('Some data has already been output, can\'t send PDF file');
2497
					}
2498
					if(php_sapi_name()!='cli') {
2499
						//We send to a browser
2500
						header('Content-Type: application/pdf');
2501
						if(headers_sent()) {
2502
							$this->Error('Some data has already been output to browser, can\'t send PDF file');
2503
						}
2504
						header('Content-Length: '.strlen($this->buffer));
2505
						header('Content-disposition: inline; filename="'.$name.'"');
2506
					}
2507
					echo $this->buffer;
2508
					break;
2509
				}
2510
				case 'D': {
2511
					//Download file
2512
					if(ob_get_contents()) {
2513
						$this->Error('Some data has already been output, can\'t send PDF file');
2514
					}
2515
					if(isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')) {
2516
						header('Content-Type: application/force-download');
2517
					} else {
2518
						header('Content-Type: application/octet-stream');
2519
					}
2520
					if(headers_sent()) {
2521
						$this->Error('Some data has already been output to browser, can\'t send PDF file');
2522
					}
2523
					header('Content-Length: '.strlen($this->buffer));
2524
					header('Content-disposition: attachment; filename="'.$name.'"');
2525
					echo $this->buffer;
2526
					break;
2527
				}
2528
				case 'F': {
2529
					//Save to local file
2530
					$f=fopen($name,'wb');
2531
					if(!$f) {
2532
						$this->Error('Unable to create output file: '.$name);
2533
					}
2534
					fwrite($f,$this->buffer,strlen($this->buffer));
2535
					fclose($f);
2536
					break;
2537
				}
2538
				case 'S': {
2539
					//Return as a string
2540
					return $this->buffer;
2541
				}
2542
				default: {
2543
					$this->Error('Incorrect output destination: '.$dest);
2544
				}
2545
			}
2546
			return '';
2547
		}
2548
2549
		// var methods
2550
2551
		/**
2552
		* Check for locale-related bug
2553
		* @access protected
2554
		*/
2555
		function _dochecks() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
2556
			//Check for locale-related bug
2557
			if(1.1==1) {
2558
				$this->Error('Don\'t alter the locale before including class file');
2559
			}
2560
			//Check for decimal separator
2561
			if(sprintf('%.1f',1.0)!='1.0') {
2562
				setlocale(LC_NUMERIC,'C');
2563
			}
2564
		}
2565
2566
		/**
2567
		* Return fonts path
2568
		* @access protected
2569
		*/
2570
		function _getfontpath() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
2571
			if(!defined('FPDF_FONTPATH') AND is_dir(dirname(__FILE__).'/font')) {
2572
				define('FPDF_FONTPATH', dirname(__FILE__).'/font/');
2573
			}
2574
			return defined('FPDF_FONTPATH') ? FPDF_FONTPATH : '';
2575
		}
2576
2577
		/**
2578
		* Start document
2579
		* @access protected
2580
		*/
2581
		function _begindoc() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
2582
			//Start document
2583
			$this->state=1;
0 ignored issues
show
Documentation Bug introduced by
It seems like 1 of type integer is incompatible with the declared type object<current> of property $state.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
2584
			$this->_out('%PDF-1.3');
2585
		}
2586
2587
		/**
2588
		* _putpages
2589
		* @access protected
2590
		*/
2591
		function _putpages() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
2592
			$nb = $this->page;
2593
			if(!empty($this->AliasNbPages)) {
2594
				$nbstr = $this->UTF8ToUTF16BE($nb, false);
2595
				//Replace number of pages
2596
				for($n=1;$n<=$nb;$n++) {
2597
					$this->pages[$n]=str_replace($this->AliasNbPages, $nbstr, $this->pages[$n]);
2598
				}
2599
			}
2600
			if($this->DefOrientation=='P') {
2601
				$wPt=$this->fwPt;
2602
				$hPt=$this->fhPt;
2603
			}
2604
			else {
2605
				$wPt=$this->fhPt;
2606
				$hPt=$this->fwPt;
2607
			}
2608
			$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
2609
			for($n=1;$n<=$nb;$n++) {
2610
				//Page
2611
				$this->_newobj();
2612
				$this->_out('<</Type /Page');
2613
				$this->_out('/Parent 1 0 R');
2614
				if(isset($this->OrientationChanges[$n])) {
2615
					$this->_out(sprintf('/MediaBox [0 0 %.2f %.2f]',$hPt,$wPt));
2616
				}
2617
				$this->_out('/Resources 2 0 R');
2618
				if(isset($this->PageLinks[$n])) {
2619
					//Links
2620
					$annots='/Annots [';
2621
					foreach($this->PageLinks[$n] as $pl) {
2622
						$rect=sprintf('%.2f %.2f %.2f %.2f',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]);
2623
						$annots.='<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] ';
2624
						if(is_string($pl[4])) {
2625
							$annots.='/A <</S /URI /URI ('.$this->_escape($pl[4]).')>>>>';
2626
						}
2627
						else {
2628
							$l=$this->links[$pl[4]];
2629
							$h=isset($this->OrientationChanges[$l[0]]) ? $wPt : $hPt;
2630
							$annots.=sprintf('/Dest [%d 0 R /XYZ 0 %.2f null]>>',1+2*$l[0],$h-$l[1]*$this->k);
2631
						}
2632
					}
2633
					$this->_out($annots.']');
2634
				}
2635
				$this->_out('/Contents '.($this->n+1).' 0 R>>');
2636
				$this->_out('endobj');
2637
				//Page content
2638
				$p=($this->compress) ? gzcompress($this->pages[$n]) : $this->pages[$n];
2639
				$this->_newobj();
2640
				$this->_out('<<'.$filter.'/Length '.strlen($p).'>>');
2641
				$this->_putstream($p);
2642
				$this->_out('endobj');
2643
			}
2644
			//Pages root
2645
			$this->offsets[1]=strlen($this->buffer);
2646
			$this->_out('1 0 obj');
2647
			$this->_out('<</Type /Pages');
2648
			$kids='/Kids [';
2649
			for($i=0;$i<$nb;$i++) {
2650
				$kids.=(3+2*$i).' 0 R ';
2651
			}
2652
			$this->_out($kids.']');
2653
			$this->_out('/Count '.$nb);
2654
			$this->_out(sprintf('/MediaBox [0 0 %.2f %.2f]',$wPt,$hPt));
2655
			$this->_out('>>');
2656
			$this->_out('endobj');
2657
		}
2658
2659
		/**
2660
		* Adds fonts
2661
		* _putfonts
2662
		* @access protected
2663
		*/
2664
		function _putfonts() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
2665
			$nf=$this->n;
2666
			foreach($this->diffs as $diff) {
2667
				//Encodings
2668
				$this->_newobj();
2669
				$this->_out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.']>>');
2670
				$this->_out('endobj');
2671
			}
2672
			$mqr=get_magic_quotes_runtime();
2673
			set_magic_quotes_runtime(0);
2674
			foreach($this->FontFiles as $file=>$info) {
2675
				//Font file embedding
2676
				$this->_newobj();
2677
				$this->FontFiles[$file]['n']=$this->n;
2678
				$font='';
2679
				$f=fopen($this->_getfontpath().$file,'rb',1);
2680
				if(!$f) {
2681
					$this->Error('Font file not found');
2682
				}
2683
				while(!feof($f)) {
2684
					$font .= fread($f, 8192);
2685
				}
2686
				fclose($f);
2687
				$compressed=(substr($file,-2)=='.z');
2688
				if(!$compressed && isset($info['length2'])) {
2689
					$header=(ord($font{0})==128);
2690
					if($header) {
2691
						//Strip first binary header
2692
						$font=substr($font,6);
2693
					}
2694
					if($header && ord($font{$info['length1']})==128) {
2695
						//Strip second binary header
2696
						$font=substr($font,0,$info['length1']).substr($font,$info['length1']+6);
2697
					}
2698
				}
2699
				$this->_out('<</Length '.strlen($font));
2700
				if($compressed) {
2701
					$this->_out('/Filter /FlateDecode');
2702
				}
2703
				$this->_out('/Length1 '.$info['length1']);
2704
				if(isset($info['length2'])) {
2705
					$this->_out('/Length2 '.$info['length2'].' /Length3 0');
2706
				}
2707
				$this->_out('>>');
2708
				$this->_putstream($font);
2709
				$this->_out('endobj');
2710
			}
2711
			set_magic_quotes_runtime($mqr);
2712
			foreach($this->fonts as $k=>$font) {
2713
				//Font objects
2714
				$this->fonts[$k]['n']=$this->n+1;
2715
				$type=$font['type'];
2716
				$name=$font['name'];
2717
				if($type=='core') {
2718
					//Standard font
2719
					$this->_newobj();
2720
					$this->_out('<</Type /Font');
2721
					$this->_out('/BaseFont /'.$name);
2722
					$this->_out('/Subtype /Type1');
2723
					if($name!='Symbol' && $name!='ZapfDingbats') {
2724
						$this->_out('/Encoding /WinAnsiEncoding');
2725
					}
2726
					$this->_out('>>');
2727
					$this->_out('endobj');
2728
				} elseif($type=='Type1' || $type=='TrueType') {
2729
					//Additional Type1 or TrueType font
2730
					$this->_newobj();
2731
					$this->_out('<</Type /Font');
2732
					$this->_out('/BaseFont /'.$name);
2733
					$this->_out('/Subtype /'.$type);
2734
					$this->_out('/FirstChar 32 /LastChar 255');
2735
					$this->_out('/Widths '.($this->n+1).' 0 R');
2736
					$this->_out('/FontDescriptor '.($this->n+2).' 0 R');
2737
					if($font['enc']) {
2738
						if(isset($font['diff'])) {
2739
							$this->_out('/Encoding '.($nf+$font['diff']).' 0 R');
2740
						} else {
2741
							$this->_out('/Encoding /WinAnsiEncoding');
2742
						}
2743
					}
2744
					$this->_out('>>');
2745
					$this->_out('endobj');
2746
					//Widths
2747
					$this->_newobj();
2748
					$cw=&$font['cw'];
2749
					$s='[';
2750
					for($i=32;$i<=255;$i++) {
2751
						$s.=$cw[chr($i)].' ';
2752
					}
2753
					$this->_out($s.']');
2754
					$this->_out('endobj');
2755
					//Descriptor
2756
					$this->_newobj();
2757
					$s='<</Type /FontDescriptor /FontName /'.$name;
2758
					foreach($font['desc'] as $k=>$v) {
2759
						$s.=' /'.$k.' '.$v;
2760
					}
2761
					$file = $font['file'];
2762
					if($file) {
2763
						$s.=' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R';
2764
					}
2765
					$this->_out($s.'>>');
2766
					$this->_out('endobj');
2767
				} else {
2768
					//Allow for additional types
2769
					$mtd='_put'.strtolower($type);
2770
					if(!method_exists($this, $mtd)) {
2771
						$this->Error('Unsupported font type: '.$type);
2772
					}
2773
					$this->$mtd($font);
2774
				}
2775
			}
2776
		}
2777
2778
		/**
2779
		* _putimages
2780
		* @access protected
2781
		*/
2782
		function _putimages() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
2783
			$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
2784
			reset($this->images);
2785
			while(list($file,$info)=each($this->images)) {
2786
				$this->_newobj();
2787
				$this->images[$file]['n']=$this->n;
2788
				$this->_out('<</Type /XObject');
2789
				$this->_out('/Subtype /Image');
2790
				$this->_out('/Width '.$info['w']);
2791
				$this->_out('/Height '.$info['h']);
2792
				if($info['cs']=='Indexed') {
2793
					$this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]');
2794
				}
2795
				else {
2796
					$this->_out('/ColorSpace /'.$info['cs']);
2797
					if($info['cs']=='DeviceCMYK') {
2798
						$this->_out('/Decode [1 0 1 0 1 0 1 0]');
2799
					}
2800
				}
2801
				$this->_out('/BitsPerComponent '.$info['bpc']);
2802
				if(isset($info['f'])) {
2803
					$this->_out('/Filter /'.$info['f']);
2804
				}
2805
				if(isset($info['parms'])) {
2806
					$this->_out($info['parms']);
2807
				}
2808
				if(isset($info['trns']) and is_array($info['trns'])) {
2809
					$trns='';
2810
					for($i=0;$i<count($info['trns']);$i++) {
0 ignored issues
show
Performance Best Practice introduced by
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...
2811
						$trns.=$info['trns'][$i].' '.$info['trns'][$i].' ';
2812
					}
2813
					$this->_out('/Mask ['.$trns.']');
2814
				}
2815
				$this->_out('/Length '.strlen($info['data']).'>>');
2816
				$this->_putstream($info['data']);
2817
				unset($this->images[$file]['data']);
2818
				$this->_out('endobj');
2819
				//Palette
2820
				if($info['cs']=='Indexed') {
2821
					$this->_newobj();
2822
					$pal=($this->compress) ? gzcompress($info['pal']) : $info['pal'];
2823
					$this->_out('<<'.$filter.'/Length '.strlen($pal).'>>');
2824
					$this->_putstream($pal);
2825
					$this->_out('endobj');
2826
				}
2827
			}
2828
		}
2829
2830
		/**
2831
		* _putxobjectdict
2832
		* @access protected
2833
		*/
2834
		function _putxobjectdict() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
2835
			foreach($this->images as $image) {
2836
				$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
2837
			}
2838
		}
2839
2840
		/**
2841
		* _putresourcedict
2842
		* @access protected
2843
		*/
2844
		function _putresourcedict(){
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
2845
			$this->_out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
2846
			$this->_out('/Font <<');
2847
			foreach($this->fonts as $font) {
2848
				$this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
2849
			}
2850
			$this->_out('>>');
2851
			$this->_out('/XObject <<');
2852
			$this->_putxobjectdict();
2853
			$this->_out('>>');
2854
		}
2855
2856
		/**
2857
		* _putresources
2858
		* @access protected
2859
		*/
2860
		function _putresources() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
2861
			$this->_putfonts();
2862
			$this->_putimages();
2863
			//Resource dictionary
2864
			$this->offsets[2]=strlen($this->buffer);
2865
			$this->_out('2 0 obj');
2866
			$this->_out('<<');
2867
			$this->_putresourcedict();
2868
			$this->_out('>>');
2869
			$this->_out('endobj');
2870
		}
2871
2872
		/**
2873
		* _putinfo
2874
		* @access protected
2875
		*/
2876
		function _putinfo() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
2877
			$this->_out('/Producer '.$this->_textstring(PDF_PRODUCER));
2878
			if(!empty($this->title)) {
2879
				$this->_out('/Title '.$this->_textstring($this->title));
2880
			}
2881
			if(!empty($this->subject)) {
2882
				$this->_out('/Subject '.$this->_textstring($this->subject));
2883
			}
2884
			if(!empty($this->author)) {
2885
				$this->_out('/Author '.$this->_textstring($this->author));
2886
			}
2887
			if(!empty($this->keywords)) {
2888
				$this->_out('/Keywords '.$this->_textstring($this->keywords));
2889
			}
2890
			if(!empty($this->creator)) {
2891
				$this->_out('/Creator '.$this->_textstring($this->creator));
2892
			}
2893
			$this->_out('/CreationDate '.$this->_textstring('D:'.date('YmdHis')));
2894
		}
2895
2896
		/**
2897
		* _putcatalog
2898
		* @access protected
2899
		*/
2900
		function _putcatalog() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
2901
			$this->_out('/Type /Catalog');
2902
			$this->_out('/Pages 1 0 R');
2903
			if($this->ZoomMode=='fullpage') {
2904
				$this->_out('/OpenAction [3 0 R /Fit]');
2905
			}
2906
			elseif($this->ZoomMode=='fullwidth') {
2907
				$this->_out('/OpenAction [3 0 R /FitH null]');
2908
			}
2909
			elseif($this->ZoomMode=='real') {
2910
				$this->_out('/OpenAction [3 0 R /XYZ null null 1]');
2911
			}
2912
			elseif(!is_string($this->ZoomMode)) {
2913
				$this->_out('/OpenAction [3 0 R /XYZ null null '.($this->ZoomMode/100).']');
2914
			}
2915
			if($this->LayoutMode=='single') {
2916
				$this->_out('/PageLayout /SinglePage');
2917
			}
2918
			elseif($this->LayoutMode=='continuous') {
2919
				$this->_out('/PageLayout /OneColumn');
2920
			}
2921
			elseif($this->LayoutMode=='two') {
2922
				$this->_out('/PageLayout /TwoColumnLeft');
2923
			}
2924
		}
2925
2926
		/**
2927
		* _puttrailer
2928
		* @access protected
2929
		*/
2930
		function _puttrailer() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
2931
			$this->_out('/Size '.($this->n+1));
2932
			$this->_out('/Root '.$this->n.' 0 R');
2933
			$this->_out('/Info '.($this->n-1).' 0 R');
2934
		}
2935
2936
		/**
2937
		* _putheader
2938
		* @access protected
2939
		*/
2940
		function _putheader() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
2941
			$this->_out('%PDF-'.$this->PDFVersion);
2942
		}
2943
2944
		/**
2945
		* _enddoc
2946
		* @access protected
2947
		*/
2948
		function _enddoc() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
2949
			$this->_putheader();
2950
			$this->_putpages();
2951
			$this->_putresources();
2952
			//Info
2953
			$this->_newobj();
2954
			$this->_out('<<');
2955
			$this->_putinfo();
2956
			$this->_out('>>');
2957
			$this->_out('endobj');
2958
			//Catalog
2959
			$this->_newobj();
2960
			$this->_out('<<');
2961
			$this->_putcatalog();
2962
			$this->_out('>>');
2963
			$this->_out('endobj');
2964
			//Cross-ref
2965
			$o=strlen($this->buffer);
2966
			$this->_out('xref');
2967
			$this->_out('0 '.($this->n+1));
2968
			$this->_out('0000000000 65535 f ');
2969
			for($i=1;$i<=$this->n;$i++) {
2970
				$this->_out(sprintf('%010d 00000 n ',$this->offsets[$i]));
2971
			}
2972
			//Trailer
2973
			$this->_out('trailer');
2974
			$this->_out('<<');
2975
			$this->_puttrailer();
2976
			$this->_out('>>');
2977
			$this->_out('startxref');
2978
			$this->_out($o);
2979
			$this->_out('%%EOF');
2980
			$this->state=3;
0 ignored issues
show
Documentation Bug introduced by
It seems like 3 of type integer is incompatible with the declared type object<current> of property $state.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
2981
		}
2982
2983
		/**
2984
		* _beginpage
2985
		* @access protected
2986
		*/
2987
		function _beginpage($orientation) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
2988
			$this->page++;
2989
			$this->pages[$this->page]='';
2990
			$this->state=2;
0 ignored issues
show
Documentation Bug introduced by
It seems like 2 of type integer is incompatible with the declared type object<current> of property $state.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
2991
			$this->x=$this->lMargin;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->lMargin of type object<left> is incompatible with the declared type object<current> of property $x.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
2992
			$this->y=$this->tMargin;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->tMargin of type object<top> is incompatible with the declared type object<current> of property $y.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
2993
			$this->FontFamily='';
0 ignored issues
show
Documentation Bug introduced by
It seems like '' of type string is incompatible with the declared type object<current> of property $FontFamily.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
2994
			//Page orientation
2995
			if(empty($orientation)) {
2996
				$orientation=$this->DefOrientation;
2997
			}
2998
			else {
2999
				$orientation=strtoupper($orientation{0});
3000
				if($orientation!=$this->DefOrientation) {
3001
					$this->OrientationChanges[$this->page]=true;
3002
				}
3003
			}
3004
			if($orientation!=$this->CurOrientation) {
3005
				//Change orientation
3006
				if($orientation=='P') {
3007
					$this->wPt=$this->fwPt;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->fwPt of type object<width> is incompatible with the declared type object<current> of property $wPt.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3008
					$this->hPt=$this->fhPt;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->fhPt of type object<height> is incompatible with the declared type object<current> of property $hPt.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3009
					$this->w=$this->fw;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->fw of type object<width> is incompatible with the declared type object<current> of property $w.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3010
					$this->h=$this->fh;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->fh of type object<height> is incompatible with the declared type object<current> of property $h.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3011
				}
3012
				else {
3013
					$this->wPt=$this->fhPt;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->fhPt of type object<height> is incompatible with the declared type object<current> of property $wPt.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3014
					$this->hPt=$this->fwPt;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->fwPt of type object<width> is incompatible with the declared type object<current> of property $hPt.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3015
					$this->w=$this->fh;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->fh of type object<height> is incompatible with the declared type object<current> of property $w.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3016
					$this->h=$this->fw;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->fw of type object<width> is incompatible with the declared type object<current> of property $h.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3017
				}
3018
				$this->PageBreakTrigger=$this->h-$this->bMargin;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->h - $this->bMargin of type integer or double is incompatible with the declared type object<threshold> of property $PageBreakTrigger.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3019
				$this->CurOrientation=$orientation;
0 ignored issues
show
Documentation Bug introduced by
It seems like $orientation of type object<default> or string is incompatible with the declared type object<current> of property $CurOrientation.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3020
			}
3021
		}
3022
3023
		/**
3024
		* End of page contents
3025
		* @access protected
3026
		*/
3027
		function _endpage() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
3028
			$this->state=1;
0 ignored issues
show
Documentation Bug introduced by
It seems like 1 of type integer is incompatible with the declared type object<current> of property $state.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3029
		}
3030
3031
		/**
3032
		* Begin a new object
3033
		* @access protected
3034
		*/
3035
		function _newobj() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
3036
			$this->n++;
3037
			$this->offsets[$this->n]=strlen($this->buffer);
3038
			$this->_out($this->n.' 0 obj');
3039
		}
3040
3041
		/**
3042
		* Underline text
3043
		* @access protected
3044
		*/
3045
		function _dounderline($x,$y,$txt) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
3046
			$up = $this->CurrentFont['up'];
3047
			$ut = $this->CurrentFont['ut'];
3048
			$w = $this->GetStringWidth($txt) + $this->ws * substr_count($txt,' ');
3049
			return sprintf('%.2f %.2f %.2f %.2f re f', $x * $this->k, ($this->h - ($y - $up / 1000 * $this->FontSize)) * $this->k, $w * $this->k, -$ut / 1000 * $this->FontSizePt);
3050
		}
3051
3052
		/**
3053
		* Extract info from a JPEG file
3054
		* @access protected
3055
		*/
3056
		function _parsejpg($file) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
3057
			$a=GetImageSize($file);
3058
			if(empty($a)) {
3059
				$this->Error('Missing or incorrect image file: '.$file);
3060
			}
3061
			if($a[2]!=2) {
3062
				$this->Error('Not a JPEG file: '.$file);
3063
			}
3064
			if(!isset($a['channels']) or $a['channels']==3) {
3065
				$colspace='DeviceRGB';
3066
			}
3067
			elseif($a['channels']==4) {
3068
				$colspace='DeviceCMYK';
3069
			}
3070
			else {
3071
				$colspace='DeviceGray';
3072
			}
3073
			$bpc=isset($a['bits']) ? $a['bits'] : 8;
3074
			//Read whole file
3075
			$f=fopen($file,'rb');
3076
			$data='';
3077
			while(!feof($f)) {
3078
				$data.=fread($f,4096);
3079
			}
3080
			fclose($f);
3081
			return array('w'=>$a[0],'h'=>$a[1],'cs'=>$colspace,'bpc'=>$bpc,'f'=>'DCTDecode','data'=>$data);
3082
		}
3083
3084
		/**
3085
		* Extract info from a PNG file
3086
		* @access protected
3087
		*/
3088
		function _parsepng($file) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
3089
			$f=fopen($file,'rb');
3090
			if(empty($f)) {
3091
				$this->Error('Can\'t open image file: '.$file);
3092
			}
3093
			//Check signature
3094
			if(fread($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) {
3095
				$this->Error('Not a PNG file: '.$file);
3096
			}
3097
			//Read header chunk
3098
			fread($f,4);
3099
			if(fread($f,4)!='IHDR') {
3100
				$this->Error('Incorrect PNG file: '.$file);
3101
			}
3102
			$w=$this->_freadint($f);
3103
			$h=$this->_freadint($f);
3104
			$bpc=ord(fread($f,1));
3105
			if($bpc>8) {
3106
				$this->Error('16-bit depth not supported: '.$file);
3107
			}
3108
			$ct=ord(fread($f,1));
3109
			if($ct==0) {
3110
				$colspace='DeviceGray';
3111
			}
3112
			elseif($ct==2) {
3113
				$colspace='DeviceRGB';
3114
			}
3115
			elseif($ct==3) {
3116
				$colspace='Indexed';
3117
			}
3118
			else {
3119
				$this->Error('Alpha channel not supported: '.$file);
3120
			}
3121
			if(ord(fread($f,1))!=0) {
3122
				$this->Error('Unknown compression method: '.$file);
3123
			}
3124
			if(ord(fread($f,1))!=0) {
3125
				$this->Error('Unknown filter method: '.$file);
3126
			}
3127
			if(ord(fread($f,1))!=0) {
3128
				$this->Error('Interlacing not supported: '.$file);
3129
			}
3130
			fread($f,4);
3131
			$parms='/DecodeParms <</Predictor 15 /Colors '.($ct==2 ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w.'>>';
3132
			//Scan chunks looking for palette, transparency and image data
3133
			$pal='';
3134
			$trns='';
3135
			$data='';
3136
			do {
3137
				$n=$this->_freadint($f);
3138
				$type=fread($f,4);
3139
				if($type=='PLTE') {
3140
					//Read palette
3141
					$pal=fread($f,$n);
3142
					fread($f,4);
3143
				}
3144
				elseif($type=='tRNS') {
3145
					//Read transparency info
3146
					$t=fread($f,$n);
3147
					if($ct==0) {
3148
						$trns=array(ord(substr($t,1,1)));
3149
					}
3150
					elseif($ct==2) {
3151
						$trns=array(ord(substr($t,1,1)),ord(substr($t,3,1)),ord(substr($t,5,1)));
3152
					}
3153
					else {
3154
						$pos=strpos($t,chr(0));
3155
						if($pos!==false) {
3156
							$trns=array($pos);
3157
						}
3158
					}
3159
					fread($f,4);
3160
				}
3161
				elseif($type=='IDAT') {
3162
					//Read image data block
3163
					$data.=fread($f,$n);
3164
					fread($f,4);
3165
				}
3166
				elseif($type=='IEND') {
3167
					break;
3168
				}
3169
				else {
3170
					fread($f,$n+4);
3171
				}
3172
			}
3173
			while($n);
3174
			if($colspace=='Indexed' and empty($pal)) {
0 ignored issues
show
Bug introduced by
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

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
3175
				$this->Error('Missing palette in '.$file);
3176
			}
3177
			fclose($f);
3178
			return array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'parms'=>$parms, 'pal'=>$pal, 'trns'=>$trns, 'data'=>$data);
3179
		}
3180
3181
		/**
3182
		* Read a 4-byte integer from file
3183
		* @access protected
3184
		*/
3185
		function _freadint($f) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
3186
			//Read a 4-byte integer from file
3187
			$a=unpack('Ni',fread($f,4));
3188
			return $a['i'];
3189
		}
3190
3191
		/**
3192
		* Format a text string
3193
		* @access protected
3194
		*/
3195
		function _textstring($s) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
3196
			if($this->isunicode) {
3197
				//Convert string to UTF-16BE
3198
				$s = $this->UTF8ToUTF16BE($s, true);
3199
			}
3200
			return '('. $this->_escape($s).')';
3201
		}
3202
3203
		/**
3204
		* Format a text string
3205
		* @access protected
3206
		*/
3207
		function _escapetext($s) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
3208
			if($this->isunicode) {
3209
				//Convert string to UTF-16BE
3210
				$s = $this->UTF8ToUTF16BE($s, false);
3211
			}
3212
			return $this->_escape($s);
3213
		}
3214
3215
		/**
3216
		* Add \ before \, ( and )
3217
		* @access protected
3218
		*/
3219
		function _escape($s) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
3220
			// the chr(13) substitution fixes the Bugs item #1421290.
3221
			return strtr($s, array(')' => '\\)', '(' => '\\(', '\\' => '\\\\', chr(13) => '\r'));
3222
		}
3223
3224
		/**
3225
		*
3226
		* @access protected
3227
		*/
3228
		function _putstream($s) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
3229
			$this->_out('stream');
3230
			$this->_out($s);
3231
			$this->_out('endstream');
3232
		}
3233
3234
		/**
3235
		* Add a line to the document
3236
		* @access protected
3237
		*/
3238
		function _out($s) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
3239
			if($this->state==2) {
3240
				$this->pages[$this->page] .= $s."\n";
3241
			}
3242
			else {
3243
				$this->buffer .= $s."\n";
3244
			}
3245
		}
3246
3247
		/**
3248
		* Adds unicode fonts.<br>
3249
		* Based on PDF Reference 1.3 (section 5)
3250
		* @access protected
3251
		* @author Nicola Asuni
3252
		* @since 1.52.0.TC005 (2005-01-05)
3253
		*/
3254
		function _puttruetypeunicode($font) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
3255
			// Type0 Font
3256
			// A composite font—a font composed of other fonts, organized hierarchically
3257
			$this->_newobj();
3258
			$this->_out('<</Type /Font');
3259
			$this->_out('/Subtype /Type0');
3260
			$this->_out('/BaseFont /'.$font['name'].'');
3261
			$this->_out('/Encoding /Identity-H'); //The horizontal identity mapping for 2-byte CIDs; may be used with CIDFonts using any Registry, Ordering, and Supplement values.
3262
			$this->_out('/DescendantFonts ['.($this->n + 1).' 0 R]');
3263
			$this->_out('/ToUnicode '.($this->n + 2).' 0 R');
3264
			$this->_out('>>');
3265
			$this->_out('endobj');
3266
3267
			// CIDFontType2
3268
			// A CIDFont whose glyph descriptions are based on TrueType font technology
3269
			$this->_newobj();
3270
			$this->_out('<</Type /Font');
3271
			$this->_out('/Subtype /CIDFontType2');
3272
			$this->_out('/BaseFont /'.$font['name'].'');
3273
			$this->_out('/CIDSystemInfo '.($this->n + 2).' 0 R');
3274
			$this->_out('/FontDescriptor '.($this->n + 3).' 0 R');
3275
			if (isset($font['desc']['MissingWidth'])){
3276
				$this->_out('/DW '.$font['desc']['MissingWidth'].''); // The default width for glyphs in the CIDFont MissingWidth
3277
			}
3278
			$w = "";
3279
			foreach ($font['cw'] as $cid => $width) {
3280
				$w .= ''.$cid.' ['.$width.'] '; // define a specific width for each individual CID
3281
			}
3282
			$this->_out('/W ['.$w.']'); // A description of the widths for the glyphs in the CIDFont
3283
			$this->_out('/CIDToGIDMap '.($this->n + 4).' 0 R');
3284
			$this->_out('>>');
3285
			$this->_out('endobj');
3286
3287
			// ToUnicode
3288
			// is a stream object that contains the definition of the CMap
3289
			// (PDF Reference 1.3 chap. 5.9)
3290
			$this->_newobj();
3291
			$this->_out('<</Length 383>>');
3292
			$this->_out('stream');
3293
			$this->_out('/CIDInit /ProcSet findresource begin');
3294
			$this->_out('12 dict begin');
3295
			$this->_out('begincmap');
3296
			$this->_out('/CIDSystemInfo');
3297
			$this->_out('<</Registry (Adobe)');
3298
			$this->_out('/Ordering (UCS)');
3299
			$this->_out('/Supplement 0');
3300
			$this->_out('>> def');
3301
			$this->_out('/CMapName /Adobe-Identity-UCS def');
3302
			$this->_out('/CMapType 2 def');
3303
			$this->_out('1 begincodespacerange');
3304
			$this->_out('<0000> <FFFF>');
3305
			$this->_out('endcodespacerange');
3306
			$this->_out('1 beginbfrange');
3307
			$this->_out('<0000> <FFFF> <0000>');
3308
			$this->_out('endbfrange');
3309
			$this->_out('endcmap');
3310
			$this->_out('CMapName currentdict /CMap defineresource pop');
3311
			$this->_out('end');
3312
			$this->_out('end');
3313
			$this->_out('endstream');
3314
			$this->_out('endobj');
3315
3316
			// CIDSystemInfo dictionary
3317
			// A dictionary containing entries that define the character collection of the CIDFont.
3318
			$this->_newobj();
3319
			$this->_out('<</Registry (Adobe)'); // A string identifying an issuer of character collections
3320
			$this->_out('/Ordering (UCS)'); // A string that uniquely names a character collection issued by a specific registry
3321
			$this->_out('/Supplement 0'); // The supplement number of the character collection.
3322
			$this->_out('>>');
3323
			$this->_out('endobj');
3324
3325
			// Font descriptor
3326
			// A font descriptor describing the CIDFont’s default metrics other than its glyph widths
3327
			$this->_newobj();
3328
			$this->_out('<</Type /FontDescriptor');
3329
			$this->_out('/FontName /'.$font['name']);
3330
			foreach ($font['desc'] as $key => $value) {
3331
				$this->_out('/'.$key.' '.$value);
3332
			}
3333
			if ($font['file']) {
3334
				// A stream containing a TrueType font program
3335
				$this->_out('/FontFile2 '.$this->FontFiles[$font['file']]['n'].' 0 R');
3336
			}
3337
			$this->_out('>>');
3338
			$this->_out('endobj');
3339
3340
			// Embed CIDToGIDMap
3341
			// A specification of the mapping from CIDs to glyph indices
3342
			$this->_newobj();
3343
			$ctgfile = $this->_getfontpath().$font['ctg'];
3344
			if(!file_exists($ctgfile)) {
3345
				$this->Error('Font file not found: '.$ctgfile);
3346
			}
3347
			$size = filesize($ctgfile);
3348
			$this->_out('<</Length '.$size.'');
3349
			if(substr($ctgfile, -2) == '.z') { // check file extension
3350
				/* Decompresses data encoded using the public-domain
3351
				zlib/deflate compression method, reproducing the
3352
				original text or binary data */
3353
				$this->_out('/Filter /FlateDecode');
3354
			}
3355
			$this->_out('>>');
3356
			$this->_putstream(file_get_contents($ctgfile));
3357
			$this->_out('endobj');
3358
		}
3359
3360
		 /**
3361
		 * Converts UTF-8 strings to codepoints array.<br>
3362
		 * Invalid byte sequences will be replaced with 0xFFFD (replacement character)<br>
3363
		 * Based on: http://www.faqs.org/rfcs/rfc3629.html
3364
		 * <pre>
3365
		 * 	  Char. number range  |        UTF-8 octet sequence
3366
		 *       (hexadecimal)    |              (binary)
3367
		 *    --------------------+-----------------------------------------------
3368
		 *    0000 0000-0000 007F | 0xxxxxxx
3369
		 *    0000 0080-0000 07FF | 110xxxxx 10xxxxxx
3370
		 *    0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
3371
		 *    0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
3372
		 *    ---------------------------------------------------------------------
3373
		 *
3374
		 *   ABFN notation:
3375
		 *   ---------------------------------------------------------------------
3376
		 *   UTF8-octets = *( UTF8-char )
3377
		 *   UTF8-char   = UTF8-1 / UTF8-2 / UTF8-3 / UTF8-4
3378
		 *   UTF8-1      = %x00-7F
3379
		 *   UTF8-2      = %xC2-DF UTF8-tail
3380
		 *
3381
		 *   UTF8-3      = %xE0 %xA0-BF UTF8-tail / %xE1-EC 2( UTF8-tail ) /
3382
		 *                 %xED %x80-9F UTF8-tail / %xEE-EF 2( UTF8-tail )
3383
		 *   UTF8-4      = %xF0 %x90-BF 2( UTF8-tail ) / %xF1-F3 3( UTF8-tail ) /
3384
		 *                 %xF4 %x80-8F 2( UTF8-tail )
3385
		 *   UTF8-tail   = %x80-BF
3386
		 *   ---------------------------------------------------------------------
3387
		 * </pre>
3388
		 * @param string $str string to process.
3389
		 * @return array containing codepoints (UTF-8 characters values)
0 ignored issues
show
Documentation introduced by
Should the return type not be string|array?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
3390
		 * @access protected
3391
		 * @author Nicola Asuni
3392
		 * @since 1.53.0.TC005 (2005-01-05)
3393
		 */
3394
		function UTF8StringToArray($str) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
3395
			if(!$this->isunicode) {
3396
				return $str; // string is not in unicode
3397
			}
3398
			$unicode = array(); // array containing unicode values
3399
			$bytes  = array(); // array containing single character byte sequences
3400
			$numbytes  = 1; // number of octetc needed to represent the UTF-8 character
3401
3402
			$str .= ""; // force $str to be a string
3403
			$length = strlen($str);
3404
3405
			for($i = 0; $i < $length; $i++) {
3406
				$char = ord($str{$i}); // get one string character at time
3407
				if(count($bytes) == 0) { // get starting octect
3408
					if ($char <= 0x7F) {
3409
						$unicode[] = $char; // use the character "as is" because is ASCII
3410
						$numbytes = 1;
3411 View Code Duplication
					} elseif (($char >> 0x05) == 0x06) { // 2 bytes character (0x06 = 110 BIN)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
3412
						$bytes[] = ($char - 0xC0) << 0x06;
3413
						$numbytes = 2;
3414
					} elseif (($char >> 0x04) == 0x0E) { // 3 bytes character (0x0E = 1110 BIN)
3415
						$bytes[] = ($char - 0xE0) << 0x0C;
3416
						$numbytes = 3;
3417 View Code Duplication
					} elseif (($char >> 0x03) == 0x1E) { // 4 bytes character (0x1E = 11110 BIN)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
3418
						$bytes[] = ($char - 0xF0) << 0x12;
3419
						$numbytes = 4;
3420
					} else {
3421
						// use replacement character for other invalid sequences
3422
						$unicode[] = 0xFFFD;
3423
						$bytes = array();
3424
						$numbytes = 1;
3425
					}
3426
				} elseif (($char >> 0x06) == 0x02) { // bytes 2, 3 and 4 must start with 0x02 = 10 BIN
3427
					$bytes[] = $char - 0x80;
3428
					if (count($bytes) == $numbytes) {
3429
						// compose UTF-8 bytes to a single unicode value
3430
						$char = $bytes[0];
3431
						for($j = 1; $j < $numbytes; $j++) {
3432
							$char += ($bytes[$j] << (($numbytes - $j - 1) * 0x06));
3433
						}
3434
						if ((($char >= 0xD800) AND ($char <= 0xDFFF)) OR ($char >= 0x10FFFF)) {
3435
							/* The definition of UTF-8 prohibits encoding character numbers between
3436
							U+D800 and U+DFFF, which are reserved for use with the UTF-16
3437
							encoding form (as surrogate pairs) and do not directly represent
3438
							characters. */
3439
							$unicode[] = 0xFFFD; // use replacement character
3440
						}
3441
						else {
3442
							$unicode[] = $char; // add char to array
3443
						}
3444
						// reset data for next char
3445
						$bytes = array();
3446
						$numbytes = 1;
3447
					}
3448
				} else {
3449
					// use replacement character for other invalid sequences
3450
					$unicode[] = 0xFFFD;
3451
					$bytes = array();
3452
					$numbytes = 1;
3453
				}
3454
			}
3455
			return $unicode;
3456
		}
3457
3458
		/**
3459
		 * Converts UTF-8 strings to UTF16-BE.<br>
3460
		 * Based on: http://www.faqs.org/rfcs/rfc2781.html
3461
	 	 * <pre>
3462
		 *   Encoding UTF-16:
3463
		 *
3464
 		 *   Encoding of a single character from an ISO 10646 character value to
3465
		 *    UTF-16 proceeds as follows. Let U be the character number, no greater
3466
		 *    than 0x10FFFF.
3467
		 *
3468
		 *    1) If U < 0x10000, encode U as a 16-bit unsigned integer and
3469
		 *       terminate.
3470
		 *
3471
		 *    2) Let U' = U - 0x10000. Because U is less than or equal to 0x10FFFF,
3472
		 *       U' must be less than or equal to 0xFFFFF. That is, U' can be
3473
		 *       represented in 20 bits.
3474
		 *
3475
		 *    3) Initialize two 16-bit unsigned integers, W1 and W2, to 0xD800 and
3476
		 *       0xDC00, respectively. These integers each have 10 bits free to
3477
		 *       encode the character value, for a total of 20 bits.
3478
		 *
3479
		 *    4) Assign the 10 high-order bits of the 20-bit U' to the 10 low-order
3480
		 *       bits of W1 and the 10 low-order bits of U' to the 10 low-order
3481
		 *       bits of W2. Terminate.
3482
		 *
3483
		 *    Graphically, steps 2 through 4 look like:
3484
		 *    U' = yyyyyyyyyyxxxxxxxxxx
3485
		 *    W1 = 110110yyyyyyyyyy
3486
		 *    W2 = 110111xxxxxxxxxx
3487
		 * </pre>
3488
		 * @param string $str string to process.
3489
		 * @param boolean $setbom if true set the Byte Order Mark (BOM = 0xFEFF)
3490
		 * @return string
3491
		 * @access protected
3492
		 * @author Nicola Asuni
3493
		 * @since 1.53.0.TC005 (2005-01-05)
3494
		 * @uses UTF8StringToArray
3495
		 */
3496
		function UTF8ToUTF16BE($str, $setbom=true) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
3497
			if(!$this->isunicode) {
3498
				return $str; // string is not in unicode
3499
			}
3500
			$outstr = ""; // string to be returned
3501
			$unicode = $this->UTF8StringToArray($str); // array containing UTF-8 unicode values
3502
			$numitems = count($unicode);
0 ignored issues
show
Unused Code introduced by
$numitems is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
3503
3504
			if ($setbom) {
3505
				$outstr .= "\xFE\xFF"; // Byte Order Mark (BOM)
3506
			}
3507
			foreach($unicode as $char) {
0 ignored issues
show
Bug introduced by
The expression $unicode of type string|array is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
3508
				if($char == 0xFFFD) {
3509
					$outstr .= "\xFF\xFD"; // replacement character
3510
				} elseif ($char < 0x10000) {
3511
					$outstr .= chr($char >> 0x08);
3512
					$outstr .= chr($char & 0xFF);
3513
				} else {
3514
					$char -= 0x10000;
3515
					$w1 = 0xD800 | ($char >> 0x10);
3516
					$w2 = 0xDC00 | ($char & 0x3FF);
3517
					$outstr .= chr($w1 >> 0x08);
3518
					$outstr .= chr($w1 & 0xFF);
3519
					$outstr .= chr($w2 >> 0x08);
3520
					$outstr .= chr($w2 & 0xFF);
3521
				}
3522
			}
3523
			return $outstr;
3524
		}
3525
3526
		// ====================================================
3527
3528
		/**
3529
	 	 * Set header font.
3530
		 * @param array $font font
3531
		 * @since 1.1
3532
		 */
3533
		function setHeaderFont($font) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
3534
			$this->header_font = $font;
0 ignored issues
show
Documentation Bug introduced by
It seems like $font of type array is incompatible with the declared type object<Header> of property $header_font.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3535
		}
3536
3537
		/**
3538
	 	 * Set footer font.
3539
		 * @param array $font font
3540
		 * @since 1.1
3541
		 */
3542
		function setFooterFont($font) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
3543
			$this->footer_font = $font;
0 ignored issues
show
Documentation Bug introduced by
It seems like $font of type array is incompatible with the declared type object<Footer> of property $footer_font.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3544
		}
3545
3546
		/**
3547
	 	 * Set language array.
3548
		 * @param array $language
3549
		 * @since 1.1
3550
		 */
3551
		function setLanguageArray($language) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
3552
			$this->l = $language;
0 ignored issues
show
Documentation Bug introduced by
It seems like $language of type array is incompatible with the declared type object<Language> of property $l.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3553
		}
3554
3555
		/**
3556
	 	 * Set document barcode.
3557
		 * @param string $bc barcode
3558
		 */
3559
		function setBarcode($bc="") {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
3560
			$this->barcode = $bc;
0 ignored issues
show
Documentation Bug introduced by
It seems like $bc of type string is incompatible with the declared type object<barcode> of property $barcode.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3561
		}
3562
3563
		/**
3564
	 	 * Print Barcode.
3565
		 * @param int $x x position in user units
3566
		 * @param int $y y position in user units
3567
		 * @param int $w width in user units
3568
		 * @param int $h height position in user units
3569
		 * @param string $type type of barcode (I25, C128A, C128B, C128C, C39)
3570
		 * @param string $style barcode style
3571
		 * @param string $font font for text
3572
		 * @param int $xres x resolution
3573
		 * @param string $code code to print
3574
		 */
3575
		function writeBarcode($x, $y, $w, $h, $type, $style, $font, $xres, $code) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
3576
			require_once(dirname(__FILE__)."/barcode/barcode.php");
3577
			require_once(dirname(__FILE__)."/barcode/i25object.php");
3578
			require_once(dirname(__FILE__)."/barcode/c39object.php");
3579
			require_once(dirname(__FILE__)."/barcode/c128aobject.php");
3580
			require_once(dirname(__FILE__)."/barcode/c128bobject.php");
3581
			require_once(dirname(__FILE__)."/barcode/c128cobject.php");
3582
3583
			if (empty($code)) {
3584
				return;
3585
			}
3586
3587
			if (empty($style)) {
3588
				$style  = BCS_ALIGN_LEFT;
3589
				$style |= BCS_IMAGE_PNG;
3590
				$style |= BCS_TRANSPARENT;
3591
				//$style |= BCS_BORDER;
3592
				//$style |= BCS_DRAW_TEXT;
3593
				//$style |= BCS_STRETCH_TEXT;
3594
				//$style |= BCS_REVERSE_COLOR;
3595
			}
3596
			if (empty($font)) {$font = BCD_DEFAULT_FONT;}
3597
			if (empty($xres)) {$xres = BCD_DEFAULT_XRES;}
3598
3599
			$scale_factor = 1.5 * $xres * $this->k;
3600
			$bc_w = round($w * $scale_factor); //width in points
3601
			$bc_h = round($h * $scale_factor); //height in points
3602
3603
			switch (strtoupper($type)) {
3604
				case "I25": {
3605
					$obj = new I25Object($bc_w, $bc_h, $style, $code);
3606
					break;
3607
				}
3608
				case "C128A": {
3609
					$obj = new C128AObject($bc_w, $bc_h, $style, $code);
3610
					break;
3611
				}
3612
				default:
3613
				case "C128B": {
0 ignored issues
show
Unused Code introduced by
case 'C128B': $obj =...yle, $code); break; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
3614
					$obj = new C128BObject($bc_w, $bc_h, $style, $code);
3615
					break;
3616
				}
3617
				case "C128C": {
3618
					$obj = new C128CObject($bc_w, $bc_h, $style, $code);
3619
					break;
3620
				}
3621
				case "C39": {
3622
					$obj = new C39Object($bc_w, $bc_h, $style, $code);
3623
					break;
3624
				}
3625
			}
3626
3627
			$obj->SetFont($font);
3628
			$obj->DrawObject($xres);
3629
3630
			//use a temporary file....
3631
			$tmpName = tempnam(K_PATH_CACHE,'img');
3632
			imagepng($obj->getImage(), $tmpName);
3633
			$this->Image($tmpName, $x, $y, $w, $h, 'png');
3634
			$obj->DestroyObject();
3635
			unset($obj);
3636
			unlink($tmpName);
3637
		}
3638
3639
		/**
3640
	 	 * Returns the PDF data.
3641
		 */
3642
		function getPDFData() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
3643
			if($this->state < 3) {
3644
				$this->Close();
3645
			}
3646
			return $this->buffer;
3647
		}
3648
3649
		// --- HTML PARSER FUNCTIONS ---
3650
3651
		/**
3652
		 * Allows to preserve some HTML formatting.<br />
3653
		 * Supports: h1, h2, h3, h4, h5, h6, b, u, i, a, img, p, br, strong, em, font, blockquote, li, ul, ol, hr, td, th, tr, table, sup, sub, small
3654
		 * @param string $html text to display
3655
		 * @param boolean $ln if true add a new line after text (default = true)
3656
		 * @param int $fill Indicates if the background must be painted (1) or transparent (0). Default value: 0.
3657
		 */
3658
		function writeHTML($html, $ln=true, $fill=0) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
3659
3660
			// store some variables
3661
			$html=strip_tags($html,"<h1><h2><h3><h4><h5><h6><b><u><i><a><img><p><br><br/><strong><em><font><blockquote><li><ul><ol><hr><td><th><tr><table><sup><sub><small>"); //remove all unsupported tags
3662
			//replace carriage returns, newlines and tabs
3663
			$repTable = array("\t" => " ", "\n" => " ", "\r" => " ", "\0" => " ", "\x0B" => " ");
3664
			$html = strtr($html, $repTable);
3665
			$pattern = '/(<[^>]+>)/Uu';
3666
			$a = preg_split($pattern, $html, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); //explodes the string
3667
3668
			if (empty($this->lasth)) {
3669
				//set row height
3670
				$this->lasth = $this->FontSize * K_CELL_HEIGHT_RATIO;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->FontSize * K_CELL_HEIGHT_RATIO of type double is incompatible with the declared type object<height> of property $lasth.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3671
			}
3672
3673
			foreach($a as $key=>$element) {
3674
				if (!preg_match($pattern, $element)) {
3675
					//Text
3676
					if($this->HREF) {
3677
						$this->addHtmlLink($this->HREF, $element, $fill);
3678
					}
3679
					elseif($this->tdbegin) {
3680
						if((strlen(trim($element)) > 0) AND ($element != "&nbsp;")) {
3681
							$this->Cell($this->tdwidth, $this->tdheight, $this->unhtmlentities($element), $this->tableborder, '', $this->tdalign, $this->tdbgcolor);
3682
						}
3683
						elseif($element == "&nbsp;") {
3684
							$this->Cell($this->tdwidth, $this->tdheight, '', $this->tableborder, '', $this->tdalign, $this->tdbgcolor);
3685
						}
3686
					}
3687
					else {
3688
						$this->Write($this->lasth, stripslashes($this->unhtmlentities($element)), '', $fill);
3689
					}
3690
				}
3691
				else {
3692
					$element = substr($element, 1, -1);
3693
					//Tag
3694
					if($element{0}=='/') {
3695
						$this->closedHTMLTagHandler(strtolower(substr($element, 1)));
3696
					}
3697
					else {
3698
						//Extract attributes
3699
						// get tag name
3700
						preg_match('/([a-zA-Z0-9]*)/', $element, $tag);
3701
						$tag = strtolower($tag[0]);
3702
						// get attributes
3703
						preg_match_all('/([^=\s]*)=["\']?([^"\']*)["\']?/', $element, $attr_array, PREG_PATTERN_ORDER);
3704
						$attr = array(); // reset attribute array
3705
						while(list($id,$name)=each($attr_array[1])) {
3706
							$attr[strtolower($name)] = $attr_array[2][$id];
3707
						}
3708
						$this->openHTMLTagHandler($tag, $attr, $fill);
0 ignored issues
show
Documentation introduced by
$attr is of type array, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
3709
					}
3710
				}
3711
			}
3712
			if ($ln) {
3713
				$this->Ln($this->lasth);
3714
			}
3715
		}
3716
3717
		/**
3718
		 * Prints a cell (rectangular area) with optional borders, background color and html text string. The upper-left corner of the cell corresponds to the current position. After the call, the current position moves to the right or to the next line.<br />
3719
		 * If automatic page breaking is enabled and the cell goes beyond the limit, a page break is done before outputting.
3720
		 * @param float $w Cell width. If 0, the cell extends up to the right margin.
3721
		 * @param float $h Cell minimum height. The cell extends automatically if needed.
3722
		 * @param float $x upper-left corner X coordinate
3723
		 * @param float $y upper-left corner Y coordinate
3724
		 * @param string $html html text to print. Default value: empty string.
3725
		 * @param mixed $border Indicates if borders must be drawn around the cell. The value can be either a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul>or a string containing some or all of the following characters (in any order):<ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul>
3726
		 * @param int $ln Indicates where the current position should go after the call. Possible values are:<ul><li>0: to the right</li><li>1: to the beginning of the next line</li><li>2: below</li></ul>
3727
	Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: 0.
3728
		 * @param int $fill Indicates if the cell background must be painted (1) or transparent (0). Default value: 0.
3729
		 * @see Cell()
3730
		 */
3731
		function writeHTMLCell($w, $h, $x, $y, $html='', $border=0, $ln=0, $fill=0) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
3732
3733
			if (empty($this->lasth)) {
3734
				//set row height
3735
				$this->lasth = $this->FontSize * K_CELL_HEIGHT_RATIO;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->FontSize * K_CELL_HEIGHT_RATIO of type double is incompatible with the declared type object<height> of property $lasth.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3736
			}
3737
3738
			if (empty($x)) {
3739
				$x = $this->GetX();
3740
			}
3741
			if (empty($y)) {
3742
				$y = $this->GetY();
3743
			}
3744
3745
			// get current page number
3746
			$pagenum = $this->page;
3747
3748
			$this->SetX($x);
3749
			$this->SetY($y);
3750
3751
			if(empty($w)) {
3752
				$w = $this->fw - $x - $this->rMargin;
3753
			}
3754
3755
			// store original margin values
3756
			$lMargin = $this->lMargin;
3757
			$rMargin = $this->rMargin;
3758
3759
			// set new margin values
3760
			$this->SetLeftMargin($x);
3761
			$this->SetRightMargin($this->fw - $x - $w);
3762
3763
			// calculate remaining vertical space on page
3764
			$restspace = $this->getPageHeight() - $this->GetY() - $this->getBreakMargin();
3765
3766
			$this->writeHTML($html, true, $fill); // write html text
3767
3768
			$currentY =  $this->GetY();
3769
3770
			// check if a new page has been created
3771
			if ($this->page > $pagenum) {
3772
				// design a cell around the text on first page
3773
				$currentpage = $this->page;
3774
				$this->page = $pagenum;
3775
				$this->SetY($this->getPageHeight() - $restspace - $this->getBreakMargin());
3776
				$h = $restspace - 1;
3777
				$this->Cell($w, $h, "", $border, $ln, 'L', 0);
3778
				// design a cell around the text on last page
3779
				$this->page = $currentpage;
3780
				$h = $currentY - $this->tMargin;
3781
				$this->SetY($this->tMargin); // put cursor at the beginning of text
3782
				$this->Cell($w, $h, "", $border, $ln, 'L', 0);
3783
			} else {
3784
				$h = max($h, ($currentY - $y));
3785
				$this->SetY($y); // put cursor at the beginning of text
3786
				// design a cell around the text
3787
				$this->Cell($w, $h, "", $border, $ln, 'L', 0);
3788
			}
3789
3790
			// restore original margin values
3791
			$this->SetLeftMargin($lMargin);
3792
			$this->SetRightMargin($rMargin);
3793
3794
			if ($ln) {
3795
				$this->Ln(0);
3796
			}
3797
		}
3798
3799
		/**
3800
		 * Process opening tags.
3801
		 * @param string $tag tag name (in uppercase)
3802
		 * @param string $attr tag attribute (in uppercase)
3803
		 * @param int $fill Indicates if the cell background must be painted (1) or transparent (0). Default value: 0.
3804
		 * @access private
3805
		 */
3806
		function openHTMLTagHandler($tag, $attr, $fill=0) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
3807
			//Opening tag
3808
			switch($tag) {
3809
				case 'table': {
3810
					if ((isset($attr['border'])) AND ($attr['border'] != '')) {
3811
						$this->tableborder = $attr['border'];
0 ignored issues
show
Documentation Bug introduced by
It seems like $attr['border'] of type string is incompatible with the declared type object<HTML> of property $tableborder.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3812
					}
3813
					else {
3814
						$this->tableborder = 0;
0 ignored issues
show
Documentation Bug introduced by
It seems like 0 of type integer is incompatible with the declared type object<HTML> of property $tableborder.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3815
					}
3816
					break;
3817
				}
3818
				case 'tr': {
3819
					break;
3820
				}
3821
				case 'td':
3822
				case 'th': {
3823
					if ((isset($attr['width'])) AND ($attr['width'] != '')) {
3824
						$this->tdwidth = ($attr['width']/4);
0 ignored issues
show
Documentation Bug introduced by
It seems like $attr['width'] / 4 of type integer or double is incompatible with the declared type object<HTML> of property $tdwidth.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3825
					}
3826
					else {
3827
						$this->tdwidth = (($this->w - $this->lMargin - $this->rMargin) / $this->default_table_columns);
0 ignored issues
show
Documentation Bug introduced by
It seems like ($this->w - $this->lMarg...->default_table_columns of type integer or double is incompatible with the declared type object<HTML> of property $tdwidth.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3828
					}
3829
					if ((isset($attr['height'])) AND ($attr['height'] != '')) {
3830
						$this->tdheight=($attr['height'] / $this->k);
0 ignored issues
show
Documentation Bug introduced by
It seems like $attr['height'] / $this->k of type integer or double is incompatible with the declared type object<HTML> of property $tdheight.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3831
					}
3832
					else {
3833
						$this->tdheight = $this->lasth;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->lasth of type object<height> is incompatible with the declared type object<HTML> of property $tdheight.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3834
					}
3835
					if ((isset($attr['align'])) AND ($attr['align'] != '')) {
3836
						switch ($attr['align']) {
3837
							case 'center': {
3838
								$this->tdalign = "C";
0 ignored issues
show
Documentation Bug introduced by
It seems like 'C' of type string is incompatible with the declared type object<HTML> of property $tdalign.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3839
								break;
3840
							}
3841
							case 'right': {
3842
								$this->tdalign = "R";
0 ignored issues
show
Documentation Bug introduced by
It seems like 'R' of type string is incompatible with the declared type object<HTML> of property $tdalign.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3843
								break;
3844
							}
3845
							default:
3846
							case 'left': {
0 ignored issues
show
Unused Code introduced by
case 'left': $this->tdalign = 'L'; break; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
3847
								$this->tdalign = "L";
0 ignored issues
show
Documentation Bug introduced by
It seems like 'L' of type string is incompatible with the declared type object<HTML> of property $tdalign.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3848
								break;
3849
							}
3850
						}
3851
					}
3852 View Code Duplication
					if ((isset($attr['bgcolor'])) AND ($attr['bgcolor'] != '')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
3853
						$coul = $this->convertColorHexToDec($attr['bgcolor']);
3854
						$this->SetFillColor($coul['R'], $coul['G'], $coul['B']);
3855
						$this->tdbgcolor=true;
0 ignored issues
show
Documentation Bug introduced by
It seems like true of type boolean is incompatible with the declared type object<HTML> of property $tdbgcolor.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3856
					}
3857
					$this->tdbegin=true;
0 ignored issues
show
Documentation Bug introduced by
It seems like true of type boolean is incompatible with the declared type object<HTML> of property $tdbegin.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3858
					break;
3859
				}
3860
				case 'hr': {
3861
					$this->Ln();
3862
					if ((isset($attr['width'])) AND ($attr['width'] != '')) {
3863
						$hrWidth = $attr['width'];
3864
					}
3865
					else {
3866
						$hrWidth = $this->w - $this->lMargin - $this->rMargin;
3867
					}
3868
					$x = $this->GetX();
3869
					$y = $this->GetY();
3870
					$this->SetLineWidth(0.2);
3871
					$this->Line($x, $y, $x + $hrWidth, $y);
3872
					$this->SetLineWidth(0.2);
3873
					$this->Ln();
3874
					break;
3875
				}
3876
				case 'strong': {
3877
					$this->setStyle('b', true);
3878
					break;
3879
				}
3880
				case 'em': {
3881
					$this->setStyle('i', true);
3882
					break;
3883
				}
3884
				case 'b':
3885
				case 'i':
3886
				case 'u': {
3887
					$this->setStyle($tag, true);
3888
					break;
3889
				}
3890
				case 'a': {
3891
					$this->HREF = $attr['href'];
0 ignored issues
show
Documentation Bug introduced by
It seems like $attr['href'] of type string is incompatible with the declared type object<HTML> of property $HREF.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3892
					break;
3893
				}
3894
				case 'img': {
3895
					if(isset($attr['src'])) {
3896
						// replace relative path with real server path
3897
						$attr['src'] = str_replace(K_PATH_URL_CACHE, K_PATH_CACHE, $attr['src']);
3898
						if(!isset($attr['width'])) {
3899
							$attr['width'] = 0;
3900
						}
3901
						if(!isset($attr['height'])) {
3902
							$attr['height'] = 0;
3903
						}
3904
3905
						$this->Image($attr['src'], $this->GetX(),$this->GetY(), $this->pixelsToMillimeters($attr['width']), $this->pixelsToMillimeters($attr['height']));
3906
						//$this->SetX($this->img_rb_x);
3907
						$this->SetY($this->img_rb_y);
3908
3909
					}
3910
					break;
3911
				}
3912
				case 'ul': {
3913
					$this->listordered = false;
0 ignored issues
show
Documentation Bug introduced by
It seems like false of type false is incompatible with the declared type object<HTML> of property $listordered.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3914
					$this->listcount = 0;
0 ignored issues
show
Documentation Bug introduced by
It seems like 0 of type integer is incompatible with the declared type object<HTML> of property $listcount.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3915
					break;
3916
				}
3917
				case 'ol': {
3918
					$this->listordered = true;
0 ignored issues
show
Documentation Bug introduced by
It seems like true of type boolean is incompatible with the declared type object<HTML> of property $listordered.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3919
					$this->listcount = 0;
3920
					break;
3921
				}
3922
				case 'li': {
3923
					$this->Ln();
3924
					if ($this->listordered) {
3925
						$this->lispacer = "    ".(++$this->listcount).". ";
0 ignored issues
show
Documentation Bug introduced by
It seems like ' ' . ++$this->listcount . '. ' of type string is incompatible with the declared type object<spacer> of property $lispacer.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3926
					}
3927
					else {
3928
						//unordered list simbol
3929
						$this->lispacer = "    -  ";
0 ignored issues
show
Documentation Bug introduced by
It seems like ' - ' of type string is incompatible with the declared type object<spacer> of property $lispacer.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3930
					}
3931
					$this->Write($this->lasth, $this->lispacer, '', $fill);
3932
					break;
3933
				}
3934
				case 'blockquote':
3935
				case 'br': {
3936
					$this->Ln();
3937
					if(strlen($this->lispacer) > 0) {
3938
						$this->x += $this->GetStringWidth($this->lispacer);
3939
					}
3940
					break;
3941
				}
3942
				case 'p': {
3943
					$this->Ln();
3944
					$this->Ln();
3945
					break;
3946
				}
3947
				case 'sup': {
3948
					$currentFontSize = $this->FontSize;
3949
					$this->tempfontsize = $this->FontSizePt;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->FontSizePt of type object<current> is incompatible with the declared type object<Store> of property $tempfontsize.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3950
					$this->SetFontSize($this->FontSizePt * K_SMALL_RATIO);
3951
					$this->SetXY($this->GetX(), $this->GetY() - (($currentFontSize - $this->FontSize)*(K_SMALL_RATIO)));
3952
					break;
3953
				}
3954 View Code Duplication
				case 'sub': {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
3955
					$currentFontSize = $this->FontSize;
3956
					$this->tempfontsize = $this->FontSizePt;
3957
					$this->SetFontSize($this->FontSizePt * K_SMALL_RATIO);
3958
					$this->SetXY($this->GetX(), $this->GetY() + (($currentFontSize - $this->FontSize)*(K_SMALL_RATIO)));
3959
					break;
3960
				}
3961 View Code Duplication
				case 'small': {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
3962
					$currentFontSize = $this->FontSize;
3963
					$this->tempfontsize = $this->FontSizePt;
3964
					$this->SetFontSize($this->FontSizePt * K_SMALL_RATIO);
3965
					$this->SetXY($this->GetX(), $this->GetY() + (($currentFontSize - $this->FontSize)/3));
3966
					break;
3967
				}
3968
				case 'font': {
3969 View Code Duplication
					if (isset($attr['color']) AND $attr['color']!='') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
3970
						$coul = $this->convertColorHexToDec($attr['color']);
3971
						$this->SetTextColor($coul['R'],$coul['G'],$coul['B']);
3972
						$this->issetcolor=true;
0 ignored issues
show
Documentation Bug introduced by
It seems like true of type boolean is incompatible with the declared type object<HTML> of property $issetcolor.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3973
					}
3974
					if (isset($attr['face']) and in_array(strtolower($attr['face']), $this->fontlist)) {
0 ignored issues
show
Bug introduced by
The property fontlist does not seem to exist. Did you mean fontList?

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...
3975
						$this->SetFont(strtolower($attr['face']));
3976
						$this->issetfont=true;
0 ignored issues
show
Documentation Bug introduced by
It seems like true of type boolean is incompatible with the declared type object<HTML> of property $issetfont.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3977
					}
3978
					if (isset($attr['size'])) {
3979
						$headsize = intval($attr['size']);
3980
					} else {
3981
						$headsize = 0;
3982
					}
3983
					$currentFontSize = $this->FontSize;
0 ignored issues
show
Unused Code introduced by
$currentFontSize is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
3984
					$this->tempfontsize = $this->FontSizePt;
3985
					$this->SetFontSize($this->FontSizePt + $headsize);
3986
					$this->lasth = $this->FontSize * K_CELL_HEIGHT_RATIO;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->FontSize * K_CELL_HEIGHT_RATIO of type double is incompatible with the declared type object<height> of property $lasth.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3987
					break;
3988
				}
3989
				case 'h1':
3990
				case 'h2':
3991
				case 'h3':
3992
				case 'h4':
3993
				case 'h5':
3994
				case 'h6': {
3995
					$headsize = (4 - substr($tag, 1)) * 2;
3996
					$currentFontSize = $this->FontSize;
0 ignored issues
show
Unused Code introduced by
$currentFontSize is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
3997
					$this->tempfontsize = $this->FontSizePt;
3998
					$this->SetFontSize($this->FontSizePt + $headsize);
3999
					$this->setStyle('b', true);
4000
					$this->lasth = $this->FontSize * K_CELL_HEIGHT_RATIO;
4001
					break;
4002
				}
4003
			}
4004
		}
4005
4006
		/**
4007
		 * Process closing tags.
4008
		 * @param string $tag tag name (in uppercase)
4009
		 * @access private
4010
		 */
4011
		function closedHTMLTagHandler($tag) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
4012
			//Closing tag
4013
			switch($tag) {
4014
				case 'td':
4015
				case 'th': {
4016
					$this->tdbegin = false;
0 ignored issues
show
Documentation Bug introduced by
It seems like false of type false is incompatible with the declared type object<HTML> of property $tdbegin.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
4017
					$this->tdwidth = 0;
0 ignored issues
show
Documentation Bug introduced by
It seems like 0 of type integer is incompatible with the declared type object<HTML> of property $tdwidth.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
4018
					$this->tdheight = 0;
0 ignored issues
show
Documentation Bug introduced by
It seems like 0 of type integer is incompatible with the declared type object<HTML> of property $tdheight.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
4019
					$this->tdalign = "L";
0 ignored issues
show
Documentation Bug introduced by
It seems like 'L' of type string is incompatible with the declared type object<HTML> of property $tdalign.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
4020
					$this->tdbgcolor = false;
0 ignored issues
show
Documentation Bug introduced by
It seems like false of type false is incompatible with the declared type object<HTML> of property $tdbgcolor.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
4021
					$this->SetFillColor($this->prevFillColor[0], $this->prevFillColor[1], $this->prevFillColor[2]);
4022
					break;
4023
				}
4024
				case 'tr': {
4025
					$this->Ln();
4026
					break;
4027
				}
4028
				case 'table': {
4029
					$this->tableborder=0;
0 ignored issues
show
Documentation Bug introduced by
It seems like 0 of type integer is incompatible with the declared type object<HTML> of property $tableborder.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
4030
					break;
4031
				}
4032
				case 'strong': {
4033
					$this->setStyle('b', false);
4034
					break;
4035
				}
4036
				case 'em': {
4037
					$this->setStyle('i', false);
4038
					break;
4039
				}
4040
				case 'b':
4041
				case 'i':
4042
				case 'u': {
4043
					$this->setStyle($tag, false);
4044
					break;
4045
				}
4046
				case 'a': {
4047
					$this->HREF = '';
0 ignored issues
show
Documentation Bug introduced by
It seems like '' of type string is incompatible with the declared type object<HTML> of property $HREF.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
4048
					break;
4049
				}
4050
				case 'sup': {
4051
					$currentFontSize = $this->FontSize;
4052
					$this->SetFontSize($this->tempfontsize);
4053
					$this->tempfontsize = $this->FontSizePt;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->FontSizePt of type object<current> is incompatible with the declared type object<Store> of property $tempfontsize.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
4054
					$this->SetXY($this->GetX(), $this->GetY() - (($currentFontSize - $this->FontSize)*(K_SMALL_RATIO)));
4055
					break;
4056
				}
4057
				case 'sub': {
4058
					$currentFontSize = $this->FontSize;
4059
					$this->SetFontSize($this->tempfontsize);
4060
					$this->tempfontsize = $this->FontSizePt;
4061
					$this->SetXY($this->GetX(), $this->GetY() + (($currentFontSize - $this->FontSize)*(K_SMALL_RATIO)));
4062
					break;
4063
				}
4064
				case 'small': {
4065
					$currentFontSize = $this->FontSize;
4066
					$this->SetFontSize($this->tempfontsize);
4067
					$this->tempfontsize = $this->FontSizePt;
4068
					$this->SetXY($this->GetX(), $this->GetY() - (($this->FontSize - $currentFontSize)/3));
4069
					break;
4070
				}
4071
				case 'font': {
4072
					if ($this->issetcolor == true) {
4073
						$this->SetTextColor($this->prevTextColor[0], $this->prevTextColor[1], $this->prevTextColor[2]);
4074
					}
4075
					if ($this->issetfont) {
4076
						$this->FontFamily = $this->prevFontFamily;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->prevFontFamily of type object<Store> is incompatible with the declared type object<current> of property $FontFamily.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
4077
						$this->FontStyle = $this->prevFontStyle;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->prevFontStyle of type object<Store> is incompatible with the declared type object<current> of property $FontStyle.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
4078
						$this->SetFont($this->FontFamily);
4079
						$this->issetfont = false;
0 ignored issues
show
Documentation Bug introduced by
It seems like false of type false is incompatible with the declared type object<HTML> of property $issetfont.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
4080
					}
4081
					$currentFontSize = $this->FontSize;
0 ignored issues
show
Unused Code introduced by
$currentFontSize is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
4082
					$this->SetFontSize($this->tempfontsize);
4083
					$this->tempfontsize = $this->FontSizePt;
4084
					//$this->TextColor = $this->prevTextColor;
4085
					$this->lasth = $this->FontSize * K_CELL_HEIGHT_RATIO;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->FontSize * K_CELL_HEIGHT_RATIO of type double is incompatible with the declared type object<height> of property $lasth.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
4086
					break;
4087
				}
4088
				case 'ul': {
4089
					$this->Ln();
4090
					break;
4091
				}
4092
				case 'ol': {
4093
					$this->Ln();
4094
					break;
4095
				}
4096
				case 'li': {
4097
					$this->lispacer = "";
0 ignored issues
show
Documentation Bug introduced by
It seems like '' of type string is incompatible with the declared type object<spacer> of property $lispacer.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
4098
					break;
4099
				}
4100
				case 'h1':
4101
				case 'h2':
4102
				case 'h3':
4103
				case 'h4':
4104
				case 'h5':
4105 View Code Duplication
				case 'h6': {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
4106
					$currentFontSize = $this->FontSize;
0 ignored issues
show
Unused Code introduced by
$currentFontSize is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
4107
					$this->SetFontSize($this->tempfontsize);
4108
					$this->tempfontsize = $this->FontSizePt;
4109
					$this->setStyle('b', false);
4110
					$this->Ln();
4111
					$this->lasth = $this->FontSize * K_CELL_HEIGHT_RATIO;
4112
					break;
4113
				}
4114
				default : {
4115
					break;
4116
				}
4117
			}
4118
		}
4119
4120
		/**
4121
		 * Sets font style.
4122
		 * @param string $tag tag name (in lowercase)
4123
		 * @param boolean $enable
4124
		 * @access private
4125
		 */
4126
		function setStyle($tag, $enable) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
4127
			//Modify style and select corresponding font
4128
			$this->$tag += ($enable ? 1 : -1);
4129
			$style='';
4130
			foreach(array('b', 'i', 'u') as $s) {
4131
				if($this->$s > 0) {
4132
					$style .= $s;
4133
				}
4134
			}
4135
			$this->SetFont('', $style);
4136
		}
4137
4138
		/**
4139
		 * Output anchor link.
4140
		 * @param string $url link URL
4141
		 * @param string $name link name
4142
		 * @param int $fill Indicates if the cell background must be painted (1) or transparent (0). Default value: 0.
4143
		 * @access public
4144
		 */
4145
		function addHtmlLink($url, $name, $fill=0) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
4146
			//Put a hyperlink
4147
			$this->SetTextColor(0, 0, 255);
4148
			$this->setStyle('u', true);
4149
			$this->Write($this->lasth, $name, $url, $fill);
4150
			$this->setStyle('u', false);
4151
			$this->SetTextColor(0);
4152
		}
4153
4154
		/**
4155
		 * Returns an associative array (keys: R,G,B) from
4156
		 * a hex html code (e.g. #3FE5AA).
4157
		 * @param string $color hexadecimal html color [#rrggbb]
4158
		 * @return array
4159
		 * @access private
4160
		 */
4161
		function convertColorHexToDec($color = "#000000"){
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
4162
			$tbl_color = array();
4163
			$tbl_color['R'] = hexdec(substr($color, 1, 2));
4164
			$tbl_color['G'] = hexdec(substr($color, 3, 2));
4165
			$tbl_color['B'] = hexdec(substr($color, 5, 2));
4166
			return $tbl_color;
4167
		}
4168
4169
		/**
4170
		 * Converts pixels to millimeters in 72 dpi.
4171
		 * @param int $px pixels
4172
		 * @return float millimeters
4173
		 * @access private
4174
		 */
4175
		function pixelsToMillimeters($px){
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
4176
			return $px * 25.4 / 72;
4177
		}
4178
4179
		/**
4180
		 * Reverse function for htmlentities.
4181
		 * Convert entities in UTF-8.
4182
		 *
4183
		 * @param $text_to_convert Text to convert.
4184
		 * @return string converted
4185
		 */
4186
		function unhtmlentities($text_to_convert) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
4187
			require_once(dirname(__FILE__).'/html_entity_decode_php4.php');
4188
			return html_entity_decode_php4($text_to_convert);
4189
		}
4190
	} // END OF CLASS
4191
4192
	//Handle special IE contype request
4193
	if(isset($_SERVER['HTTP_USER_AGENT']) AND ($_SERVER['HTTP_USER_AGENT']=='contype')) {
4194
		header('Content-Type: application/pdf');
4195
		exit;
4196
	}
4197
4198
}
4199
//============================================================+
4200
// END OF FILE
4201
//============================================================+
4202
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...