Completed
Pull Request — master (#430)
by Roberto
02:52
created

Danfe   F

Complexity

Total Complexity 426

Size/Duplication

Total Lines 3784
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 3784
ccs 0
cts 2822
cp 0
rs 0.8
c 0
b 0
f 0
wmc 426
lcom 1
cbo 3

33 Methods

Rating   Name   Duplication   Size   Complexity  
A notaDPEC() 0 4 1
A __construct() 0 4 1
A setVUnComCasasDec() 0 4 1
A setQComCasasDec() 0 4 1
F calculoEspacoVericalDadosAdicionais() 0 84 20
A calculoItensPorPagina() 0 3 1
F monta() 0 272 43
F anfaveaDANFE() 0 140 36
C statusNFe() 0 44 17
F header() 0 383 31
F destinatarioDANFE() 0 203 22
F localEntregaDANFE() 0 141 12
F localRetiradaDANFE() 0 141 12
B getTextoFatura() 0 31 7
A sizeExtraTextoFatura() 0 10 3
F fatura() 0 116 20
F pagamento() 0 116 14
A impostoHelper() 0 20 3
B imposto() 0 66 8
F transporte() 0 313 52
A descricaoProdutoHelper() 0 15 4
F descricaoProduto() 0 73 12
F itens() 0 369 34
B dadosItenVeiculoDANFE() 0 161 3
D issqn() 0 71 11
C dadosAdicionais() 0 84 11
A rodape() 0 16 3
C canhoto() 0 136 9
B geraInformacoesDaTagCompra() 0 20 6
B geraChaveAdicionalDeContingencia() 0 33 6
C geraInformacoesDasNotasReferenciadas() 0 84 14
A loadDoc() 0 38 4
A calculeHeight() 0 18 4

How to fix   Complexity   

Complex Class

Complex classes like Danfe often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Danfe, and based on these observations, apply Extract Interface, too.

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

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
Bug introduced by
The variable $y1 does not seem to be defined for all execution paths leading up to this point.

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
Bug introduced by
The variable $tw does not seem to be defined for all execution paths leading up to this point.

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
984
            //endereço
985
            $y1     = $y1 + 5;
986
            $aFont  = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
987
            $fone   = ! empty($this->enderEmit->getElementsByTagName("fone")->item(0)->nodeValue)
988
                ? $this->enderEmit->getElementsByTagName("fone")->item(0)->nodeValue
989
                : '';
990
            $lgr    = $this->getTagValue($this->enderEmit, "xLgr");
991
            $nro    = $this->getTagValue($this->enderEmit, "nro");
992
            $cpl    = $this->getTagValue($this->enderEmit, "xCpl", " - ");
993
            $bairro = $this->getTagValue($this->enderEmit, "xBairro");
994
            $CEP    = $this->getTagValue($this->enderEmit, "CEP");
995
            $CEP    = $this->formatField($CEP, "#####-###");
996
            $mun    = $this->getTagValue($this->enderEmit, "xMun");
997
            $UF     = $this->getTagValue($this->enderEmit, "UF");
998
            $texto  = $lgr . ", " . $nro . $cpl . "\n" . $bairro . " - "
999
                . $CEP . "\n" . $mun . " - " . $UF . " "
1000
                . "Fone/Fax: " . $fone;
1001
            $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...
1002
        }
1003
1004
        //####################################################################################
1005
        //coluna central Danfe
1006
        $x  += $w;
1007
        $w  = round($maxW * 0.17, 0);//35;
1008
        $w2 = $w;
1009
        $h  = 32;
1010
        $this->pdf->textBox($x, $y, $w, $h);
1011
1012
        $texto = "DANFE";
1013
        $aFont = ['font' => $this->fontePadrao, 'size' => 14, 'style' => 'B'];
1014
        $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...
1015
        $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
1016
        $texto = 'Documento Auxiliar da Nota Fiscal Eletrônica';
1017
        $h     = 20;
1018
        $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...
1019
1020
        $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
1021
        $texto = '0 - ENTRADA';
1022
        $y1    = $y + 14;
1023
        $h     = 8;
1024
        $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...
1025
        $texto = '1 - SAÍDA';
1026
        $y1    = $y + 17;
1027
        $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...
1028
        //tipo de nF
1029
        $aFont = ['font' => $this->fontePadrao, 'size' => 12, 'style' => 'B'];
1030
        $y1    = $y + 13;
1031
        $h     = 7;
1032
        $texto = $this->ide->getElementsByTagName('tpNF')->item(0)->nodeValue;
1033
        $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...
1034
        //numero da NF
1035
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1036
        $y1    = $y + 20;
1037
        $numNF = str_pad(
1038
            $this->ide->getElementsByTagName('nNF')->item(0)->nodeValue,
1039
            9,
1040
            "0",
1041
            STR_PAD_LEFT
1042
        );
1043
        $numNF = $this->formatField($numNF, "###.###.###");
1044
        $texto = "Nº. " . $numNF;
1045
        $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...
1046
        //Série
1047
        $y1    = $y + 23;
1048
        $serie = str_pad(
1049
            $this->ide->getElementsByTagName('serie')->item(0)->nodeValue,
1050
            3,
1051
            "0",
1052
            STR_PAD_LEFT
1053
        );
1054
        $texto = "Série " . $serie;
1055
        $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...
1056
        //numero paginas
1057
        $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'I'];
1058
        $y1    = $y + 26;
1059
        $texto = "Folha " . $pag . "/" . $totPag;
1060
        $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...
1061
1062
        //####################################################################################
1063
        //coluna codigo de barras
1064
        $x  += $w;
1065
        $w  = ($maxW - $w1 - $w2);//85;
1066
        $w3 = $w;
1067
        $h  = 32;
1068
        $this->pdf->textBox($x, $y, $w, $h);
1069
        $this->pdf->setFillColor(0, 0, 0);
1070
        $chave_acesso = str_replace('NFe', '', $this->infNFe->getAttribute("Id"));
1071
        $bW           = 75;
1072
        $bH           = 12;
1073
        //codigo de barras
1074
        $this->pdf->code128($x + (($w - $bW) / 2), $y + 2, $chave_acesso, $bW, $bH);
1075
        //linhas divisorias
1076
        $this->pdf->line($x, $y + 4 + $bH, $x + $w, $y + 4 + $bH);
1077
        $this->pdf->line($x, $y + 12 + $bH, $x + $w, $y + 12 + $bH);
1078
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1079
        $y1    = $y + 4 + $bH;
1080
        $h     = 7;
1081
        $texto = 'CHAVE DE ACESSO';
1082
        $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...
1083
        $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'];
1084
        $y1    = $y + 8 + $bH;
1085
        $texto = $this->formatField($chave_acesso, $this->formatoChave);
1086
        $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...
1087
        $y1                = $y + 12 + $bH;
1088
        $aFont             = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
1089
        $chaveContingencia = "";
1090
        if ($this->notaDpec()) {
1091
            $cabecalhoProtoAutorizacao = 'NÚMERO DE REGISTRO DPEC';
1092
        } else {
1093
            $cabecalhoProtoAutorizacao = 'PROTOCOLO DE AUTORIZAÇÃO DE USO';
1094
        }
1095
        if (($this->tpEmis == 2 || $this->tpEmis == 5) && ! $this->notaDpec()) {
1096
            $cabecalhoProtoAutorizacao = "DADOS DA NF-E";
1097
            $chaveContingencia         = $this->geraChaveAdicionalDeContingencia();
1098
            $this->pdf->setFillColor(0, 0, 0);
1099
            //codigo de barras
1100
            $this->pdf->code128($x + 11, $y1 + 1, $chaveContingencia, $bW * .9, $bH / 2);
1101
        } else {
1102
            $texto = 'Consulta de autenticidade no portal nacional da NF-e';
1103
            $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...
1104
            $y1    = $y + 16 + $bH;
1105
            $texto = 'www.nfe.fazenda.gov.br/portal ou no site da Sefaz Autorizadora';
1106
            $this->pdf->textBox(
1107
                $x + 2,
1108
                $y1,
1109
                $w - 2,
1110
                $h,
1111
                $texto,
1112
                $aFont,
1113
                'T',
1114
                'C',
1115
                0,
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1116
                'http://www.nfe.fazenda.gov.br/portal ou no site da Sefaz Autorizadora'
1117
            );
1118
        }
1119
1120
        //####################################################################################
1121
        //Dados da NF do cabeçalho
1122
        //natureza da operação
1123
        $texto = 'NATUREZA DA OPERAÇÃO';
1124
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1125
        $w     = $w1 + $w2;
1126
        $y     = $oldY;
1127
        $oldY  += $h;
1128
        $x     = $oldX;
1129
        $h     = 7;
1130
        $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...
1131
        $texto = $this->ide->getElementsByTagName("natOp")->item(0)->nodeValue;
1132
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1133
        $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...
1134
        $x += $w;
1135
        $w = $w3;
1136
        //PROTOCOLO DE AUTORIZAÇÃO DE USO ou DADOS da NF-E
1137
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1138
        $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...
1139
        // algumas NFe podem estar sem o protocolo de uso portanto sua existencia deve ser
1140
        // testada antes de tentar obter a informação.
1141
        // NOTA : DANFE sem protocolo deve existir somente no caso de contingência !!!
1142
        // Além disso, existem várias NFes em contingência que eu recebo com protocolo de autorização.
1143
        // Na minha opinião, deveríamos mostra-lo, mas o  manual  da NFe v4.01 diz outra coisa...
1144
        if (($this->tpEmis == 2 || $this->tpEmis == 5) && ! $this->notaDpec()) {
1145
            $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'];
1146
            $texto = $this->formatField(
1147
                $chaveContingencia,
1148
                "#### #### #### #### #### #### #### #### ####"
1149
            );
1150
            $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...
1151
        } else {
1152
            $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1153
            if ($this->notaDpec()) {
1154
                $texto = $this->numdepec;
1155
                $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...
1156
            } else {
1157
                if (isset($this->nfeProc)) {
1158
                    $texto  = ! empty($this->nfeProc->getElementsByTagName("nProt")->item(0)->nodeValue)
1159
                        ? $this->nfeProc->getElementsByTagName("nProt")->item(0)->nodeValue
1160
                        : '';
1161
                    $tsHora = $this->toTimestamp(
1162
                        $this->nfeProc->getElementsByTagName("dhRecbto")->item(0)->nodeValue
1163
                    );
1164
                    if ($texto != '') {
1165
                        $texto .= "  -  " . date('d/m/Y H:i:s', $tsHora);
1166
                    }
1167
                    $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...
1168
                } else {
1169
                    $texto = '';
1170
                    $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...
1171
                }
1172
            }
1173
        }
1174
        $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...
1175
        //####################################################################################
1176
        //INSCRIÇÃO ESTADUAL
1177
        $w     = round($maxW * 0.250, 0);
1178
        $y     += $h;
1179
        $oldY  += $h;
1180
        $x     = $oldX;
1181
        $texto = 'INSCRIÇÃO ESTADUAL';
1182
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1183
        $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...
1184
        $texto = $this->getTagValue($this->emit, "IE");
1185
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1186
        $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...
1187
        //INSCRIÇÃO MUNICIPAL
1188
        $x     += $w;
1189
        $texto = 'INSCRIÇÃO MUNICIPAL';
1190
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1191
        $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...
1192
        $texto = $this->getTagValue($this->emit, "IM");
1193
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1194
        $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...
1195
        //INSCRIÇÃO ESTADUAL DO SUBST. TRIBUT.
1196
        $x     += $w;
1197
        $texto = 'INSCRIÇÃO ESTADUAL DO SUBST. TRIBUT.';
1198
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1199
        $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...
1200
        $texto = ! empty($this->emit->getElementsByTagName("IEST")->item(0)->nodeValue)
1201
            ? $this->emit->getElementsByTagName("IEST")->item(0)->nodeValue
1202
            : '';
1203
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1204
        $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...
1205
        //CNPJ
1206
        $x     += $w;
1207
        $w     = ($maxW - (3 * $w));
1208
        $texto = 'CNPJ';
1209
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1210
        $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...
1211
        //Pegando valor do CPF/CNPJ
1212
        if (! empty($this->emit->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1213
            $texto = $this->formatField(
1214
                $this->emit->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1215
                "###.###.###/####-##"
1216
            );
1217
        } else {
1218
            $texto = ! empty($this->emit->getElementsByTagName("CPF")->item(0)->nodeValue)
1219
                ? $this->formatField(
1220
                    $this->emit->getElementsByTagName("CPF")->item(0)->nodeValue,
1221
                    "###.###.###-##"
1222
                )
1223
                : '';
1224
        }
1225
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1226
        $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...
1227
1228
        //####################################################################################
1229
        //Indicação de NF Homologação, cancelamento e falta de protocolo
1230
        $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...
1231
        //indicar cancelamento
1232
        $resp = $this->statusNFe();
1233
        if (!$resp['status']) {
1234
            $n = count($resp['message']);
1235
            $alttot = $n * 15;
1236
            $x = 10;
1237
            $y = $this->hPrint/2 - $alttot/2;
1238
            $h = 15;
1239
            $w = $maxW - (2 * $x);
1240
            $this->pdf->settextcolor(90, 90, 90);
1241
            
1242
            foreach($resp['message'] as $msg) { 
0 ignored issues
show
Bug introduced by
The expression $resp['message'] of type boolean|array|string is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

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

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

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

Loading history...
1243
                $aFont = ['font' => $this->fontePadrao, 'size' => 48, 'style' => 'B'];
1244
                $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...
1245
                $y += $h; 
1246
            }
1247
            $texto = $resp['submessage'];
1248
            if (!empty($texto)) {
1249
                $y += 3;
1250
                $h = 5;
1251
                $aFont = ['font' => $this->fontePadrao, 'size' => 20, 'style' => 'B'];
1252
                $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...
1253
                $y += $h; 
1254
            }
1255
            $y += 5;
1256
            $w = $maxW - (2 * $x);
1257
            $texto = "SEM VALOR FISCAL";
1258
            $aFont = ['font' => $this->fontePadrao, 'size' => 48, 'style' => 'B'];
1259
            $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...
1260
            $this->pdf->settextcolor(0, 0, 0);
1261
        }
1262
        if ($this->notaDpec() || $this->tpEmis == 4) {
1263
            //DPEC
1264
            $x = 10;
1265
            $y = $this->hPrint - 130;
1266
            $h = 25;
1267
            $w = $maxW - (2 * $x);
1268
            $this->pdf->SetTextColor(200, 200, 200);
1269
            $texto = "DANFE impresso em contingência -\n" .
1270
                "DPEC regularmente recebido pela Receita\n" .
1271
                "Federal do Brasil";
1272
            $aFont = ['font' => $this->fontePadrao, 'size' => 48, 'style' => 'B'];
1273
            $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...
1274
            $this->pdf->SetTextColor(0, 0, 0);
1275
        }
1276
1277
        return $oldY;
1278
    } //fim header
1279
1280
    /**
1281
     * destinatarioDANFE
1282
     * Monta o campo com os dados do destinatário na DANFE. (retrato e paisagem)
1283
     *
1284
     * @name   destinatarioDANFE
1285
     *
1286
     * @param number $x Posição horizontal canto esquerdo
1287
     * @param number $y Posição vertical canto superior
1288
     *
1289
     * @return number Posição vertical final
1290
     */
1291
    protected function destinatarioDANFE($x = 0, $y = 0)
1292
    {
1293
        //####################################################################################
1294
        //DESTINATÁRIO / REMETENTE
1295
        $oldX = $x;
1296
        $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...
1297
        if ($this->orientacao == 'P') {
1298
            $maxW = $this->wPrint;
1299
        } else {
1300
            $maxW = $this->wPrint - $this->wCanhoto;
1301
        }
1302
        $w     = $maxW;
1303
        $h     = 7;
1304
        $texto = 'DESTINATÁRIO / REMETENTE';
1305
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1306
        $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...
1307
        //NOME / RAZÃO SOCIAL
1308
        $w     = round($maxW * 0.61, 0);
1309
        $w1    = $w;
1310
        $y     += 3;
1311
        $texto = 'NOME / RAZÃO SOCIAL';
1312
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1313
        $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...
1314
        $texto = $this->dest->getElementsByTagName("xNome")->item(0)->nodeValue;
1315
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1316
        if ($this->orientacao == 'P') {
1317
            $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...
1318
        } else {
1319
            $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...
1320
        }
1321
        //CNPJ / CPF
1322
        $x     += $w;
1323
        $w     = round($maxW * 0.23, 0);
1324
        $w2    = $w;
1325
        $texto = 'CNPJ / CPF';
1326
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1327
        $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...
1328
        //Pegando valor do CPF/CNPJ
1329
        if (! empty($this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1330
            $texto = $this->formatField(
1331
                $this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1332
                "###.###.###/####-##"
1333
            );
1334
        } else {
1335
            $texto = ! empty($this->dest->getElementsByTagName("CPF")->item(0)->nodeValue)
1336
                ? $this->formatField(
1337
                    $this->dest->getElementsByTagName("CPF")->item(0)->nodeValue,
1338
                    "###.###.###-##"
1339
                )
1340
                : '';
1341
        }
1342
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1343
        $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...
1344
        //DATA DA EMISSÃO
1345
        $x     += $w;
1346
        $w     = $maxW - ($w1 + $w2);
1347
        $wx    = $w;
1348
        $texto = 'DATA DA EMISSÃO';
1349
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1350
        $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...
1351
        $dEmi = ! empty($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue)
1352
            ? $this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue
1353
            : '';
1354
        if ($dEmi == '') {
1355
            $dEmi  = ! empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue)
1356
                ? $this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue
1357
                : '';
1358
            $aDemi = explode('T', $dEmi);
1359
            $dEmi  = $aDemi[0];
1360
        }
1361
        $texto = $this->ymdTodmy($dEmi);
1362
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1363
        if ($this->orientacao == 'P') {
1364
            $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...
1365
        } else {
1366
            $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...
1367
        }
1368
        //ENDEREÇO
1369
        $w     = round($maxW * 0.47, 0);
1370
        $w1    = $w;
1371
        $y     += $h;
1372
        $x     = $oldX;
1373
        $texto = 'ENDEREÇO';
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
        $texto = $this->dest->getElementsByTagName("xLgr")->item(0)->nodeValue;
1377
        $texto .= ', ' . $this->dest->getElementsByTagName("nro")->item(0)->nodeValue;
1378
        $texto .= $this->getTagValue($this->dest, "xCpl", " - ");
1379
1380
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1381
        $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...
1382
        //BAIRRO / DISTRITO
1383
        $x     += $w;
1384
        $w     = round($maxW * 0.21, 0);
1385
        $w2    = $w;
1386
        $texto = 'BAIRRO / DISTRITO';
1387
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1388
        $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...
1389
        $texto = $this->dest->getElementsByTagName("xBairro")->item(0)->nodeValue;
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
        //CEP
1393
        $x     += $w;
1394
        $w     = $maxW - $w1 - $w2 - $wx;
1395
        $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...
1396
        $texto = 'CEP';
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
        $texto = ! empty($this->dest->getElementsByTagName("CEP")->item(0)->nodeValue)
1400
            ? $this->dest->getElementsByTagName("CEP")->item(0)->nodeValue
1401
            : '';
1402
        $texto = $this->formatField($texto, "#####-###");
1403
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1404
        $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...
1405
        //DATA DA SAÍDA
1406
        $x     += $w;
1407
        $w     = $wx;
1408
        $texto = 'DATA DA SAÍDA/ENTRADA';
1409
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1410
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1411
        $dSaiEnt = ! empty($this->ide->getElementsByTagName("dSaiEnt")->item(0)->nodeValue)
1412
            ? $this->ide->getElementsByTagName("dSaiEnt")->item(0)->nodeValue
1413
            : '';
1414
        if ($dSaiEnt == '') {
1415
            $dSaiEnt  = ! empty($this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue)
1416
                ? $this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue
1417
                : '';
1418
            $aDsaient = explode('T', $dSaiEnt);
1419
            $dSaiEnt  = $aDsaient[0];
1420
        }
1421
        $texto = $this->ymdTodmy($dSaiEnt);
1422
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1423
        $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...
1424
        //MUNICÍPIO
1425
        $w     = $w1;
1426
        $y     += $h;
1427
        $x     = $oldX;
1428
        $texto = 'MUNICÍPIO';
1429
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1430
        $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...
1431
        $texto = $this->dest->getElementsByTagName("xMun")->item(0)->nodeValue;
1432
        if (strtoupper(trim($texto)) == "EXTERIOR"
1433
            && $this->dest->getElementsByTagName("xPais")->length > 0
1434
        ) {
1435
            $texto .= " - " . $this->dest->getElementsByTagName("xPais")->item(0)->nodeValue;
1436
        }
1437
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1438
        $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...
1439
        //UF
1440
        $x     += $w;
1441
        $w     = 8;
1442
        $texto = 'UF';
1443
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1444
        $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...
1445
        $texto = $this->dest->getElementsByTagName("UF")->item(0)->nodeValue;
1446
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1447
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1448
        //FONE / FAX
1449
        $x     += $w;
1450
        $w     = round(($maxW - $w1 - $wx - 8) / 2, 0);
1451
        $w3    = $w;
1452
        $texto = 'FONE / FAX';
1453
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1454
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1455
        $texto = ! empty($this->dest->getElementsByTagName("fone")->item(0)->nodeValue)
1456
            ? $this->dest->getElementsByTagName("fone")->item(0)->nodeValue
1457
            : '';
1458
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1459
        $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...
1460
        //INSCRIÇÃO ESTADUAL
1461
        $x     += $w;
1462
        $w     = $maxW - $w1 - $wx - 8 - $w3;
1463
        $texto = 'INSCRIÇÃO ESTADUAL';
1464
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1465
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1466
        $IE    = $this->dest->getElementsByTagName("IE");
1467
        $texto = ($IE && $IE->length > 0) ? $IE->item(0)->nodeValue : '';
1468
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1469
        $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...
1470
        //HORA DA SAÍDA
1471
        $x     += $w;
1472
        $w     = $wx;
1473
        $texto = 'HORA DA SAÍDA/ENTRADA';
1474
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1475
        $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...
1476
        $hSaiEnt = ! empty($this->ide->getElementsByTagName("hSaiEnt")->item(0)->nodeValue)
1477
            ? $this->ide->getElementsByTagName("hSaiEnt")->item(0)->nodeValue
1478
            : '';
1479
        if ($hSaiEnt == '') {
1480
            $dhSaiEnt   = ! empty($this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue)
1481
                ? $this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue
1482
                : '';
1483
            $tsDhSaiEnt = $this->toTimestamp($dhSaiEnt);
1484
            if ($tsDhSaiEnt != '') {
1485
                $hSaiEnt = date('H:i:s', $tsDhSaiEnt);
1486
            }
1487
        }
1488
        $texto = $hSaiEnt;
1489
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1490
        $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...
1491
1492
        return ($y + $h);
1493
    } //fim da função destinatarioDANFE
1494
1495
    /**
1496
     * localEntregaDANFE
1497
     * Monta o campo com os dados do local de entrega na DANFE. (retrato e paisagem)
1498
     *
1499
     * @name   localEntregaDANFE
1500
     *
1501
     * @param number $x Posição horizontal canto esquerdo
1502
     * @param number $y Posição vertical canto superior
1503
     *
1504
     * @return number Posição vertical final
1505
     */
1506
    protected function localEntregaDANFE($x = 0, $y = 0)
1507
    {
1508
        //####################################################################################
1509
        //LOCAL DE ENTREGA
1510
        $oldX = $x;
1511
        if ($this->orientacao == 'P') {
1512
            $maxW = $this->wPrint;
1513
        } else {
1514
            $maxW = $this->wPrint - $this->wCanhoto;
1515
        }
1516
        $w     = $maxW;
1517
        $h     = 7;
1518
        $texto = 'INFORMAÇÕES DO LOCAL DE ENTREGA';
1519
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1520
        $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...
1521
        //NOME / RAZÃO SOCIAL
1522
        $w     = round($maxW * 0.61, 0);
1523
        $w1    = $w;
1524
        $y     += 3;
1525
        $texto = 'NOME / RAZÃO SOCIAL';
1526
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1527
        $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...
1528
        $texto = '';
1529
        if ($this->entrega->getElementsByTagName("xNome")->item(0)) {
1530
            $texto = $this->entrega->getElementsByTagName("xNome")->item(0)->nodeValue;
1531
        }
1532
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1533
        if ($this->orientacao == 'P') {
1534
            $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...
1535
        } else {
1536
            $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...
1537
        }
1538
        //CNPJ / CPF
1539
        $x     += $w;
1540
        $w     = round($maxW * 0.23, 0);
1541
        $w2    = $w;
1542
        $texto = 'CNPJ / CPF';
1543
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1544
        $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...
1545
        //Pegando valor do CPF/CNPJ
1546
        if (! empty($this->entrega->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1547
            $texto = $this->formatField(
1548
                $this->entrega->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1549
                "###.###.###/####-##"
1550
            );
1551
        } else {
1552
            $texto = ! empty($this->entrega->getElementsByTagName("CPF")->item(0)->nodeValue) ?
1553
                $this->formatField(
1554
                    $this->entrega->getElementsByTagName("CPF")->item(0)->nodeValue,
1555
                    "###.###.###-##"
1556
                ) : '';
1557
        }
1558
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1559
        $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...
1560
        //INSCRIÇÃO ESTADUAL
1561
        $x     += $w;
1562
        $w     = $maxW - ($w1 + $w2);
1563
        $wx    = $w;
1564
        $texto = 'INSCRIÇÃO ESTADUAL';
1565
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1566
        $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...
1567
        $texto = '';
1568
        if ($this->entrega->getElementsByTagName("IE")->item(0)) {
1569
            $texto = $this->entrega->getElementsByTagName("IE")->item(0)->nodeValue;
1570
        }
1571
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1572
        if ($this->orientacao == 'P') {
1573
            $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...
1574
        } else {
1575
            $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...
1576
        }
1577
        //ENDEREÇO
1578
        $w     = round($maxW * 0.355, 0) + $wx;
1579
        $w1    = $w;
1580
        $y     += $h;
1581
        $x     = $oldX;
1582
        $texto = 'ENDEREÇO';
1583
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1584
        $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...
1585
        $texto = $this->entrega->getElementsByTagName("xLgr")->item(0)->nodeValue;
1586
        $texto .= ', ' . $this->entrega->getElementsByTagName("nro")->item(0)->nodeValue;
1587
        $texto .= $this->getTagValue($this->entrega, "xCpl", " - ");
1588
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1589
        $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...
1590
        //BAIRRO / DISTRITO
1591
        $x     += $w;
1592
        $w     = round($maxW * 0.335, 0);
1593
        $w2    = $w;
1594
        $texto = 'BAIRRO / DISTRITO';
1595
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1596
        $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...
1597
        $texto = $this->entrega->getElementsByTagName("xBairro")->item(0)->nodeValue;
1598
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1599
        $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...
1600
        //CEP
1601
        $x     += $w;
1602
        $w     = $maxW - ($w1 + $w2);
1603
        $texto = 'CEP';
1604
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1605
        $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...
1606
        $texto = ! empty($this->entrega->getElementsByTagName("CEP")->item(0)->nodeValue) ?
1607
            $this->entrega->getElementsByTagName("CEP")->item(0)->nodeValue : '';
1608
        $texto = $this->formatField($texto, "#####-###");
1609
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1610
        $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...
1611
        //MUNICÍPIO
1612
        $w     = round($maxW * 0.805, 0);
1613
        $w1    = $w;
1614
        $y     += $h;
1615
        $x     = $oldX;
1616
        $texto = 'MUNICÍPIO';
1617
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1618
        $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...
1619
        $texto = $this->entrega->getElementsByTagName("xMun")->item(0)->nodeValue;
1620
        if (strtoupper(trim($texto)) == "EXTERIOR" && $this->entrega->getElementsByTagName("xPais")->length > 0) {
1621
            $texto .= " - " . $this->entrega->getElementsByTagName("xPais")->item(0)->nodeValue;
1622
        }
1623
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1624
        $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...
1625
        //UF
1626
        $x     += $w;
1627
        $w     = 8;
1628
        $texto = 'UF';
1629
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1630
        $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...
1631
        $texto = $this->entrega->getElementsByTagName("UF")->item(0)->nodeValue;
1632
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1633
        $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...
1634
        //FONE / FAX
1635
        $x     += $w;
1636
        $w     = $maxW - $w - $w1;
1637
        $texto = 'FONE / FAX';
1638
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1639
        $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...
1640
        $texto = ! empty($this->entrega->getElementsByTagName("fone")->item(0)->nodeValue) ?
1641
            $this->entrega->getElementsByTagName("fone")->item(0)->nodeValue : '';
1642
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1643
        $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...
1644
1645
        return ($y + $h);
1646
    } //fim da função localEntregaDANFE
1647
1648
    /**
1649
     * localretiradaDANFE
1650
     * Monta o campo com os dados do local de entrega na DANFE. (retrato e paisagem)
1651
     *
1652
     * @name   localretiradaDANFE
1653
     *
1654
     * @param number $x Posição horizontal canto esquerdo
1655
     * @param number $y Posição vertical canto superior
1656
     *
1657
     * @return number Posição vertical final
1658
     */
1659
    protected function localRetiradaDANFE($x = 0, $y = 0)
1660
    {
1661
        //####################################################################################
1662
        //LOCAL DE RETIRADA
1663
        $oldX = $x;
1664
        if ($this->orientacao == 'P') {
1665
            $maxW = $this->wPrint;
1666
        } else {
1667
            $maxW = $this->wPrint - $this->wCanhoto;
1668
        }
1669
        $w     = $maxW;
1670
        $h     = 7;
1671
        $texto = 'INFORMAÇÕES DO LOCAL DE RETIRADA';
1672
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1673
        $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...
1674
        //NOME / RAZÃO SOCIAL
1675
        $w     = round($maxW * 0.61, 0);
1676
        $w1    = $w;
1677
        $y     += 3;
1678
        $texto = 'NOME / RAZÃO SOCIAL';
1679
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1680
        $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...
1681
        $texto = '';
1682
        if ($this->retirada->getElementsByTagName("xNome")->item(0)) {
1683
            $texto = $this->retirada->getElementsByTagName("xNome")->item(0)->nodeValue;
1684
        }
1685
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1686
        if ($this->orientacao == 'P') {
1687
            $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...
1688
        } else {
1689
            $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...
1690
        }
1691
        //CNPJ / CPF
1692
        $x     += $w;
1693
        $w     = round($maxW * 0.23, 0);
1694
        $w2    = $w;
1695
        $texto = 'CNPJ / CPF';
1696
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1697
        $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...
1698
        //Pegando valor do CPF/CNPJ
1699
        if (! empty($this->retirada->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1700
            $texto = $this->formatField(
1701
                $this->retirada->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1702
                "###.###.###/####-##"
1703
            );
1704
        } else {
1705
            $texto = ! empty($this->retirada->getElementsByTagName("CPF")->item(0)->nodeValue) ?
1706
                $this->formatField(
1707
                    $this->retirada->getElementsByTagName("CPF")->item(0)->nodeValue,
1708
                    "###.###.###-##"
1709
                ) : '';
1710
        }
1711
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1712
        $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...
1713
        //INSCRIÇÃO ESTADUAL
1714
        $x     += $w;
1715
        $w     = $maxW - ($w1 + $w2);
1716
        $wx    = $w;
1717
        $texto = 'INSCRIÇÃO ESTADUAL';
1718
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1719
        $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...
1720
        $texto = '';
1721
        if ($this->retirada->getElementsByTagName("IE")->item(0)) {
1722
            $texto = $this->retirada->getElementsByTagName("IE")->item(0)->nodeValue;
1723
        }
1724
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1725
        if ($this->orientacao == 'P') {
1726
            $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...
1727
        } else {
1728
            $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...
1729
        }
1730
        //ENDEREÇO
1731
        $w     = round($maxW * 0.355, 0) + $wx;
1732
        $w1    = $w;
1733
        $y     += $h;
1734
        $x     = $oldX;
1735
        $texto = 'ENDEREÇO';
1736
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1737
        $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...
1738
        $texto = $this->retirada->getElementsByTagName("xLgr")->item(0)->nodeValue;
1739
        $texto .= ', ' . $this->retirada->getElementsByTagName("nro")->item(0)->nodeValue;
1740
        $texto .= $this->getTagValue($this->retirada, "xCpl", " - ");
1741
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1742
        $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...
1743
        //BAIRRO / DISTRITO
1744
        $x     += $w;
1745
        $w     = round($maxW * 0.335, 0);
1746
        $w2    = $w;
1747
        $texto = 'BAIRRO / DISTRITO';
1748
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1749
        $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...
1750
        $texto = $this->retirada->getElementsByTagName("xBairro")->item(0)->nodeValue;
1751
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1752
        $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...
1753
        //CEP
1754
        $x     += $w;
1755
        $w     = $maxW - ($w1 + $w2);
1756
        $texto = 'CEP';
1757
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1758
        $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...
1759
        $texto = ! empty($this->retirada->getElementsByTagName("CEP")->item(0)->nodeValue) ?
1760
            $this->retirada->getElementsByTagName("CEP")->item(0)->nodeValue : '';
1761
        $texto = $this->formatField($texto, "#####-###");
1762
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1763
        $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...
1764
        //MUNICÍPIO
1765
        $w     = round($maxW * 0.805, 0);
1766
        $w1    = $w;
1767
        $y     += $h;
1768
        $x     = $oldX;
1769
        $texto = 'MUNICÍPIO';
1770
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1771
        $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...
1772
        $texto = $this->retirada->getElementsByTagName("xMun")->item(0)->nodeValue;
1773
        if (strtoupper(trim($texto)) == "EXTERIOR" && $this->retirada->getElementsByTagName("xPais")->length > 0) {
1774
            $texto .= " - " . $this->retirada->getElementsByTagName("xPais")->item(0)->nodeValue;
1775
        }
1776
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1777
        $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...
1778
        //UF
1779
        $x     += $w;
1780
        $w     = 8;
1781
        $texto = 'UF';
1782
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1783
        $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...
1784
        $texto = $this->retirada->getElementsByTagName("UF")->item(0)->nodeValue;
1785
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1786
        $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...
1787
        //FONE / FAX
1788
        $x     += $w;
1789
        $w     = $maxW - $w - $w1;
1790
        $texto = 'FONE / FAX';
1791
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1792
        $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...
1793
        $texto = ! empty($this->retirada->getElementsByTagName("fone")->item(0)->nodeValue) ?
1794
            $this->retirada->getElementsByTagName("fone")->item(0)->nodeValue : '';
1795
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1796
        $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...
1797
1798
        return ($y + $h);
1799
    } //fim da função localRetiradaDANFE
1800
1801
    /**
1802
     * getTextoFatura
1803
     * Gera a String do Texto da Fatura
1804
     *
1805
     * @name   getTextoFatura
1806
     * @return uma String com o texto ou "";
1807
     */
1808
    protected function getTextoFatura()
1809
    {
1810
        if (isset($this->cobr)) {
1811
            $fat = $this->cobr->getElementsByTagName("fat")->item(0);
1812
            if (isset($fat)) {
1813
                if (! empty($this->getTagValue($this->ide, "indPag"))) {
1814
                    $textoIndPag = "";
1815
                    $indPag      = $this->getTagValue($this->ide, "indPag");
1816
                    if ($indPag === "0") {
1817
                        $textoIndPag = "Pagamento à Vista - ";
1818
                    } elseif ($indPag === "1") {
1819
                        $textoIndPag = "Pagamento à Prazo - ";
1820
                    }
1821
                    $nFat  = $this->getTagValue($fat, "nFat", "Fatura: ");
1822
                    $vOrig = $this->getTagValue($fat, "vOrig", " Valor Original: ");
1823
                    $vDesc = $this->getTagValue($fat, "vDesc", " Desconto: ");
1824
                    $vLiq  = $this->getTagValue($fat, "vLiq", " Valor Líquido: ");
1825
                    $texto = $textoIndPag . $nFat . $vOrig . $vDesc . $vLiq;
1826
1827
                    return $texto;
1828
                } else {
1829
                    $pag = $this->dom->getElementsByTagName("pag");
1830
                    if ($tPag = $this->getTagValue($pag->item(0), "tPag")) {
1831
                        return $this->tipoPag($tPag);
1832
                    }
1833
                }
1834
            }
1835
        }
1836
1837
        return "";
1838
    }
1839
1840
    /**
1841
     * sizeExtraTextoFatura
1842
     * Calcula o espaço ocupado pelo texto da fatura. Este espaço só é utilizado quando não houver duplicata.
1843
     *
1844
     * @name   sizeExtraTextoFatura
1845
     * @return integer
1846
     */
1847
    protected function sizeExtraTextoFatura()
1848
    {
1849
        $textoFatura = $this->getTextoFatura();
1850
        //verificar se existem duplicatas
1851
        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...
1852
            return 10;
1853
        }
1854
1855
        return 0;
1856
    }
1857
1858
    /**
1859
     * fatura
1860
     * Monta o campo de duplicatas da DANFE (retrato e paisagem)
1861
     *
1862
     * @name   fatura
1863
     *
1864
     * @param number $x Posição horizontal canto esquerdo
1865
     * @param number $y Posição vertical canto superior
1866
     *
1867
     * @return number Posição vertical final
1868
     */
1869
    protected function fatura($x, $y)
1870
    {
1871
        $linha       = 1;
1872
        $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...
1873
        $oldx        = $x;
1874
        $textoFatura = $this->getTextoFatura();
1875
        //verificar se existem duplicatas
1876
        if ($this->dup->length > 0 || $textoFatura !== "") {
1877
            //#####################################################################
1878
            //FATURA / DUPLICATA
1879
            $texto = "FATURA / DUPLICATA";
1880
            if ($this->orientacao == 'P') {
1881
                $w = $this->wPrint;
1882
            } else {
1883
                $w = 271;
1884
            }
1885
            $h     = 8;
1886
            $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1887
            $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...
1888
            $y       += 3;
1889
            $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...
1890
            $dupcont = 0;
1891
            $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...
1892
            if ($nFat > 7) {
1893
                $myH = 6;
1894
                $myW = $this->wPrint;
1895
                if ($this->orientacao == 'L') {
1896
                    $myW -= $this->wCanhoto;
1897
                }
1898
                $aFont = ['font' => $this->fontePadrao, 'size' => 9, 'style' => ''];
1899
                $texto = "Existem mais de 7 duplicatas registradas, portanto não "
1900
                    . "serão exibidas, confira diretamente pelo XML.";
1901
                $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...
1902
1903
                return ($y + $h - 3);
1904
            }
1905
            if ($textoFatura !== "" && $this->exibirTextoFatura) {
1906
                $myH = 6;
1907
                $myW = $this->wPrint;
1908
                if ($this->orientacao == 'L') {
1909
                    $myW -= $this->wCanhoto;
1910
                }
1911
                $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
1912
                $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...
1913
                $y += $myH + 1;
1914
            }
1915
            if ($this->orientacao == 'P') {
1916
                $w = round($this->wPrint / 7.018, 0) - 1;
1917
            } else {
1918
                $w = 28;
1919
            }
1920
            $increm = 1;
1921
            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...
1922
                $nDup  = ! empty($this->dup->item($k)->getElementsByTagName('nDup')->item(0)->nodeValue)
1923
                    ? $this->dup->item($k)->getElementsByTagName('nDup')->item(0)->nodeValue
1924
                    : '';
1925
                $dDup  = ! empty($this->dup->item($k)->getElementsByTagName('dVenc')->item(0)->nodeValue)
1926
                    ? $this->ymdTodmy($this->dup->item($k)->getElementsByTagName('dVenc')->item(0)->nodeValue)
1927
                    : '';
1928
                $vDup  = ! empty($this->dup->item($k)->getElementsByTagName('vDup')->item(0)->nodeValue)
1929
                    ? 'R$ ' . number_format(
1930
                        $this->dup->item($k)->getElementsByTagName('vDup')->item(0)->nodeValue,
1931
                        2,
1932
                        ",",
1933
                        "."
1934
                    )
1935
                    : '';
1936
                $h     = 8;
1937
                $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...
1938
                if ($nDup != '0' && $nDup != '') {
1939
                    $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1940
                    $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...
1941
                    $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1942
                    $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...
1943
                } else {
1944
                    $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1945
                    $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...
1946
                }
1947
                $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1948
                $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...
1949
                $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1950
                $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...
1951
                $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1952
                $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...
1953
                $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1954
                $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...
1955
                $x       += $w + $increm;
1956
                $dupcont += 1;
1957
                if ($this->orientacao == 'P') {
1958
                    $maxDupCont = 6;
1959
                } else {
1960
                    $maxDupCont = 8;
1961
                }
1962
                if ($dupcont > $maxDupCont) {
1963
                    $y       += 9;
1964
                    $x       = $oldx;
1965
                    $dupcont = 0;
1966
                    $linha   += 1;
1967
                }
1968
                if ($linha == 5) {
1969
                    $linha = 4;
1970
                    break;
1971
                }
1972
            }
1973
            if ($dupcont == 0) {
1974
                $y -= 9;
1975
                $linha --;
1976
            }
1977
1978
            return ($y + $h);
1979
        } else {
1980
            $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...
1981
1982
            return ($y - 2);
1983
        }
1984
    }
1985
1986
    /**
1987
     * pagamento
1988
     * Monta o campo de pagamentos da DANFE (retrato e paisagem) (foi baseada na fatura)
1989
     *
1990
     * @name   pagamento
1991
     *
1992
     * @param number $x Posição horizontal canto esquerdo
1993
     * @param number $y Posição vertical canto superior
1994
     *
1995
     * @return number Posição vertical final
1996
     */
1997
    protected function pagamento($x, $y)
1998
    {
1999
        $linha = 1;
2000
        $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...
2001
        $oldx  = $x;
2002
        //verificar se existem cobranças definidas
2003
        if (isset($this->detPag) && $this->detPag->length > 0) {
2004
            //#####################################################################
2005
            //Tipo de pagamento
2006
            $texto = "PAGAMENTO";
2007
            if ($this->orientacao == 'P') {
2008
                $w = $this->wPrint;
2009
            } else {
2010
                $w = 271;
2011
            }
2012
            $h     = 8;
2013
            $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2014
            $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...
2015
            $y       += 3;
2016
            $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...
2017
            $dupcont = 0;
2018
            if ($this->orientacao == 'P') {
2019
                $w = round($this->wPrint / 7.018, 0) - 1;
2020
            } else {
2021
                $w = 28;
2022
            }
2023
            if ($this->orientacao == 'P') {
2024
                $maxDupCont = 6;
2025
            } else {
2026
                $maxDupCont = 8;
2027
            }
2028
            $increm         = 1;
2029
            $formaPagamento = [
2030
                '01' => 'Dinheiro',
2031
                '02' => 'Cheque',
2032
                '03' => 'Cartão de Crédito',
2033
                '04' => 'Cartão de Débito',
2034
                '05' => 'Crédito Loja',
2035
                '10' => 'Vale Alimentação',
2036
                '11' => 'Vale Refeição',
2037
                '12' => 'Vale Presente',
2038
                '13' => 'Vale Combustível',
2039
                '14' => 'Duplicata Mercantil',
2040
                '15' => 'Boleto',
2041
                '90' => 'Sem pagamento',
2042
                '99' => 'Outros'
2043
            ];
2044
            $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...
2045
                '01' => 'Visa',
2046
                '02' => 'Mastercard',
2047
                '03' => 'American',
2048
                '04' => 'Sorocred',
2049
                '05' => 'Diners',
2050
                '06' => 'Elo',
2051
                '07' => 'Hipercard',
2052
                '08' => 'Aura',
2053
                '09' => 'Cabal',
2054
                '99' => 'Outros'
2055
            ];
2056
            foreach ($this->detPag as $k => $d) {
2057
                $fPag  = ! empty($this->detPag->item($k)->getElementsByTagName('tPag')->item(0)->nodeValue)
2058
                    ? $this->detPag->item($k)->getElementsByTagName('tPag')->item(0)->nodeValue
2059
                    : '0';
2060
                $vPag  = ! empty($this->detPag->item($k)->getElementsByTagName('vPag')->item(0)->nodeValue)
2061
                    ? 'R$ ' . number_format(
2062
                        $this->detPag->item($k)->getElementsByTagName('vPag')->item(0)->nodeValue,
2063
                        2,
2064
                        ",",
2065
                        "."
2066
                    )
2067
                    : '';
2068
                $h     = 6;
2069
                $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...
2070
                if (isset($formaPagamento[$fPag])) {
2071
                    /*Exibir Item sem pagamento*/
2072
                    if ($fPag == '90') {
2073
                        continue;
2074
                    }
2075
                    $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2076
                    $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...
2077
                    $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2078
                    $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...
2079
                } else {
2080
                    $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
2081
                    $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...
2082
                }
2083
                $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2084
                $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...
2085
                $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2086
                $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...
2087
                $x       += $w + $increm;
2088
                $dupcont += 1;
2089
2090
                if ($dupcont > $maxDupCont) {
2091
                    $y       += 9;
2092
                    $x       = $oldx;
2093
                    $dupcont = 0;
2094
                    $linha   += 1;
2095
                }
2096
                if ($linha == 5) {
2097
                    $linha = 4;
2098
                    break;
2099
                }
2100
            }
2101
            if ($dupcont == 0) {
2102
                $y -= 9;
2103
                $linha --;
2104
            }
2105
2106
            return ($y + $h);
2107
        } else {
2108
            $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...
2109
2110
            return ($y - 2);
2111
        }
2112
    } //fim da função pagamento
2113
2114
    /**
2115
     * impostoHelper
2116
     * Auxilia a montagem dos campos de impostos e totais da DANFE
2117
     *
2118
     * @name   impostoHelper
2119
     *
2120
     * @param float $x Posição horizontal canto esquerdo
2121
     * @param float $y Posição vertical canto superior
2122
     * @param float $w Largura do campo
2123
     * @param float $h Altura do campo
2124
     * @param float $h Título do campo
2125
     * @param float $h Valor do imposto
2126
     *
2127
     * @return float Sugestão do $x do próximo imposto
2128
     */
2129
    protected function impostoHelper($x, $y, $w, $h, $titulo, $campoImposto)
2130
    {
2131
        $valorImposto = '0,00';
2132
        $the_field    = $this->ICMSTot->getElementsByTagName($campoImposto)->item(0);
2133
        if (isset($the_field)) {
2134
            $the_value = $the_field->nodeValue;
2135
            if (! empty($the_value)) {
2136
                $valorImposto = number_format($the_value, 2, ",", ".");
2137
            }
2138
        }
2139
2140
        $fontTitulo = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2141
        $fontValor  = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2142
        $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...
2143
        $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...
2144
2145
        $next_x = $x + $w;
2146
2147
        return $next_x;
2148
    }
2149
2150
    /**
2151
     * imposto
2152
     * Monta o campo de impostos e totais da DANFE (retrato e paisagem)
2153
     *
2154
     * @param number $x Posição horizontal canto esquerdo
2155
     * @param number $y Posição vertical canto superior
2156
     *
2157
     * @return number Posição vertical final
2158
     */
2159
    protected function imposto($x, $y)
2160
    {
2161
        $x_inicial = $x;
2162
        //#####################################################################
2163
        $campos_por_linha = 9;
2164
        if (! $this->exibirPIS) {
2165
            $campos_por_linha --;
2166
        }
2167
        if (! $this->exibirIcmsInterestadual) {
2168
            $campos_por_linha -= 2;
2169
        }
2170
2171
        if ($this->orientacao == 'P') {
2172
            $maxW       = $this->wPrint;
2173
            $title_size = 31;
2174
        } else {
2175
            $maxW       = $this->wPrint - $this->wCanhoto;
2176
            $title_size = 40;
2177
        }
2178
        $w = $maxW / $campos_por_linha;
2179
2180
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2181
        $texto = "CÁLCULO DO IMPOSTO";
2182
        $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...
2183
        $y += 3;
2184
        $h = 7;
2185
2186
        $x = $this->impostoHelper($x, $y, $w, $h, "BASE DE CÁLC. DO ICMS", "vBC");
2187
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO ICMS", "vICMS");
2188
        $x = $this->impostoHelper($x, $y, $w, $h, "BASE DE CÁLC. ICMS S.T.", "vBCST");
2189
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO ICMS SUBST.", "vST");
2190
        $x = $this->impostoHelper($x, $y, $w, $h, "V. IMP. IMPORTAÇÃO", "vII");
2191
2192
        if ($this->exibirIcmsInterestadual) {
2193
            $x = $this->impostoHelper($x, $y, $w, $h, "V. ICMS UF REMET.", "vICMSUFRemet");
2194
            $x = $this->impostoHelper($x, $y, $w, $h, "V. FCP UF DEST.", "vFCPUFDest");
2195
        }
2196
2197
        if ($this->exibirPIS) {
2198
            $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO PIS", "vPIS");
2199
        }
2200
2201
        $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...
2202
2203
        //
2204
2205
        $y += $h;
2206
        $x = $x_inicial;
2207
2208
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO FRETE", "vFrete");
2209
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO SEGURO", "vSeg");
2210
        $x = $this->impostoHelper($x, $y, $w, $h, "DESCONTO", "vDesc");
2211
        $x = $this->impostoHelper($x, $y, $w, $h, "OUTRAS DESPESAS", "vOutro");
2212
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR TOTAL IPI", "vIPI");
2213
2214
        if ($this->exibirIcmsInterestadual) {
2215
            $x = $this->impostoHelper($x, $y, $w, $h, "V. ICMS UF DEST.", "vICMSUFDest");
2216
            $x = $this->impostoHelper($x, $y, $w, $h, "V. TOT. TRIB.", "vTotTrib");
2217
        }
2218
        if ($this->exibirPIS) {
2219
            $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DA COFINS", "vCOFINS");
2220
        }
2221
        $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...
2222
2223
        return ($y + $h);
2224
    } //fim imposto
2225
2226
    /**
2227
     * transporte
2228
     * Monta o campo de transportes da DANFE (retrato e paisagem)
2229
     *
2230
     * @name   transporte
2231
     *
2232
     * @param float $x Posição horizontal canto esquerdo
2233
     * @param float $y Posição vertical canto superior
2234
     *
2235
     * @return float Posição vertical final
2236
     */
2237
    protected function transporte($x, $y)
2238
    {
2239
        $oldX = $x;
2240
        if ($this->orientacao == 'P') {
2241
            $maxW = $this->wPrint;
2242
        } else {
2243
            $maxW = $this->wPrint - $this->wCanhoto;
2244
        }
2245
        //#####################################################################
2246
        //TRANSPORTADOR / VOLUMES TRANSPORTADOS
2247
        $texto = "TRANSPORTADOR / VOLUMES TRANSPORTADOS";
2248
        $w     = $maxW;
2249
        $h     = 7;
2250
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2251
        $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...
2252
        //NOME / RAZÃO SOCIAL
2253
        $w1    = $maxW * 0.29;
2254
        $y     += 3;
2255
        $texto = 'NOME / RAZÃO SOCIAL';
2256
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2257
        $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...
2258
        if (isset($this->transporta)) {
2259
            $texto = ! empty($this->transporta->getElementsByTagName("xNome")->item(0)->nodeValue)
2260
                ? $this->transporta->getElementsByTagName("xNome")->item(0)->nodeValue
2261
                : '';
2262
        } else {
2263
            $texto = '';
2264
        }
2265
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2266
        $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...
2267
        //FRETE POR CONTA
2268
        $x     += $w1;
2269
        $w2    = $maxW * 0.15;
2270
        $texto = 'FRETE';
2271
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2272
        $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...
2273
        $tipoFrete = ! empty($this->transp->getElementsByTagName("modFrete")->item(0)->nodeValue)
2274
            ? $this->transp->getElementsByTagName("modFrete")->item(0)->nodeValue
2275
            : '0';
2276
        switch ($tipoFrete) {
2277
            case 0:
2278
                $texto = "0-Por conta do Rem";
2279
                break;
2280
            case 1:
2281
                $texto = "1-Por conta do Dest";
2282
                break;
2283
            case 2:
2284
                $texto = "2-Por conta de Terceiros";
2285
                break;
2286
            case 3:
2287
                $texto = "3-Próprio por conta do Rem";
2288
                break;
2289
            case 4:
2290
                $texto = "4-Próprio por conta do Dest";
2291
                break;
2292
            case 9:
2293
                $texto = "9-Sem Transporte";
2294
                break;
2295
        }
2296
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2297
        $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...
2298
        //CÓDIGO ANTT
2299
        $x     += $w2;
2300
        $texto = 'CÓDIGO ANTT';
2301
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2302
        $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...
2303
        if (isset($this->veicTransp)) {
2304
            $texto = ! empty($this->veicTransp->getElementsByTagName("RNTC")->item(0)->nodeValue)
2305
                ? $this->veicTransp->getElementsByTagName("RNTC")->item(0)->nodeValue
2306
                : '';
2307
        } else {
2308
            $texto = '';
2309
        }
2310
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2311
        $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...
2312
        //PLACA DO VEÍC
2313
        $x     += $w2;
2314
        $texto = 'PLACA DO VEÍCULO';
2315
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2316
        $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...
2317
        if (isset($this->veicTransp)) {
2318
            $texto = ! empty($this->veicTransp->getElementsByTagName("placa")->item(0)->nodeValue)
2319
                ? $this->veicTransp->getElementsByTagName("placa")->item(0)->nodeValue
2320
                : '';
2321
        } elseif (isset($this->reboque)) {
2322
            $texto = ! empty($this->reboque->getElementsByTagName("placa")->item(0)->nodeValue)
2323
                ? $this->reboque->getElementsByTagName("placa")->item(0)->nodeValue
2324
                : '';
2325
        } else {
2326
            $texto = '';
2327
        }
2328
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2329
        $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...
2330
        //UF
2331
        $x     += $w2;
2332
        $w3    = round($maxW * 0.04, 0);
2333
        $texto = 'UF';
2334
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2335
        $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...
2336
        if (isset($this->veicTransp)) {
2337
            $texto = ! empty($this->veicTransp->getElementsByTagName("UF")->item(0)->nodeValue)
2338
                ? $this->veicTransp->getElementsByTagName("UF")->item(0)->nodeValue
2339
                : '';
2340
        } elseif (isset($this->reboque)) {
2341
            $texto = ! empty($this->reboque->getElementsByTagName("UF")->item(0)->nodeValue)
2342
                ? $this->reboque->getElementsByTagName("UF")->item(0)->nodeValue
2343
                : '';
2344
        } else {
2345
            $texto = '';
2346
        }
2347
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2348
        $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...
2349
        //CNPJ / CPF
2350
        $x     += $w3;
2351
        $w     = $maxW - ($w1 + 3 * $w2 + $w3);
2352
        $texto = 'CNPJ / CPF';
2353
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2354
        $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...
2355
        if (isset($this->transporta)) {
2356
            $texto = ! empty($this->transporta->getElementsByTagName("CNPJ")->item(0)->nodeValue)
2357
                ? $this->formatField(
2358
                    $this->transporta->getElementsByTagName("CNPJ")->item(0)->nodeValue,
2359
                    "##.###.###/####-##"
2360
                )
2361
                : '';
2362
            if ($texto == '') {
2363
                $texto = ! empty($this->transporta->getElementsByTagName("CPF")->item(0)->nodeValue)
2364
                    ? $this->formatField(
2365
                        $this->transporta->getElementsByTagName("CPF")->item(0)->nodeValue,
2366
                        "###.###.###-##"
2367
                    )
2368
                    : '';
2369
            }
2370
        } else {
2371
            $texto = '';
2372
        }
2373
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2374
        $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...
2375
        //#####################################################################
2376
        //ENDEREÇO
2377
        $y     += $h;
2378
        $x     = $oldX;
2379
        $h     = 7;
2380
        $w1    = $maxW * 0.44;
2381
        $texto = 'ENDEREÇO';
2382
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2383
        $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...
2384
        if (isset($this->transporta)) {
2385
            $texto = ! empty($this->transporta->getElementsByTagName("xEnder")->item(0)->nodeValue)
2386
                ? $this->transporta->getElementsByTagName("xEnder")->item(0)->nodeValue
2387
                : '';
2388
        } else {
2389
            $texto = '';
2390
        }
2391
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2392
        $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...
2393
        //MUNICÍPIO
2394
        $x     += $w1;
2395
        $w2    = round($maxW * 0.30, 0);
2396
        $texto = 'MUNICÍPIO';
2397
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2398
        $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...
2399
        if (isset($this->transporta)) {
2400
            $texto = ! empty($this->transporta->getElementsByTagName("xMun")->item(0)->nodeValue)
2401
                ? $this->transporta->getElementsByTagName("xMun")->item(0)->nodeValue
2402
                : '';
2403
        } else {
2404
            $texto = '';
2405
        }
2406
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2407
        $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...
2408
        //UF
2409
        $x     += $w2;
2410
        $w3    = round($maxW * 0.04, 0);
2411
        $texto = 'UF';
2412
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2413
        $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...
2414
        if (isset($this->transporta)) {
2415
            $texto = ! empty($this->transporta->getElementsByTagName("UF")->item(0)->nodeValue)
2416
                ? $this->transporta->getElementsByTagName("UF")->item(0)->nodeValue
2417
                : '';
2418
        } else {
2419
            $texto = '';
2420
        }
2421
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2422
        $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...
2423
        //INSCRIÇÃO ESTADUAL
2424
        $x     += $w3;
2425
        $w     = $maxW - ($w1 + $w2 + $w3);
2426
        $texto = 'INSCRIÇÃO ESTADUAL';
2427
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2428
        $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...
2429
        $texto = '';
2430
        if (isset($this->transporta)) {
2431
            if (! empty($this->transporta->getElementsByTagName("IE")->item(0)->nodeValue)) {
2432
                $texto = $this->transporta->getElementsByTagName("IE")->item(0)->nodeValue;
2433
            }
2434
        }
2435
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2436
        $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...
2437
        //Tratar Multiplos volumes
2438
        $volumes     = $this->transp->getElementsByTagName('vol');
2439
        $quantidade  = 0;
2440
        $especie     = '';
2441
        $marca       = '';
2442
        $numero      = '';
2443
        $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...
2444
        $pesoBruto   = 0;
2445
        $pesoLiquido = 0;
2446
        foreach ($volumes as $volume) {
2447
            $quantidade  += ! empty($volume->getElementsByTagName("qVol")->item(0)->nodeValue) ?
2448
                $volume->getElementsByTagName("qVol")->item(0)->nodeValue : 0;
2449
            $pesoBruto   += ! empty($volume->getElementsByTagName("pesoB")->item(0)->nodeValue) ?
2450
                $volume->getElementsByTagName("pesoB")->item(0)->nodeValue : 0;
2451
            $pesoLiquido += ! empty($volume->getElementsByTagName("pesoL")->item(0)->nodeValue) ?
2452
                $volume->getElementsByTagName("pesoL")->item(0)->nodeValue : 0;
2453
            $texto       = ! empty($this->transp->getElementsByTagName("esp")->item(0)->nodeValue) ?
2454
                $this->transp->getElementsByTagName("esp")->item(0)->nodeValue : '';
2455
            if ($texto != $especie && $especie != '') {
2456
                //tem várias especies
2457
                $especie = 'VARIAS';
2458
            } else {
2459
                $especie = $texto;
2460
            }
2461
            $texto = ! empty($this->transp->getElementsByTagName("marca")->item(0)->nodeValue)
2462
                ? $this->transp->getElementsByTagName("marca")->item(0)->nodeValue
2463
                : '';
2464
            if ($texto != $marca && $marca != '') {
2465
                //tem várias especies
2466
                $marca = 'VARIAS';
2467
            } else {
2468
                $marca = $texto;
2469
            }
2470
            $texto = ! empty($this->transp->getElementsByTagName("nVol")->item(0)->nodeValue)
2471
                ? $this->transp->getElementsByTagName("nVol")->item(0)->nodeValue
2472
                : '';
2473
            if ($texto != $numero && $numero != '') {
2474
                //tem várias especies
2475
                $numero = 'VARIOS';
2476
            } else {
2477
                $numero = $texto;
2478
            }
2479
        }
2480
2481
        //#####################################################################
2482
        //QUANTIDADE
2483
        $y     += $h;
2484
        $x     = $oldX;
2485
        $h     = 7;
2486
        $w1    = round($maxW * 0.10, 0);
2487
        $texto = 'QUANTIDADE';
2488
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2489
        $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...
2490
        if (! empty($quantidade)) {
2491
            $texto = $quantidade;
2492
            $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2493
            $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...
2494
        }
2495
        //ESPÉCIE
2496
        $x     += $w1;
2497
        $w2    = round($maxW * 0.17, 0);
2498
        $texto = 'ESPÉCIE';
2499
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2500
        $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...
2501
        $texto = $especie;
2502
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2503
        $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...
2504
        //MARCA
2505
        $x     += $w2;
2506
        $texto = 'MARCA';
2507
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2508
        $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...
2509
        $texto = ! empty($this->transp->getElementsByTagName("marca")->item(0)->nodeValue) ?
2510
            $this->transp->getElementsByTagName("marca")->item(0)->nodeValue : '';
2511
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2512
        $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...
2513
        //NUMERAÇÃO
2514
        $x     += $w2;
2515
        $texto = 'NUMERAÇÃO';
2516
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2517
        $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...
2518
        $texto = $numero;
2519
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2520
        $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...
2521
        //PESO BRUTO
2522
        $x     += $w2;
2523
        $w3    = round($maxW * 0.20, 0);
2524
        $texto = 'PESO BRUTO';
2525
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2526
        $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...
2527
        if (is_numeric($pesoBruto) && $pesoBruto > 0) {
2528
            $texto = number_format($pesoBruto, 3, ",", ".");
2529
        } else {
2530
            $texto = '';
2531
        }
2532
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2533
        $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...
2534
        //PESO LÍQUIDO
2535
        $x     += $w3;
2536
        $w     = $maxW - ($w1 + 3 * $w2 + $w3);
2537
        $texto = 'PESO LÍQUIDO';
2538
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2539
        $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...
2540
        if (is_numeric($pesoLiquido) && $pesoLiquido > 0) {
2541
            $texto = number_format($pesoLiquido, 3, ",", ".");
2542
        } else {
2543
            $texto = '';
2544
        }
2545
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2546
        $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...
2547
2548
        return ($y + $h);
2549
    } //fim transporte
2550
2551
2552
    protected function descricaoProdutoHelper($origem, $campo, $formato)
2553
    {
2554
        $valor_original = $origem->getElementsByTagName($campo)->item(0);
2555
        if (! isset($valor_original)) {
2556
            return "";
2557
        }
2558
        $valor_original = $valor_original->nodeValue;
2559
        $valor          = ! empty($valor_original) ? number_format($valor_original, 2, ",", ".") : '';
2560
2561
        if ($valor != "") {
2562
            return sprintf($formato, $valor);
2563
        }
2564
2565
        return "";
2566
    }
2567
2568
    /**
2569
     * descricaoProduto
2570
     * Monta a string de descrição de cada Produto
2571
     *
2572
     * @name   descricaoProduto
2573
     *
2574
     * @param DOMNode itemProd
2575
     *
2576
     * @return string descricao do produto
2577
     */
2578
    protected function descricaoProduto($itemProd)
2579
    {
2580
        $prod       = $itemProd->getElementsByTagName('prod')->item(0);
2581
        $ICMS       = $itemProd->getElementsByTagName("ICMS")->item(0);
2582
        $ICMSUFDest = $itemProd->getElementsByTagName("ICMSUFDest")->item(0);
2583
        $impostos   = '';
2584
2585
        if (! empty($ICMS)) {
2586
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vBCFCP", " BcFcp=%s");
2587
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pFCP", " pFcp=%s%%");
2588
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vFCP", " vFcp=%s");
2589
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pRedBC", " pRedBC=%s%%");
2590
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pMVAST", " IVA/MVA=%s%%");
2591
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pICMSST", " pIcmsSt=%s%%");
2592
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vBCST", " BcIcmsSt=%s");
2593
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vICMSST", " vIcmsSt=%s");
2594
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vBCFCPST", " BcFcpSt=%s");
2595
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pFCPST", " pFcpSt=%s%%");
2596
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vFCPST", " vFcpSt=%s");
2597
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vBCSTRet", " Retido na compra: BASE ICMS ST=%s");
2598
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pST", " pSt=%s");
2599
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vICMSSTRet", " VALOR ICMS ST=%s");
2600
        }
2601
        if (! empty($ICMSUFDest)) {
2602
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "pFCPUFDest", " pFCPUFDest=%s%%");
2603
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "pICMSUFDest", " pICMSUFDest=%s%%");
2604
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "pICMSInterPart", " pICMSInterPart=%s%%");
2605
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "vFCPUFDest", " vFCPUFDest=%s");
2606
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "vICMSUFDest", " vICMSUFDest=%s");
2607
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "vICMSUFRemet", " vICMSUFRemet=%s");
2608
        }
2609
        $infAdProd = ! empty($itemProd->getElementsByTagName('infAdProd')->item(0)->nodeValue)
2610
            ? substr(
2611
                $this->anfaveaDANFE($itemProd->getElementsByTagName('infAdProd')->item(0)->nodeValue),
2612
                0,
2613
                500
2614
            )
2615
            : '';
2616
        if (! empty($infAdProd)) {
2617
            $infAdProd = trim($infAdProd);
2618
            $infAdProd .= ' ';
2619
        }
2620
        $loteTxt = '';
2621
        $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...
2622
        if (! empty($prod->getElementsByTagName("rastro"))) {
2623
            $rastro = $prod->getElementsByTagName("rastro");
2624
            $i      = 0;
2625
            while ($i < $rastro->length) {
2626
                $loteTxt .= $this->getTagValue($rastro->item($i), 'nLote', ' Lote: ');
2627
                $loteTxt .= $this->getTagValue($rastro->item($i), 'qLote', ' Quant: ');
2628
                $loteTxt .= $this->getTagDate($rastro->item($i), 'dFab', ' Fab: ');
2629
                $loteTxt .= $this->getTagDate($rastro->item($i), 'dVal', ' Val: ');
2630
                $loteTxt .= $this->getTagValue($rastro->item($i), 'vPMC', ' PMC: ');
2631
                $i ++;
2632
            }
2633
            if ($loteTxt != '') {
2634
                $loteTxt .= ' ';
2635
            }
2636
        }
2637
        //NT2013.006 FCI
2638
        $nFCI   = (! empty($itemProd->getElementsByTagName('nFCI')->item(0)->nodeValue)) ?
2639
            ' FCI:' . $itemProd->getElementsByTagName('nFCI')->item(0)->nodeValue : '';
2640
        $tmp_ad = $infAdProd . ($this->descProdInfoComplemento ? $loteTxt . $impostos . $nFCI : '');
2641
        $texto  = $prod->getElementsByTagName("xProd")->item(0)->nodeValue
2642
            . (strlen($tmp_ad) != 0 ? "\n    " . $tmp_ad : '');
2643
        //decodifica os caracteres html no xml
2644
        $texto = html_entity_decode($texto);
2645
        if ($this->descProdQuebraLinha) {
2646
            $texto = str_replace(";", "\n", $texto);
2647
        }
2648
2649
        return $texto;
2650
    }
2651
2652
    /**
2653
     * itens
2654
     * Monta o campo de itens da DANFE (retrato e paisagem)
2655
     *
2656
     * @name   itens
2657
     *
2658
     * @param float $x       Posição horizontal canto esquerdo
2659
     * @param float $y       Posição vertical canto superior
2660
     * @param float $nInicio Número do item inicial
2661
     * @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...
2662
     * @param float $hmax    Altura máxima do campo de itens em mm
2663
     *
2664
     * @return float Posição vertical final
2665
     */
2666
    protected function itens($x, $y, &$nInicio, $hmax, $pag = 0, $totpag = 0, $hCabecItens = 7)
2667
    {
2668
        $oldX = $x;
2669
        $oldY = $y;
2670
        $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...
2671
        //#####################################################################
2672
        //DADOS DOS PRODUTOS / SERVIÇOS
2673
        $texto = "DADOS DOS PRODUTOS / SERVIÇOS";
2674
        if ($this->orientacao == 'P') {
2675
            $w = $this->wPrint;
2676
        } else {
2677
            if ($nInicio < 2) { // primeira página
2678
                $w = $this->wPrint - $this->wCanhoto;
2679
            } else { // páginas seguintes
2680
                $w = $this->wPrint;
2681
            }
2682
        }
2683
        $h     = 4;
2684
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2685
        $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...
2686
        $y += 3;
2687
        //desenha a caixa dos dados dos itens da NF
2688
        $hmax  += 1;
2689
        $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...
2690
        $this->pdf->textBox($x, $y, $w, $hmax);
2691
        //##################################################################################
2692
        // cabecalho LOOP COM OS DADOS DOS PRODUTOS
2693
        //CÓDIGO PRODUTO
2694
        $texto = "CÓDIGO PRODUTO";
2695
        $w1    = round($w * 0.09, 0);
2696
        $h     = 4;
2697
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2698
        $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...
2699
        $this->pdf->line($x + $w1, $y, $x + $w1, $y + $hmax);
2700
        //DESCRIÇÃO DO PRODUTO / SERVIÇO
2701
        $x     += $w1;
2702
        $w2    = round($w * 0.25, 0);
2703
        $texto = 'DESCRIÇÃO DO PRODUTO / SERVIÇO';
2704
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2705
        $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...
2706
        $this->pdf->line($x + $w2, $y, $x + $w2, $y + $hmax);
2707
        //NCM/SH
2708
        $x     += $w2;
2709
        $w3    = round($w * 0.06, 0);
2710
        $texto = 'NCM/SH';
2711
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2712
        $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...
2713
        $this->pdf->line($x + $w3, $y, $x + $w3, $y + $hmax);
2714
        //O/CST ou O/CSOSN
2715
        $x     += $w3;
2716
        $w4    = round($w * 0.05, 0);
2717
        $texto = 'O/CSOSN';//Regime do Simples CRT = 1 ou CRT = 2
2718
        if ($this->getTagValue($this->emit, 'CRT') == '3') {
2719
            $texto = 'O/CST';//Regime Normal
2720
        }
2721
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2722
        $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...
2723
        $this->pdf->line($x + $w4, $y, $x + $w4, $y + $hmax);
2724
        //CFOP
2725
        $x     += $w4;
2726
        $w5    = round($w * 0.04, 0);
2727
        $texto = 'CFOP';
2728
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2729
        $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...
2730
        $this->pdf->line($x + $w5, $y, $x + $w5, $y + $hmax);
2731
        //UN
2732
        $x     += $w5;
2733
        $w6    = round($w * 0.03, 0);
2734
        $texto = 'UN';
2735
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2736
        $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...
2737
        $this->pdf->line($x + $w6, $y, $x + $w6, $y + $hmax);
2738
        //QUANT
2739
        $x     += $w6;
2740
        $w7    = round($w * 0.08, 0);
2741
        $texto = 'QUANT';
2742
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2743
        $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...
2744
        $this->pdf->line($x + $w7, $y, $x + $w7, $y + $hmax);
2745
        //VALOR UNIT
2746
        $x     += $w7;
2747
        $w8    = round($w * 0.06, 0);
2748
        $texto = 'VALOR UNIT';
2749
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2750
        $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...
2751
        $this->pdf->line($x + $w8, $y, $x + $w8, $y + $hmax);
2752
        //VALOR TOTAL
2753
        $x     += $w8;
2754
        $w9    = round($w * 0.06, 0);
2755
        $texto = 'VALOR TOTAL';
2756
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2757
        $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...
2758
        $this->pdf->line($x + $w9, $y, $x + $w9, $y + $hmax);
2759
        //VALOR DESCONTO
2760
        $x     += $w9;
2761
        $w10   = round($w * 0.05, 0);
2762
        $texto = 'VALOR DESC';
2763
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2764
        $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...
2765
        $this->pdf->line($x + $w10, $y, $x + $w10, $y + $hmax);
2766
        //B.CÁLC ICMS
2767
        $x     += $w10;
2768
        $w11   = round($w * 0.06, 0);
2769
        $texto = 'B.CÁLC ICMS';
2770
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2771
        $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...
2772
        $this->pdf->line($x + $w11, $y, $x + $w11, $y + $hmax);
2773
        //VALOR ICMS
2774
        $x     += $w11;
2775
        $w12   = round($w * 0.06, 0);
2776
        $texto = 'VALOR ICMS';
2777
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2778
        $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...
2779
        $this->pdf->line($x + $w12, $y, $x + $w12, $y + $hmax);
2780
        //VALOR IPI
2781
        $x     += $w12;
2782
        $w13   = round($w * 0.05, 0);
2783
        $texto = 'VALOR IPI';
2784
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2785
        $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...
2786
        $this->pdf->line($x + $w13, $y, $x + $w13, $y + $hmax);
2787
        //ALÍQ. ICMS
2788
        $x     += $w13;
2789
        $w14   = round($w * 0.04, 0);
2790
        $texto = 'ALÍQ. ICMS';
2791
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2792
        $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...
2793
        $this->pdf->line($x + $w14, $y, $x + $w14, $y + $hmax);
2794
        //ALÍQ. IPI
2795
        $x     += $w14;
2796
        $w15   = $w - ($w1 + $w2 + $w3 + $w4 + $w5 + $w6 + $w7 + $w8 + $w9 + $w10 + $w11 + $w12 + $w13 + $w14);
2797
        $texto = 'ALÍQ. IPI';
2798
        $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...
2799
        $this->pdf->line($oldX, $y + $h + 1, $oldX + $w, $y + $h + 1);
2800
        $y += 5;
2801
        //##################################################################################
2802
        // LOOP COM OS DADOS DOS PRODUTOS
2803
        $i      = 0;
2804
        $hUsado = $hCabecItens;
2805
        $aFont  = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
2806
2807
        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...
2808
            if ($i >= $nInicio) {
2809
                $thisItem = $this->det->item($i);
2810
                //carrega as tags do item
2811
                $prod         = $thisItem->getElementsByTagName("prod")->item(0);
2812
                $imposto      = $this->det->item($i)->getElementsByTagName("imposto")->item(0);
2813
                $ICMS         = $imposto->getElementsByTagName("ICMS")->item(0);
2814
                $IPI          = $imposto->getElementsByTagName("IPI")->item(0);
2815
                $textoProduto = $this->descricaoProduto($thisItem);
2816
                
2817
2818
                // Posição y dos dados das unidades tributaveis.
2819
                $yTrib = $this->pdf->fontSize + .5;
2820
2821
                $uCom = $prod->getElementsByTagName("uCom")->item(0)->nodeValue;
2822
                $uTrib = $prod->getElementsByTagName("uTrib")->item(0);
2823
                $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...
2824
                // A Configuração serve para informar se irá exibir
2825
                //   de forma obrigatória, estando diferente ou não,
2826
                //   a unidade de medida tributária.
2827
                // ========
2828
                // A Exibição será realizada sempre que a unidade comercial for
2829
                //   diferente da unidade de medida tributária.
2830
                // "Nas situações em que o valor unitário comercial for diferente do valor unitário tributável,
2831
                //   ambas as informações deverão estar expressas e identificadas no DANFE, podendo ser
2832
                //   utilizada uma das linhas adicionais previstas, ou o campo de informações adicionais."
2833
                // > Manual Integração - Contribuinte 4.01 - NT2009.006, Item 7.1.5, página 91.
2834
                $mostrarUnidadeTributavel = (!empty($uTrib) && strtoupper(trim($uCom)) !== strtoupper(trim($uTrib->nodeValue)));
2835
2836
                // Informação sobre unidade de medida tributavel.
2837
                // Se não for para exibir a unidade de medida tributavel, então
2838
                // A Escrita irá começar em 0.
2839
                if (! $mostrarUnidadeTributavel) {
2840
                    $yTrib = 0;
2841
                }
2842
                $h = $this->calculeHeight($thisItem, $mostrarUnidadeTributavel);
2843
                $hUsado += $h;
2844
2845
                $yTrib += $y;
2846
                $diffH = $hmax - $hUsado;
2847
2848
                if ($pag != $totpag) {
2849
                    if (1 > $diffH && $i < $totItens) {
2850
                        //ultrapassa a capacidade para uma única página
2851
                        //o restante dos dados serão usados nas proximas paginas
2852
                        $nInicio = $i;
2853
                        break;
2854
                    }
2855
                }
2856
                $y_linha = $y + $h;
2857
                // linha entre itens
2858
                $this->pdf->dashedHLine($oldX, $y_linha, $w, 0.1, 120);
2859
                //corrige o x
2860
                $x = $oldX;
2861
                //codigo do produto
2862
                $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...
2863
                $texto = $prod->getElementsByTagName("cProd")->item(0)->nodeValue;
2864
                $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...
2865
                $x += $w1;
2866
                //DESCRIÇÃO
2867
                if ($this->orientacao == 'P') {
2868
                    $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...
2869
                } else {
2870
                    $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...
2871
                }
2872
                $x += $w2;
2873
                //NCM
2874
                $texto = ! empty($prod->getElementsByTagName("NCM")->item(0)->nodeValue) ?
2875
                    $prod->getElementsByTagName("NCM")->item(0)->nodeValue : '';
2876
                $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...
2877
                $x += $w3;
2878
                //CST
2879
                if (isset($ICMS)) {
2880
                    $origem = $this->getTagValue($ICMS, "orig");
2881
                    $cst    = $this->getTagValue($ICMS, "CST");
2882
                    $csosn  = $this->getTagValue($ICMS, "CSOSN");
2883
                    $texto  = $origem . $cst . $csosn;
2884
                    $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...
2885
                }
2886
                //CFOP
2887
                $x     += $w4;
2888
                $texto = $prod->getElementsByTagName("CFOP")->item(0)->nodeValue;
2889
                $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...
2890
                //Unidade
2891
                $x     += $w5;
2892
                $texto = $uCom;
2893
                $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...
2894
                //Unidade de medida tributável
2895
                if ($mostrarUnidadeTributavel && !empty($uTrib)) {
2896
                    $texto = $uTrib->nodeValue;
2897
                    $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...
2898
                }
2899
                $x += $w6;
2900
                if ($this->orientacao == 'P') {
2901
                    $alinhamento = 'R';
2902
                } else {
2903
                    $alinhamento = 'R';
2904
                }
2905
                // QTDADE
2906
                $qCom  = $prod->getElementsByTagName("qCom")->item(0);
2907
                $texto = number_format($qCom->nodeValue, $this->qComCasasDec, ",", ".");
2908
                $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...
2909
                // QTDADE Tributável
2910
                if ($mostrarUnidadeTributavel) {
2911
                    $qTrib = $prod->getElementsByTagName("qTrib")->item(0);
2912
                    if (! empty($qTrib)) {
2913
                        $texto = number_format($qTrib->nodeValue, $this->qComCasasDec, ",", ".");
2914
                        $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...
2915
                    }
2916
                }
2917
                $x += $w7;
2918
                // Valor Unitário
2919
                $vUnCom = $prod->getElementsByTagName("vUnCom")->item(0);
2920
                $texto  = number_format($vUnCom->nodeValue, $this->vUnComCasasDec, ",", ".");
2921
                $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...
2922
                // Valor Unitário Tributável
2923
                if ($mostrarUnidadeTributavel) {
2924
                    $vUnTrib = $prod->getElementsByTagName("vUnTrib")->item(0);
2925
                    if (! empty($vUnTrib)) {
2926
                        $texto = number_format($vUnTrib->nodeValue, $this->vUnComCasasDec, ",", ".");
2927
                        $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...
2928
                    }
2929
                }
2930
                $x += $w8;
2931
                // Valor do Produto
2932
                $texto = "";
2933
                if (is_numeric($prod->getElementsByTagName("vProd")->item(0)->nodeValue)) {
2934
                    $texto = number_format($prod->getElementsByTagName("vProd")->item(0)->nodeValue, 2, ",", ".");
2935
                }
2936
                $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...
2937
                $x += $w9;
2938
                //Valor do Desconto
2939
                $vdesc = ! empty($prod->getElementsByTagName("vDesc")->item(0)->nodeValue)
2940
                    ? $prod->getElementsByTagName("vDesc")->item(0)->nodeValue : 0;
2941
2942
                $texto = number_format($vdesc, 2, ",", ".");
2943
                $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...
2944
                //Valor da Base de calculo
2945
                $x += $w10;
2946
                if (isset($ICMS)) {
2947
                    $texto = ! empty($ICMS->getElementsByTagName("vBC")->item(0)->nodeValue)
2948
                        ? number_format(
2949
                            $ICMS->getElementsByTagName("vBC")->item(0)->nodeValue,
2950
                            2,
2951
                            ",",
2952
                            "."
2953
                        )
2954
                        : '0,00';
2955
                    $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...
2956
                }
2957
                //Valor do ICMS
2958
                $x += $w11;
2959
                if (isset($ICMS)) {
2960
                    $texto = ! empty($ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue)
2961
                        ? number_format(
2962
                            $ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue,
2963
                            2,
2964
                            ",",
2965
                            "."
2966
                        )
2967
                        : '0,00';
2968
                    $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...
2969
                }
2970
                //Valor do IPI
2971
                $x += $w12;
2972
                if (isset($IPI)) {
2973
                    $texto = ! empty($IPI->getElementsByTagName("vIPI")->item(0)->nodeValue)
2974
                        ? number_format(
2975
                            $IPI->getElementsByTagName("vIPI")->item(0)->nodeValue,
2976
                            2,
2977
                            ",",
2978
                            "."
2979
                        )
2980
                        : '';
2981
                } else {
2982
                    $texto = '';
2983
                }
2984
                $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...
2985
                // %ICMS
2986
                $x += $w13;
2987
                if (isset($ICMS)) {
2988
                    $texto = ! empty($ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue)
2989
                        ? number_format(
2990
                            $ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue,
2991
                            2,
2992
                            ",",
2993
                            "."
2994
                        )
2995
                        : '0,00';
2996
                    $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...
2997
                }
2998
                //%IPI
2999
                $x += $w14;
3000
                if (isset($IPI)) {
3001
                    $texto = ! empty($IPI->getElementsByTagName("pIPI")->item(0)->nodeValue)
3002
                        ? number_format(
3003
                            $IPI->getElementsByTagName("pIPI")->item(0)->nodeValue,
3004
                            2,
3005
                            ",",
3006
                            "."
3007
                        )
3008
                        : '';
3009
                } else {
3010
                    $texto = '';
3011
                }
3012
                $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...
3013
3014
3015
                // Dados do Veiculo Somente para veiculo 0 Km
3016
                $veicProd = $prod->getElementsByTagName("veicProd")->item(0);
3017
                // Tag somente é gerada para veiculo 0k, e só é permitido um veiculo por NF-e por conta do detran
3018
                // Verifica se a Tag existe
3019
                if (! empty($veicProd)) {
3020
                    $this->dadosItenVeiculoDANFE($oldX, $y, $nInicio, $h, $prod);
3021
                }
3022
3023
3024
                $y += $h;
3025
                $i ++;
3026
                //incrementa o controle dos itens processados.
3027
                $this->qtdeItensProc ++;
3028
            } else {
3029
                $i ++;
3030
            }
3031
        }
3032
3033
        return $oldY + $hmax;
3034
    }
3035
3036
3037
    /**
3038
     * dadosItenVeiculoDANFE
3039
     * Coloca os dados do veiculo abaixo do item da NFe. (retrato e paisagem)
3040
     *
3041
     * @param float  $x    Posição horizontal
3042
     *                     canto esquerdo
3043
     * @param float  $y    Posição vertical
3044
     *                     canto superior
3045
     * @param        $nInicio
3046
     * @param float  $h    altura do campo
3047
     * @param object $prod Contendo todos os dados do item
3048
     */
3049
3050
    protected function dadosItenVeiculoDANFE($x, $y, &$nInicio, $h, $prod)
3051
    {
3052
        $oldX = $x;
3053
        $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...
3054
3055
        if ($this->orientacao == 'P') {
3056
            $w = $this->wPrint;
3057
        } else {
3058
            if ($nInicio < 2) { // primeira página
3059
                $w = $this->wPrint - $this->wCanhoto;
3060
            } else { // páginas seguintes
3061
                $w = $this->wPrint;
3062
            }
3063
        }
3064
3065
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
3066
3067
        $w1 = round($w * 0.09, 0);
3068
3069
        // Tabela Renavam Combustivel
3070
        $renavamCombustivel = [
3071
            1  => 'ALCOOL',
3072
            2  => 'GASOLINA',
3073
            3  => 'DIESEL',
3074
            4  => 'GASOGENIO',
3075
            5  => 'GAS METANO',
3076
            6  => 'ELETRICO/FONTE INTERNA',
3077
            7  => 'ELETRICO/FONTE EXTERNA',
3078
            8  => 'GASOL/GAS NATURAL COMBUSTIVEL',
3079
            9  => 'ALCOOL/GAS NATURAL COMBUSTIVEL',
3080
            10 => 'DIESEL/GAS NATURAL COMBUSTIVEL',
3081
            11 => 'VIDE/CAMPO/OBSERVACAO',
3082
            12 => 'ALCOOL/GAS NATURAL VEICULAR',
3083
            13 => 'GASOLINA/GAS NATURAL VEICULAR',
3084
            14 => 'DIESEL/GAS NATURAL VEICULAR',
3085
            15 => 'GAS NATURAL VEICULAR',
3086
            16 => 'ALCOOL/GASOLINA',
3087
            17 => 'GASOLINA/ALCOOL/GAS NATURAL',
3088
            18 => 'GASOLINA/ELETRICO'
3089
        ];
3090
3091
        $renavamEspecie = [
3092
            1 => 'PASSAGEIRO',
3093
            2 => 'CARGA',
3094
            3 => 'MISTO',
3095
            4 => 'CORRIDA',
3096
            5 => 'TRACAO',
3097
            6 => 'ESPECIAL',
3098
            7 => 'COLECAO'
3099
        ];
3100
3101
        $renavamTiposVeiculos = [
3102
            1  => 'BICICLETA',
3103
            2  => 'CICLOMOTOR',
3104
            3  => 'MOTONETA',
3105
            4  => 'MOTOCICLETA',
3106
            5  => 'TRICICLO',
3107
            6  => 'AUTOMOVEL',
3108
            7  => 'MICROONIBUS',
3109
            8  => 'ONIBUS',
3110
            9  => 'BONDE',
3111
            10 => 'REBOQUE',
3112
            11 => 'SEMI-REBOQUE',
3113
            12 => 'CHARRETE',
3114
            13 => 'CAMIONETA',
3115
            14 => 'CAMINHAO',
3116
            15 => 'CARROCA',
3117
            16 => 'CARRO DE MAO',
3118
            17 => 'CAMINHAO TRATOR',
3119
            18 => 'TRATOR DE RODAS',
3120
            19 => 'TRATOR DE ESTEIRAS',
3121
            20 => 'TRATOR MISTO',
3122
            21 => 'QUADRICICLO',
3123
            22 => 'CHASSI/PLATAFORMA',
3124
            23 => 'CAMINHONETE',
3125
            24 => 'SIDE-CAR',
3126
            25 => 'UTILITARIO',
3127
            26 => 'MOTOR-CASA'
3128
        ];
3129
3130
        $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...
3131
            'F' => 'FOSCA',
3132
            'S' => 'SÓLIDA',
3133
            'P' => 'PEROLIZADA',
3134
            'M' => 'METALICA',
3135
        ];
3136
3137
        $veicProd = $prod->getElementsByTagName("veicProd")->item(0);
3138
3139
        $veiculoChassi     = $veicProd->getElementsByTagName("chassi")->item(0)->nodeValue;
3140
        $veiculoCor        = $veicProd->getElementsByTagName("xCor")->item(0)->nodeValue;
3141
        $veiculoCilindrada = $veicProd->getElementsByTagName("cilin")->item(0)->nodeValue;
3142
        $veiculoCmkg       = $veicProd->getElementsByTagName("CMT")->item(0)->nodeValue;
3143
        $veiculoTipo       = $veicProd->getElementsByTagName("tpVeic")->item(0)->nodeValue;
3144
3145
        $veiculoMotor       = $veicProd->getElementsByTagName("nMotor")->item(0)->nodeValue;
3146
        $veiculoRenavam     = $veicProd->getElementsByTagName("cMod")->item(0)->nodeValue;
3147
        $veiculoHp          = $veicProd->getElementsByTagName("pot")->item(0)->nodeValue;
3148
        $veiculoPlaca       = ''; //$veiculo->getElementsByTagName("CMT")->item(0)->nodeValue;
3149
        $veiculoTipoPintura = $veicProd->getElementsByTagName("tpPint")->item(0)->nodeValue;
3150
        $veiculoMarcaModelo = $prod->getElementsByTagName("xProd")->item(0)->nodeValue;
3151
        $veiculoEspecie     = $veicProd->getElementsByTagName("espVeic")->item(0)->nodeValue;
3152
        $veiculoCombustivel = $veicProd->getElementsByTagName("tpComb")->item(0)->nodeValue;
3153
        $veiculoSerial      = $veicProd->getElementsByTagName("nSerie")->item(0)->nodeValue;
3154
        $veiculoFabricacao  = $veicProd->getElementsByTagName("anoFab")->item(0)->nodeValue;
3155
        $veiculoModelo      = $veicProd->getElementsByTagName("anoMod")->item(0)->nodeValue;
3156
        $veiculoDistancia   = $veicProd->getElementsByTagName("dist")->item(0)->nodeValue;
3157
3158
        $x = $oldX;
3159
3160
        $yVeic = $y + $h;
3161
        $texto = 'Chassi: ............: ' . $veiculoChassi;
3162
        $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...
3163
        $yVeic += $h;
3164
        $texto = 'Cor...................: ' . $veiculoCor;
3165
        $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...
3166
        $yVeic += $h;
3167
        $texto = 'Cilindrada........: ' . $veiculoCilindrada;
3168
        $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...
3169
        $yVeic += $h;
3170
        $texto = 'Cmkg...............: ' . $veiculoCmkg;
3171
        $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...
3172
        $yVeic += $h;
3173
        $texto = 'Tipo.................: ' . ($renavamTiposVeiculos[intval($veiculoTipo)] ?? $veiculoTipo);
3174
        $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...
3175
        $yVeic = $y + $h;
3176
        $xVeic = $x + 65;
3177
        $texto = 'Nº Motor: .........: ' . $veiculoMotor;
3178
        $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...
3179
        $yVeic += $h;
3180
        $texto = 'Renavam...........: ' . $veiculoRenavam;
3181
        $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...
3182
        $yVeic += $h;
3183
        $texto = 'HP.....................: ' . $veiculoHp;
3184
        $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...
3185
        $yVeic += $h;
3186
        $texto = 'Placa.................: ' . $veiculoPlaca;
3187
        $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...
3188
        $yVeic += $h;
3189
        $texto = 'Tipo Pintura......: ' . ($renavamEspecie[intval($veiculoTipoPintura)] ?? $veiculoTipoPintura);
3190
        $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...
3191
        $yVeic = $y + $h;
3192
        $xVeic = $xVeic + 55;
3193
        $texto = 'Marca / Modelo.....: ' . $veiculoMarcaModelo;
3194
        $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...
3195
        $yVeic += $h;
3196
        $texto = 'Especie..................: ' . ($renavamEspecie[intval($veiculoEspecie)] ?? $veiculoEspecie);
3197
        $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...
3198
        $yVeic += $h;
3199
        $texto = 'Combustivel..........: ' . ($renavamCombustivel[intval($veiculoCombustivel)] ?? $veiculoCombustivel);
3200
        $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...
3201
        $yVeic += $h;
3202
        $texto = 'Serial.....................: ' . $veiculoSerial;
3203
        $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...
3204
        $yVeic += $h;
3205
        $texto = 'Ano Fab/Mod........: ' . $veiculoFabricacao . '/' . $veiculoModelo;
3206
        $this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
3207
        $yVeic += $h;
3208
        $texto = 'Distancia Entre Eixos(mm)..: ' . $veiculoDistancia;
3209
        $this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
3210
    }
3211
3212
    /**
3213
     * issqn
3214
     * Monta o campo de serviços do DANFE
3215
     *
3216
     * @name   issqn (retrato e paisagem)
3217
     *
3218
     * @param float $x Posição horizontal canto esquerdo
3219
     * @param float $y Posição vertical canto superior
3220
     *
3221
     * @return float Posição vertical final
3222
     */
3223
    protected function issqn($x, $y)
3224
    {
3225
        $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...
3226
        //#####################################################################
3227
        //CÁLCULO DO ISSQN
3228
        $texto = "CÁLCULO DO ISSQN";
3229
        $w     = $this->wPrint;
3230
        $h     = 7;
3231
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
3232
        $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...
3233
        //INSCRIÇÃO MUNICIPAL
3234
        $y     += 3;
3235
        $w     = round($this->wPrint * 0.23, 0);
3236
        $texto = 'INSCRIÇÃO MUNICIPAL';
3237
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
3238
        $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...
3239
        //inscrição municipal
3240
        $texto = ! empty($this->emit->getElementsByTagName("IM")->item(0)->nodeValue) ?
3241
            $this->emit->getElementsByTagName("IM")->item(0)->nodeValue : '';
3242
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
3243
        $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...
3244
        //VALOR TOTAL DOS SERVIÇOS
3245
        $x     += $w;
3246
        $texto = 'VALOR TOTAL DOS SERVIÇOS';
3247
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
3248
        $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...
3249
        if (isset($this->ISSQNtot)) {
3250
            $texto = ! empty($this->ISSQNtot->getElementsByTagName("vServ")->item(0)->nodeValue) ?
3251
                $this->ISSQNtot->getElementsByTagName("vServ")->item(0)->nodeValue : '';
3252
            $texto = number_format($texto, 2, ",", ".");
3253
        } else {
3254
            $texto = '';
3255
        }
3256
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
3257
        $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...
3258
        //BASE DE CÁLCULO DO ISSQN
3259
        $x     += $w;
3260
        $texto = 'BASE DE CÁLCULO DO ISSQN';
3261
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
3262
        $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...
3263
        if (isset($this->ISSQNtot)) {
3264
            $texto = ! empty($this->ISSQNtot->getElementsByTagName("vBC")->item(0)->nodeValue) ?
3265
                $this->ISSQNtot->getElementsByTagName("vBC")->item(0)->nodeValue : '';
3266
            $texto = ! empty($texto) ? number_format($texto, 2, ",", ".") : '';
3267
        } else {
3268
            $texto = '';
3269
        }
3270
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
3271
        $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...
3272
        //VALOR TOTAL DO ISSQN
3273
        $x += $w;
3274
        if ($this->orientacao == 'P') {
3275
            $w = $this->wPrint - (3 * $w);
3276
        } else {
3277
            $w = $this->wPrint - (3 * $w) - $this->wCanhoto;
3278
        }
3279
        $texto = 'VALOR TOTAL DO ISSQN';
3280
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
3281
        $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...
3282
        if (isset($this->ISSQNtot)) {
3283
            $texto = ! empty($this->ISSQNtot->getElementsByTagName("vISS")->item(0)->nodeValue) ?
3284
                $this->ISSQNtot->getElementsByTagName("vISS")->item(0)->nodeValue : '';
3285
            $texto = ! empty($texto) ? number_format($texto, 2, ",", ".") : '';
3286
        } else {
3287
            $texto = '';
3288
        }
3289
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
3290
        $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...
3291
3292
        return ($y + $h + 1);
3293
    }
3294
3295
    /**
3296
     *dadosAdicionais
3297
     * Coloca o grupo de dados adicionais da NFe. (retrato e paisagem)
3298
     *
3299
     * @name   dadosAdicionais
3300
     *
3301
     * @param float $x Posição horizontal canto esquerdo
3302
     * @param float $y Posição vertical canto superior
3303
     * @param float $h altura do campo
3304
     *
3305
     * @return float Posição vertical final (eixo Y)
3306
     */
3307
    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...
3308
    {
3309
        $y = $this->maxH - (7 + $h);
3310
        //$y = $this->maxH - 20;
3311
        //##################################################################################
3312
        //DADOS ADICIONAIS
3313
        $texto = "DADOS ADICIONAIS";
3314
        if ($this->orientacao == 'P') {
3315
            $w = $this->wPrint;
3316
        } else {
3317
            $w = $this->wPrint - $this->wCanhoto;
3318
        }
3319
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
3320
        $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...
3321
3322
        //INFORMAÇÕES COMPLEMENTARES
3323
        $texto = "INFORMAÇÕES COMPLEMENTARES";
3324
        $y     += 3;
3325
        $w     = $this->wAdic;
3326
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => 'B'];
3327
        $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...
3328
        //o texto com os dados adicionais foi obtido na função montaDANFE
3329
        //e carregado em uma propriedade privada da classe
3330
        //$this->wAdic com a largura do campo
3331
        //$this->textoAdic com o texto completo do campo
3332
        //echo str_replace("\n", "<br>",$this->textoAdic);
3333
        //die;
3334
        $y     += 1;
3335
        $aFont = ['font' => $this->fontePadrao, 'size' => $this->textadicfontsize * $this->pdf->k, 'style' => ''];
3336
        //$aFont = ['font'=>$this->fontePadrao, 'size'=> 5, 'style'=>''];
3337
        $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...
3338
        //RESERVADO AO FISCO
3339
        $texto = "RESERVADO AO FISCO";
3340
        if (isset($this->nfeProc) && $this->nfeProc->getElementsByTagName("xMsg")->length) {
3341
            $texto = $texto . ' ' . $this->nfeProc->getElementsByTagName("xMsg")->item(0)->nodeValue;
3342
        }
3343
        $x += $w;
3344
        $y -= 1;
3345
        if ($this->orientacao == 'P') {
3346
            $w = $this->wPrint - $w;
3347
        } else {
3348
            $w = $this->wPrint - $w - $this->wCanhoto;
3349
        }
3350
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => 'B'];
3351
        $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...
3352
        //inserir texto informando caso de contingência
3353
        // 1 - Normal - emissão normal;
3354
        // 2 - Contingência FS - emissão em contingência com impressão do DANFE em Formulário de Segurança;
3355
        // 3 - Contingência SCAN - emissão em contingência no Sistema de Contingência do Ambiente Nacional;
3356
        // 4 - Contingência DPEC - emissão em contingência com envio da Declaração
3357
        //     Prévia de Emissão em Contingência;
3358
        // 5 - Contingência FS-DA - emissão em contingência com impressão do DANFE em Formulário de
3359
        //     Segurança para Impressão de Documento Auxiliar de Documento Fiscal Eletrônico (FS-DA);
3360
        // 6 - Contingência SVC-AN
3361
        // 7 - Contingência SVC-RS
3362
        $xJust  = $this->getTagValue($this->ide, 'xJust', 'Justificativa: ');
3363
        $dhCont = $this->getTagValue($this->ide, 'dhCont', ' Entrada em contingência : ');
3364
        $texto  = '';
3365
        switch ($this->tpEmis) {
3366
            case 2:
3367
                $texto = 'CONTINGÊNCIA FS' . $dhCont . $xJust;
3368
                break;
3369
            case 3:
3370
                $texto = 'CONTINGÊNCIA SCAN' . $dhCont . $xJust;
3371
                break;
3372
            case 4:
3373
                $texto = 'CONTINGÊNCIA DPEC' . $dhCont . $xJust;
3374
                break;
3375
            case 5:
3376
                $texto = 'CONTINGÊNCIA FSDA' . $dhCont . $xJust;
3377
                break;
3378
            case 6:
3379
                $texto = 'CONTINGÊNCIA SVC-AN' . $dhCont . $xJust;
3380
                break;
3381
            case 7:
3382
                $texto = 'CONTINGÊNCIA SVC-RS' . $dhCont . $xJust;
3383
                break;
3384
        }
3385
        $y     += 2;
3386
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
3387
        $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...
3388
3389
        return $y + $h;
3390
    }
3391
3392
    /**
3393
     * rodape
3394
     * Monta o rodapé no final da DANFE com a data/hora de impressão e informações
3395
     * sobre a API NfePHP
3396
     *
3397
     * @param float $x Posição horizontal canto esquerdo
3398
     *
3399
     * @return void
3400
     */
3401
    protected function rodape($x)
3402
    {
3403
        $y = $this->maxH - 4;
3404
        if ($this->orientacao == 'P') {
3405
            $w = $this->wPrint;
3406
        } else {
3407
            $w = $this->wPrint - $this->wCanhoto;
3408
            $x = $this->wCanhoto;
3409
        }
3410
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => 'I'];
3411
        $texto = "Impresso em " . date('d/m/Y') . " as " . date('H:i:s')
3412
            . '  ' . $this->creditos;
3413
        $this->pdf->textBox($x, $y, $w, 0, $texto, $aFont, 'T', 'L', false);
3414
        $texto = $this->powered ? "Powered by NFePHP®" : '';
3415
        $this->pdf->textBox($x, $y, $w, 0, $texto, $aFont, 'T', 'R', false, '');
3416
    }
3417
3418
    /**
3419
     * Monta o canhoto da DANFE (retrato e paisagem)
3420
     *
3421
     * @name   canhotoDANFE
3422
     *
3423
     * @param number $x Posição horizontal canto esquerdo
3424
     * @param number $y Posição vertical canto superior
3425
     *
3426
     * @return number Posição vertical final
3427
     *
3428
     * TODO 21/07/14 fmertins: quando orientação L-paisagem, o canhoto está sendo gerado incorretamente
3429
     */
3430
    protected function canhoto($x, $y)
3431
    {
3432
        $oldX = $x;
3433
        $oldY = $y;
3434
        //#################################################################################
3435
        //canhoto
3436
        //identificação do tipo de nf entrada ou saida
3437
        $tpNF = $this->ide->getElementsByTagName('tpNF')->item(0)->nodeValue;
3438
        if ($tpNF == '0') {
3439
            //NFe de Entrada
3440
            $emitente     = '';
3441
            $emitente     .= $this->dest->getElementsByTagName("xNome")->item(0)->nodeValue . " - ";
3442
            $emitente     .= $this->enderDest->getElementsByTagName("xLgr")->item(0)->nodeValue . ", ";
3443
            $emitente     .= $this->enderDest->getElementsByTagName("nro")->item(0)->nodeValue . " - ";
3444
            $emitente     .= $this->getTagValue($this->enderDest, "xCpl", " - ", " ");
3445
            $emitente     .= $this->enderDest->getElementsByTagName("xBairro")->item(0)->nodeValue . " ";
3446
            $emitente     .= $this->enderDest->getElementsByTagName("xMun")->item(0)->nodeValue . "-";
3447
            $emitente     .= $this->enderDest->getElementsByTagName("UF")->item(0)->nodeValue . "";
3448
            $destinatario = $this->emit->getElementsByTagName("xNome")->item(0)->nodeValue . " ";
3449
        } else {
3450
            //NFe de Saída
3451
            $emitente     = $this->emit->getElementsByTagName("xNome")->item(0)->nodeValue . " ";
3452
            $destinatario = '';
3453
            $destinatario .= $this->dest->getElementsByTagName("xNome")->item(0)->nodeValue . " - ";
3454
            $destinatario .= $this->enderDest->getElementsByTagName("xLgr")->item(0)->nodeValue . ", ";
3455
            $destinatario .= $this->enderDest->getElementsByTagName("nro")->item(0)->nodeValue . " ";
3456
            $destinatario .= $this->getTagValue($this->enderDest, "xCpl", " - ", " ");
3457
            $destinatario .= $this->enderDest->getElementsByTagName("xBairro")->item(0)->nodeValue . " ";
3458
            $destinatario .= $this->enderDest->getElementsByTagName("xMun")->item(0)->nodeValue . "-";
3459
            $destinatario .= $this->enderDest->getElementsByTagName("UF")->item(0)->nodeValue . " ";
3460
        }
3461
        //identificação do sistema emissor
3462
        //linha separadora do canhoto
3463
        if ($this->orientacao == 'P') {
3464
            $w = round($this->wPrint * 0.81, 0);
3465
        } else {
3466
            //linha separadora do canhoto - 238
3467
            //posicao altura
3468
            $y = $this->wPrint - 85;
3469
            //altura
3470
            $w = $this->wPrint - 85 - 24;
3471
        }
3472
        $h = 10;
3473
        //desenha caixa
3474
        $texto      = '';
3475
        $aFont      = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
3476
        $aFontSmall = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
3477
        if ($this->orientacao == 'P') {
3478
            $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...
3479
        } else {
3480
            $this->pdf->textBox90($x, $y, $w, $h, $texto, $aFont, 'C', 'L', 1, '', false);
3481
        }
3482
        $numNF = str_pad($this->ide->getElementsByTagName('nNF')->item(0)->nodeValue, 9, "0", STR_PAD_LEFT);
3483
        $serie = str_pad($this->ide->getElementsByTagName('serie')->item(0)->nodeValue, 3, "0", STR_PAD_LEFT);
3484
        $texto = "RECEBEMOS DE ";
3485
        $texto .= $emitente;
3486
        $texto .= " OS PRODUTOS E/OU SERVIÇOS CONSTANTES DA NOTA FISCAL ELETRÔNICA INDICADA ";
3487
        if ($this->orientacao == 'P') {
3488
            $texto .= "ABAIXO";
3489
        } else {
3490
            $texto .= "AO LADO";
3491
        }
3492
        $texto .= ". EMISSÃO: ";
3493
        $dEmi  = ! empty($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue) ?
3494
            $this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue : '';
3495
        if ($dEmi == '') {
3496
            $dEmi  = ! empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
3497
                $this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue : '';
3498
            $aDemi = explode('T', $dEmi);
3499
            $dEmi  = $aDemi[0];
3500
        }
3501
        $texto .= $this->ymdTodmy($dEmi) . " ";
3502
        $texto .= "VALOR TOTAL: R$ ";
3503
        $texto .= number_format($this->ICMSTot->getElementsByTagName("vNF")->item(0)->nodeValue, 2, ",", ".") . " ";
3504
        $texto .= "DESTINATÁRIO: ";
3505
        $texto .= $destinatario;
3506
        if ($this->orientacao == 'P') {
3507
            $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...
3508
            $x1    = $x + $w;
3509
            $w1    = $this->wPrint - $w;
3510
            $texto = "NF-e";
3511
            $aFont = ['font' => $this->fontePadrao, 'size' => 14, 'style' => 'B'];
3512
            $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...
3513
            $texto = "Nº. " . $this->formatField($numNF, "###.###.###") . " \n";
3514
            $texto .= "Série $serie";
3515
            $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
3516
            $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...
3517
            //DATA DE RECEBIMENTO
3518
            $texto = "DATA DE RECEBIMENTO";
3519
            $y     += $h;
3520
            $w2    = round($this->wPrint * 0.17, 0); //35;
3521
            $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
3522
            $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...
3523
            //IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR
3524
            $x     += $w2;
3525
            $w3    = $w - $w2;
3526
            $texto = "IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR";
3527
            $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...
3528
            $x = $oldX;
3529
            $y += 9;
3530
            $this->pdf->dashedHLine($x, $y, $this->wPrint, 0.1, 80);
3531
            $y += 2;
3532
3533
            return $y;
3534
        } else {
3535
            $x --;
3536
            $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...
3537
            //NUMERO DA NOTA FISCAL LOGO NFE
3538
            $w1    = 18;
3539
            $x1    = $oldX;
3540
            $y     = $oldY;
3541
            $texto = "NF-e";
3542
            $aFont = ['font' => $this->fontePadrao, 'size' => 14, 'style' => 'B'];
3543
            $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...
3544
            $texto = "Nº.\n" . $this->formatField($numNF, "###.###.###") . " \n";
3545
            $texto .= "Série $serie";
3546
            $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'];
3547
            $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...
3548
            //DATA DO RECEBIMENTO
3549
            $texto = "DATA DO RECEBIMENTO";
3550
            $y     = $this->wPrint - 85;
3551
            $x     = 12;
3552
            $w2    = round($this->wPrint * 0.17, 0); //35;
3553
            $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
3554
            $this->pdf->textBox90($x, $y, $w2, 8, $texto, $aFont, 'T', 'L', 1, '');
3555
            //IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR
3556
            $y     -= $w2;
3557
            $w3    = $w - $w2;
3558
            $texto = "IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR";
3559
            $aFont = ['font' => $this->fontePadrao, 'size' => 5.7, 'style' => ''];
3560
            $x     = $this->pdf->textBox90($x, $y, $w3, 8, $texto, $aFont, 'T', 'L', 1, '');
3561
            $this->pdf->dashedVLine(22, $oldY, 0.1, $this->wPrint, 69);
3562
3563
            return $x;
3564
        }
3565
    }
3566
3567
    /**
3568
     * geraInformacoesDaTagCompra
3569
     * Devolve uma string contendo informação sobre as tag <compra><xNEmp>, <xPed> e <xCont> ou string vazia.
3570
     * Aviso: Esta função não leva em consideração dados na tag xPed do item.
3571
     *
3572
     * @name   pGeraInformacoesDaTagCompra
3573
     * @return string com as informacoes dos pedidos.
3574
     */
3575
    protected function geraInformacoesDaTagCompra()
3576
    {
3577
        if (! $this->gerarInformacoesAutomaticas) {
3578
            return '';
3579
        }
3580
        $saida = "";
3581
        if (isset($this->compra)) {
3582
            if (! empty($this->compra->getElementsByTagName("xNEmp")->item(0)->nodeValue)) {
3583
                $saida .= " Nota de Empenho: " . $this->compra->getElementsByTagName("xNEmp")->item(0)->nodeValue;
3584
            }
3585
            if (! empty($this->compra->getElementsByTagName("xPed")->item(0)->nodeValue)) {
3586
                $saida .= " Pedido: " . $this->compra->getElementsByTagName("xPed")->item(0)->nodeValue;
3587
            }
3588
            if (! empty($this->compra->getElementsByTagName("xCont")->item(0)->nodeValue)) {
3589
                $saida .= " Contrato: " . $this->compra->getElementsByTagName("xCont")->item(0)->nodeValue;
3590
            }
3591
        }
3592
3593
        return $saida;
3594
    }
3595
3596
    /**
3597
     * geraChaveAdicionalDeContingencia
3598
     *
3599
     * @name   geraChaveAdicionalDeContingencia
3600
     * @return string chave
3601
     */
3602
    protected function geraChaveAdicionalDeContingencia()
3603
    {
3604
        //cUF tpEmis CNPJ vNF ICMSp ICMSs DD  DV
3605
        // Quantidade de caracteres  02   01      14  14    01    01  02 01
3606
        $forma = "%02d%d%s%014d%01d%01d%02d";
3607
        $cUF   = $this->ide->getElementsByTagName('cUF')->item(0)->nodeValue;
3608
        $CNPJ  = "00000000000000" . $this->emit->getElementsByTagName('CNPJ')->item(0)->nodeValue;
3609
        $CNPJ  = substr($CNPJ, - 14);
3610
        $vNF   = $this->ICMSTot->getElementsByTagName("vNF")->item(0)->nodeValue * 100;
3611
        $vICMS = $this->ICMSTot->getElementsByTagName("vICMS")->item(0)->nodeValue;
3612
        if ($vICMS > 0) {
3613
            $vICMS = 1;
3614
        }
3615
        $icmss = $this->ICMSTot->getElementsByTagName("vBC")->item(0)->nodeValue;
3616
        if ($icmss > 0) {
3617
            $icmss = 1;
3618
        }
3619
        $dEmi = ! empty($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue) ?
3620
            $this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue : '';
3621
        if ($dEmi == '') {
3622
            $dEmi  = ! empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
3623
                $this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue : '';
3624
            $aDemi = explode('T', $dEmi);
3625
            $dEmi  = $aDemi[0];
3626
        }
3627
        $dd    = $dEmi;
3628
        $rpos  = strrpos($dd, '-');
3629
        $dd    = substr($dd, $rpos + 1);
3630
        $chave = sprintf($forma, $cUF, $this->tpEmis, $CNPJ, $vNF, $vICMS, $icmss, $dd);
3631
        $chave = $chave . $this->modulo11($chave);
3632
3633
        return $chave;
3634
    }
3635
3636
    /**
3637
     *  geraInformacoesDasNotasReferenciadas
3638
     * Devolve uma string contendo informação sobre as notas referenciadas. Suporta N notas, eletrônicas ou não
3639
     * Exemplo: NFe Ref.: série: 01 número: 01 emit: 11.111.111/0001-01
3640
     * em 10/2010 [0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000]
3641
     *
3642
     * @return string Informacoes a serem adicionadas no rodapé sobre notas referenciadas.
3643
     */
3644
    protected function geraInformacoesDasNotasReferenciadas()
3645
    {
3646
        if (! $this->gerarInformacoesAutomaticas) {
3647
            return '';
3648
        }
3649
        $formaNfeRef = "\r\nNFe Ref.: série:%d número:%d emit:%s em %s [%s]";
3650
        $formaCTeRef = "\r\nCTe Ref.: série:%d número:%d emit:%s em %s [%s]";
3651
        $formaNfRef  = "\r\nNF  Ref.: série:%d numero:%d emit:%s em %s modelo: %d";
3652
        $formaECFRef = "\r\nECF Ref.: modelo: %s ECF:%d COO:%d";
3653
        $formaNfpRef = "\r\nNFP Ref.: série:%d número:%d emit:%s em %s modelo: %d IE:%s";
3654
        $saida       = '';
3655
        $nfRefs      = $this->ide->getElementsByTagName('NFref');
3656
        if (0 === $nfRefs->length) {
3657
            return $saida;
3658
        }
3659
        if ($nfRefs->length > 2) {
3660
            return 'Existem mais de 2 NF/NFe/ECF/NFP/CTe referenciadas, não serão exibidas na DANFE.';
3661
        }
3662
        foreach ($nfRefs as $nfRef) {
3663
            if (empty($nfRef)) {
3664
                continue;
3665
            }
3666
            $refNFe = $nfRef->getElementsByTagName('refNFe');
3667
            foreach ($refNFe as $chave_acessoRef) {
3668
                $chave_acesso  = $chave_acessoRef->nodeValue;
3669
                $chave_acessoF = $this->formatField($chave_acesso, $this->formatoChave);
3670
                $data          = substr($chave_acesso, 4, 2) . "/20" . substr($chave_acesso, 2, 2);
3671
                $cnpj          = $this->formatField(substr($chave_acesso, 6, 14), "##.###.###/####-##");
3672
                $serie         = substr($chave_acesso, 22, 3);
3673
                $numero        = substr($chave_acesso, 25, 9);
3674
                $saida         .= sprintf($formaNfeRef, $serie, $numero, $cnpj, $data, $chave_acessoF);
3675
            }
3676
            $refNF = $nfRef->getElementsByTagName('refNF');
3677
            foreach ($refNF as $umaRefNFe) {
3678
                $data   = $umaRefNFe->getElementsByTagName('AAMM')->item(0)->nodeValue;
3679
                $cnpj   = $umaRefNFe->getElementsByTagName('CNPJ')->item(0)->nodeValue;
3680
                $mod    = $umaRefNFe->getElementsByTagName('mod')->item(0)->nodeValue;
3681
                $serie  = $umaRefNFe->getElementsByTagName('serie')->item(0)->nodeValue;
3682
                $numero = $umaRefNFe->getElementsByTagName('nNF')->item(0)->nodeValue;
3683
                $data   = substr($data, 2, 2) . "/20" . substr($data, 0, 2);
3684
                $cnpj   = $this->formatField($cnpj, "##.###.###/####-##");
3685
                $saida  .= sprintf($formaNfRef, $serie, $numero, $cnpj, $data, $mod);
3686
            }
3687
            $refCTe = $nfRef->getElementsByTagName('refCTe');
3688
            foreach ($refCTe as $chave_acessoRef) {
3689
                $chave_acesso  = $chave_acessoRef->nodeValue;
3690
                $chave_acessoF = $this->formatField($chave_acesso, $this->formatoChave);
3691
                $data          = substr($chave_acesso, 4, 2) . "/20" . substr($chave_acesso, 2, 2);
3692
                $cnpj          = $this->formatField(substr($chave_acesso, 6, 14), "##.###.###/####-##");
3693
                $serie         = substr($chave_acesso, 22, 3);
3694
                $numero        = substr($chave_acesso, 25, 9);
3695
                $saida         .= sprintf($formaCTeRef, $serie, $numero, $cnpj, $data, $chave_acessoF);
3696
            }
3697
            $refECF = $nfRef->getElementsByTagName('refECF');
3698
            foreach ($refECF as $umaRefNFe) {
3699
                $mod   = $umaRefNFe->getElementsByTagName('mod')->item(0)->nodeValue;
3700
                $nECF  = $umaRefNFe->getElementsByTagName('nECF')->item(0)->nodeValue;
3701
                $nCOO  = $umaRefNFe->getElementsByTagName('nCOO')->item(0)->nodeValue;
3702
                $saida .= sprintf($formaECFRef, $mod, $nECF, $nCOO);
3703
            }
3704
            $refNFP = $nfRef->getElementsByTagName('refNFP');
3705
            foreach ($refNFP as $umaRefNFe) {
3706
                $data   = $umaRefNFe->getElementsByTagName('AAMM')->item(0)->nodeValue;
3707
                $cnpj   = ! empty($umaRefNFe->getElementsByTagName('CNPJ')->item(0)->nodeValue) ?
3708
                    $umaRefNFe->getElementsByTagName('CNPJ')->item(0)->nodeValue :
3709
                    '';
3710
                $cpf    = ! empty($umaRefNFe->getElementsByTagName('CPF')->item(0)->nodeValue) ?
3711
                    $umaRefNFe->getElementsByTagName('CPF')->item(0)->nodeValue : '';
3712
                $mod    = $umaRefNFe->getElementsByTagName('mod')->item(0)->nodeValue;
3713
                $serie  = $umaRefNFe->getElementsByTagName('serie')->item(0)->nodeValue;
3714
                $numero = $umaRefNFe->getElementsByTagName('nNF')->item(0)->nodeValue;
3715
                $ie     = $umaRefNFe->getElementsByTagName('IE')->item(0)->nodeValue;
3716
                $data   = substr($data, 2, 2) . "/20" . substr($data, 0, 2);
3717
                if ($cnpj == '') {
3718
                    $cpf_cnpj = $this->formatField($cpf, "###.###.###-##");
3719
                } else {
3720
                    $cpf_cnpj = $this->formatField($cnpj, "##.###.###/####-##");
3721
                }
3722
                $saida .= sprintf($formaNfpRef, $serie, $numero, $cpf_cnpj, $data, $mod, $ie);
3723
            }
3724
        }
3725
3726
        return $saida;
3727
    }
3728
3729
    private function loadDoc($xml)
3730
    {
3731
        $this->xml = $xml;
3732
        if (! empty($xml)) {
3733
            $this->dom = new Dom();
3734
            $this->dom->loadXML($this->xml);
3735
            if (empty($this->dom->getElementsByTagName("infNFe")->item(0))) {
3736
                throw new \Exception('Isso não é um NFe.');
3737
            }
3738
            $this->nfeProc = $this->dom->getElementsByTagName("nfeProc")->item(0);
3739
            $this->infNFe  = $this->dom->getElementsByTagName("infNFe")->item(0);
3740
            $this->ide     = $this->dom->getElementsByTagName("ide")->item(0);
3741
            if ($this->getTagValue($this->ide, "mod") != '55') {
3742
                throw new \Exception("O xml deve ser NF-e modelo 55.");
3743
            }
3744
            $this->entrega    = $this->dom->getElementsByTagName("entrega")->item(0);
3745
            $this->retirada   = $this->dom->getElementsByTagName("retirada")->item(0);
3746
            $this->emit       = $this->dom->getElementsByTagName("emit")->item(0);
3747
            $this->dest       = $this->dom->getElementsByTagName("dest")->item(0);
3748
            $this->enderEmit  = $this->dom->getElementsByTagName("enderEmit")->item(0);
3749
            $this->enderDest  = $this->dom->getElementsByTagName("enderDest")->item(0);
3750
            $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...
3751
            $this->cobr       = $this->dom->getElementsByTagName("cobr")->item(0);
3752
            $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...
3753
            $this->ICMSTot    = $this->dom->getElementsByTagName("ICMSTot")->item(0);
3754
            $this->ISSQNtot   = $this->dom->getElementsByTagName("ISSQNtot")->item(0);
3755
            $this->transp     = $this->dom->getElementsByTagName("transp")->item(0);
3756
            $this->transporta = $this->dom->getElementsByTagName("transporta")->item(0);
3757
            $this->veicTransp = $this->dom->getElementsByTagName("veicTransp")->item(0);
3758
            $this->detPag     = $this->dom->getElementsByTagName("detPag");
3759
            $this->reboque    = $this->dom->getElementsByTagName("reboque")->item(0);
3760
            $this->infAdic    = $this->dom->getElementsByTagName("infAdic")->item(0);
3761
            $this->compra     = $this->dom->getElementsByTagName("compra")->item(0);
3762
            $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...
3763
            $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...
3764
            $this->infProt    = $this->dom->getElementsByTagName("infProt")->item(0);
3765
        }
3766
    }
3767
3768
    /**
3769
     * @param $item
3770
     *
3771
     * @return float
3772
     */
3773
    protected function calculeHeight($item, $mostrarUnidadeTributavel = false)
3774
    {
3775
        if ($this->orientacao == 'P') {
3776
            $w = $this->wPrint;
3777
        } else {
3778
            $w = $this->wPrint - $this->wCanhoto;
3779
        }
3780
        $w2           = round($w * 0.25, 0);
3781
        $aFont        = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
3782
        $textoProduto = $this->descricaoProduto($item);
3783
        $numlinhas    = $this->pdf->getNumLines($textoProduto, $w2, $aFont);
3784
3785
        if ($mostrarUnidadeTributavel && $numlinhas == 1) {
3786
            $numlinhas ++;
3787
        }
3788
3789
        return round(($numlinhas * $this->pdf->fontSize) + ($numlinhas * 0.5), 2);
3790
    }
3791
}
3792