Completed
Pull Request — master (#451)
by
unknown
03:07
created

Danfe::setOcultarUnidadeTributavel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
namespace NFePHP\DA\NFe;
3
4
use NFePHP\DA\Legacy\Dom;
5
use NFePHP\DA\Legacy\Pdf;
6
use \NFePHP\DA\Common\DaCommon;
7
8
class Danfe extends DaCommon
9
{
10
11
    /**
12
     * Posição
13
     *
14
     * @var float
15
     */
16
    protected $yDados = 0;
17
    /**
18
     * Parâmetro para exibir ou ocultar os valores do PIS/COFINS.
19
     *
20
     * @var boolean
21
     */
22
    protected $qCanhoto = 1;
23
    /**
24
     * Define a exbição dos valores de PIS e Cofins
25
     *
26
     * @var bool
27
     */
28
    protected $exibirPIS = true;
29
    /**
30
     * Parâmetro para exibir ou ocultar os valores do ICMS Interestadual e Valor Total dos Impostos.
31
     *
32
     * @var boolean
33
     */
34
    protected $exibirIcmsInterestadual = true;
35
    /**
36
     * Parâmetro para exibir ou ocultar o texto sobre valor aproximado dos tributos.
37
     *
38
     * @var boolean
39
     */
40
    protected $exibirValorTributos = true;
41
    /**
42
     * Parâmetro para exibir ou ocultar o texto adicional sobre a forma de pagamento
43
     * e as informações de fatura/duplicata.
44
     *
45
     * @var boolean
46
     */
47
    protected $exibirTextoFatura = false;
48
    /**
49
     * Parâmetro do controle se deve concatenar automaticamente informações complementares
50
     * na descrição do produto, como por exemplo, informações sobre impostos.
51
     *
52
     * @var boolean
53
     */
54
    public $descProdInfoComplemento = true;
55
    /**
56
     *`Parâmetro que habilita a geração de automatica de informações
57
     *
58
     * @var boolean
59
     */
60
    public $gerarInformacoesAutomaticas = true;
61
    /**
62
     * Parâmetro do controle se deve gerar quebras de linha com "\n" a partir de ";" na descrição do produto.
63
     *
64
     * @var boolean
65
     */
66
    protected $descProdQuebraLinha = true;
67
     /**
68
     * Parâmetro para ocultar a unidade tributável nos itens
69
     *
70
     * @var boolean
71
     */
72
    protected $ocultarUnidadeTributavel = false;
73
    /**
74
     * XML NFe
75
     *
76
     * @var string
77
     */
78
    protected $xml;
79
    /**
80
     * mesagens de erro
81
     *
82
     * @var string
83
     */
84
    protected $errMsg = '';
85
    /**
86
     * status de erro true um erro ocorreu false sem erros
87
     *
88
     * @var boolean
89
     */
90
    protected $errStatus = false;
91
    /**
92
     * Texto adicional da DANFE
93
     *
94
     * @var string
95
     */
96
    protected $textoAdic = '';
97
    /**
98
     * Largura
99
     *
100
     * @var float
101
     */
102
    protected $wAdic = 0;
103
    /**
104
     * largura do canhoto (25mm) apenas para a formatação paisagem
105
     *
106
     * @var float
107
     */
108
    protected $wCanhoto = 25;
109
    /**
110
     * Formato chave
111
     *
112
     * @var string
113
     */
114
    protected $formatoChave = "#### #### #### #### #### #### #### #### #### #### ####";
115
    /**
116
     * quantidade de itens já processados na montagem do DANFE
117
     *
118
     * @var integer
119
     */
120
    protected $qtdeItensProc;
121
    /**
122
     * Dom Document
123
     *
124
     * @var \NFePHP\DA\Legacy\Dom
125
     */
126
    protected $dom;
127
    /**
128
     * Node
129
     *
130
     * @var \DOMNode
131
     */
132
    protected $infNFe;
133
    /**
134
     * Node
135
     *
136
     * @var \DOMNode
137
     */
138
    protected $ide;
139
    /**
140
     * Node
141
     *
142
     * @var \DOMNode
143
     */
144
    protected $entrega;
145
    /**
146
     * Node
147
     *
148
     * @var \DOMNode
149
     */
150
    protected $retirada;
151
    /**
152
     * Node
153
     *
154
     * @var \DOMNode
155
     */
156
    protected $emit;
157
    /**
158
     * Node
159
     *
160
     * @var \DOMNode
161
     */
162
    protected $dest;
163
    /**
164
     * Node
165
     *
166
     * @var \DOMNode
167
     */
168
    protected $enderEmit;
169
    /**
170
     * Node
171
     *
172
     * @var \DOMNode
173
     */
174
    protected $enderDest;
175
    /**
176
     * Node
177
     *
178
     * @var \DOMNode
179
     */
180
    protected $det;
181
    /**
182
     * Node
183
     *
184
     * @var \DOMNode
185
     */
186
    protected $cobr;
187
    /**
188
     * Node
189
     *
190
     * @var \DOMNode
191
     */
192
    protected $dup;
193
    /**
194
     * Node
195
     *
196
     * @var \DOMNode
197
     */
198
    protected $ICMSTot;
199
    /**
200
     * Node
201
     *
202
     * @var \DOMNode
203
     */
204
    protected $ISSQNtot;
205
    /**
206
     * Node
207
     *
208
     * @var \DOMNode
209
     */
210
    protected $transp;
211
    /**
212
     * Node
213
     *
214
     * @var \DOMNode
215
     */
216
    protected $transporta;
217
    /**
218
     * Node
219
     *
220
     * @var \DOMNode
221
     */
222
    protected $veicTransp;
223
    /**
224
     * Node reboque
225
     *
226
     * @var \DOMNode
227
     */
228
    protected $reboque;
229
    /**
230
     * Node infAdic
231
     *
232
     * @var \DOMNode
233
     */
234
    protected $infAdic;
235
    /**
236
     * Tipo de emissão
237
     *
238
     * @var integer
239
     */
240
    protected $tpEmis;
241
    /**
242
     * Node infProt
243
     *
244
     * @var \DOMNode
245
     */
246
    protected $infProt;
247
    /**
248
     * 1-Retrato/ 2-Paisagem
249
     *
250
     * @var integer
251
     */
252
    protected $tpImp;
253
    /**
254
     * Node compra
255
     *
256
     * @var \DOMNode
257
     */
258
    protected $compra;
259
    /**
260
     * @var int
261
     */
262
    protected $textadicfontsize;
263
    /**
264
     * Número de casas para a quantidade de itens da unidade comercial.
265
     *
266
     * @var integer
267
     */
268
    protected $qComCasasDec = 4;
269
    /**
270
     * Número de casas decimais para o valor da unidade comercial.
271
     *
272
     * @var integer
273
     */
274
    protected $vUnComCasasDec = 4;
275
    /**
276
     * @var int
277
     */
278
    protected $hdadosadic = 10;
279
    /**
280
     * @var array
281
     */
282
    protected $epec = [];
283
    /**
284
     * @var bool
285
     */
286
    protected $obsshow = true;
287
288
    /**
289
     * __construct
290
     *
291
     * @name  __construct
292
     *
293
     * @param string $xml Conteúdo XML da NF-e (com ou sem a tag nfeProc)
294
     */
295
    public function __construct($xml)
296
    {
297
        $this->loadDoc($xml);
298
    }
299
300
    public function epec($protocolo, $data)
301
    {
302
        $this->epec = [
303
            'protocolo' => $protocolo,
304
            'data' => $data
305
        ];
306
    }
307
308
    public function obsContShow($flag = true)
309
    {
310
        $this->obsshow = $flag;
311
    }
312
313
    /**
314
     * Define a quantidade de casas decimais para unidade comercial.
315
     *
316
     * @param integer $vUnComCasasDec
317
     */
318
    public function setVUnComCasasDec($vUnComCasasDec)
319
    {
320
        $this->vUnComCasasDec = $vUnComCasasDec;
321
    }
322
323
    /**
324
     * Define a quantidade de casas decimais para unidade comercial.
325
     *
326
     * @param integer $qComCasasDec
327
     */
328
    public function setQComCasasDec($qComCasasDec)
329
    {
330
        $this->qComCasasDec = $qComCasasDec;
331
    }
332
    
333
    /**
334
     * Atribui se a unidade tributável deve sempre ocultada nos itens.
335
     * @param bool $ocultarUnidadeTributavel
336
     */
337
    public function setOcultarUnidadeTributavel($ocultarUnidadeTributavel = false)
338
    {
339
        $this->ocultarUnidadeTributavel = filter_var($ocultarUnidadeTributavel, FILTER_VALIDATE_BOOLEAN);
340
    }
341
342
    protected function calculoEspacoVericalDadosAdicionais()
343
    {
344
        $this->textoAdic = '';
345
        //informações adicionais
346
        $fontProduto            = [
347
            'font'  => $this->fontePadrao,
348
            'size'  => 8,
349
            'style' => ''
350
        ];
351
        $k                      = $this->pdf->k;
352
        $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...
353
        $this->textoAdic        .= $this->geraInformacoesDasNotasReferenciadas();
354
        if (isset($this->infAdic)) {
355
            $i = 0;
356
            if ($this->textoAdic != '') {
357
                $this->textoAdic .= ". \n";
358
            }
359
            $this->textoAdic .= ! empty($this->getTagValue($this->infAdic, "infCpl"))
360
                ? 'Inf. Contribuinte: ' . $this->anfaveaDANFE($this->getTagValue($this->infAdic, "infCpl"))
361
                : '';
362
            $infPedido       = $this->geraInformacoesDaTagCompra();
363
            if ($infPedido != "") {
364
                $this->textoAdic .= $infPedido;
365
            }
366
            $this->textoAdic .= $this->getTagValue($this->dest, "email", ' Email do Destinatário: ');
367
            $this->textoAdic .= ! empty($this->getTagValue($this->infAdic, "infAdFisco"))
368
                ? "\n Inf. fisco: " . $this->getTagValue($this->infAdic, "infAdFisco")
369
                : '';
370
            if ($this->obsshow) {
371
                $obsCont = $this->infAdic->getElementsByTagName("obsCont");
372
                if (isset($obsCont)) {
373
                    foreach ($obsCont as $obs) {
374
                        $campo = $obsCont->item($i)->getAttribute("xCampo");
375
                        $xTexto = ! empty($obsCont->item($i)->getElementsByTagName("xTexto")->item(0)->nodeValue)
376
                            ? $obsCont->item($i)->getElementsByTagName("xTexto")->item(0)->nodeValue
377
                            : '';
378
                        $this->textoAdic .= "\n" . $campo . ':  ' . trim($xTexto);
379
                        $i ++;
380
                    }
381
                }
382
            }
383
        }
384
        //INCLUSO pela NT 2013.003 Lei da Transparência
385
        //verificar se a informação sobre o valor aproximado dos tributos
386
        //já se encontra no campo de informações adicionais
387
        if ($this->exibirValorTributos) {
388
            $flagVTT  = strpos(strtolower(trim($this->textoAdic)), 'valor');
389
            $flagVTT  = $flagVTT || strpos(strtolower(trim($this->textoAdic)), 'vl');
390
            $flagVTT  = $flagVTT && strpos(strtolower(trim($this->textoAdic)), 'aprox');
391
            $flagVTT  = $flagVTT && (strpos(strtolower(trim($this->textoAdic)), 'trib') ||
392
                    strpos(strtolower(trim($this->textoAdic)), 'imp'));
393
            $vTotTrib = $this->getTagValue($this->ICMSTot, 'vTotTrib');
394
            if ($vTotTrib != '' && ! $flagVTT) {
395
                $this->textoAdic .= "\n Valor Aproximado dos Tributos : R$ "
396
                    . number_format($vTotTrib, 2, ",", ".");
397
            }
398
        }
399
        //fim da alteração NT 2013.003 Lei da Transparência
400
        $this->textoAdic        = str_replace(";", "\n", $this->textoAdic);
401
        $numlinhasdados         = $this->pdf->getNumLines($this->textoAdic, $this->wAdic, $fontProduto) + 1.5;
402
        $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...
403
        $hdadosadic             = ceil($numlinhasdados * ($this->textadicfontsize));
404
        if ($hdadosadic > 70) {
405
            for ($f = 8; $f > 3; $f --) {
406
                $this->pdf->setFont($this->fontePadrao, '', $f);
407
                $fontProduto            = [
408
                    'font'  => $this->fontePadrao,
409
                    'size'  => $f,
410
                    'style' => ''
411
                ];
412
                $numlinhasdados         = $this->pdf->getNumLines($this->textoAdic, $this->wAdic, $fontProduto) + 3;
413
                $this->textadicfontsize = $this->pdf->fontSize;
414
                $hdadosadic             = ceil($numlinhasdados * $this->textadicfontsize);
415
                echo $hdadosadic;
416
                if ($hdadosadic <= 90) {
417
                    $hdadosadic = ceil($hdadosadic);
418
                    break;
419
                }
420
            }
421
        }
422
        if ($hdadosadic < 10) {
423
            $hdadosadic = 10;
424
        }
425
426
        return $hdadosadic;
427
    }
428
429
    /**
430
     * monta
431
     * Monta a DANFE conforme as informações fornecidas para a classe durante sua
432
     * construção. Constroi DANFEs com até 3 páginas podendo conter até 56 itens.
433
     * A definição de margens e posições iniciais para a impressão são estabelecidas
434
     * pelo conteúdo da funçao e podem ser modificados.
435
     *
436
     * @return string O ID da NFe numero de 44 digitos extraido do arquivo XML
437
     */
438
    protected function monta(
439
        $logo = ''
440
    ) {
441
        $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...
442
        $this->logomarca = $this->adjustImage($logo);
443
        //se a orientação estiver em branco utilizar o padrão estabelecido na NF
444
        if (empty($this->orientacao)) {
445
            if ($this->tpImp == '2') {
446
                $this->orientacao = 'L';
447
            } else {
448
                $this->orientacao = 'P';
449
            }
450
        }
451
        //instancia a classe pdf
452
        $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...
453
        //margens do PDF, em milímetros. Obs.: a margem direita é sempre igual à
454
        //margem esquerda. A margem inferior *não* existe na FPDF, é definida aqui
455
        //apenas para controle se necessário ser maior do que a margem superior
456
        // posição inicial do conteúdo, a partir do canto superior esquerdo da página
457
        $xInic = $this->margesq;
458
        if ($this->orientacao == 'P') {
459
            if ($this->papel == 'A4') {
460
                $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...
461
                $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...
462
            }
463
        } else {
464
            if ($this->papel == 'A4') {
465
                $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...
466
                $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...
467
                $xInic      = $this->margesq + 10;
468
                //se paisagem multiplica a largura do canhoto pela quantidade de canhotos
469
                //$this->wCanhoto *= $this->qCanhoto;
470
            }
471
        }
472
        //total inicial de paginas
473
        $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...
474
        //largura imprimivel em mm: largura da folha menos as margens esq/direita
475
        $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...
476
        //comprimento (altura) imprimivel em mm: altura da folha menos as margens
477
        //superior e inferior
478
        $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...
479
        // estabelece contagem de paginas
480
        $this->pdf->aliasNbPages();
481
        // fixa as margens
482
        $this->pdf->setMargins($this->margesq, $this->margsup);
483
        $this->pdf->setDrawColor(0, 0, 0);
484
        $this->pdf->setFillColor(255, 255, 255);
485
        // inicia o documento
486
        $this->pdf->open();
487
        // adiciona a primeira página
488
        $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...
489
        $this->pdf->setLineWidth(0.1);
490
        $this->pdf->settextcolor(0, 0, 0);
491
492
        //##################################################################
493
        // CALCULO DO NUMERO DE PAGINAS A SEREM IMPRESSAS
494
        //##################################################################
495
        //Verificando quantas linhas serão usadas para impressão das duplicatas
496
        $linhasDup = 0;
497
        $qtdPag    = 0;
498
        if (isset($this->dup) && $this->dup->length > 0) {
499
            $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...
500
        } 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...
501
            $qtdPag = $this->detPag->length;
502
        }
503
        if (($qtdPag > 0) && ($qtdPag <= 7)) {
504
            $linhasDup = 1;
505
        } elseif (($qtdPag > 7) && ($qtdPag <= 14)) {
506
            $linhasDup = 2;
507
        } elseif (($qtdPag > 14) && ($qtdPag <= 21)) {
508
            $linhasDup = 3;
509
        } elseif ($qtdPag > 21) {
510
            // chinnonsantos 11/05/2016: Limite máximo de impressão de duplicatas na NFe,
511
            // só vai ser exibito as 21 primeiras duplicatas (parcelas de pagamento),
512
            // se não oculpa espaço d+, cada linha comporta até 7 duplicatas.
513
            $linhasDup = 3;
514
        }
515
        //verifica se será impressa a linha dos serviços ISSQN
516
        $linhaISSQN = 0;
517
        if ((isset($this->ISSQNtot)) && ($this->getTagValue($this->ISSQNtot, 'vServ') > 0)) {
518
            $linhaISSQN = 1;
519
        }
520
        //calcular a altura necessária para os dados adicionais
521
        if ($this->orientacao == 'P') {
522
            $this->wAdic = round($this->wPrint * 0.66, 0);
523
        } else {
524
            $this->wAdic = round(($this->wPrint - $this->wCanhoto) * 0.5, 0);
525
        }
526
        $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...
527
528
        $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...
529
530
        //altura disponivel para os campos da DANFE
531
        $hcabecalho    = 47;//para cabeçalho
532
        $hdestinatario = 25;//para destinatario
533
        $hduplicatas   = 12;//para cada grupo de 7 duplicatas
534
        if (isset($this->entrega)) {
535
            $hlocalentrega = 25;
536
        } else {
537
            $hlocalentrega = 0;
538
        }
539
        if (isset($this->retirada)) {
540
            $hlocalretirada = 25;
541
        } else {
542
            $hlocalretirada = 0;
543
        }
544
        $himposto    = 18;// para imposto
545
        $htransporte = 25;// para transporte
546
        $hissqn      = 11;// para issqn
547
        $hfooter     = 5;// para rodape
548
        $hCabecItens = 4;//cabeçalho dos itens
549
        $hOCUPADA    = $hcabecalho
550
            + $hdestinatario
551
            + $hlocalentrega
552
            + $hlocalretirada
553
            + ($linhasDup * $hduplicatas)
554
            + $himposto + $htransporte
555
            + ($linhaISSQN * $hissqn)
556
            + $this->hdadosadic
557
            + $hfooter
558
            + $hCabecItens
559
            + $this->sizeExtraTextoFatura();
560
561
        //alturas disponiveis para os dados
562
        $hDispo1 = $this->hPrint - $hOCUPADA;
563
        /*($hcabecalho +
564
        //$hdestinatario + ($linhasDup * $hduplicatas) + $himposto + $htransporte +
565
        $hdestinatario + $hlocalentrega + $hlocalretirada +
566
        ($linhasDup * $hduplicatas) + $himposto + $htransporte +
567
        ($linhaISSQN * $hissqn) + $this->hdadosadic + $hfooter + $hCabecItens +
568
        $this->sizeExtraTextoFatura());*/
569
570
        if ($this->orientacao == 'P') {
571
            $hDispo1 -= 24 * $this->qCanhoto;//para canhoto
572
            $w       = $this->wPrint;
573
        } else {
574
            $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...
575
            $w        = $this->wPrint - $this->wCanhoto;
576
        }
577
        //$hDispo1 += 14;
578
        $hDispo2 = $this->hPrint - ($hcabecalho + $hfooter + $hCabecItens);
579
        //Contagem da altura ocupada para impressão dos itens
580
        $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...
581
        $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...
582
        $hUsado    = $hCabecItens;
583
        $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...
584
        $hDispo    = $hDispo1;
585
        $totPag    = 1;
586
        $i         = 0;
587
        while ($i < $this->det->length) {
588
            $itemProd = $this->det->item($i);
589
            $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...
590
            $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...
591
592
            $prod = $itemProd->getElementsByTagName('prod')->item(0);
593
            $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...
594
            $vUnCom = $prod->getElementsByTagName("vUnCom")->item(0)->nodeValue;
595
            $uTrib = $prod->getElementsByTagName("uTrib")->item(0);
596
            $qTrib = $prod->getElementsByTagName("qTrib")->item(0);
597
            $vUnTrib = !empty($prod->getElementsByTagName("vUnTrib")->item(0)->nodeValue)
598
                ? $prod->getElementsByTagName("vUnTrib")->item(0)->nodeValue
599
                : 0;
600
            //se as unidades forem diferentes e q qtda de qTrib for maior que 0
601
            //mostrat as unidades
602
            $mostrarUnidadeTributavel = (
603
                !$this->ocultarUnidadeTributavel
604
                && !empty($uTrib)
605
                && !empty($qTrib)
606
                && number_format($vUnCom, 2, ',', '') !== number_format($vUnTrib, 2, ',', '')
607
            );
608
            $hUsado += $this->calculeHeight($itemProd, $mostrarUnidadeTributavel);
609
            if ($hUsado > $hDispo) {
610
                $totPag ++;
611
                $hDispo = $hDispo2;
612
                $hUsado = $hCabecItens;
613
                $i --; // decrementa para readicionar o item que não coube nessa pagina na outra.
614
            }
615
            $i ++;
616
        } //fim da soma das areas de itens usadas
617
        $qtdeItens = $i; //controle da quantidade de itens no DANFE
618
        //montagem da primeira página
619
        $pag = 1;
620
621
        $x = $this->margesq;
622
        $y = $this->margsup;
623
        //coloca o(s) canhoto(s) da NFe
624
        if ($this->orientacao == 'P') {
625
            $y = $this->canhoto($this->margesq, $this->margsup);
626
        } else {
627
            $this->canhoto($this->margesq, $this->margsup);
628
            $x = 25;
629
        }
630
        //coloca o cabeçalho
631
        $y = $this->header($x, $y, $pag, $totPag);
632
        //coloca os dados do destinatário
633
        $y = $this->destinatarioDANFE($x, $y + 1);
634
        //coloca os dados do local de retirada
635
        if (isset($this->retirada)) {
636
            $y = $this->localRetiradaDANFE($x, $y + 1);
637
        }
638
        //coloca os dados do local de entrega
639
        if (isset($this->entrega)) {
640
            $y = $this->localEntregaDANFE($x, $y + 1);
641
        }
642
643
        //Verifica as formas de pagamento da nota fiscal
644
        $formaPag = [];
645
        if (isset($this->detPag) && $this->detPag->length > 0) {
646
            foreach ($this->detPag as $k => $d) {
647
                $fPag            = ! empty($this->detPag->item($k)->getElementsByTagName('tPag')->item(0)->nodeValue)
648
                    ? $this->detPag->item($k)->getElementsByTagName('tPag')->item(0)->nodeValue
649
                    : '0';
650
                $formaPag[$fPag] = $fPag;
651
            }
652
        }
653
        //caso tenha boleto imprimir fatura
654
        if ($this->dup->length > 0) {
655
            $y = $this->fatura($x, $y + 1);
656
        } else {
657
            //Se somente tiver a forma de pagamento sem pagamento não imprimir nada
658
            if (count($formaPag) == '1' && isset($formaPag[90])) {
659
                $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...
660
            } else {
661
                //caso tenha mais de uma forma de pagamento ou seja diferente de boleto exibe a
662
                //forma de pagamento e o valor
663
                $y = $this->pagamento($x, $y + 1);
664
            }
665
        }
666
        //coloca os dados dos impostos e totais da NFe
667
        $y = $this->imposto($x, $y + 1);
668
        //coloca os dados do trasnporte
669
        $y = $this->transporte($x, $y + 1);
670
        //itens da DANFE
671
        $nInicial = 0;
672
673
        $y = $this->itens($x, $y + 1, $nInicial, $hDispo1, $pag, $totPag, $hCabecItens);
674
675
        //coloca os dados do ISSQN
676
        if ($linhaISSQN == 1) {
677
            $y = $this->issqn($x, $y + 4);
678
        } else {
679
            $y += 4;
680
        }
681
        //coloca os dados adicionais da NFe
682
        $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...
683
        //coloca o rodapé da página
684
        if ($this->orientacao == 'P') {
685
            $this->rodape($xInic);
686
        } else {
687
            $this->rodape($xInic);
688
        }
689
690
        //loop para páginas seguintes
691
        for ($n = 2; $n <= $totPag; $n ++) {
692
            // fixa as margens
693
            $this->pdf->setMargins($this->margesq, $this->margsup);
694
            //adiciona nova página
695
            $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...
696
            //ajusta espessura das linhas
697
            $this->pdf->setLineWidth(0.1);
698
            //seta a cor do texto para petro
699
            $this->pdf->settextcolor(0, 0, 0);
700
            // posição inicial do relatorio
701
            $x = $this->margesq;
702
            $y = $this->margsup;
703
            //coloca o cabeçalho na página adicional
704
            $y = $this->header($x, $y, $n, $totPag);
705
            //coloca os itens na página adicional
706
            $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...
707
            //coloca o rodapé da página
708
            if ($this->orientacao == 'P') {
709
                $this->rodape($this->margesq);
710
            } else {
711
                $this->rodape($this->margesq);
712
            }
713
            //se estiver na última página e ainda restar itens para inserir, adiciona mais uma página
714
            if ($n == $totPag && $this->qtdeItensProc < $qtdeItens) {
715
                $totPag ++;
716
            }
717
        }
718
    }
719
720
    /**
721
     * anfavea
722
     * Função para transformar o campo cdata do padrão ANFAVEA para
723
     * texto imprimível
724
     *
725
     * @param string $cdata campo CDATA
726
     *
727
     * @return string conteúdo do campo CDATA como string
728
     */
729
    protected function anfaveaDANFE($cdata = '')
730
    {
731
        if ($cdata == '') {
732
            return '';
733
        }
734
        //remove qualquer texto antes ou depois da tag CDATA
735
        $cdata    = str_replace('<![CDATA[', '<CDATA>', $cdata);
736
        $cdata    = str_replace(']]>', '</CDATA>', $cdata);
737
        $cdata    = preg_replace('/\s\s+/', ' ', $cdata);
738
        $cdata    = str_replace("> <", "><", $cdata);
739
        $len      = strlen($cdata);
740
        $startPos = strpos($cdata, '<');
741
        if ($startPos === false) {
742
            return $cdata;
743
        }
744
        for ($x = $len; $x > 0; $x --) {
745
            if (substr($cdata, $x, 1) == '>') {
746
                $endPos = $x;
747
                break;
748
            }
749
        }
750
        if ($x === 0) {
751
            return $cdata;
752
        }
753
        if ($startPos > 0) {
754
            $parte1 = substr($cdata, 0, $startPos);
755
        } else {
756
            $parte1 = '';
757
        }
758
        $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...
759
        if ($endPos < $len) {
760
            $parte3 = substr($cdata, $endPos + 1, $len - $endPos - 1);
761
        } else {
762
            $parte3 = '';
763
        }
764
        $texto = trim($parte1) . ' ' . trim($parte3);
765
        if (strpos($parte2, '<CDATA>') === false) {
766
            $cdata = '<CDATA>' . $parte2 . '</CDATA>';
767
        } else {
768
            $cdata = $parte2;
769
        }
770
        //Retira a tag <FONTE IBPT> (caso existir) pois não é uma estrutura válida XML
771
        $cdata = str_replace('<FONTE IBPT>', '', $cdata);
772
        //carrega o xml CDATA em um objeto DOM
773
        $dom = new Dom();
774
        $dom->loadXML($cdata, LIBXML_NOBLANKS | LIBXML_NOEMPTYTAG);
775
        //$xml = $dom->saveXML();
776
        //grupo CDATA infADprod
777
        $id   = $dom->getElementsByTagName('id')->item(0);
778
        $div  = $dom->getElementsByTagName('div')->item(0);
779
        $entg = $dom->getElementsByTagName('entg')->item(0);
780
        $dest = $dom->getElementsByTagName('dest')->item(0);
781
        $ctl  = $dom->getElementsByTagName('ctl')->item(0);
782
        $ref  = $dom->getElementsByTagName('ref')->item(0);
783
        if (isset($id)) {
784
            if ($id->hasAttributes()) {
785
                foreach ($id->attributes as $attr) {
786
                    $name  = $attr->nodeName;
787
                    $value = $attr->nodeValue;
788
                    $texto .= " $name : $value";
789
                }
790
            }
791
        }
792
        if (isset($div)) {
793
            if ($div->hasAttributes()) {
794
                foreach ($div->attributes as $attr) {
795
                    $name  = $attr->nodeName;
796
                    $value = $attr->nodeValue;
797
                    $texto .= " $name : $value";
798
                }
799
            }
800
        }
801
        if (isset($entg)) {
802
            if ($entg->hasAttributes()) {
803
                foreach ($entg->attributes as $attr) {
804
                    $name  = $attr->nodeName;
805
                    $value = $attr->nodeValue;
806
                    $texto .= " $name : $value";
807
                }
808
            }
809
        }
810
        if (isset($dest)) {
811
            if ($dest->hasAttributes()) {
812
                foreach ($dest->attributes as $attr) {
813
                    $name  = $attr->nodeName;
814
                    $value = $attr->nodeValue;
815
                    $texto .= " $name : $value";
816
                }
817
            }
818
        }
819
        if (isset($ctl)) {
820
            if ($ctl->hasAttributes()) {
821
                foreach ($ctl->attributes as $attr) {
822
                    $name  = $attr->nodeName;
823
                    $value = $attr->nodeValue;
824
                    $texto .= " $name : $value";
825
                }
826
            }
827
        }
828
        if (isset($ref)) {
829
            if ($ref->hasAttributes()) {
830
                foreach ($ref->attributes as $attr) {
831
                    $name  = $attr->nodeName;
832
                    $value = $attr->nodeValue;
833
                    $texto .= " $name : $value";
834
                }
835
            }
836
        }
837
        //grupo CADATA infCpl
838
        $t          = $dom->getElementsByTagName('transmissor')->item(0);
839
        $r          = $dom->getElementsByTagName('receptor')->item(0);
840
        $versao     = ! empty($dom->getElementsByTagName('versao')->item(0)->nodeValue) ?
841
            'Versao:' . $dom->getElementsByTagName('versao')->item(0)->nodeValue . ' ' : '';
842
        $especieNF  = ! empty($dom->getElementsByTagName('especieNF')->item(0)->nodeValue) ?
843
            'Especie:' . $dom->getElementsByTagName('especieNF')->item(0)->nodeValue . ' ' : '';
844
        $fabEntrega = ! empty($dom->getElementsByTagName('fabEntrega')->item(0)->nodeValue) ?
845
            'Entrega:' . $dom->getElementsByTagName('fabEntrega')->item(0)->nodeValue . ' ' : '';
846
        $dca        = ! empty($dom->getElementsByTagName('dca')->item(0)->nodeValue) ?
847
            'dca:' . $dom->getElementsByTagName('dca')->item(0)->nodeValue . ' ' : '';
848
        $texto      .= "" . $versao . $especieNF . $fabEntrega . $dca;
849
        if (isset($t)) {
850
            if ($t->hasAttributes()) {
851
                $texto .= " Transmissor ";
852
                foreach ($t->attributes as $attr) {
853
                    $name  = $attr->nodeName;
854
                    $value = $attr->nodeValue;
855
                    $texto .= " $name : $value";
856
                }
857
            }
858
        }
859
        if (isset($r)) {
860
            if ($r->hasAttributes()) {
861
                $texto .= " Receptor ";
862
                foreach ($r->attributes as $attr) {
863
                    $name  = $attr->nodeName;
864
                    $value = $attr->nodeValue;
865
                    $texto .= " $name : $value";
866
                }
867
            }
868
        }
869
870
        return $texto;
871
    }
872
873
    /**
874
     * Verifica o status da NFe
875
     *
876
     * @return array
877
     */
878
    protected function statusNFe()
879
    {
880
        $resp = [
881
            'status' => true,
882
            'message' => [],
883
            'submessage' => ''
884
        ];
885
        if (!empty($this->epec) && $this->tpEmis == '4') {
886
            return $resp;
887
        }
888
        if (!isset($this->nfeProc)) {
889
            $resp['status'] = false;
890
            $resp['message'][] = 'NFe NÃO PROTOCOLADA';
891
        } else {
892
            if ($this->getTagValue($this->ide, "tpAmb") == '2') {
893
                $resp['status'] = false;
894
                $resp['message'][] =  "NFe EMITIDA EM HOMOLOGAÇÃO";
895
            }
896
            $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...
897
            $cStat = $this->getTagValue($this->nfeProc, "cStat");
898
            if ($cStat == '110' ||
899
                $cStat == '301' ||
900
                $cStat == '302'
901
            ) {
902
                $resp['status'] = false;
903
                $resp['message'][] = "NFe DENEGADA";
904
            } elseif ($cStat == '101'
905
                || $cStat == '151'
906
                || $cStat == '135'
907
                || $cStat == '155'
908
                || $this->cancelFlag === true
909
            ) {
910
                $resp['status'] = false;
911
                $resp['message'][] = "NFe CANCELADA";
912
            } elseif (!empty($retEvento)) {
913
                $infEvento = $retEvento->getElementsByTagName('infEvento')->item(0);
914
                $cStat = $this->getTagValue($infEvento, "cStat");
915
                $tpEvento= $this->getTagValue($infEvento, "tpEvento");
916
                $dhEvento = $this->toDateTime($this->getTagValue($infEvento, "dhRegEvento"))->format("d/m/Y H:i:s");
917
                $nProt = $this->getTagValue($infEvento, "nProt");
918
                if ($tpEvento == '110111' &&
919
                    ($cStat == '101' ||
920
                     $cStat == '151' ||
921
                     $cStat == '135' ||
922
                     $cStat == '155')
923
                ) {
924
                    $resp['status'] = false;
925
                    $resp['message'][] = "NFe CANCELADA";
926
                    $resp['submessage'] = "{$dhEvento} - {$nProt}";
927
                }
928
            }
929
        }
930
        return $resp;
931
    }
932
933
    /**
934
     *header
935
     * Monta o cabelhalho da DANFE (retrato e paisagem)
936
     *
937
     * @param number $x      Posição horizontal inicial, canto esquerdo
938
     * @param number $y      Posição vertical inicial, canto superior
939
     * @param number $pag    Número da Página
940
     * @param number $totPag Total de páginas
941
     *
942
     * @return number Posição vertical final
943
     */
944
    protected function header($x = 0, $y = 0, $pag = '1', $totPag = '1')
945
    {
946
        $oldX = $x;
947
        $oldY = $y;
948
        if ($this->orientacao == 'P') {
949
            $maxW = $this->wPrint;
950
        } else {
951
            if ($pag == 1) { // primeira página
952
                $maxW = $this->wPrint - $this->wCanhoto;
953
            } else { // páginas seguintes
954
                $maxW = $this->wPrint;
955
            }
956
        }
957
        //####################################################################################
958
        //coluna esquerda identificação do emitente
959
        $w = round($maxW * 0.41, 0);
960
        if ($this->orientacao == 'P') {
961
            $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => 'I'];
962
        } else {
963
            $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'];
964
        }
965
        $w1   = $w;
966
        $h    = 32;
967
        $oldY += $h;
968
        $this->pdf->textBox($x, $y, $w, $h);
969
        $texto = 'IDENTIFICAÇÃO DO EMITENTE';
970
        $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...
971
        //estabelecer o alinhamento
972
        //pode ser left L, center C, right R, full logo L
973
        //se for left separar 1/3 da largura para o tamanho da imagem
974
        //os outros 2/3 serão usados para os dados do emitente
975
        //se for center separar 1/2 da altura para o logo e 1/2 para os dados
976
        //se for right separa 2/3 para os dados e o terço seguinte para o logo
977
        //se não houver logo centraliza dos dados do emitente
978
        // coloca o logo
979
        if (! empty($this->logomarca)) {
980
            $logoInfo = getimagesize($this->logomarca);
981
            //largura da imagem em mm
982
            $logoWmm = ($logoInfo[0] / 72) * 25.4;
983
            //altura da imagem em mm
984
            $logoHmm = ($logoInfo[1] / 72) * 25.4;
985
            if ($this->logoAlign == 'L') {
986
                $nImgW = round($w / 3, 0);
987
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
988
                $xImg  = $x + 1;
989
                $yImg  = round(($h - $nImgH) / 2, 0) + $y;
990
                //estabelecer posições do texto
991
                $x1 = round($xImg + $nImgW + 1, 0);
992
                $y1 = round($h / 3 + $y, 0);
993
                $tw = round(2 * $w / 3, 0);
994
            } elseif ($this->logoAlign == 'C') {
995
                $nImgH = round($h / 3, 0);
996
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
997
                $xImg  = round(($w - $nImgW) / 2 + $x, 0);
998
                $yImg  = $y + 3;
999
                $x1    = $x;
1000
                $y1    = round($yImg + $nImgH + 1, 0);
1001
                $tw    = $w;
1002
            } elseif ($this->logoAlign == 'R') {
1003
                $nImgW = round($w / 3, 0);
1004
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
1005
                $xImg  = round($x + ($w - (1 + $nImgW)), 0);
1006
                $yImg  = round(($h - $nImgH) / 2, 0) + $y;
1007
                $x1    = $x;
1008
                $y1    = round($h / 3 + $y, 0);
1009
                $tw    = round(2 * $w / 3, 0);
1010
            } elseif ($this->logoAlign == 'F') {
1011
                $nImgH = round($h - 5, 0);
1012
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
1013
                $xImg  = round(($w - $nImgW) / 2 + $x, 0);
1014
                $yImg  = $y + 3;
1015
                $x1    = $x;
1016
                $y1    = round($yImg + $nImgH + 1, 0);
1017
                $tw    = $w;
1018
            }
1019
            $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...
1020
            $this->pdf->Image($this->logomarca, $xImg, $yImg, $nImgW, $nImgH, 'jpeg');
0 ignored issues
show
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...
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 $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 $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...
1021
        } else {
1022
            $x1 = $x;
1023
            $y1 = round($h / 3 + $y, 0);
1024
            $tw = $w;
1025
        }
1026
        // monta as informações apenas se diferente de full logo
1027
        if ($this->logoAlign !== 'F') {
1028
            //Nome emitente
1029
            $aFont = ['font' => $this->fontePadrao, 'size' => 12, 'style' => 'B'];
1030
            $texto = $this->emit->getElementsByTagName("xNome")->item(0)->nodeValue;
1031
            $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 $x1 does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
Bug introduced by
The variable $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...
1032
            //endereço
1033
            $y1     = $y1 + 5;
1034
            $aFont  = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
1035
            $fone   = ! empty($this->enderEmit->getElementsByTagName("fone")->item(0)->nodeValue)
1036
                ? $this->enderEmit->getElementsByTagName("fone")->item(0)->nodeValue
1037
                : '';
1038
            $lgr    = $this->getTagValue($this->enderEmit, "xLgr");
1039
            $nro    = $this->getTagValue($this->enderEmit, "nro");
1040
            $cpl    = $this->getTagValue($this->enderEmit, "xCpl", " - ");
1041
            $bairro = $this->getTagValue($this->enderEmit, "xBairro");
1042
            $CEP    = $this->getTagValue($this->enderEmit, "CEP");
1043
            $CEP    = $this->formatField($CEP, "#####-###");
1044
            $mun    = $this->getTagValue($this->enderEmit, "xMun");
1045
            $UF     = $this->getTagValue($this->enderEmit, "UF");
1046
            $texto  = $lgr . ", " . $nro . $cpl . "\n" . $bairro . " - "
1047
                . $CEP . "\n" . $mun . " - " . $UF . " "
1048
                . "Fone/Fax: " . $fone;
1049
            $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...
1050
        }
1051
1052
        //####################################################################################
1053
        //coluna central Danfe
1054
        $x  += $w;
1055
        $w  = round($maxW * 0.17, 0);//35;
1056
        $w2 = $w;
1057
        $h  = 32;
1058
        $this->pdf->textBox($x, $y, $w, $h);
1059
1060
        $texto = "DANFE";
1061
        $aFont = ['font' => $this->fontePadrao, 'size' => 14, 'style' => 'B'];
1062
        $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...
1063
        $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
1064
        $texto = 'Documento Auxiliar da Nota Fiscal Eletrônica';
1065
        $h     = 20;
1066
        $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...
1067
1068
        $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
1069
        $texto = '0 - ENTRADA';
1070
        $y1    = $y + 14;
1071
        $h     = 8;
1072
        $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...
1073
        $texto = '1 - SAÍDA';
1074
        $y1    = $y + 17;
1075
        $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...
1076
        //tipo de nF
1077
        $aFont = ['font' => $this->fontePadrao, 'size' => 12, 'style' => 'B'];
1078
        $y1    = $y + 13;
1079
        $h     = 7;
1080
        $texto = $this->ide->getElementsByTagName('tpNF')->item(0)->nodeValue;
1081
        $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...
1082
        //numero da NF
1083
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1084
        $y1    = $y + 20;
1085
        $numNF = str_pad(
1086
            $this->ide->getElementsByTagName('nNF')->item(0)->nodeValue,
1087
            9,
1088
            "0",
1089
            STR_PAD_LEFT
1090
        );
1091
        $numNF = $this->formatField($numNF, "###.###.###");
1092
        $texto = "Nº. " . $numNF;
1093
        $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...
1094
        //Série
1095
        $y1    = $y + 23;
1096
        $serie = str_pad(
1097
            $this->ide->getElementsByTagName('serie')->item(0)->nodeValue,
1098
            3,
1099
            "0",
1100
            STR_PAD_LEFT
1101
        );
1102
        $texto = "Série " . $serie;
1103
        $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...
1104
        //numero paginas
1105
        $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'I'];
1106
        $y1    = $y + 26;
1107
        $texto = "Folha " . $pag . "/" . $totPag;
1108
        $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...
1109
1110
        //####################################################################################
1111
        //coluna codigo de barras
1112
        $x  += $w;
1113
        $w  = ($maxW - $w1 - $w2);//85;
1114
        $w3 = $w;
1115
        $h  = 32;
1116
        $this->pdf->textBox($x, $y, $w, $h);
1117
        $this->pdf->setFillColor(0, 0, 0);
1118
        $chave_acesso = str_replace('NFe', '', $this->infNFe->getAttribute("Id"));
1119
        $bW           = 75;
1120
        $bH           = 12;
1121
        //codigo de barras
1122
        $this->pdf->code128($x + (($w - $bW) / 2), $y + 2, $chave_acesso, $bW, $bH);
1123
        //linhas divisorias
1124
        $this->pdf->line($x, $y + 4 + $bH, $x + $w, $y + 4 + $bH);
1125
        $this->pdf->line($x, $y + 12 + $bH, $x + $w, $y + 12 + $bH);
1126
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1127
        $y1    = $y + 4 + $bH;
1128
        $h     = 7;
1129
        $texto = 'CHAVE DE ACESSO';
1130
        $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...
1131
        $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'];
1132
        $y1    = $y + 8 + $bH;
1133
        $texto = $this->formatField($chave_acesso, $this->formatoChave);
1134
        $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...
1135
        $y1                = $y + 12 + $bH;
1136
        $aFont             = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
1137
        $chaveContingencia = "";
1138
        if (!empty($this->epec) && $this->tpEmis == '4') {
1139
            $cabecalhoProtoAutorizacao = 'NÚMERO DE REGISTRO EPEC';
1140
        } else {
1141
            $cabecalhoProtoAutorizacao = 'PROTOCOLO DE AUTORIZAÇÃO DE USO';
1142
        }
1143
        if (($this->tpEmis == 2 || $this->tpEmis == 5)) {
1144
            $cabecalhoProtoAutorizacao = "DADOS DA NF-E";
1145
            $chaveContingencia         = $this->geraChaveAdicionalDeContingencia();
1146
            $this->pdf->setFillColor(0, 0, 0);
1147
            //codigo de barras
1148
            $this->pdf->code128($x + 11, $y1 + 1, $chaveContingencia, $bW * .9, $bH / 2);
1149
        } else {
1150
            $texto = 'Consulta de autenticidade no portal nacional da NF-e';
1151
            $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...
1152
            $y1    = $y + 16 + $bH;
1153
            $texto = 'www.nfe.fazenda.gov.br/portal ou no site da Sefaz Autorizadora';
1154
            $this->pdf->textBox(
1155
                $x + 2,
1156
                $y1,
1157
                $w - 2,
1158
                $h,
1159
                $texto,
1160
                $aFont,
1161
                'T',
1162
                'C',
1163
                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...
1164
                'http://www.nfe.fazenda.gov.br/portal ou no site da Sefaz Autorizadora'
1165
            );
1166
        }
1167
1168
        //####################################################################################
1169
        //Dados da NF do cabeçalho
1170
        //natureza da operação
1171
        $texto = 'NATUREZA DA OPERAÇÃO';
1172
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1173
        $w     = $w1 + $w2;
1174
        $y     = $oldY;
1175
        $oldY  += $h;
1176
        $x     = $oldX;
1177
        $h     = 7;
1178
        $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...
1179
        $texto = $this->ide->getElementsByTagName("natOp")->item(0)->nodeValue;
1180
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1181
        $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...
1182
        $x += $w;
1183
        $w = $w3;
1184
        //PROTOCOLO DE AUTORIZAÇÃO DE USO ou DADOS da NF-E
1185
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1186
        $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...
1187
        // algumas NFe podem estar sem o protocolo de uso portanto sua existencia deve ser
1188
        // testada antes de tentar obter a informação.
1189
        // NOTA : DANFE sem protocolo deve existir somente no caso de contingência !!!
1190
        // Além disso, existem várias NFes em contingência que eu recebo com protocolo de autorização.
1191
        // Na minha opinião, deveríamos mostra-lo, mas o  manual  da NFe v4.01 diz outra coisa...
1192
        if (($this->tpEmis == 2 || $this->tpEmis == 5) && empty($this->epec)) {
1193
            $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'];
1194
            $texto = $this->formatField(
1195
                $chaveContingencia,
1196
                "#### #### #### #### #### #### #### #### ####"
1197
            );
1198
            $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...
1199
        } else {
1200
            $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1201
            if (!empty($this->epec)) {
1202
                $texto = $this->epec['protocolo'] . ' - ' . $this->epec['data'];
1203
                $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...
1204
            } else {
1205
                if (isset($this->nfeProc)) {
1206
                    $texto  = ! empty($this->nfeProc->getElementsByTagName("nProt")->item(0)->nodeValue)
1207
                        ? $this->nfeProc->getElementsByTagName("nProt")->item(0)->nodeValue
1208
                        : '';
1209
                    $dtHora = $this->toDateTime(
1210
                        $this->nfeProc->getElementsByTagName("dhRecbto")->item(0)->nodeValue
1211
                    );
1212
                    if ($texto != '') {
1213
                        $texto .= "  -  " . $dtHora->format('d/m/Y H:i:s');
1214
                    }
1215
                    $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...
1216
                } else {
1217
                    $texto = '';
1218
                    $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...
1219
                }
1220
            }
1221
        }
1222
        $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...
1223
        //####################################################################################
1224
        //INSCRIÇÃO ESTADUAL
1225
        $w     = round($maxW * 0.250, 0);
1226
        $y     += $h;
1227
        $oldY  += $h;
1228
        $x     = $oldX;
1229
        $texto = 'INSCRIÇÃO ESTADUAL';
1230
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1231
        $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...
1232
        $texto = $this->getTagValue($this->emit, "IE");
1233
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1234
        $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...
1235
        //INSCRIÇÃO MUNICIPAL
1236
        $x     += $w;
1237
        $texto = 'INSCRIÇÃO MUNICIPAL';
1238
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1239
        $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...
1240
        $texto = $this->getTagValue($this->emit, "IM");
1241
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1242
        $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...
1243
        //INSCRIÇÃO ESTADUAL DO SUBST. TRIBUT.
1244
        $x     += $w;
1245
        $texto = 'INSCRIÇÃO ESTADUAL DO SUBST. TRIBUT.';
1246
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1247
        $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...
1248
        $texto = ! empty($this->emit->getElementsByTagName("IEST")->item(0)->nodeValue)
1249
            ? $this->emit->getElementsByTagName("IEST")->item(0)->nodeValue
1250
            : '';
1251
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1252
        $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...
1253
        //CNPJ
1254
        $x     += $w;
1255
        $w     = ($maxW - (3 * $w));
1256
        $texto = 'CNPJ / CPF';
1257
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1258
        $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...
1259
        //Pegando valor do CPF/CNPJ
1260
        if (! empty($this->emit->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1261
            $texto = $this->formatField(
1262
                $this->emit->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1263
                "###.###.###/####-##"
1264
            );
1265
        } else {
1266
            $texto = ! empty($this->emit->getElementsByTagName("CPF")->item(0)->nodeValue)
1267
                ? $this->formatField(
1268
                    $this->emit->getElementsByTagName("CPF")->item(0)->nodeValue,
1269
                    "###.###.###-##"
1270
                )
1271
                : '';
1272
        }
1273
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1274
        $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...
1275
1276
        //####################################################################################
1277
        //Indicação de NF Homologação, cancelamento e falta de protocolo
1278
        $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...
1279
        //indicar cancelamento
1280
        $resp = $this->statusNFe();
1281
        if (!$resp['status']) {
1282
            $n = count($resp['message']);
1283
            $alttot = $n * 15;
1284
            $x = 10;
1285
            $y = $this->hPrint/2 - $alttot/2;
1286
            $h = 15;
1287
            $w = $maxW - (2 * $x);
1288
            $this->pdf->settextcolor(90, 90, 90);
1289
1290
            foreach ($resp['message'] as $msg) {
1291
                $aFont = ['font' => $this->fontePadrao, 'size' => 48, 'style' => 'B'];
1292
                $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...
1293
                $y += $h;
1294
            }
1295
            $texto = $resp['submessage'];
1296
            if (!empty($texto)) {
1297
                $y += 3;
1298
                $h = 5;
1299
                $aFont = ['font' => $this->fontePadrao, 'size' => 20, 'style' => 'B'];
1300
                $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...
1301
                $y += $h;
1302
            }
1303
            $y += 5;
1304
            $w = $maxW - (2 * $x);
1305
            $texto = "SEM VALOR FISCAL";
1306
            $aFont = ['font' => $this->fontePadrao, 'size' => 48, 'style' => 'B'];
1307
            $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...
1308
            $this->pdf->settextcolor(0, 0, 0);
1309
        }
1310
        if (!empty($this->epec) && $this->tpEmis == 4) {
1311
            //EPEC
1312
            $x = 10;
1313
            $y = $this->hPrint - 130;
1314
            $h = 25;
1315
            $w = $maxW - (2 * $x);
1316
            $this->pdf->SetTextColor(200, 200, 200);
1317
            $texto = "DANFE impresso em contingência -\n" .
1318
                "EPEC regularmente recebido pela Receita\n" .
1319
                "Federal do Brasil";
1320
            $aFont = ['font' => $this->fontePadrao, 'size' => 48, 'style' => 'B'];
1321
            $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...
1322
            $this->pdf->SetTextColor(0, 0, 0);
1323
        }
1324
1325
        return $oldY;
1326
    } //fim header
1327
1328
    /**
1329
     * destinatarioDANFE
1330
     * Monta o campo com os dados do destinatário na DANFE. (retrato e paisagem)
1331
     *
1332
     * @name   destinatarioDANFE
1333
     *
1334
     * @param number $x Posição horizontal canto esquerdo
1335
     * @param number $y Posição vertical canto superior
1336
     *
1337
     * @return number Posição vertical final
1338
     */
1339
    protected function destinatarioDANFE($x = 0, $y = 0)
1340
    {
1341
        //####################################################################################
1342
        //DESTINATÁRIO / REMETENTE
1343
        $oldX = $x;
1344
        $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...
1345
        if ($this->orientacao == 'P') {
1346
            $maxW = $this->wPrint;
1347
        } else {
1348
            $maxW = $this->wPrint - $this->wCanhoto;
1349
        }
1350
        $w     = $maxW;
1351
        $h     = 7;
1352
        $texto = 'DESTINATÁRIO / REMETENTE';
1353
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1354
        $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...
1355
        //NOME / RAZÃO SOCIAL
1356
        $w     = round($maxW * 0.61, 0);
1357
        $w1    = $w;
1358
        $y     += 3;
1359
        $texto = 'NOME / RAZÃO SOCIAL';
1360
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1361
        $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...
1362
        $texto = $this->dest->getElementsByTagName("xNome")->item(0)->nodeValue;
1363
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1364
        if ($this->orientacao == 'P') {
1365
            $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...
1366
        } else {
1367
            $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...
1368
        }
1369
        //CNPJ / CPF
1370
        $x     += $w;
1371
        $w     = round($maxW * 0.23, 0);
1372
        $w2    = $w;
1373
        $texto = 'CNPJ / CPF';
1374
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1375
        $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...
1376
        //Pegando valor do CPF/CNPJ
1377
        if (! empty($this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1378
            $texto = $this->formatField(
1379
                $this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1380
                "###.###.###/####-##"
1381
            );
1382
        } else {
1383
            $texto = ! empty($this->dest->getElementsByTagName("CPF")->item(0)->nodeValue)
1384
                ? $this->formatField(
1385
                    $this->dest->getElementsByTagName("CPF")->item(0)->nodeValue,
1386
                    "###.###.###-##"
1387
                )
1388
                : '';
1389
        }
1390
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1391
        $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...
1392
        //DATA DA EMISSÃO
1393
        $x     += $w;
1394
        $w     = $maxW - ($w1 + $w2);
1395
        $wx    = $w;
1396
        $texto = 'DATA DA EMISSÃO';
1397
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1398
        $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...
1399
        $dEmi = ! empty($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue)
1400
            ? $this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue
1401
            : '';
1402
        if ($dEmi == '') {
1403
            $dEmi  = ! empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue)
1404
                ? $this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue
1405
                : '';
1406
            $aDemi = explode('T', $dEmi);
1407
            $dEmi  = $aDemi[0];
1408
        }
1409
        $texto = $this->ymdTodmy($dEmi);
1410
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1411
        if ($this->orientacao == 'P') {
1412
            $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...
1413
        } else {
1414
            $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...
1415
        }
1416
        //ENDEREÇO
1417
        $w     = round($maxW * 0.47, 0);
1418
        $w1    = $w;
1419
        $y     += $h;
1420
        $x     = $oldX;
1421
        $texto = 'ENDEREÇO';
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("xLgr")->item(0)->nodeValue;
1425
        $texto .= ', ' . $this->dest->getElementsByTagName("nro")->item(0)->nodeValue;
1426
        $texto .= $this->getTagValue($this->dest, "xCpl", " - ");
1427
1428
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1429
        $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...
1430
        //BAIRRO / DISTRITO
1431
        $x     += $w;
1432
        $w     = round($maxW * 0.21, 0);
1433
        $w2    = $w;
1434
        $texto = 'BAIRRO / DISTRITO';
1435
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1436
        $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...
1437
        $texto = $this->dest->getElementsByTagName("xBairro")->item(0)->nodeValue;
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
        //CEP
1441
        $x     += $w;
1442
        $w     = $maxW - $w1 - $w2 - $wx;
1443
        $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...
1444
        $texto = 'CEP';
1445
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1446
        $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...
1447
        $texto = ! empty($this->dest->getElementsByTagName("CEP")->item(0)->nodeValue)
1448
            ? $this->dest->getElementsByTagName("CEP")->item(0)->nodeValue
1449
            : '';
1450
        $texto = $this->formatField($texto, "#####-###");
1451
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1452
        $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...
1453
        //DATA DA SAÍDA
1454
        $x     += $w;
1455
        $w     = $wx;
1456
        $texto = 'DATA DA SAÍDA/ENTRADA';
1457
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1458
        $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...
1459
        $dSaiEnt = ! empty($this->ide->getElementsByTagName("dSaiEnt")->item(0)->nodeValue)
1460
            ? $this->ide->getElementsByTagName("dSaiEnt")->item(0)->nodeValue
1461
            : '';
1462
        if ($dSaiEnt == '') {
1463
            $dSaiEnt  = ! empty($this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue)
1464
                ? $this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue
1465
                : '';
1466
            $aDsaient = explode('T', $dSaiEnt);
1467
            $dSaiEnt  = $aDsaient[0];
1468
        }
1469
        $texto = $this->ymdTodmy($dSaiEnt);
1470
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1471
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1472
        //MUNICÍPIO
1473
        $w     = $w1;
1474
        $y     += $h;
1475
        $x     = $oldX;
1476
        $texto = 'MUNICÍPIO';
1477
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1478
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1479
        $texto = $this->dest->getElementsByTagName("xMun")->item(0)->nodeValue;
1480
        if (strtoupper(trim($texto)) == "EXTERIOR"
1481
            && $this->dest->getElementsByTagName("xPais")->length > 0
1482
        ) {
1483
            $texto .= " - " . $this->dest->getElementsByTagName("xPais")->item(0)->nodeValue;
1484
        }
1485
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1486
        $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...
1487
        //UF
1488
        $x     += $w;
1489
        $w     = 8;
1490
        $texto = 'UF';
1491
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1492
        $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...
1493
        $texto = $this->dest->getElementsByTagName("UF")->item(0)->nodeValue;
1494
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1495
        $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...
1496
        //FONE / FAX
1497
        $x     += $w;
1498
        $w     = round(($maxW - $w1 - $wx - 8) / 2, 0);
1499
        $w3    = $w;
1500
        $texto = 'FONE / FAX';
1501
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1502
        $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...
1503
        $texto = ! empty($this->dest->getElementsByTagName("fone")->item(0)->nodeValue)
1504
            ? $this->dest->getElementsByTagName("fone")->item(0)->nodeValue
1505
            : '';
1506
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1507
        $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...
1508
        //INSCRIÇÃO ESTADUAL
1509
        $x     += $w;
1510
        $w     = $maxW - $w1 - $wx - 8 - $w3;
1511
        $texto = 'INSCRIÇÃO ESTADUAL';
1512
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1513
        $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...
1514
        $IE    = $this->dest->getElementsByTagName("IE");
1515
        $texto = ($IE && $IE->length > 0) ? $IE->item(0)->nodeValue : '';
1516
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1517
        $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...
1518
        //HORA DA SAÍDA
1519
        $x     += $w;
1520
        $w     = $wx;
1521
        $texto = 'HORA DA SAÍDA/ENTRADA';
1522
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1523
        $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...
1524
        $hSaiEnt = ! empty($this->ide->getElementsByTagName("hSaiEnt")->item(0)->nodeValue)
1525
            ? $this->ide->getElementsByTagName("hSaiEnt")->item(0)->nodeValue
1526
            : '';
1527
        if ($hSaiEnt == '') {
1528
            $dhSaiEnt   = ! empty($this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue)
1529
                ? $this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue
1530
                : '';
1531
            $tsDhSaiEnt = $this->toDateTime($dhSaiEnt);
1532
            if ($tsDhSaiEnt) {
1533
                $hSaiEnt = $tsDhSaiEnt->format('H:i:s');
1534
            }
1535
        }
1536
        $texto = $hSaiEnt;
1537
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1538
        $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...
1539
1540
        return ($y + $h);
1541
    } //fim da função destinatarioDANFE
1542
1543
    /**
1544
     * localEntregaDANFE
1545
     * Monta o campo com os dados do local de entrega na DANFE. (retrato e paisagem)
1546
     *
1547
     * @name   localEntregaDANFE
1548
     *
1549
     * @param number $x Posição horizontal canto esquerdo
1550
     * @param number $y Posição vertical canto superior
1551
     *
1552
     * @return number Posição vertical final
1553
     */
1554
    protected function localEntregaDANFE($x = 0, $y = 0)
1555
    {
1556
        //####################################################################################
1557
        //LOCAL DE ENTREGA
1558
        $oldX = $x;
1559
        if ($this->orientacao == 'P') {
1560
            $maxW = $this->wPrint;
1561
        } else {
1562
            $maxW = $this->wPrint - $this->wCanhoto;
1563
        }
1564
        $w     = $maxW;
1565
        $h     = 7;
1566
        $texto = 'INFORMAÇÕES DO LOCAL DE ENTREGA';
1567
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1568
        $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...
1569
        //NOME / RAZÃO SOCIAL
1570
        $w     = round($maxW * 0.61, 0);
1571
        $w1    = $w;
1572
        $y     += 3;
1573
        $texto = 'NOME / RAZÃO SOCIAL';
1574
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1575
        $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...
1576
        $texto = '';
1577
        if ($this->entrega->getElementsByTagName("xNome")->item(0)) {
1578
            $texto = $this->entrega->getElementsByTagName("xNome")->item(0)->nodeValue;
1579
        }
1580
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1581
        if ($this->orientacao == 'P') {
1582
            $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...
1583
        } else {
1584
            $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...
1585
        }
1586
        //CNPJ / CPF
1587
        $x     += $w;
1588
        $w     = round($maxW * 0.23, 0);
1589
        $w2    = $w;
1590
        $texto = 'CNPJ / CPF';
1591
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1592
        $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...
1593
        //Pegando valor do CPF/CNPJ
1594
        if (! empty($this->entrega->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1595
            $texto = $this->formatField(
1596
                $this->entrega->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1597
                "###.###.###/####-##"
1598
            );
1599
        } else {
1600
            $texto = ! empty($this->entrega->getElementsByTagName("CPF")->item(0)->nodeValue) ?
1601
                $this->formatField(
1602
                    $this->entrega->getElementsByTagName("CPF")->item(0)->nodeValue,
1603
                    "###.###.###-##"
1604
                ) : '';
1605
        }
1606
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1607
        $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...
1608
        //INSCRIÇÃO ESTADUAL
1609
        $x     += $w;
1610
        $w     = $maxW - ($w1 + $w2);
1611
        $wx    = $w;
1612
        $texto = 'INSCRIÇÃO ESTADUAL';
1613
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1614
        $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...
1615
        $texto = '';
1616
        if ($this->entrega->getElementsByTagName("IE")->item(0)) {
1617
            $texto = $this->entrega->getElementsByTagName("IE")->item(0)->nodeValue;
1618
        }
1619
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1620
        if ($this->orientacao == 'P') {
1621
            $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...
1622
        } else {
1623
            $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...
1624
        }
1625
        //ENDEREÇO
1626
        $w     = round($maxW * 0.355, 0) + $wx;
1627
        $w1    = $w;
1628
        $y     += $h;
1629
        $x     = $oldX;
1630
        $texto = 'ENDEREÇO';
1631
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1632
        $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...
1633
        $texto = $this->entrega->getElementsByTagName("xLgr")->item(0)->nodeValue;
1634
        $texto .= ', ' . $this->entrega->getElementsByTagName("nro")->item(0)->nodeValue;
1635
        $texto .= $this->getTagValue($this->entrega, "xCpl", " - ");
1636
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1637
        $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...
1638
        //BAIRRO / DISTRITO
1639
        $x     += $w;
1640
        $w     = round($maxW * 0.335, 0);
1641
        $w2    = $w;
1642
        $texto = 'BAIRRO / DISTRITO';
1643
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1644
        $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...
1645
        $texto = $this->entrega->getElementsByTagName("xBairro")->item(0)->nodeValue;
1646
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1647
        $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...
1648
        //CEP
1649
        $x     += $w;
1650
        $w     = $maxW - ($w1 + $w2);
1651
        $texto = 'CEP';
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 = ! empty($this->entrega->getElementsByTagName("CEP")->item(0)->nodeValue) ?
1655
            $this->entrega->getElementsByTagName("CEP")->item(0)->nodeValue : '';
1656
        $texto = $this->formatField($texto, "#####-###");
1657
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1658
        $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...
1659
        //MUNICÍPIO
1660
        $w     = round($maxW * 0.805, 0);
1661
        $w1    = $w;
1662
        $y     += $h;
1663
        $x     = $oldX;
1664
        $texto = 'MUNICÍPIO';
1665
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1666
        $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...
1667
        $texto = $this->entrega->getElementsByTagName("xMun")->item(0)->nodeValue;
1668
        if (strtoupper(trim($texto)) == "EXTERIOR" && $this->entrega->getElementsByTagName("xPais")->length > 0) {
1669
            $texto .= " - " . $this->entrega->getElementsByTagName("xPais")->item(0)->nodeValue;
1670
        }
1671
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1672
        $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...
1673
        //UF
1674
        $x     += $w;
1675
        $w     = 8;
1676
        $texto = 'UF';
1677
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1678
        $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...
1679
        $texto = $this->entrega->getElementsByTagName("UF")->item(0)->nodeValue;
1680
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1681
        $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...
1682
        //FONE / FAX
1683
        $x     += $w;
1684
        $w     = $maxW - $w - $w1;
1685
        $texto = 'FONE / FAX';
1686
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1687
        $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...
1688
        $texto = ! empty($this->entrega->getElementsByTagName("fone")->item(0)->nodeValue) ?
1689
            $this->entrega->getElementsByTagName("fone")->item(0)->nodeValue : '';
1690
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1691
        $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...
1692
1693
        return ($y + $h);
1694
    } //fim da função localEntregaDANFE
1695
1696
    /**
1697
     * localretiradaDANFE
1698
     * Monta o campo com os dados do local de entrega na DANFE. (retrato e paisagem)
1699
     *
1700
     * @name   localretiradaDANFE
1701
     *
1702
     * @param number $x Posição horizontal canto esquerdo
1703
     * @param number $y Posição vertical canto superior
1704
     *
1705
     * @return number Posição vertical final
1706
     */
1707
    protected function localRetiradaDANFE($x = 0, $y = 0)
1708
    {
1709
        //####################################################################################
1710
        //LOCAL DE RETIRADA
1711
        $oldX = $x;
1712
        if ($this->orientacao == 'P') {
1713
            $maxW = $this->wPrint;
1714
        } else {
1715
            $maxW = $this->wPrint - $this->wCanhoto;
1716
        }
1717
        $w     = $maxW;
1718
        $h     = 7;
1719
        $texto = 'INFORMAÇÕES DO LOCAL DE RETIRADA';
1720
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1721
        $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...
1722
        //NOME / RAZÃO SOCIAL
1723
        $w     = round($maxW * 0.61, 0);
1724
        $w1    = $w;
1725
        $y     += 3;
1726
        $texto = 'NOME / RAZÃO SOCIAL';
1727
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1728
        $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...
1729
        $texto = '';
1730
        if ($this->retirada->getElementsByTagName("xNome")->item(0)) {
1731
            $texto = $this->retirada->getElementsByTagName("xNome")->item(0)->nodeValue;
1732
        }
1733
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1734
        if ($this->orientacao == 'P') {
1735
            $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...
1736
        } else {
1737
            $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...
1738
        }
1739
        //CNPJ / CPF
1740
        $x     += $w;
1741
        $w     = round($maxW * 0.23, 0);
1742
        $w2    = $w;
1743
        $texto = 'CNPJ / CPF';
1744
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1745
        $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...
1746
        //Pegando valor do CPF/CNPJ
1747
        if (! empty($this->retirada->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1748
            $texto = $this->formatField(
1749
                $this->retirada->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1750
                "###.###.###/####-##"
1751
            );
1752
        } else {
1753
            $texto = ! empty($this->retirada->getElementsByTagName("CPF")->item(0)->nodeValue) ?
1754
                $this->formatField(
1755
                    $this->retirada->getElementsByTagName("CPF")->item(0)->nodeValue,
1756
                    "###.###.###-##"
1757
                ) : '';
1758
        }
1759
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1760
        $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...
1761
        //INSCRIÇÃO ESTADUAL
1762
        $x     += $w;
1763
        $w     = $maxW - ($w1 + $w2);
1764
        $wx    = $w;
1765
        $texto = 'INSCRIÇÃO ESTADUAL';
1766
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1767
        $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...
1768
        $texto = '';
1769
        if ($this->retirada->getElementsByTagName("IE")->item(0)) {
1770
            $texto = $this->retirada->getElementsByTagName("IE")->item(0)->nodeValue;
1771
        }
1772
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1773
        if ($this->orientacao == 'P') {
1774
            $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...
1775
        } else {
1776
            $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...
1777
        }
1778
        //ENDEREÇO
1779
        $w     = round($maxW * 0.355, 0) + $wx;
1780
        $w1    = $w;
1781
        $y     += $h;
1782
        $x     = $oldX;
1783
        $texto = 'ENDEREÇO';
1784
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1785
        $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...
1786
        $texto = $this->retirada->getElementsByTagName("xLgr")->item(0)->nodeValue;
1787
        $texto .= ', ' . $this->retirada->getElementsByTagName("nro")->item(0)->nodeValue;
1788
        $texto .= $this->getTagValue($this->retirada, "xCpl", " - ");
1789
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1790
        $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...
1791
        //BAIRRO / DISTRITO
1792
        $x     += $w;
1793
        $w     = round($maxW * 0.335, 0);
1794
        $w2    = $w;
1795
        $texto = 'BAIRRO / DISTRITO';
1796
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1797
        $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...
1798
        $texto = $this->retirada->getElementsByTagName("xBairro")->item(0)->nodeValue;
1799
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1800
        $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...
1801
        //CEP
1802
        $x     += $w;
1803
        $w     = $maxW - ($w1 + $w2);
1804
        $texto = 'CEP';
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 = ! empty($this->retirada->getElementsByTagName("CEP")->item(0)->nodeValue) ?
1808
            $this->retirada->getElementsByTagName("CEP")->item(0)->nodeValue : '';
1809
        $texto = $this->formatField($texto, "#####-###");
1810
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1811
        $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...
1812
        //MUNICÍPIO
1813
        $w     = round($maxW * 0.805, 0);
1814
        $w1    = $w;
1815
        $y     += $h;
1816
        $x     = $oldX;
1817
        $texto = 'MUNICÍPIO';
1818
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1819
        $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...
1820
        $texto = $this->retirada->getElementsByTagName("xMun")->item(0)->nodeValue;
1821
        if (strtoupper(trim($texto)) == "EXTERIOR" && $this->retirada->getElementsByTagName("xPais")->length > 0) {
1822
            $texto .= " - " . $this->retirada->getElementsByTagName("xPais")->item(0)->nodeValue;
1823
        }
1824
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1825
        $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...
1826
        //UF
1827
        $x     += $w;
1828
        $w     = 8;
1829
        $texto = 'UF';
1830
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1831
        $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...
1832
        $texto = $this->retirada->getElementsByTagName("UF")->item(0)->nodeValue;
1833
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1834
        $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...
1835
        //FONE / FAX
1836
        $x     += $w;
1837
        $w     = $maxW - $w - $w1;
1838
        $texto = 'FONE / FAX';
1839
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1840
        $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...
1841
        $texto = ! empty($this->retirada->getElementsByTagName("fone")->item(0)->nodeValue) ?
1842
            $this->retirada->getElementsByTagName("fone")->item(0)->nodeValue : '';
1843
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1844
        $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...
1845
1846
        return ($y + $h);
1847
    } //fim da função localRetiradaDANFE
1848
1849
    /**
1850
     * getTextoFatura
1851
     * Gera a String do Texto da Fatura
1852
     *
1853
     * @name   getTextoFatura
1854
     * @return uma String com o texto ou "";
1855
     */
1856
    protected function getTextoFatura()
1857
    {
1858
        if (isset($this->cobr)) {
1859
            $fat = $this->cobr->getElementsByTagName("fat")->item(0);
1860
            if (isset($fat)) {
1861
                if (! empty($this->getTagValue($this->ide, "indPag"))) {
1862
                    $textoIndPag = "";
1863
                    $indPag      = $this->getTagValue($this->ide, "indPag");
1864
                    if ($indPag === "0") {
1865
                        $textoIndPag = "Pagamento à Vista - ";
1866
                    } elseif ($indPag === "1") {
1867
                        $textoIndPag = "Pagamento à Prazo - ";
1868
                    }
1869
                    $nFat  = $this->getTagValue($fat, "nFat", "Fatura: ");
1870
                    $vOrig = $this->getTagValue($fat, "vOrig", " Valor Original: ");
1871
                    $vDesc = $this->getTagValue($fat, "vDesc", " Desconto: ");
1872
                    $vLiq  = $this->getTagValue($fat, "vLiq", " Valor Líquido: ");
1873
                    $texto = $textoIndPag . $nFat . $vOrig . $vDesc . $vLiq;
1874
1875
                    return $texto;
1876
                } else {
1877
                    $pag = $this->dom->getElementsByTagName("pag");
1878
                    if ($tPag = $this->getTagValue($pag->item(0), "tPag")) {
1879
                        return $this->tipoPag($tPag);
1880
                    }
1881
                }
1882
            }
1883
        }
1884
        return "";
1885
    }
1886
1887
    /**
1888
     * sizeExtraTextoFatura
1889
     * Calcula o espaço ocupado pelo texto da fatura. Este espaço só é utilizado quando não houver duplicata.
1890
     *
1891
     * @name   sizeExtraTextoFatura
1892
     * @return integer
1893
     */
1894
    protected function sizeExtraTextoFatura()
1895
    {
1896
        $textoFatura = $this->getTextoFatura();
1897
        //verificar se existem duplicatas
1898
        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...
1899
            return 10;
1900
        }
1901
1902
        return 0;
1903
    }
1904
1905
    /**
1906
     * fatura
1907
     * Monta o campo de duplicatas da DANFE (retrato e paisagem)
1908
     *
1909
     * @name   fatura
1910
     *
1911
     * @param number $x Posição horizontal canto esquerdo
1912
     * @param number $y Posição vertical canto superior
1913
     *
1914
     * @return number Posição vertical final
1915
     */
1916
    protected function fatura($x, $y)
1917
    {
1918
        $linha       = 1;
1919
        $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...
1920
        $oldx        = $x;
1921
        $textoFatura = $this->getTextoFatura();
1922
        //verificar se existem duplicatas
1923
        if ($this->dup->length > 0 || $textoFatura !== "") {
1924
            //#####################################################################
1925
            //FATURA / DUPLICATA
1926
            $texto = "FATURA / DUPLICATA";
1927
            if ($this->orientacao == 'P') {
1928
                $w = $this->wPrint;
1929
            } else {
1930
                $w = 271;
1931
            }
1932
            $h     = 8;
1933
            $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1934
            $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...
1935
            $y       += 3;
1936
            $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...
1937
            $dupcont = 0;
1938
            $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...
1939
            if ($nFat > 7) {
1940
                $myH = 6;
1941
                $myW = $this->wPrint;
1942
                if ($this->orientacao == 'L') {
1943
                    $myW -= $this->wCanhoto;
1944
                }
1945
                $aFont = ['font' => $this->fontePadrao, 'size' => 9, 'style' => ''];
1946
                $texto = "Existem mais de 7 duplicatas registradas, portanto não "
1947
                    . "serão exibidas, confira diretamente pelo XML.";
1948
                $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...
1949
1950
                return ($y + $h - 3);
1951
            }
1952
            if ($textoFatura !== "" && $this->exibirTextoFatura) {
1953
                $myH = 6;
1954
                $myW = $this->wPrint;
1955
                if ($this->orientacao == 'L') {
1956
                    $myW -= $this->wCanhoto;
1957
                }
1958
                $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
1959
                $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...
1960
                $y += $myH + 1;
1961
            }
1962
            if ($this->orientacao == 'P') {
1963
                $w = round($this->wPrint / 7.018, 0) - 1;
1964
            } else {
1965
                $w = 28;
1966
            }
1967
            $increm = 1;
1968
            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...
1969
                $nDup  = ! empty($this->dup->item($k)->getElementsByTagName('nDup')->item(0)->nodeValue)
1970
                    ? $this->dup->item($k)->getElementsByTagName('nDup')->item(0)->nodeValue
1971
                    : '';
1972
                $dDup  = ! empty($this->dup->item($k)->getElementsByTagName('dVenc')->item(0)->nodeValue)
1973
                    ? $this->ymdTodmy($this->dup->item($k)->getElementsByTagName('dVenc')->item(0)->nodeValue)
1974
                    : '';
1975
                $vDup  = ! empty($this->dup->item($k)->getElementsByTagName('vDup')->item(0)->nodeValue)
1976
                    ? 'R$ ' . number_format(
1977
                        $this->dup->item($k)->getElementsByTagName('vDup')->item(0)->nodeValue,
1978
                        2,
1979
                        ",",
1980
                        "."
1981
                    )
1982
                    : '';
1983
                $h     = 8;
1984
                $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...
1985
                if ($nDup != '0' && $nDup != '') {
1986
                    $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1987
                    $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...
1988
                    $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1989
                    $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...
1990
                } else {
1991
                    $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1992
                    $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...
1993
                }
1994
                $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1995
                $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...
1996
                $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1997
                $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...
1998
                $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1999
                $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...
2000
                $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2001
                $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...
2002
                $x       += $w + $increm;
2003
                $dupcont += 1;
2004
                if ($this->orientacao == 'P') {
2005
                    $maxDupCont = 6;
2006
                } else {
2007
                    $maxDupCont = 8;
2008
                }
2009
                if ($dupcont > $maxDupCont) {
2010
                    $y       += 9;
2011
                    $x       = $oldx;
2012
                    $dupcont = 0;
2013
                    $linha   += 1;
2014
                }
2015
                if ($linha == 5) {
2016
                    $linha = 4;
2017
                    break;
2018
                }
2019
            }
2020
            if ($dupcont == 0) {
2021
                $y -= 9;
2022
                $linha --;
2023
            }
2024
2025
            return ($y + $h);
2026
        } else {
2027
            $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...
2028
2029
            return ($y - 2);
2030
        }
2031
    }
2032
2033
    /**
2034
     * pagamento
2035
     * Monta o campo de pagamentos da DANFE (retrato e paisagem) (foi baseada na fatura)
2036
     *
2037
     * @name   pagamento
2038
     *
2039
     * @param number $x Posição horizontal canto esquerdo
2040
     * @param number $y Posição vertical canto superior
2041
     *
2042
     * @return number Posição vertical final
2043
     */
2044
    protected function pagamento($x, $y)
2045
    {
2046
        $linha = 1;
2047
        $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...
2048
        $oldx  = $x;
2049
        //verificar se existem cobranças definidas
2050
        if (isset($this->detPag) && $this->detPag->length > 0) {
2051
            //#####################################################################
2052
            //Tipo de pagamento
2053
            $texto = "PAGAMENTO";
2054
            if ($this->orientacao == 'P') {
2055
                $w = $this->wPrint;
2056
            } else {
2057
                $w = 271;
2058
            }
2059
            $h     = 8;
2060
            $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2061
            $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...
2062
            $y       += 3;
2063
            $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...
2064
            $dupcont = 0;
2065
            if ($this->orientacao == 'P') {
2066
                $w = round($this->wPrint / 7.018, 0) - 1;
2067
            } else {
2068
                $w = 28;
2069
            }
2070
            if ($this->orientacao == 'P') {
2071
                $maxDupCont = 6;
2072
            } else {
2073
                $maxDupCont = 8;
2074
            }
2075
            $increm         = 1;
2076
            $formaPagamento = [
2077
                '01' => 'Dinheiro',
2078
                '02' => 'Cheque',
2079
                '03' => 'Cartão de Crédito',
2080
                '04' => 'Cartão de Débito',
2081
                '05' => 'Crédito Loja',
2082
                '10' => 'Vale Alimentação',
2083
                '11' => 'Vale Refeição',
2084
                '12' => 'Vale Presente',
2085
                '13' => 'Vale Combustível',
2086
                '14' => 'Duplicata Mercantil',
2087
                '15' => 'Boleto',
2088
                '16' => 'Depósito Bancário',
2089
                '17' => 'Pagamento Instantâneo (PIX)',
2090
                '18' => 'Transferência bancária, Carteira Digital',
2091
                '19' => 'Programa de fidelidade, Cashback, Crédito Virtual',
2092
                '90' => 'Sem pagamento',
2093
                '99' => 'Outros'
2094
            ];
2095
            $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...
2096
                '01' => 'Visa',
2097
                '02' => 'Mastercard',
2098
                '03' => 'American',
2099
                '04' => 'Sorocred',
2100
                '05' => 'Diners',
2101
                '06' => 'Elo',
2102
                '07' => 'Hipercard',
2103
                '08' => 'Aura',
2104
                '09' => 'Cabal',
2105
                '99' => 'Outros'
2106
            ];
2107
            foreach ($this->detPag as $k => $d) {
2108
                $fPag  = ! empty($this->detPag->item($k)->getElementsByTagName('tPag')->item(0)->nodeValue)
2109
                    ? $this->detPag->item($k)->getElementsByTagName('tPag')->item(0)->nodeValue
2110
                    : '0';
2111
                $vPag  = ! empty($this->detPag->item($k)->getElementsByTagName('vPag')->item(0)->nodeValue)
2112
                    ? 'R$ ' . number_format(
2113
                        $this->detPag->item($k)->getElementsByTagName('vPag')->item(0)->nodeValue,
2114
                        2,
2115
                        ",",
2116
                        "."
2117
                    )
2118
                    : '';
2119
                $h     = 6;
2120
                $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...
2121
                if (isset($formaPagamento[$fPag])) {
2122
                    /*Exibir Item sem pagamento*/
2123
                    if ($fPag == '90') {
2124
                        continue;
2125
                    }
2126
                    $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2127
                    $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...
2128
                    $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2129
                    $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...
2130
                } else {
2131
                    $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
2132
                    $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...
2133
                }
2134
                $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2135
                $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...
2136
                $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2137
                $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...
2138
                $x       += $w + $increm;
2139
                $dupcont += 1;
2140
2141
                if ($dupcont > $maxDupCont) {
2142
                    $y       += 9;
2143
                    $x       = $oldx;
2144
                    $dupcont = 0;
2145
                    $linha   += 1;
2146
                }
2147
                if ($linha == 5) {
2148
                    $linha = 4;
2149
                    break;
2150
                }
2151
            }
2152
            if ($dupcont == 0) {
2153
                $y -= 9;
2154
                $linha --;
2155
            }
2156
2157
            return ($y + $h);
2158
        } else {
2159
            $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...
2160
2161
            return ($y - 2);
2162
        }
2163
    } //fim da função pagamento
2164
2165
    /**
2166
     * impostoHelper
2167
     * Auxilia a montagem dos campos de impostos e totais da DANFE
2168
     *
2169
     * @name   impostoHelper
2170
     *
2171
     * @param float $x Posição horizontal canto esquerdo
2172
     * @param float $y Posição vertical canto superior
2173
     * @param float $w Largura do campo
2174
     * @param float $h Altura do campo
2175
     * @param float $h Título do campo
2176
     * @param float $h Valor do imposto
2177
     *
2178
     * @return float Sugestão do $x do próximo imposto
2179
     */
2180
    protected function impostoHelper($x, $y, $w, $h, $titulo, $campoImposto)
2181
    {
2182
        $valorImposto = '0,00';
2183
        $the_field    = $this->ICMSTot->getElementsByTagName($campoImposto)->item(0);
2184
        if (isset($the_field)) {
2185
            $the_value = $the_field->nodeValue;
2186
            if (! empty($the_value)) {
2187
                $valorImposto = number_format($the_value, 2, ",", ".");
2188
            }
2189
        }
2190
2191
        $fontTitulo = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2192
        $fontValor  = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2193
        $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...
2194
        $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...
2195
2196
        $next_x = $x + $w;
2197
2198
        return $next_x;
2199
    }
2200
2201
    /**
2202
     * imposto
2203
     * Monta o campo de impostos e totais da DANFE (retrato e paisagem)
2204
     *
2205
     * @param number $x Posição horizontal canto esquerdo
2206
     * @param number $y Posição vertical canto superior
2207
     *
2208
     * @return number Posição vertical final
2209
     */
2210
    protected function imposto($x, $y)
2211
    {
2212
        $x_inicial = $x;
2213
        //#####################################################################
2214
        $campos_por_linha = 9;
2215
        if (! $this->exibirPIS) {
2216
            $campos_por_linha --;
2217
        }
2218
        if (! $this->exibirIcmsInterestadual) {
2219
            $campos_por_linha -= 2;
2220
        }
2221
2222
        if ($this->orientacao == 'P') {
2223
            $maxW       = $this->wPrint;
2224
            $title_size = 31;
2225
        } else {
2226
            $maxW       = $this->wPrint - $this->wCanhoto;
2227
            $title_size = 40;
2228
        }
2229
        $w = $maxW / $campos_por_linha;
2230
2231
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2232
        $texto = "CÁLCULO DO IMPOSTO";
2233
        $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...
2234
        $y += 3;
2235
        $h = 7;
2236
2237
        $x = $this->impostoHelper($x, $y, $w, $h, "BASE DE CÁLC. DO ICMS", "vBC");
2238
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO ICMS", "vICMS");
2239
        $x = $this->impostoHelper($x, $y, $w, $h, "BASE DE CÁLC. ICMS S.T.", "vBCST");
2240
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO ICMS SUBST.", "vST");
2241
        $x = $this->impostoHelper($x, $y, $w, $h, "V. IMP. IMPORTAÇÃO", "vII");
2242
2243
        if ($this->exibirIcmsInterestadual) {
2244
            $x = $this->impostoHelper($x, $y, $w, $h, "V. ICMS UF REMET.", "vICMSUFRemet");
2245
            $x = $this->impostoHelper($x, $y, $w, $h, "V. FCP UF DEST.", "vFCPUFDest");
2246
        }
2247
2248
        if ($this->exibirPIS) {
2249
            $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO PIS", "vPIS");
2250
        }
2251
2252
        $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...
2253
2254
        //
2255
2256
        $y += $h;
2257
        $x = $x_inicial;
2258
2259
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO FRETE", "vFrete");
2260
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO SEGURO", "vSeg");
2261
        $x = $this->impostoHelper($x, $y, $w, $h, "DESCONTO", "vDesc");
2262
        $x = $this->impostoHelper($x, $y, $w, $h, "OUTRAS DESPESAS", "vOutro");
2263
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR TOTAL IPI", "vIPI");
2264
2265
        if ($this->exibirIcmsInterestadual) {
2266
            $x = $this->impostoHelper($x, $y, $w, $h, "V. ICMS UF DEST.", "vICMSUFDest");
2267
            $x = $this->impostoHelper($x, $y, $w, $h, "V. TOT. TRIB.", "vTotTrib");
2268
        }
2269
        if ($this->exibirPIS) {
2270
            $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DA COFINS", "vCOFINS");
2271
        }
2272
        $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...
2273
2274
        return ($y + $h);
2275
    } //fim imposto
2276
2277
    /**
2278
     * transporte
2279
     * Monta o campo de transportes da DANFE (retrato e paisagem)
2280
     *
2281
     * @name   transporte
2282
     *
2283
     * @param float $x Posição horizontal canto esquerdo
2284
     * @param float $y Posição vertical canto superior
2285
     *
2286
     * @return float Posição vertical final
2287
     */
2288
    protected function transporte($x, $y)
2289
    {
2290
        $oldX = $x;
2291
        if ($this->orientacao == 'P') {
2292
            $maxW = $this->wPrint;
2293
        } else {
2294
            $maxW = $this->wPrint - $this->wCanhoto;
2295
        }
2296
        //#####################################################################
2297
        //TRANSPORTADOR / VOLUMES TRANSPORTADOS
2298
        $texto = "TRANSPORTADOR / VOLUMES TRANSPORTADOS";
2299
        $w     = $maxW;
2300
        $h     = 7;
2301
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2302
        $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...
2303
        //NOME / RAZÃO SOCIAL
2304
        $w1    = $maxW * 0.29;
2305
        $y     += 3;
2306
        $texto = 'NOME / RAZÃO SOCIAL';
2307
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2308
        $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...
2309
        if (isset($this->transporta)) {
2310
            $texto = ! empty($this->transporta->getElementsByTagName("xNome")->item(0)->nodeValue)
2311
                ? $this->transporta->getElementsByTagName("xNome")->item(0)->nodeValue
2312
                : '';
2313
        } else {
2314
            $texto = '';
2315
        }
2316
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2317
        $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...
2318
        //FRETE POR CONTA
2319
        $x     += $w1;
2320
        $w2    = $maxW * 0.15;
2321
        $texto = 'FRETE';
2322
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2323
        $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...
2324
        $tipoFrete = ! empty($this->transp->getElementsByTagName("modFrete")->item(0)->nodeValue)
2325
            ? $this->transp->getElementsByTagName("modFrete")->item(0)->nodeValue
2326
            : '0';
2327
        switch ($tipoFrete) {
2328
            case 0:
2329
                $texto = "0-Por conta do Rem";
2330
                break;
2331
            case 1:
2332
                $texto = "1-Por conta do Dest";
2333
                break;
2334
            case 2:
2335
                $texto = "2-Por conta de Terceiros";
2336
                break;
2337
            case 3:
2338
                $texto = "3-Próprio por conta do Rem";
2339
                break;
2340
            case 4:
2341
                $texto = "4-Próprio por conta do Dest";
2342
                break;
2343
            case 9:
2344
                $texto = "9-Sem Transporte";
2345
                break;
2346
        }
2347
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2348
        $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...
2349
        //CÓDIGO ANTT
2350
        $x     += $w2;
2351
        $texto = 'CÓDIGO ANTT';
2352
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2353
        $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...
2354
        if (isset($this->veicTransp)) {
2355
            $texto = ! empty($this->veicTransp->getElementsByTagName("RNTC")->item(0)->nodeValue)
2356
                ? $this->veicTransp->getElementsByTagName("RNTC")->item(0)->nodeValue
2357
                : '';
2358
        } else {
2359
            $texto = '';
2360
        }
2361
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2362
        $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...
2363
        //PLACA DO VEÍC
2364
        $x     += $w2;
2365
        $texto = 'PLACA DO VEÍCULO';
2366
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2367
        $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...
2368
        if (isset($this->veicTransp)) {
2369
            $texto = ! empty($this->veicTransp->getElementsByTagName("placa")->item(0)->nodeValue)
2370
                ? $this->veicTransp->getElementsByTagName("placa")->item(0)->nodeValue
2371
                : '';
2372
        } elseif (isset($this->reboque)) {
2373
            $texto = ! empty($this->reboque->getElementsByTagName("placa")->item(0)->nodeValue)
2374
                ? $this->reboque->getElementsByTagName("placa")->item(0)->nodeValue
2375
                : '';
2376
        } else {
2377
            $texto = '';
2378
        }
2379
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2380
        $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...
2381
        //UF
2382
        $x     += $w2;
2383
        $w3    = round($maxW * 0.04, 0);
2384
        $texto = 'UF';
2385
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2386
        $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...
2387
        if (isset($this->veicTransp)) {
2388
            $texto = ! empty($this->veicTransp->getElementsByTagName("UF")->item(0)->nodeValue)
2389
                ? $this->veicTransp->getElementsByTagName("UF")->item(0)->nodeValue
2390
                : '';
2391
        } elseif (isset($this->reboque)) {
2392
            $texto = ! empty($this->reboque->getElementsByTagName("UF")->item(0)->nodeValue)
2393
                ? $this->reboque->getElementsByTagName("UF")->item(0)->nodeValue
2394
                : '';
2395
        } else {
2396
            $texto = '';
2397
        }
2398
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2399
        $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...
2400
        //CNPJ / CPF
2401
        $x     += $w3;
2402
        $w     = $maxW - ($w1 + 3 * $w2 + $w3);
2403
        $texto = 'CNPJ / CPF';
2404
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2405
        $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...
2406
        if (isset($this->transporta)) {
2407
            $texto = ! empty($this->transporta->getElementsByTagName("CNPJ")->item(0)->nodeValue)
2408
                ? $this->formatField(
2409
                    $this->transporta->getElementsByTagName("CNPJ")->item(0)->nodeValue,
2410
                    "##.###.###/####-##"
2411
                )
2412
                : '';
2413
            if ($texto == '') {
2414
                $texto = ! empty($this->transporta->getElementsByTagName("CPF")->item(0)->nodeValue)
2415
                    ? $this->formatField(
2416
                        $this->transporta->getElementsByTagName("CPF")->item(0)->nodeValue,
2417
                        "###.###.###-##"
2418
                    )
2419
                    : '';
2420
            }
2421
        } else {
2422
            $texto = '';
2423
        }
2424
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2425
        $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...
2426
        //#####################################################################
2427
        //ENDEREÇO
2428
        $y     += $h;
2429
        $x     = $oldX;
2430
        $h     = 7;
2431
        $w1    = $maxW * 0.44;
2432
        $texto = 'ENDEREÇO';
2433
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2434
        $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...
2435
        if (isset($this->transporta)) {
2436
            $texto = ! empty($this->transporta->getElementsByTagName("xEnder")->item(0)->nodeValue)
2437
                ? $this->transporta->getElementsByTagName("xEnder")->item(0)->nodeValue
2438
                : '';
2439
        } else {
2440
            $texto = '';
2441
        }
2442
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2443
        $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...
2444
        //MUNICÍPIO
2445
        $x     += $w1;
2446
        $w2    = round($maxW * 0.30, 0);
2447
        $texto = 'MUNICÍPIO';
2448
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2449
        $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...
2450
        if (isset($this->transporta)) {
2451
            $texto = ! empty($this->transporta->getElementsByTagName("xMun")->item(0)->nodeValue)
2452
                ? $this->transporta->getElementsByTagName("xMun")->item(0)->nodeValue
2453
                : '';
2454
        } else {
2455
            $texto = '';
2456
        }
2457
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2458
        $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...
2459
        //UF
2460
        $x     += $w2;
2461
        $w3    = round($maxW * 0.04, 0);
2462
        $texto = 'UF';
2463
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2464
        $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...
2465
        if (isset($this->transporta)) {
2466
            $texto = ! empty($this->transporta->getElementsByTagName("UF")->item(0)->nodeValue)
2467
                ? $this->transporta->getElementsByTagName("UF")->item(0)->nodeValue
2468
                : '';
2469
        } else {
2470
            $texto = '';
2471
        }
2472
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2473
        $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...
2474
        //INSCRIÇÃO ESTADUAL
2475
        $x     += $w3;
2476
        $w     = $maxW - ($w1 + $w2 + $w3);
2477
        $texto = 'INSCRIÇÃO ESTADUAL';
2478
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2479
        $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...
2480
        $texto = '';
2481
        if (isset($this->transporta)) {
2482
            if (! empty($this->transporta->getElementsByTagName("IE")->item(0)->nodeValue)) {
2483
                $texto = $this->transporta->getElementsByTagName("IE")->item(0)->nodeValue;
2484
            }
2485
        }
2486
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2487
        $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...
2488
        //Tratar Multiplos volumes
2489
        $volumes     = $this->transp->getElementsByTagName('vol');
2490
        $quantidade  = 0;
2491
        $especie     = '';
2492
        $marca       = '';
2493
        $numero      = '';
2494
        $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...
2495
        $pesoBruto   = 0;
2496
        $pesoLiquido = 0;
2497
        foreach ($volumes as $volume) {
2498
            $quantidade  += ! empty($volume->getElementsByTagName("qVol")->item(0)->nodeValue) ?
2499
                $volume->getElementsByTagName("qVol")->item(0)->nodeValue : 0;
2500
            $pesoBruto   += ! empty($volume->getElementsByTagName("pesoB")->item(0)->nodeValue) ?
2501
                $volume->getElementsByTagName("pesoB")->item(0)->nodeValue : 0;
2502
            $pesoLiquido += ! empty($volume->getElementsByTagName("pesoL")->item(0)->nodeValue) ?
2503
                $volume->getElementsByTagName("pesoL")->item(0)->nodeValue : 0;
2504
            $texto       = ! empty($this->transp->getElementsByTagName("esp")->item(0)->nodeValue) ?
2505
                $this->transp->getElementsByTagName("esp")->item(0)->nodeValue : '';
2506
            if ($texto != $especie && $especie != '') {
2507
                //tem várias especies
2508
                $especie = 'VARIAS';
2509
            } else {
2510
                $especie = $texto;
2511
            }
2512
            $texto = ! empty($this->transp->getElementsByTagName("marca")->item(0)->nodeValue)
2513
                ? $this->transp->getElementsByTagName("marca")->item(0)->nodeValue
2514
                : '';
2515
            if ($texto != $marca && $marca != '') {
2516
                //tem várias especies
2517
                $marca = 'VARIAS';
2518
            } else {
2519
                $marca = $texto;
2520
            }
2521
            $texto = ! empty($this->transp->getElementsByTagName("nVol")->item(0)->nodeValue)
2522
                ? $this->transp->getElementsByTagName("nVol")->item(0)->nodeValue
2523
                : '';
2524
            if ($texto != $numero && $numero != '') {
2525
                //tem várias especies
2526
                $numero = 'VARIOS';
2527
            } else {
2528
                $numero = $texto;
2529
            }
2530
        }
2531
2532
        //#####################################################################
2533
        //QUANTIDADE
2534
        $y     += $h;
2535
        $x     = $oldX;
2536
        $h     = 7;
2537
        $w1    = round($maxW * 0.10, 0);
2538
        $texto = 'QUANTIDADE';
2539
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2540
        $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...
2541
        if (! empty($quantidade)) {
2542
            $texto = $quantidade;
2543
            $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2544
            $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...
2545
        }
2546
        //ESPÉCIE
2547
        $x     += $w1;
2548
        $w2    = round($maxW * 0.17, 0);
2549
        $texto = 'ESPÉCIE';
2550
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2551
        $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...
2552
        $texto = $especie;
2553
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2554
        $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...
2555
        //MARCA
2556
        $x     += $w2;
2557
        $texto = 'MARCA';
2558
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2559
        $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...
2560
        $texto = ! empty($this->transp->getElementsByTagName("marca")->item(0)->nodeValue) ?
2561
            $this->transp->getElementsByTagName("marca")->item(0)->nodeValue : '';
2562
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2563
        $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...
2564
        //NUMERAÇÃO
2565
        $x     += $w2;
2566
        $texto = 'NUMERAÇÃO';
2567
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2568
        $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...
2569
        $texto = $numero;
2570
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2571
        $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...
2572
        //PESO BRUTO
2573
        $x     += $w2;
2574
        $w3    = round($maxW * 0.20, 0);
2575
        $texto = 'PESO BRUTO';
2576
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2577
        $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...
2578
        if (is_numeric($pesoBruto) && $pesoBruto > 0) {
2579
            $texto = number_format($pesoBruto, 3, ",", ".");
2580
        } else {
2581
            $texto = '';
2582
        }
2583
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2584
        $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...
2585
        //PESO LÍQUIDO
2586
        $x     += $w3;
2587
        $w     = $maxW - ($w1 + 3 * $w2 + $w3);
2588
        $texto = 'PESO LÍQUIDO';
2589
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2590
        $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...
2591
        if (is_numeric($pesoLiquido) && $pesoLiquido > 0) {
2592
            $texto = number_format($pesoLiquido, 3, ",", ".");
2593
        } else {
2594
            $texto = '';
2595
        }
2596
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2597
        $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...
2598
2599
        return ($y + $h);
2600
    } //fim transporte
2601
2602
2603
    protected function descricaoProdutoHelper($origem, $campo, $formato)
2604
    {
2605
        $valor_original = $origem->getElementsByTagName($campo)->item(0);
2606
        if (! isset($valor_original)) {
2607
            return "";
2608
        }
2609
        $valor_original = $valor_original->nodeValue;
2610
        $valor          = ! empty($valor_original) ? number_format($valor_original, 2, ",", ".") : '';
2611
2612
        if ($valor != "") {
2613
            return sprintf($formato, $valor);
2614
        }
2615
2616
        return "";
2617
    }
2618
2619
    /**
2620
     * descricaoProduto
2621
     * Monta a string de descrição de cada Produto
2622
     *
2623
     * @name   descricaoProduto
2624
     *
2625
     * @param DOMNode itemProd
2626
     *
2627
     * @return string descricao do produto
2628
     */
2629
    protected function descricaoProduto($itemProd)
2630
    {
2631
        $prod       = $itemProd->getElementsByTagName('prod')->item(0);
2632
        $ICMS       = $itemProd->getElementsByTagName("ICMS")->item(0);
2633
        $ICMSUFDest = $itemProd->getElementsByTagName("ICMSUFDest")->item(0);
2634
        $impostos   = '';
2635
2636
        if (! empty($ICMS)) {
2637
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vBCFCP", " BcFcp=%s");
2638
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pFCP", " pFcp=%s%%");
2639
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vFCP", " vFcp=%s");
2640
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pRedBC", " pRedBC=%s%%");
2641
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pMVAST", " IVA/MVA=%s%%");
2642
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pICMSST", " pIcmsSt=%s%%");
2643
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vBCST", " BcIcmsSt=%s");
2644
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vICMSST", " vIcmsSt=%s");
2645
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vBCFCPST", " BcFcpSt=%s");
2646
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pFCPST", " pFcpSt=%s%%");
2647
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vFCPST", " vFcpSt=%s");
2648
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vBCSTRet", " Retido na compra: BASE ICMS ST=%s");
2649
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pST", " pSt=%s");
2650
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vICMSSTRet", " VALOR ICMS ST=%s");
2651
        }
2652
        if (! empty($ICMSUFDest)) {
2653
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "pFCPUFDest", " pFCPUFDest=%s%%");
2654
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "pICMSUFDest", " pICMSUFDest=%s%%");
2655
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "pICMSInterPart", " pICMSInterPart=%s%%");
2656
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "vFCPUFDest", " vFCPUFDest=%s");
2657
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "vICMSUFDest", " vICMSUFDest=%s");
2658
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "vICMSUFRemet", " vICMSUFRemet=%s");
2659
        }
2660
        $infAdProd = ! empty($itemProd->getElementsByTagName('infAdProd')->item(0)->nodeValue)
2661
            ? substr(
2662
                $this->anfaveaDANFE($itemProd->getElementsByTagName('infAdProd')->item(0)->nodeValue),
2663
                0,
2664
                500
2665
            )
2666
            : '';
2667
        if (! empty($infAdProd)) {
2668
            $infAdProd = trim($infAdProd);
2669
            $infAdProd .= ' ';
2670
        }
2671
        $loteTxt = '';
2672
        $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...
2673
        if (! empty($prod->getElementsByTagName("rastro"))) {
2674
            $rastro = $prod->getElementsByTagName("rastro");
2675
            $i      = 0;
2676
            while ($i < $rastro->length) {
2677
                $dFab = $this->getTagDate($rastro->item($i), 'dFab');
2678
                $datafab = " Fab: " . $dFab;
2679
                $dVal = $this->getTagDate($rastro->item($i), 'dVal');
2680
                $dataval = " Val: " . $dVal;
2681
                
2682
                $loteTxt .= $this->getTagValue($rastro->item($i), 'nLote', ' Lote: ');
2683
                $loteTxt .= $this->getTagValue($rastro->item($i), 'qLote', ' Quant: ');
2684
                $loteTxt .= $datafab; //$this->getTagDate($rastro->item($i), 'dFab', ' Fab: ');
2685
                $loteTxt .= $dataval; //$this->getTagDate($rastro->item($i), 'dVal', ' Val: ');
2686
                $loteTxt .= $this->getTagValue($rastro->item($i), 'vPMC', ' PMC: ');
2687
                $i ++;
2688
            }
2689
            if ($loteTxt != '') {
2690
                $loteTxt .= ' ';
2691
            }
2692
        }
2693
        //NT2013.006 FCI
2694
        $nFCI   = (! empty($itemProd->getElementsByTagName('nFCI')->item(0)->nodeValue)) ?
2695
            ' FCI:' . $itemProd->getElementsByTagName('nFCI')->item(0)->nodeValue : '';
2696
        $tmp_ad = $infAdProd . ($this->descProdInfoComplemento ? $loteTxt . $impostos . $nFCI : '');
2697
        $texto  = $prod->getElementsByTagName("xProd")->item(0)->nodeValue
2698
            . (strlen($tmp_ad) != 0 ? "\n    " . $tmp_ad : '');
2699
        //decodifica os caracteres html no xml
2700
        $texto = html_entity_decode($texto);
2701
        if ($this->descProdQuebraLinha) {
2702
            $texto = str_replace(";", "\n", $texto);
2703
        }
2704
2705
        return $texto;
2706
    }
2707
2708
    /**
2709
     * itens
2710
     * Monta o campo de itens da DANFE (retrato e paisagem)
2711
     *
2712
     * @name   itens
2713
     *
2714
     * @param float $x       Posição horizontal canto esquerdo
2715
     * @param float $y       Posição vertical canto superior
2716
     * @param float $nInicio Número do item inicial
2717
     * @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...
2718
     * @param float $hmax    Altura máxima do campo de itens em mm
2719
     *
2720
     * @return float Posição vertical final
2721
     */
2722
    protected function itens($x, $y, &$nInicio, $hmax, $pag = 0, $totpag = 0, $hCabecItens = 7)
2723
    {
2724
        $oldX = $x;
2725
        $oldY = $y;
2726
        $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...
2727
        //#####################################################################
2728
        //DADOS DOS PRODUTOS / SERVIÇOS
2729
        $texto = "DADOS DOS PRODUTOS / SERVIÇOS";
2730
        if ($this->orientacao == 'P') {
2731
            $w = $this->wPrint;
2732
        } else {
2733
            if ($nInicio < 2) { // primeira página
2734
                $w = $this->wPrint - $this->wCanhoto;
2735
            } else { // páginas seguintes
2736
                $w = $this->wPrint;
2737
            }
2738
        }
2739
        $h     = 4;
2740
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2741
        $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...
2742
        $y += 3;
2743
        //desenha a caixa dos dados dos itens da NF
2744
        $hmax  += 1;
2745
        $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...
2746
        $this->pdf->textBox($x, $y, $w, $hmax);
2747
        //##################################################################################
2748
        // cabecalho LOOP COM OS DADOS DOS PRODUTOS
2749
        //CÓDIGO PRODUTO
2750
        $texto = "CÓDIGO PRODUTO";
2751
        $w1    = round($w * 0.09, 0);
2752
        $h     = 4;
2753
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2754
        $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...
2755
        $this->pdf->line($x + $w1, $y, $x + $w1, $y + $hmax);
2756
        //DESCRIÇÃO DO PRODUTO / SERVIÇO
2757
        $x     += $w1;
2758
        $w2    = round($w * 0.25, 0);
2759
        $texto = 'DESCRIÇÃO DO PRODUTO / SERVIÇO';
2760
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2761
        $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...
2762
        $this->pdf->line($x + $w2, $y, $x + $w2, $y + $hmax);
2763
        //NCM/SH
2764
        $x     += $w2;
2765
        $w3    = round($w * 0.06, 0);
2766
        $texto = 'NCM/SH';
2767
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2768
        $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...
2769
        $this->pdf->line($x + $w3, $y, $x + $w3, $y + $hmax);
2770
        //O/CST ou O/CSOSN
2771
        $x     += $w3;
2772
        $w4    = round($w * 0.05, 0);
2773
        $texto = 'O/CST'; // CRT = 2 ou CRT = 3
2774
        if ($this->getTagValue($this->emit, 'CRT') == '1') {
2775
            $texto = 'O/CSOSN';//Regime do Simples CRT = 1
2776
        }
2777
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2778
        $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...
2779
        $this->pdf->line($x + $w4, $y, $x + $w4, $y + $hmax);
2780
        //CFOP
2781
        $x     += $w4;
2782
        $w5    = round($w * 0.04, 0);
2783
        $texto = 'CFOP';
2784
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2785
        $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...
2786
        $this->pdf->line($x + $w5, $y, $x + $w5, $y + $hmax);
2787
        //UN
2788
        $x     += $w5;
2789
        $w6    = round($w * 0.03, 0);
2790
        $texto = 'UN';
2791
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2792
        $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...
2793
        $this->pdf->line($x + $w6, $y, $x + $w6, $y + $hmax);
2794
        //QUANT
2795
        $x     += $w6;
2796
        $w7    = round($w * 0.08, 0);
2797
        $texto = 'QUANT';
2798
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2799
        $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...
2800
        $this->pdf->line($x + $w7, $y, $x + $w7, $y + $hmax);
2801
        //VALOR UNIT
2802
        $x     += $w7;
2803
        $w8    = round($w * 0.06, 0);
2804
        $texto = 'VALOR UNIT';
2805
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2806
        $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...
2807
        $this->pdf->line($x + $w8, $y, $x + $w8, $y + $hmax);
2808
        //VALOR TOTAL
2809
        $x     += $w8;
2810
        $w9    = round($w * 0.06, 0);
2811
        $texto = 'VALOR TOTAL';
2812
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2813
        $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...
2814
        $this->pdf->line($x + $w9, $y, $x + $w9, $y + $hmax);
2815
        //VALOR DESCONTO
2816
        $x     += $w9;
2817
        $w10   = round($w * 0.05, 0);
2818
        $texto = 'VALOR DESC';
2819
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2820
        $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...
2821
        $this->pdf->line($x + $w10, $y, $x + $w10, $y + $hmax);
2822
        //B.CÁLC ICMS
2823
        $x     += $w10;
2824
        $w11   = round($w * 0.06, 0);
2825
        $texto = 'B.CÁLC ICMS';
2826
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2827
        $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...
2828
        $this->pdf->line($x + $w11, $y, $x + $w11, $y + $hmax);
2829
        //VALOR ICMS
2830
        $x     += $w11;
2831
        $w12   = round($w * 0.06, 0);
2832
        $texto = 'VALOR ICMS';
2833
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2834
        $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...
2835
        $this->pdf->line($x + $w12, $y, $x + $w12, $y + $hmax);
2836
        //VALOR IPI
2837
        $x     += $w12;
2838
        $w13   = round($w * 0.05, 0);
2839
        $texto = 'VALOR IPI';
2840
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2841
        $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...
2842
        $this->pdf->line($x + $w13, $y, $x + $w13, $y + $hmax);
2843
        //ALÍQ. ICMS
2844
        $x     += $w13;
2845
        $w14   = round($w * 0.04, 0);
2846
        $texto = 'ALÍQ. ICMS';
2847
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2848
        $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...
2849
        $this->pdf->line($x + $w14, $y, $x + $w14, $y + $hmax);
2850
        //ALÍQ. IPI
2851
        $x     += $w14;
2852
        $w15   = $w - ($w1 + $w2 + $w3 + $w4 + $w5 + $w6 + $w7 + $w8 + $w9 + $w10 + $w11 + $w12 + $w13 + $w14);
2853
        $texto = 'ALÍQ. IPI';
2854
        $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...
2855
        $this->pdf->line($oldX, $y + $h + 1, $oldX + $w, $y + $h + 1);
2856
        $y += 5;
2857
        //##################################################################################
2858
        // LOOP COM OS DADOS DOS PRODUTOS
2859
        $i      = 0;
2860
        $hUsado = $hCabecItens;
2861
        $aFont  = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
2862
2863
        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...
2864
            if ($i >= $nInicio) {
2865
                $thisItem = $this->det->item($i);
2866
                //carrega as tags do item
2867
                $prod         = $thisItem->getElementsByTagName("prod")->item(0);
2868
                $imposto      = $this->det->item($i)->getElementsByTagName("imposto")->item(0);
2869
                $ICMS         = $imposto->getElementsByTagName("ICMS")->item(0);
2870
                $IPI          = $imposto->getElementsByTagName("IPI")->item(0);
2871
                $textoProduto = $this->descricaoProduto($thisItem);
2872
2873
2874
                // Posição y dos dados das unidades tributaveis.
2875
                $yTrib = $this->pdf->fontSize + .5;
2876
2877
                $uCom = $prod->getElementsByTagName("uCom")->item(0)->nodeValue;
2878
                $vUnCom = $prod->getElementsByTagName("vUnCom")->item(0)->nodeValue;
2879
                $uTrib = $prod->getElementsByTagName("uTrib")->item(0);
2880
                $qTrib = $prod->getElementsByTagName("qTrib")->item(0);
2881
                $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...
2882
                $vUnTrib = !empty($prod->getElementsByTagName("vUnTrib")->item(0)->nodeValue)
2883
                    ? $prod->getElementsByTagName("vUnTrib")->item(0)->nodeValue
2884
                    : 0;
2885
                // A Configuração serve para informar se irá exibir
2886
                //   de forma obrigatória, estando diferente ou não,
2887
                //   a unidade de medida tributária.
2888
                // ========
2889
                // A Exibição será realizada sempre que a unidade comercial for
2890
                //   diferente da unidade de medida tributária.
2891
                // "Nas situações em que o valor unitário comercial for diferente do valor unitário tributável,
2892
                //   ambas as informações deverão estar expressas e identificadas no DANFE, podendo ser
2893
                //   utilizada uma das linhas adicionais previstas, ou o campo de informações adicionais."
2894
                // > Manual Integração - Contribuinte 4.01 - NT2009.006, Item 7.1.5, página 91.
2895
                $mostrarUnidadeTributavel = (
2896
                    !$this->ocultarUnidadeTributavel
2897
                    && !empty($uTrib)
2898
                    && !empty($qTrib)
2899
                    && number_format($vUnCom, 2, ',', '') !== number_format($vUnTrib, 2, ',', '')
2900
                );
2901
2902
                // Informação sobre unidade de medida tributavel.
2903
                // Se não for para exibir a unidade de medida tributavel, então
2904
                // A Escrita irá começar em 0.
2905
                if (! $mostrarUnidadeTributavel) {
2906
                    $yTrib = 0;
2907
                }
2908
                $h = $this->calculeHeight($thisItem, $mostrarUnidadeTributavel);
2909
                $hUsado += $h;
2910
2911
                $yTrib += $y;
2912
                $diffH = $hmax - $hUsado;
2913
2914
                if ($pag != $totpag) {
2915
                    if (1 > $diffH && $i < $totItens) {
2916
                        //ultrapassa a capacidade para uma única página
2917
                        //o restante dos dados serão usados nas proximas paginas
2918
                        $nInicio = $i;
2919
                        break;
2920
                    }
2921
                }
2922
                $y_linha = $y + $h;
2923
                // linha entre itens
2924
                $this->pdf->dashedHLine($oldX, $y_linha, $w, 0.1, 120);
2925
                //corrige o x
2926
                $x = $oldX;
2927
                //codigo do produto
2928
                $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...
2929
                $texto = $prod->getElementsByTagName("cProd")->item(0)->nodeValue;
2930
                $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...
2931
                $x += $w1;
2932
                //DESCRIÇÃO
2933
                if ($this->orientacao == 'P') {
2934
                    $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...
2935
                } else {
2936
                    $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...
2937
                }
2938
                $x += $w2;
2939
                //NCM
2940
                $texto = ! empty($prod->getElementsByTagName("NCM")->item(0)->nodeValue) ?
2941
                    $prod->getElementsByTagName("NCM")->item(0)->nodeValue : '';
2942
                $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...
2943
                $x += $w3;
2944
                //CST
2945
                if (isset($ICMS)) {
2946
                    $origem = $this->getTagValue($ICMS, "orig");
2947
                    $cst    = $this->getTagValue($ICMS, "CST");
2948
                    $csosn  = $this->getTagValue($ICMS, "CSOSN");
2949
                    $texto  = $origem . $cst . $csosn;
2950
                    $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...
2951
                }
2952
                //CFOP
2953
                $x     += $w4;
2954
                $texto = $prod->getElementsByTagName("CFOP")->item(0)->nodeValue;
2955
                $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...
2956
                //Unidade
2957
                $x     += $w5;
2958
                $texto = $uCom;
2959
                $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...
2960
                //Unidade de medida tributável
2961
                $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...
2962
                if ($mostrarUnidadeTributavel) {
2963
                    $texto = $uTrib->nodeValue;
2964
                    $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...
2965
                }
2966
                $x += $w6;
2967
                if ($this->orientacao == 'P') {
2968
                    $alinhamento = 'R';
2969
                } else {
2970
                    $alinhamento = 'R';
2971
                }
2972
                // QTDADE
2973
                $qCom  = $prod->getElementsByTagName("qCom")->item(0);
2974
                $texto = number_format($qCom->nodeValue, $this->qComCasasDec, ",", ".");
2975
                $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...
2976
                // QTDADE Tributável
2977
                if ($mostrarUnidadeTributavel) {
2978
                    $qTrib = $prod->getElementsByTagName("qTrib")->item(0);
2979
                    if (! empty($qTrib)) {
2980
                        $texto = number_format($qTrib->nodeValue, $this->qComCasasDec, ",", ".");
2981
                        $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...
2982
                    }
2983
                }
2984
                $x += $w7;
2985
                // Valor Unitário
2986
                $vUnCom = $prod->getElementsByTagName("vUnCom")->item(0);
2987
                $texto  = number_format($vUnCom->nodeValue, $this->vUnComCasasDec, ",", ".");
2988
                $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...
2989
                // Valor Unitário Tributável
2990
                if ($mostrarUnidadeTributavel) {
2991
                    $vUnTrib = $prod->getElementsByTagName("vUnTrib")->item(0);
2992
                    if (! empty($vUnTrib)) {
2993
                        $texto = number_format($vUnTrib->nodeValue, $this->vUnComCasasDec, ",", ".");
2994
                        $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...
2995
                    }
2996
                }
2997
                $x += $w8;
2998
                // Valor do Produto
2999
                $texto = "";
3000
                if (is_numeric($prod->getElementsByTagName("vProd")->item(0)->nodeValue)) {
3001
                    $texto = number_format($prod->getElementsByTagName("vProd")->item(0)->nodeValue, 2, ",", ".");
3002
                }
3003
                $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...
3004
                $x += $w9;
3005
                //Valor do Desconto
3006
                $vdesc = ! empty($prod->getElementsByTagName("vDesc")->item(0)->nodeValue)
3007
                    ? $prod->getElementsByTagName("vDesc")->item(0)->nodeValue : 0;
3008
3009
                $texto = number_format($vdesc, 2, ",", ".");
3010
                $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...
3011
                //Valor da Base de calculo
3012
                $x += $w10;
3013
                if (isset($ICMS)) {
3014
                    $texto = ! empty($ICMS->getElementsByTagName("vBC")->item(0)->nodeValue)
3015
                        ? number_format(
3016
                            $ICMS->getElementsByTagName("vBC")->item(0)->nodeValue,
3017
                            2,
3018
                            ",",
3019
                            "."
3020
                        )
3021
                        : '0,00';
3022
                    $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...
3023
                }
3024
                //Valor do ICMS
3025
                $x += $w11;
3026
                if (isset($ICMS)) {
3027
                    $texto = ! empty($ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue)
3028
                        ? number_format(
3029
                            $ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue,
3030
                            2,
3031
                            ",",
3032
                            "."
3033
                        )
3034
                        : '0,00';
3035
                    $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...
3036
                }
3037
                //Valor do IPI
3038
                $x += $w12;
3039
                if (isset($IPI)) {
3040
                    $texto = ! empty($IPI->getElementsByTagName("vIPI")->item(0)->nodeValue)
3041
                        ? number_format(
3042
                            $IPI->getElementsByTagName("vIPI")->item(0)->nodeValue,
3043
                            2,
3044
                            ",",
3045
                            "."
3046
                        )
3047
                        : '';
3048
                } else {
3049
                    $texto = '';
3050
                }
3051
                $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...
3052
                // %ICMS
3053
                $x += $w13;
3054
                if (isset($ICMS)) {
3055
                    $texto = ! empty($ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue)
3056
                        ? number_format(
3057
                            $ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue,
3058
                            2,
3059
                            ",",
3060
                            "."
3061
                        )
3062
                        : '0,00';
3063
                    $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...
3064
                }
3065
                //%IPI
3066
                $x += $w14;
3067
                if (isset($IPI)) {
3068
                    $texto = ! empty($IPI->getElementsByTagName("pIPI")->item(0)->nodeValue)
3069
                        ? number_format(
3070
                            $IPI->getElementsByTagName("pIPI")->item(0)->nodeValue,
3071
                            2,
3072
                            ",",
3073
                            "."
3074
                        )
3075
                        : '';
3076
                } else {
3077
                    $texto = '';
3078
                }
3079
                $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...
3080
3081
3082
                // Dados do Veiculo Somente para veiculo 0 Km
3083
                $veicProd = $prod->getElementsByTagName("veicProd")->item(0);
3084
                // Tag somente é gerada para veiculo 0k, e só é permitido um veiculo por NF-e por conta do detran
3085
                // Verifica se a Tag existe
3086
                if (! empty($veicProd)) {
3087
                    $this->dadosItenVeiculoDANFE($oldX, $y, $nInicio, $h, $prod);
3088
                }
3089
3090
3091
                $y += $h;
3092
                $i ++;
3093
                //incrementa o controle dos itens processados.
3094
                $this->qtdeItensProc ++;
3095
            } else {
3096
                $i ++;
3097
            }
3098
        }
3099
3100
        return $oldY + $hmax;
3101
    }
3102
3103
3104
    /**
3105
     * dadosItenVeiculoDANFE
3106
     * Coloca os dados do veiculo abaixo do item da NFe. (retrato e paisagem)
3107
     *
3108
     * @param float  $x    Posição horizontal
3109
     *                     canto esquerdo
3110
     * @param float  $y    Posição vertical
3111
     *                     canto superior
3112
     * @param        $nInicio
3113
     * @param float  $h    altura do campo
3114
     * @param object $prod Contendo todos os dados do item
3115
     */
3116
3117
    protected function dadosItenVeiculoDANFE($x, $y, &$nInicio, $h, $prod)
3118
    {
3119
        $oldX = $x;
3120
        $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...
3121
3122
        if ($this->orientacao == 'P') {
3123
            $w = $this->wPrint;
3124
        } else {
3125
            if ($nInicio < 2) { // primeira página
3126
                $w = $this->wPrint - $this->wCanhoto;
3127
            } else { // páginas seguintes
3128
                $w = $this->wPrint;
3129
            }
3130
        }
3131
3132
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
3133
3134
        $w1 = round($w * 0.09, 0);
3135
3136
        // Tabela Renavam Combustivel
3137
        $renavamCombustivel = [
3138
            1  => 'ALCOOL',
3139
            2  => 'GASOLINA',
3140
            3  => 'DIESEL',
3141
            4  => 'GASOGENIO',
3142
            5  => 'GAS METANO',
3143
            6  => 'ELETRICO/FONTE INTERNA',
3144
            7  => 'ELETRICO/FONTE EXTERNA',
3145
            8  => 'GASOL/GAS NATURAL COMBUSTIVEL',
3146
            9  => 'ALCOOL/GAS NATURAL COMBUSTIVEL',
3147
            10 => 'DIESEL/GAS NATURAL COMBUSTIVEL',
3148
            11 => 'VIDE/CAMPO/OBSERVACAO',
3149
            12 => 'ALCOOL/GAS NATURAL VEICULAR',
3150
            13 => 'GASOLINA/GAS NATURAL VEICULAR',
3151
            14 => 'DIESEL/GAS NATURAL VEICULAR',
3152
            15 => 'GAS NATURAL VEICULAR',
3153
            16 => 'ALCOOL/GASOLINA',
3154
            17 => 'GASOLINA/ALCOOL/GAS NATURAL',
3155
            18 => 'GASOLINA/ELETRICO'
3156
        ];
3157
3158
        $renavamEspecie = [
3159
            1 => 'PASSAGEIRO',
3160
            2 => 'CARGA',
3161
            3 => 'MISTO',
3162
            4 => 'CORRIDA',
3163
            5 => 'TRACAO',
3164
            6 => 'ESPECIAL',
3165
            7 => 'COLECAO'
3166
        ];
3167
3168
        $renavamTiposVeiculos = [
3169
            1  => 'BICICLETA',
3170
            2  => 'CICLOMOTOR',
3171
            3  => 'MOTONETA',
3172
            4  => 'MOTOCICLETA',
3173
            5  => 'TRICICLO',
3174
            6  => 'AUTOMOVEL',
3175
            7  => 'MICROONIBUS',
3176
            8  => 'ONIBUS',
3177
            9  => 'BONDE',
3178
            10 => 'REBOQUE',
3179
            11 => 'SEMI-REBOQUE',
3180
            12 => 'CHARRETE',
3181
            13 => 'CAMIONETA',
3182
            14 => 'CAMINHAO',
3183
            15 => 'CARROCA',
3184
            16 => 'CARRO DE MAO',
3185
            17 => 'CAMINHAO TRATOR',
3186
            18 => 'TRATOR DE RODAS',
3187
            19 => 'TRATOR DE ESTEIRAS',
3188
            20 => 'TRATOR MISTO',
3189
            21 => 'QUADRICICLO',
3190
            22 => 'CHASSI/PLATAFORMA',
3191
            23 => 'CAMINHONETE',
3192
            24 => 'SIDE-CAR',
3193
            25 => 'UTILITARIO',
3194
            26 => 'MOTOR-CASA'
3195
        ];
3196
3197
        $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...
3198
            'F' => 'FOSCA',
3199
            'S' => 'SÓLIDA',
3200
            'P' => 'PEROLIZADA',
3201
            'M' => 'METALICA',
3202
        ];
3203
3204
        $veicProd = $prod->getElementsByTagName("veicProd")->item(0);
3205
3206
        $veiculoChassi     = $veicProd->getElementsByTagName("chassi")->item(0)->nodeValue;
3207
        $veiculoCor        = $veicProd->getElementsByTagName("xCor")->item(0)->nodeValue;
3208
        $veiculoCilindrada = $veicProd->getElementsByTagName("cilin")->item(0)->nodeValue;
3209
        $veiculoCmkg       = $veicProd->getElementsByTagName("CMT")->item(0)->nodeValue;
3210
        $veiculoTipo       = $veicProd->getElementsByTagName("tpVeic")->item(0)->nodeValue;
3211
3212
        $veiculoMotor       = $veicProd->getElementsByTagName("nMotor")->item(0)->nodeValue;
3213
        $veiculoRenavam     = $veicProd->getElementsByTagName("cMod")->item(0)->nodeValue;
3214
        $veiculoHp          = $veicProd->getElementsByTagName("pot")->item(0)->nodeValue;
3215
        $veiculoPlaca       = ''; //$veiculo->getElementsByTagName("CMT")->item(0)->nodeValue;
3216
        $veiculoTipoPintura = $veicProd->getElementsByTagName("tpPint")->item(0)->nodeValue;
3217
        $veiculoMarcaModelo = $prod->getElementsByTagName("xProd")->item(0)->nodeValue;
3218
        $veiculoEspecie     = $veicProd->getElementsByTagName("espVeic")->item(0)->nodeValue;
3219
        $veiculoCombustivel = $veicProd->getElementsByTagName("tpComb")->item(0)->nodeValue;
3220
        $veiculoSerial      = $veicProd->getElementsByTagName("nSerie")->item(0)->nodeValue;
3221
        $veiculoFabricacao  = $veicProd->getElementsByTagName("anoFab")->item(0)->nodeValue;
3222
        $veiculoModelo      = $veicProd->getElementsByTagName("anoMod")->item(0)->nodeValue;
3223
        $veiculoDistancia   = $veicProd->getElementsByTagName("dist")->item(0)->nodeValue;
3224
3225
        $x = $oldX;
3226
3227
        $yVeic = $y + $h;
3228
        $texto = 'Chassi: ............: ' . $veiculoChassi;
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 += $h;
3231
        $texto = 'Cor...................: ' . $veiculoCor;
3232
        $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...
3233
        $yVeic += $h;
3234
        $texto = 'Cilindrada........: ' . $veiculoCilindrada;
3235
        $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...
3236
        $yVeic += $h;
3237
        $texto = 'Cmkg...............: ' . $veiculoCmkg;
3238
        $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...
3239
        $yVeic += $h;
3240
        $texto = 'Tipo.................: ' . ($renavamTiposVeiculos[intval($veiculoTipo)] ?? $veiculoTipo);
3241
        $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...
3242
        $yVeic = $y + $h;
3243
        $xVeic = $x + 65;
3244
        $texto = 'Nº Motor: .........: ' . $veiculoMotor;
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 += $h;
3247
        $texto = 'Renavam...........: ' . $veiculoRenavam;
3248
        $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...
3249
        $yVeic += $h;
3250
        $texto = 'HP.....................: ' . $veiculoHp;
3251
        $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...
3252
        $yVeic += $h;
3253
        $texto = 'Placa.................: ' . $veiculoPlaca;
3254
        $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...
3255
        $yVeic += $h;
3256
        $texto = 'Tipo Pintura......: ' . ($renavamEspecie[intval($veiculoTipoPintura)] ?? $veiculoTipoPintura);
3257
        $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...
3258
        $yVeic = $y + $h;
3259
        $xVeic = $xVeic + 55;
3260
        $texto = 'Marca / Modelo.....: ' . $veiculoMarcaModelo;
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 = 'Especie..................: ' . ($renavamEspecie[intval($veiculoEspecie)] ?? $veiculoEspecie);
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
        $yVeic += $h;
3266
        $texto = 'Combustivel..........: ' . ($renavamCombustivel[intval($veiculoCombustivel)] ?? $veiculoCombustivel);
3267
        $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...
3268
        $yVeic += $h;
3269
        $texto = 'Serial.....................: ' . $veiculoSerial;
3270
        $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...
3271
        $yVeic += $h;
3272
        $texto = 'Ano Fab/Mod........: ' . $veiculoFabricacao . '/' . $veiculoModelo;
3273
        $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...
3274
        $yVeic += $h;
3275
        $texto = 'Distancia Entre Eixos(mm)..: ' . $veiculoDistancia;
3276
        $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...
3277
    }
3278
3279
    /**
3280
     * issqn
3281
     * Monta o campo de serviços do DANFE
3282
     *
3283
     * @name   issqn (retrato e paisagem)
3284
     *
3285
     * @param float $x Posição horizontal canto esquerdo
3286
     * @param float $y Posição vertical canto superior
3287
     *
3288
     * @return float Posição vertical final
3289
     */
3290
    protected function issqn($x, $y)
3291
    {
3292
        $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...
3293
        //#####################################################################
3294
        //CÁLCULO DO ISSQN
3295
        $texto = "CÁLCULO DO ISSQN";
3296
        $w     = $this->wPrint;
3297
        $h     = 7;
3298
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
3299
        $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...
3300
        //INSCRIÇÃO MUNICIPAL
3301
        $y     += 3;
3302
        $w     = round($this->wPrint * 0.23, 0);
3303
        $texto = 'INSCRIÇÃO MUNICIPAL';
3304
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
3305
        $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...
3306
        //inscrição municipal
3307
        $texto = ! empty($this->emit->getElementsByTagName("IM")->item(0)->nodeValue) ?
3308
            $this->emit->getElementsByTagName("IM")->item(0)->nodeValue : '';
3309
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
3310
        $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...
3311
        //VALOR TOTAL DOS SERVIÇOS
3312
        $x     += $w;
3313
        $texto = 'VALOR TOTAL DOS SERVIÇOS';
3314
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
3315
        $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...
3316
        if (isset($this->ISSQNtot)) {
3317
            $texto = ! empty($this->ISSQNtot->getElementsByTagName("vServ")->item(0)->nodeValue) ?
3318
                $this->ISSQNtot->getElementsByTagName("vServ")->item(0)->nodeValue : '';
3319
            $texto = number_format($texto, 2, ",", ".");
3320
        } else {
3321
            $texto = '';
3322
        }
3323
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
3324
        $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...
3325
        //BASE DE CÁLCULO DO ISSQN
3326
        $x     += $w;
3327
        $texto = 'BASE DE CÁLCULO DO ISSQN';
3328
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
3329
        $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...
3330
        if (isset($this->ISSQNtot)) {
3331
            $texto = ! empty($this->ISSQNtot->getElementsByTagName("vBC")->item(0)->nodeValue) ?
3332
                $this->ISSQNtot->getElementsByTagName("vBC")->item(0)->nodeValue : '';
3333
            $texto = ! empty($texto) ? number_format($texto, 2, ",", ".") : '';
3334
        } else {
3335
            $texto = '';
3336
        }
3337
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
3338
        $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...
3339
        //VALOR TOTAL DO ISSQN
3340
        $x += $w;
3341
        if ($this->orientacao == 'P') {
3342
            $w = $this->wPrint - (3 * $w);
3343
        } else {
3344
            $w = $this->wPrint - (3 * $w) - $this->wCanhoto;
3345
        }
3346
        $texto = 'VALOR TOTAL DO ISSQN';
3347
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
3348
        $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...
3349
        if (isset($this->ISSQNtot)) {
3350
            $texto = ! empty($this->ISSQNtot->getElementsByTagName("vISS")->item(0)->nodeValue) ?
3351
                $this->ISSQNtot->getElementsByTagName("vISS")->item(0)->nodeValue : '';
3352
            $texto = ! empty($texto) ? number_format($texto, 2, ",", ".") : '';
3353
        } else {
3354
            $texto = '';
3355
        }
3356
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
3357
        $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...
3358
3359
        return ($y + $h + 1);
3360
    }
3361
3362
    /**
3363
     *dadosAdicionais
3364
     * Coloca o grupo de dados adicionais da NFe. (retrato e paisagem)
3365
     *
3366
     * @name   dadosAdicionais
3367
     *
3368
     * @param float $x Posição horizontal canto esquerdo
3369
     * @param float $y Posição vertical canto superior
3370
     * @param float $h altura do campo
3371
     *
3372
     * @return float Posição vertical final (eixo Y)
3373
     */
3374
    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...
3375
    {
3376
        $y = $this->maxH - (7 + $h);
3377
        //$y = $this->maxH - 20;
3378
        //##################################################################################
3379
        //DADOS ADICIONAIS
3380
        $texto = "DADOS ADICIONAIS";
3381
        if ($this->orientacao == 'P') {
3382
            $w = $this->wPrint;
3383
        } else {
3384
            $w = $this->wPrint - $this->wCanhoto;
3385
        }
3386
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
3387
        $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...
3388
3389
        //INFORMAÇÕES COMPLEMENTARES
3390
        $texto = "INFORMAÇÕES COMPLEMENTARES";
3391
        $y     += 3;
3392
        $w     = $this->wAdic;
3393
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => 'B'];
3394
        $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...
3395
        //o texto com os dados adicionais foi obtido na função montaDANFE
3396
        //e carregado em uma propriedade privada da classe
3397
        //$this->wAdic com a largura do campo
3398
        //$this->textoAdic com o texto completo do campo
3399
        //echo str_replace("\n", "<br>",$this->textoAdic);
3400
        //die;
3401
        $y     += 1;
3402
        $aFont = ['font' => $this->fontePadrao, 'size' => $this->textadicfontsize * $this->pdf->k, 'style' => ''];
3403
        //$aFont = ['font'=>$this->fontePadrao, 'size'=> 5, 'style'=>''];
3404
        $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...
3405
        //RESERVADO AO FISCO
3406
        $texto = "RESERVADO AO FISCO";
3407
        if (isset($this->nfeProc) && $this->nfeProc->getElementsByTagName("xMsg")->length) {
3408
            $texto = $texto . ' ' . $this->nfeProc->getElementsByTagName("xMsg")->item(0)->nodeValue;
3409
        }
3410
        $x += $w;
3411
        $y -= 1;
3412
        if ($this->orientacao == 'P') {
3413
            $w = $this->wPrint - $w;
3414
        } else {
3415
            $w = $this->wPrint - $w - $this->wCanhoto;
3416
        }
3417
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => 'B'];
3418
        $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...
3419
        //inserir texto informando caso de contingência
3420
        // 1 - Normal - emissão normal;
3421
        // 2 - Contingência FS - emissão em contingência com impressão do DANFE em Formulário de Segurança;
3422
        // 3 - Contingência SCAN - emissão em contingência no Sistema de Contingência do Ambiente Nacional;
3423
        // 4 - Contingência EPEC - emissão em contingência com envio da Evento
3424
        //     Prévia de Emissão em Contingência;
3425
        // 5 - Contingência FS-DA - emissão em contingência com impressão do DANFE em Formulário de
3426
        //     Segurança para Impressão de Documento Auxiliar de Documento Fiscal Eletrônico (FS-DA);
3427
        // 6 - Contingência SVC-AN
3428
        // 7 - Contingência SVC-RS
3429
        $xJust  = $this->getTagValue($this->ide, 'xJust', 'Justificativa: ');
3430
        $dhCont = $this->getTagValue($this->ide, 'dhCont', ' Entrada em contingência : ');
3431
        $texto  = '';
3432
        switch ($this->tpEmis) {
3433
            case 4:
3434
                $texto = "CONTINGÊNCIA EPEC\n" . $dhCont . "\n" . $xJust;
3435
                break;
3436
            case 5:
3437
                $texto = "CONTINGÊNCIA FSDA\n" . $dhCont . "\n" . $xJust;
3438
                break;
3439
            case 6:
3440
                $texto = "CONTINGÊNCIA SVC-AN\n" . $dhCont . "\n" . $xJust;
3441
                break;
3442
            case 7:
3443
                $texto = "CONTINGÊNCIA SVC-RS\n" . $dhCont . "\n" . $xJust;
3444
                break;
3445
        }
3446
        $y     += 2;
3447
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
3448
        $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...
3449
3450
        return $y + $h;
3451
    }
3452
3453
    /**
3454
     * rodape
3455
     * Monta o rodapé no final da DANFE com a data/hora de impressão e informações
3456
     * sobre a API NfePHP
3457
     *
3458
     * @param float $x Posição horizontal canto esquerdo
3459
     *
3460
     * @return void
3461
     */
3462
    protected function rodape($x)
3463
    {
3464
        $y = $this->maxH - 4;
3465
        if ($this->orientacao == 'P') {
3466
            $w = $this->wPrint;
3467
        } else {
3468
            $w = $this->wPrint - $this->wCanhoto;
3469
            $x = $this->wCanhoto;
3470
        }
3471
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => 'I'];
3472
        $texto = "Impresso em " . date('d/m/Y') . " as " . date('H:i:s')
3473
            . '  ' . $this->creditos;
3474
        $this->pdf->textBox($x, $y, $w, 0, $texto, $aFont, 'T', 'L', false);
3475
        $texto = $this->powered ? "Powered by NFePHP®" : '';
3476
        $this->pdf->textBox($x, $y, $w, 0, $texto, $aFont, 'T', 'R', false, '');
3477
    }
3478
3479
    /**
3480
     * Monta o canhoto da DANFE (retrato e paisagem)
3481
     *
3482
     * @name   canhotoDANFE
3483
     *
3484
     * @param number $x Posição horizontal canto esquerdo
3485
     * @param number $y Posição vertical canto superior
3486
     *
3487
     * @return number Posição vertical final
3488
     *
3489
     * TODO 21/07/14 fmertins: quando orientação L-paisagem, o canhoto está sendo gerado incorretamente
3490
     */
3491
    protected function canhoto($x, $y)
3492
    {
3493
        $oldX = $x;
3494
        $oldY = $y;
3495
        //#################################################################################
3496
        //canhoto
3497
        //identificação do tipo de nf entrada ou saida
3498
        $tpNF = $this->ide->getElementsByTagName('tpNF')->item(0)->nodeValue;
3499
        if ($tpNF == '0') {
3500
            //NFe de Entrada
3501
            $emitente     = '';
3502
            $emitente     .= $this->dest->getElementsByTagName("xNome")->item(0)->nodeValue . " - ";
3503
            $emitente     .= $this->enderDest->getElementsByTagName("xLgr")->item(0)->nodeValue . ", ";
3504
            $emitente     .= $this->enderDest->getElementsByTagName("nro")->item(0)->nodeValue . " - ";
3505
            $emitente     .= $this->getTagValue($this->enderDest, "xCpl", " - ", " ");
3506
            $emitente     .= $this->enderDest->getElementsByTagName("xBairro")->item(0)->nodeValue . " ";
3507
            $emitente     .= $this->enderDest->getElementsByTagName("xMun")->item(0)->nodeValue . "-";
3508
            $emitente     .= $this->enderDest->getElementsByTagName("UF")->item(0)->nodeValue . "";
3509
            $destinatario = $this->emit->getElementsByTagName("xNome")->item(0)->nodeValue . " ";
3510
        } else {
3511
            //NFe de Saída
3512
            $emitente     = $this->emit->getElementsByTagName("xNome")->item(0)->nodeValue . " ";
3513
            $destinatario = '';
3514
            $destinatario .= $this->dest->getElementsByTagName("xNome")->item(0)->nodeValue . " - ";
3515
            $destinatario .= $this->enderDest->getElementsByTagName("xLgr")->item(0)->nodeValue . ", ";
3516
            $destinatario .= $this->enderDest->getElementsByTagName("nro")->item(0)->nodeValue . " ";
3517
            $destinatario .= $this->getTagValue($this->enderDest, "xCpl", " - ", " ");
3518
            $destinatario .= $this->enderDest->getElementsByTagName("xBairro")->item(0)->nodeValue . " ";
3519
            $destinatario .= $this->enderDest->getElementsByTagName("xMun")->item(0)->nodeValue . "-";
3520
            $destinatario .= $this->enderDest->getElementsByTagName("UF")->item(0)->nodeValue . " ";
3521
        }
3522
        //identificação do sistema emissor
3523
        //linha separadora do canhoto
3524
        if ($this->orientacao == 'P') {
3525
            $w = round($this->wPrint * 0.81, 0);
3526
        } else {
3527
            //linha separadora do canhoto - 238
3528
            //posicao altura
3529
            $y = $this->wPrint - 85;
3530
            //altura
3531
            $w = $this->wPrint - 85 - 24;
3532
        }
3533
        $h = 10;
3534
        //desenha caixa
3535
        $texto      = '';
3536
        $aFont      = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
3537
        $aFontSmall = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
3538
        if ($this->orientacao == 'P') {
3539
            $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...
3540
        } else {
3541
            $this->pdf->textBox90($x, $y, $w, $h, $texto, $aFont, 'C', 'L', 1, '', false);
3542
        }
3543
        $numNF = str_pad($this->ide->getElementsByTagName('nNF')->item(0)->nodeValue, 9, "0", STR_PAD_LEFT);
3544
        $serie = str_pad($this->ide->getElementsByTagName('serie')->item(0)->nodeValue, 3, "0", STR_PAD_LEFT);
3545
        $texto = "RECEBEMOS DE ";
3546
        $texto .= $emitente;
3547
        $texto .= " OS PRODUTOS E/OU SERVIÇOS CONSTANTES DA NOTA FISCAL ELETRÔNICA INDICADA ";
3548
        if ($this->orientacao == 'P') {
3549
            $texto .= "ABAIXO";
3550
        } else {
3551
            $texto .= "AO LADO";
3552
        }
3553
        $texto .= ". EMISSÃO: ";
3554
        $dEmi  = ! empty($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue) ?
3555
            $this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue : '';
3556
        if ($dEmi == '') {
3557
            $dEmi  = ! empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
3558
                $this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue : '';
3559
            $aDemi = explode('T', $dEmi);
3560
            $dEmi  = $aDemi[0];
3561
        }
3562
        $texto .= $this->ymdTodmy($dEmi) . " ";
3563
        $texto .= "VALOR TOTAL: R$ ";
3564
        $texto .= number_format($this->ICMSTot->getElementsByTagName("vNF")->item(0)->nodeValue, 2, ",", ".") . " ";
3565
        $texto .= "DESTINATÁRIO: ";
3566
        $texto .= $destinatario;
3567
        if ($this->orientacao == 'P') {
3568
            $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...
3569
            $x1    = $x + $w;
3570
            $w1    = $this->wPrint - $w;
3571
            $texto = "NF-e";
3572
            $aFont = ['font' => $this->fontePadrao, 'size' => 14, 'style' => 'B'];
3573
            $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...
3574
            $texto = "Nº. " . $this->formatField($numNF, "###.###.###") . " \n";
3575
            $texto .= "Série $serie";
3576
            $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
3577
            $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...
3578
            //DATA DE RECEBIMENTO
3579
            $texto = "DATA DE RECEBIMENTO";
3580
            $y     += $h;
3581
            $w2    = round($this->wPrint * 0.17, 0); //35;
3582
            $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
3583
            $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...
3584
            //IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR
3585
            $x     += $w2;
3586
            $w3    = $w - $w2;
3587
            $texto = "IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR";
3588
            $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...
3589
            $x = $oldX;
3590
            $y += 9;
3591
            $this->pdf->dashedHLine($x, $y, $this->wPrint, 0.1, 80);
3592
            $y += 2;
3593
3594
            return $y;
3595
        } else {
3596
            $x --;
3597
            $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...
3598
            //NUMERO DA NOTA FISCAL LOGO NFE
3599
            $w1    = 18;
3600
            $x1    = $oldX;
3601
            $y     = $oldY;
3602
            $texto = "NF-e";
3603
            $aFont = ['font' => $this->fontePadrao, 'size' => 14, 'style' => 'B'];
3604
            $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...
3605
            $texto = "Nº.\n" . $this->formatField($numNF, "###.###.###") . " \n";
3606
            $texto .= "Série $serie";
3607
            $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'];
3608
            $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...
3609
            //DATA DO RECEBIMENTO
3610
            $texto = "DATA DO RECEBIMENTO";
3611
            $y     = $this->wPrint - 85;
3612
            $x     = 12;
3613
            $w2    = round($this->wPrint * 0.17, 0); //35;
3614
            $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
3615
            $this->pdf->textBox90($x, $y, $w2, 8, $texto, $aFont, 'T', 'L', 1, '');
3616
            //IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR
3617
            $y     -= $w2;
3618
            $w3    = $w - $w2;
3619
            $texto = "IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR";
3620
            $aFont = ['font' => $this->fontePadrao, 'size' => 5.7, 'style' => ''];
3621
            $x     = $this->pdf->textBox90($x, $y, $w3, 8, $texto, $aFont, 'T', 'L', 1, '');
3622
            $this->pdf->dashedVLine(22, $oldY, 0.1, $this->wPrint, 69);
3623
3624
            return $x;
3625
        }
3626
    }
3627
3628
    /**
3629
     * geraInformacoesDaTagCompra
3630
     * Devolve uma string contendo informação sobre as tag <compra><xNEmp>, <xPed> e <xCont> ou string vazia.
3631
     * Aviso: Esta função não leva em consideração dados na tag xPed do item.
3632
     *
3633
     * @name   pGeraInformacoesDaTagCompra
3634
     * @return string com as informacoes dos pedidos.
3635
     */
3636
    protected function geraInformacoesDaTagCompra()
3637
    {
3638
        if (! $this->gerarInformacoesAutomaticas) {
3639
            return '';
3640
        }
3641
        $saida = "";
3642
        if (isset($this->compra)) {
3643
            if (! empty($this->compra->getElementsByTagName("xNEmp")->item(0)->nodeValue)) {
3644
                $saida .= " Nota de Empenho: " . $this->compra->getElementsByTagName("xNEmp")->item(0)->nodeValue;
3645
            }
3646
            if (! empty($this->compra->getElementsByTagName("xPed")->item(0)->nodeValue)) {
3647
                $saida .= " Pedido: " . $this->compra->getElementsByTagName("xPed")->item(0)->nodeValue;
3648
            }
3649
            if (! empty($this->compra->getElementsByTagName("xCont")->item(0)->nodeValue)) {
3650
                $saida .= " Contrato: " . $this->compra->getElementsByTagName("xCont")->item(0)->nodeValue;
3651
            }
3652
        }
3653
3654
        return $saida;
3655
    }
3656
3657
    /**
3658
     * geraChaveAdicionalDeContingencia
3659
     *
3660
     * @name   geraChaveAdicionalDeContingencia
3661
     * @return string chave
3662
     */
3663
    protected function geraChaveAdicionalDeContingencia()
3664
    {
3665
        //cUF tpEmis CNPJ vNF ICMSp ICMSs DD  DV
3666
        // Quantidade de caracteres  02   01      14  14    01    01  02 01
3667
        $forma = "%02d%d%s%014d%01d%01d%02d";
3668
        $cUF   = $this->ide->getElementsByTagName('cUF')->item(0)->nodeValue;
3669
        $CNPJ  = "00000000000000" . $this->emit->getElementsByTagName('CNPJ')->item(0)->nodeValue;
3670
        $CNPJ  = substr($CNPJ, - 14);
3671
        $vNF   = $this->ICMSTot->getElementsByTagName("vNF")->item(0)->nodeValue * 100;
3672
        $vICMS = $this->ICMSTot->getElementsByTagName("vICMS")->item(0)->nodeValue;
3673
        if ($vICMS > 0) {
3674
            $vICMS = 1;
3675
        }
3676
        $icmss = $this->ICMSTot->getElementsByTagName("vBC")->item(0)->nodeValue;
3677
        if ($icmss > 0) {
3678
            $icmss = 1;
3679
        }
3680
        $dEmi = ! empty($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue) ?
3681
            $this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue : '';
3682
        if ($dEmi == '') {
3683
            $dEmi  = ! empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
3684
                $this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue : '';
3685
            $aDemi = explode('T', $dEmi);
3686
            $dEmi  = $aDemi[0];
3687
        }
3688
        $dd    = $dEmi;
3689
        $rpos  = strrpos($dd, '-');
3690
        $dd    = substr($dd, $rpos + 1);
3691
        $chave = sprintf($forma, $cUF, $this->tpEmis, $CNPJ, $vNF, $vICMS, $icmss, $dd);
3692
        $chave = $chave . $this->modulo11($chave);
3693
3694
        return $chave;
3695
    }
3696
3697
    /**
3698
     *  geraInformacoesDasNotasReferenciadas
3699
     * Devolve uma string contendo informação sobre as notas referenciadas. Suporta N notas, eletrônicas ou não
3700
     * Exemplo: NFe Ref.: série: 01 número: 01 emit: 11.111.111/0001-01
3701
     * em 10/2010 [0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000]
3702
     *
3703
     * @return string Informacoes a serem adicionadas no rodapé sobre notas referenciadas.
3704
     */
3705
    protected function geraInformacoesDasNotasReferenciadas()
3706
    {
3707
        if (! $this->gerarInformacoesAutomaticas) {
3708
            return '';
3709
        }
3710
        $formaNfeRef = "\r\nNFe Ref.: série:%d número:%d emit:%s em %s [%s]";
3711
        $formaCTeRef = "\r\nCTe Ref.: série:%d número:%d emit:%s em %s [%s]";
3712
        $formaNfRef  = "\r\nNF  Ref.: série:%d numero:%d emit:%s em %s modelo: %d";
3713
        $formaECFRef = "\r\nECF Ref.: modelo: %s ECF:%d COO:%d";
3714
        $formaNfpRef = "\r\nNFP Ref.: série:%d número:%d emit:%s em %s modelo: %d IE:%s";
3715
        $saida       = '';
3716
        $nfRefs      = $this->ide->getElementsByTagName('NFref');
3717
        if (0 === $nfRefs->length) {
3718
            return $saida;
3719
        }
3720
        if ($nfRefs->length > 2) {
3721
            return 'Existem mais de 2 NF/NFe/ECF/NFP/CTe referenciadas, não serão exibidas na DANFE.';
3722
        }
3723
        foreach ($nfRefs as $nfRef) {
3724
            if (empty($nfRef)) {
3725
                continue;
3726
            }
3727
            $refNFe = $nfRef->getElementsByTagName('refNFe');
3728
            foreach ($refNFe as $chave_acessoRef) {
3729
                $chave_acesso  = $chave_acessoRef->nodeValue;
3730
                $chave_acessoF = $this->formatField($chave_acesso, $this->formatoChave);
3731
                $data          = substr($chave_acesso, 4, 2) . "/20" . substr($chave_acesso, 2, 2);
3732
                $cnpj          = $this->formatField(substr($chave_acesso, 6, 14), "##.###.###/####-##");
3733
                $serie         = substr($chave_acesso, 22, 3);
3734
                $numero        = substr($chave_acesso, 25, 9);
3735
                $saida         .= sprintf($formaNfeRef, $serie, $numero, $cnpj, $data, $chave_acessoF);
3736
            }
3737
            $refNF = $nfRef->getElementsByTagName('refNF');
3738
            foreach ($refNF as $umaRefNFe) {
3739
                $data   = $umaRefNFe->getElementsByTagName('AAMM')->item(0)->nodeValue;
3740
                $cnpj   = $umaRefNFe->getElementsByTagName('CNPJ')->item(0)->nodeValue;
3741
                $mod    = $umaRefNFe->getElementsByTagName('mod')->item(0)->nodeValue;
3742
                $serie  = $umaRefNFe->getElementsByTagName('serie')->item(0)->nodeValue;
3743
                $numero = $umaRefNFe->getElementsByTagName('nNF')->item(0)->nodeValue;
3744
                $data   = substr($data, 2, 2) . "/20" . substr($data, 0, 2);
3745
                $cnpj   = $this->formatField($cnpj, "##.###.###/####-##");
3746
                $saida  .= sprintf($formaNfRef, $serie, $numero, $cnpj, $data, $mod);
3747
            }
3748
            $refCTe = $nfRef->getElementsByTagName('refCTe');
3749
            foreach ($refCTe as $chave_acessoRef) {
3750
                $chave_acesso  = $chave_acessoRef->nodeValue;
3751
                $chave_acessoF = $this->formatField($chave_acesso, $this->formatoChave);
3752
                $data          = substr($chave_acesso, 4, 2) . "/20" . substr($chave_acesso, 2, 2);
3753
                $cnpj          = $this->formatField(substr($chave_acesso, 6, 14), "##.###.###/####-##");
3754
                $serie         = substr($chave_acesso, 22, 3);
3755
                $numero        = substr($chave_acesso, 25, 9);
3756
                $saida         .= sprintf($formaCTeRef, $serie, $numero, $cnpj, $data, $chave_acessoF);
3757
            }
3758
            $refECF = $nfRef->getElementsByTagName('refECF');
3759
            foreach ($refECF as $umaRefNFe) {
3760
                $mod   = $umaRefNFe->getElementsByTagName('mod')->item(0)->nodeValue;
3761
                $nECF  = $umaRefNFe->getElementsByTagName('nECF')->item(0)->nodeValue;
3762
                $nCOO  = $umaRefNFe->getElementsByTagName('nCOO')->item(0)->nodeValue;
3763
                $saida .= sprintf($formaECFRef, $mod, $nECF, $nCOO);
3764
            }
3765
            $refNFP = $nfRef->getElementsByTagName('refNFP');
3766
            foreach ($refNFP as $umaRefNFe) {
3767
                $data   = $umaRefNFe->getElementsByTagName('AAMM')->item(0)->nodeValue;
3768
                $cnpj   = ! empty($umaRefNFe->getElementsByTagName('CNPJ')->item(0)->nodeValue) ?
3769
                    $umaRefNFe->getElementsByTagName('CNPJ')->item(0)->nodeValue :
3770
                    '';
3771
                $cpf    = ! empty($umaRefNFe->getElementsByTagName('CPF')->item(0)->nodeValue) ?
3772
                    $umaRefNFe->getElementsByTagName('CPF')->item(0)->nodeValue : '';
3773
                $mod    = $umaRefNFe->getElementsByTagName('mod')->item(0)->nodeValue;
3774
                $serie  = $umaRefNFe->getElementsByTagName('serie')->item(0)->nodeValue;
3775
                $numero = $umaRefNFe->getElementsByTagName('nNF')->item(0)->nodeValue;
3776
                $ie     = $umaRefNFe->getElementsByTagName('IE')->item(0)->nodeValue;
3777
                $data   = substr($data, 2, 2) . "/20" . substr($data, 0, 2);
3778
                if ($cnpj == '') {
3779
                    $cpf_cnpj = $this->formatField($cpf, "###.###.###-##");
3780
                } else {
3781
                    $cpf_cnpj = $this->formatField($cnpj, "##.###.###/####-##");
3782
                }
3783
                $saida .= sprintf($formaNfpRef, $serie, $numero, $cpf_cnpj, $data, $mod, $ie);
3784
            }
3785
        }
3786
3787
        return $saida;
3788
    }
3789
3790
    private function loadDoc($xml)
3791
    {
3792
        $this->xml = $xml;
3793
        if (! empty($xml)) {
3794
            $this->dom = new Dom();
3795
            $this->dom->loadXML($this->xml);
3796
            if (empty($this->dom->getElementsByTagName("infNFe")->item(0))) {
3797
                throw new \Exception('Isso não é um NFe.');
3798
            }
3799
            $this->nfeProc = $this->dom->getElementsByTagName("nfeProc")->item(0);
3800
            $this->infNFe  = $this->dom->getElementsByTagName("infNFe")->item(0);
3801
            $this->ide     = $this->dom->getElementsByTagName("ide")->item(0);
3802
            if ($this->getTagValue($this->ide, "mod") != '55') {
3803
                throw new \Exception("O xml deve ser NF-e modelo 55.");
3804
            }
3805
            $this->entrega    = $this->dom->getElementsByTagName("entrega")->item(0);
3806
            $this->retirada   = $this->dom->getElementsByTagName("retirada")->item(0);
3807
            $this->emit       = $this->dom->getElementsByTagName("emit")->item(0);
3808
            $this->dest       = $this->dom->getElementsByTagName("dest")->item(0);
3809
            $this->enderEmit  = $this->dom->getElementsByTagName("enderEmit")->item(0);
3810
            $this->enderDest  = $this->dom->getElementsByTagName("enderDest")->item(0);
3811
            $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...
3812
            $this->cobr       = $this->dom->getElementsByTagName("cobr")->item(0);
3813
            $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...
3814
            $this->ICMSTot    = $this->dom->getElementsByTagName("ICMSTot")->item(0);
3815
            $this->ISSQNtot   = $this->dom->getElementsByTagName("ISSQNtot")->item(0);
3816
            $this->transp     = $this->dom->getElementsByTagName("transp")->item(0);
3817
            $this->transporta = $this->dom->getElementsByTagName("transporta")->item(0);
3818
            $this->veicTransp = $this->dom->getElementsByTagName("veicTransp")->item(0);
3819
            $this->detPag     = $this->dom->getElementsByTagName("detPag");
3820
            $this->reboque    = $this->dom->getElementsByTagName("reboque")->item(0);
3821
            $this->infAdic    = $this->dom->getElementsByTagName("infAdic")->item(0);
3822
            $this->compra     = $this->dom->getElementsByTagName("compra")->item(0);
3823
            $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...
3824
            $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...
3825
            $this->infProt    = $this->dom->getElementsByTagName("infProt")->item(0);
3826
        }
3827
    }
3828
3829
    /**
3830
     * @param $item
3831
     *
3832
     * @return float
3833
     */
3834
    protected function calculeHeight($item, $mostrarUnidadeTributavel = false)
3835
    {
3836
        if ($this->orientacao == 'P') {
3837
            $w = $this->wPrint;
3838
        } else {
3839
            $w = $this->wPrint - $this->wCanhoto;
3840
        }
3841
        $w2           = round($w * 0.25, 0);
3842
        $aFont        = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
3843
        $textoProduto = $this->descricaoProduto($item);
3844
        $numlinhas    = $this->pdf->getNumLines($textoProduto, $w2, $aFont);
3845
3846
        if ($mostrarUnidadeTributavel && $numlinhas == 1) {
3847
            $numlinhas ++;
3848
        }
3849
3850
        return round(($numlinhas * $this->pdf->fontSize) + ($numlinhas * 0.5), 2);
3851
    }
3852
}
3853