Completed
Push — master ( cc47ff...c36dee )
by Roberto
11:19 queued 07:30
created

Danfe::calculeHeight()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
cc 4
nc 4
nop 2
dl 0
loc 18
ccs 0
cts 16
cp 0
crap 20
rs 9.6666
c 0
b 0
f 0
1
<?php
2
namespace NFePHP\DA\NFe;
3
4
use NFePHP\DA\Legacy\Dom;
5
use NFePHP\DA\Legacy\Pdf;
6
use \NFePHP\DA\Common\DaCommon;
7
8
class Danfe extends DaCommon
9
{
10
11
    /**
12
     * Posição
13
     *
14
     * @var float
15
     */
16
    protected $yDados = 0;
17
    /**
18
     * Parâmetro para exibir ou ocultar os valores do PIS/COFINS.
19
     *
20
     * @var boolean
21
     */
22
    protected $qCanhoto = 1;
23
    /**
24
     * Define a exbição dos valores de PIS e Cofins
25
     *
26
     * @var bool
27
     */
28
    protected $exibirPIS = true;
29
    /**
30
     * Parâmetro para exibir ou ocultar os valores do ICMS Interestadual e Valor Total dos Impostos.
31
     *
32
     * @var boolean
33
     */
34
    protected $exibirIcmsInterestadual = true;
35
    /**
36
     * Parâmetro para exibir ou ocultar o texto sobre valor aproximado dos tributos.
37
     *
38
     * @var boolean
39
     */
40
    protected $exibirValorTributos = true;
41
    /**
42
     * Parâmetro para exibir ou ocultar o texto adicional sobre a forma de pagamento
43
     * e as informações de fatura/duplicata.
44
     *
45
     * @var boolean
46
     */
47
    protected $exibirTextoFatura = false;
48
    /**
49
     * Parâmetro do controle se deve concatenar automaticamente informações complementares
50
     * na descrição do produto, como por exemplo, informações sobre impostos.
51
     *
52
     * @var boolean
53
     */
54
    public $descProdInfoComplemento = true;
55
    /**
56
     *`Parâmetro que habilita a geração de automatica de informações
57
     *
58
     * @var boolean
59
     */
60
    public $gerarInformacoesAutomaticas = true;
61
    /**
62
     * Parâmetro do controle se deve gerar quebras de linha com "\n" a partir de ";" na descrição do produto.
63
     *
64
     * @var boolean
65
     */
66
    protected $descProdQuebraLinha = true;
67
    /**
68
     * XML NFe
69
     *
70
     * @var string
71
     */
72
    protected $xml;
73
    /**
74
     * mesagens de erro
75
     *
76
     * @var string
77
     */
78
    protected $errMsg = '';
79
    /**
80
     * status de erro true um erro ocorreu false sem erros
81
     *
82
     * @var boolean
83
     */
84
    protected $errStatus = false;
85
    /**
86
     * Texto adicional da DANFE
87
     *
88
     * @var string
89
     */
90
    protected $textoAdic = '';
91
    /**
92
     * Largura
93
     *
94
     * @var float
95
     */
96
    protected $wAdic = 0;
97
    /**
98
     * largura do canhoto (25mm) apenas para a formatação paisagem
99
     *
100
     * @var float
101
     */
102
    protected $wCanhoto = 25;
103
    /**
104
     * Formato chave
105
     *
106
     * @var string
107
     */
108
    protected $formatoChave = "#### #### #### #### #### #### #### #### #### #### ####";
109
    /**
110
     * quantidade de itens já processados na montagem do DANFE
111
     *
112
     * @var integer
113
     */
114
    protected $qtdeItensProc;
115
    /**
116
     * Dom Document
117
     *
118
     * @var \NFePHP\DA\Legacy\Dom
119
     */
120
    protected $dom;
121
    /**
122
     * Node
123
     *
124
     * @var \DOMNode
125
     */
126
    protected $infNFe;
127
    /**
128
     * Node
129
     *
130
     * @var \DOMNode
131
     */
132
    protected $ide;
133
    /**
134
     * Node
135
     *
136
     * @var \DOMNode
137
     */
138
    protected $entrega;
139
    /**
140
     * Node
141
     *
142
     * @var \DOMNode
143
     */
144
    protected $retirada;
145
    /**
146
     * Node
147
     *
148
     * @var \DOMNode
149
     */
150
    protected $emit;
151
    /**
152
     * Node
153
     *
154
     * @var \DOMNode
155
     */
156
    protected $dest;
157
    /**
158
     * Node
159
     *
160
     * @var \DOMNode
161
     */
162
    protected $enderEmit;
163
    /**
164
     * Node
165
     *
166
     * @var \DOMNode
167
     */
168
    protected $enderDest;
169
    /**
170
     * Node
171
     *
172
     * @var \DOMNode
173
     */
174
    protected $det;
175
    /**
176
     * Node
177
     *
178
     * @var \DOMNode
179
     */
180
    protected $cobr;
181
    /**
182
     * Node
183
     *
184
     * @var \DOMNode
185
     */
186
    protected $dup;
187
    /**
188
     * Node
189
     *
190
     * @var \DOMNode
191
     */
192
    protected $ICMSTot;
193
    /**
194
     * Node
195
     *
196
     * @var \DOMNode
197
     */
198
    protected $ISSQNtot;
199
    /**
200
     * Node
201
     *
202
     * @var \DOMNode
203
     */
204
    protected $transp;
205
    /**
206
     * Node
207
     *
208
     * @var \DOMNode
209
     */
210
    protected $transporta;
211
    /**
212
     * Node
213
     *
214
     * @var \DOMNode
215
     */
216
    protected $veicTransp;
217
    /**
218
     * Node reboque
219
     *
220
     * @var \DOMNode
221
     */
222
    protected $reboque;
223
    /**
224
     * Node infAdic
225
     *
226
     * @var \DOMNode
227
     */
228
    protected $infAdic;
229
    /**
230
     * Tipo de emissão
231
     *
232
     * @var integer
233
     */
234
    protected $tpEmis;
235
    /**
236
     * Node infProt
237
     *
238
     * @var \DOMNode
239
     */
240
    protected $infProt;
241
    /**
242
     * 1-Retrato/ 2-Paisagem
243
     *
244
     * @var integer
245
     */
246
    protected $tpImp;
247
    /**
248
     * Node compra
249
     *
250
     * @var \DOMNode
251
     */
252
    protected $compra;
253
    /**
254
     * @var int
255
     */
256
    protected $textadicfontsize;
257
    /**
258
     * Número de casas para a quantidade de itens da unidade comercial.
259
     *
260
     * @var integer
261
     */
262
    protected $qComCasasDec = 4;
263
264
    /**
265
     * Número de casas decimais para o valor da unidade comercial.
266
     *
267
     * @var integer
268
     */
269
    protected $vUnComCasasDec = 4;
270
271
    /**
272
     * @var int
273
     */
274
    protected $hdadosadic = 10;
275
    /**
276
     *
277
     * @var array
278
     */
279
    protected $epec = [];
280
281
    /**
282
     * __construct
283
     *
284
     * @name  __construct
285
     *
286
     * @param string $xml Conteúdo XML da NF-e (com ou sem a tag nfeProc)
287
     */
288
    public function __construct($xml)
289
    {
290
        $this->loadDoc($xml);
291
    }
292
    
293
    public function epec($protocolo, $data)
294
    {
295
        if ($this->dom->getElementsByTagName("tpEmis")->item(0)->nodeValue != '4') {
296
            throw new \Exception('Esta nota não foi emitida em contingência EPEC, tpEmis != 4.');
297
        }
298
        $this->epec = [
299
            'protocolo' => $protocolo,
300
            'data' => $data
301
        ];
302
    }
303
304
305
    /**
306
     * Define a quantidade de casas decimais para unidade comercial.
307
     *
308
     * @param integer $vUnComCasasDec
309
     */
310
    public function setVUnComCasasDec($vUnComCasasDec)
311
    {
312
        $this->vUnComCasasDec = $vUnComCasasDec;
313
    }
314
315
    /**
316
     * Define a quantidade de casas decimais para unidade comercial.
317
     *
318
     * @param integer $qComCasasDec
319
     */
320
    public function setQComCasasDec($qComCasasDec)
321
    {
322
        $this->qComCasasDec = $qComCasasDec;
323
    }
324
325
    protected function calculoEspacoVericalDadosAdicionais()
326
    {
327
        $this->textoAdic = '';
328
        //informações adicionais
329
        $fontProduto            = [
330
            'font'  => $this->fontePadrao,
331
            'size'  => 8,
332
            'style' => ''
333
        ];
334
        $k                      = $this->pdf->k;
335
        $this->textadicfontsize = $fontProduto['size'] / $k;
0 ignored issues
show
Documentation Bug introduced by
It seems like $fontProduto['size'] / $k can also be of type double. However, the property $textadicfontsize is declared as type integer. 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...
336
        $this->textoAdic        .= $this->geraInformacoesDasNotasReferenciadas();
337
        if (isset($this->infAdic)) {
338
            $i = 0;
339
            if ($this->textoAdic != '') {
340
                $this->textoAdic .= ". \n";
341
            }
342
            $this->textoAdic .= ! empty($this->getTagValue($this->infAdic, "infCpl"))
343
                ? 'Inf. Contribuinte: ' . $this->anfaveaDANFE($this->getTagValue($this->infAdic, "infCpl"))
344
                : '';
345
            $infPedido       = $this->geraInformacoesDaTagCompra();
346
            if ($infPedido != "") {
347
                $this->textoAdic .= $infPedido;
348
            }
349
            $this->textoAdic .= $this->getTagValue($this->dest, "email", ' Email do Destinatário: ');
350
            $this->textoAdic .= ! empty($this->getTagValue($this->infAdic, "infAdFisco"))
351
                ? "\n Inf. fisco: " . $this->getTagValue($this->infAdic, "infAdFisco")
352
                : '';
353
            $obsCont         = $this->infAdic->getElementsByTagName("obsCont");
354
            if (isset($obsCont)) {
355
                foreach ($obsCont as $obs) {
356
                    $campo           = $obsCont->item($i)->getAttribute("xCampo");
357
                    $xTexto          = ! empty($obsCont->item($i)->getElementsByTagName("xTexto")->item(0)->nodeValue)
358
                        ? $obsCont->item($i)->getElementsByTagName("xTexto")->item(0)->nodeValue
359
                        : '';
360
                    $this->textoAdic .= "\n" . $campo . ':  ' . trim($xTexto);
361
                    $i ++;
362
                }
363
            }
364
        }
365
        //INCLUSO pela NT 2013.003 Lei da Transparência
366
        //verificar se a informação sobre o valor aproximado dos tributos
367
        //já se encontra no campo de informações adicionais
368
        if ($this->exibirValorTributos) {
369
            $flagVTT  = strpos(strtolower(trim($this->textoAdic)), 'valor');
370
            $flagVTT  = $flagVTT || strpos(strtolower(trim($this->textoAdic)), 'vl');
371
            $flagVTT  = $flagVTT && strpos(strtolower(trim($this->textoAdic)), 'aprox');
372
            $flagVTT  = $flagVTT && (strpos(strtolower(trim($this->textoAdic)), 'trib') ||
373
                    strpos(strtolower(trim($this->textoAdic)), 'imp'));
374
            $vTotTrib = $this->getTagValue($this->ICMSTot, 'vTotTrib');
375
            if ($vTotTrib != '' && ! $flagVTT) {
376
                $this->textoAdic .= "\n Valor Aproximado dos Tributos : R$ "
377
                    . number_format($vTotTrib, 2, ",", ".");
378
            }
379
        }
380
        //fim da alteração NT 2013.003 Lei da Transparência
381
        $this->textoAdic        = str_replace(";", "\n", $this->textoAdic);
382
        $numlinhasdados         = $this->pdf->getNumLines($this->textoAdic, $this->wAdic, $fontProduto) + 1.5;
383
        $this->textadicfontsize = $this->pdf->fontSize;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->pdf->fontSize can also be of type double. However, the property $textadicfontsize is declared as type integer. 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...
384
        $hdadosadic             = ceil($numlinhasdados * ($this->textadicfontsize));
385
        if ($hdadosadic > 70) {
386
            for ($f = 8; $f > 3; $f --) {
387
                $this->pdf->setFont($this->fontePadrao, '', $f);
388
                $fontProduto            = [
389
                    'font'  => $this->fontePadrao,
390
                    'size'  => $f,
391
                    'style' => ''
392
                ];
393
                $numlinhasdados         = $this->pdf->getNumLines($this->textoAdic, $this->wAdic, $fontProduto) + 3;
394
                $this->textadicfontsize = $this->pdf->fontSize;
395
                $hdadosadic             = ceil($numlinhasdados * $this->textadicfontsize);
396
                echo $hdadosadic;
397
                if ($hdadosadic <= 90) {
398
                    $hdadosadic = ceil($hdadosadic);
399
                    break;
400
                }
401
            }
402
        }
403
        if ($hdadosadic < 10) {
404
            $hdadosadic = 10;
405
        }
406
407
        return $hdadosadic;
408
    }
409
410
    protected function calculoItensPorPagina()
411
    {
412
    }
413
414
    /**
415
     * monta
416
     * Monta a DANFE conforme as informações fornecidas para a classe durante sua
417
     * construção. Constroi DANFEs com até 3 páginas podendo conter até 56 itens.
418
     * A definição de margens e posições iniciais para a impressão são estabelecidas
419
     * pelo conteúdo da funçao e podem ser modificados.
420
     *
421
     * @return string O ID da NFe numero de 44 digitos extraido do arquivo XML
422
     */
423
    protected function monta(
424
        $logo = ''
425
    ) {
426
        $this->pdf       = '';
0 ignored issues
show
Documentation Bug introduced by
It seems like '' of type string is incompatible with the declared type object<NFePHP\DA\Legacy\Pdf> of property $pdf.

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...
427
        $this->logomarca = $this->adjustImage($logo);
428
        //se a orientação estiver em branco utilizar o padrão estabelecido na NF
429
        if (empty($this->orientacao)) {
430
            if ($this->tpImp == '2') {
431
                $this->orientacao = 'L';
432
            } else {
433
                $this->orientacao = 'P';
434
            }
435
        }
436
        //instancia a classe pdf
437
        $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
0 ignored issues
show
Bug introduced by
It seems like $this->papel can also be of type array; however, NFePHP\DA\Legacy\Pdf::__construct() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
438
        //margens do PDF, em milímetros. Obs.: a margem direita é sempre igual à
439
        //margem esquerda. A margem inferior *não* existe na FPDF, é definida aqui
440
        //apenas para controle se necessário ser maior do que a margem superior
441
        // posição inicial do conteúdo, a partir do canto superior esquerdo da página
442
        $xInic = $this->margesq;
443
        if ($this->orientacao == 'P') {
444
            if ($this->papel == 'A4') {
445
                $this->maxW = 210;
0 ignored issues
show
Documentation Bug introduced by
The property $maxW was declared of type double, but 210 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
446
                $this->maxH = 297;
0 ignored issues
show
Documentation Bug introduced by
The property $maxH was declared of type double, but 297 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
447
            }
448
        } else {
449
            if ($this->papel == 'A4') {
450
                $this->maxW = 297;
0 ignored issues
show
Documentation Bug introduced by
The property $maxW was declared of type double, but 297 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
451
                $this->maxH = 210;
0 ignored issues
show
Documentation Bug introduced by
The property $maxH was declared of type double, but 210 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
452
                $xInic      = $this->margesq + 10;
453
                //se paisagem multiplica a largura do canhoto pela quantidade de canhotos
454
                //$this->wCanhoto *= $this->qCanhoto;
455
            }
456
        }
457
        //total inicial de paginas
458
        $totPag = 1;
0 ignored issues
show
Unused Code introduced by
$totPag 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...
459
        //largura imprimivel em mm: largura da folha menos as margens esq/direita
460
        $this->wPrint = $this->maxW - ($this->margesq * 2);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->maxW - $this->margesq * 2 can also be of type integer. However, the property $wPrint is declared as type double. 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...
461
        //comprimento (altura) imprimivel em mm: altura da folha menos as margens
462
        //superior e inferior
463
        $this->hPrint = $this->maxH - $this->margsup - $this->marginf;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->maxH - $this->margsup - $this->marginf can also be of type integer. However, the property $hPrint is declared as type double. 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...
464
        // estabelece contagem de paginas
465
        $this->pdf->aliasNbPages();
466
        // fixa as margens
467
        $this->pdf->setMargins($this->margesq, $this->margsup);
468
        $this->pdf->setDrawColor(0, 0, 0);
469
        $this->pdf->setFillColor(255, 255, 255);
470
        // inicia o documento
471
        $this->pdf->open();
472
        // adiciona a primeira página
473
        $this->pdf->addPage($this->orientacao, $this->papel);
0 ignored issues
show
Bug introduced by
It seems like $this->papel can also be of type array; however, NFePHP\DA\Legacy\FPDF\Fpdf::addPage() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
474
        $this->pdf->setLineWidth(0.1);
475
        $this->pdf->settextcolor(0, 0, 0);
476
477
        //##################################################################
478
        // CALCULO DO NUMERO DE PAGINAS A SEREM IMPRESSAS
479
        //##################################################################
480
        //Verificando quantas linhas serão usadas para impressão das duplicatas
481
        $linhasDup = 0;
482
        $qtdPag    = 0;
483
        if (isset($this->dup) && $this->dup->length > 0) {
484
            $qtdPag = $this->dup->length;
0 ignored issues
show
Bug introduced by
The property length does not seem to exist in DOMNode.

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...
485
        } elseif (isset($this->detPag) && $this->detPag->length > 0) {
0 ignored issues
show
Bug introduced by
The property detPag does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
486
            $qtdPag = $this->detPag->length;
487
        }
488
        if (($qtdPag > 0) && ($qtdPag <= 7)) {
489
            $linhasDup = 1;
490
        } elseif (($qtdPag > 7) && ($qtdPag <= 14)) {
491
            $linhasDup = 2;
492
        } elseif (($qtdPag > 14) && ($qtdPag <= 21)) {
493
            $linhasDup = 3;
494
        } elseif ($qtdPag > 21) {
495
            // chinnonsantos 11/05/2016: Limite máximo de impressão de duplicatas na NFe,
496
            // só vai ser exibito as 21 primeiras duplicatas (parcelas de pagamento),
497
            // se não oculpa espaço d+, cada linha comporta até 7 duplicatas.
498
            $linhasDup = 3;
499
        }
500
        //verifica se será impressa a linha dos serviços ISSQN
501
        $linhaISSQN = 0;
502
        if ((isset($this->ISSQNtot)) && ($this->getTagValue($this->ISSQNtot, 'vServ') > 0)) {
503
            $linhaISSQN = 1;
504
        }
505
        //calcular a altura necessária para os dados adicionais
506
        if ($this->orientacao == 'P') {
507
            $this->wAdic = round($this->wPrint * 0.66, 0);
508
        } else {
509
            $this->wAdic = round(($this->wPrint - $this->wCanhoto) * 0.5, 0);
510
        }
511
        $fontProduto = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
0 ignored issues
show
Unused Code introduced by
$fontProduto 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...
512
513
        $this->hdadosadic = $this->calculoEspacoVericalDadosAdicionais();
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->calculoEspacoVericalDadosAdicionais() can also be of type double. However, the property $hdadosadic is declared as type integer. 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...
514
515
        //altura disponivel para os campos da DANFE
516
        $hcabecalho    = 47;//para cabeçalho
517
        $hdestinatario = 25;//para destinatario
518
        $hduplicatas   = 12;//para cada grupo de 7 duplicatas
519
        if (isset($this->entrega)) {
520
            $hlocalentrega = 25;
521
        } else {
522
            $hlocalentrega = 0;
523
        }
524
        if (isset($this->retirada)) {
525
            $hlocalretirada = 25;
526
        } else {
527
            $hlocalretirada = 0;
528
        }
529
        $himposto    = 18;// para imposto
530
        $htransporte = 25;// para transporte
531
        $hissqn      = 11;// para issqn
532
        $hfooter     = 5;// para rodape
533
        $hCabecItens = 4;//cabeçalho dos itens
534
        $hOCUPADA    = $hcabecalho
535
            + $hdestinatario
536
            + $hlocalentrega
537
            + $hlocalretirada
538
            + ($linhasDup * $hduplicatas)
539
            + $himposto + $htransporte
540
            + ($linhaISSQN * $hissqn)
541
            + $this->hdadosadic
542
            + $hfooter
543
            + $hCabecItens
544
            + $this->sizeExtraTextoFatura();
545
546
        //alturas disponiveis para os dados
547
        $hDispo1 = $this->hPrint - $hOCUPADA;
548
        /*($hcabecalho +
549
        //$hdestinatario + ($linhasDup * $hduplicatas) + $himposto + $htransporte +
550
        $hdestinatario + $hlocalentrega + $hlocalretirada +
551
        ($linhasDup * $hduplicatas) + $himposto + $htransporte +
552
        ($linhaISSQN * $hissqn) + $this->hdadosadic + $hfooter + $hCabecItens +
553
        $this->sizeExtraTextoFatura());*/
554
555
        if ($this->orientacao == 'P') {
556
            $hDispo1 -= 24 * $this->qCanhoto;//para canhoto
557
            $w       = $this->wPrint;
558
        } else {
559
            $hcanhoto = $this->hPrint;//para canhoto
0 ignored issues
show
Unused Code introduced by
$hcanhoto 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...
560
            $w        = $this->wPrint - $this->wCanhoto;
561
        }
562
        //$hDispo1 += 14;
563
        $hDispo2 = $this->hPrint - ($hcabecalho + $hfooter + $hCabecItens);
564
        //Contagem da altura ocupada para impressão dos itens
565
        $aFont     = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
0 ignored issues
show
Unused Code introduced by
$aFont 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...
566
        $numlinhas = 0;
0 ignored issues
show
Unused Code introduced by
$numlinhas 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...
567
        $hUsado    = $hCabecItens;
568
        $w2        = round($w * 0.25, 0);
0 ignored issues
show
Unused Code introduced by
$w2 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...
569
        $hDispo    = $hDispo1;
570
        $totPag    = 1;
571
        $i         = 0;
572
        while ($i < $this->det->length) {
573
            $itemProd = $this->det->item($i);
574
            $texto = $this->descricaoProduto($itemProd);
0 ignored issues
show
Unused Code introduced by
$texto 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...
575
            $mostrarUnidadeTributavel = false;
576
577
            $prod = $itemProd->getElementsByTagName('prod')->item(0);
578
            $uCom = $prod->getElementsByTagName("uCom")->item(0)->nodeValue;
579
            $uTrib = $prod->getElementsByTagName("uTrib")->item(0);
580
            if (! empty($uTrib) && strcmp($uCom, $uTrib->nodeValue) != 0) {
581
                $mostrarUnidadeTributavel = true;
582
            }
583
584
            $hUsado += $this->calculeHeight($itemProd, $mostrarUnidadeTributavel);
585
            if ($hUsado > $hDispo) {
586
                $totPag ++;
587
                $hDispo = $hDispo2;
588
                $hUsado = $hCabecItens;
589
                $i --; // decrementa para readicionar o item que não coube nessa pagina na outra.
590
            }
591
            $i ++;
592
        } //fim da soma das areas de itens usadas
593
        $qtdeItens = $i; //controle da quantidade de itens no DANFE
594
        //montagem da primeira página
595
        $pag = 1;
596
597
        $x = $this->margesq;
598
        $y = $this->margsup;
599
        //coloca o(s) canhoto(s) da NFe
600
        if ($this->orientacao == 'P') {
601
            $y = $this->canhoto($this->margesq, $this->margsup);
602
        } else {
603
            $this->canhoto($this->margesq, $this->margsup);
604
            $x = 25;
605
        }
606
        //coloca o cabeçalho
607
        $y = $this->header($x, $y, $pag, $totPag);
608
        //coloca os dados do destinatário
609
        $y = $this->destinatarioDANFE($x, $y + 1);
610
        //coloca os dados do local de retirada
611
        if (isset($this->retirada)) {
612
            $y = $this->localRetiradaDANFE($x, $y + 1);
613
        }
614
        //coloca os dados do local de entrega
615
        if (isset($this->entrega)) {
616
            $y = $this->localEntregaDANFE($x, $y + 1);
617
        }
618
619
        //Verifica as formas de pagamento da nota fiscal
620
        $formaPag = [];
621
        if (isset($this->detPag) && $this->detPag->length > 0) {
622
            foreach ($this->detPag as $k => $d) {
623
                $fPag            = ! empty($this->detPag->item($k)->getElementsByTagName('tPag')->item(0)->nodeValue)
624
                    ? $this->detPag->item($k)->getElementsByTagName('tPag')->item(0)->nodeValue
625
                    : '0';
626
                $formaPag[$fPag] = $fPag;
627
            }
628
        }
629
        //caso tenha boleto imprimir fatura
630
        if ($this->dup->length > 0) {
631
            $y = $this->fatura($x, $y + 1);
632
        } else {
633
            //Se somente tiver a forma de pagamento sem pagamento não imprimir nada
634
            if (count($formaPag) == '1' && isset($formaPag[90])) {
635
                $y = $y;
0 ignored issues
show
Bug introduced by
Why assign $y to itself?

This checks looks for cases where a variable has been assigned to itself.

This assignement can be removed without consequences.

Loading history...
636
            } else {
637
                //caso tenha mais de uma forma de pagamento ou seja diferente de boleto exibe a
638
                //forma de pagamento e o valor
639
                $y = $this->pagamento($x, $y + 1);
640
            }
641
        }
642
        //coloca os dados dos impostos e totais da NFe
643
        $y = $this->imposto($x, $y + 1);
644
        //coloca os dados do trasnporte
645
        $y = $this->transporte($x, $y + 1);
646
        //itens da DANFE
647
        $nInicial = 0;
648
649
        $y = $this->itens($x, $y + 1, $nInicial, $hDispo1, $pag, $totPag, $hCabecItens);
650
651
        //coloca os dados do ISSQN
652
        if ($linhaISSQN == 1) {
653
            $y = $this->issqn($x, $y + 4);
654
        } else {
655
            $y += 4;
656
        }
657
        //coloca os dados adicionais da NFe
658
        $y = $this->dadosAdicionais($x, $y, $this->hdadosadic);
0 ignored issues
show
Unused Code introduced by
$y 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...
659
        //coloca o rodapé da página
660
        if ($this->orientacao == 'P') {
661
            $this->rodape($xInic);
662
        } else {
663
            $this->rodape($xInic);
664
        }
665
666
        //loop para páginas seguintes
667
        for ($n = 2; $n <= $totPag; $n ++) {
668
            // fixa as margens
669
            $this->pdf->setMargins($this->margesq, $this->margsup);
670
            //adiciona nova página
671
            $this->pdf->addPage($this->orientacao, $this->papel);
0 ignored issues
show
Bug introduced by
It seems like $this->papel can also be of type array; however, NFePHP\DA\Legacy\FPDF\Fpdf::addPage() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
672
            //ajusta espessura das linhas
673
            $this->pdf->setLineWidth(0.1);
674
            //seta a cor do texto para petro
675
            $this->pdf->settextcolor(0, 0, 0);
676
            // posição inicial do relatorio
677
            $x = $this->margesq;
678
            $y = $this->margsup;
679
            //coloca o cabeçalho na página adicional
680
            $y = $this->header($x, $y, $n, $totPag);
681
            //coloca os itens na página adicional
682
            $y = $this->itens($x, $y + 1, $nInicial, $hDispo2, $n, $totPag, $hCabecItens);
0 ignored issues
show
Unused Code introduced by
$y 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...
683
            //coloca o rodapé da página
684
            if ($this->orientacao == 'P') {
685
                $this->rodape($this->margesq);
686
            } else {
687
                $this->rodape($this->margesq);
688
            }
689
            //se estiver na última página e ainda restar itens para inserir, adiciona mais uma página
690
            if ($n == $totPag && $this->qtdeItensProc < $qtdeItens) {
691
                $totPag ++;
692
            }
693
        }
694
    }
695
696
    /**
697
     * anfavea
698
     * Função para transformar o campo cdata do padrão ANFAVEA para
699
     * texto imprimível
700
     *
701
     * @param string $cdata campo CDATA
702
     *
703
     * @return string conteúdo do campo CDATA como string
704
     */
705
    protected function anfaveaDANFE($cdata = '')
706
    {
707
        if ($cdata == '') {
708
            return '';
709
        }
710
        //remove qualquer texto antes ou depois da tag CDATA
711
        $cdata    = str_replace('<![CDATA[', '<CDATA>', $cdata);
712
        $cdata    = str_replace(']]>', '</CDATA>', $cdata);
713
        $cdata    = preg_replace('/\s\s+/', ' ', $cdata);
714
        $cdata    = str_replace("> <", "><", $cdata);
715
        $len      = strlen($cdata);
716
        $startPos = strpos($cdata, '<');
717
        if ($startPos === false) {
718
            return $cdata;
719
        }
720
        for ($x = $len; $x > 0; $x --) {
721
            if (substr($cdata, $x, 1) == '>') {
722
                $endPos = $x;
723
                break;
724
            }
725
        }
726
        if ($x === 0) {
727
            return $cdata;
728
        }
729
        if ($startPos > 0) {
730
            $parte1 = substr($cdata, 0, $startPos);
731
        } else {
732
            $parte1 = '';
733
        }
734
        $parte2 = substr($cdata, $startPos, $endPos - $startPos + 1);
0 ignored issues
show
Bug introduced by
The variable $endPos 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...
735
        if ($endPos < $len) {
736
            $parte3 = substr($cdata, $endPos + 1, $len - $endPos - 1);
737
        } else {
738
            $parte3 = '';
739
        }
740
        $texto = trim($parte1) . ' ' . trim($parte3);
741
        if (strpos($parte2, '<CDATA>') === false) {
742
            $cdata = '<CDATA>' . $parte2 . '</CDATA>';
743
        } else {
744
            $cdata = $parte2;
745
        }
746
        //Retira a tag <FONTE IBPT> (caso existir) pois não é uma estrutura válida XML
747
        $cdata = str_replace('<FONTE IBPT>', '', $cdata);
748
        //carrega o xml CDATA em um objeto DOM
749
        $dom = new Dom();
750
        $dom->loadXML($cdata, LIBXML_NOBLANKS | LIBXML_NOEMPTYTAG);
751
        //$xml = $dom->saveXML();
752
        //grupo CDATA infADprod
753
        $id   = $dom->getElementsByTagName('id')->item(0);
754
        $div  = $dom->getElementsByTagName('div')->item(0);
755
        $entg = $dom->getElementsByTagName('entg')->item(0);
756
        $dest = $dom->getElementsByTagName('dest')->item(0);
757
        $ctl  = $dom->getElementsByTagName('ctl')->item(0);
758
        $ref  = $dom->getElementsByTagName('ref')->item(0);
759
        if (isset($id)) {
760
            if ($id->hasAttributes()) {
761
                foreach ($id->attributes as $attr) {
762
                    $name  = $attr->nodeName;
763
                    $value = $attr->nodeValue;
764
                    $texto .= " $name : $value";
765
                }
766
            }
767
        }
768
        if (isset($div)) {
769
            if ($div->hasAttributes()) {
770
                foreach ($div->attributes as $attr) {
771
                    $name  = $attr->nodeName;
772
                    $value = $attr->nodeValue;
773
                    $texto .= " $name : $value";
774
                }
775
            }
776
        }
777
        if (isset($entg)) {
778
            if ($entg->hasAttributes()) {
779
                foreach ($entg->attributes as $attr) {
780
                    $name  = $attr->nodeName;
781
                    $value = $attr->nodeValue;
782
                    $texto .= " $name : $value";
783
                }
784
            }
785
        }
786
        if (isset($dest)) {
787
            if ($dest->hasAttributes()) {
788
                foreach ($dest->attributes as $attr) {
789
                    $name  = $attr->nodeName;
790
                    $value = $attr->nodeValue;
791
                    $texto .= " $name : $value";
792
                }
793
            }
794
        }
795
        if (isset($ctl)) {
796
            if ($ctl->hasAttributes()) {
797
                foreach ($ctl->attributes as $attr) {
798
                    $name  = $attr->nodeName;
799
                    $value = $attr->nodeValue;
800
                    $texto .= " $name : $value";
801
                }
802
            }
803
        }
804
        if (isset($ref)) {
805
            if ($ref->hasAttributes()) {
806
                foreach ($ref->attributes as $attr) {
807
                    $name  = $attr->nodeName;
808
                    $value = $attr->nodeValue;
809
                    $texto .= " $name : $value";
810
                }
811
            }
812
        }
813
        //grupo CADATA infCpl
814
        $t          = $dom->getElementsByTagName('transmissor')->item(0);
815
        $r          = $dom->getElementsByTagName('receptor')->item(0);
816
        $versao     = ! empty($dom->getElementsByTagName('versao')->item(0)->nodeValue) ?
817
            'Versao:' . $dom->getElementsByTagName('versao')->item(0)->nodeValue . ' ' : '';
818
        $especieNF  = ! empty($dom->getElementsByTagName('especieNF')->item(0)->nodeValue) ?
819
            'Especie:' . $dom->getElementsByTagName('especieNF')->item(0)->nodeValue . ' ' : '';
820
        $fabEntrega = ! empty($dom->getElementsByTagName('fabEntrega')->item(0)->nodeValue) ?
821
            'Entrega:' . $dom->getElementsByTagName('fabEntrega')->item(0)->nodeValue . ' ' : '';
822
        $dca        = ! empty($dom->getElementsByTagName('dca')->item(0)->nodeValue) ?
823
            'dca:' . $dom->getElementsByTagName('dca')->item(0)->nodeValue . ' ' : '';
824
        $texto      .= "" . $versao . $especieNF . $fabEntrega . $dca;
825
        if (isset($t)) {
826
            if ($t->hasAttributes()) {
827
                $texto .= " Transmissor ";
828
                foreach ($t->attributes as $attr) {
829
                    $name  = $attr->nodeName;
830
                    $value = $attr->nodeValue;
831
                    $texto .= " $name : $value";
832
                }
833
            }
834
        }
835
        if (isset($r)) {
836
            if ($r->hasAttributes()) {
837
                $texto .= " Receptor ";
838
                foreach ($r->attributes as $attr) {
839
                    $name  = $attr->nodeName;
840
                    $value = $attr->nodeValue;
841
                    $texto .= " $name : $value";
842
                }
843
            }
844
        }
845
846
        return $texto;
847
    }
848
849
    /**
850
     * Verifica o status da NFe
851
     *
852
     * @return array
853
     */
854
    protected function statusNFe()
855
    {
856
        $resp = [
857
            'status' => true,
858
            'message' => [],
859
            'submessage' => ''
860
        ];
861
        if (!empty($this->epec)) {
862
            return $resp;
863
        }
864
        if (!isset($this->nfeProc)) {
865
            $resp['status'] = false;
866
            $resp['message'][] = 'NFe NÃO PROTOCOLADA';
867
        } else {
868
            if ($this->getTagValue($this->ide, "tpAmb") == '2') {
869
                $resp['status'] = false;
870
                $resp['message'][] =  "NFe EMITIDA EM HOMOLOGAÇÃO";
871
            }
872
            $retEvento = $this->nfeProc->getElementsByTagName('retEvento')->item(0);
0 ignored issues
show
Bug introduced by
The property nfeProc does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
873
            $cStat = $this->getTagValue($this->nfeProc, "cStat");
874
            if ($cStat == '110' ||
875
                $cStat == '301' ||
876
                $cStat == '302'
877
            ) {
878
                $resp['status'] = false;
879
                $resp['message'][] = "NFe DENEGADA";
880
            } elseif ($cStat == '101'
881
                || $cStat == '151'
882
                || $cStat == '135'
883
                || $cStat == '155'
884
                || $this->cancelFlag === true
885
            ) {
886
                $resp['status'] = false;
887
                $resp['message'][] = "NFe CANCELADA";
888
            } elseif (!empty($retEvento)) {
889
                $infEvento = $retEvento->getElementsByTagName('infEvento')->item(0);
890
                $cStat = $this->getTagValue($infEvento, "cStat");
891
                $tpEvento= $this->getTagValue($infEvento, "tpEvento");
892
                $dhEvento = date("d/m/Y H:i:s", $this->toTimestamp($this->getTagValue($infEvento, "dhRegEvento")));
893
                $nProt = $this->getTagValue($infEvento, "nProt");
894
                if ($tpEvento == '110111' &&
895
                    ($cStat == '101' ||
896
                     $cStat == '151' ||
897
                     $cStat == '135' ||
898
                     $cStat == '155')
899
                ) {
900
                    $resp['status'] = false;
901
                    $resp['message'][] = "NFe CANCELADA";
902
                    $resp['submessage'] = "{$dhEvento} - {$nProt}";
903
                }
904
            }
905
        }
906
        return $resp;
907
    }
908
909
    /**
910
     *header
911
     * Monta o cabelhalho da DANFE (retrato e paisagem)
912
     *
913
     * @param number $x      Posição horizontal inicial, canto esquerdo
914
     * @param number $y      Posição vertical inicial, canto superior
915
     * @param number $pag    Número da Página
916
     * @param number $totPag Total de páginas
917
     *
918
     * @return number Posição vertical final
919
     */
920
    protected function header($x = 0, $y = 0, $pag = '1', $totPag = '1')
921
    {
922
        $oldX = $x;
923
        $oldY = $y;
924
        if ($this->orientacao == 'P') {
925
            $maxW = $this->wPrint;
926
        } else {
927
            if ($pag == 1) { // primeira página
928
                $maxW = $this->wPrint - $this->wCanhoto;
929
            } else { // páginas seguintes
930
                $maxW = $this->wPrint;
931
            }
932
        }
933
        //####################################################################################
934
        //coluna esquerda identificação do emitente
935
        $w = round($maxW * 0.41, 0);
936
        if ($this->orientacao == 'P') {
937
            $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => 'I'];
938
        } else {
939
            $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'];
940
        }
941
        $w1   = $w;
942
        $h    = 32;
943
        $oldY += $h;
944
        $this->pdf->textBox($x, $y, $w, $h);
945
        $texto = 'IDENTIFICAÇÃO DO EMITENTE';
946
        $this->pdf->textBox($x, $y, $w, 5, $texto, $aFont, 'T', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
947
        //estabelecer o alinhamento
948
        //pode ser left L, center C, right R, full logo L
949
        //se for left separar 1/3 da largura para o tamanho da imagem
950
        //os outros 2/3 serão usados para os dados do emitente
951
        //se for center separar 1/2 da altura para o logo e 1/2 para os dados
952
        //se for right separa 2/3 para os dados e o terço seguinte para o logo
953
        //se não houver logo centraliza dos dados do emitente
954
        // coloca o logo
955
        if (! empty($this->logomarca)) {
956
            $logoInfo = getimagesize($this->logomarca);
957
            //largura da imagem em mm
958
            $logoWmm = ($logoInfo[0] / 72) * 25.4;
959
            //altura da imagem em mm
960
            $logoHmm = ($logoInfo[1] / 72) * 25.4;
961
            if ($this->logoAlign == 'L') {
962
                $nImgW = round($w / 3, 0);
963
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
964
                $xImg  = $x + 1;
965
                $yImg  = round(($h - $nImgH) / 2, 0) + $y;
966
                //estabelecer posições do texto
967
                $x1 = round($xImg + $nImgW + 1, 0);
968
                $y1 = round($h / 3 + $y, 0);
969
                $tw = round(2 * $w / 3, 0);
970
            } elseif ($this->logoAlign == 'C') {
971
                $nImgH = round($h / 3, 0);
972
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
973
                $xImg  = round(($w - $nImgW) / 2 + $x, 0);
974
                $yImg  = $y + 3;
975
                $x1    = $x;
976
                $y1    = round($yImg + $nImgH + 1, 0);
977
                $tw    = $w;
978
            } elseif ($this->logoAlign == 'R') {
979
                $nImgW = round($w / 3, 0);
980
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
981
                $xImg  = round($x + ($w - (1 + $nImgW)), 0);
982
                $yImg  = round(($h - $nImgH) / 2, 0) + $y;
983
                $x1    = $x;
984
                $y1    = round($h / 3 + $y, 0);
985
                $tw    = round(2 * $w / 3, 0);
986
            } elseif ($this->logoAlign == 'F') {
987
                $nImgH = round($h - 5, 0);
988
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
989
                $xImg  = round(($w - $nImgW) / 2 + $x, 0);
990
                $yImg  = $y + 3;
991
                $x1    = $x;
992
                $y1    = round($yImg + $nImgH + 1, 0);
993
                $tw    = $w;
994
            }
995
            $type = (substr($this->logomarca, 0, 7) === 'data://') ? 'jpg' : null;
0 ignored issues
show
Unused Code introduced by
$type 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...
996
            $this->pdf->Image($this->logomarca, $xImg, $yImg, $nImgW, $nImgH, 'jpeg');
0 ignored issues
show
Bug introduced by
The variable $nImgH 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 $nImgW 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 $yImg 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 $xImg 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...
997
        } else {
998
            $x1 = $x;
999
            $y1 = round($h / 3 + $y, 0);
1000
            $tw = $w;
1001
        }
1002
        // monta as informações apenas se diferente de full logo
1003
        if ($this->logoAlign !== 'F') {
1004
            //Nome emitente
1005
            $aFont = ['font' => $this->fontePadrao, 'size' => 12, 'style' => 'B'];
1006
            $texto = $this->emit->getElementsByTagName("xNome")->item(0)->nodeValue;
1007
            $this->pdf->textBox($x1, $y1, $tw, 8, $texto, $aFont, 'T', 'C', 0, '');
0 ignored issues
show
Bug introduced by
The variable $x1 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 $tw 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 introduced by
0 is of type integer, but the function expects a boolean.

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...
Bug introduced by
The variable $y1 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...
1008
            //endereço
1009
            $y1     = $y1 + 5;
1010
            $aFont  = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
1011
            $fone   = ! empty($this->enderEmit->getElementsByTagName("fone")->item(0)->nodeValue)
1012
                ? $this->enderEmit->getElementsByTagName("fone")->item(0)->nodeValue
1013
                : '';
1014
            $lgr    = $this->getTagValue($this->enderEmit, "xLgr");
1015
            $nro    = $this->getTagValue($this->enderEmit, "nro");
1016
            $cpl    = $this->getTagValue($this->enderEmit, "xCpl", " - ");
1017
            $bairro = $this->getTagValue($this->enderEmit, "xBairro");
1018
            $CEP    = $this->getTagValue($this->enderEmit, "CEP");
1019
            $CEP    = $this->formatField($CEP, "#####-###");
1020
            $mun    = $this->getTagValue($this->enderEmit, "xMun");
1021
            $UF     = $this->getTagValue($this->enderEmit, "UF");
1022
            $texto  = $lgr . ", " . $nro . $cpl . "\n" . $bairro . " - "
1023
                . $CEP . "\n" . $mun . " - " . $UF . " "
1024
                . "Fone/Fax: " . $fone;
1025
            $this->pdf->textBox($x1, $y1, $tw, 8, $texto, $aFont, 'T', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1026
        }
1027
1028
        //####################################################################################
1029
        //coluna central Danfe
1030
        $x  += $w;
1031
        $w  = round($maxW * 0.17, 0);//35;
1032
        $w2 = $w;
1033
        $h  = 32;
1034
        $this->pdf->textBox($x, $y, $w, $h);
1035
1036
        $texto = "DANFE";
1037
        $aFont = ['font' => $this->fontePadrao, 'size' => 14, 'style' => 'B'];
1038
        $this->pdf->textBox($x, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1039
        $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
1040
        $texto = 'Documento Auxiliar da Nota Fiscal Eletrônica';
1041
        $h     = 20;
1042
        $this->pdf->textBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'C', 0, '', false);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1043
1044
        $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
1045
        $texto = '0 - ENTRADA';
1046
        $y1    = $y + 14;
1047
        $h     = 8;
1048
        $this->pdf->textBox($x + 2, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1049
        $texto = '1 - SAÍDA';
1050
        $y1    = $y + 17;
1051
        $this->pdf->textBox($x + 2, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1052
        //tipo de nF
1053
        $aFont = ['font' => $this->fontePadrao, 'size' => 12, 'style' => 'B'];
1054
        $y1    = $y + 13;
1055
        $h     = 7;
1056
        $texto = $this->ide->getElementsByTagName('tpNF')->item(0)->nodeValue;
1057
        $this->pdf->textBox($x + 27, $y1, 5, $h, $texto, $aFont, 'C', 'C', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1058
        //numero da NF
1059
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1060
        $y1    = $y + 20;
1061
        $numNF = str_pad(
1062
            $this->ide->getElementsByTagName('nNF')->item(0)->nodeValue,
1063
            9,
1064
            "0",
1065
            STR_PAD_LEFT
1066
        );
1067
        $numNF = $this->formatField($numNF, "###.###.###");
1068
        $texto = "Nº. " . $numNF;
1069
        $this->pdf->textBox($x, $y1, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1070
        //Série
1071
        $y1    = $y + 23;
1072
        $serie = str_pad(
1073
            $this->ide->getElementsByTagName('serie')->item(0)->nodeValue,
1074
            3,
1075
            "0",
1076
            STR_PAD_LEFT
1077
        );
1078
        $texto = "Série " . $serie;
1079
        $this->pdf->textBox($x, $y1, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1080
        //numero paginas
1081
        $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'I'];
1082
        $y1    = $y + 26;
1083
        $texto = "Folha " . $pag . "/" . $totPag;
1084
        $this->pdf->textBox($x, $y1, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1085
1086
        //####################################################################################
1087
        //coluna codigo de barras
1088
        $x  += $w;
1089
        $w  = ($maxW - $w1 - $w2);//85;
1090
        $w3 = $w;
1091
        $h  = 32;
1092
        $this->pdf->textBox($x, $y, $w, $h);
1093
        $this->pdf->setFillColor(0, 0, 0);
1094
        $chave_acesso = str_replace('NFe', '', $this->infNFe->getAttribute("Id"));
1095
        $bW           = 75;
1096
        $bH           = 12;
1097
        //codigo de barras
1098
        $this->pdf->code128($x + (($w - $bW) / 2), $y + 2, $chave_acesso, $bW, $bH);
1099
        //linhas divisorias
1100
        $this->pdf->line($x, $y + 4 + $bH, $x + $w, $y + 4 + $bH);
1101
        $this->pdf->line($x, $y + 12 + $bH, $x + $w, $y + 12 + $bH);
1102
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1103
        $y1    = $y + 4 + $bH;
1104
        $h     = 7;
1105
        $texto = 'CHAVE DE ACESSO';
1106
        $this->pdf->textBox($x, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1107
        $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'];
1108
        $y1    = $y + 8 + $bH;
1109
        $texto = $this->formatField($chave_acesso, $this->formatoChave);
1110
        $this->pdf->textBox($x + 2, $y1, $w - 2, $h, $texto, $aFont, 'T', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1111
        $y1                = $y + 12 + $bH;
1112
        $aFont             = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
1113
        $chaveContingencia = "";
1114
        if (!empty($this->epec)) {
1115
            $cabecalhoProtoAutorizacao = 'NÚMERO DE REGISTRO EPEC';
1116
        } else {
1117
            $cabecalhoProtoAutorizacao = 'PROTOCOLO DE AUTORIZAÇÃO DE USO';
1118
        }
1119
        if (($this->tpEmis == 2 || $this->tpEmis == 5) && empty($this->epec)) {
1120
            $cabecalhoProtoAutorizacao = "DADOS DA NF-E";
1121
            $chaveContingencia         = $this->geraChaveAdicionalDeContingencia();
1122
            $this->pdf->setFillColor(0, 0, 0);
1123
            //codigo de barras
1124
            $this->pdf->code128($x + 11, $y1 + 1, $chaveContingencia, $bW * .9, $bH / 2);
1125
        } else {
1126
            $texto = 'Consulta de autenticidade no portal nacional da NF-e';
1127
            $this->pdf->textBox($x + 2, $y1, $w - 2, $h, $texto, $aFont, 'T', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1128
            $y1    = $y + 16 + $bH;
1129
            $texto = 'www.nfe.fazenda.gov.br/portal ou no site da Sefaz Autorizadora';
1130
            $this->pdf->textBox(
1131
                $x + 2,
1132
                $y1,
1133
                $w - 2,
1134
                $h,
1135
                $texto,
1136
                $aFont,
1137
                'T',
1138
                'C',
1139
                0,
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1140
                'http://www.nfe.fazenda.gov.br/portal ou no site da Sefaz Autorizadora'
1141
            );
1142
        }
1143
1144
        //####################################################################################
1145
        //Dados da NF do cabeçalho
1146
        //natureza da operação
1147
        $texto = 'NATUREZA DA OPERAÇÃO';
1148
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1149
        $w     = $w1 + $w2;
1150
        $y     = $oldY;
1151
        $oldY  += $h;
1152
        $x     = $oldX;
1153
        $h     = 7;
1154
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1155
        $texto = $this->ide->getElementsByTagName("natOp")->item(0)->nodeValue;
1156
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1157
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1158
        $x += $w;
1159
        $w = $w3;
1160
        //PROTOCOLO DE AUTORIZAÇÃO DE USO ou DADOS da NF-E
1161
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1162
        $this->pdf->textBox($x, $y, $w, $h, $cabecalhoProtoAutorizacao, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1163
        // algumas NFe podem estar sem o protocolo de uso portanto sua existencia deve ser
1164
        // testada antes de tentar obter a informação.
1165
        // NOTA : DANFE sem protocolo deve existir somente no caso de contingência !!!
1166
        // Além disso, existem várias NFes em contingência que eu recebo com protocolo de autorização.
1167
        // Na minha opinião, deveríamos mostra-lo, mas o  manual  da NFe v4.01 diz outra coisa...
1168
        if (($this->tpEmis == 2 || $this->tpEmis == 5) && empty($this->epec)) {
1169
            $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'];
1170
            $texto = $this->formatField(
1171
                $chaveContingencia,
1172
                "#### #### #### #### #### #### #### #### ####"
1173
            );
1174
            $cStat = '';
0 ignored issues
show
Unused Code introduced by
$cStat 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...
1175
        } else {
1176
            $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1177
            if (!empty($this->epec)) {
1178
                $texto = $this->epec['protocolo'] . ' - ' . $this->epec['data'];
1179
                $cStat = '';
0 ignored issues
show
Unused Code introduced by
$cStat 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...
1180
            } else {
1181
                if (isset($this->nfeProc)) {
1182
                    $texto  = ! empty($this->nfeProc->getElementsByTagName("nProt")->item(0)->nodeValue)
1183
                        ? $this->nfeProc->getElementsByTagName("nProt")->item(0)->nodeValue
1184
                        : '';
1185
                    $tsHora = $this->toTimestamp(
1186
                        $this->nfeProc->getElementsByTagName("dhRecbto")->item(0)->nodeValue
1187
                    );
1188
                    if ($texto != '') {
1189
                        $texto .= "  -  " . date('d/m/Y H:i:s', $tsHora);
1190
                    }
1191
                    $cStat = $this->nfeProc->getElementsByTagName("cStat")->item(0)->nodeValue;
0 ignored issues
show
Unused Code introduced by
$cStat 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...
1192
                } else {
1193
                    $texto = '';
1194
                    $cStat = '';
0 ignored issues
show
Unused Code introduced by
$cStat 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...
1195
                }
1196
            }
1197
        }
1198
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1199
        //####################################################################################
1200
        //INSCRIÇÃO ESTADUAL
1201
        $w     = round($maxW * 0.250, 0);
1202
        $y     += $h;
1203
        $oldY  += $h;
1204
        $x     = $oldX;
1205
        $texto = 'INSCRIÇÃO ESTADUAL';
1206
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1207
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1208
        $texto = $this->getTagValue($this->emit, "IE");
1209
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1210
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1211
        //INSCRIÇÃO MUNICIPAL
1212
        $x     += $w;
1213
        $texto = 'INSCRIÇÃO MUNICIPAL';
1214
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1215
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1216
        $texto = $this->getTagValue($this->emit, "IM");
1217
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1218
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1219
        //INSCRIÇÃO ESTADUAL DO SUBST. TRIBUT.
1220
        $x     += $w;
1221
        $texto = 'INSCRIÇÃO ESTADUAL DO SUBST. TRIBUT.';
1222
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1223
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1224
        $texto = ! empty($this->emit->getElementsByTagName("IEST")->item(0)->nodeValue)
1225
            ? $this->emit->getElementsByTagName("IEST")->item(0)->nodeValue
1226
            : '';
1227
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1228
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1229
        //CNPJ
1230
        $x     += $w;
1231
        $w     = ($maxW - (3 * $w));
1232
        $texto = 'CNPJ';
1233
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1234
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1235
        //Pegando valor do CPF/CNPJ
1236
        if (! empty($this->emit->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1237
            $texto = $this->formatField(
1238
                $this->emit->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1239
                "###.###.###/####-##"
1240
            );
1241
        } else {
1242
            $texto = ! empty($this->emit->getElementsByTagName("CPF")->item(0)->nodeValue)
1243
                ? $this->formatField(
1244
                    $this->emit->getElementsByTagName("CPF")->item(0)->nodeValue,
1245
                    "###.###.###-##"
1246
                )
1247
                : '';
1248
        }
1249
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1250
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1251
1252
        //####################################################################################
1253
        //Indicação de NF Homologação, cancelamento e falta de protocolo
1254
        $tpAmb = $this->ide->getElementsByTagName('tpAmb')->item(0)->nodeValue;
0 ignored issues
show
Unused Code introduced by
$tpAmb 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...
1255
        //indicar cancelamento
1256
        $resp = $this->statusNFe();
1257
        if (!$resp['status']) {
1258
            $n = count($resp['message']);
1259
            $alttot = $n * 15;
1260
            $x = 10;
1261
            $y = $this->hPrint/2 - $alttot/2;
1262
            $h = 15;
1263
            $w = $maxW - (2 * $x);
1264
            $this->pdf->settextcolor(90, 90, 90);
1265
            
1266
            foreach ($resp['message'] as $msg) {
1267
                $aFont = ['font' => $this->fontePadrao, 'size' => 48, 'style' => 'B'];
1268
                $this->pdf->textBox($x, $y, $w, $h, $msg, $aFont, 'C', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1269
                $y += $h;
1270
            }
1271
            $texto = $resp['submessage'];
1272
            if (!empty($texto)) {
1273
                $y += 3;
1274
                $h = 5;
1275
                $aFont = ['font' => $this->fontePadrao, 'size' => 20, 'style' => 'B'];
1276
                $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1277
                $y += $h;
1278
            }
1279
            $y += 5;
1280
            $w = $maxW - (2 * $x);
1281
            $texto = "SEM VALOR FISCAL";
1282
            $aFont = ['font' => $this->fontePadrao, 'size' => 48, 'style' => 'B'];
1283
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1284
            $this->pdf->settextcolor(0, 0, 0);
1285
        }
1286
        if (!empty($this->epec) || $this->tpEmis == 4) {
1287
            //EPEC
1288
            $x = 10;
1289
            $y = $this->hPrint - 130;
1290
            $h = 25;
1291
            $w = $maxW - (2 * $x);
1292
            $this->pdf->SetTextColor(200, 200, 200);
1293
            $texto = "DANFE impresso em contingência -\n" .
1294
                "EPEC regularmente recebido pela Receita\n" .
1295
                "Federal do Brasil";
1296
            $aFont = ['font' => $this->fontePadrao, 'size' => 48, 'style' => 'B'];
1297
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1298
            $this->pdf->SetTextColor(0, 0, 0);
1299
        }
1300
1301
        return $oldY;
1302
    } //fim header
1303
1304
    /**
1305
     * destinatarioDANFE
1306
     * Monta o campo com os dados do destinatário na DANFE. (retrato e paisagem)
1307
     *
1308
     * @name   destinatarioDANFE
1309
     *
1310
     * @param number $x Posição horizontal canto esquerdo
1311
     * @param number $y Posição vertical canto superior
1312
     *
1313
     * @return number Posição vertical final
1314
     */
1315
    protected function destinatarioDANFE($x = 0, $y = 0)
1316
    {
1317
        //####################################################################################
1318
        //DESTINATÁRIO / REMETENTE
1319
        $oldX = $x;
1320
        $oldY = $y;
0 ignored issues
show
Unused Code introduced by
$oldY 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...
1321
        if ($this->orientacao == 'P') {
1322
            $maxW = $this->wPrint;
1323
        } else {
1324
            $maxW = $this->wPrint - $this->wCanhoto;
1325
        }
1326
        $w     = $maxW;
1327
        $h     = 7;
1328
        $texto = 'DESTINATÁRIO / REMETENTE';
1329
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1330
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1331
        //NOME / RAZÃO SOCIAL
1332
        $w     = round($maxW * 0.61, 0);
1333
        $w1    = $w;
1334
        $y     += 3;
1335
        $texto = 'NOME / RAZÃO SOCIAL';
1336
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1337
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1338
        $texto = $this->dest->getElementsByTagName("xNome")->item(0)->nodeValue;
1339
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1340
        if ($this->orientacao == 'P') {
1341
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1342
        } else {
1343
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1344
        }
1345
        //CNPJ / CPF
1346
        $x     += $w;
1347
        $w     = round($maxW * 0.23, 0);
1348
        $w2    = $w;
1349
        $texto = 'CNPJ / CPF';
1350
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1351
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1352
        //Pegando valor do CPF/CNPJ
1353
        if (! empty($this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1354
            $texto = $this->formatField(
1355
                $this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1356
                "###.###.###/####-##"
1357
            );
1358
        } else {
1359
            $texto = ! empty($this->dest->getElementsByTagName("CPF")->item(0)->nodeValue)
1360
                ? $this->formatField(
1361
                    $this->dest->getElementsByTagName("CPF")->item(0)->nodeValue,
1362
                    "###.###.###-##"
1363
                )
1364
                : '';
1365
        }
1366
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1367
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1368
        //DATA DA EMISSÃO
1369
        $x     += $w;
1370
        $w     = $maxW - ($w1 + $w2);
1371
        $wx    = $w;
1372
        $texto = 'DATA DA EMISSÃO';
1373
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1374
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1375
        $dEmi = ! empty($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue)
1376
            ? $this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue
1377
            : '';
1378
        if ($dEmi == '') {
1379
            $dEmi  = ! empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue)
1380
                ? $this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue
1381
                : '';
1382
            $aDemi = explode('T', $dEmi);
1383
            $dEmi  = $aDemi[0];
1384
        }
1385
        $texto = $this->ymdTodmy($dEmi);
1386
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1387
        if ($this->orientacao == 'P') {
1388
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1389
        } else {
1390
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1391
        }
1392
        //ENDEREÇO
1393
        $w     = round($maxW * 0.47, 0);
1394
        $w1    = $w;
1395
        $y     += $h;
1396
        $x     = $oldX;
1397
        $texto = 'ENDEREÇO';
1398
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1399
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1400
        $texto = $this->dest->getElementsByTagName("xLgr")->item(0)->nodeValue;
1401
        $texto .= ', ' . $this->dest->getElementsByTagName("nro")->item(0)->nodeValue;
1402
        $texto .= $this->getTagValue($this->dest, "xCpl", " - ");
1403
1404
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1405
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, '', true);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1406
        //BAIRRO / DISTRITO
1407
        $x     += $w;
1408
        $w     = round($maxW * 0.21, 0);
1409
        $w2    = $w;
1410
        $texto = 'BAIRRO / DISTRITO';
1411
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1412
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1413
        $texto = $this->dest->getElementsByTagName("xBairro")->item(0)->nodeValue;
1414
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1415
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1416
        //CEP
1417
        $x     += $w;
1418
        $w     = $maxW - $w1 - $w2 - $wx;
1419
        $w2    = $w;
0 ignored issues
show
Unused Code introduced by
$w2 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...
1420
        $texto = 'CEP';
1421
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1422
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1423
        $texto = ! empty($this->dest->getElementsByTagName("CEP")->item(0)->nodeValue)
1424
            ? $this->dest->getElementsByTagName("CEP")->item(0)->nodeValue
1425
            : '';
1426
        $texto = $this->formatField($texto, "#####-###");
1427
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1428
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1429
        //DATA DA SAÍDA
1430
        $x     += $w;
1431
        $w     = $wx;
1432
        $texto = 'DATA DA SAÍDA/ENTRADA';
1433
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1434
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1435
        $dSaiEnt = ! empty($this->ide->getElementsByTagName("dSaiEnt")->item(0)->nodeValue)
1436
            ? $this->ide->getElementsByTagName("dSaiEnt")->item(0)->nodeValue
1437
            : '';
1438
        if ($dSaiEnt == '') {
1439
            $dSaiEnt  = ! empty($this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue)
1440
                ? $this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue
1441
                : '';
1442
            $aDsaient = explode('T', $dSaiEnt);
1443
            $dSaiEnt  = $aDsaient[0];
1444
        }
1445
        $texto = $this->ymdTodmy($dSaiEnt);
1446
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1447
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1448
        //MUNICÍPIO
1449
        $w     = $w1;
1450
        $y     += $h;
1451
        $x     = $oldX;
1452
        $texto = 'MUNICÍPIO';
1453
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1454
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1455
        $texto = $this->dest->getElementsByTagName("xMun")->item(0)->nodeValue;
1456
        if (strtoupper(trim($texto)) == "EXTERIOR"
1457
            && $this->dest->getElementsByTagName("xPais")->length > 0
1458
        ) {
1459
            $texto .= " - " . $this->dest->getElementsByTagName("xPais")->item(0)->nodeValue;
1460
        }
1461
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1462
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1463
        //UF
1464
        $x     += $w;
1465
        $w     = 8;
1466
        $texto = 'UF';
1467
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1468
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1469
        $texto = $this->dest->getElementsByTagName("UF")->item(0)->nodeValue;
1470
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1471
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1472
        //FONE / FAX
1473
        $x     += $w;
1474
        $w     = round(($maxW - $w1 - $wx - 8) / 2, 0);
1475
        $w3    = $w;
1476
        $texto = 'FONE / FAX';
1477
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1478
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1479
        $texto = ! empty($this->dest->getElementsByTagName("fone")->item(0)->nodeValue)
1480
            ? $this->dest->getElementsByTagName("fone")->item(0)->nodeValue
1481
            : '';
1482
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1483
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1484
        //INSCRIÇÃO ESTADUAL
1485
        $x     += $w;
1486
        $w     = $maxW - $w1 - $wx - 8 - $w3;
1487
        $texto = 'INSCRIÇÃO ESTADUAL';
1488
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1489
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1490
        $IE    = $this->dest->getElementsByTagName("IE");
1491
        $texto = ($IE && $IE->length > 0) ? $IE->item(0)->nodeValue : '';
1492
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1493
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1494
        //HORA DA SAÍDA
1495
        $x     += $w;
1496
        $w     = $wx;
1497
        $texto = 'HORA DA SAÍDA/ENTRADA';
1498
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1499
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1500
        $hSaiEnt = ! empty($this->ide->getElementsByTagName("hSaiEnt")->item(0)->nodeValue)
1501
            ? $this->ide->getElementsByTagName("hSaiEnt")->item(0)->nodeValue
1502
            : '';
1503
        if ($hSaiEnt == '') {
1504
            $dhSaiEnt   = ! empty($this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue)
1505
                ? $this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue
1506
                : '';
1507
            $tsDhSaiEnt = $this->toTimestamp($dhSaiEnt);
1508
            if ($tsDhSaiEnt != '') {
1509
                $hSaiEnt = date('H:i:s', $tsDhSaiEnt);
1510
            }
1511
        }
1512
        $texto = $hSaiEnt;
1513
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1514
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1515
1516
        return ($y + $h);
1517
    } //fim da função destinatarioDANFE
1518
1519
    /**
1520
     * localEntregaDANFE
1521
     * Monta o campo com os dados do local de entrega na DANFE. (retrato e paisagem)
1522
     *
1523
     * @name   localEntregaDANFE
1524
     *
1525
     * @param number $x Posição horizontal canto esquerdo
1526
     * @param number $y Posição vertical canto superior
1527
     *
1528
     * @return number Posição vertical final
1529
     */
1530
    protected function localEntregaDANFE($x = 0, $y = 0)
1531
    {
1532
        //####################################################################################
1533
        //LOCAL DE ENTREGA
1534
        $oldX = $x;
1535
        if ($this->orientacao == 'P') {
1536
            $maxW = $this->wPrint;
1537
        } else {
1538
            $maxW = $this->wPrint - $this->wCanhoto;
1539
        }
1540
        $w     = $maxW;
1541
        $h     = 7;
1542
        $texto = 'INFORMAÇÕES DO LOCAL DE ENTREGA';
1543
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1544
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1545
        //NOME / RAZÃO SOCIAL
1546
        $w     = round($maxW * 0.61, 0);
1547
        $w1    = $w;
1548
        $y     += 3;
1549
        $texto = 'NOME / RAZÃO SOCIAL';
1550
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1551
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1552
        $texto = '';
1553
        if ($this->entrega->getElementsByTagName("xNome")->item(0)) {
1554
            $texto = $this->entrega->getElementsByTagName("xNome")->item(0)->nodeValue;
1555
        }
1556
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1557
        if ($this->orientacao == 'P') {
1558
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1559
        } else {
1560
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1561
        }
1562
        //CNPJ / CPF
1563
        $x     += $w;
1564
        $w     = round($maxW * 0.23, 0);
1565
        $w2    = $w;
1566
        $texto = 'CNPJ / CPF';
1567
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1568
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1569
        //Pegando valor do CPF/CNPJ
1570
        if (! empty($this->entrega->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1571
            $texto = $this->formatField(
1572
                $this->entrega->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1573
                "###.###.###/####-##"
1574
            );
1575
        } else {
1576
            $texto = ! empty($this->entrega->getElementsByTagName("CPF")->item(0)->nodeValue) ?
1577
                $this->formatField(
1578
                    $this->entrega->getElementsByTagName("CPF")->item(0)->nodeValue,
1579
                    "###.###.###-##"
1580
                ) : '';
1581
        }
1582
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1583
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1584
        //INSCRIÇÃO ESTADUAL
1585
        $x     += $w;
1586
        $w     = $maxW - ($w1 + $w2);
1587
        $wx    = $w;
1588
        $texto = 'INSCRIÇÃO ESTADUAL';
1589
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1590
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1591
        $texto = '';
1592
        if ($this->entrega->getElementsByTagName("IE")->item(0)) {
1593
            $texto = $this->entrega->getElementsByTagName("IE")->item(0)->nodeValue;
1594
        }
1595
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1596
        if ($this->orientacao == 'P') {
1597
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1598
        } else {
1599
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1600
        }
1601
        //ENDEREÇO
1602
        $w     = round($maxW * 0.355, 0) + $wx;
1603
        $w1    = $w;
1604
        $y     += $h;
1605
        $x     = $oldX;
1606
        $texto = 'ENDEREÇO';
1607
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1608
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1609
        $texto = $this->entrega->getElementsByTagName("xLgr")->item(0)->nodeValue;
1610
        $texto .= ', ' . $this->entrega->getElementsByTagName("nro")->item(0)->nodeValue;
1611
        $texto .= $this->getTagValue($this->entrega, "xCpl", " - ");
1612
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1613
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, '', true);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1614
        //BAIRRO / DISTRITO
1615
        $x     += $w;
1616
        $w     = round($maxW * 0.335, 0);
1617
        $w2    = $w;
1618
        $texto = 'BAIRRO / DISTRITO';
1619
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1620
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1621
        $texto = $this->entrega->getElementsByTagName("xBairro")->item(0)->nodeValue;
1622
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1623
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1624
        //CEP
1625
        $x     += $w;
1626
        $w     = $maxW - ($w1 + $w2);
1627
        $texto = 'CEP';
1628
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1629
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1630
        $texto = ! empty($this->entrega->getElementsByTagName("CEP")->item(0)->nodeValue) ?
1631
            $this->entrega->getElementsByTagName("CEP")->item(0)->nodeValue : '';
1632
        $texto = $this->formatField($texto, "#####-###");
1633
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1634
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1635
        //MUNICÍPIO
1636
        $w     = round($maxW * 0.805, 0);
1637
        $w1    = $w;
1638
        $y     += $h;
1639
        $x     = $oldX;
1640
        $texto = 'MUNICÍPIO';
1641
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1642
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1643
        $texto = $this->entrega->getElementsByTagName("xMun")->item(0)->nodeValue;
1644
        if (strtoupper(trim($texto)) == "EXTERIOR" && $this->entrega->getElementsByTagName("xPais")->length > 0) {
1645
            $texto .= " - " . $this->entrega->getElementsByTagName("xPais")->item(0)->nodeValue;
1646
        }
1647
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1648
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1649
        //UF
1650
        $x     += $w;
1651
        $w     = 8;
1652
        $texto = 'UF';
1653
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1654
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1655
        $texto = $this->entrega->getElementsByTagName("UF")->item(0)->nodeValue;
1656
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1657
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1658
        //FONE / FAX
1659
        $x     += $w;
1660
        $w     = $maxW - $w - $w1;
1661
        $texto = 'FONE / FAX';
1662
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1663
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1664
        $texto = ! empty($this->entrega->getElementsByTagName("fone")->item(0)->nodeValue) ?
1665
            $this->entrega->getElementsByTagName("fone")->item(0)->nodeValue : '';
1666
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1667
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1668
1669
        return ($y + $h);
1670
    } //fim da função localEntregaDANFE
1671
1672
    /**
1673
     * localretiradaDANFE
1674
     * Monta o campo com os dados do local de entrega na DANFE. (retrato e paisagem)
1675
     *
1676
     * @name   localretiradaDANFE
1677
     *
1678
     * @param number $x Posição horizontal canto esquerdo
1679
     * @param number $y Posição vertical canto superior
1680
     *
1681
     * @return number Posição vertical final
1682
     */
1683
    protected function localRetiradaDANFE($x = 0, $y = 0)
1684
    {
1685
        //####################################################################################
1686
        //LOCAL DE RETIRADA
1687
        $oldX = $x;
1688
        if ($this->orientacao == 'P') {
1689
            $maxW = $this->wPrint;
1690
        } else {
1691
            $maxW = $this->wPrint - $this->wCanhoto;
1692
        }
1693
        $w     = $maxW;
1694
        $h     = 7;
1695
        $texto = 'INFORMAÇÕES DO LOCAL DE RETIRADA';
1696
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1697
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1698
        //NOME / RAZÃO SOCIAL
1699
        $w     = round($maxW * 0.61, 0);
1700
        $w1    = $w;
1701
        $y     += 3;
1702
        $texto = 'NOME / RAZÃO SOCIAL';
1703
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1704
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1705
        $texto = '';
1706
        if ($this->retirada->getElementsByTagName("xNome")->item(0)) {
1707
            $texto = $this->retirada->getElementsByTagName("xNome")->item(0)->nodeValue;
1708
        }
1709
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1710
        if ($this->orientacao == 'P') {
1711
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1712
        } else {
1713
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1714
        }
1715
        //CNPJ / CPF
1716
        $x     += $w;
1717
        $w     = round($maxW * 0.23, 0);
1718
        $w2    = $w;
1719
        $texto = 'CNPJ / CPF';
1720
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1721
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1722
        //Pegando valor do CPF/CNPJ
1723
        if (! empty($this->retirada->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1724
            $texto = $this->formatField(
1725
                $this->retirada->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1726
                "###.###.###/####-##"
1727
            );
1728
        } else {
1729
            $texto = ! empty($this->retirada->getElementsByTagName("CPF")->item(0)->nodeValue) ?
1730
                $this->formatField(
1731
                    $this->retirada->getElementsByTagName("CPF")->item(0)->nodeValue,
1732
                    "###.###.###-##"
1733
                ) : '';
1734
        }
1735
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1736
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1737
        //INSCRIÇÃO ESTADUAL
1738
        $x     += $w;
1739
        $w     = $maxW - ($w1 + $w2);
1740
        $wx    = $w;
1741
        $texto = 'INSCRIÇÃO ESTADUAL';
1742
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1743
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1744
        $texto = '';
1745
        if ($this->retirada->getElementsByTagName("IE")->item(0)) {
1746
            $texto = $this->retirada->getElementsByTagName("IE")->item(0)->nodeValue;
1747
        }
1748
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1749
        if ($this->orientacao == 'P') {
1750
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1751
        } else {
1752
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1753
        }
1754
        //ENDEREÇO
1755
        $w     = round($maxW * 0.355, 0) + $wx;
1756
        $w1    = $w;
1757
        $y     += $h;
1758
        $x     = $oldX;
1759
        $texto = 'ENDEREÇO';
1760
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1761
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1762
        $texto = $this->retirada->getElementsByTagName("xLgr")->item(0)->nodeValue;
1763
        $texto .= ', ' . $this->retirada->getElementsByTagName("nro")->item(0)->nodeValue;
1764
        $texto .= $this->getTagValue($this->retirada, "xCpl", " - ");
1765
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1766
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, '', true);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1767
        //BAIRRO / DISTRITO
1768
        $x     += $w;
1769
        $w     = round($maxW * 0.335, 0);
1770
        $w2    = $w;
1771
        $texto = 'BAIRRO / DISTRITO';
1772
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1773
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1774
        $texto = $this->retirada->getElementsByTagName("xBairro")->item(0)->nodeValue;
1775
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1776
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1777
        //CEP
1778
        $x     += $w;
1779
        $w     = $maxW - ($w1 + $w2);
1780
        $texto = 'CEP';
1781
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1782
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1783
        $texto = ! empty($this->retirada->getElementsByTagName("CEP")->item(0)->nodeValue) ?
1784
            $this->retirada->getElementsByTagName("CEP")->item(0)->nodeValue : '';
1785
        $texto = $this->formatField($texto, "#####-###");
1786
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1787
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1788
        //MUNICÍPIO
1789
        $w     = round($maxW * 0.805, 0);
1790
        $w1    = $w;
1791
        $y     += $h;
1792
        $x     = $oldX;
1793
        $texto = 'MUNICÍPIO';
1794
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1795
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1796
        $texto = $this->retirada->getElementsByTagName("xMun")->item(0)->nodeValue;
1797
        if (strtoupper(trim($texto)) == "EXTERIOR" && $this->retirada->getElementsByTagName("xPais")->length > 0) {
1798
            $texto .= " - " . $this->retirada->getElementsByTagName("xPais")->item(0)->nodeValue;
1799
        }
1800
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1801
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1802
        //UF
1803
        $x     += $w;
1804
        $w     = 8;
1805
        $texto = 'UF';
1806
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1807
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1808
        $texto = $this->retirada->getElementsByTagName("UF")->item(0)->nodeValue;
1809
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1810
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1811
        //FONE / FAX
1812
        $x     += $w;
1813
        $w     = $maxW - $w - $w1;
1814
        $texto = 'FONE / FAX';
1815
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1816
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1817
        $texto = ! empty($this->retirada->getElementsByTagName("fone")->item(0)->nodeValue) ?
1818
            $this->retirada->getElementsByTagName("fone")->item(0)->nodeValue : '';
1819
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1820
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1821
1822
        return ($y + $h);
1823
    } //fim da função localRetiradaDANFE
1824
1825
    /**
1826
     * getTextoFatura
1827
     * Gera a String do Texto da Fatura
1828
     *
1829
     * @name   getTextoFatura
1830
     * @return uma String com o texto ou "";
1831
     */
1832
    protected function getTextoFatura()
1833
    {
1834
        if (isset($this->cobr)) {
1835
            $fat = $this->cobr->getElementsByTagName("fat")->item(0);
1836
            if (isset($fat)) {
1837
                if (! empty($this->getTagValue($this->ide, "indPag"))) {
1838
                    $textoIndPag = "";
1839
                    $indPag      = $this->getTagValue($this->ide, "indPag");
1840
                    if ($indPag === "0") {
1841
                        $textoIndPag = "Pagamento à Vista - ";
1842
                    } elseif ($indPag === "1") {
1843
                        $textoIndPag = "Pagamento à Prazo - ";
1844
                    }
1845
                    $nFat  = $this->getTagValue($fat, "nFat", "Fatura: ");
1846
                    $vOrig = $this->getTagValue($fat, "vOrig", " Valor Original: ");
1847
                    $vDesc = $this->getTagValue($fat, "vDesc", " Desconto: ");
1848
                    $vLiq  = $this->getTagValue($fat, "vLiq", " Valor Líquido: ");
1849
                    $texto = $textoIndPag . $nFat . $vOrig . $vDesc . $vLiq;
1850
1851
                    return $texto;
1852
                } else {
1853
                    $pag = $this->dom->getElementsByTagName("pag");
1854
                    if ($tPag = $this->getTagValue($pag->item(0), "tPag")) {
1855
                        return $this->tipoPag($tPag);
1856
                    }
1857
                }
1858
            }
1859
        }
1860
        return "";
1861
    }
1862
1863
    /**
1864
     * sizeExtraTextoFatura
1865
     * Calcula o espaço ocupado pelo texto da fatura. Este espaço só é utilizado quando não houver duplicata.
1866
     *
1867
     * @name   sizeExtraTextoFatura
1868
     * @return integer
1869
     */
1870
    protected function sizeExtraTextoFatura()
1871
    {
1872
        $textoFatura = $this->getTextoFatura();
1873
        //verificar se existem duplicatas
1874
        if ($this->dup->length == 0 && $textoFatura !== "") {
0 ignored issues
show
Bug introduced by
The property length does not seem to exist in DOMNode.

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...
1875
            return 10;
1876
        }
1877
1878
        return 0;
1879
    }
1880
1881
    /**
1882
     * fatura
1883
     * Monta o campo de duplicatas da DANFE (retrato e paisagem)
1884
     *
1885
     * @name   fatura
1886
     *
1887
     * @param number $x Posição horizontal canto esquerdo
1888
     * @param number $y Posição vertical canto superior
1889
     *
1890
     * @return number Posição vertical final
1891
     */
1892
    protected function fatura($x, $y)
1893
    {
1894
        $linha       = 1;
1895
        $h           = 8 + 3;
0 ignored issues
show
Unused Code introduced by
$h 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...
1896
        $oldx        = $x;
1897
        $textoFatura = $this->getTextoFatura();
1898
        //verificar se existem duplicatas
1899
        if ($this->dup->length > 0 || $textoFatura !== "") {
1900
            //#####################################################################
1901
            //FATURA / DUPLICATA
1902
            $texto = "FATURA / DUPLICATA";
1903
            if ($this->orientacao == 'P') {
1904
                $w = $this->wPrint;
1905
            } else {
1906
                $w = 271;
1907
            }
1908
            $h     = 8;
1909
            $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1910
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1911
            $y       += 3;
1912
            $dups    = "";
0 ignored issues
show
Unused Code introduced by
$dups 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...
1913
            $dupcont = 0;
1914
            $nFat    = $this->dup->length;
0 ignored issues
show
Bug introduced by
The property length does not seem to exist in DOMNode.

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...
1915
            if ($nFat > 7) {
1916
                $myH = 6;
1917
                $myW = $this->wPrint;
1918
                if ($this->orientacao == 'L') {
1919
                    $myW -= $this->wCanhoto;
1920
                }
1921
                $aFont = ['font' => $this->fontePadrao, 'size' => 9, 'style' => ''];
1922
                $texto = "Existem mais de 7 duplicatas registradas, portanto não "
1923
                    . "serão exibidas, confira diretamente pelo XML.";
1924
                $this->pdf->textBox($x, $y, $myW, $myH, $texto, $aFont, 'C', 'C', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1925
1926
                return ($y + $h - 3);
1927
            }
1928
            if ($textoFatura !== "" && $this->exibirTextoFatura) {
1929
                $myH = 6;
1930
                $myW = $this->wPrint;
1931
                if ($this->orientacao == 'L') {
1932
                    $myW -= $this->wCanhoto;
1933
                }
1934
                $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
1935
                $this->pdf->textBox($x, $y, $myW, $myH, $textoFatura, $aFont, 'C', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1936
                $y += $myH + 1;
1937
            }
1938
            if ($this->orientacao == 'P') {
1939
                $w = round($this->wPrint / 7.018, 0) - 1;
1940
            } else {
1941
                $w = 28;
1942
            }
1943
            $increm = 1;
1944
            foreach ($this->dup as $k => $d) {
0 ignored issues
show
Bug introduced by
The expression $this->dup of type object<DOMNode> is not traversable.
Loading history...
1945
                $nDup  = ! empty($this->dup->item($k)->getElementsByTagName('nDup')->item(0)->nodeValue)
1946
                    ? $this->dup->item($k)->getElementsByTagName('nDup')->item(0)->nodeValue
1947
                    : '';
1948
                $dDup  = ! empty($this->dup->item($k)->getElementsByTagName('dVenc')->item(0)->nodeValue)
1949
                    ? $this->ymdTodmy($this->dup->item($k)->getElementsByTagName('dVenc')->item(0)->nodeValue)
1950
                    : '';
1951
                $vDup  = ! empty($this->dup->item($k)->getElementsByTagName('vDup')->item(0)->nodeValue)
1952
                    ? 'R$ ' . number_format(
1953
                        $this->dup->item($k)->getElementsByTagName('vDup')->item(0)->nodeValue,
1954
                        2,
1955
                        ",",
1956
                        "."
1957
                    )
1958
                    : '';
1959
                $h     = 8;
1960
                $texto = '';
0 ignored issues
show
Unused Code introduced by
$texto 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...
1961
                if ($nDup != '0' && $nDup != '') {
1962
                    $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1963
                    $this->pdf->textBox($x, $y, $w, $h, 'Num.', $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1964
                    $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1965
                    $this->pdf->textBox($x, $y, $w, $h, $nDup, $aFont, 'T', 'R', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1966
                } else {
1967
                    $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1968
                    $this->pdf->textBox($x, $y, $w, $h, ($dupcont + 1) . "", $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
1969
                }
1970
                $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1971
                $this->pdf->textBox($x, $y, $w, $h, 'Venc.', $aFont, 'C', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1972
                $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1973
                $this->pdf->textBox($x, $y, $w, $h, $dDup, $aFont, 'C', 'R', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1974
                $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1975
                $this->pdf->textBox($x, $y, $w, $h, 'Valor', $aFont, 'B', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1976
                $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1977
                $this->pdf->textBox($x, $y, $w, $h, $vDup, $aFont, 'B', 'R', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
1978
                $x       += $w + $increm;
1979
                $dupcont += 1;
1980
                if ($this->orientacao == 'P') {
1981
                    $maxDupCont = 6;
1982
                } else {
1983
                    $maxDupCont = 8;
1984
                }
1985
                if ($dupcont > $maxDupCont) {
1986
                    $y       += 9;
1987
                    $x       = $oldx;
1988
                    $dupcont = 0;
1989
                    $linha   += 1;
1990
                }
1991
                if ($linha == 5) {
1992
                    $linha = 4;
1993
                    break;
1994
                }
1995
            }
1996
            if ($dupcont == 0) {
1997
                $y -= 9;
1998
                $linha --;
1999
            }
2000
2001
            return ($y + $h);
2002
        } else {
2003
            $linha = 0;
0 ignored issues
show
Unused Code introduced by
$linha 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...
2004
2005
            return ($y - 2);
2006
        }
2007
    }
2008
2009
    /**
2010
     * pagamento
2011
     * Monta o campo de pagamentos da DANFE (retrato e paisagem) (foi baseada na fatura)
2012
     *
2013
     * @name   pagamento
2014
     *
2015
     * @param number $x Posição horizontal canto esquerdo
2016
     * @param number $y Posição vertical canto superior
2017
     *
2018
     * @return number Posição vertical final
2019
     */
2020
    protected function pagamento($x, $y)
2021
    {
2022
        $linha = 1;
2023
        $h     = 8 + 3;
0 ignored issues
show
Unused Code introduced by
$h 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...
2024
        $oldx  = $x;
2025
        //verificar se existem cobranças definidas
2026
        if (isset($this->detPag) && $this->detPag->length > 0) {
2027
            //#####################################################################
2028
            //Tipo de pagamento
2029
            $texto = "PAGAMENTO";
2030
            if ($this->orientacao == 'P') {
2031
                $w = $this->wPrint;
2032
            } else {
2033
                $w = 271;
2034
            }
2035
            $h     = 8;
2036
            $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2037
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2038
            $y       += 3;
2039
            $dups    = "";
0 ignored issues
show
Unused Code introduced by
$dups 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...
2040
            $dupcont = 0;
2041
            if ($this->orientacao == 'P') {
2042
                $w = round($this->wPrint / 7.018, 0) - 1;
2043
            } else {
2044
                $w = 28;
2045
            }
2046
            if ($this->orientacao == 'P') {
2047
                $maxDupCont = 6;
2048
            } else {
2049
                $maxDupCont = 8;
2050
            }
2051
            $increm         = 1;
2052
            $formaPagamento = [
2053
                '01' => 'Dinheiro',
2054
                '02' => 'Cheque',
2055
                '03' => 'Cartão de Crédito',
2056
                '04' => 'Cartão de Débito',
2057
                '05' => 'Crédito Loja',
2058
                '10' => 'Vale Alimentação',
2059
                '11' => 'Vale Refeição',
2060
                '12' => 'Vale Presente',
2061
                '13' => 'Vale Combustível',
2062
                '14' => 'Duplicata Mercantil',
2063
                '15' => 'Boleto',
2064
                '16' => 'Depósito Bancário',
2065
                '17' => 'Pagamento Instantâneo (PIX)',
2066
                '18' => 'Transferência bancária, Carteira Digital',
2067
                '19' => 'Programa de fidelidade, Cashback, Crédito Virtual',
2068
                '90' => 'Sem pagamento',
2069
                '99' => 'Outros'
2070
            ];
2071
            $bandeira       = [
0 ignored issues
show
Unused Code introduced by
$bandeira 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...
2072
                '01' => 'Visa',
2073
                '02' => 'Mastercard',
2074
                '03' => 'American',
2075
                '04' => 'Sorocred',
2076
                '05' => 'Diners',
2077
                '06' => 'Elo',
2078
                '07' => 'Hipercard',
2079
                '08' => 'Aura',
2080
                '09' => 'Cabal',
2081
                '99' => 'Outros'
2082
            ];
2083
            foreach ($this->detPag as $k => $d) {
2084
                $fPag  = ! empty($this->detPag->item($k)->getElementsByTagName('tPag')->item(0)->nodeValue)
2085
                    ? $this->detPag->item($k)->getElementsByTagName('tPag')->item(0)->nodeValue
2086
                    : '0';
2087
                $vPag  = ! empty($this->detPag->item($k)->getElementsByTagName('vPag')->item(0)->nodeValue)
2088
                    ? 'R$ ' . number_format(
2089
                        $this->detPag->item($k)->getElementsByTagName('vPag')->item(0)->nodeValue,
2090
                        2,
2091
                        ",",
2092
                        "."
2093
                    )
2094
                    : '';
2095
                $h     = 6;
2096
                $texto = '';
0 ignored issues
show
Unused Code introduced by
$texto 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...
2097
                if (isset($formaPagamento[$fPag])) {
2098
                    /*Exibir Item sem pagamento*/
2099
                    if ($fPag == '90') {
2100
                        continue;
2101
                    }
2102
                    $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2103
                    $this->pdf->textBox($x, $y, $w, $h, 'Forma', $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
2104
                    $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2105
                    $this->pdf->textBox($x, $y, $w, $h, $formaPagamento[$fPag], $aFont, 'T', 'R', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2106
                } else {
2107
                    $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
2108
                    $this->pdf->textBox($x, $y, $w, $h, "Forma " . $fPag . " não encontrado", $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
2109
                }
2110
                $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2111
                $this->pdf->textBox($x, $y, $w, $h, 'Valor', $aFont, 'B', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2112
                $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2113
                $this->pdf->textBox($x, $y, $w, $h, $vPag, $aFont, 'B', 'R', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2114
                $x       += $w + $increm;
2115
                $dupcont += 1;
2116
2117
                if ($dupcont > $maxDupCont) {
2118
                    $y       += 9;
2119
                    $x       = $oldx;
2120
                    $dupcont = 0;
2121
                    $linha   += 1;
2122
                }
2123
                if ($linha == 5) {
2124
                    $linha = 4;
2125
                    break;
2126
                }
2127
            }
2128
            if ($dupcont == 0) {
2129
                $y -= 9;
2130
                $linha --;
2131
            }
2132
2133
            return ($y + $h);
2134
        } else {
2135
            $linha = 0;
0 ignored issues
show
Unused Code introduced by
$linha 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...
2136
2137
            return ($y - 2);
2138
        }
2139
    } //fim da função pagamento
2140
2141
    /**
2142
     * impostoHelper
2143
     * Auxilia a montagem dos campos de impostos e totais da DANFE
2144
     *
2145
     * @name   impostoHelper
2146
     *
2147
     * @param float $x Posição horizontal canto esquerdo
2148
     * @param float $y Posição vertical canto superior
2149
     * @param float $w Largura do campo
2150
     * @param float $h Altura do campo
2151
     * @param float $h Título do campo
2152
     * @param float $h Valor do imposto
2153
     *
2154
     * @return float Sugestão do $x do próximo imposto
2155
     */
2156
    protected function impostoHelper($x, $y, $w, $h, $titulo, $campoImposto)
2157
    {
2158
        $valorImposto = '0,00';
2159
        $the_field    = $this->ICMSTot->getElementsByTagName($campoImposto)->item(0);
2160
        if (isset($the_field)) {
2161
            $the_value = $the_field->nodeValue;
2162
            if (! empty($the_value)) {
2163
                $valorImposto = number_format($the_value, 2, ",", ".");
2164
            }
2165
        }
2166
2167
        $fontTitulo = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2168
        $fontValor  = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2169
        $this->pdf->textBox($x, $y, $w, $h, $titulo, $fontTitulo, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
2170
        $this->pdf->textBox($x, $y, $w, $h, $valorImposto, $fontValor, 'B', 'R', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2171
2172
        $next_x = $x + $w;
2173
2174
        return $next_x;
2175
    }
2176
2177
    /**
2178
     * imposto
2179
     * Monta o campo de impostos e totais da DANFE (retrato e paisagem)
2180
     *
2181
     * @param number $x Posição horizontal canto esquerdo
2182
     * @param number $y Posição vertical canto superior
2183
     *
2184
     * @return number Posição vertical final
2185
     */
2186
    protected function imposto($x, $y)
2187
    {
2188
        $x_inicial = $x;
2189
        //#####################################################################
2190
        $campos_por_linha = 9;
2191
        if (! $this->exibirPIS) {
2192
            $campos_por_linha --;
2193
        }
2194
        if (! $this->exibirIcmsInterestadual) {
2195
            $campos_por_linha -= 2;
2196
        }
2197
2198
        if ($this->orientacao == 'P') {
2199
            $maxW       = $this->wPrint;
2200
            $title_size = 31;
2201
        } else {
2202
            $maxW       = $this->wPrint - $this->wCanhoto;
2203
            $title_size = 40;
2204
        }
2205
        $w = $maxW / $campos_por_linha;
2206
2207
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2208
        $texto = "CÁLCULO DO IMPOSTO";
2209
        $this->pdf->textBox($x, $y, $title_size, 8, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2210
        $y += 3;
2211
        $h = 7;
2212
2213
        $x = $this->impostoHelper($x, $y, $w, $h, "BASE DE CÁLC. DO ICMS", "vBC");
2214
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO ICMS", "vICMS");
2215
        $x = $this->impostoHelper($x, $y, $w, $h, "BASE DE CÁLC. ICMS S.T.", "vBCST");
2216
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO ICMS SUBST.", "vST");
2217
        $x = $this->impostoHelper($x, $y, $w, $h, "V. IMP. IMPORTAÇÃO", "vII");
2218
2219
        if ($this->exibirIcmsInterestadual) {
2220
            $x = $this->impostoHelper($x, $y, $w, $h, "V. ICMS UF REMET.", "vICMSUFRemet");
2221
            $x = $this->impostoHelper($x, $y, $w, $h, "V. FCP UF DEST.", "vFCPUFDest");
2222
        }
2223
2224
        if ($this->exibirPIS) {
2225
            $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO PIS", "vPIS");
2226
        }
2227
2228
        $x = $this->impostoHelper($x, $y, $w, $h, "V. TOTAL PRODUTOS", "vProd");
0 ignored issues
show
Unused Code introduced by
$x 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...
2229
2230
        //
2231
2232
        $y += $h;
2233
        $x = $x_inicial;
2234
2235
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO FRETE", "vFrete");
2236
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO SEGURO", "vSeg");
2237
        $x = $this->impostoHelper($x, $y, $w, $h, "DESCONTO", "vDesc");
2238
        $x = $this->impostoHelper($x, $y, $w, $h, "OUTRAS DESPESAS", "vOutro");
2239
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR TOTAL IPI", "vIPI");
2240
2241
        if ($this->exibirIcmsInterestadual) {
2242
            $x = $this->impostoHelper($x, $y, $w, $h, "V. ICMS UF DEST.", "vICMSUFDest");
2243
            $x = $this->impostoHelper($x, $y, $w, $h, "V. TOT. TRIB.", "vTotTrib");
2244
        }
2245
        if ($this->exibirPIS) {
2246
            $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DA COFINS", "vCOFINS");
2247
        }
2248
        $x = $this->impostoHelper($x, $y, $w, $h, "V. TOTAL DA NOTA", "vNF");
0 ignored issues
show
Unused Code introduced by
$x 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...
2249
2250
        return ($y + $h);
2251
    } //fim imposto
2252
2253
    /**
2254
     * transporte
2255
     * Monta o campo de transportes da DANFE (retrato e paisagem)
2256
     *
2257
     * @name   transporte
2258
     *
2259
     * @param float $x Posição horizontal canto esquerdo
2260
     * @param float $y Posição vertical canto superior
2261
     *
2262
     * @return float Posição vertical final
2263
     */
2264
    protected function transporte($x, $y)
2265
    {
2266
        $oldX = $x;
2267
        if ($this->orientacao == 'P') {
2268
            $maxW = $this->wPrint;
2269
        } else {
2270
            $maxW = $this->wPrint - $this->wCanhoto;
2271
        }
2272
        //#####################################################################
2273
        //TRANSPORTADOR / VOLUMES TRANSPORTADOS
2274
        $texto = "TRANSPORTADOR / VOLUMES TRANSPORTADOS";
2275
        $w     = $maxW;
2276
        $h     = 7;
2277
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2278
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2279
        //NOME / RAZÃO SOCIAL
2280
        $w1    = $maxW * 0.29;
2281
        $y     += 3;
2282
        $texto = 'NOME / RAZÃO SOCIAL';
2283
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2284
        $this->pdf->textBox($x, $y, $w1, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
2285
        if (isset($this->transporta)) {
2286
            $texto = ! empty($this->transporta->getElementsByTagName("xNome")->item(0)->nodeValue)
2287
                ? $this->transporta->getElementsByTagName("xNome")->item(0)->nodeValue
2288
                : '';
2289
        } else {
2290
            $texto = '';
2291
        }
2292
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2293
        $this->pdf->textBox($x, $y, $w1, $h, $texto, $aFont, 'B', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2294
        //FRETE POR CONTA
2295
        $x     += $w1;
2296
        $w2    = $maxW * 0.15;
2297
        $texto = 'FRETE';
2298
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2299
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
2300
        $tipoFrete = ! empty($this->transp->getElementsByTagName("modFrete")->item(0)->nodeValue)
2301
            ? $this->transp->getElementsByTagName("modFrete")->item(0)->nodeValue
2302
            : '0';
2303
        switch ($tipoFrete) {
2304
            case 0:
2305
                $texto = "0-Por conta do Rem";
2306
                break;
2307
            case 1:
2308
                $texto = "1-Por conta do Dest";
2309
                break;
2310
            case 2:
2311
                $texto = "2-Por conta de Terceiros";
2312
                break;
2313
            case 3:
2314
                $texto = "3-Próprio por conta do Rem";
2315
                break;
2316
            case 4:
2317
                $texto = "4-Próprio por conta do Dest";
2318
                break;
2319
            case 9:
2320
                $texto = "9-Sem Transporte";
2321
                break;
2322
        }
2323
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2324
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'C', 'C', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
2325
        //CÓDIGO ANTT
2326
        $x     += $w2;
2327
        $texto = 'CÓDIGO ANTT';
2328
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2329
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
2330
        if (isset($this->veicTransp)) {
2331
            $texto = ! empty($this->veicTransp->getElementsByTagName("RNTC")->item(0)->nodeValue)
2332
                ? $this->veicTransp->getElementsByTagName("RNTC")->item(0)->nodeValue
2333
                : '';
2334
        } else {
2335
            $texto = '';
2336
        }
2337
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2338
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2339
        //PLACA DO VEÍC
2340
        $x     += $w2;
2341
        $texto = 'PLACA DO VEÍCULO';
2342
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2343
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
2344
        if (isset($this->veicTransp)) {
2345
            $texto = ! empty($this->veicTransp->getElementsByTagName("placa")->item(0)->nodeValue)
2346
                ? $this->veicTransp->getElementsByTagName("placa")->item(0)->nodeValue
2347
                : '';
2348
        } elseif (isset($this->reboque)) {
2349
            $texto = ! empty($this->reboque->getElementsByTagName("placa")->item(0)->nodeValue)
2350
                ? $this->reboque->getElementsByTagName("placa")->item(0)->nodeValue
2351
                : '';
2352
        } else {
2353
            $texto = '';
2354
        }
2355
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2356
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2357
        //UF
2358
        $x     += $w2;
2359
        $w3    = round($maxW * 0.04, 0);
2360
        $texto = 'UF';
2361
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2362
        $this->pdf->textBox($x, $y, $w3, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
2363
        if (isset($this->veicTransp)) {
2364
            $texto = ! empty($this->veicTransp->getElementsByTagName("UF")->item(0)->nodeValue)
2365
                ? $this->veicTransp->getElementsByTagName("UF")->item(0)->nodeValue
2366
                : '';
2367
        } elseif (isset($this->reboque)) {
2368
            $texto = ! empty($this->reboque->getElementsByTagName("UF")->item(0)->nodeValue)
2369
                ? $this->reboque->getElementsByTagName("UF")->item(0)->nodeValue
2370
                : '';
2371
        } else {
2372
            $texto = '';
2373
        }
2374
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2375
        $this->pdf->textBox($x, $y, $w3, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2376
        //CNPJ / CPF
2377
        $x     += $w3;
2378
        $w     = $maxW - ($w1 + 3 * $w2 + $w3);
2379
        $texto = 'CNPJ / CPF';
2380
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2381
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
2382
        if (isset($this->transporta)) {
2383
            $texto = ! empty($this->transporta->getElementsByTagName("CNPJ")->item(0)->nodeValue)
2384
                ? $this->formatField(
2385
                    $this->transporta->getElementsByTagName("CNPJ")->item(0)->nodeValue,
2386
                    "##.###.###/####-##"
2387
                )
2388
                : '';
2389
            if ($texto == '') {
2390
                $texto = ! empty($this->transporta->getElementsByTagName("CPF")->item(0)->nodeValue)
2391
                    ? $this->formatField(
2392
                        $this->transporta->getElementsByTagName("CPF")->item(0)->nodeValue,
2393
                        "###.###.###-##"
2394
                    )
2395
                    : '';
2396
            }
2397
        } else {
2398
            $texto = '';
2399
        }
2400
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2401
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2402
        //#####################################################################
2403
        //ENDEREÇO
2404
        $y     += $h;
2405
        $x     = $oldX;
2406
        $h     = 7;
2407
        $w1    = $maxW * 0.44;
2408
        $texto = 'ENDEREÇO';
2409
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2410
        $this->pdf->textBox($x, $y, $w1, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
2411
        if (isset($this->transporta)) {
2412
            $texto = ! empty($this->transporta->getElementsByTagName("xEnder")->item(0)->nodeValue)
2413
                ? $this->transporta->getElementsByTagName("xEnder")->item(0)->nodeValue
2414
                : '';
2415
        } else {
2416
            $texto = '';
2417
        }
2418
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2419
        $this->pdf->textBox($x, $y, $w1, $h, $texto, $aFont, 'B', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2420
        //MUNICÍPIO
2421
        $x     += $w1;
2422
        $w2    = round($maxW * 0.30, 0);
2423
        $texto = 'MUNICÍPIO';
2424
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2425
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
2426
        if (isset($this->transporta)) {
2427
            $texto = ! empty($this->transporta->getElementsByTagName("xMun")->item(0)->nodeValue)
2428
                ? $this->transporta->getElementsByTagName("xMun")->item(0)->nodeValue
2429
                : '';
2430
        } else {
2431
            $texto = '';
2432
        }
2433
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2434
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2435
        //UF
2436
        $x     += $w2;
2437
        $w3    = round($maxW * 0.04, 0);
2438
        $texto = 'UF';
2439
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2440
        $this->pdf->textBox($x, $y, $w3, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
2441
        if (isset($this->transporta)) {
2442
            $texto = ! empty($this->transporta->getElementsByTagName("UF")->item(0)->nodeValue)
2443
                ? $this->transporta->getElementsByTagName("UF")->item(0)->nodeValue
2444
                : '';
2445
        } else {
2446
            $texto = '';
2447
        }
2448
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2449
        $this->pdf->textBox($x, $y, $w3, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2450
        //INSCRIÇÃO ESTADUAL
2451
        $x     += $w3;
2452
        $w     = $maxW - ($w1 + $w2 + $w3);
2453
        $texto = 'INSCRIÇÃO ESTADUAL';
2454
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2455
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
2456
        $texto = '';
2457
        if (isset($this->transporta)) {
2458
            if (! empty($this->transporta->getElementsByTagName("IE")->item(0)->nodeValue)) {
2459
                $texto = $this->transporta->getElementsByTagName("IE")->item(0)->nodeValue;
2460
            }
2461
        }
2462
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2463
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2464
        //Tratar Multiplos volumes
2465
        $volumes     = $this->transp->getElementsByTagName('vol');
2466
        $quantidade  = 0;
2467
        $especie     = '';
2468
        $marca       = '';
2469
        $numero      = '';
2470
        $texto       = '';
0 ignored issues
show
Unused Code introduced by
$texto 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...
2471
        $pesoBruto   = 0;
2472
        $pesoLiquido = 0;
2473
        foreach ($volumes as $volume) {
2474
            $quantidade  += ! empty($volume->getElementsByTagName("qVol")->item(0)->nodeValue) ?
2475
                $volume->getElementsByTagName("qVol")->item(0)->nodeValue : 0;
2476
            $pesoBruto   += ! empty($volume->getElementsByTagName("pesoB")->item(0)->nodeValue) ?
2477
                $volume->getElementsByTagName("pesoB")->item(0)->nodeValue : 0;
2478
            $pesoLiquido += ! empty($volume->getElementsByTagName("pesoL")->item(0)->nodeValue) ?
2479
                $volume->getElementsByTagName("pesoL")->item(0)->nodeValue : 0;
2480
            $texto       = ! empty($this->transp->getElementsByTagName("esp")->item(0)->nodeValue) ?
2481
                $this->transp->getElementsByTagName("esp")->item(0)->nodeValue : '';
2482
            if ($texto != $especie && $especie != '') {
2483
                //tem várias especies
2484
                $especie = 'VARIAS';
2485
            } else {
2486
                $especie = $texto;
2487
            }
2488
            $texto = ! empty($this->transp->getElementsByTagName("marca")->item(0)->nodeValue)
2489
                ? $this->transp->getElementsByTagName("marca")->item(0)->nodeValue
2490
                : '';
2491
            if ($texto != $marca && $marca != '') {
2492
                //tem várias especies
2493
                $marca = 'VARIAS';
2494
            } else {
2495
                $marca = $texto;
2496
            }
2497
            $texto = ! empty($this->transp->getElementsByTagName("nVol")->item(0)->nodeValue)
2498
                ? $this->transp->getElementsByTagName("nVol")->item(0)->nodeValue
2499
                : '';
2500
            if ($texto != $numero && $numero != '') {
2501
                //tem várias especies
2502
                $numero = 'VARIOS';
2503
            } else {
2504
                $numero = $texto;
2505
            }
2506
        }
2507
2508
        //#####################################################################
2509
        //QUANTIDADE
2510
        $y     += $h;
2511
        $x     = $oldX;
2512
        $h     = 7;
2513
        $w1    = round($maxW * 0.10, 0);
2514
        $texto = 'QUANTIDADE';
2515
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2516
        $this->pdf->textBox($x, $y, $w1, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
2517
        if (! empty($quantidade)) {
2518
            $texto = $quantidade;
2519
            $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2520
            $this->pdf->textBox($x, $y, $w1, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2521
        }
2522
        //ESPÉCIE
2523
        $x     += $w1;
2524
        $w2    = round($maxW * 0.17, 0);
2525
        $texto = 'ESPÉCIE';
2526
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2527
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
2528
        $texto = $especie;
2529
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2530
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2531
        //MARCA
2532
        $x     += $w2;
2533
        $texto = 'MARCA';
2534
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2535
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
2536
        $texto = ! empty($this->transp->getElementsByTagName("marca")->item(0)->nodeValue) ?
2537
            $this->transp->getElementsByTagName("marca")->item(0)->nodeValue : '';
2538
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2539
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2540
        //NUMERAÇÃO
2541
        $x     += $w2;
2542
        $texto = 'NUMERAÇÃO';
2543
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2544
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
2545
        $texto = $numero;
2546
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2547
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2548
        //PESO BRUTO
2549
        $x     += $w2;
2550
        $w3    = round($maxW * 0.20, 0);
2551
        $texto = 'PESO BRUTO';
2552
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2553
        $this->pdf->textBox($x, $y, $w3, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
2554
        if (is_numeric($pesoBruto) && $pesoBruto > 0) {
2555
            $texto = number_format($pesoBruto, 3, ",", ".");
2556
        } else {
2557
            $texto = '';
2558
        }
2559
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2560
        $this->pdf->textBox($x, $y, $w3, $h, $texto, $aFont, 'B', 'R', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2561
        //PESO LÍQUIDO
2562
        $x     += $w3;
2563
        $w     = $maxW - ($w1 + 3 * $w2 + $w3);
2564
        $texto = 'PESO LÍQUIDO';
2565
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2566
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
2567
        if (is_numeric($pesoLiquido) && $pesoLiquido > 0) {
2568
            $texto = number_format($pesoLiquido, 3, ",", ".");
2569
        } else {
2570
            $texto = '';
2571
        }
2572
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2573
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'R', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2574
2575
        return ($y + $h);
2576
    } //fim transporte
2577
2578
2579
    protected function descricaoProdutoHelper($origem, $campo, $formato)
2580
    {
2581
        $valor_original = $origem->getElementsByTagName($campo)->item(0);
2582
        if (! isset($valor_original)) {
2583
            return "";
2584
        }
2585
        $valor_original = $valor_original->nodeValue;
2586
        $valor          = ! empty($valor_original) ? number_format($valor_original, 2, ",", ".") : '';
2587
2588
        if ($valor != "") {
2589
            return sprintf($formato, $valor);
2590
        }
2591
2592
        return "";
2593
    }
2594
2595
    /**
2596
     * descricaoProduto
2597
     * Monta a string de descrição de cada Produto
2598
     *
2599
     * @name   descricaoProduto
2600
     *
2601
     * @param DOMNode itemProd
2602
     *
2603
     * @return string descricao do produto
2604
     */
2605
    protected function descricaoProduto($itemProd)
2606
    {
2607
        $prod       = $itemProd->getElementsByTagName('prod')->item(0);
2608
        $ICMS       = $itemProd->getElementsByTagName("ICMS")->item(0);
2609
        $ICMSUFDest = $itemProd->getElementsByTagName("ICMSUFDest")->item(0);
2610
        $impostos   = '';
2611
2612
        if (! empty($ICMS)) {
2613
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vBCFCP", " BcFcp=%s");
2614
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pFCP", " pFcp=%s%%");
2615
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vFCP", " vFcp=%s");
2616
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pRedBC", " pRedBC=%s%%");
2617
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pMVAST", " IVA/MVA=%s%%");
2618
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pICMSST", " pIcmsSt=%s%%");
2619
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vBCST", " BcIcmsSt=%s");
2620
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vICMSST", " vIcmsSt=%s");
2621
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vBCFCPST", " BcFcpSt=%s");
2622
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pFCPST", " pFcpSt=%s%%");
2623
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vFCPST", " vFcpSt=%s");
2624
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vBCSTRet", " Retido na compra: BASE ICMS ST=%s");
2625
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pST", " pSt=%s");
2626
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vICMSSTRet", " VALOR ICMS ST=%s");
2627
        }
2628
        if (! empty($ICMSUFDest)) {
2629
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "pFCPUFDest", " pFCPUFDest=%s%%");
2630
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "pICMSUFDest", " pICMSUFDest=%s%%");
2631
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "pICMSInterPart", " pICMSInterPart=%s%%");
2632
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "vFCPUFDest", " vFCPUFDest=%s");
2633
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "vICMSUFDest", " vICMSUFDest=%s");
2634
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "vICMSUFRemet", " vICMSUFRemet=%s");
2635
        }
2636
        $infAdProd = ! empty($itemProd->getElementsByTagName('infAdProd')->item(0)->nodeValue)
2637
            ? substr(
2638
                $this->anfaveaDANFE($itemProd->getElementsByTagName('infAdProd')->item(0)->nodeValue),
2639
                0,
2640
                500
2641
            )
2642
            : '';
2643
        if (! empty($infAdProd)) {
2644
            $infAdProd = trim($infAdProd);
2645
            $infAdProd .= ' ';
2646
        }
2647
        $loteTxt = '';
2648
        $rastro  = $prod->getElementsByTagName("med");
0 ignored issues
show
Unused Code introduced by
$rastro 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...
2649
        if (! empty($prod->getElementsByTagName("rastro"))) {
2650
            $rastro = $prod->getElementsByTagName("rastro");
2651
            $i      = 0;
2652
            while ($i < $rastro->length) {
2653
                $loteTxt .= $this->getTagValue($rastro->item($i), 'nLote', ' Lote: ');
2654
                $loteTxt .= $this->getTagValue($rastro->item($i), 'qLote', ' Quant: ');
2655
                $loteTxt .= $this->getTagDate($rastro->item($i), 'dFab', ' Fab: ');
2656
                $loteTxt .= $this->getTagDate($rastro->item($i), 'dVal', ' Val: ');
2657
                $loteTxt .= $this->getTagValue($rastro->item($i), 'vPMC', ' PMC: ');
2658
                $i ++;
2659
            }
2660
            if ($loteTxt != '') {
2661
                $loteTxt .= ' ';
2662
            }
2663
        }
2664
        //NT2013.006 FCI
2665
        $nFCI   = (! empty($itemProd->getElementsByTagName('nFCI')->item(0)->nodeValue)) ?
2666
            ' FCI:' . $itemProd->getElementsByTagName('nFCI')->item(0)->nodeValue : '';
2667
        $tmp_ad = $infAdProd . ($this->descProdInfoComplemento ? $loteTxt . $impostos . $nFCI : '');
2668
        $texto  = $prod->getElementsByTagName("xProd")->item(0)->nodeValue
2669
            . (strlen($tmp_ad) != 0 ? "\n    " . $tmp_ad : '');
2670
        //decodifica os caracteres html no xml
2671
        $texto = html_entity_decode($texto);
2672
        if ($this->descProdQuebraLinha) {
2673
            $texto = str_replace(";", "\n", $texto);
2674
        }
2675
2676
        return $texto;
2677
    }
2678
2679
    /**
2680
     * itens
2681
     * Monta o campo de itens da DANFE (retrato e paisagem)
2682
     *
2683
     * @name   itens
2684
     *
2685
     * @param float $x       Posição horizontal canto esquerdo
2686
     * @param float $y       Posição vertical canto superior
2687
     * @param float $nInicio Número do item inicial
2688
     * @param float $max     Número do item final
0 ignored issues
show
Bug introduced by
There is no parameter named $max. 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...
2689
     * @param float $hmax    Altura máxima do campo de itens em mm
2690
     *
2691
     * @return float Posição vertical final
2692
     */
2693
    protected function itens($x, $y, &$nInicio, $hmax, $pag = 0, $totpag = 0, $hCabecItens = 7)
2694
    {
2695
        $oldX = $x;
2696
        $oldY = $y;
2697
        $totItens = $this->det->length;
0 ignored issues
show
Bug introduced by
The property length does not seem to exist in DOMNode.

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...
2698
        //#####################################################################
2699
        //DADOS DOS PRODUTOS / SERVIÇOS
2700
        $texto = "DADOS DOS PRODUTOS / SERVIÇOS";
2701
        if ($this->orientacao == 'P') {
2702
            $w = $this->wPrint;
2703
        } else {
2704
            if ($nInicio < 2) { // primeira página
2705
                $w = $this->wPrint - $this->wCanhoto;
2706
            } else { // páginas seguintes
2707
                $w = $this->wPrint;
2708
            }
2709
        }
2710
        $h     = 4;
2711
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2712
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2713
        $y += 3;
2714
        //desenha a caixa dos dados dos itens da NF
2715
        $hmax  += 1;
2716
        $texto = '';
0 ignored issues
show
Unused Code introduced by
$texto 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...
2717
        $this->pdf->textBox($x, $y, $w, $hmax);
2718
        //##################################################################################
2719
        // cabecalho LOOP COM OS DADOS DOS PRODUTOS
2720
        //CÓDIGO PRODUTO
2721
        $texto = "CÓDIGO PRODUTO";
2722
        $w1    = round($w * 0.09, 0);
2723
        $h     = 4;
2724
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2725
        $this->pdf->textBox($x, $y, $w1, $h, $texto, $aFont, 'C', 'C', 0, '', false);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2726
        $this->pdf->line($x + $w1, $y, $x + $w1, $y + $hmax);
2727
        //DESCRIÇÃO DO PRODUTO / SERVIÇO
2728
        $x     += $w1;
2729
        $w2    = round($w * 0.25, 0);
2730
        $texto = 'DESCRIÇÃO DO PRODUTO / SERVIÇO';
2731
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2732
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'C', 'C', 0, '', false);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2733
        $this->pdf->line($x + $w2, $y, $x + $w2, $y + $hmax);
2734
        //NCM/SH
2735
        $x     += $w2;
2736
        $w3    = round($w * 0.06, 0);
2737
        $texto = 'NCM/SH';
2738
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2739
        $this->pdf->textBox($x, $y, $w3, $h, $texto, $aFont, 'C', 'C', 0, '', false);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2740
        $this->pdf->line($x + $w3, $y, $x + $w3, $y + $hmax);
2741
        //O/CST ou O/CSOSN
2742
        $x     += $w3;
2743
        $w4    = round($w * 0.05, 0);
2744
        $texto = 'O/CST'; // CRT = 2 ou CRT = 3
2745
        if ($this->getTagValue($this->emit, 'CRT') == '1') {
2746
            $texto = 'O/CSOSN';//Regime do Simples CRT = 1
2747
        }
2748
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2749
        $this->pdf->textBox($x, $y, $w4, $h, $texto, $aFont, 'C', 'C', 0, '', false);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2750
        $this->pdf->line($x + $w4, $y, $x + $w4, $y + $hmax);
2751
        //CFOP
2752
        $x     += $w4;
2753
        $w5    = round($w * 0.04, 0);
2754
        $texto = 'CFOP';
2755
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2756
        $this->pdf->textBox($x, $y, $w5, $h, $texto, $aFont, 'C', 'C', 0, '', false);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2757
        $this->pdf->line($x + $w5, $y, $x + $w5, $y + $hmax);
2758
        //UN
2759
        $x     += $w5;
2760
        $w6    = round($w * 0.03, 0);
2761
        $texto = 'UN';
2762
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2763
        $this->pdf->textBox($x, $y, $w6, $h, $texto, $aFont, 'C', 'C', 0, '', false);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2764
        $this->pdf->line($x + $w6, $y, $x + $w6, $y + $hmax);
2765
        //QUANT
2766
        $x     += $w6;
2767
        $w7    = round($w * 0.08, 0);
2768
        $texto = 'QUANT';
2769
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2770
        $this->pdf->textBox($x, $y, $w7, $h, $texto, $aFont, 'C', 'C', 0, '', false);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2771
        $this->pdf->line($x + $w7, $y, $x + $w7, $y + $hmax);
2772
        //VALOR UNIT
2773
        $x     += $w7;
2774
        $w8    = round($w * 0.06, 0);
2775
        $texto = 'VALOR UNIT';
2776
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2777
        $this->pdf->textBox($x, $y, $w8, $h, $texto, $aFont, 'C', 'C', 0, '', false);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2778
        $this->pdf->line($x + $w8, $y, $x + $w8, $y + $hmax);
2779
        //VALOR TOTAL
2780
        $x     += $w8;
2781
        $w9    = round($w * 0.06, 0);
2782
        $texto = 'VALOR TOTAL';
2783
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2784
        $this->pdf->textBox($x, $y, $w9, $h, $texto, $aFont, 'C', 'C', 0, '', false);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2785
        $this->pdf->line($x + $w9, $y, $x + $w9, $y + $hmax);
2786
        //VALOR DESCONTO
2787
        $x     += $w9;
2788
        $w10   = round($w * 0.05, 0);
2789
        $texto = 'VALOR DESC';
2790
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2791
        $this->pdf->textBox($x, $y, $w10, $h, $texto, $aFont, 'C', 'C', 0, '', false);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2792
        $this->pdf->line($x + $w10, $y, $x + $w10, $y + $hmax);
2793
        //B.CÁLC ICMS
2794
        $x     += $w10;
2795
        $w11   = round($w * 0.06, 0);
2796
        $texto = 'B.CÁLC ICMS';
2797
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2798
        $this->pdf->textBox($x, $y, $w11, $h, $texto, $aFont, 'C', 'C', 0, '', false);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2799
        $this->pdf->line($x + $w11, $y, $x + $w11, $y + $hmax);
2800
        //VALOR ICMS
2801
        $x     += $w11;
2802
        $w12   = round($w * 0.06, 0);
2803
        $texto = 'VALOR ICMS';
2804
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2805
        $this->pdf->textBox($x, $y, $w12, $h, $texto, $aFont, 'C', 'C', 0, '', false);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2806
        $this->pdf->line($x + $w12, $y, $x + $w12, $y + $hmax);
2807
        //VALOR IPI
2808
        $x     += $w12;
2809
        $w13   = round($w * 0.05, 0);
2810
        $texto = 'VALOR IPI';
2811
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2812
        $this->pdf->textBox($x, $y, $w13, $h, $texto, $aFont, 'C', 'C', 0, '', false);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2813
        $this->pdf->line($x + $w13, $y, $x + $w13, $y + $hmax);
2814
        //ALÍQ. ICMS
2815
        $x     += $w13;
2816
        $w14   = round($w * 0.04, 0);
2817
        $texto = 'ALÍQ. ICMS';
2818
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2819
        $this->pdf->textBox($x, $y, $w14, $h, $texto, $aFont, 'C', 'C', 0, '', false);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2820
        $this->pdf->line($x + $w14, $y, $x + $w14, $y + $hmax);
2821
        //ALÍQ. IPI
2822
        $x     += $w14;
2823
        $w15   = $w - ($w1 + $w2 + $w3 + $w4 + $w5 + $w6 + $w7 + $w8 + $w9 + $w10 + $w11 + $w12 + $w13 + $w14);
2824
        $texto = 'ALÍQ. IPI';
2825
        $this->pdf->textBox($x, $y, $w15, $h, $texto, $aFont, 'C', 'C', 0, '', false);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2826
        $this->pdf->line($oldX, $y + $h + 1, $oldX + $w, $y + $h + 1);
2827
        $y += 5;
2828
        //##################################################################################
2829
        // LOOP COM OS DADOS DOS PRODUTOS
2830
        $i      = 0;
2831
        $hUsado = $hCabecItens;
2832
        $aFont  = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
2833
2834
        foreach ($this->det as $d) {
0 ignored issues
show
Bug introduced by
The expression $this->det of type object<DOMNode> is not traversable.
Loading history...
2835
            if ($i >= $nInicio) {
2836
                $thisItem = $this->det->item($i);
2837
                //carrega as tags do item
2838
                $prod         = $thisItem->getElementsByTagName("prod")->item(0);
2839
                $imposto      = $this->det->item($i)->getElementsByTagName("imposto")->item(0);
2840
                $ICMS         = $imposto->getElementsByTagName("ICMS")->item(0);
2841
                $IPI          = $imposto->getElementsByTagName("IPI")->item(0);
2842
                $textoProduto = $this->descricaoProduto($thisItem);
2843
                
2844
2845
                // Posição y dos dados das unidades tributaveis.
2846
                $yTrib = $this->pdf->fontSize + .5;
2847
2848
                $uCom = $prod->getElementsByTagName("uCom")->item(0)->nodeValue;
2849
                $uTrib = $prod->getElementsByTagName("uTrib")->item(0);
2850
                $cfop = $prod->getElementsByTagName("CFOP")->item(0)->nodeValue;
0 ignored issues
show
Unused Code introduced by
$cfop 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...
2851
                // A Configuração serve para informar se irá exibir
2852
                //   de forma obrigatória, estando diferente ou não,
2853
                //   a unidade de medida tributária.
2854
                // ========
2855
                // A Exibição será realizada sempre que a unidade comercial for
2856
                //   diferente da unidade de medida tributária.
2857
                // "Nas situações em que o valor unitário comercial for diferente do valor unitário tributável,
2858
                //   ambas as informações deverão estar expressas e identificadas no DANFE, podendo ser
2859
                //   utilizada uma das linhas adicionais previstas, ou o campo de informações adicionais."
2860
                // > Manual Integração - Contribuinte 4.01 - NT2009.006, Item 7.1.5, página 91.
2861
                $mostrarUnidadeTributavel = (!empty($uTrib)
2862
                    && strtoupper(trim($uCom)) !== strtoupper(trim($uTrib->nodeValue)));
2863
2864
                // Informação sobre unidade de medida tributavel.
2865
                // Se não for para exibir a unidade de medida tributavel, então
2866
                // A Escrita irá começar em 0.
2867
                if (! $mostrarUnidadeTributavel) {
2868
                    $yTrib = 0;
2869
                }
2870
                $h = $this->calculeHeight($thisItem, $mostrarUnidadeTributavel);
2871
                $hUsado += $h;
2872
2873
                $yTrib += $y;
2874
                $diffH = $hmax - $hUsado;
2875
2876
                if ($pag != $totpag) {
2877
                    if (1 > $diffH && $i < $totItens) {
2878
                        //ultrapassa a capacidade para uma única página
2879
                        //o restante dos dados serão usados nas proximas paginas
2880
                        $nInicio = $i;
2881
                        break;
2882
                    }
2883
                }
2884
                $y_linha = $y + $h;
2885
                // linha entre itens
2886
                $this->pdf->dashedHLine($oldX, $y_linha, $w, 0.1, 120);
2887
                //corrige o x
2888
                $x = $oldX;
2889
                //codigo do produto
2890
                $guup  = $i + 1;
0 ignored issues
show
Unused Code introduced by
$guup 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...
2891
                $texto = $prod->getElementsByTagName("cProd")->item(0)->nodeValue;
2892
                $this->pdf->textBox($x, $y, $w1, $h, $texto, $aFont, 'T', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2893
                $x += $w1;
2894
                //DESCRIÇÃO
2895
                if ($this->orientacao == 'P') {
2896
                    $this->pdf->textBox($x, $y, $w2, $h, $textoProduto, $aFont, 'T', 'L', 0, '', false);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2897
                } else {
2898
                    $this->pdf->textBox($x, $y, $w2, $h, $textoProduto, $aFont, 'T', 'L', 0, '', false);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2899
                }
2900
                $x += $w2;
2901
                //NCM
2902
                $texto = ! empty($prod->getElementsByTagName("NCM")->item(0)->nodeValue) ?
2903
                    $prod->getElementsByTagName("NCM")->item(0)->nodeValue : '';
2904
                $this->pdf->textBox($x, $y, $w3, $h, $texto, $aFont, 'T', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2905
                $x += $w3;
2906
                //CST
2907
                if (isset($ICMS)) {
2908
                    $origem = $this->getTagValue($ICMS, "orig");
2909
                    $cst    = $this->getTagValue($ICMS, "CST");
2910
                    $csosn  = $this->getTagValue($ICMS, "CSOSN");
2911
                    $texto  = $origem . $cst . $csosn;
2912
                    $this->pdf->textBox($x, $y, $w4, $h, $texto, $aFont, 'T', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2913
                }
2914
                //CFOP
2915
                $x     += $w4;
2916
                $texto = $prod->getElementsByTagName("CFOP")->item(0)->nodeValue;
2917
                $this->pdf->textBox($x, $y, $w5, $h, $texto, $aFont, 'T', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2918
                //Unidade
2919
                $x     += $w5;
2920
                $texto = $uCom;
2921
                $this->pdf->textBox($x, $y, $w6, $h, $texto, $aFont, 'T', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2922
                //Unidade de medida tributável
2923
                if ($mostrarUnidadeTributavel && !empty($uTrib)) {
2924
                    $texto = $uTrib->nodeValue;
2925
                    $this->pdf->textBox($x, $yTrib, $w6, $h, $texto, $aFont, 'T', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2926
                }
2927
                $x += $w6;
2928
                if ($this->orientacao == 'P') {
2929
                    $alinhamento = 'R';
2930
                } else {
2931
                    $alinhamento = 'R';
2932
                }
2933
                // QTDADE
2934
                $qCom  = $prod->getElementsByTagName("qCom")->item(0);
2935
                $texto = number_format($qCom->nodeValue, $this->qComCasasDec, ",", ".");
2936
                $this->pdf->textBox($x, $y, $w7, $h, $texto, $aFont, 'T', $alinhamento, 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2937
                // QTDADE Tributável
2938
                if ($mostrarUnidadeTributavel) {
2939
                    $qTrib = $prod->getElementsByTagName("qTrib")->item(0);
2940
                    if (! empty($qTrib)) {
2941
                        $texto = number_format($qTrib->nodeValue, $this->qComCasasDec, ",", ".");
2942
                        $this->pdf->textBox($x, $yTrib, $w7, $h, $texto, $aFont, 'T', $alinhamento, 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2943
                    }
2944
                }
2945
                $x += $w7;
2946
                // Valor Unitário
2947
                $vUnCom = $prod->getElementsByTagName("vUnCom")->item(0);
2948
                $texto  = number_format($vUnCom->nodeValue, $this->vUnComCasasDec, ",", ".");
2949
                $this->pdf->textBox($x, $y, $w8, $h, $texto, $aFont, 'T', $alinhamento, 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2950
                // Valor Unitário Tributável
2951
                if ($mostrarUnidadeTributavel) {
2952
                    $vUnTrib = $prod->getElementsByTagName("vUnTrib")->item(0);
2953
                    if (! empty($vUnTrib)) {
2954
                        $texto = number_format($vUnTrib->nodeValue, $this->vUnComCasasDec, ",", ".");
2955
                        $this->pdf->textBox($x, $yTrib, $w8, $h, $texto, $aFont, 'T', $alinhamento, 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2956
                    }
2957
                }
2958
                $x += $w8;
2959
                // Valor do Produto
2960
                $texto = "";
2961
                if (is_numeric($prod->getElementsByTagName("vProd")->item(0)->nodeValue)) {
2962
                    $texto = number_format($prod->getElementsByTagName("vProd")->item(0)->nodeValue, 2, ",", ".");
2963
                }
2964
                $this->pdf->textBox($x, $y, $w9, $h, $texto, $aFont, 'T', $alinhamento, 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2965
                $x += $w9;
2966
                //Valor do Desconto
2967
                $vdesc = ! empty($prod->getElementsByTagName("vDesc")->item(0)->nodeValue)
2968
                    ? $prod->getElementsByTagName("vDesc")->item(0)->nodeValue : 0;
2969
2970
                $texto = number_format($vdesc, 2, ",", ".");
2971
                $this->pdf->textBox($x, $y, $w10, $h, $texto, $aFont, 'T', $alinhamento, 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2972
                //Valor da Base de calculo
2973
                $x += $w10;
2974
                if (isset($ICMS)) {
2975
                    $texto = ! empty($ICMS->getElementsByTagName("vBC")->item(0)->nodeValue)
2976
                        ? number_format(
2977
                            $ICMS->getElementsByTagName("vBC")->item(0)->nodeValue,
2978
                            2,
2979
                            ",",
2980
                            "."
2981
                        )
2982
                        : '0,00';
2983
                    $this->pdf->textBox($x, $y, $w11, $h, $texto, $aFont, 'T', $alinhamento, 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2984
                }
2985
                //Valor do ICMS
2986
                $x += $w11;
2987
                if (isset($ICMS)) {
2988
                    $texto = ! empty($ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue)
2989
                        ? number_format(
2990
                            $ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue,
2991
                            2,
2992
                            ",",
2993
                            "."
2994
                        )
2995
                        : '0,00';
2996
                    $this->pdf->textBox($x, $y, $w12, $h, $texto, $aFont, 'T', $alinhamento, 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
2997
                }
2998
                //Valor do IPI
2999
                $x += $w12;
3000
                if (isset($IPI)) {
3001
                    $texto = ! empty($IPI->getElementsByTagName("vIPI")->item(0)->nodeValue)
3002
                        ? number_format(
3003
                            $IPI->getElementsByTagName("vIPI")->item(0)->nodeValue,
3004
                            2,
3005
                            ",",
3006
                            "."
3007
                        )
3008
                        : '';
3009
                } else {
3010
                    $texto = '';
3011
                }
3012
                $this->pdf->textBox($x, $y, $w13, $h, $texto, $aFont, 'T', $alinhamento, 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3013
                // %ICMS
3014
                $x += $w13;
3015
                if (isset($ICMS)) {
3016
                    $texto = ! empty($ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue)
3017
                        ? number_format(
3018
                            $ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue,
3019
                            2,
3020
                            ",",
3021
                            "."
3022
                        )
3023
                        : '0,00';
3024
                    $this->pdf->textBox($x, $y, $w14, $h, $texto, $aFont, 'T', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3025
                }
3026
                //%IPI
3027
                $x += $w14;
3028
                if (isset($IPI)) {
3029
                    $texto = ! empty($IPI->getElementsByTagName("pIPI")->item(0)->nodeValue)
3030
                        ? number_format(
3031
                            $IPI->getElementsByTagName("pIPI")->item(0)->nodeValue,
3032
                            2,
3033
                            ",",
3034
                            "."
3035
                        )
3036
                        : '';
3037
                } else {
3038
                    $texto = '';
3039
                }
3040
                $this->pdf->textBox($x, $y, $w15, $h, $texto, $aFont, 'T', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3041
3042
3043
                // Dados do Veiculo Somente para veiculo 0 Km
3044
                $veicProd = $prod->getElementsByTagName("veicProd")->item(0);
3045
                // Tag somente é gerada para veiculo 0k, e só é permitido um veiculo por NF-e por conta do detran
3046
                // Verifica se a Tag existe
3047
                if (! empty($veicProd)) {
3048
                    $this->dadosItenVeiculoDANFE($oldX, $y, $nInicio, $h, $prod);
3049
                }
3050
3051
3052
                $y += $h;
3053
                $i ++;
3054
                //incrementa o controle dos itens processados.
3055
                $this->qtdeItensProc ++;
3056
            } else {
3057
                $i ++;
3058
            }
3059
        }
3060
3061
        return $oldY + $hmax;
3062
    }
3063
3064
3065
    /**
3066
     * dadosItenVeiculoDANFE
3067
     * Coloca os dados do veiculo abaixo do item da NFe. (retrato e paisagem)
3068
     *
3069
     * @param float  $x    Posição horizontal
3070
     *                     canto esquerdo
3071
     * @param float  $y    Posição vertical
3072
     *                     canto superior
3073
     * @param        $nInicio
3074
     * @param float  $h    altura do campo
3075
     * @param object $prod Contendo todos os dados do item
3076
     */
3077
3078
    protected function dadosItenVeiculoDANFE($x, $y, &$nInicio, $h, $prod)
3079
    {
3080
        $oldX = $x;
3081
        $oldY = $y;
0 ignored issues
show
Unused Code introduced by
$oldY 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...
3082
3083
        if ($this->orientacao == 'P') {
3084
            $w = $this->wPrint;
3085
        } else {
3086
            if ($nInicio < 2) { // primeira página
3087
                $w = $this->wPrint - $this->wCanhoto;
3088
            } else { // páginas seguintes
3089
                $w = $this->wPrint;
3090
            }
3091
        }
3092
3093
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
3094
3095
        $w1 = round($w * 0.09, 0);
3096
3097
        // Tabela Renavam Combustivel
3098
        $renavamCombustivel = [
3099
            1  => 'ALCOOL',
3100
            2  => 'GASOLINA',
3101
            3  => 'DIESEL',
3102
            4  => 'GASOGENIO',
3103
            5  => 'GAS METANO',
3104
            6  => 'ELETRICO/FONTE INTERNA',
3105
            7  => 'ELETRICO/FONTE EXTERNA',
3106
            8  => 'GASOL/GAS NATURAL COMBUSTIVEL',
3107
            9  => 'ALCOOL/GAS NATURAL COMBUSTIVEL',
3108
            10 => 'DIESEL/GAS NATURAL COMBUSTIVEL',
3109
            11 => 'VIDE/CAMPO/OBSERVACAO',
3110
            12 => 'ALCOOL/GAS NATURAL VEICULAR',
3111
            13 => 'GASOLINA/GAS NATURAL VEICULAR',
3112
            14 => 'DIESEL/GAS NATURAL VEICULAR',
3113
            15 => 'GAS NATURAL VEICULAR',
3114
            16 => 'ALCOOL/GASOLINA',
3115
            17 => 'GASOLINA/ALCOOL/GAS NATURAL',
3116
            18 => 'GASOLINA/ELETRICO'
3117
        ];
3118
3119
        $renavamEspecie = [
3120
            1 => 'PASSAGEIRO',
3121
            2 => 'CARGA',
3122
            3 => 'MISTO',
3123
            4 => 'CORRIDA',
3124
            5 => 'TRACAO',
3125
            6 => 'ESPECIAL',
3126
            7 => 'COLECAO'
3127
        ];
3128
3129
        $renavamTiposVeiculos = [
3130
            1  => 'BICICLETA',
3131
            2  => 'CICLOMOTOR',
3132
            3  => 'MOTONETA',
3133
            4  => 'MOTOCICLETA',
3134
            5  => 'TRICICLO',
3135
            6  => 'AUTOMOVEL',
3136
            7  => 'MICROONIBUS',
3137
            8  => 'ONIBUS',
3138
            9  => 'BONDE',
3139
            10 => 'REBOQUE',
3140
            11 => 'SEMI-REBOQUE',
3141
            12 => 'CHARRETE',
3142
            13 => 'CAMIONETA',
3143
            14 => 'CAMINHAO',
3144
            15 => 'CARROCA',
3145
            16 => 'CARRO DE MAO',
3146
            17 => 'CAMINHAO TRATOR',
3147
            18 => 'TRATOR DE RODAS',
3148
            19 => 'TRATOR DE ESTEIRAS',
3149
            20 => 'TRATOR MISTO',
3150
            21 => 'QUADRICICLO',
3151
            22 => 'CHASSI/PLATAFORMA',
3152
            23 => 'CAMINHONETE',
3153
            24 => 'SIDE-CAR',
3154
            25 => 'UTILITARIO',
3155
            26 => 'MOTOR-CASA'
3156
        ];
3157
3158
        $renavamTipoPintura = [
0 ignored issues
show
Unused Code introduced by
$renavamTipoPintura 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...
3159
            'F' => 'FOSCA',
3160
            'S' => 'SÓLIDA',
3161
            'P' => 'PEROLIZADA',
3162
            'M' => 'METALICA',
3163
        ];
3164
3165
        $veicProd = $prod->getElementsByTagName("veicProd")->item(0);
3166
3167
        $veiculoChassi     = $veicProd->getElementsByTagName("chassi")->item(0)->nodeValue;
3168
        $veiculoCor        = $veicProd->getElementsByTagName("xCor")->item(0)->nodeValue;
3169
        $veiculoCilindrada = $veicProd->getElementsByTagName("cilin")->item(0)->nodeValue;
3170
        $veiculoCmkg       = $veicProd->getElementsByTagName("CMT")->item(0)->nodeValue;
3171
        $veiculoTipo       = $veicProd->getElementsByTagName("tpVeic")->item(0)->nodeValue;
3172
3173
        $veiculoMotor       = $veicProd->getElementsByTagName("nMotor")->item(0)->nodeValue;
3174
        $veiculoRenavam     = $veicProd->getElementsByTagName("cMod")->item(0)->nodeValue;
3175
        $veiculoHp          = $veicProd->getElementsByTagName("pot")->item(0)->nodeValue;
3176
        $veiculoPlaca       = ''; //$veiculo->getElementsByTagName("CMT")->item(0)->nodeValue;
3177
        $veiculoTipoPintura = $veicProd->getElementsByTagName("tpPint")->item(0)->nodeValue;
3178
        $veiculoMarcaModelo = $prod->getElementsByTagName("xProd")->item(0)->nodeValue;
3179
        $veiculoEspecie     = $veicProd->getElementsByTagName("espVeic")->item(0)->nodeValue;
3180
        $veiculoCombustivel = $veicProd->getElementsByTagName("tpComb")->item(0)->nodeValue;
3181
        $veiculoSerial      = $veicProd->getElementsByTagName("nSerie")->item(0)->nodeValue;
3182
        $veiculoFabricacao  = $veicProd->getElementsByTagName("anoFab")->item(0)->nodeValue;
3183
        $veiculoModelo      = $veicProd->getElementsByTagName("anoMod")->item(0)->nodeValue;
3184
        $veiculoDistancia   = $veicProd->getElementsByTagName("dist")->item(0)->nodeValue;
3185
3186
        $x = $oldX;
3187
3188
        $yVeic = $y + $h;
3189
        $texto = 'Chassi: ............: ' . $veiculoChassi;
3190
        $this->pdf->textBox($x, $yVeic, $w1 + 40, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3191
        $yVeic += $h;
3192
        $texto = 'Cor...................: ' . $veiculoCor;
3193
        $this->pdf->textBox($x, $yVeic, $w1 + 40, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3194
        $yVeic += $h;
3195
        $texto = 'Cilindrada........: ' . $veiculoCilindrada;
3196
        $this->pdf->textBox($x, $yVeic, $w1 + 40, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3197
        $yVeic += $h;
3198
        $texto = 'Cmkg...............: ' . $veiculoCmkg;
3199
        $this->pdf->textBox($x, $yVeic, $w1 + 40, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3200
        $yVeic += $h;
3201
        $texto = 'Tipo.................: ' . ($renavamTiposVeiculos[intval($veiculoTipo)] ?? $veiculoTipo);
3202
        $this->pdf->textBox($x, $yVeic, $w1 + 40, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3203
        $yVeic = $y + $h;
3204
        $xVeic = $x + 65;
3205
        $texto = 'Nº Motor: .........: ' . $veiculoMotor;
3206
        $this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3207
        $yVeic += $h;
3208
        $texto = 'Renavam...........: ' . $veiculoRenavam;
3209
        $this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3210
        $yVeic += $h;
3211
        $texto = 'HP.....................: ' . $veiculoHp;
3212
        $this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3213
        $yVeic += $h;
3214
        $texto = 'Placa.................: ' . $veiculoPlaca;
3215
        $this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3216
        $yVeic += $h;
3217
        $texto = 'Tipo Pintura......: ' . ($renavamEspecie[intval($veiculoTipoPintura)] ?? $veiculoTipoPintura);
3218
        $this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3219
        $yVeic = $y + $h;
3220
        $xVeic = $xVeic + 55;
3221
        $texto = 'Marca / Modelo.....: ' . $veiculoMarcaModelo;
3222
        $this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3223
        $yVeic += $h;
3224
        $texto = 'Especie..................: ' . ($renavamEspecie[intval($veiculoEspecie)] ?? $veiculoEspecie);
3225
        $this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3226
        $yVeic += $h;
3227
        $texto = 'Combustivel..........: ' . ($renavamCombustivel[intval($veiculoCombustivel)] ?? $veiculoCombustivel);
3228
        $this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3229
        $yVeic += $h;
3230
        $texto = 'Serial.....................: ' . $veiculoSerial;
3231
        $this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3232
        $yVeic += $h;
3233
        $texto = 'Ano Fab/Mod........: ' . $veiculoFabricacao . '/' . $veiculoModelo;
3234
        $this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3235
        $yVeic += $h;
3236
        $texto = 'Distancia Entre Eixos(mm)..: ' . $veiculoDistancia;
3237
        $this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3238
    }
3239
3240
    /**
3241
     * issqn
3242
     * Monta o campo de serviços do DANFE
3243
     *
3244
     * @name   issqn (retrato e paisagem)
3245
     *
3246
     * @param float $x Posição horizontal canto esquerdo
3247
     * @param float $y Posição vertical canto superior
3248
     *
3249
     * @return float Posição vertical final
3250
     */
3251
    protected function issqn($x, $y)
3252
    {
3253
        $oldX = $x;
0 ignored issues
show
Unused Code introduced by
$oldX 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...
3254
        //#####################################################################
3255
        //CÁLCULO DO ISSQN
3256
        $texto = "CÁLCULO DO ISSQN";
3257
        $w     = $this->wPrint;
3258
        $h     = 7;
3259
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
3260
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3261
        //INSCRIÇÃO MUNICIPAL
3262
        $y     += 3;
3263
        $w     = round($this->wPrint * 0.23, 0);
3264
        $texto = 'INSCRIÇÃO MUNICIPAL';
3265
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
3266
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
3267
        //inscrição municipal
3268
        $texto = ! empty($this->emit->getElementsByTagName("IM")->item(0)->nodeValue) ?
3269
            $this->emit->getElementsByTagName("IM")->item(0)->nodeValue : '';
3270
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
3271
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3272
        //VALOR TOTAL DOS SERVIÇOS
3273
        $x     += $w;
3274
        $texto = 'VALOR TOTAL DOS SERVIÇOS';
3275
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
3276
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
3277
        if (isset($this->ISSQNtot)) {
3278
            $texto = ! empty($this->ISSQNtot->getElementsByTagName("vServ")->item(0)->nodeValue) ?
3279
                $this->ISSQNtot->getElementsByTagName("vServ")->item(0)->nodeValue : '';
3280
            $texto = number_format($texto, 2, ",", ".");
3281
        } else {
3282
            $texto = '';
3283
        }
3284
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
3285
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'R', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3286
        //BASE DE CÁLCULO DO ISSQN
3287
        $x     += $w;
3288
        $texto = 'BASE DE CÁLCULO DO ISSQN';
3289
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
3290
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
3291
        if (isset($this->ISSQNtot)) {
3292
            $texto = ! empty($this->ISSQNtot->getElementsByTagName("vBC")->item(0)->nodeValue) ?
3293
                $this->ISSQNtot->getElementsByTagName("vBC")->item(0)->nodeValue : '';
3294
            $texto = ! empty($texto) ? number_format($texto, 2, ",", ".") : '';
3295
        } else {
3296
            $texto = '';
3297
        }
3298
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
3299
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'R', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3300
        //VALOR TOTAL DO ISSQN
3301
        $x += $w;
3302
        if ($this->orientacao == 'P') {
3303
            $w = $this->wPrint - (3 * $w);
3304
        } else {
3305
            $w = $this->wPrint - (3 * $w) - $this->wCanhoto;
3306
        }
3307
        $texto = 'VALOR TOTAL DO ISSQN';
3308
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
3309
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
3310
        if (isset($this->ISSQNtot)) {
3311
            $texto = ! empty($this->ISSQNtot->getElementsByTagName("vISS")->item(0)->nodeValue) ?
3312
                $this->ISSQNtot->getElementsByTagName("vISS")->item(0)->nodeValue : '';
3313
            $texto = ! empty($texto) ? number_format($texto, 2, ",", ".") : '';
3314
        } else {
3315
            $texto = '';
3316
        }
3317
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
3318
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'R', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3319
3320
        return ($y + $h + 1);
3321
    }
3322
3323
    /**
3324
     *dadosAdicionais
3325
     * Coloca o grupo de dados adicionais da NFe. (retrato e paisagem)
3326
     *
3327
     * @name   dadosAdicionais
3328
     *
3329
     * @param float $x Posição horizontal canto esquerdo
3330
     * @param float $y Posição vertical canto superior
3331
     * @param float $h altura do campo
3332
     *
3333
     * @return float Posição vertical final (eixo Y)
3334
     */
3335
    protected function dadosAdicionais($x, $y, $h)
0 ignored issues
show
Unused Code introduced by
The parameter $y is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
3336
    {
3337
        $y = $this->maxH - (7 + $h);
3338
        //$y = $this->maxH - 20;
3339
        //##################################################################################
3340
        //DADOS ADICIONAIS
3341
        $texto = "DADOS ADICIONAIS";
3342
        if ($this->orientacao == 'P') {
3343
            $w = $this->wPrint;
3344
        } else {
3345
            $w = $this->wPrint - $this->wCanhoto;
3346
        }
3347
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
3348
        $this->pdf->textBox($x, $y, $w, 8, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3349
3350
        //INFORMAÇÕES COMPLEMENTARES
3351
        $texto = "INFORMAÇÕES COMPLEMENTARES";
3352
        $y     += 3;
3353
        $w     = $this->wAdic;
3354
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => 'B'];
3355
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
3356
        //o texto com os dados adicionais foi obtido na função montaDANFE
3357
        //e carregado em uma propriedade privada da classe
3358
        //$this->wAdic com a largura do campo
3359
        //$this->textoAdic com o texto completo do campo
3360
        //echo str_replace("\n", "<br>",$this->textoAdic);
3361
        //die;
3362
        $y     += 1;
3363
        $aFont = ['font' => $this->fontePadrao, 'size' => $this->textadicfontsize * $this->pdf->k, 'style' => ''];
3364
        //$aFont = ['font'=>$this->fontePadrao, 'size'=> 5, 'style'=>''];
3365
        $this->pdf->textBox($x, $y + 2, $w - 2, $h, $this->textoAdic, $aFont, 'T', 'L', 0, '', false);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3366
        //RESERVADO AO FISCO
3367
        $texto = "RESERVADO AO FISCO";
3368
        if (isset($this->nfeProc) && $this->nfeProc->getElementsByTagName("xMsg")->length) {
3369
            $texto = $texto . ' ' . $this->nfeProc->getElementsByTagName("xMsg")->item(0)->nodeValue;
3370
        }
3371
        $x += $w;
3372
        $y -= 1;
3373
        if ($this->orientacao == 'P') {
3374
            $w = $this->wPrint - $w;
3375
        } else {
3376
            $w = $this->wPrint - $w - $this->wCanhoto;
3377
        }
3378
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => 'B'];
3379
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
3380
        //inserir texto informando caso de contingência
3381
        // 1 - Normal - emissão normal;
3382
        // 2 - Contingência FS - emissão em contingência com impressão do DANFE em Formulário de Segurança;
3383
        // 3 - Contingência SCAN - emissão em contingência no Sistema de Contingência do Ambiente Nacional;
3384
        // 4 - Contingência EPEC - emissão em contingência com envio da Evento
3385
        //     Prévia de Emissão em Contingência;
3386
        // 5 - Contingência FS-DA - emissão em contingência com impressão do DANFE em Formulário de
3387
        //     Segurança para Impressão de Documento Auxiliar de Documento Fiscal Eletrônico (FS-DA);
3388
        // 6 - Contingência SVC-AN
3389
        // 7 - Contingência SVC-RS
3390
        $xJust  = $this->getTagValue($this->ide, 'xJust', 'Justificativa: ');
3391
        $dhCont = $this->getTagValue($this->ide, 'dhCont', ' Entrada em contingência : ');
3392
        $texto  = '';
3393
        switch ($this->tpEmis) {
3394
            case 4:
3395
                $texto = "CONTINGÊNCIA EPEC\n" . $dhCont . "\n" . $xJust;
3396
                break;
3397
            case 5:
3398
                $texto = "CONTINGÊNCIA FSDA\n" . $dhCont . "\n" . $xJust;
3399
                break;
3400
            case 6:
3401
                $texto = "CONTINGÊNCIA SVC-AN\n" . $dhCont . "\n" . $xJust;
3402
                break;
3403
            case 7:
3404
                $texto = "CONTINGÊNCIA SVC-RS\n" . $dhCont . "\n" . $xJust;
3405
                break;
3406
        }
3407
        $y     += 2;
3408
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
3409
        $this->pdf->textBox($x, $y, $w - 2, $h, $texto, $aFont, 'T', 'L', 0, '', false);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3410
3411
        return $y + $h;
3412
    }
3413
3414
    /**
3415
     * rodape
3416
     * Monta o rodapé no final da DANFE com a data/hora de impressão e informações
3417
     * sobre a API NfePHP
3418
     *
3419
     * @param float $x Posição horizontal canto esquerdo
3420
     *
3421
     * @return void
3422
     */
3423
    protected function rodape($x)
3424
    {
3425
        $y = $this->maxH - 4;
3426
        if ($this->orientacao == 'P') {
3427
            $w = $this->wPrint;
3428
        } else {
3429
            $w = $this->wPrint - $this->wCanhoto;
3430
            $x = $this->wCanhoto;
3431
        }
3432
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => 'I'];
3433
        $texto = "Impresso em " . date('d/m/Y') . " as " . date('H:i:s')
3434
            . '  ' . $this->creditos;
3435
        $this->pdf->textBox($x, $y, $w, 0, $texto, $aFont, 'T', 'L', false);
3436
        $texto = $this->powered ? "Powered by NFePHP®" : '';
3437
        $this->pdf->textBox($x, $y, $w, 0, $texto, $aFont, 'T', 'R', false, '');
3438
    }
3439
3440
    /**
3441
     * Monta o canhoto da DANFE (retrato e paisagem)
3442
     *
3443
     * @name   canhotoDANFE
3444
     *
3445
     * @param number $x Posição horizontal canto esquerdo
3446
     * @param number $y Posição vertical canto superior
3447
     *
3448
     * @return number Posição vertical final
3449
     *
3450
     * TODO 21/07/14 fmertins: quando orientação L-paisagem, o canhoto está sendo gerado incorretamente
3451
     */
3452
    protected function canhoto($x, $y)
3453
    {
3454
        $oldX = $x;
3455
        $oldY = $y;
3456
        //#################################################################################
3457
        //canhoto
3458
        //identificação do tipo de nf entrada ou saida
3459
        $tpNF = $this->ide->getElementsByTagName('tpNF')->item(0)->nodeValue;
3460
        if ($tpNF == '0') {
3461
            //NFe de Entrada
3462
            $emitente     = '';
3463
            $emitente     .= $this->dest->getElementsByTagName("xNome")->item(0)->nodeValue . " - ";
3464
            $emitente     .= $this->enderDest->getElementsByTagName("xLgr")->item(0)->nodeValue . ", ";
3465
            $emitente     .= $this->enderDest->getElementsByTagName("nro")->item(0)->nodeValue . " - ";
3466
            $emitente     .= $this->getTagValue($this->enderDest, "xCpl", " - ", " ");
3467
            $emitente     .= $this->enderDest->getElementsByTagName("xBairro")->item(0)->nodeValue . " ";
3468
            $emitente     .= $this->enderDest->getElementsByTagName("xMun")->item(0)->nodeValue . "-";
3469
            $emitente     .= $this->enderDest->getElementsByTagName("UF")->item(0)->nodeValue . "";
3470
            $destinatario = $this->emit->getElementsByTagName("xNome")->item(0)->nodeValue . " ";
3471
        } else {
3472
            //NFe de Saída
3473
            $emitente     = $this->emit->getElementsByTagName("xNome")->item(0)->nodeValue . " ";
3474
            $destinatario = '';
3475
            $destinatario .= $this->dest->getElementsByTagName("xNome")->item(0)->nodeValue . " - ";
3476
            $destinatario .= $this->enderDest->getElementsByTagName("xLgr")->item(0)->nodeValue . ", ";
3477
            $destinatario .= $this->enderDest->getElementsByTagName("nro")->item(0)->nodeValue . " ";
3478
            $destinatario .= $this->getTagValue($this->enderDest, "xCpl", " - ", " ");
3479
            $destinatario .= $this->enderDest->getElementsByTagName("xBairro")->item(0)->nodeValue . " ";
3480
            $destinatario .= $this->enderDest->getElementsByTagName("xMun")->item(0)->nodeValue . "-";
3481
            $destinatario .= $this->enderDest->getElementsByTagName("UF")->item(0)->nodeValue . " ";
3482
        }
3483
        //identificação do sistema emissor
3484
        //linha separadora do canhoto
3485
        if ($this->orientacao == 'P') {
3486
            $w = round($this->wPrint * 0.81, 0);
3487
        } else {
3488
            //linha separadora do canhoto - 238
3489
            //posicao altura
3490
            $y = $this->wPrint - 85;
3491
            //altura
3492
            $w = $this->wPrint - 85 - 24;
3493
        }
3494
        $h = 10;
3495
        //desenha caixa
3496
        $texto      = '';
3497
        $aFont      = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
3498
        $aFontSmall = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
3499
        if ($this->orientacao == 'P') {
3500
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'L', 1, '', false);
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
3501
        } else {
3502
            $this->pdf->textBox90($x, $y, $w, $h, $texto, $aFont, 'C', 'L', 1, '', false);
3503
        }
3504
        $numNF = str_pad($this->ide->getElementsByTagName('nNF')->item(0)->nodeValue, 9, "0", STR_PAD_LEFT);
3505
        $serie = str_pad($this->ide->getElementsByTagName('serie')->item(0)->nodeValue, 3, "0", STR_PAD_LEFT);
3506
        $texto = "RECEBEMOS DE ";
3507
        $texto .= $emitente;
3508
        $texto .= " OS PRODUTOS E/OU SERVIÇOS CONSTANTES DA NOTA FISCAL ELETRÔNICA INDICADA ";
3509
        if ($this->orientacao == 'P') {
3510
            $texto .= "ABAIXO";
3511
        } else {
3512
            $texto .= "AO LADO";
3513
        }
3514
        $texto .= ". EMISSÃO: ";
3515
        $dEmi  = ! empty($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue) ?
3516
            $this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue : '';
3517
        if ($dEmi == '') {
3518
            $dEmi  = ! empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
3519
                $this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue : '';
3520
            $aDemi = explode('T', $dEmi);
3521
            $dEmi  = $aDemi[0];
3522
        }
3523
        $texto .= $this->ymdTodmy($dEmi) . " ";
3524
        $texto .= "VALOR TOTAL: R$ ";
3525
        $texto .= number_format($this->ICMSTot->getElementsByTagName("vNF")->item(0)->nodeValue, 2, ",", ".") . " ";
3526
        $texto .= "DESTINATÁRIO: ";
3527
        $texto .= $destinatario;
3528
        if ($this->orientacao == 'P') {
3529
            $this->pdf->textBox($x, $y, $w - 1, $h, $texto, $aFont, 'C', 'L', 0, '', false);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3530
            $x1    = $x + $w;
3531
            $w1    = $this->wPrint - $w;
3532
            $texto = "NF-e";
3533
            $aFont = ['font' => $this->fontePadrao, 'size' => 14, 'style' => 'B'];
3534
            $this->pdf->textBox($x1, $y, $w1, 18, $texto, $aFont, 'T', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3535
            $texto = "Nº. " . $this->formatField($numNF, "###.###.###") . " \n";
3536
            $texto .= "Série $serie";
3537
            $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
3538
            $this->pdf->textBox($x1, $y, $w1, 18, $texto, $aFont, 'C', 'C', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
3539
            //DATA DE RECEBIMENTO
3540
            $texto = "DATA DE RECEBIMENTO";
3541
            $y     += $h;
3542
            $w2    = round($this->wPrint * 0.17, 0); //35;
3543
            $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
3544
            $this->pdf->textBox($x, $y, $w2, 8, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
3545
            //IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR
3546
            $x     += $w2;
3547
            $w3    = $w - $w2;
3548
            $texto = "IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR";
3549
            $this->pdf->textBox($x, $y, $w3, 8, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
3550
            $x = $oldX;
3551
            $y += 9;
3552
            $this->pdf->dashedHLine($x, $y, $this->wPrint, 0.1, 80);
3553
            $y += 2;
3554
3555
            return $y;
3556
        } else {
3557
            $x --;
3558
            $x = $this->pdf->textBox90($x, $y, $w - 1, $h, $texto, $aFontSmall, 'C', 'L', 0, '', false);
0 ignored issues
show
Unused Code introduced by
$x 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...
3559
            //NUMERO DA NOTA FISCAL LOGO NFE
3560
            $w1    = 18;
3561
            $x1    = $oldX;
3562
            $y     = $oldY;
3563
            $texto = "NF-e";
3564
            $aFont = ['font' => $this->fontePadrao, 'size' => 14, 'style' => 'B'];
3565
            $this->pdf->textBox($x1, $y, $w1, 18, $texto, $aFont, 'T', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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...
3566
            $texto = "Nº.\n" . $this->formatField($numNF, "###.###.###") . " \n";
3567
            $texto .= "Série $serie";
3568
            $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'];
3569
            $this->pdf->textBox($x1, $y, $w1, 18, $texto, $aFont, 'C', 'C', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
3570
            //DATA DO RECEBIMENTO
3571
            $texto = "DATA DO RECEBIMENTO";
3572
            $y     = $this->wPrint - 85;
3573
            $x     = 12;
3574
            $w2    = round($this->wPrint * 0.17, 0); //35;
3575
            $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
3576
            $this->pdf->textBox90($x, $y, $w2, 8, $texto, $aFont, 'T', 'L', 1, '');
3577
            //IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR
3578
            $y     -= $w2;
3579
            $w3    = $w - $w2;
3580
            $texto = "IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR";
3581
            $aFont = ['font' => $this->fontePadrao, 'size' => 5.7, 'style' => ''];
3582
            $x     = $this->pdf->textBox90($x, $y, $w3, 8, $texto, $aFont, 'T', 'L', 1, '');
3583
            $this->pdf->dashedVLine(22, $oldY, 0.1, $this->wPrint, 69);
3584
3585
            return $x;
3586
        }
3587
    }
3588
3589
    /**
3590
     * geraInformacoesDaTagCompra
3591
     * Devolve uma string contendo informação sobre as tag <compra><xNEmp>, <xPed> e <xCont> ou string vazia.
3592
     * Aviso: Esta função não leva em consideração dados na tag xPed do item.
3593
     *
3594
     * @name   pGeraInformacoesDaTagCompra
3595
     * @return string com as informacoes dos pedidos.
3596
     */
3597
    protected function geraInformacoesDaTagCompra()
3598
    {
3599
        if (! $this->gerarInformacoesAutomaticas) {
3600
            return '';
3601
        }
3602
        $saida = "";
3603
        if (isset($this->compra)) {
3604
            if (! empty($this->compra->getElementsByTagName("xNEmp")->item(0)->nodeValue)) {
3605
                $saida .= " Nota de Empenho: " . $this->compra->getElementsByTagName("xNEmp")->item(0)->nodeValue;
3606
            }
3607
            if (! empty($this->compra->getElementsByTagName("xPed")->item(0)->nodeValue)) {
3608
                $saida .= " Pedido: " . $this->compra->getElementsByTagName("xPed")->item(0)->nodeValue;
3609
            }
3610
            if (! empty($this->compra->getElementsByTagName("xCont")->item(0)->nodeValue)) {
3611
                $saida .= " Contrato: " . $this->compra->getElementsByTagName("xCont")->item(0)->nodeValue;
3612
            }
3613
        }
3614
3615
        return $saida;
3616
    }
3617
3618
    /**
3619
     * geraChaveAdicionalDeContingencia
3620
     *
3621
     * @name   geraChaveAdicionalDeContingencia
3622
     * @return string chave
3623
     */
3624
    protected function geraChaveAdicionalDeContingencia()
3625
    {
3626
        //cUF tpEmis CNPJ vNF ICMSp ICMSs DD  DV
3627
        // Quantidade de caracteres  02   01      14  14    01    01  02 01
3628
        $forma = "%02d%d%s%014d%01d%01d%02d";
3629
        $cUF   = $this->ide->getElementsByTagName('cUF')->item(0)->nodeValue;
3630
        $CNPJ  = "00000000000000" . $this->emit->getElementsByTagName('CNPJ')->item(0)->nodeValue;
3631
        $CNPJ  = substr($CNPJ, - 14);
3632
        $vNF   = $this->ICMSTot->getElementsByTagName("vNF")->item(0)->nodeValue * 100;
3633
        $vICMS = $this->ICMSTot->getElementsByTagName("vICMS")->item(0)->nodeValue;
3634
        if ($vICMS > 0) {
3635
            $vICMS = 1;
3636
        }
3637
        $icmss = $this->ICMSTot->getElementsByTagName("vBC")->item(0)->nodeValue;
3638
        if ($icmss > 0) {
3639
            $icmss = 1;
3640
        }
3641
        $dEmi = ! empty($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue) ?
3642
            $this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue : '';
3643
        if ($dEmi == '') {
3644
            $dEmi  = ! empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
3645
                $this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue : '';
3646
            $aDemi = explode('T', $dEmi);
3647
            $dEmi  = $aDemi[0];
3648
        }
3649
        $dd    = $dEmi;
3650
        $rpos  = strrpos($dd, '-');
3651
        $dd    = substr($dd, $rpos + 1);
3652
        $chave = sprintf($forma, $cUF, $this->tpEmis, $CNPJ, $vNF, $vICMS, $icmss, $dd);
3653
        $chave = $chave . $this->modulo11($chave);
3654
3655
        return $chave;
3656
    }
3657
3658
    /**
3659
     *  geraInformacoesDasNotasReferenciadas
3660
     * Devolve uma string contendo informação sobre as notas referenciadas. Suporta N notas, eletrônicas ou não
3661
     * Exemplo: NFe Ref.: série: 01 número: 01 emit: 11.111.111/0001-01
3662
     * em 10/2010 [0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000]
3663
     *
3664
     * @return string Informacoes a serem adicionadas no rodapé sobre notas referenciadas.
3665
     */
3666
    protected function geraInformacoesDasNotasReferenciadas()
3667
    {
3668
        if (! $this->gerarInformacoesAutomaticas) {
3669
            return '';
3670
        }
3671
        $formaNfeRef = "\r\nNFe Ref.: série:%d número:%d emit:%s em %s [%s]";
3672
        $formaCTeRef = "\r\nCTe Ref.: série:%d número:%d emit:%s em %s [%s]";
3673
        $formaNfRef  = "\r\nNF  Ref.: série:%d numero:%d emit:%s em %s modelo: %d";
3674
        $formaECFRef = "\r\nECF Ref.: modelo: %s ECF:%d COO:%d";
3675
        $formaNfpRef = "\r\nNFP Ref.: série:%d número:%d emit:%s em %s modelo: %d IE:%s";
3676
        $saida       = '';
3677
        $nfRefs      = $this->ide->getElementsByTagName('NFref');
3678
        if (0 === $nfRefs->length) {
3679
            return $saida;
3680
        }
3681
        if ($nfRefs->length > 2) {
3682
            return 'Existem mais de 2 NF/NFe/ECF/NFP/CTe referenciadas, não serão exibidas na DANFE.';
3683
        }
3684
        foreach ($nfRefs as $nfRef) {
3685
            if (empty($nfRef)) {
3686
                continue;
3687
            }
3688
            $refNFe = $nfRef->getElementsByTagName('refNFe');
3689
            foreach ($refNFe as $chave_acessoRef) {
3690
                $chave_acesso  = $chave_acessoRef->nodeValue;
3691
                $chave_acessoF = $this->formatField($chave_acesso, $this->formatoChave);
3692
                $data          = substr($chave_acesso, 4, 2) . "/20" . substr($chave_acesso, 2, 2);
3693
                $cnpj          = $this->formatField(substr($chave_acesso, 6, 14), "##.###.###/####-##");
3694
                $serie         = substr($chave_acesso, 22, 3);
3695
                $numero        = substr($chave_acesso, 25, 9);
3696
                $saida         .= sprintf($formaNfeRef, $serie, $numero, $cnpj, $data, $chave_acessoF);
3697
            }
3698
            $refNF = $nfRef->getElementsByTagName('refNF');
3699
            foreach ($refNF as $umaRefNFe) {
3700
                $data   = $umaRefNFe->getElementsByTagName('AAMM')->item(0)->nodeValue;
3701
                $cnpj   = $umaRefNFe->getElementsByTagName('CNPJ')->item(0)->nodeValue;
3702
                $mod    = $umaRefNFe->getElementsByTagName('mod')->item(0)->nodeValue;
3703
                $serie  = $umaRefNFe->getElementsByTagName('serie')->item(0)->nodeValue;
3704
                $numero = $umaRefNFe->getElementsByTagName('nNF')->item(0)->nodeValue;
3705
                $data   = substr($data, 2, 2) . "/20" . substr($data, 0, 2);
3706
                $cnpj   = $this->formatField($cnpj, "##.###.###/####-##");
3707
                $saida  .= sprintf($formaNfRef, $serie, $numero, $cnpj, $data, $mod);
3708
            }
3709
            $refCTe = $nfRef->getElementsByTagName('refCTe');
3710
            foreach ($refCTe as $chave_acessoRef) {
3711
                $chave_acesso  = $chave_acessoRef->nodeValue;
3712
                $chave_acessoF = $this->formatField($chave_acesso, $this->formatoChave);
3713
                $data          = substr($chave_acesso, 4, 2) . "/20" . substr($chave_acesso, 2, 2);
3714
                $cnpj          = $this->formatField(substr($chave_acesso, 6, 14), "##.###.###/####-##");
3715
                $serie         = substr($chave_acesso, 22, 3);
3716
                $numero        = substr($chave_acesso, 25, 9);
3717
                $saida         .= sprintf($formaCTeRef, $serie, $numero, $cnpj, $data, $chave_acessoF);
3718
            }
3719
            $refECF = $nfRef->getElementsByTagName('refECF');
3720
            foreach ($refECF as $umaRefNFe) {
3721
                $mod   = $umaRefNFe->getElementsByTagName('mod')->item(0)->nodeValue;
3722
                $nECF  = $umaRefNFe->getElementsByTagName('nECF')->item(0)->nodeValue;
3723
                $nCOO  = $umaRefNFe->getElementsByTagName('nCOO')->item(0)->nodeValue;
3724
                $saida .= sprintf($formaECFRef, $mod, $nECF, $nCOO);
3725
            }
3726
            $refNFP = $nfRef->getElementsByTagName('refNFP');
3727
            foreach ($refNFP as $umaRefNFe) {
3728
                $data   = $umaRefNFe->getElementsByTagName('AAMM')->item(0)->nodeValue;
3729
                $cnpj   = ! empty($umaRefNFe->getElementsByTagName('CNPJ')->item(0)->nodeValue) ?
3730
                    $umaRefNFe->getElementsByTagName('CNPJ')->item(0)->nodeValue :
3731
                    '';
3732
                $cpf    = ! empty($umaRefNFe->getElementsByTagName('CPF')->item(0)->nodeValue) ?
3733
                    $umaRefNFe->getElementsByTagName('CPF')->item(0)->nodeValue : '';
3734
                $mod    = $umaRefNFe->getElementsByTagName('mod')->item(0)->nodeValue;
3735
                $serie  = $umaRefNFe->getElementsByTagName('serie')->item(0)->nodeValue;
3736
                $numero = $umaRefNFe->getElementsByTagName('nNF')->item(0)->nodeValue;
3737
                $ie     = $umaRefNFe->getElementsByTagName('IE')->item(0)->nodeValue;
3738
                $data   = substr($data, 2, 2) . "/20" . substr($data, 0, 2);
3739
                if ($cnpj == '') {
3740
                    $cpf_cnpj = $this->formatField($cpf, "###.###.###-##");
3741
                } else {
3742
                    $cpf_cnpj = $this->formatField($cnpj, "##.###.###/####-##");
3743
                }
3744
                $saida .= sprintf($formaNfpRef, $serie, $numero, $cpf_cnpj, $data, $mod, $ie);
3745
            }
3746
        }
3747
3748
        return $saida;
3749
    }
3750
3751
    private function loadDoc($xml)
3752
    {
3753
        $this->xml = $xml;
3754
        if (! empty($xml)) {
3755
            $this->dom = new Dom();
3756
            $this->dom->loadXML($this->xml);
3757
            if (empty($this->dom->getElementsByTagName("infNFe")->item(0))) {
3758
                throw new \Exception('Isso não é um NFe.');
3759
            }
3760
            $this->nfeProc = $this->dom->getElementsByTagName("nfeProc")->item(0);
3761
            $this->infNFe  = $this->dom->getElementsByTagName("infNFe")->item(0);
3762
            $this->ide     = $this->dom->getElementsByTagName("ide")->item(0);
3763
            if ($this->getTagValue($this->ide, "mod") != '55') {
3764
                throw new \Exception("O xml deve ser NF-e modelo 55.");
3765
            }
3766
            $this->entrega    = $this->dom->getElementsByTagName("entrega")->item(0);
3767
            $this->retirada   = $this->dom->getElementsByTagName("retirada")->item(0);
3768
            $this->emit       = $this->dom->getElementsByTagName("emit")->item(0);
3769
            $this->dest       = $this->dom->getElementsByTagName("dest")->item(0);
3770
            $this->enderEmit  = $this->dom->getElementsByTagName("enderEmit")->item(0);
3771
            $this->enderDest  = $this->dom->getElementsByTagName("enderDest")->item(0);
3772
            $this->det        = $this->dom->getElementsByTagName("det");
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->dom->getElementsByTagName('det') of type object<DOMNodeList> is incompatible with the declared type object<DOMNode> of property $det.

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...
3773
            $this->cobr       = $this->dom->getElementsByTagName("cobr")->item(0);
3774
            $this->dup        = $this->dom->getElementsByTagName('dup');
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->dom->getElementsByTagName('dup') of type object<DOMNodeList> is incompatible with the declared type object<DOMNode> of property $dup.

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...
3775
            $this->ICMSTot    = $this->dom->getElementsByTagName("ICMSTot")->item(0);
3776
            $this->ISSQNtot   = $this->dom->getElementsByTagName("ISSQNtot")->item(0);
3777
            $this->transp     = $this->dom->getElementsByTagName("transp")->item(0);
3778
            $this->transporta = $this->dom->getElementsByTagName("transporta")->item(0);
3779
            $this->veicTransp = $this->dom->getElementsByTagName("veicTransp")->item(0);
3780
            $this->detPag     = $this->dom->getElementsByTagName("detPag");
3781
            $this->reboque    = $this->dom->getElementsByTagName("reboque")->item(0);
3782
            $this->infAdic    = $this->dom->getElementsByTagName("infAdic")->item(0);
3783
            $this->compra     = $this->dom->getElementsByTagName("compra")->item(0);
3784
            $this->tpEmis     = $this->getTagValue($this->ide, "tpEmis");
0 ignored issues
show
Documentation Bug introduced by
The property $tpEmis was declared of type integer, but $this->getTagValue($this->ide, 'tpEmis') is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
3785
            $this->tpImp      = $this->getTagValue($this->ide, "tpImp");
0 ignored issues
show
Documentation Bug introduced by
The property $tpImp was declared of type integer, but $this->getTagValue($this->ide, 'tpImp') is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
3786
            $this->infProt    = $this->dom->getElementsByTagName("infProt")->item(0);
3787
        }
3788
    }
3789
3790
    /**
3791
     * @param $item
3792
     *
3793
     * @return float
3794
     */
3795
    protected function calculeHeight($item, $mostrarUnidadeTributavel = false)
3796
    {
3797
        if ($this->orientacao == 'P') {
3798
            $w = $this->wPrint;
3799
        } else {
3800
            $w = $this->wPrint - $this->wCanhoto;
3801
        }
3802
        $w2           = round($w * 0.25, 0);
3803
        $aFont        = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
3804
        $textoProduto = $this->descricaoProduto($item);
3805
        $numlinhas    = $this->pdf->getNumLines($textoProduto, $w2, $aFont);
3806
3807
        if ($mostrarUnidadeTributavel && $numlinhas == 1) {
3808
            $numlinhas ++;
3809
        }
3810
3811
        return round(($numlinhas * $this->pdf->fontSize) + ($numlinhas * 0.5), 2);
3812
    }
3813
}
3814