Completed
Pull Request — master (#448)
by Roberto
03:27
created

Danfe::pagamento()   F

Complexity

Conditions 14
Paths 593

Size

Total Lines 120

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 210

Importance

Changes 0
Metric Value
cc 14
nc 593
nop 2
dl 0
loc 120
ccs 0
cts 113
cp 0
crap 210
rs 2.1322
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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
     * Número de casas decimais para o valor da unidade comercial.
265
     *
266
     * @var integer
267
     */
268
    protected $vUnComCasasDec = 4;
269
    /**
270
     * @var int
271
     */
272
    protected $hdadosadic = 10;
273
    /**
274
     * @var array
275
     */
276
    protected $epec = [];
277
    /**
278
     * @var bool
279
     */
280
    protected $obsshow = true;
281
282
    /**
283
     * __construct
284
     *
285
     * @name  __construct
286
     *
287
     * @param string $xml Conteúdo XML da NF-e (com ou sem a tag nfeProc)
288
     */
289
    public function __construct($xml)
290
    {
291
        $this->loadDoc($xml);
292
    }
293
294
    public function epec($protocolo, $data)
295
    {
296
        if ($this->dom->getElementsByTagName("tpEmis")->item(0)->nodeValue != '4') {
297
            throw new \Exception('Esta nota não foi emitida em contingência EPEC, tpEmis != 4.');
298
        }
299
        $this->epec = [
300
            'protocolo' => $protocolo,
301
            'data' => $data
302
        ];
303
    }
304
305
    public function obsContShow($flag = true)
306
    {
307
        $this->obsshow = $flag;
308
    }
309
310
    /**
311
     * Define a quantidade de casas decimais para unidade comercial.
312
     *
313
     * @param integer $vUnComCasasDec
314
     */
315
    public function setVUnComCasasDec($vUnComCasasDec)
316
    {
317
        $this->vUnComCasasDec = $vUnComCasasDec;
318
    }
319
320
    /**
321
     * Define a quantidade de casas decimais para unidade comercial.
322
     *
323
     * @param integer $qComCasasDec
324
     */
325
    public function setQComCasasDec($qComCasasDec)
326
    {
327
        $this->qComCasasDec = $qComCasasDec;
328
    }
329
330
    protected function calculoEspacoVericalDadosAdicionais()
331
    {
332
        $this->textoAdic = '';
333
        //informações adicionais
334
        $fontProduto            = [
335
            'font'  => $this->fontePadrao,
336
            'size'  => 8,
337
            'style' => ''
338
        ];
339
        $k                      = $this->pdf->k;
340
        $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...
341
        $this->textoAdic        .= $this->geraInformacoesDasNotasReferenciadas();
342
        if (isset($this->infAdic)) {
343
            $i = 0;
344
            if ($this->textoAdic != '') {
345
                $this->textoAdic .= ". \n";
346
            }
347
            $this->textoAdic .= ! empty($this->getTagValue($this->infAdic, "infCpl"))
348
                ? 'Inf. Contribuinte: ' . $this->anfaveaDANFE($this->getTagValue($this->infAdic, "infCpl"))
349
                : '';
350
            $infPedido       = $this->geraInformacoesDaTagCompra();
351
            if ($infPedido != "") {
352
                $this->textoAdic .= $infPedido;
353
            }
354
            $this->textoAdic .= $this->getTagValue($this->dest, "email", ' Email do Destinatário: ');
355
            $this->textoAdic .= ! empty($this->getTagValue($this->infAdic, "infAdFisco"))
356
                ? "\n Inf. fisco: " . $this->getTagValue($this->infAdic, "infAdFisco")
357
                : '';
358
            if ($this->obsshow) {
359
                $obsCont = $this->infAdic->getElementsByTagName("obsCont");
360
                if (isset($obsCont)) {
361
                    foreach ($obsCont as $obs) {
362
                        $campo = $obsCont->item($i)->getAttribute("xCampo");
363
                        $xTexto = ! empty($obsCont->item($i)->getElementsByTagName("xTexto")->item(0)->nodeValue)
364
                            ? $obsCont->item($i)->getElementsByTagName("xTexto")->item(0)->nodeValue
365
                            : '';
366
                        $this->textoAdic .= "\n" . $campo . ':  ' . trim($xTexto);
367
                        $i ++;
368
                    }
369
                }
370
            }
371
        }
372
        //INCLUSO pela NT 2013.003 Lei da Transparência
373
        //verificar se a informação sobre o valor aproximado dos tributos
374
        //já se encontra no campo de informações adicionais
375
        if ($this->exibirValorTributos) {
376
            $flagVTT  = strpos(strtolower(trim($this->textoAdic)), 'valor');
377
            $flagVTT  = $flagVTT || strpos(strtolower(trim($this->textoAdic)), 'vl');
378
            $flagVTT  = $flagVTT && strpos(strtolower(trim($this->textoAdic)), 'aprox');
379
            $flagVTT  = $flagVTT && (strpos(strtolower(trim($this->textoAdic)), 'trib') ||
380
                    strpos(strtolower(trim($this->textoAdic)), 'imp'));
381
            $vTotTrib = $this->getTagValue($this->ICMSTot, 'vTotTrib');
382
            if ($vTotTrib != '' && ! $flagVTT) {
383
                $this->textoAdic .= "\n Valor Aproximado dos Tributos : R$ "
384
                    . number_format($vTotTrib, 2, ",", ".");
385
            }
386
        }
387
        //fim da alteração NT 2013.003 Lei da Transparência
388
        $this->textoAdic        = str_replace(";", "\n", $this->textoAdic);
389
        $numlinhasdados         = $this->pdf->getNumLines($this->textoAdic, $this->wAdic, $fontProduto) + 1.5;
390
        $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...
391
        $hdadosadic             = ceil($numlinhasdados * ($this->textadicfontsize));
392
        if ($hdadosadic > 70) {
393
            for ($f = 8; $f > 3; $f --) {
394
                $this->pdf->setFont($this->fontePadrao, '', $f);
395
                $fontProduto            = [
396
                    'font'  => $this->fontePadrao,
397
                    'size'  => $f,
398
                    'style' => ''
399
                ];
400
                $numlinhasdados         = $this->pdf->getNumLines($this->textoAdic, $this->wAdic, $fontProduto) + 3;
401
                $this->textadicfontsize = $this->pdf->fontSize;
402
                $hdadosadic             = ceil($numlinhasdados * $this->textadicfontsize);
403
                echo $hdadosadic;
404
                if ($hdadosadic <= 90) {
405
                    $hdadosadic = ceil($hdadosadic);
406
                    break;
407
                }
408
            }
409
        }
410
        if ($hdadosadic < 10) {
411
            $hdadosadic = 10;
412
        }
413
414
        return $hdadosadic;
415
    }
416
417
    /**
418
     * monta
419
     * Monta a DANFE conforme as informações fornecidas para a classe durante sua
420
     * construção. Constroi DANFEs com até 3 páginas podendo conter até 56 itens.
421
     * A definição de margens e posições iniciais para a impressão são estabelecidas
422
     * pelo conteúdo da funçao e podem ser modificados.
423
     *
424
     * @return string O ID da NFe numero de 44 digitos extraido do arquivo XML
425
     */
426
    protected function monta(
427
        $logo = ''
428
    ) {
429
        $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...
430
        $this->logomarca = $this->adjustImage($logo);
431
        //se a orientação estiver em branco utilizar o padrão estabelecido na NF
432
        if (empty($this->orientacao)) {
433
            if ($this->tpImp == '2') {
434
                $this->orientacao = 'L';
435
            } else {
436
                $this->orientacao = 'P';
437
            }
438
        }
439
        //instancia a classe pdf
440
        $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...
441
        //margens do PDF, em milímetros. Obs.: a margem direita é sempre igual à
442
        //margem esquerda. A margem inferior *não* existe na FPDF, é definida aqui
443
        //apenas para controle se necessário ser maior do que a margem superior
444
        // posição inicial do conteúdo, a partir do canto superior esquerdo da página
445
        $xInic = $this->margesq;
446
        if ($this->orientacao == 'P') {
447
            if ($this->papel == 'A4') {
448
                $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...
449
                $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...
450
            }
451
        } else {
452
            if ($this->papel == 'A4') {
453
                $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...
454
                $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...
455
                $xInic      = $this->margesq + 10;
456
                //se paisagem multiplica a largura do canhoto pela quantidade de canhotos
457
                //$this->wCanhoto *= $this->qCanhoto;
458
            }
459
        }
460
        //total inicial de paginas
461
        $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...
462
        //largura imprimivel em mm: largura da folha menos as margens esq/direita
463
        $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...
464
        //comprimento (altura) imprimivel em mm: altura da folha menos as margens
465
        //superior e inferior
466
        $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...
467
        // estabelece contagem de paginas
468
        $this->pdf->aliasNbPages();
469
        // fixa as margens
470
        $this->pdf->setMargins($this->margesq, $this->margsup);
471
        $this->pdf->setDrawColor(0, 0, 0);
472
        $this->pdf->setFillColor(255, 255, 255);
473
        // inicia o documento
474
        $this->pdf->open();
475
        // adiciona a primeira página
476
        $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...
477
        $this->pdf->setLineWidth(0.1);
478
        $this->pdf->settextcolor(0, 0, 0);
479
480
        //##################################################################
481
        // CALCULO DO NUMERO DE PAGINAS A SEREM IMPRESSAS
482
        //##################################################################
483
        //Verificando quantas linhas serão usadas para impressão das duplicatas
484
        $linhasDup = 0;
485
        $qtdPag    = 0;
486
        if (isset($this->dup) && $this->dup->length > 0) {
487
            $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...
488
        } 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...
489
            $qtdPag = $this->detPag->length;
490
        }
491
        if (($qtdPag > 0) && ($qtdPag <= 7)) {
492
            $linhasDup = 1;
493
        } elseif (($qtdPag > 7) && ($qtdPag <= 14)) {
494
            $linhasDup = 2;
495
        } elseif (($qtdPag > 14) && ($qtdPag <= 21)) {
496
            $linhasDup = 3;
497
        } elseif ($qtdPag > 21) {
498
            // chinnonsantos 11/05/2016: Limite máximo de impressão de duplicatas na NFe,
499
            // só vai ser exibito as 21 primeiras duplicatas (parcelas de pagamento),
500
            // se não oculpa espaço d+, cada linha comporta até 7 duplicatas.
501
            $linhasDup = 3;
502
        }
503
        //verifica se será impressa a linha dos serviços ISSQN
504
        $linhaISSQN = 0;
505
        if ((isset($this->ISSQNtot)) && ($this->getTagValue($this->ISSQNtot, 'vServ') > 0)) {
506
            $linhaISSQN = 1;
507
        }
508
        //calcular a altura necessária para os dados adicionais
509
        if ($this->orientacao == 'P') {
510
            $this->wAdic = round($this->wPrint * 0.66, 0);
511
        } else {
512
            $this->wAdic = round(($this->wPrint - $this->wCanhoto) * 0.5, 0);
513
        }
514
        $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...
515
516
        $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...
517
518
        //altura disponivel para os campos da DANFE
519
        $hcabecalho    = 47;//para cabeçalho
520
        $hdestinatario = 25;//para destinatario
521
        $hduplicatas   = 12;//para cada grupo de 7 duplicatas
522
        if (isset($this->entrega)) {
523
            $hlocalentrega = 25;
524
        } else {
525
            $hlocalentrega = 0;
526
        }
527
        if (isset($this->retirada)) {
528
            $hlocalretirada = 25;
529
        } else {
530
            $hlocalretirada = 0;
531
        }
532
        $himposto    = 18;// para imposto
533
        $htransporte = 25;// para transporte
534
        $hissqn      = 11;// para issqn
535
        $hfooter     = 5;// para rodape
536
        $hCabecItens = 4;//cabeçalho dos itens
537
        $hOCUPADA    = $hcabecalho
538
            + $hdestinatario
539
            + $hlocalentrega
540
            + $hlocalretirada
541
            + ($linhasDup * $hduplicatas)
542
            + $himposto + $htransporte
543
            + ($linhaISSQN * $hissqn)
544
            + $this->hdadosadic
545
            + $hfooter
546
            + $hCabecItens
547
            + $this->sizeExtraTextoFatura();
548
549
        //alturas disponiveis para os dados
550
        $hDispo1 = $this->hPrint - $hOCUPADA;
551
        /*($hcabecalho +
552
        //$hdestinatario + ($linhasDup * $hduplicatas) + $himposto + $htransporte +
553
        $hdestinatario + $hlocalentrega + $hlocalretirada +
554
        ($linhasDup * $hduplicatas) + $himposto + $htransporte +
555
        ($linhaISSQN * $hissqn) + $this->hdadosadic + $hfooter + $hCabecItens +
556
        $this->sizeExtraTextoFatura());*/
557
558
        if ($this->orientacao == 'P') {
559
            $hDispo1 -= 24 * $this->qCanhoto;//para canhoto
560
            $w       = $this->wPrint;
561
        } else {
562
            $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...
563
            $w        = $this->wPrint - $this->wCanhoto;
564
        }
565
        //$hDispo1 += 14;
566
        $hDispo2 = $this->hPrint - ($hcabecalho + $hfooter + $hCabecItens);
567
        //Contagem da altura ocupada para impressão dos itens
568
        $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...
569
        $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...
570
        $hUsado    = $hCabecItens;
571
        $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...
572
        $hDispo    = $hDispo1;
573
        $totPag    = 1;
574
        $i         = 0;
575
        while ($i < $this->det->length) {
576
            $itemProd = $this->det->item($i);
577
            $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...
578
            $mostrarUnidadeTributavel = false;
0 ignored issues
show
Unused Code introduced by
$mostrarUnidadeTributavel 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...
579
580
            $prod = $itemProd->getElementsByTagName('prod')->item(0);
581
            $uCom = $prod->getElementsByTagName("uCom")->item(0)->nodeValue;
0 ignored issues
show
Unused Code introduced by
$uCom 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...
582
            $vUnCom = $prod->getElementsByTagName("vUnCom")->item(0)->nodeValue;
583
            $uTrib = $prod->getElementsByTagName("uTrib")->item(0);
584
            $qTrib = $prod->getElementsByTagName("qTrib")->item(0);
585
            $vUnTrib = !empty($prod->getElementsByTagName("vUnTrib")->item(0)->nodeValue)
586
                ? $prod->getElementsByTagName("vUnTrib")->item(0)->nodeValue
587
                : 0;
588
            //se as unidades forem diferentes e q qtda de qTrib for maior que 0
589
            //mostrat as unidades
590
            $mostrarUnidadeTributavel = (
591
                !empty($uTrib)
592
                && !empty($qTrib)
593
                && number_format($vUnCom, 2, ',', '') !== number_format($vUnTrib, 2, ',', '')
594
            );
595
            $hUsado += $this->calculeHeight($itemProd, $mostrarUnidadeTributavel);
596
            if ($hUsado > $hDispo) {
597
                $totPag ++;
598
                $hDispo = $hDispo2;
599
                $hUsado = $hCabecItens;
600
                $i --; // decrementa para readicionar o item que não coube nessa pagina na outra.
601
            }
602
            $i ++;
603
        } //fim da soma das areas de itens usadas
604
        $qtdeItens = $i; //controle da quantidade de itens no DANFE
605
        //montagem da primeira página
606
        $pag = 1;
607
608
        $x = $this->margesq;
609
        $y = $this->margsup;
610
        //coloca o(s) canhoto(s) da NFe
611
        if ($this->orientacao == 'P') {
612
            $y = $this->canhoto($this->margesq, $this->margsup);
613
        } else {
614
            $this->canhoto($this->margesq, $this->margsup);
615
            $x = 25;
616
        }
617
        //coloca o cabeçalho
618
        $y = $this->header($x, $y, $pag, $totPag);
619
        //coloca os dados do destinatário
620
        $y = $this->destinatarioDANFE($x, $y + 1);
621
        //coloca os dados do local de retirada
622
        if (isset($this->retirada)) {
623
            $y = $this->localRetiradaDANFE($x, $y + 1);
624
        }
625
        //coloca os dados do local de entrega
626
        if (isset($this->entrega)) {
627
            $y = $this->localEntregaDANFE($x, $y + 1);
628
        }
629
630
        //Verifica as formas de pagamento da nota fiscal
631
        $formaPag = [];
632
        if (isset($this->detPag) && $this->detPag->length > 0) {
633
            foreach ($this->detPag as $k => $d) {
634
                $fPag            = ! empty($this->detPag->item($k)->getElementsByTagName('tPag')->item(0)->nodeValue)
635
                    ? $this->detPag->item($k)->getElementsByTagName('tPag')->item(0)->nodeValue
636
                    : '0';
637
                $formaPag[$fPag] = $fPag;
638
            }
639
        }
640
        //caso tenha boleto imprimir fatura
641
        if ($this->dup->length > 0) {
642
            $y = $this->fatura($x, $y + 1);
643
        } else {
644
            //Se somente tiver a forma de pagamento sem pagamento não imprimir nada
645
            if (count($formaPag) == '1' && isset($formaPag[90])) {
646
                $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...
647
            } else {
648
                //caso tenha mais de uma forma de pagamento ou seja diferente de boleto exibe a
649
                //forma de pagamento e o valor
650
                $y = $this->pagamento($x, $y + 1);
651
            }
652
        }
653
        //coloca os dados dos impostos e totais da NFe
654
        $y = $this->imposto($x, $y + 1);
655
        //coloca os dados do trasnporte
656
        $y = $this->transporte($x, $y + 1);
657
        //itens da DANFE
658
        $nInicial = 0;
659
660
        $y = $this->itens($x, $y + 1, $nInicial, $hDispo1, $pag, $totPag, $hCabecItens);
661
662
        //coloca os dados do ISSQN
663
        if ($linhaISSQN == 1) {
664
            $y = $this->issqn($x, $y + 4);
665
        } else {
666
            $y += 4;
667
        }
668
        //coloca os dados adicionais da NFe
669
        $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...
670
        //coloca o rodapé da página
671
        if ($this->orientacao == 'P') {
672
            $this->rodape($xInic);
673
        } else {
674
            $this->rodape($xInic);
675
        }
676
677
        //loop para páginas seguintes
678
        for ($n = 2; $n <= $totPag; $n ++) {
679
            // fixa as margens
680
            $this->pdf->setMargins($this->margesq, $this->margsup);
681
            //adiciona nova página
682
            $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...
683
            //ajusta espessura das linhas
684
            $this->pdf->setLineWidth(0.1);
685
            //seta a cor do texto para petro
686
            $this->pdf->settextcolor(0, 0, 0);
687
            // posição inicial do relatorio
688
            $x = $this->margesq;
689
            $y = $this->margsup;
690
            //coloca o cabeçalho na página adicional
691
            $y = $this->header($x, $y, $n, $totPag);
692
            //coloca os itens na página adicional
693
            $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...
694
            //coloca o rodapé da página
695
            if ($this->orientacao == 'P') {
696
                $this->rodape($this->margesq);
697
            } else {
698
                $this->rodape($this->margesq);
699
            }
700
            //se estiver na última página e ainda restar itens para inserir, adiciona mais uma página
701
            if ($n == $totPag && $this->qtdeItensProc < $qtdeItens) {
702
                $totPag ++;
703
            }
704
        }
705
    }
706
707
    /**
708
     * anfavea
709
     * Função para transformar o campo cdata do padrão ANFAVEA para
710
     * texto imprimível
711
     *
712
     * @param string $cdata campo CDATA
713
     *
714
     * @return string conteúdo do campo CDATA como string
715
     */
716
    protected function anfaveaDANFE($cdata = '')
717
    {
718
        if ($cdata == '') {
719
            return '';
720
        }
721
        //remove qualquer texto antes ou depois da tag CDATA
722
        $cdata    = str_replace('<![CDATA[', '<CDATA>', $cdata);
723
        $cdata    = str_replace(']]>', '</CDATA>', $cdata);
724
        $cdata    = preg_replace('/\s\s+/', ' ', $cdata);
725
        $cdata    = str_replace("> <", "><", $cdata);
726
        $len      = strlen($cdata);
727
        $startPos = strpos($cdata, '<');
728
        if ($startPos === false) {
729
            return $cdata;
730
        }
731
        for ($x = $len; $x > 0; $x --) {
732
            if (substr($cdata, $x, 1) == '>') {
733
                $endPos = $x;
734
                break;
735
            }
736
        }
737
        if ($x === 0) {
738
            return $cdata;
739
        }
740
        if ($startPos > 0) {
741
            $parte1 = substr($cdata, 0, $startPos);
742
        } else {
743
            $parte1 = '';
744
        }
745
        $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...
746
        if ($endPos < $len) {
747
            $parte3 = substr($cdata, $endPos + 1, $len - $endPos - 1);
748
        } else {
749
            $parte3 = '';
750
        }
751
        $texto = trim($parte1) . ' ' . trim($parte3);
752
        if (strpos($parte2, '<CDATA>') === false) {
753
            $cdata = '<CDATA>' . $parte2 . '</CDATA>';
754
        } else {
755
            $cdata = $parte2;
756
        }
757
        //Retira a tag <FONTE IBPT> (caso existir) pois não é uma estrutura válida XML
758
        $cdata = str_replace('<FONTE IBPT>', '', $cdata);
759
        //carrega o xml CDATA em um objeto DOM
760
        $dom = new Dom();
761
        $dom->loadXML($cdata, LIBXML_NOBLANKS | LIBXML_NOEMPTYTAG);
762
        //$xml = $dom->saveXML();
763
        //grupo CDATA infADprod
764
        $id   = $dom->getElementsByTagName('id')->item(0);
765
        $div  = $dom->getElementsByTagName('div')->item(0);
766
        $entg = $dom->getElementsByTagName('entg')->item(0);
767
        $dest = $dom->getElementsByTagName('dest')->item(0);
768
        $ctl  = $dom->getElementsByTagName('ctl')->item(0);
769
        $ref  = $dom->getElementsByTagName('ref')->item(0);
770
        if (isset($id)) {
771
            if ($id->hasAttributes()) {
772
                foreach ($id->attributes as $attr) {
773
                    $name  = $attr->nodeName;
774
                    $value = $attr->nodeValue;
775
                    $texto .= " $name : $value";
776
                }
777
            }
778
        }
779
        if (isset($div)) {
780
            if ($div->hasAttributes()) {
781
                foreach ($div->attributes as $attr) {
782
                    $name  = $attr->nodeName;
783
                    $value = $attr->nodeValue;
784
                    $texto .= " $name : $value";
785
                }
786
            }
787
        }
788
        if (isset($entg)) {
789
            if ($entg->hasAttributes()) {
790
                foreach ($entg->attributes as $attr) {
791
                    $name  = $attr->nodeName;
792
                    $value = $attr->nodeValue;
793
                    $texto .= " $name : $value";
794
                }
795
            }
796
        }
797
        if (isset($dest)) {
798
            if ($dest->hasAttributes()) {
799
                foreach ($dest->attributes as $attr) {
800
                    $name  = $attr->nodeName;
801
                    $value = $attr->nodeValue;
802
                    $texto .= " $name : $value";
803
                }
804
            }
805
        }
806
        if (isset($ctl)) {
807
            if ($ctl->hasAttributes()) {
808
                foreach ($ctl->attributes as $attr) {
809
                    $name  = $attr->nodeName;
810
                    $value = $attr->nodeValue;
811
                    $texto .= " $name : $value";
812
                }
813
            }
814
        }
815
        if (isset($ref)) {
816
            if ($ref->hasAttributes()) {
817
                foreach ($ref->attributes as $attr) {
818
                    $name  = $attr->nodeName;
819
                    $value = $attr->nodeValue;
820
                    $texto .= " $name : $value";
821
                }
822
            }
823
        }
824
        //grupo CADATA infCpl
825
        $t          = $dom->getElementsByTagName('transmissor')->item(0);
826
        $r          = $dom->getElementsByTagName('receptor')->item(0);
827
        $versao     = ! empty($dom->getElementsByTagName('versao')->item(0)->nodeValue) ?
828
            'Versao:' . $dom->getElementsByTagName('versao')->item(0)->nodeValue . ' ' : '';
829
        $especieNF  = ! empty($dom->getElementsByTagName('especieNF')->item(0)->nodeValue) ?
830
            'Especie:' . $dom->getElementsByTagName('especieNF')->item(0)->nodeValue . ' ' : '';
831
        $fabEntrega = ! empty($dom->getElementsByTagName('fabEntrega')->item(0)->nodeValue) ?
832
            'Entrega:' . $dom->getElementsByTagName('fabEntrega')->item(0)->nodeValue . ' ' : '';
833
        $dca        = ! empty($dom->getElementsByTagName('dca')->item(0)->nodeValue) ?
834
            'dca:' . $dom->getElementsByTagName('dca')->item(0)->nodeValue . ' ' : '';
835
        $texto      .= "" . $versao . $especieNF . $fabEntrega . $dca;
836
        if (isset($t)) {
837
            if ($t->hasAttributes()) {
838
                $texto .= " Transmissor ";
839
                foreach ($t->attributes as $attr) {
840
                    $name  = $attr->nodeName;
841
                    $value = $attr->nodeValue;
842
                    $texto .= " $name : $value";
843
                }
844
            }
845
        }
846
        if (isset($r)) {
847
            if ($r->hasAttributes()) {
848
                $texto .= " Receptor ";
849
                foreach ($r->attributes as $attr) {
850
                    $name  = $attr->nodeName;
851
                    $value = $attr->nodeValue;
852
                    $texto .= " $name : $value";
853
                }
854
            }
855
        }
856
857
        return $texto;
858
    }
859
860
    /**
861
     * Verifica o status da NFe
862
     *
863
     * @return array
864
     */
865
    protected function statusNFe()
866
    {
867
        $resp = [
868
            'status' => true,
869
            'message' => [],
870
            'submessage' => ''
871
        ];
872
        if (!empty($this->epec)) {
873
            return $resp;
874
        }
875
        if (!isset($this->nfeProc)) {
876
            $resp['status'] = false;
877
            $resp['message'][] = 'NFe NÃO PROTOCOLADA';
878
        } else {
879
            if ($this->getTagValue($this->ide, "tpAmb") == '2') {
880
                $resp['status'] = false;
881
                $resp['message'][] =  "NFe EMITIDA EM HOMOLOGAÇÃO";
882
            }
883
            $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...
884
            $cStat = $this->getTagValue($this->nfeProc, "cStat");
885
            if ($cStat == '110' ||
886
                $cStat == '301' ||
887
                $cStat == '302'
888
            ) {
889
                $resp['status'] = false;
890
                $resp['message'][] = "NFe DENEGADA";
891
            } elseif ($cStat == '101'
892
                || $cStat == '151'
893
                || $cStat == '135'
894
                || $cStat == '155'
895
                || $this->cancelFlag === true
896
            ) {
897
                $resp['status'] = false;
898
                $resp['message'][] = "NFe CANCELADA";
899
            } elseif (!empty($retEvento)) {
900
                $infEvento = $retEvento->getElementsByTagName('infEvento')->item(0);
901
                $cStat = $this->getTagValue($infEvento, "cStat");
902
                $tpEvento= $this->getTagValue($infEvento, "tpEvento");
903
                $dhEvento = $this->toDateTime($this->getTagValue($infEvento, "dhRegEvento"))->format("d/m/Y H:i:s");
904
                $nProt = $this->getTagValue($infEvento, "nProt");
905
                if ($tpEvento == '110111' &&
906
                    ($cStat == '101' ||
907
                     $cStat == '151' ||
908
                     $cStat == '135' ||
909
                     $cStat == '155')
910
                ) {
911
                    $resp['status'] = false;
912
                    $resp['message'][] = "NFe CANCELADA";
913
                    $resp['submessage'] = "{$dhEvento} - {$nProt}";
914
                }
915
            }
916
        }
917
        return $resp;
918
    }
919
920
    /**
921
     *header
922
     * Monta o cabelhalho da DANFE (retrato e paisagem)
923
     *
924
     * @param number $x      Posição horizontal inicial, canto esquerdo
925
     * @param number $y      Posição vertical inicial, canto superior
926
     * @param number $pag    Número da Página
927
     * @param number $totPag Total de páginas
928
     *
929
     * @return number Posição vertical final
930
     */
931
    protected function header($x = 0, $y = 0, $pag = '1', $totPag = '1')
932
    {
933
        $oldX = $x;
934
        $oldY = $y;
935
        if ($this->orientacao == 'P') {
936
            $maxW = $this->wPrint;
937
        } else {
938
            if ($pag == 1) { // primeira página
939
                $maxW = $this->wPrint - $this->wCanhoto;
940
            } else { // páginas seguintes
941
                $maxW = $this->wPrint;
942
            }
943
        }
944
        //####################################################################################
945
        //coluna esquerda identificação do emitente
946
        $w = round($maxW * 0.41, 0);
947
        if ($this->orientacao == 'P') {
948
            $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => 'I'];
949
        } else {
950
            $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'];
951
        }
952
        $w1   = $w;
953
        $h    = 32;
954
        $oldY += $h;
955
        $this->pdf->textBox($x, $y, $w, $h);
956
        $texto = 'IDENTIFICAÇÃO DO EMITENTE';
957
        $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...
958
        //estabelecer o alinhamento
959
        //pode ser left L, center C, right R, full logo L
960
        //se for left separar 1/3 da largura para o tamanho da imagem
961
        //os outros 2/3 serão usados para os dados do emitente
962
        //se for center separar 1/2 da altura para o logo e 1/2 para os dados
963
        //se for right separa 2/3 para os dados e o terço seguinte para o logo
964
        //se não houver logo centraliza dos dados do emitente
965
        // coloca o logo
966
        if (! empty($this->logomarca)) {
967
            $logoInfo = getimagesize($this->logomarca);
968
            //largura da imagem em mm
969
            $logoWmm = ($logoInfo[0] / 72) * 25.4;
970
            //altura da imagem em mm
971
            $logoHmm = ($logoInfo[1] / 72) * 25.4;
972
            if ($this->logoAlign == 'L') {
973
                $nImgW = round($w / 3, 0);
974
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
975
                $xImg  = $x + 1;
976
                $yImg  = round(($h - $nImgH) / 2, 0) + $y;
977
                //estabelecer posições do texto
978
                $x1 = round($xImg + $nImgW + 1, 0);
979
                $y1 = round($h / 3 + $y, 0);
980
                $tw = round(2 * $w / 3, 0);
981
            } elseif ($this->logoAlign == 'C') {
982
                $nImgH = round($h / 3, 0);
983
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
984
                $xImg  = round(($w - $nImgW) / 2 + $x, 0);
985
                $yImg  = $y + 3;
986
                $x1    = $x;
987
                $y1    = round($yImg + $nImgH + 1, 0);
988
                $tw    = $w;
989
            } elseif ($this->logoAlign == 'R') {
990
                $nImgW = round($w / 3, 0);
991
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
992
                $xImg  = round($x + ($w - (1 + $nImgW)), 0);
993
                $yImg  = round(($h - $nImgH) / 2, 0) + $y;
994
                $x1    = $x;
995
                $y1    = round($h / 3 + $y, 0);
996
                $tw    = round(2 * $w / 3, 0);
997
            } elseif ($this->logoAlign == 'F') {
998
                $nImgH = round($h - 5, 0);
999
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
1000
                $xImg  = round(($w - $nImgW) / 2 + $x, 0);
1001
                $yImg  = $y + 3;
1002
                $x1    = $x;
1003
                $y1    = round($yImg + $nImgH + 1, 0);
1004
                $tw    = $w;
1005
            }
1006
            $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...
1007
            $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...
1008
        } else {
1009
            $x1 = $x;
1010
            $y1 = round($h / 3 + $y, 0);
1011
            $tw = $w;
1012
        }
1013
        // monta as informações apenas se diferente de full logo
1014
        if ($this->logoAlign !== 'F') {
1015
            //Nome emitente
1016
            $aFont = ['font' => $this->fontePadrao, 'size' => 12, 'style' => 'B'];
1017
            $texto = $this->emit->getElementsByTagName("xNome")->item(0)->nodeValue;
1018
            $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...
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...
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...
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...
1019
            //endereço
1020
            $y1     = $y1 + 5;
1021
            $aFont  = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
1022
            $fone   = ! empty($this->enderEmit->getElementsByTagName("fone")->item(0)->nodeValue)
1023
                ? $this->enderEmit->getElementsByTagName("fone")->item(0)->nodeValue
1024
                : '';
1025
            $lgr    = $this->getTagValue($this->enderEmit, "xLgr");
1026
            $nro    = $this->getTagValue($this->enderEmit, "nro");
1027
            $cpl    = $this->getTagValue($this->enderEmit, "xCpl", " - ");
1028
            $bairro = $this->getTagValue($this->enderEmit, "xBairro");
1029
            $CEP    = $this->getTagValue($this->enderEmit, "CEP");
1030
            $CEP    = $this->formatField($CEP, "#####-###");
1031
            $mun    = $this->getTagValue($this->enderEmit, "xMun");
1032
            $UF     = $this->getTagValue($this->enderEmit, "UF");
1033
            $texto  = $lgr . ", " . $nro . $cpl . "\n" . $bairro . " - "
1034
                . $CEP . "\n" . $mun . " - " . $UF . " "
1035
                . "Fone/Fax: " . $fone;
1036
            $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...
1037
        }
1038
1039
        //####################################################################################
1040
        //coluna central Danfe
1041
        $x  += $w;
1042
        $w  = round($maxW * 0.17, 0);//35;
1043
        $w2 = $w;
1044
        $h  = 32;
1045
        $this->pdf->textBox($x, $y, $w, $h);
1046
1047
        $texto = "DANFE";
1048
        $aFont = ['font' => $this->fontePadrao, 'size' => 14, 'style' => 'B'];
1049
        $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...
1050
        $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
1051
        $texto = 'Documento Auxiliar da Nota Fiscal Eletrônica';
1052
        $h     = 20;
1053
        $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...
1054
1055
        $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
1056
        $texto = '0 - ENTRADA';
1057
        $y1    = $y + 14;
1058
        $h     = 8;
1059
        $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...
1060
        $texto = '1 - SAÍDA';
1061
        $y1    = $y + 17;
1062
        $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...
1063
        //tipo de nF
1064
        $aFont = ['font' => $this->fontePadrao, 'size' => 12, 'style' => 'B'];
1065
        $y1    = $y + 13;
1066
        $h     = 7;
1067
        $texto = $this->ide->getElementsByTagName('tpNF')->item(0)->nodeValue;
1068
        $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...
1069
        //numero da NF
1070
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1071
        $y1    = $y + 20;
1072
        $numNF = str_pad(
1073
            $this->ide->getElementsByTagName('nNF')->item(0)->nodeValue,
1074
            9,
1075
            "0",
1076
            STR_PAD_LEFT
1077
        );
1078
        $numNF = $this->formatField($numNF, "###.###.###");
1079
        $texto = "Nº. " . $numNF;
1080
        $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...
1081
        //Série
1082
        $y1    = $y + 23;
1083
        $serie = str_pad(
1084
            $this->ide->getElementsByTagName('serie')->item(0)->nodeValue,
1085
            3,
1086
            "0",
1087
            STR_PAD_LEFT
1088
        );
1089
        $texto = "Série " . $serie;
1090
        $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...
1091
        //numero paginas
1092
        $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'I'];
1093
        $y1    = $y + 26;
1094
        $texto = "Folha " . $pag . "/" . $totPag;
1095
        $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...
1096
1097
        //####################################################################################
1098
        //coluna codigo de barras
1099
        $x  += $w;
1100
        $w  = ($maxW - $w1 - $w2);//85;
1101
        $w3 = $w;
1102
        $h  = 32;
1103
        $this->pdf->textBox($x, $y, $w, $h);
1104
        $this->pdf->setFillColor(0, 0, 0);
1105
        $chave_acesso = str_replace('NFe', '', $this->infNFe->getAttribute("Id"));
1106
        $bW           = 75;
1107
        $bH           = 12;
1108
        //codigo de barras
1109
        $this->pdf->code128($x + (($w - $bW) / 2), $y + 2, $chave_acesso, $bW, $bH);
1110
        //linhas divisorias
1111
        $this->pdf->line($x, $y + 4 + $bH, $x + $w, $y + 4 + $bH);
1112
        $this->pdf->line($x, $y + 12 + $bH, $x + $w, $y + 12 + $bH);
1113
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1114
        $y1    = $y + 4 + $bH;
1115
        $h     = 7;
1116
        $texto = 'CHAVE DE ACESSO';
1117
        $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...
1118
        $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'];
1119
        $y1    = $y + 8 + $bH;
1120
        $texto = $this->formatField($chave_acesso, $this->formatoChave);
1121
        $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...
1122
        $y1                = $y + 12 + $bH;
1123
        $aFont             = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
1124
        $chaveContingencia = "";
1125
        if (!empty($this->epec)) {
1126
            $cabecalhoProtoAutorizacao = 'NÚMERO DE REGISTRO EPEC';
1127
        } else {
1128
            $cabecalhoProtoAutorizacao = 'PROTOCOLO DE AUTORIZAÇÃO DE USO';
1129
        }
1130
        if (($this->tpEmis == 2 || $this->tpEmis == 5) && empty($this->epec)) {
1131
            $cabecalhoProtoAutorizacao = "DADOS DA NF-E";
1132
            $chaveContingencia         = $this->geraChaveAdicionalDeContingencia();
1133
            $this->pdf->setFillColor(0, 0, 0);
1134
            //codigo de barras
1135
            $this->pdf->code128($x + 11, $y1 + 1, $chaveContingencia, $bW * .9, $bH / 2);
1136
        } else {
1137
            $texto = 'Consulta de autenticidade no portal nacional da NF-e';
1138
            $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...
1139
            $y1    = $y + 16 + $bH;
1140
            $texto = 'www.nfe.fazenda.gov.br/portal ou no site da Sefaz Autorizadora';
1141
            $this->pdf->textBox(
1142
                $x + 2,
1143
                $y1,
1144
                $w - 2,
1145
                $h,
1146
                $texto,
1147
                $aFont,
1148
                'T',
1149
                'C',
1150
                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...
1151
                'http://www.nfe.fazenda.gov.br/portal ou no site da Sefaz Autorizadora'
1152
            );
1153
        }
1154
1155
        //####################################################################################
1156
        //Dados da NF do cabeçalho
1157
        //natureza da operação
1158
        $texto = 'NATUREZA DA OPERAÇÃO';
1159
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1160
        $w     = $w1 + $w2;
1161
        $y     = $oldY;
1162
        $oldY  += $h;
1163
        $x     = $oldX;
1164
        $h     = 7;
1165
        $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...
1166
        $texto = $this->ide->getElementsByTagName("natOp")->item(0)->nodeValue;
1167
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1168
        $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...
1169
        $x += $w;
1170
        $w = $w3;
1171
        //PROTOCOLO DE AUTORIZAÇÃO DE USO ou DADOS da NF-E
1172
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1173
        $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...
1174
        // algumas NFe podem estar sem o protocolo de uso portanto sua existencia deve ser
1175
        // testada antes de tentar obter a informação.
1176
        // NOTA : DANFE sem protocolo deve existir somente no caso de contingência !!!
1177
        // Além disso, existem várias NFes em contingência que eu recebo com protocolo de autorização.
1178
        // Na minha opinião, deveríamos mostra-lo, mas o  manual  da NFe v4.01 diz outra coisa...
1179
        if (($this->tpEmis == 2 || $this->tpEmis == 5) && empty($this->epec)) {
1180
            $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'];
1181
            $texto = $this->formatField(
1182
                $chaveContingencia,
1183
                "#### #### #### #### #### #### #### #### ####"
1184
            );
1185
            $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...
1186
        } else {
1187
            $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1188
            if (!empty($this->epec)) {
1189
                $texto = $this->epec['protocolo'] . ' - ' . $this->epec['data'];
1190
                $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...
1191
            } else {
1192
                if (isset($this->nfeProc)) {
1193
                    $texto  = ! empty($this->nfeProc->getElementsByTagName("nProt")->item(0)->nodeValue)
1194
                        ? $this->nfeProc->getElementsByTagName("nProt")->item(0)->nodeValue
1195
                        : '';
1196
                    $dtHora = $this->toDateTime(
1197
                        $this->nfeProc->getElementsByTagName("dhRecbto")->item(0)->nodeValue
1198
                    );
1199
                    if ($texto != '') {
1200
                        $texto .= "  -  " . $dtHora->format('d/m/Y H:i:s');
1201
                    }
1202
                    $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...
1203
                } else {
1204
                    $texto = '';
1205
                    $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...
1206
                }
1207
            }
1208
        }
1209
        $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...
1210
        //####################################################################################
1211
        //INSCRIÇÃO ESTADUAL
1212
        $w     = round($maxW * 0.250, 0);
1213
        $y     += $h;
1214
        $oldY  += $h;
1215
        $x     = $oldX;
1216
        $texto = 'INSCRIÇÃO ESTADUAL';
1217
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1218
        $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...
1219
        $texto = $this->getTagValue($this->emit, "IE");
1220
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1221
        $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...
1222
        //INSCRIÇÃO MUNICIPAL
1223
        $x     += $w;
1224
        $texto = 'INSCRIÇÃO MUNICIPAL';
1225
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1226
        $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...
1227
        $texto = $this->getTagValue($this->emit, "IM");
1228
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1229
        $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...
1230
        //INSCRIÇÃO ESTADUAL DO SUBST. TRIBUT.
1231
        $x     += $w;
1232
        $texto = 'INSCRIÇÃO ESTADUAL DO SUBST. TRIBUT.';
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
        $texto = ! empty($this->emit->getElementsByTagName("IEST")->item(0)->nodeValue)
1236
            ? $this->emit->getElementsByTagName("IEST")->item(0)->nodeValue
1237
            : '';
1238
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1239
        $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...
1240
        //CNPJ
1241
        $x     += $w;
1242
        $w     = ($maxW - (3 * $w));
1243
        $texto = 'CNPJ / CPF';
1244
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1245
        $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...
1246
        //Pegando valor do CPF/CNPJ
1247
        if (! empty($this->emit->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1248
            $texto = $this->formatField(
1249
                $this->emit->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1250
                "###.###.###/####-##"
1251
            );
1252
        } else {
1253
            $texto = ! empty($this->emit->getElementsByTagName("CPF")->item(0)->nodeValue)
1254
                ? $this->formatField(
1255
                    $this->emit->getElementsByTagName("CPF")->item(0)->nodeValue,
1256
                    "###.###.###-##"
1257
                )
1258
                : '';
1259
        }
1260
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1261
        $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...
1262
1263
        //####################################################################################
1264
        //Indicação de NF Homologação, cancelamento e falta de protocolo
1265
        $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...
1266
        //indicar cancelamento
1267
        $resp = $this->statusNFe();
1268
        if (!$resp['status']) {
1269
            $n = count($resp['message']);
1270
            $alttot = $n * 15;
1271
            $x = 10;
1272
            $y = $this->hPrint/2 - $alttot/2;
1273
            $h = 15;
1274
            $w = $maxW - (2 * $x);
1275
            $this->pdf->settextcolor(90, 90, 90);
1276
1277
            foreach ($resp['message'] as $msg) {
1278
                $aFont = ['font' => $this->fontePadrao, 'size' => 48, 'style' => 'B'];
1279
                $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...
1280
                $y += $h;
1281
            }
1282
            $texto = $resp['submessage'];
1283
            if (!empty($texto)) {
1284
                $y += 3;
1285
                $h = 5;
1286
                $aFont = ['font' => $this->fontePadrao, 'size' => 20, 'style' => 'B'];
1287
                $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...
1288
                $y += $h;
1289
            }
1290
            $y += 5;
1291
            $w = $maxW - (2 * $x);
1292
            $texto = "SEM VALOR FISCAL";
1293
            $aFont = ['font' => $this->fontePadrao, 'size' => 48, 'style' => 'B'];
1294
            $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...
1295
            $this->pdf->settextcolor(0, 0, 0);
1296
        }
1297
        if (!empty($this->epec) || $this->tpEmis == 4) {
1298
            //EPEC
1299
            $x = 10;
1300
            $y = $this->hPrint - 130;
1301
            $h = 25;
1302
            $w = $maxW - (2 * $x);
1303
            $this->pdf->SetTextColor(200, 200, 200);
1304
            $texto = "DANFE impresso em contingência -\n" .
1305
                "EPEC regularmente recebido pela Receita\n" .
1306
                "Federal do Brasil";
1307
            $aFont = ['font' => $this->fontePadrao, 'size' => 48, 'style' => 'B'];
1308
            $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...
1309
            $this->pdf->SetTextColor(0, 0, 0);
1310
        }
1311
1312
        return $oldY;
1313
    } //fim header
1314
1315
    /**
1316
     * destinatarioDANFE
1317
     * Monta o campo com os dados do destinatário na DANFE. (retrato e paisagem)
1318
     *
1319
     * @name   destinatarioDANFE
1320
     *
1321
     * @param number $x Posição horizontal canto esquerdo
1322
     * @param number $y Posição vertical canto superior
1323
     *
1324
     * @return number Posição vertical final
1325
     */
1326
    protected function destinatarioDANFE($x = 0, $y = 0)
1327
    {
1328
        //####################################################################################
1329
        //DESTINATÁRIO / REMETENTE
1330
        $oldX = $x;
1331
        $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...
1332
        if ($this->orientacao == 'P') {
1333
            $maxW = $this->wPrint;
1334
        } else {
1335
            $maxW = $this->wPrint - $this->wCanhoto;
1336
        }
1337
        $w     = $maxW;
1338
        $h     = 7;
1339
        $texto = 'DESTINATÁRIO / REMETENTE';
1340
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1341
        $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...
1342
        //NOME / RAZÃO SOCIAL
1343
        $w     = round($maxW * 0.61, 0);
1344
        $w1    = $w;
1345
        $y     += 3;
1346
        $texto = 'NOME / RAZÃO SOCIAL';
1347
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1348
        $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...
1349
        $texto = $this->dest->getElementsByTagName("xNome")->item(0)->nodeValue;
1350
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1351
        if ($this->orientacao == 'P') {
1352
            $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...
1353
        } else {
1354
            $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...
1355
        }
1356
        //CNPJ / CPF
1357
        $x     += $w;
1358
        $w     = round($maxW * 0.23, 0);
1359
        $w2    = $w;
1360
        $texto = 'CNPJ / CPF';
1361
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1362
        $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...
1363
        //Pegando valor do CPF/CNPJ
1364
        if (! empty($this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1365
            $texto = $this->formatField(
1366
                $this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1367
                "###.###.###/####-##"
1368
            );
1369
        } else {
1370
            $texto = ! empty($this->dest->getElementsByTagName("CPF")->item(0)->nodeValue)
1371
                ? $this->formatField(
1372
                    $this->dest->getElementsByTagName("CPF")->item(0)->nodeValue,
1373
                    "###.###.###-##"
1374
                )
1375
                : '';
1376
        }
1377
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1378
        $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...
1379
        //DATA DA EMISSÃO
1380
        $x     += $w;
1381
        $w     = $maxW - ($w1 + $w2);
1382
        $wx    = $w;
1383
        $texto = 'DATA DA EMISSÃO';
1384
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1385
        $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...
1386
        $dEmi = ! empty($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue)
1387
            ? $this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue
1388
            : '';
1389
        if ($dEmi == '') {
1390
            $dEmi  = ! empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue)
1391
                ? $this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue
1392
                : '';
1393
            $aDemi = explode('T', $dEmi);
1394
            $dEmi  = $aDemi[0];
1395
        }
1396
        $texto = $this->ymdTodmy($dEmi);
1397
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1398
        if ($this->orientacao == 'P') {
1399
            $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...
1400
        } else {
1401
            $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...
1402
        }
1403
        //ENDEREÇO
1404
        $w     = round($maxW * 0.47, 0);
1405
        $w1    = $w;
1406
        $y     += $h;
1407
        $x     = $oldX;
1408
        $texto = 'ENDEREÇO';
1409
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1410
        $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...
1411
        $texto = $this->dest->getElementsByTagName("xLgr")->item(0)->nodeValue;
1412
        $texto .= ', ' . $this->dest->getElementsByTagName("nro")->item(0)->nodeValue;
1413
        $texto .= $this->getTagValue($this->dest, "xCpl", " - ");
1414
1415
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1416
        $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...
1417
        //BAIRRO / DISTRITO
1418
        $x     += $w;
1419
        $w     = round($maxW * 0.21, 0);
1420
        $w2    = $w;
1421
        $texto = 'BAIRRO / DISTRITO';
1422
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1423
        $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...
1424
        $texto = $this->dest->getElementsByTagName("xBairro")->item(0)->nodeValue;
1425
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1426
        $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...
1427
        //CEP
1428
        $x     += $w;
1429
        $w     = $maxW - $w1 - $w2 - $wx;
1430
        $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...
1431
        $texto = 'CEP';
1432
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1433
        $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...
1434
        $texto = ! empty($this->dest->getElementsByTagName("CEP")->item(0)->nodeValue)
1435
            ? $this->dest->getElementsByTagName("CEP")->item(0)->nodeValue
1436
            : '';
1437
        $texto = $this->formatField($texto, "#####-###");
1438
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1439
        $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...
1440
        //DATA DA SAÍDA
1441
        $x     += $w;
1442
        $w     = $wx;
1443
        $texto = 'DATA DA SAÍDA/ENTRADA';
1444
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1445
        $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...
1446
        $dSaiEnt = ! empty($this->ide->getElementsByTagName("dSaiEnt")->item(0)->nodeValue)
1447
            ? $this->ide->getElementsByTagName("dSaiEnt")->item(0)->nodeValue
1448
            : '';
1449
        if ($dSaiEnt == '') {
1450
            $dSaiEnt  = ! empty($this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue)
1451
                ? $this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue
1452
                : '';
1453
            $aDsaient = explode('T', $dSaiEnt);
1454
            $dSaiEnt  = $aDsaient[0];
1455
        }
1456
        $texto = $this->ymdTodmy($dSaiEnt);
1457
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1458
        $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...
1459
        //MUNICÍPIO
1460
        $w     = $w1;
1461
        $y     += $h;
1462
        $x     = $oldX;
1463
        $texto = 'MUNICÍPIO';
1464
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1465
        $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...
1466
        $texto = $this->dest->getElementsByTagName("xMun")->item(0)->nodeValue;
1467
        if (strtoupper(trim($texto)) == "EXTERIOR"
1468
            && $this->dest->getElementsByTagName("xPais")->length > 0
1469
        ) {
1470
            $texto .= " - " . $this->dest->getElementsByTagName("xPais")->item(0)->nodeValue;
1471
        }
1472
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1473
        $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...
1474
        //UF
1475
        $x     += $w;
1476
        $w     = 8;
1477
        $texto = 'UF';
1478
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1479
        $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...
1480
        $texto = $this->dest->getElementsByTagName("UF")->item(0)->nodeValue;
1481
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1482
        $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...
1483
        //FONE / FAX
1484
        $x     += $w;
1485
        $w     = round(($maxW - $w1 - $wx - 8) / 2, 0);
1486
        $w3    = $w;
1487
        $texto = 'FONE / FAX';
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
        $texto = ! empty($this->dest->getElementsByTagName("fone")->item(0)->nodeValue)
1491
            ? $this->dest->getElementsByTagName("fone")->item(0)->nodeValue
1492
            : '';
1493
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1494
        $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...
1495
        //INSCRIÇÃO ESTADUAL
1496
        $x     += $w;
1497
        $w     = $maxW - $w1 - $wx - 8 - $w3;
1498
        $texto = 'INSCRIÇÃO ESTADUAL';
1499
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1500
        $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...
1501
        $IE    = $this->dest->getElementsByTagName("IE");
1502
        $texto = ($IE && $IE->length > 0) ? $IE->item(0)->nodeValue : '';
1503
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1504
        $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...
1505
        //HORA DA SAÍDA
1506
        $x     += $w;
1507
        $w     = $wx;
1508
        $texto = 'HORA DA SAÍDA/ENTRADA';
1509
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1510
        $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...
1511
        $hSaiEnt = ! empty($this->ide->getElementsByTagName("hSaiEnt")->item(0)->nodeValue)
1512
            ? $this->ide->getElementsByTagName("hSaiEnt")->item(0)->nodeValue
1513
            : '';
1514
        if ($hSaiEnt == '') {
1515
            $dhSaiEnt   = ! empty($this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue)
1516
                ? $this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue
1517
                : '';
1518
            $tsDhSaiEnt = $this->toDateTime($dhSaiEnt);
1519
            if ($tsDhSaiEnt) {
1520
                $hSaiEnt = $tsDhSaiEnt->format('H:i:s');
1521
            }
1522
        }
1523
        $texto = $hSaiEnt;
1524
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1525
        $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...
1526
1527
        return ($y + $h);
1528
    } //fim da função destinatarioDANFE
1529
1530
    /**
1531
     * localEntregaDANFE
1532
     * Monta o campo com os dados do local de entrega na DANFE. (retrato e paisagem)
1533
     *
1534
     * @name   localEntregaDANFE
1535
     *
1536
     * @param number $x Posição horizontal canto esquerdo
1537
     * @param number $y Posição vertical canto superior
1538
     *
1539
     * @return number Posição vertical final
1540
     */
1541
    protected function localEntregaDANFE($x = 0, $y = 0)
1542
    {
1543
        //####################################################################################
1544
        //LOCAL DE ENTREGA
1545
        $oldX = $x;
1546
        if ($this->orientacao == 'P') {
1547
            $maxW = $this->wPrint;
1548
        } else {
1549
            $maxW = $this->wPrint - $this->wCanhoto;
1550
        }
1551
        $w     = $maxW;
1552
        $h     = 7;
1553
        $texto = 'INFORMAÇÕES DO LOCAL DE ENTREGA';
1554
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1555
        $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...
1556
        //NOME / RAZÃO SOCIAL
1557
        $w     = round($maxW * 0.61, 0);
1558
        $w1    = $w;
1559
        $y     += 3;
1560
        $texto = 'NOME / RAZÃO SOCIAL';
1561
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1562
        $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...
1563
        $texto = '';
1564
        if ($this->entrega->getElementsByTagName("xNome")->item(0)) {
1565
            $texto = $this->entrega->getElementsByTagName("xNome")->item(0)->nodeValue;
1566
        }
1567
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1568
        if ($this->orientacao == 'P') {
1569
            $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...
1570
        } else {
1571
            $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...
1572
        }
1573
        //CNPJ / CPF
1574
        $x     += $w;
1575
        $w     = round($maxW * 0.23, 0);
1576
        $w2    = $w;
1577
        $texto = 'CNPJ / CPF';
1578
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1579
        $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...
1580
        //Pegando valor do CPF/CNPJ
1581
        if (! empty($this->entrega->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1582
            $texto = $this->formatField(
1583
                $this->entrega->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1584
                "###.###.###/####-##"
1585
            );
1586
        } else {
1587
            $texto = ! empty($this->entrega->getElementsByTagName("CPF")->item(0)->nodeValue) ?
1588
                $this->formatField(
1589
                    $this->entrega->getElementsByTagName("CPF")->item(0)->nodeValue,
1590
                    "###.###.###-##"
1591
                ) : '';
1592
        }
1593
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1594
        $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...
1595
        //INSCRIÇÃO ESTADUAL
1596
        $x     += $w;
1597
        $w     = $maxW - ($w1 + $w2);
1598
        $wx    = $w;
1599
        $texto = 'INSCRIÇÃO ESTADUAL';
1600
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1601
        $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...
1602
        $texto = '';
1603
        if ($this->entrega->getElementsByTagName("IE")->item(0)) {
1604
            $texto = $this->entrega->getElementsByTagName("IE")->item(0)->nodeValue;
1605
        }
1606
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1607
        if ($this->orientacao == 'P') {
1608
            $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...
1609
        } else {
1610
            $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...
1611
        }
1612
        //ENDEREÇO
1613
        $w     = round($maxW * 0.355, 0) + $wx;
1614
        $w1    = $w;
1615
        $y     += $h;
1616
        $x     = $oldX;
1617
        $texto = 'ENDEREÇO';
1618
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1619
        $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...
1620
        $texto = $this->entrega->getElementsByTagName("xLgr")->item(0)->nodeValue;
1621
        $texto .= ', ' . $this->entrega->getElementsByTagName("nro")->item(0)->nodeValue;
1622
        $texto .= $this->getTagValue($this->entrega, "xCpl", " - ");
1623
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1624
        $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...
1625
        //BAIRRO / DISTRITO
1626
        $x     += $w;
1627
        $w     = round($maxW * 0.335, 0);
1628
        $w2    = $w;
1629
        $texto = 'BAIRRO / DISTRITO';
1630
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1631
        $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...
1632
        $texto = $this->entrega->getElementsByTagName("xBairro")->item(0)->nodeValue;
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
        //CEP
1636
        $x     += $w;
1637
        $w     = $maxW - ($w1 + $w2);
1638
        $texto = 'CEP';
1639
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1640
        $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...
1641
        $texto = ! empty($this->entrega->getElementsByTagName("CEP")->item(0)->nodeValue) ?
1642
            $this->entrega->getElementsByTagName("CEP")->item(0)->nodeValue : '';
1643
        $texto = $this->formatField($texto, "#####-###");
1644
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1645
        $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...
1646
        //MUNICÍPIO
1647
        $w     = round($maxW * 0.805, 0);
1648
        $w1    = $w;
1649
        $y     += $h;
1650
        $x     = $oldX;
1651
        $texto = 'MUNICÍPIO';
1652
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1653
        $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...
1654
        $texto = $this->entrega->getElementsByTagName("xMun")->item(0)->nodeValue;
1655
        if (strtoupper(trim($texto)) == "EXTERIOR" && $this->entrega->getElementsByTagName("xPais")->length > 0) {
1656
            $texto .= " - " . $this->entrega->getElementsByTagName("xPais")->item(0)->nodeValue;
1657
        }
1658
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1659
        $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...
1660
        //UF
1661
        $x     += $w;
1662
        $w     = 8;
1663
        $texto = 'UF';
1664
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1665
        $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...
1666
        $texto = $this->entrega->getElementsByTagName("UF")->item(0)->nodeValue;
1667
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1668
        $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...
1669
        //FONE / FAX
1670
        $x     += $w;
1671
        $w     = $maxW - $w - $w1;
1672
        $texto = 'FONE / FAX';
1673
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1674
        $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...
1675
        $texto = ! empty($this->entrega->getElementsByTagName("fone")->item(0)->nodeValue) ?
1676
            $this->entrega->getElementsByTagName("fone")->item(0)->nodeValue : '';
1677
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1678
        $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...
1679
1680
        return ($y + $h);
1681
    } //fim da função localEntregaDANFE
1682
1683
    /**
1684
     * localretiradaDANFE
1685
     * Monta o campo com os dados do local de entrega na DANFE. (retrato e paisagem)
1686
     *
1687
     * @name   localretiradaDANFE
1688
     *
1689
     * @param number $x Posição horizontal canto esquerdo
1690
     * @param number $y Posição vertical canto superior
1691
     *
1692
     * @return number Posição vertical final
1693
     */
1694
    protected function localRetiradaDANFE($x = 0, $y = 0)
1695
    {
1696
        //####################################################################################
1697
        //LOCAL DE RETIRADA
1698
        $oldX = $x;
1699
        if ($this->orientacao == 'P') {
1700
            $maxW = $this->wPrint;
1701
        } else {
1702
            $maxW = $this->wPrint - $this->wCanhoto;
1703
        }
1704
        $w     = $maxW;
1705
        $h     = 7;
1706
        $texto = 'INFORMAÇÕES DO LOCAL DE RETIRADA';
1707
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1708
        $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...
1709
        //NOME / RAZÃO SOCIAL
1710
        $w     = round($maxW * 0.61, 0);
1711
        $w1    = $w;
1712
        $y     += 3;
1713
        $texto = 'NOME / RAZÃO SOCIAL';
1714
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1715
        $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...
1716
        $texto = '';
1717
        if ($this->retirada->getElementsByTagName("xNome")->item(0)) {
1718
            $texto = $this->retirada->getElementsByTagName("xNome")->item(0)->nodeValue;
1719
        }
1720
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1721
        if ($this->orientacao == 'P') {
1722
            $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...
1723
        } else {
1724
            $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...
1725
        }
1726
        //CNPJ / CPF
1727
        $x     += $w;
1728
        $w     = round($maxW * 0.23, 0);
1729
        $w2    = $w;
1730
        $texto = 'CNPJ / CPF';
1731
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1732
        $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...
1733
        //Pegando valor do CPF/CNPJ
1734
        if (! empty($this->retirada->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1735
            $texto = $this->formatField(
1736
                $this->retirada->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1737
                "###.###.###/####-##"
1738
            );
1739
        } else {
1740
            $texto = ! empty($this->retirada->getElementsByTagName("CPF")->item(0)->nodeValue) ?
1741
                $this->formatField(
1742
                    $this->retirada->getElementsByTagName("CPF")->item(0)->nodeValue,
1743
                    "###.###.###-##"
1744
                ) : '';
1745
        }
1746
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1747
        $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...
1748
        //INSCRIÇÃO ESTADUAL
1749
        $x     += $w;
1750
        $w     = $maxW - ($w1 + $w2);
1751
        $wx    = $w;
1752
        $texto = 'INSCRIÇÃO ESTADUAL';
1753
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1754
        $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...
1755
        $texto = '';
1756
        if ($this->retirada->getElementsByTagName("IE")->item(0)) {
1757
            $texto = $this->retirada->getElementsByTagName("IE")->item(0)->nodeValue;
1758
        }
1759
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1760
        if ($this->orientacao == 'P') {
1761
            $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...
1762
        } else {
1763
            $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...
1764
        }
1765
        //ENDEREÇO
1766
        $w     = round($maxW * 0.355, 0) + $wx;
1767
        $w1    = $w;
1768
        $y     += $h;
1769
        $x     = $oldX;
1770
        $texto = 'ENDEREÇO';
1771
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1772
        $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...
1773
        $texto = $this->retirada->getElementsByTagName("xLgr")->item(0)->nodeValue;
1774
        $texto .= ', ' . $this->retirada->getElementsByTagName("nro")->item(0)->nodeValue;
1775
        $texto .= $this->getTagValue($this->retirada, "xCpl", " - ");
1776
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1777
        $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...
1778
        //BAIRRO / DISTRITO
1779
        $x     += $w;
1780
        $w     = round($maxW * 0.335, 0);
1781
        $w2    = $w;
1782
        $texto = 'BAIRRO / DISTRITO';
1783
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1784
        $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...
1785
        $texto = $this->retirada->getElementsByTagName("xBairro")->item(0)->nodeValue;
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
        //CEP
1789
        $x     += $w;
1790
        $w     = $maxW - ($w1 + $w2);
1791
        $texto = 'CEP';
1792
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1793
        $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...
1794
        $texto = ! empty($this->retirada->getElementsByTagName("CEP")->item(0)->nodeValue) ?
1795
            $this->retirada->getElementsByTagName("CEP")->item(0)->nodeValue : '';
1796
        $texto = $this->formatField($texto, "#####-###");
1797
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1798
        $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...
1799
        //MUNICÍPIO
1800
        $w     = round($maxW * 0.805, 0);
1801
        $w1    = $w;
1802
        $y     += $h;
1803
        $x     = $oldX;
1804
        $texto = 'MUNICÍPIO';
1805
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1806
        $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...
1807
        $texto = $this->retirada->getElementsByTagName("xMun")->item(0)->nodeValue;
1808
        if (strtoupper(trim($texto)) == "EXTERIOR" && $this->retirada->getElementsByTagName("xPais")->length > 0) {
1809
            $texto .= " - " . $this->retirada->getElementsByTagName("xPais")->item(0)->nodeValue;
1810
        }
1811
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1812
        $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...
1813
        //UF
1814
        $x     += $w;
1815
        $w     = 8;
1816
        $texto = 'UF';
1817
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1818
        $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...
1819
        $texto = $this->retirada->getElementsByTagName("UF")->item(0)->nodeValue;
1820
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1821
        $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...
1822
        //FONE / FAX
1823
        $x     += $w;
1824
        $w     = $maxW - $w - $w1;
1825
        $texto = 'FONE / FAX';
1826
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1827
        $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...
1828
        $texto = ! empty($this->retirada->getElementsByTagName("fone")->item(0)->nodeValue) ?
1829
            $this->retirada->getElementsByTagName("fone")->item(0)->nodeValue : '';
1830
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1831
        $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...
1832
1833
        return ($y + $h);
1834
    } //fim da função localRetiradaDANFE
1835
1836
    /**
1837
     * getTextoFatura
1838
     * Gera a String do Texto da Fatura
1839
     *
1840
     * @name   getTextoFatura
1841
     * @return uma String com o texto ou "";
1842
     */
1843
    protected function getTextoFatura()
1844
    {
1845
        if (isset($this->cobr)) {
1846
            $fat = $this->cobr->getElementsByTagName("fat")->item(0);
1847
            if (isset($fat)) {
1848
                if (! empty($this->getTagValue($this->ide, "indPag"))) {
1849
                    $textoIndPag = "";
1850
                    $indPag      = $this->getTagValue($this->ide, "indPag");
1851
                    if ($indPag === "0") {
1852
                        $textoIndPag = "Pagamento à Vista - ";
1853
                    } elseif ($indPag === "1") {
1854
                        $textoIndPag = "Pagamento à Prazo - ";
1855
                    }
1856
                    $nFat  = $this->getTagValue($fat, "nFat", "Fatura: ");
1857
                    $vOrig = $this->getTagValue($fat, "vOrig", " Valor Original: ");
1858
                    $vDesc = $this->getTagValue($fat, "vDesc", " Desconto: ");
1859
                    $vLiq  = $this->getTagValue($fat, "vLiq", " Valor Líquido: ");
1860
                    $texto = $textoIndPag . $nFat . $vOrig . $vDesc . $vLiq;
1861
1862
                    return $texto;
1863
                } else {
1864
                    $pag = $this->dom->getElementsByTagName("pag");
1865
                    if ($tPag = $this->getTagValue($pag->item(0), "tPag")) {
1866
                        return $this->tipoPag($tPag);
1867
                    }
1868
                }
1869
            }
1870
        }
1871
        return "";
1872
    }
1873
1874
    /**
1875
     * sizeExtraTextoFatura
1876
     * Calcula o espaço ocupado pelo texto da fatura. Este espaço só é utilizado quando não houver duplicata.
1877
     *
1878
     * @name   sizeExtraTextoFatura
1879
     * @return integer
1880
     */
1881
    protected function sizeExtraTextoFatura()
1882
    {
1883
        $textoFatura = $this->getTextoFatura();
1884
        //verificar se existem duplicatas
1885
        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...
1886
            return 10;
1887
        }
1888
1889
        return 0;
1890
    }
1891
1892
    /**
1893
     * fatura
1894
     * Monta o campo de duplicatas da DANFE (retrato e paisagem)
1895
     *
1896
     * @name   fatura
1897
     *
1898
     * @param number $x Posição horizontal canto esquerdo
1899
     * @param number $y Posição vertical canto superior
1900
     *
1901
     * @return number Posição vertical final
1902
     */
1903
    protected function fatura($x, $y)
1904
    {
1905
        $linha       = 1;
1906
        $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...
1907
        $oldx        = $x;
1908
        $textoFatura = $this->getTextoFatura();
1909
        //verificar se existem duplicatas
1910
        if ($this->dup->length > 0 || $textoFatura !== "") {
1911
            //#####################################################################
1912
            //FATURA / DUPLICATA
1913
            $texto = "FATURA / DUPLICATA";
1914
            if ($this->orientacao == 'P') {
1915
                $w = $this->wPrint;
1916
            } else {
1917
                $w = 271;
1918
            }
1919
            $h     = 8;
1920
            $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1921
            $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...
1922
            $y       += 3;
1923
            $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...
1924
            $dupcont = 0;
1925
            $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...
1926
            if ($nFat > 7) {
1927
                $myH = 6;
1928
                $myW = $this->wPrint;
1929
                if ($this->orientacao == 'L') {
1930
                    $myW -= $this->wCanhoto;
1931
                }
1932
                $aFont = ['font' => $this->fontePadrao, 'size' => 9, 'style' => ''];
1933
                $texto = "Existem mais de 7 duplicatas registradas, portanto não "
1934
                    . "serão exibidas, confira diretamente pelo XML.";
1935
                $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...
1936
1937
                return ($y + $h - 3);
1938
            }
1939
            if ($textoFatura !== "" && $this->exibirTextoFatura) {
1940
                $myH = 6;
1941
                $myW = $this->wPrint;
1942
                if ($this->orientacao == 'L') {
1943
                    $myW -= $this->wCanhoto;
1944
                }
1945
                $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
1946
                $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...
1947
                $y += $myH + 1;
1948
            }
1949
            if ($this->orientacao == 'P') {
1950
                $w = round($this->wPrint / 7.018, 0) - 1;
1951
            } else {
1952
                $w = 28;
1953
            }
1954
            $increm = 1;
1955
            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...
1956
                $nDup  = ! empty($this->dup->item($k)->getElementsByTagName('nDup')->item(0)->nodeValue)
1957
                    ? $this->dup->item($k)->getElementsByTagName('nDup')->item(0)->nodeValue
1958
                    : '';
1959
                $dDup  = ! empty($this->dup->item($k)->getElementsByTagName('dVenc')->item(0)->nodeValue)
1960
                    ? $this->ymdTodmy($this->dup->item($k)->getElementsByTagName('dVenc')->item(0)->nodeValue)
1961
                    : '';
1962
                $vDup  = ! empty($this->dup->item($k)->getElementsByTagName('vDup')->item(0)->nodeValue)
1963
                    ? 'R$ ' . number_format(
1964
                        $this->dup->item($k)->getElementsByTagName('vDup')->item(0)->nodeValue,
1965
                        2,
1966
                        ",",
1967
                        "."
1968
                    )
1969
                    : '';
1970
                $h     = 8;
1971
                $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...
1972
                if ($nDup != '0' && $nDup != '') {
1973
                    $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1974
                    $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...
1975
                    $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1976
                    $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...
1977
                } else {
1978
                    $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1979
                    $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...
1980
                }
1981
                $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1982
                $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...
1983
                $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1984
                $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...
1985
                $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1986
                $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...
1987
                $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1988
                $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...
1989
                $x       += $w + $increm;
1990
                $dupcont += 1;
1991
                if ($this->orientacao == 'P') {
1992
                    $maxDupCont = 6;
1993
                } else {
1994
                    $maxDupCont = 8;
1995
                }
1996
                if ($dupcont > $maxDupCont) {
1997
                    $y       += 9;
1998
                    $x       = $oldx;
1999
                    $dupcont = 0;
2000
                    $linha   += 1;
2001
                }
2002
                if ($linha == 5) {
2003
                    $linha = 4;
2004
                    break;
2005
                }
2006
            }
2007
            if ($dupcont == 0) {
2008
                $y -= 9;
2009
                $linha --;
2010
            }
2011
2012
            return ($y + $h);
2013
        } else {
2014
            $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...
2015
2016
            return ($y - 2);
2017
        }
2018
    }
2019
2020
    /**
2021
     * pagamento
2022
     * Monta o campo de pagamentos da DANFE (retrato e paisagem) (foi baseada na fatura)
2023
     *
2024
     * @name   pagamento
2025
     *
2026
     * @param number $x Posição horizontal canto esquerdo
2027
     * @param number $y Posição vertical canto superior
2028
     *
2029
     * @return number Posição vertical final
2030
     */
2031
    protected function pagamento($x, $y)
2032
    {
2033
        $linha = 1;
2034
        $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...
2035
        $oldx  = $x;
2036
        //verificar se existem cobranças definidas
2037
        if (isset($this->detPag) && $this->detPag->length > 0) {
2038
            //#####################################################################
2039
            //Tipo de pagamento
2040
            $texto = "PAGAMENTO";
2041
            if ($this->orientacao == 'P') {
2042
                $w = $this->wPrint;
2043
            } else {
2044
                $w = 271;
2045
            }
2046
            $h     = 8;
2047
            $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2048
            $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...
2049
            $y       += 3;
2050
            $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...
2051
            $dupcont = 0;
2052
            if ($this->orientacao == 'P') {
2053
                $w = round($this->wPrint / 7.018, 0) - 1;
2054
            } else {
2055
                $w = 28;
2056
            }
2057
            if ($this->orientacao == 'P') {
2058
                $maxDupCont = 6;
2059
            } else {
2060
                $maxDupCont = 8;
2061
            }
2062
            $increm         = 1;
2063
            $formaPagamento = [
2064
                '01' => 'Dinheiro',
2065
                '02' => 'Cheque',
2066
                '03' => 'Cartão de Crédito',
2067
                '04' => 'Cartão de Débito',
2068
                '05' => 'Crédito Loja',
2069
                '10' => 'Vale Alimentação',
2070
                '11' => 'Vale Refeição',
2071
                '12' => 'Vale Presente',
2072
                '13' => 'Vale Combustível',
2073
                '14' => 'Duplicata Mercantil',
2074
                '15' => 'Boleto',
2075
                '16' => 'Depósito Bancário',
2076
                '17' => 'Pagamento Instantâneo (PIX)',
2077
                '18' => 'Transferência bancária, Carteira Digital',
2078
                '19' => 'Programa de fidelidade, Cashback, Crédito Virtual',
2079
                '90' => 'Sem pagamento',
2080
                '99' => 'Outros'
2081
            ];
2082
            $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...
2083
                '01' => 'Visa',
2084
                '02' => 'Mastercard',
2085
                '03' => 'American',
2086
                '04' => 'Sorocred',
2087
                '05' => 'Diners',
2088
                '06' => 'Elo',
2089
                '07' => 'Hipercard',
2090
                '08' => 'Aura',
2091
                '09' => 'Cabal',
2092
                '99' => 'Outros'
2093
            ];
2094
            foreach ($this->detPag as $k => $d) {
2095
                $fPag  = ! empty($this->detPag->item($k)->getElementsByTagName('tPag')->item(0)->nodeValue)
2096
                    ? $this->detPag->item($k)->getElementsByTagName('tPag')->item(0)->nodeValue
2097
                    : '0';
2098
                $vPag  = ! empty($this->detPag->item($k)->getElementsByTagName('vPag')->item(0)->nodeValue)
2099
                    ? 'R$ ' . number_format(
2100
                        $this->detPag->item($k)->getElementsByTagName('vPag')->item(0)->nodeValue,
2101
                        2,
2102
                        ",",
2103
                        "."
2104
                    )
2105
                    : '';
2106
                $h     = 6;
2107
                $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...
2108
                if (isset($formaPagamento[$fPag])) {
2109
                    /*Exibir Item sem pagamento*/
2110
                    if ($fPag == '90') {
2111
                        continue;
2112
                    }
2113
                    $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2114
                    $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...
2115
                    $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2116
                    $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...
2117
                } else {
2118
                    $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
2119
                    $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...
2120
                }
2121
                $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2122
                $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...
2123
                $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2124
                $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...
2125
                $x       += $w + $increm;
2126
                $dupcont += 1;
2127
2128
                if ($dupcont > $maxDupCont) {
2129
                    $y       += 9;
2130
                    $x       = $oldx;
2131
                    $dupcont = 0;
2132
                    $linha   += 1;
2133
                }
2134
                if ($linha == 5) {
2135
                    $linha = 4;
2136
                    break;
2137
                }
2138
            }
2139
            if ($dupcont == 0) {
2140
                $y -= 9;
2141
                $linha --;
2142
            }
2143
2144
            return ($y + $h);
2145
        } else {
2146
            $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...
2147
2148
            return ($y - 2);
2149
        }
2150
    } //fim da função pagamento
2151
2152
    /**
2153
     * impostoHelper
2154
     * Auxilia a montagem dos campos de impostos e totais da DANFE
2155
     *
2156
     * @name   impostoHelper
2157
     *
2158
     * @param float $x Posição horizontal canto esquerdo
2159
     * @param float $y Posição vertical canto superior
2160
     * @param float $w Largura do campo
2161
     * @param float $h Altura do campo
2162
     * @param float $h Título do campo
2163
     * @param float $h Valor do imposto
2164
     *
2165
     * @return float Sugestão do $x do próximo imposto
2166
     */
2167
    protected function impostoHelper($x, $y, $w, $h, $titulo, $campoImposto)
2168
    {
2169
        $valorImposto = '0,00';
2170
        $the_field    = $this->ICMSTot->getElementsByTagName($campoImposto)->item(0);
2171
        if (isset($the_field)) {
2172
            $the_value = $the_field->nodeValue;
2173
            if (! empty($the_value)) {
2174
                $valorImposto = number_format($the_value, 2, ",", ".");
2175
            }
2176
        }
2177
2178
        $fontTitulo = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2179
        $fontValor  = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2180
        $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...
2181
        $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...
2182
2183
        $next_x = $x + $w;
2184
2185
        return $next_x;
2186
    }
2187
2188
    /**
2189
     * imposto
2190
     * Monta o campo de impostos e totais da DANFE (retrato e paisagem)
2191
     *
2192
     * @param number $x Posição horizontal canto esquerdo
2193
     * @param number $y Posição vertical canto superior
2194
     *
2195
     * @return number Posição vertical final
2196
     */
2197
    protected function imposto($x, $y)
2198
    {
2199
        $x_inicial = $x;
2200
        //#####################################################################
2201
        $campos_por_linha = 9;
2202
        if (! $this->exibirPIS) {
2203
            $campos_por_linha --;
2204
        }
2205
        if (! $this->exibirIcmsInterestadual) {
2206
            $campos_por_linha -= 2;
2207
        }
2208
2209
        if ($this->orientacao == 'P') {
2210
            $maxW       = $this->wPrint;
2211
            $title_size = 31;
2212
        } else {
2213
            $maxW       = $this->wPrint - $this->wCanhoto;
2214
            $title_size = 40;
2215
        }
2216
        $w = $maxW / $campos_por_linha;
2217
2218
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2219
        $texto = "CÁLCULO DO IMPOSTO";
2220
        $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...
2221
        $y += 3;
2222
        $h = 7;
2223
2224
        $x = $this->impostoHelper($x, $y, $w, $h, "BASE DE CÁLC. DO ICMS", "vBC");
2225
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO ICMS", "vICMS");
2226
        $x = $this->impostoHelper($x, $y, $w, $h, "BASE DE CÁLC. ICMS S.T.", "vBCST");
2227
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO ICMS SUBST.", "vST");
2228
        $x = $this->impostoHelper($x, $y, $w, $h, "V. IMP. IMPORTAÇÃO", "vII");
2229
2230
        if ($this->exibirIcmsInterestadual) {
2231
            $x = $this->impostoHelper($x, $y, $w, $h, "V. ICMS UF REMET.", "vICMSUFRemet");
2232
            $x = $this->impostoHelper($x, $y, $w, $h, "V. FCP UF DEST.", "vFCPUFDest");
2233
        }
2234
2235
        if ($this->exibirPIS) {
2236
            $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO PIS", "vPIS");
2237
        }
2238
2239
        $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...
2240
2241
        //
2242
2243
        $y += $h;
2244
        $x = $x_inicial;
2245
2246
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO FRETE", "vFrete");
2247
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO SEGURO", "vSeg");
2248
        $x = $this->impostoHelper($x, $y, $w, $h, "DESCONTO", "vDesc");
2249
        $x = $this->impostoHelper($x, $y, $w, $h, "OUTRAS DESPESAS", "vOutro");
2250
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR TOTAL IPI", "vIPI");
2251
2252
        if ($this->exibirIcmsInterestadual) {
2253
            $x = $this->impostoHelper($x, $y, $w, $h, "V. ICMS UF DEST.", "vICMSUFDest");
2254
            $x = $this->impostoHelper($x, $y, $w, $h, "V. TOT. TRIB.", "vTotTrib");
2255
        }
2256
        if ($this->exibirPIS) {
2257
            $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DA COFINS", "vCOFINS");
2258
        }
2259
        $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...
2260
2261
        return ($y + $h);
2262
    } //fim imposto
2263
2264
    /**
2265
     * transporte
2266
     * Monta o campo de transportes da DANFE (retrato e paisagem)
2267
     *
2268
     * @name   transporte
2269
     *
2270
     * @param float $x Posição horizontal canto esquerdo
2271
     * @param float $y Posição vertical canto superior
2272
     *
2273
     * @return float Posição vertical final
2274
     */
2275
    protected function transporte($x, $y)
2276
    {
2277
        $oldX = $x;
2278
        if ($this->orientacao == 'P') {
2279
            $maxW = $this->wPrint;
2280
        } else {
2281
            $maxW = $this->wPrint - $this->wCanhoto;
2282
        }
2283
        //#####################################################################
2284
        //TRANSPORTADOR / VOLUMES TRANSPORTADOS
2285
        $texto = "TRANSPORTADOR / VOLUMES TRANSPORTADOS";
2286
        $w     = $maxW;
2287
        $h     = 7;
2288
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2289
        $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...
2290
        //NOME / RAZÃO SOCIAL
2291
        $w1    = $maxW * 0.29;
2292
        $y     += 3;
2293
        $texto = 'NOME / RAZÃO SOCIAL';
2294
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2295
        $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...
2296
        if (isset($this->transporta)) {
2297
            $texto = ! empty($this->transporta->getElementsByTagName("xNome")->item(0)->nodeValue)
2298
                ? $this->transporta->getElementsByTagName("xNome")->item(0)->nodeValue
2299
                : '';
2300
        } else {
2301
            $texto = '';
2302
        }
2303
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2304
        $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...
2305
        //FRETE POR CONTA
2306
        $x     += $w1;
2307
        $w2    = $maxW * 0.15;
2308
        $texto = 'FRETE';
2309
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2310
        $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...
2311
        $tipoFrete = ! empty($this->transp->getElementsByTagName("modFrete")->item(0)->nodeValue)
2312
            ? $this->transp->getElementsByTagName("modFrete")->item(0)->nodeValue
2313
            : '0';
2314
        switch ($tipoFrete) {
2315
            case 0:
2316
                $texto = "0-Por conta do Rem";
2317
                break;
2318
            case 1:
2319
                $texto = "1-Por conta do Dest";
2320
                break;
2321
            case 2:
2322
                $texto = "2-Por conta de Terceiros";
2323
                break;
2324
            case 3:
2325
                $texto = "3-Próprio por conta do Rem";
2326
                break;
2327
            case 4:
2328
                $texto = "4-Próprio por conta do Dest";
2329
                break;
2330
            case 9:
2331
                $texto = "9-Sem Transporte";
2332
                break;
2333
        }
2334
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2335
        $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...
2336
        //CÓDIGO ANTT
2337
        $x     += $w2;
2338
        $texto = 'CÓDIGO ANTT';
2339
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2340
        $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...
2341
        if (isset($this->veicTransp)) {
2342
            $texto = ! empty($this->veicTransp->getElementsByTagName("RNTC")->item(0)->nodeValue)
2343
                ? $this->veicTransp->getElementsByTagName("RNTC")->item(0)->nodeValue
2344
                : '';
2345
        } else {
2346
            $texto = '';
2347
        }
2348
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2349
        $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...
2350
        //PLACA DO VEÍC
2351
        $x     += $w2;
2352
        $texto = 'PLACA DO VEÍCULO';
2353
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2354
        $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...
2355
        if (isset($this->veicTransp)) {
2356
            $texto = ! empty($this->veicTransp->getElementsByTagName("placa")->item(0)->nodeValue)
2357
                ? $this->veicTransp->getElementsByTagName("placa")->item(0)->nodeValue
2358
                : '';
2359
        } elseif (isset($this->reboque)) {
2360
            $texto = ! empty($this->reboque->getElementsByTagName("placa")->item(0)->nodeValue)
2361
                ? $this->reboque->getElementsByTagName("placa")->item(0)->nodeValue
2362
                : '';
2363
        } else {
2364
            $texto = '';
2365
        }
2366
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2367
        $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...
2368
        //UF
2369
        $x     += $w2;
2370
        $w3    = round($maxW * 0.04, 0);
2371
        $texto = 'UF';
2372
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2373
        $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...
2374
        if (isset($this->veicTransp)) {
2375
            $texto = ! empty($this->veicTransp->getElementsByTagName("UF")->item(0)->nodeValue)
2376
                ? $this->veicTransp->getElementsByTagName("UF")->item(0)->nodeValue
2377
                : '';
2378
        } elseif (isset($this->reboque)) {
2379
            $texto = ! empty($this->reboque->getElementsByTagName("UF")->item(0)->nodeValue)
2380
                ? $this->reboque->getElementsByTagName("UF")->item(0)->nodeValue
2381
                : '';
2382
        } else {
2383
            $texto = '';
2384
        }
2385
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2386
        $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...
2387
        //CNPJ / CPF
2388
        $x     += $w3;
2389
        $w     = $maxW - ($w1 + 3 * $w2 + $w3);
2390
        $texto = 'CNPJ / CPF';
2391
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2392
        $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...
2393
        if (isset($this->transporta)) {
2394
            $texto = ! empty($this->transporta->getElementsByTagName("CNPJ")->item(0)->nodeValue)
2395
                ? $this->formatField(
2396
                    $this->transporta->getElementsByTagName("CNPJ")->item(0)->nodeValue,
2397
                    "##.###.###/####-##"
2398
                )
2399
                : '';
2400
            if ($texto == '') {
2401
                $texto = ! empty($this->transporta->getElementsByTagName("CPF")->item(0)->nodeValue)
2402
                    ? $this->formatField(
2403
                        $this->transporta->getElementsByTagName("CPF")->item(0)->nodeValue,
2404
                        "###.###.###-##"
2405
                    )
2406
                    : '';
2407
            }
2408
        } else {
2409
            $texto = '';
2410
        }
2411
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2412
        $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...
2413
        //#####################################################################
2414
        //ENDEREÇO
2415
        $y     += $h;
2416
        $x     = $oldX;
2417
        $h     = 7;
2418
        $w1    = $maxW * 0.44;
2419
        $texto = 'ENDEREÇO';
2420
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2421
        $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...
2422
        if (isset($this->transporta)) {
2423
            $texto = ! empty($this->transporta->getElementsByTagName("xEnder")->item(0)->nodeValue)
2424
                ? $this->transporta->getElementsByTagName("xEnder")->item(0)->nodeValue
2425
                : '';
2426
        } else {
2427
            $texto = '';
2428
        }
2429
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2430
        $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...
2431
        //MUNICÍPIO
2432
        $x     += $w1;
2433
        $w2    = round($maxW * 0.30, 0);
2434
        $texto = 'MUNICÍPIO';
2435
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2436
        $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...
2437
        if (isset($this->transporta)) {
2438
            $texto = ! empty($this->transporta->getElementsByTagName("xMun")->item(0)->nodeValue)
2439
                ? $this->transporta->getElementsByTagName("xMun")->item(0)->nodeValue
2440
                : '';
2441
        } else {
2442
            $texto = '';
2443
        }
2444
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2445
        $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...
2446
        //UF
2447
        $x     += $w2;
2448
        $w3    = round($maxW * 0.04, 0);
2449
        $texto = 'UF';
2450
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2451
        $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...
2452
        if (isset($this->transporta)) {
2453
            $texto = ! empty($this->transporta->getElementsByTagName("UF")->item(0)->nodeValue)
2454
                ? $this->transporta->getElementsByTagName("UF")->item(0)->nodeValue
2455
                : '';
2456
        } else {
2457
            $texto = '';
2458
        }
2459
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2460
        $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...
2461
        //INSCRIÇÃO ESTADUAL
2462
        $x     += $w3;
2463
        $w     = $maxW - ($w1 + $w2 + $w3);
2464
        $texto = 'INSCRIÇÃO ESTADUAL';
2465
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2466
        $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...
2467
        $texto = '';
2468
        if (isset($this->transporta)) {
2469
            if (! empty($this->transporta->getElementsByTagName("IE")->item(0)->nodeValue)) {
2470
                $texto = $this->transporta->getElementsByTagName("IE")->item(0)->nodeValue;
2471
            }
2472
        }
2473
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2474
        $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...
2475
        //Tratar Multiplos volumes
2476
        $volumes     = $this->transp->getElementsByTagName('vol');
2477
        $quantidade  = 0;
2478
        $especie     = '';
2479
        $marca       = '';
2480
        $numero      = '';
2481
        $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...
2482
        $pesoBruto   = 0;
2483
        $pesoLiquido = 0;
2484
        foreach ($volumes as $volume) {
2485
            $quantidade  += ! empty($volume->getElementsByTagName("qVol")->item(0)->nodeValue) ?
2486
                $volume->getElementsByTagName("qVol")->item(0)->nodeValue : 0;
2487
            $pesoBruto   += ! empty($volume->getElementsByTagName("pesoB")->item(0)->nodeValue) ?
2488
                $volume->getElementsByTagName("pesoB")->item(0)->nodeValue : 0;
2489
            $pesoLiquido += ! empty($volume->getElementsByTagName("pesoL")->item(0)->nodeValue) ?
2490
                $volume->getElementsByTagName("pesoL")->item(0)->nodeValue : 0;
2491
            $texto       = ! empty($this->transp->getElementsByTagName("esp")->item(0)->nodeValue) ?
2492
                $this->transp->getElementsByTagName("esp")->item(0)->nodeValue : '';
2493
            if ($texto != $especie && $especie != '') {
2494
                //tem várias especies
2495
                $especie = 'VARIAS';
2496
            } else {
2497
                $especie = $texto;
2498
            }
2499
            $texto = ! empty($this->transp->getElementsByTagName("marca")->item(0)->nodeValue)
2500
                ? $this->transp->getElementsByTagName("marca")->item(0)->nodeValue
2501
                : '';
2502
            if ($texto != $marca && $marca != '') {
2503
                //tem várias especies
2504
                $marca = 'VARIAS';
2505
            } else {
2506
                $marca = $texto;
2507
            }
2508
            $texto = ! empty($this->transp->getElementsByTagName("nVol")->item(0)->nodeValue)
2509
                ? $this->transp->getElementsByTagName("nVol")->item(0)->nodeValue
2510
                : '';
2511
            if ($texto != $numero && $numero != '') {
2512
                //tem várias especies
2513
                $numero = 'VARIOS';
2514
            } else {
2515
                $numero = $texto;
2516
            }
2517
        }
2518
2519
        //#####################################################################
2520
        //QUANTIDADE
2521
        $y     += $h;
2522
        $x     = $oldX;
2523
        $h     = 7;
2524
        $w1    = round($maxW * 0.10, 0);
2525
        $texto = 'QUANTIDADE';
2526
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2527
        $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...
2528
        if (! empty($quantidade)) {
2529
            $texto = $quantidade;
2530
            $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2531
            $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...
2532
        }
2533
        //ESPÉCIE
2534
        $x     += $w1;
2535
        $w2    = round($maxW * 0.17, 0);
2536
        $texto = 'ESPÉCIE';
2537
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2538
        $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...
2539
        $texto = $especie;
2540
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2541
        $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...
2542
        //MARCA
2543
        $x     += $w2;
2544
        $texto = 'MARCA';
2545
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2546
        $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...
2547
        $texto = ! empty($this->transp->getElementsByTagName("marca")->item(0)->nodeValue) ?
2548
            $this->transp->getElementsByTagName("marca")->item(0)->nodeValue : '';
2549
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2550
        $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...
2551
        //NUMERAÇÃO
2552
        $x     += $w2;
2553
        $texto = 'NUMERAÇÃO';
2554
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2555
        $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...
2556
        $texto = $numero;
2557
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2558
        $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...
2559
        //PESO BRUTO
2560
        $x     += $w2;
2561
        $w3    = round($maxW * 0.20, 0);
2562
        $texto = 'PESO BRUTO';
2563
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2564
        $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...
2565
        if (is_numeric($pesoBruto) && $pesoBruto > 0) {
2566
            $texto = number_format($pesoBruto, 3, ",", ".");
2567
        } else {
2568
            $texto = '';
2569
        }
2570
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2571
        $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...
2572
        //PESO LÍQUIDO
2573
        $x     += $w3;
2574
        $w     = $maxW - ($w1 + 3 * $w2 + $w3);
2575
        $texto = 'PESO LÍQUIDO';
2576
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2577
        $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...
2578
        if (is_numeric($pesoLiquido) && $pesoLiquido > 0) {
2579
            $texto = number_format($pesoLiquido, 3, ",", ".");
2580
        } else {
2581
            $texto = '';
2582
        }
2583
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2584
        $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...
2585
2586
        return ($y + $h);
2587
    } //fim transporte
2588
2589
2590
    protected function descricaoProdutoHelper($origem, $campo, $formato)
2591
    {
2592
        $valor_original = $origem->getElementsByTagName($campo)->item(0);
2593
        if (! isset($valor_original)) {
2594
            return "";
2595
        }
2596
        $valor_original = $valor_original->nodeValue;
2597
        $valor          = ! empty($valor_original) ? number_format($valor_original, 2, ",", ".") : '';
2598
2599
        if ($valor != "") {
2600
            return sprintf($formato, $valor);
2601
        }
2602
2603
        return "";
2604
    }
2605
2606
    /**
2607
     * descricaoProduto
2608
     * Monta a string de descrição de cada Produto
2609
     *
2610
     * @name   descricaoProduto
2611
     *
2612
     * @param DOMNode itemProd
2613
     *
2614
     * @return string descricao do produto
2615
     */
2616
    protected function descricaoProduto($itemProd)
2617
    {
2618
        $prod       = $itemProd->getElementsByTagName('prod')->item(0);
2619
        $ICMS       = $itemProd->getElementsByTagName("ICMS")->item(0);
2620
        $ICMSUFDest = $itemProd->getElementsByTagName("ICMSUFDest")->item(0);
2621
        $impostos   = '';
2622
2623
        if (! empty($ICMS)) {
2624
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vBCFCP", " BcFcp=%s");
2625
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pFCP", " pFcp=%s%%");
2626
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vFCP", " vFcp=%s");
2627
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pRedBC", " pRedBC=%s%%");
2628
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pMVAST", " IVA/MVA=%s%%");
2629
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pICMSST", " pIcmsSt=%s%%");
2630
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vBCST", " BcIcmsSt=%s");
2631
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vICMSST", " vIcmsSt=%s");
2632
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vBCFCPST", " BcFcpSt=%s");
2633
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pFCPST", " pFcpSt=%s%%");
2634
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vFCPST", " vFcpSt=%s");
2635
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vBCSTRet", " Retido na compra: BASE ICMS ST=%s");
2636
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pST", " pSt=%s");
2637
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vICMSSTRet", " VALOR ICMS ST=%s");
2638
        }
2639
        if (! empty($ICMSUFDest)) {
2640
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "pFCPUFDest", " pFCPUFDest=%s%%");
2641
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "pICMSUFDest", " pICMSUFDest=%s%%");
2642
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "pICMSInterPart", " pICMSInterPart=%s%%");
2643
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "vFCPUFDest", " vFCPUFDest=%s");
2644
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "vICMSUFDest", " vICMSUFDest=%s");
2645
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "vICMSUFRemet", " vICMSUFRemet=%s");
2646
        }
2647
        $infAdProd = ! empty($itemProd->getElementsByTagName('infAdProd')->item(0)->nodeValue)
2648
            ? substr(
2649
                $this->anfaveaDANFE($itemProd->getElementsByTagName('infAdProd')->item(0)->nodeValue),
2650
                0,
2651
                500
2652
            )
2653
            : '';
2654
        if (! empty($infAdProd)) {
2655
            $infAdProd = trim($infAdProd);
2656
            $infAdProd .= ' ';
2657
        }
2658
        $loteTxt = '';
2659
        $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...
2660
        if (! empty($prod->getElementsByTagName("rastro"))) {
2661
            $rastro = $prod->getElementsByTagName("rastro");
2662
            $i      = 0;
2663
            while ($i < $rastro->length) {
2664
                $dFab = $this->getTagDate($rastro->item($i), 'dFab');
2665
                $dt = \DateTime::createFromFormat('Y-m-d', $dFab);
2666
                $datafab = " Fab: " . $dt->format('d/m/Y');
2667
                $dVal = $this->getTagDate($rastro->item($i), 'dVal');
2668
                $dt = \DateTime::createFromFormat('Y-m-d', $dVal);
2669
                $dataval = " Val: " . $dt->format('m/Y');
2670
                
2671
                $loteTxt .= $this->getTagValue($rastro->item($i), 'nLote', ' Lote: ');
2672
                $loteTxt .= $this->getTagValue($rastro->item($i), 'qLote', ' Quant: ');
2673
                $loteTxt .= $datafab; //$this->getTagDate($rastro->item($i), 'dFab', ' Fab: ');
2674
                $loteTxt .= $dataval; //$this->getTagDate($rastro->item($i), 'dVal', ' Val: ');
2675
                $loteTxt .= $this->getTagValue($rastro->item($i), 'vPMC', ' PMC: ');
2676
                $i ++;
2677
            }
2678
            if ($loteTxt != '') {
2679
                $loteTxt .= ' ';
2680
            }
2681
        }
2682
        //NT2013.006 FCI
2683
        $nFCI   = (! empty($itemProd->getElementsByTagName('nFCI')->item(0)->nodeValue)) ?
2684
            ' FCI:' . $itemProd->getElementsByTagName('nFCI')->item(0)->nodeValue : '';
2685
        $tmp_ad = $infAdProd . ($this->descProdInfoComplemento ? $loteTxt . $impostos . $nFCI : '');
2686
        $texto  = $prod->getElementsByTagName("xProd")->item(0)->nodeValue
2687
            . (strlen($tmp_ad) != 0 ? "\n    " . $tmp_ad : '');
2688
        //decodifica os caracteres html no xml
2689
        $texto = html_entity_decode($texto);
2690
        if ($this->descProdQuebraLinha) {
2691
            $texto = str_replace(";", "\n", $texto);
2692
        }
2693
2694
        return $texto;
2695
    }
2696
2697
    /**
2698
     * itens
2699
     * Monta o campo de itens da DANFE (retrato e paisagem)
2700
     *
2701
     * @name   itens
2702
     *
2703
     * @param float $x       Posição horizontal canto esquerdo
2704
     * @param float $y       Posição vertical canto superior
2705
     * @param float $nInicio Número do item inicial
2706
     * @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...
2707
     * @param float $hmax    Altura máxima do campo de itens em mm
2708
     *
2709
     * @return float Posição vertical final
2710
     */
2711
    protected function itens($x, $y, &$nInicio, $hmax, $pag = 0, $totpag = 0, $hCabecItens = 7)
2712
    {
2713
        $oldX = $x;
2714
        $oldY = $y;
2715
        $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...
2716
        //#####################################################################
2717
        //DADOS DOS PRODUTOS / SERVIÇOS
2718
        $texto = "DADOS DOS PRODUTOS / SERVIÇOS";
2719
        if ($this->orientacao == 'P') {
2720
            $w = $this->wPrint;
2721
        } else {
2722
            if ($nInicio < 2) { // primeira página
2723
                $w = $this->wPrint - $this->wCanhoto;
2724
            } else { // páginas seguintes
2725
                $w = $this->wPrint;
2726
            }
2727
        }
2728
        $h     = 4;
2729
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2730
        $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...
2731
        $y += 3;
2732
        //desenha a caixa dos dados dos itens da NF
2733
        $hmax  += 1;
2734
        $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...
2735
        $this->pdf->textBox($x, $y, $w, $hmax);
2736
        //##################################################################################
2737
        // cabecalho LOOP COM OS DADOS DOS PRODUTOS
2738
        //CÓDIGO PRODUTO
2739
        $texto = "CÓDIGO PRODUTO";
2740
        $w1    = round($w * 0.09, 0);
2741
        $h     = 4;
2742
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2743
        $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...
2744
        $this->pdf->line($x + $w1, $y, $x + $w1, $y + $hmax);
2745
        //DESCRIÇÃO DO PRODUTO / SERVIÇO
2746
        $x     += $w1;
2747
        $w2    = round($w * 0.25, 0);
2748
        $texto = 'DESCRIÇÃO DO PRODUTO / SERVIÇO';
2749
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2750
        $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...
2751
        $this->pdf->line($x + $w2, $y, $x + $w2, $y + $hmax);
2752
        //NCM/SH
2753
        $x     += $w2;
2754
        $w3    = round($w * 0.06, 0);
2755
        $texto = 'NCM/SH';
2756
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2757
        $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...
2758
        $this->pdf->line($x + $w3, $y, $x + $w3, $y + $hmax);
2759
        //O/CST ou O/CSOSN
2760
        $x     += $w3;
2761
        $w4    = round($w * 0.05, 0);
2762
        $texto = 'O/CST'; // CRT = 2 ou CRT = 3
2763
        if ($this->getTagValue($this->emit, 'CRT') == '1') {
2764
            $texto = 'O/CSOSN';//Regime do Simples CRT = 1
2765
        }
2766
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2767
        $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...
2768
        $this->pdf->line($x + $w4, $y, $x + $w4, $y + $hmax);
2769
        //CFOP
2770
        $x     += $w4;
2771
        $w5    = round($w * 0.04, 0);
2772
        $texto = 'CFOP';
2773
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2774
        $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...
2775
        $this->pdf->line($x + $w5, $y, $x + $w5, $y + $hmax);
2776
        //UN
2777
        $x     += $w5;
2778
        $w6    = round($w * 0.03, 0);
2779
        $texto = 'UN';
2780
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2781
        $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...
2782
        $this->pdf->line($x + $w6, $y, $x + $w6, $y + $hmax);
2783
        //QUANT
2784
        $x     += $w6;
2785
        $w7    = round($w * 0.08, 0);
2786
        $texto = 'QUANT';
2787
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2788
        $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...
2789
        $this->pdf->line($x + $w7, $y, $x + $w7, $y + $hmax);
2790
        //VALOR UNIT
2791
        $x     += $w7;
2792
        $w8    = round($w * 0.06, 0);
2793
        $texto = 'VALOR UNIT';
2794
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2795
        $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...
2796
        $this->pdf->line($x + $w8, $y, $x + $w8, $y + $hmax);
2797
        //VALOR TOTAL
2798
        $x     += $w8;
2799
        $w9    = round($w * 0.06, 0);
2800
        $texto = 'VALOR TOTAL';
2801
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2802
        $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...
2803
        $this->pdf->line($x + $w9, $y, $x + $w9, $y + $hmax);
2804
        //VALOR DESCONTO
2805
        $x     += $w9;
2806
        $w10   = round($w * 0.05, 0);
2807
        $texto = 'VALOR DESC';
2808
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2809
        $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...
2810
        $this->pdf->line($x + $w10, $y, $x + $w10, $y + $hmax);
2811
        //B.CÁLC ICMS
2812
        $x     += $w10;
2813
        $w11   = round($w * 0.06, 0);
2814
        $texto = 'B.CÁLC ICMS';
2815
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2816
        $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...
2817
        $this->pdf->line($x + $w11, $y, $x + $w11, $y + $hmax);
2818
        //VALOR ICMS
2819
        $x     += $w11;
2820
        $w12   = round($w * 0.06, 0);
2821
        $texto = 'VALOR ICMS';
2822
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2823
        $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...
2824
        $this->pdf->line($x + $w12, $y, $x + $w12, $y + $hmax);
2825
        //VALOR IPI
2826
        $x     += $w12;
2827
        $w13   = round($w * 0.05, 0);
2828
        $texto = 'VALOR IPI';
2829
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2830
        $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...
2831
        $this->pdf->line($x + $w13, $y, $x + $w13, $y + $hmax);
2832
        //ALÍQ. ICMS
2833
        $x     += $w13;
2834
        $w14   = round($w * 0.04, 0);
2835
        $texto = 'ALÍQ. ICMS';
2836
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2837
        $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...
2838
        $this->pdf->line($x + $w14, $y, $x + $w14, $y + $hmax);
2839
        //ALÍQ. IPI
2840
        $x     += $w14;
2841
        $w15   = $w - ($w1 + $w2 + $w3 + $w4 + $w5 + $w6 + $w7 + $w8 + $w9 + $w10 + $w11 + $w12 + $w13 + $w14);
2842
        $texto = 'ALÍQ. IPI';
2843
        $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...
2844
        $this->pdf->line($oldX, $y + $h + 1, $oldX + $w, $y + $h + 1);
2845
        $y += 5;
2846
        //##################################################################################
2847
        // LOOP COM OS DADOS DOS PRODUTOS
2848
        $i      = 0;
2849
        $hUsado = $hCabecItens;
2850
        $aFont  = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
2851
2852
        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...
2853
            if ($i >= $nInicio) {
2854
                $thisItem = $this->det->item($i);
2855
                //carrega as tags do item
2856
                $prod         = $thisItem->getElementsByTagName("prod")->item(0);
2857
                $imposto      = $this->det->item($i)->getElementsByTagName("imposto")->item(0);
2858
                $ICMS         = $imposto->getElementsByTagName("ICMS")->item(0);
2859
                $IPI          = $imposto->getElementsByTagName("IPI")->item(0);
2860
                $textoProduto = $this->descricaoProduto($thisItem);
2861
2862
2863
                // Posição y dos dados das unidades tributaveis.
2864
                $yTrib = $this->pdf->fontSize + .5;
2865
2866
                $uCom = $prod->getElementsByTagName("uCom")->item(0)->nodeValue;
2867
                $vUnCom = $prod->getElementsByTagName("vUnCom")->item(0)->nodeValue;
2868
                $uTrib = $prod->getElementsByTagName("uTrib")->item(0);
2869
                $qTrib = $prod->getElementsByTagName("qTrib")->item(0);
2870
                $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...
2871
                $vUnTrib = !empty($prod->getElementsByTagName("vUnTrib")->item(0)->nodeValue)
2872
                    ? $prod->getElementsByTagName("vUnTrib")->item(0)->nodeValue
2873
                    : 0;
2874
                // A Configuração serve para informar se irá exibir
2875
                //   de forma obrigatória, estando diferente ou não,
2876
                //   a unidade de medida tributária.
2877
                // ========
2878
                // A Exibição será realizada sempre que a unidade comercial for
2879
                //   diferente da unidade de medida tributária.
2880
                // "Nas situações em que o valor unitário comercial for diferente do valor unitário tributável,
2881
                //   ambas as informações deverão estar expressas e identificadas no DANFE, podendo ser
2882
                //   utilizada uma das linhas adicionais previstas, ou o campo de informações adicionais."
2883
                // > Manual Integração - Contribuinte 4.01 - NT2009.006, Item 7.1.5, página 91.
2884
                $mostrarUnidadeTributavel = (
2885
                    !empty($uTrib)
2886
                    && !empty($qTrib)
2887
                    && number_format($vUnCom, 2, ',', '') !== number_format($vUnTrib, 2, ',', '')
2888
                );
2889
2890
                // Informação sobre unidade de medida tributavel.
2891
                // Se não for para exibir a unidade de medida tributavel, então
2892
                // A Escrita irá começar em 0.
2893
                if (! $mostrarUnidadeTributavel) {
2894
                    $yTrib = 0;
2895
                }
2896
                $h = $this->calculeHeight($thisItem, $mostrarUnidadeTributavel);
2897
                $hUsado += $h;
2898
2899
                $yTrib += $y;
2900
                $diffH = $hmax - $hUsado;
2901
2902
                if ($pag != $totpag) {
2903
                    if (1 > $diffH && $i < $totItens) {
2904
                        //ultrapassa a capacidade para uma única página
2905
                        //o restante dos dados serão usados nas proximas paginas
2906
                        $nInicio = $i;
2907
                        break;
2908
                    }
2909
                }
2910
                $y_linha = $y + $h;
2911
                // linha entre itens
2912
                $this->pdf->dashedHLine($oldX, $y_linha, $w, 0.1, 120);
2913
                //corrige o x
2914
                $x = $oldX;
2915
                //codigo do produto
2916
                $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...
2917
                $texto = $prod->getElementsByTagName("cProd")->item(0)->nodeValue;
2918
                $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...
2919
                $x += $w1;
2920
                //DESCRIÇÃO
2921
                if ($this->orientacao == 'P') {
2922
                    $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...
2923
                } else {
2924
                    $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...
2925
                }
2926
                $x += $w2;
2927
                //NCM
2928
                $texto = ! empty($prod->getElementsByTagName("NCM")->item(0)->nodeValue) ?
2929
                    $prod->getElementsByTagName("NCM")->item(0)->nodeValue : '';
2930
                $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...
2931
                $x += $w3;
2932
                //CST
2933
                if (isset($ICMS)) {
2934
                    $origem = $this->getTagValue($ICMS, "orig");
2935
                    $cst    = $this->getTagValue($ICMS, "CST");
2936
                    $csosn  = $this->getTagValue($ICMS, "CSOSN");
2937
                    $texto  = $origem . $cst . $csosn;
2938
                    $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...
2939
                }
2940
                //CFOP
2941
                $x     += $w4;
2942
                $texto = $prod->getElementsByTagName("CFOP")->item(0)->nodeValue;
2943
                $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...
2944
                //Unidade
2945
                $x     += $w5;
2946
                $texto = $uCom;
2947
                $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...
2948
                //Unidade de medida tributável
2949
                $qTrib = $prod->getElementsByTagName("qTrib")->item(0)->nodeValue;
0 ignored issues
show
Unused Code introduced by
$qTrib 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...
2950
                if ($mostrarUnidadeTributavel) {
2951
                    $texto = $uTrib->nodeValue;
2952
                    $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...
2953
                }
2954
                $x += $w6;
2955
                if ($this->orientacao == 'P') {
2956
                    $alinhamento = 'R';
2957
                } else {
2958
                    $alinhamento = 'R';
2959
                }
2960
                // QTDADE
2961
                $qCom  = $prod->getElementsByTagName("qCom")->item(0);
2962
                $texto = number_format($qCom->nodeValue, $this->qComCasasDec, ",", ".");
2963
                $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...
2964
                // QTDADE Tributável
2965
                if ($mostrarUnidadeTributavel) {
2966
                    $qTrib = $prod->getElementsByTagName("qTrib")->item(0);
2967
                    if (! empty($qTrib)) {
2968
                        $texto = number_format($qTrib->nodeValue, $this->qComCasasDec, ",", ".");
2969
                        $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...
2970
                    }
2971
                }
2972
                $x += $w7;
2973
                // Valor Unitário
2974
                $vUnCom = $prod->getElementsByTagName("vUnCom")->item(0);
2975
                $texto  = number_format($vUnCom->nodeValue, $this->vUnComCasasDec, ",", ".");
2976
                $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...
2977
                // Valor Unitário Tributável
2978
                if ($mostrarUnidadeTributavel) {
2979
                    $vUnTrib = $prod->getElementsByTagName("vUnTrib")->item(0);
2980
                    if (! empty($vUnTrib)) {
2981
                        $texto = number_format($vUnTrib->nodeValue, $this->vUnComCasasDec, ",", ".");
2982
                        $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...
2983
                    }
2984
                }
2985
                $x += $w8;
2986
                // Valor do Produto
2987
                $texto = "";
2988
                if (is_numeric($prod->getElementsByTagName("vProd")->item(0)->nodeValue)) {
2989
                    $texto = number_format($prod->getElementsByTagName("vProd")->item(0)->nodeValue, 2, ",", ".");
2990
                }
2991
                $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...
2992
                $x += $w9;
2993
                //Valor do Desconto
2994
                $vdesc = ! empty($prod->getElementsByTagName("vDesc")->item(0)->nodeValue)
2995
                    ? $prod->getElementsByTagName("vDesc")->item(0)->nodeValue : 0;
2996
2997
                $texto = number_format($vdesc, 2, ",", ".");
2998
                $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...
2999
                //Valor da Base de calculo
3000
                $x += $w10;
3001
                if (isset($ICMS)) {
3002
                    $texto = ! empty($ICMS->getElementsByTagName("vBC")->item(0)->nodeValue)
3003
                        ? number_format(
3004
                            $ICMS->getElementsByTagName("vBC")->item(0)->nodeValue,
3005
                            2,
3006
                            ",",
3007
                            "."
3008
                        )
3009
                        : '0,00';
3010
                    $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...
3011
                }
3012
                //Valor do ICMS
3013
                $x += $w11;
3014
                if (isset($ICMS)) {
3015
                    $texto = ! empty($ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue)
3016
                        ? number_format(
3017
                            $ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue,
3018
                            2,
3019
                            ",",
3020
                            "."
3021
                        )
3022
                        : '0,00';
3023
                    $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...
3024
                }
3025
                //Valor do IPI
3026
                $x += $w12;
3027
                if (isset($IPI)) {
3028
                    $texto = ! empty($IPI->getElementsByTagName("vIPI")->item(0)->nodeValue)
3029
                        ? number_format(
3030
                            $IPI->getElementsByTagName("vIPI")->item(0)->nodeValue,
3031
                            2,
3032
                            ",",
3033
                            "."
3034
                        )
3035
                        : '';
3036
                } else {
3037
                    $texto = '';
3038
                }
3039
                $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...
3040
                // %ICMS
3041
                $x += $w13;
3042
                if (isset($ICMS)) {
3043
                    $texto = ! empty($ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue)
3044
                        ? number_format(
3045
                            $ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue,
3046
                            2,
3047
                            ",",
3048
                            "."
3049
                        )
3050
                        : '0,00';
3051
                    $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...
3052
                }
3053
                //%IPI
3054
                $x += $w14;
3055
                if (isset($IPI)) {
3056
                    $texto = ! empty($IPI->getElementsByTagName("pIPI")->item(0)->nodeValue)
3057
                        ? number_format(
3058
                            $IPI->getElementsByTagName("pIPI")->item(0)->nodeValue,
3059
                            2,
3060
                            ",",
3061
                            "."
3062
                        )
3063
                        : '';
3064
                } else {
3065
                    $texto = '';
3066
                }
3067
                $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...
3068
3069
3070
                // Dados do Veiculo Somente para veiculo 0 Km
3071
                $veicProd = $prod->getElementsByTagName("veicProd")->item(0);
3072
                // Tag somente é gerada para veiculo 0k, e só é permitido um veiculo por NF-e por conta do detran
3073
                // Verifica se a Tag existe
3074
                if (! empty($veicProd)) {
3075
                    $this->dadosItenVeiculoDANFE($oldX, $y, $nInicio, $h, $prod);
3076
                }
3077
3078
3079
                $y += $h;
3080
                $i ++;
3081
                //incrementa o controle dos itens processados.
3082
                $this->qtdeItensProc ++;
3083
            } else {
3084
                $i ++;
3085
            }
3086
        }
3087
3088
        return $oldY + $hmax;
3089
    }
3090
3091
3092
    /**
3093
     * dadosItenVeiculoDANFE
3094
     * Coloca os dados do veiculo abaixo do item da NFe. (retrato e paisagem)
3095
     *
3096
     * @param float  $x    Posição horizontal
3097
     *                     canto esquerdo
3098
     * @param float  $y    Posição vertical
3099
     *                     canto superior
3100
     * @param        $nInicio
3101
     * @param float  $h    altura do campo
3102
     * @param object $prod Contendo todos os dados do item
3103
     */
3104
3105
    protected function dadosItenVeiculoDANFE($x, $y, &$nInicio, $h, $prod)
3106
    {
3107
        $oldX = $x;
3108
        $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...
3109
3110
        if ($this->orientacao == 'P') {
3111
            $w = $this->wPrint;
3112
        } else {
3113
            if ($nInicio < 2) { // primeira página
3114
                $w = $this->wPrint - $this->wCanhoto;
3115
            } else { // páginas seguintes
3116
                $w = $this->wPrint;
3117
            }
3118
        }
3119
3120
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
3121
3122
        $w1 = round($w * 0.09, 0);
3123
3124
        // Tabela Renavam Combustivel
3125
        $renavamCombustivel = [
3126
            1  => 'ALCOOL',
3127
            2  => 'GASOLINA',
3128
            3  => 'DIESEL',
3129
            4  => 'GASOGENIO',
3130
            5  => 'GAS METANO',
3131
            6  => 'ELETRICO/FONTE INTERNA',
3132
            7  => 'ELETRICO/FONTE EXTERNA',
3133
            8  => 'GASOL/GAS NATURAL COMBUSTIVEL',
3134
            9  => 'ALCOOL/GAS NATURAL COMBUSTIVEL',
3135
            10 => 'DIESEL/GAS NATURAL COMBUSTIVEL',
3136
            11 => 'VIDE/CAMPO/OBSERVACAO',
3137
            12 => 'ALCOOL/GAS NATURAL VEICULAR',
3138
            13 => 'GASOLINA/GAS NATURAL VEICULAR',
3139
            14 => 'DIESEL/GAS NATURAL VEICULAR',
3140
            15 => 'GAS NATURAL VEICULAR',
3141
            16 => 'ALCOOL/GASOLINA',
3142
            17 => 'GASOLINA/ALCOOL/GAS NATURAL',
3143
            18 => 'GASOLINA/ELETRICO'
3144
        ];
3145
3146
        $renavamEspecie = [
3147
            1 => 'PASSAGEIRO',
3148
            2 => 'CARGA',
3149
            3 => 'MISTO',
3150
            4 => 'CORRIDA',
3151
            5 => 'TRACAO',
3152
            6 => 'ESPECIAL',
3153
            7 => 'COLECAO'
3154
        ];
3155
3156
        $renavamTiposVeiculos = [
3157
            1  => 'BICICLETA',
3158
            2  => 'CICLOMOTOR',
3159
            3  => 'MOTONETA',
3160
            4  => 'MOTOCICLETA',
3161
            5  => 'TRICICLO',
3162
            6  => 'AUTOMOVEL',
3163
            7  => 'MICROONIBUS',
3164
            8  => 'ONIBUS',
3165
            9  => 'BONDE',
3166
            10 => 'REBOQUE',
3167
            11 => 'SEMI-REBOQUE',
3168
            12 => 'CHARRETE',
3169
            13 => 'CAMIONETA',
3170
            14 => 'CAMINHAO',
3171
            15 => 'CARROCA',
3172
            16 => 'CARRO DE MAO',
3173
            17 => 'CAMINHAO TRATOR',
3174
            18 => 'TRATOR DE RODAS',
3175
            19 => 'TRATOR DE ESTEIRAS',
3176
            20 => 'TRATOR MISTO',
3177
            21 => 'QUADRICICLO',
3178
            22 => 'CHASSI/PLATAFORMA',
3179
            23 => 'CAMINHONETE',
3180
            24 => 'SIDE-CAR',
3181
            25 => 'UTILITARIO',
3182
            26 => 'MOTOR-CASA'
3183
        ];
3184
3185
        $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...
3186
            'F' => 'FOSCA',
3187
            'S' => 'SÓLIDA',
3188
            'P' => 'PEROLIZADA',
3189
            'M' => 'METALICA',
3190
        ];
3191
3192
        $veicProd = $prod->getElementsByTagName("veicProd")->item(0);
3193
3194
        $veiculoChassi     = $veicProd->getElementsByTagName("chassi")->item(0)->nodeValue;
3195
        $veiculoCor        = $veicProd->getElementsByTagName("xCor")->item(0)->nodeValue;
3196
        $veiculoCilindrada = $veicProd->getElementsByTagName("cilin")->item(0)->nodeValue;
3197
        $veiculoCmkg       = $veicProd->getElementsByTagName("CMT")->item(0)->nodeValue;
3198
        $veiculoTipo       = $veicProd->getElementsByTagName("tpVeic")->item(0)->nodeValue;
3199
3200
        $veiculoMotor       = $veicProd->getElementsByTagName("nMotor")->item(0)->nodeValue;
3201
        $veiculoRenavam     = $veicProd->getElementsByTagName("cMod")->item(0)->nodeValue;
3202
        $veiculoHp          = $veicProd->getElementsByTagName("pot")->item(0)->nodeValue;
3203
        $veiculoPlaca       = ''; //$veiculo->getElementsByTagName("CMT")->item(0)->nodeValue;
3204
        $veiculoTipoPintura = $veicProd->getElementsByTagName("tpPint")->item(0)->nodeValue;
3205
        $veiculoMarcaModelo = $prod->getElementsByTagName("xProd")->item(0)->nodeValue;
3206
        $veiculoEspecie     = $veicProd->getElementsByTagName("espVeic")->item(0)->nodeValue;
3207
        $veiculoCombustivel = $veicProd->getElementsByTagName("tpComb")->item(0)->nodeValue;
3208
        $veiculoSerial      = $veicProd->getElementsByTagName("nSerie")->item(0)->nodeValue;
3209
        $veiculoFabricacao  = $veicProd->getElementsByTagName("anoFab")->item(0)->nodeValue;
3210
        $veiculoModelo      = $veicProd->getElementsByTagName("anoMod")->item(0)->nodeValue;
3211
        $veiculoDistancia   = $veicProd->getElementsByTagName("dist")->item(0)->nodeValue;
3212
3213
        $x = $oldX;
3214
3215
        $yVeic = $y + $h;
3216
        $texto = 'Chassi: ............: ' . $veiculoChassi;
3217
        $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...
3218
        $yVeic += $h;
3219
        $texto = 'Cor...................: ' . $veiculoCor;
3220
        $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...
3221
        $yVeic += $h;
3222
        $texto = 'Cilindrada........: ' . $veiculoCilindrada;
3223
        $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...
3224
        $yVeic += $h;
3225
        $texto = 'Cmkg...............: ' . $veiculoCmkg;
3226
        $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...
3227
        $yVeic += $h;
3228
        $texto = 'Tipo.................: ' . ($renavamTiposVeiculos[intval($veiculoTipo)] ?? $veiculoTipo);
3229
        $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...
3230
        $yVeic = $y + $h;
3231
        $xVeic = $x + 65;
3232
        $texto = 'Nº Motor: .........: ' . $veiculoMotor;
3233
        $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...
3234
        $yVeic += $h;
3235
        $texto = 'Renavam...........: ' . $veiculoRenavam;
3236
        $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...
3237
        $yVeic += $h;
3238
        $texto = 'HP.....................: ' . $veiculoHp;
3239
        $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...
3240
        $yVeic += $h;
3241
        $texto = 'Placa.................: ' . $veiculoPlaca;
3242
        $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...
3243
        $yVeic += $h;
3244
        $texto = 'Tipo Pintura......: ' . ($renavamEspecie[intval($veiculoTipoPintura)] ?? $veiculoTipoPintura);
3245
        $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...
3246
        $yVeic = $y + $h;
3247
        $xVeic = $xVeic + 55;
3248
        $texto = 'Marca / Modelo.....: ' . $veiculoMarcaModelo;
3249
        $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...
3250
        $yVeic += $h;
3251
        $texto = 'Especie..................: ' . ($renavamEspecie[intval($veiculoEspecie)] ?? $veiculoEspecie);
3252
        $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...
3253
        $yVeic += $h;
3254
        $texto = 'Combustivel..........: ' . ($renavamCombustivel[intval($veiculoCombustivel)] ?? $veiculoCombustivel);
3255
        $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...
3256
        $yVeic += $h;
3257
        $texto = 'Serial.....................: ' . $veiculoSerial;
3258
        $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...
3259
        $yVeic += $h;
3260
        $texto = 'Ano Fab/Mod........: ' . $veiculoFabricacao . '/' . $veiculoModelo;
3261
        $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...
3262
        $yVeic += $h;
3263
        $texto = 'Distancia Entre Eixos(mm)..: ' . $veiculoDistancia;
3264
        $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...
3265
    }
3266
3267
    /**
3268
     * issqn
3269
     * Monta o campo de serviços do DANFE
3270
     *
3271
     * @name   issqn (retrato e paisagem)
3272
     *
3273
     * @param float $x Posição horizontal canto esquerdo
3274
     * @param float $y Posição vertical canto superior
3275
     *
3276
     * @return float Posição vertical final
3277
     */
3278
    protected function issqn($x, $y)
3279
    {
3280
        $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...
3281
        //#####################################################################
3282
        //CÁLCULO DO ISSQN
3283
        $texto = "CÁLCULO DO ISSQN";
3284
        $w     = $this->wPrint;
3285
        $h     = 7;
3286
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
3287
        $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...
3288
        //INSCRIÇÃO MUNICIPAL
3289
        $y     += 3;
3290
        $w     = round($this->wPrint * 0.23, 0);
3291
        $texto = 'INSCRIÇÃO MUNICIPAL';
3292
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
3293
        $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...
3294
        //inscrição municipal
3295
        $texto = ! empty($this->emit->getElementsByTagName("IM")->item(0)->nodeValue) ?
3296
            $this->emit->getElementsByTagName("IM")->item(0)->nodeValue : '';
3297
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
3298
        $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...
3299
        //VALOR TOTAL DOS SERVIÇOS
3300
        $x     += $w;
3301
        $texto = 'VALOR TOTAL DOS SERVIÇOS';
3302
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
3303
        $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...
3304
        if (isset($this->ISSQNtot)) {
3305
            $texto = ! empty($this->ISSQNtot->getElementsByTagName("vServ")->item(0)->nodeValue) ?
3306
                $this->ISSQNtot->getElementsByTagName("vServ")->item(0)->nodeValue : '';
3307
            $texto = number_format($texto, 2, ",", ".");
3308
        } else {
3309
            $texto = '';
3310
        }
3311
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
3312
        $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...
3313
        //BASE DE CÁLCULO DO ISSQN
3314
        $x     += $w;
3315
        $texto = 'BASE DE CÁLCULO DO ISSQN';
3316
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
3317
        $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...
3318
        if (isset($this->ISSQNtot)) {
3319
            $texto = ! empty($this->ISSQNtot->getElementsByTagName("vBC")->item(0)->nodeValue) ?
3320
                $this->ISSQNtot->getElementsByTagName("vBC")->item(0)->nodeValue : '';
3321
            $texto = ! empty($texto) ? number_format($texto, 2, ",", ".") : '';
3322
        } else {
3323
            $texto = '';
3324
        }
3325
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
3326
        $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...
3327
        //VALOR TOTAL DO ISSQN
3328
        $x += $w;
3329
        if ($this->orientacao == 'P') {
3330
            $w = $this->wPrint - (3 * $w);
3331
        } else {
3332
            $w = $this->wPrint - (3 * $w) - $this->wCanhoto;
3333
        }
3334
        $texto = 'VALOR TOTAL DO ISSQN';
3335
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
3336
        $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...
3337
        if (isset($this->ISSQNtot)) {
3338
            $texto = ! empty($this->ISSQNtot->getElementsByTagName("vISS")->item(0)->nodeValue) ?
3339
                $this->ISSQNtot->getElementsByTagName("vISS")->item(0)->nodeValue : '';
3340
            $texto = ! empty($texto) ? number_format($texto, 2, ",", ".") : '';
3341
        } else {
3342
            $texto = '';
3343
        }
3344
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
3345
        $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...
3346
3347
        return ($y + $h + 1);
3348
    }
3349
3350
    /**
3351
     *dadosAdicionais
3352
     * Coloca o grupo de dados adicionais da NFe. (retrato e paisagem)
3353
     *
3354
     * @name   dadosAdicionais
3355
     *
3356
     * @param float $x Posição horizontal canto esquerdo
3357
     * @param float $y Posição vertical canto superior
3358
     * @param float $h altura do campo
3359
     *
3360
     * @return float Posição vertical final (eixo Y)
3361
     */
3362
    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...
3363
    {
3364
        $y = $this->maxH - (7 + $h);
3365
        //$y = $this->maxH - 20;
3366
        //##################################################################################
3367
        //DADOS ADICIONAIS
3368
        $texto = "DADOS ADICIONAIS";
3369
        if ($this->orientacao == 'P') {
3370
            $w = $this->wPrint;
3371
        } else {
3372
            $w = $this->wPrint - $this->wCanhoto;
3373
        }
3374
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
3375
        $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...
3376
3377
        //INFORMAÇÕES COMPLEMENTARES
3378
        $texto = "INFORMAÇÕES COMPLEMENTARES";
3379
        $y     += 3;
3380
        $w     = $this->wAdic;
3381
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => 'B'];
3382
        $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...
3383
        //o texto com os dados adicionais foi obtido na função montaDANFE
3384
        //e carregado em uma propriedade privada da classe
3385
        //$this->wAdic com a largura do campo
3386
        //$this->textoAdic com o texto completo do campo
3387
        //echo str_replace("\n", "<br>",$this->textoAdic);
3388
        //die;
3389
        $y     += 1;
3390
        $aFont = ['font' => $this->fontePadrao, 'size' => $this->textadicfontsize * $this->pdf->k, 'style' => ''];
3391
        //$aFont = ['font'=>$this->fontePadrao, 'size'=> 5, 'style'=>''];
3392
        $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...
3393
        //RESERVADO AO FISCO
3394
        $texto = "RESERVADO AO FISCO";
3395
        if (isset($this->nfeProc) && $this->nfeProc->getElementsByTagName("xMsg")->length) {
3396
            $texto = $texto . ' ' . $this->nfeProc->getElementsByTagName("xMsg")->item(0)->nodeValue;
3397
        }
3398
        $x += $w;
3399
        $y -= 1;
3400
        if ($this->orientacao == 'P') {
3401
            $w = $this->wPrint - $w;
3402
        } else {
3403
            $w = $this->wPrint - $w - $this->wCanhoto;
3404
        }
3405
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => 'B'];
3406
        $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...
3407
        //inserir texto informando caso de contingência
3408
        // 1 - Normal - emissão normal;
3409
        // 2 - Contingência FS - emissão em contingência com impressão do DANFE em Formulário de Segurança;
3410
        // 3 - Contingência SCAN - emissão em contingência no Sistema de Contingência do Ambiente Nacional;
3411
        // 4 - Contingência EPEC - emissão em contingência com envio da Evento
3412
        //     Prévia de Emissão em Contingência;
3413
        // 5 - Contingência FS-DA - emissão em contingência com impressão do DANFE em Formulário de
3414
        //     Segurança para Impressão de Documento Auxiliar de Documento Fiscal Eletrônico (FS-DA);
3415
        // 6 - Contingência SVC-AN
3416
        // 7 - Contingência SVC-RS
3417
        $xJust  = $this->getTagValue($this->ide, 'xJust', 'Justificativa: ');
3418
        $dhCont = $this->getTagValue($this->ide, 'dhCont', ' Entrada em contingência : ');
3419
        $texto  = '';
3420
        switch ($this->tpEmis) {
3421
            case 4:
3422
                $texto = "CONTINGÊNCIA EPEC\n" . $dhCont . "\n" . $xJust;
3423
                break;
3424
            case 5:
3425
                $texto = "CONTINGÊNCIA FSDA\n" . $dhCont . "\n" . $xJust;
3426
                break;
3427
            case 6:
3428
                $texto = "CONTINGÊNCIA SVC-AN\n" . $dhCont . "\n" . $xJust;
3429
                break;
3430
            case 7:
3431
                $texto = "CONTINGÊNCIA SVC-RS\n" . $dhCont . "\n" . $xJust;
3432
                break;
3433
        }
3434
        $y     += 2;
3435
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
3436
        $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...
3437
3438
        return $y + $h;
3439
    }
3440
3441
    /**
3442
     * rodape
3443
     * Monta o rodapé no final da DANFE com a data/hora de impressão e informações
3444
     * sobre a API NfePHP
3445
     *
3446
     * @param float $x Posição horizontal canto esquerdo
3447
     *
3448
     * @return void
3449
     */
3450
    protected function rodape($x)
3451
    {
3452
        $y = $this->maxH - 4;
3453
        if ($this->orientacao == 'P') {
3454
            $w = $this->wPrint;
3455
        } else {
3456
            $w = $this->wPrint - $this->wCanhoto;
3457
            $x = $this->wCanhoto;
3458
        }
3459
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => 'I'];
3460
        $texto = "Impresso em " . date('d/m/Y') . " as " . date('H:i:s')
3461
            . '  ' . $this->creditos;
3462
        $this->pdf->textBox($x, $y, $w, 0, $texto, $aFont, 'T', 'L', false);
3463
        $texto = $this->powered ? "Powered by NFePHP®" : '';
3464
        $this->pdf->textBox($x, $y, $w, 0, $texto, $aFont, 'T', 'R', false, '');
3465
    }
3466
3467
    /**
3468
     * Monta o canhoto da DANFE (retrato e paisagem)
3469
     *
3470
     * @name   canhotoDANFE
3471
     *
3472
     * @param number $x Posição horizontal canto esquerdo
3473
     * @param number $y Posição vertical canto superior
3474
     *
3475
     * @return number Posição vertical final
3476
     *
3477
     * TODO 21/07/14 fmertins: quando orientação L-paisagem, o canhoto está sendo gerado incorretamente
3478
     */
3479
    protected function canhoto($x, $y)
3480
    {
3481
        $oldX = $x;
3482
        $oldY = $y;
3483
        //#################################################################################
3484
        //canhoto
3485
        //identificação do tipo de nf entrada ou saida
3486
        $tpNF = $this->ide->getElementsByTagName('tpNF')->item(0)->nodeValue;
3487
        if ($tpNF == '0') {
3488
            //NFe de Entrada
3489
            $emitente     = '';
3490
            $emitente     .= $this->dest->getElementsByTagName("xNome")->item(0)->nodeValue . " - ";
3491
            $emitente     .= $this->enderDest->getElementsByTagName("xLgr")->item(0)->nodeValue . ", ";
3492
            $emitente     .= $this->enderDest->getElementsByTagName("nro")->item(0)->nodeValue . " - ";
3493
            $emitente     .= $this->getTagValue($this->enderDest, "xCpl", " - ", " ");
3494
            $emitente     .= $this->enderDest->getElementsByTagName("xBairro")->item(0)->nodeValue . " ";
3495
            $emitente     .= $this->enderDest->getElementsByTagName("xMun")->item(0)->nodeValue . "-";
3496
            $emitente     .= $this->enderDest->getElementsByTagName("UF")->item(0)->nodeValue . "";
3497
            $destinatario = $this->emit->getElementsByTagName("xNome")->item(0)->nodeValue . " ";
3498
        } else {
3499
            //NFe de Saída
3500
            $emitente     = $this->emit->getElementsByTagName("xNome")->item(0)->nodeValue . " ";
3501
            $destinatario = '';
3502
            $destinatario .= $this->dest->getElementsByTagName("xNome")->item(0)->nodeValue . " - ";
3503
            $destinatario .= $this->enderDest->getElementsByTagName("xLgr")->item(0)->nodeValue . ", ";
3504
            $destinatario .= $this->enderDest->getElementsByTagName("nro")->item(0)->nodeValue . " ";
3505
            $destinatario .= $this->getTagValue($this->enderDest, "xCpl", " - ", " ");
3506
            $destinatario .= $this->enderDest->getElementsByTagName("xBairro")->item(0)->nodeValue . " ";
3507
            $destinatario .= $this->enderDest->getElementsByTagName("xMun")->item(0)->nodeValue . "-";
3508
            $destinatario .= $this->enderDest->getElementsByTagName("UF")->item(0)->nodeValue . " ";
3509
        }
3510
        //identificação do sistema emissor
3511
        //linha separadora do canhoto
3512
        if ($this->orientacao == 'P') {
3513
            $w = round($this->wPrint * 0.81, 0);
3514
        } else {
3515
            //linha separadora do canhoto - 238
3516
            //posicao altura
3517
            $y = $this->wPrint - 85;
3518
            //altura
3519
            $w = $this->wPrint - 85 - 24;
3520
        }
3521
        $h = 10;
3522
        //desenha caixa
3523
        $texto      = '';
3524
        $aFont      = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
3525
        $aFontSmall = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
3526
        if ($this->orientacao == 'P') {
3527
            $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...
3528
        } else {
3529
            $this->pdf->textBox90($x, $y, $w, $h, $texto, $aFont, 'C', 'L', 1, '', false);
3530
        }
3531
        $numNF = str_pad($this->ide->getElementsByTagName('nNF')->item(0)->nodeValue, 9, "0", STR_PAD_LEFT);
3532
        $serie = str_pad($this->ide->getElementsByTagName('serie')->item(0)->nodeValue, 3, "0", STR_PAD_LEFT);
3533
        $texto = "RECEBEMOS DE ";
3534
        $texto .= $emitente;
3535
        $texto .= " OS PRODUTOS E/OU SERVIÇOS CONSTANTES DA NOTA FISCAL ELETRÔNICA INDICADA ";
3536
        if ($this->orientacao == 'P') {
3537
            $texto .= "ABAIXO";
3538
        } else {
3539
            $texto .= "AO LADO";
3540
        }
3541
        $texto .= ". EMISSÃO: ";
3542
        $dEmi  = ! empty($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue) ?
3543
            $this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue : '';
3544
        if ($dEmi == '') {
3545
            $dEmi  = ! empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
3546
                $this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue : '';
3547
            $aDemi = explode('T', $dEmi);
3548
            $dEmi  = $aDemi[0];
3549
        }
3550
        $texto .= $this->ymdTodmy($dEmi) . " ";
3551
        $texto .= "VALOR TOTAL: R$ ";
3552
        $texto .= number_format($this->ICMSTot->getElementsByTagName("vNF")->item(0)->nodeValue, 2, ",", ".") . " ";
3553
        $texto .= "DESTINATÁRIO: ";
3554
        $texto .= $destinatario;
3555
        if ($this->orientacao == 'P') {
3556
            $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...
3557
            $x1    = $x + $w;
3558
            $w1    = $this->wPrint - $w;
3559
            $texto = "NF-e";
3560
            $aFont = ['font' => $this->fontePadrao, 'size' => 14, 'style' => 'B'];
3561
            $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...
3562
            $texto = "Nº. " . $this->formatField($numNF, "###.###.###") . " \n";
3563
            $texto .= "Série $serie";
3564
            $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
3565
            $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...
3566
            //DATA DE RECEBIMENTO
3567
            $texto = "DATA DE RECEBIMENTO";
3568
            $y     += $h;
3569
            $w2    = round($this->wPrint * 0.17, 0); //35;
3570
            $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
3571
            $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...
3572
            //IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR
3573
            $x     += $w2;
3574
            $w3    = $w - $w2;
3575
            $texto = "IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR";
3576
            $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...
3577
            $x = $oldX;
3578
            $y += 9;
3579
            $this->pdf->dashedHLine($x, $y, $this->wPrint, 0.1, 80);
3580
            $y += 2;
3581
3582
            return $y;
3583
        } else {
3584
            $x --;
3585
            $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...
3586
            //NUMERO DA NOTA FISCAL LOGO NFE
3587
            $w1    = 18;
3588
            $x1    = $oldX;
3589
            $y     = $oldY;
3590
            $texto = "NF-e";
3591
            $aFont = ['font' => $this->fontePadrao, 'size' => 14, 'style' => 'B'];
3592
            $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...
3593
            $texto = "Nº.\n" . $this->formatField($numNF, "###.###.###") . " \n";
3594
            $texto .= "Série $serie";
3595
            $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'];
3596
            $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...
3597
            //DATA DO RECEBIMENTO
3598
            $texto = "DATA DO RECEBIMENTO";
3599
            $y     = $this->wPrint - 85;
3600
            $x     = 12;
3601
            $w2    = round($this->wPrint * 0.17, 0); //35;
3602
            $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
3603
            $this->pdf->textBox90($x, $y, $w2, 8, $texto, $aFont, 'T', 'L', 1, '');
3604
            //IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR
3605
            $y     -= $w2;
3606
            $w3    = $w - $w2;
3607
            $texto = "IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR";
3608
            $aFont = ['font' => $this->fontePadrao, 'size' => 5.7, 'style' => ''];
3609
            $x     = $this->pdf->textBox90($x, $y, $w3, 8, $texto, $aFont, 'T', 'L', 1, '');
3610
            $this->pdf->dashedVLine(22, $oldY, 0.1, $this->wPrint, 69);
3611
3612
            return $x;
3613
        }
3614
    }
3615
3616
    /**
3617
     * geraInformacoesDaTagCompra
3618
     * Devolve uma string contendo informação sobre as tag <compra><xNEmp>, <xPed> e <xCont> ou string vazia.
3619
     * Aviso: Esta função não leva em consideração dados na tag xPed do item.
3620
     *
3621
     * @name   pGeraInformacoesDaTagCompra
3622
     * @return string com as informacoes dos pedidos.
3623
     */
3624
    protected function geraInformacoesDaTagCompra()
3625
    {
3626
        if (! $this->gerarInformacoesAutomaticas) {
3627
            return '';
3628
        }
3629
        $saida = "";
3630
        if (isset($this->compra)) {
3631
            if (! empty($this->compra->getElementsByTagName("xNEmp")->item(0)->nodeValue)) {
3632
                $saida .= " Nota de Empenho: " . $this->compra->getElementsByTagName("xNEmp")->item(0)->nodeValue;
3633
            }
3634
            if (! empty($this->compra->getElementsByTagName("xPed")->item(0)->nodeValue)) {
3635
                $saida .= " Pedido: " . $this->compra->getElementsByTagName("xPed")->item(0)->nodeValue;
3636
            }
3637
            if (! empty($this->compra->getElementsByTagName("xCont")->item(0)->nodeValue)) {
3638
                $saida .= " Contrato: " . $this->compra->getElementsByTagName("xCont")->item(0)->nodeValue;
3639
            }
3640
        }
3641
3642
        return $saida;
3643
    }
3644
3645
    /**
3646
     * geraChaveAdicionalDeContingencia
3647
     *
3648
     * @name   geraChaveAdicionalDeContingencia
3649
     * @return string chave
3650
     */
3651
    protected function geraChaveAdicionalDeContingencia()
3652
    {
3653
        //cUF tpEmis CNPJ vNF ICMSp ICMSs DD  DV
3654
        // Quantidade de caracteres  02   01      14  14    01    01  02 01
3655
        $forma = "%02d%d%s%014d%01d%01d%02d";
3656
        $cUF   = $this->ide->getElementsByTagName('cUF')->item(0)->nodeValue;
3657
        $CNPJ  = "00000000000000" . $this->emit->getElementsByTagName('CNPJ')->item(0)->nodeValue;
3658
        $CNPJ  = substr($CNPJ, - 14);
3659
        $vNF   = $this->ICMSTot->getElementsByTagName("vNF")->item(0)->nodeValue * 100;
3660
        $vICMS = $this->ICMSTot->getElementsByTagName("vICMS")->item(0)->nodeValue;
3661
        if ($vICMS > 0) {
3662
            $vICMS = 1;
3663
        }
3664
        $icmss = $this->ICMSTot->getElementsByTagName("vBC")->item(0)->nodeValue;
3665
        if ($icmss > 0) {
3666
            $icmss = 1;
3667
        }
3668
        $dEmi = ! empty($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue) ?
3669
            $this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue : '';
3670
        if ($dEmi == '') {
3671
            $dEmi  = ! empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
3672
                $this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue : '';
3673
            $aDemi = explode('T', $dEmi);
3674
            $dEmi  = $aDemi[0];
3675
        }
3676
        $dd    = $dEmi;
3677
        $rpos  = strrpos($dd, '-');
3678
        $dd    = substr($dd, $rpos + 1);
3679
        $chave = sprintf($forma, $cUF, $this->tpEmis, $CNPJ, $vNF, $vICMS, $icmss, $dd);
3680
        $chave = $chave . $this->modulo11($chave);
3681
3682
        return $chave;
3683
    }
3684
3685
    /**
3686
     *  geraInformacoesDasNotasReferenciadas
3687
     * Devolve uma string contendo informação sobre as notas referenciadas. Suporta N notas, eletrônicas ou não
3688
     * Exemplo: NFe Ref.: série: 01 número: 01 emit: 11.111.111/0001-01
3689
     * em 10/2010 [0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000]
3690
     *
3691
     * @return string Informacoes a serem adicionadas no rodapé sobre notas referenciadas.
3692
     */
3693
    protected function geraInformacoesDasNotasReferenciadas()
3694
    {
3695
        if (! $this->gerarInformacoesAutomaticas) {
3696
            return '';
3697
        }
3698
        $formaNfeRef = "\r\nNFe Ref.: série:%d número:%d emit:%s em %s [%s]";
3699
        $formaCTeRef = "\r\nCTe Ref.: série:%d número:%d emit:%s em %s [%s]";
3700
        $formaNfRef  = "\r\nNF  Ref.: série:%d numero:%d emit:%s em %s modelo: %d";
3701
        $formaECFRef = "\r\nECF Ref.: modelo: %s ECF:%d COO:%d";
3702
        $formaNfpRef = "\r\nNFP Ref.: série:%d número:%d emit:%s em %s modelo: %d IE:%s";
3703
        $saida       = '';
3704
        $nfRefs      = $this->ide->getElementsByTagName('NFref');
3705
        if (0 === $nfRefs->length) {
3706
            return $saida;
3707
        }
3708
        if ($nfRefs->length > 2) {
3709
            return 'Existem mais de 2 NF/NFe/ECF/NFP/CTe referenciadas, não serão exibidas na DANFE.';
3710
        }
3711
        foreach ($nfRefs as $nfRef) {
3712
            if (empty($nfRef)) {
3713
                continue;
3714
            }
3715
            $refNFe = $nfRef->getElementsByTagName('refNFe');
3716
            foreach ($refNFe as $chave_acessoRef) {
3717
                $chave_acesso  = $chave_acessoRef->nodeValue;
3718
                $chave_acessoF = $this->formatField($chave_acesso, $this->formatoChave);
3719
                $data          = substr($chave_acesso, 4, 2) . "/20" . substr($chave_acesso, 2, 2);
3720
                $cnpj          = $this->formatField(substr($chave_acesso, 6, 14), "##.###.###/####-##");
3721
                $serie         = substr($chave_acesso, 22, 3);
3722
                $numero        = substr($chave_acesso, 25, 9);
3723
                $saida         .= sprintf($formaNfeRef, $serie, $numero, $cnpj, $data, $chave_acessoF);
3724
            }
3725
            $refNF = $nfRef->getElementsByTagName('refNF');
3726
            foreach ($refNF as $umaRefNFe) {
3727
                $data   = $umaRefNFe->getElementsByTagName('AAMM')->item(0)->nodeValue;
3728
                $cnpj   = $umaRefNFe->getElementsByTagName('CNPJ')->item(0)->nodeValue;
3729
                $mod    = $umaRefNFe->getElementsByTagName('mod')->item(0)->nodeValue;
3730
                $serie  = $umaRefNFe->getElementsByTagName('serie')->item(0)->nodeValue;
3731
                $numero = $umaRefNFe->getElementsByTagName('nNF')->item(0)->nodeValue;
3732
                $data   = substr($data, 2, 2) . "/20" . substr($data, 0, 2);
3733
                $cnpj   = $this->formatField($cnpj, "##.###.###/####-##");
3734
                $saida  .= sprintf($formaNfRef, $serie, $numero, $cnpj, $data, $mod);
3735
            }
3736
            $refCTe = $nfRef->getElementsByTagName('refCTe');
3737
            foreach ($refCTe as $chave_acessoRef) {
3738
                $chave_acesso  = $chave_acessoRef->nodeValue;
3739
                $chave_acessoF = $this->formatField($chave_acesso, $this->formatoChave);
3740
                $data          = substr($chave_acesso, 4, 2) . "/20" . substr($chave_acesso, 2, 2);
3741
                $cnpj          = $this->formatField(substr($chave_acesso, 6, 14), "##.###.###/####-##");
3742
                $serie         = substr($chave_acesso, 22, 3);
3743
                $numero        = substr($chave_acesso, 25, 9);
3744
                $saida         .= sprintf($formaCTeRef, $serie, $numero, $cnpj, $data, $chave_acessoF);
3745
            }
3746
            $refECF = $nfRef->getElementsByTagName('refECF');
3747
            foreach ($refECF as $umaRefNFe) {
3748
                $mod   = $umaRefNFe->getElementsByTagName('mod')->item(0)->nodeValue;
3749
                $nECF  = $umaRefNFe->getElementsByTagName('nECF')->item(0)->nodeValue;
3750
                $nCOO  = $umaRefNFe->getElementsByTagName('nCOO')->item(0)->nodeValue;
3751
                $saida .= sprintf($formaECFRef, $mod, $nECF, $nCOO);
3752
            }
3753
            $refNFP = $nfRef->getElementsByTagName('refNFP');
3754
            foreach ($refNFP as $umaRefNFe) {
3755
                $data   = $umaRefNFe->getElementsByTagName('AAMM')->item(0)->nodeValue;
3756
                $cnpj   = ! empty($umaRefNFe->getElementsByTagName('CNPJ')->item(0)->nodeValue) ?
3757
                    $umaRefNFe->getElementsByTagName('CNPJ')->item(0)->nodeValue :
3758
                    '';
3759
                $cpf    = ! empty($umaRefNFe->getElementsByTagName('CPF')->item(0)->nodeValue) ?
3760
                    $umaRefNFe->getElementsByTagName('CPF')->item(0)->nodeValue : '';
3761
                $mod    = $umaRefNFe->getElementsByTagName('mod')->item(0)->nodeValue;
3762
                $serie  = $umaRefNFe->getElementsByTagName('serie')->item(0)->nodeValue;
3763
                $numero = $umaRefNFe->getElementsByTagName('nNF')->item(0)->nodeValue;
3764
                $ie     = $umaRefNFe->getElementsByTagName('IE')->item(0)->nodeValue;
3765
                $data   = substr($data, 2, 2) . "/20" . substr($data, 0, 2);
3766
                if ($cnpj == '') {
3767
                    $cpf_cnpj = $this->formatField($cpf, "###.###.###-##");
3768
                } else {
3769
                    $cpf_cnpj = $this->formatField($cnpj, "##.###.###/####-##");
3770
                }
3771
                $saida .= sprintf($formaNfpRef, $serie, $numero, $cpf_cnpj, $data, $mod, $ie);
3772
            }
3773
        }
3774
3775
        return $saida;
3776
    }
3777
3778
    private function loadDoc($xml)
3779
    {
3780
        $this->xml = $xml;
3781
        if (! empty($xml)) {
3782
            $this->dom = new Dom();
3783
            $this->dom->loadXML($this->xml);
3784
            if (empty($this->dom->getElementsByTagName("infNFe")->item(0))) {
3785
                throw new \Exception('Isso não é um NFe.');
3786
            }
3787
            $this->nfeProc = $this->dom->getElementsByTagName("nfeProc")->item(0);
3788
            $this->infNFe  = $this->dom->getElementsByTagName("infNFe")->item(0);
3789
            $this->ide     = $this->dom->getElementsByTagName("ide")->item(0);
3790
            if ($this->getTagValue($this->ide, "mod") != '55') {
3791
                throw new \Exception("O xml deve ser NF-e modelo 55.");
3792
            }
3793
            $this->entrega    = $this->dom->getElementsByTagName("entrega")->item(0);
3794
            $this->retirada   = $this->dom->getElementsByTagName("retirada")->item(0);
3795
            $this->emit       = $this->dom->getElementsByTagName("emit")->item(0);
3796
            $this->dest       = $this->dom->getElementsByTagName("dest")->item(0);
3797
            $this->enderEmit  = $this->dom->getElementsByTagName("enderEmit")->item(0);
3798
            $this->enderDest  = $this->dom->getElementsByTagName("enderDest")->item(0);
3799
            $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...
3800
            $this->cobr       = $this->dom->getElementsByTagName("cobr")->item(0);
3801
            $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...
3802
            $this->ICMSTot    = $this->dom->getElementsByTagName("ICMSTot")->item(0);
3803
            $this->ISSQNtot   = $this->dom->getElementsByTagName("ISSQNtot")->item(0);
3804
            $this->transp     = $this->dom->getElementsByTagName("transp")->item(0);
3805
            $this->transporta = $this->dom->getElementsByTagName("transporta")->item(0);
3806
            $this->veicTransp = $this->dom->getElementsByTagName("veicTransp")->item(0);
3807
            $this->detPag     = $this->dom->getElementsByTagName("detPag");
3808
            $this->reboque    = $this->dom->getElementsByTagName("reboque")->item(0);
3809
            $this->infAdic    = $this->dom->getElementsByTagName("infAdic")->item(0);
3810
            $this->compra     = $this->dom->getElementsByTagName("compra")->item(0);
3811
            $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...
3812
            $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...
3813
            $this->infProt    = $this->dom->getElementsByTagName("infProt")->item(0);
3814
        }
3815
    }
3816
3817
    /**
3818
     * @param $item
3819
     *
3820
     * @return float
3821
     */
3822
    protected function calculeHeight($item, $mostrarUnidadeTributavel = false)
3823
    {
3824
        if ($this->orientacao == 'P') {
3825
            $w = $this->wPrint;
3826
        } else {
3827
            $w = $this->wPrint - $this->wCanhoto;
3828
        }
3829
        $w2           = round($w * 0.25, 0);
3830
        $aFont        = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
3831
        $textoProduto = $this->descricaoProduto($item);
3832
        $numlinhas    = $this->pdf->getNumLines($textoProduto, $w2, $aFont);
3833
3834
        if ($mostrarUnidadeTributavel && $numlinhas == 1) {
3835
            $numlinhas ++;
3836
        }
3837
3838
        return round(($numlinhas * $this->pdf->fontSize) + ($numlinhas * 0.5), 2);
3839
    }
3840
}
3841