Passed
Push — master ( d84d98...50dd51 )
by Roberto
03:48 queued 10s
created

Danfe   F

Complexity

Total Complexity 430

Size/Duplication

Total Lines 3829
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 3829
ccs 0
cts 2859
cp 0
rs 0.8
c 0
b 0
f 0
wmc 430
lcom 1
cbo 3

33 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A epec() 0 10 2
A obsContShow() 0 4 1
A setVUnComCasasDec() 0 4 1
A setQComCasasDec() 0 4 1
F calculoEspacoVericalDadosAdicionais() 0 86 21
F monta() 0 280 44
F anfaveaDANFE() 0 143 37
D statusNFe() 0 54 18
F header() 0 383 31
F destinatarioDANFE() 0 203 22
F localEntregaDANFE() 0 141 12
F localRetiradaDANFE() 0 141 12
B getTextoFatura() 0 30 7
A sizeExtraTextoFatura() 0 10 3
F fatura() 0 116 20
F pagamento() 0 120 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 379 35
B dadosItenVeiculoDANFE() 0 161 3
D issqn() 0 71 11
C dadosAdicionais() 0 78 9
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
     * @var array
278
     */
279
    protected $epec = [];
280
    /**
281
     * @var bool
282
     */
283
    protected $obsshow = true;
284
285
    /**
286
     * __construct
287
     *
288
     * @name  __construct
289
     *
290
     * @param string $xml Conteúdo XML da NF-e (com ou sem a tag nfeProc)
291
     */
292
    public function __construct($xml)
293
    {
294
        $this->loadDoc($xml);
295
    }
296
    
297
    public function epec($protocolo, $data)
298
    {
299
        if ($this->dom->getElementsByTagName("tpEmis")->item(0)->nodeValue != '4') {
300
            throw new \Exception('Esta nota não foi emitida em contingência EPEC, tpEmis != 4.');
301
        }
302
        $this->epec = [
303
            'protocolo' => $protocolo,
304
            'data' => $data
305
        ];
306
    }
307
308
    public function obsContShow($flag = true)
309
    {
310
        $this->obsshow = $flag;
311
    }
312
313
    /**
314
     * Define a quantidade de casas decimais para unidade comercial.
315
     *
316
     * @param integer $vUnComCasasDec
317
     */
318
    public function setVUnComCasasDec($vUnComCasasDec)
319
    {
320
        $this->vUnComCasasDec = $vUnComCasasDec;
321
    }
322
323
    /**
324
     * Define a quantidade de casas decimais para unidade comercial.
325
     *
326
     * @param integer $qComCasasDec
327
     */
328
    public function setQComCasasDec($qComCasasDec)
329
    {
330
        $this->qComCasasDec = $qComCasasDec;
331
    }
332
333
    protected function calculoEspacoVericalDadosAdicionais()
334
    {
335
        $this->textoAdic = '';
336
        //informações adicionais
337
        $fontProduto            = [
338
            'font'  => $this->fontePadrao,
339
            'size'  => 8,
340
            'style' => ''
341
        ];
342
        $k                      = $this->pdf->k;
343
        $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...
344
        $this->textoAdic        .= $this->geraInformacoesDasNotasReferenciadas();
345
        if (isset($this->infAdic)) {
346
            $i = 0;
347
            if ($this->textoAdic != '') {
348
                $this->textoAdic .= ". \n";
349
            }
350
            $this->textoAdic .= ! empty($this->getTagValue($this->infAdic, "infCpl"))
351
                ? 'Inf. Contribuinte: ' . $this->anfaveaDANFE($this->getTagValue($this->infAdic, "infCpl"))
352
                : '';
353
            $infPedido       = $this->geraInformacoesDaTagCompra();
354
            if ($infPedido != "") {
355
                $this->textoAdic .= $infPedido;
356
            }
357
            $this->textoAdic .= $this->getTagValue($this->dest, "email", ' Email do Destinatário: ');
358
            $this->textoAdic .= ! empty($this->getTagValue($this->infAdic, "infAdFisco"))
359
                ? "\n Inf. fisco: " . $this->getTagValue($this->infAdic, "infAdFisco")
360
                : '';
361
            if ($this->obsshow) {
362
                $obsCont = $this->infAdic->getElementsByTagName("obsCont");
363
                if (isset($obsCont)) {
364
                    foreach ($obsCont as $obs) {
365
                        $campo           = $obsCont->item($i)->getAttribute("xCampo");
366
                        $xTexto          = ! empty($obsCont->item($i)->getElementsByTagName("xTexto")->item(0)->nodeValue)
367
                            ? $obsCont->item($i)->getElementsByTagName("xTexto")->item(0)->nodeValue
368
                            : '';
369
                        $this->textoAdic .= "\n" . $campo . ':  ' . trim($xTexto);
370
                        $i ++;
371
                    }
372
                }
373
            }
374
        }
375
        //INCLUSO pela NT 2013.003 Lei da Transparência
376
        //verificar se a informação sobre o valor aproximado dos tributos
377
        //já se encontra no campo de informações adicionais
378
        if ($this->exibirValorTributos) {
379
            $flagVTT  = strpos(strtolower(trim($this->textoAdic)), 'valor');
380
            $flagVTT  = $flagVTT || strpos(strtolower(trim($this->textoAdic)), 'vl');
381
            $flagVTT  = $flagVTT && strpos(strtolower(trim($this->textoAdic)), 'aprox');
382
            $flagVTT  = $flagVTT && (strpos(strtolower(trim($this->textoAdic)), 'trib') ||
383
                    strpos(strtolower(trim($this->textoAdic)), 'imp'));
384
            $vTotTrib = $this->getTagValue($this->ICMSTot, 'vTotTrib');
385
            if ($vTotTrib != '' && ! $flagVTT) {
386
                $this->textoAdic .= "\n Valor Aproximado dos Tributos : R$ "
387
                    . number_format($vTotTrib, 2, ",", ".");
388
            }
389
        }
390
        //fim da alteração NT 2013.003 Lei da Transparência
391
        $this->textoAdic        = str_replace(";", "\n", $this->textoAdic);
392
        $numlinhasdados         = $this->pdf->getNumLines($this->textoAdic, $this->wAdic, $fontProduto) + 1.5;
393
        $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...
394
        $hdadosadic             = ceil($numlinhasdados * ($this->textadicfontsize));
395
        if ($hdadosadic > 70) {
396
            for ($f = 8; $f > 3; $f --) {
397
                $this->pdf->setFont($this->fontePadrao, '', $f);
398
                $fontProduto            = [
399
                    'font'  => $this->fontePadrao,
400
                    'size'  => $f,
401
                    'style' => ''
402
                ];
403
                $numlinhasdados         = $this->pdf->getNumLines($this->textoAdic, $this->wAdic, $fontProduto) + 3;
404
                $this->textadicfontsize = $this->pdf->fontSize;
405
                $hdadosadic             = ceil($numlinhasdados * $this->textadicfontsize);
406
                echo $hdadosadic;
407
                if ($hdadosadic <= 90) {
408
                    $hdadosadic = ceil($hdadosadic);
409
                    break;
410
                }
411
            }
412
        }
413
        if ($hdadosadic < 10) {
414
            $hdadosadic = 10;
415
        }
416
417
        return $hdadosadic;
418
    }
419
420
    /**
421
     * monta
422
     * Monta a DANFE conforme as informações fornecidas para a classe durante sua
423
     * construção. Constroi DANFEs com até 3 páginas podendo conter até 56 itens.
424
     * A definição de margens e posições iniciais para a impressão são estabelecidas
425
     * pelo conteúdo da funçao e podem ser modificados.
426
     *
427
     * @return string O ID da NFe numero de 44 digitos extraido do arquivo XML
428
     */
429
    protected function monta(
430
        $logo = ''
431
    ) {
432
        $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...
433
        $this->logomarca = $this->adjustImage($logo);
434
        //se a orientação estiver em branco utilizar o padrão estabelecido na NF
435
        if (empty($this->orientacao)) {
436
            if ($this->tpImp == '2') {
437
                $this->orientacao = 'L';
438
            } else {
439
                $this->orientacao = 'P';
440
            }
441
        }
442
        //instancia a classe pdf
443
        $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...
444
        //margens do PDF, em milímetros. Obs.: a margem direita é sempre igual à
445
        //margem esquerda. A margem inferior *não* existe na FPDF, é definida aqui
446
        //apenas para controle se necessário ser maior do que a margem superior
447
        // posição inicial do conteúdo, a partir do canto superior esquerdo da página
448
        $xInic = $this->margesq;
449
        if ($this->orientacao == 'P') {
450
            if ($this->papel == 'A4') {
451
                $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...
452
                $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...
453
            }
454
        } else {
455
            if ($this->papel == 'A4') {
456
                $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...
457
                $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...
458
                $xInic      = $this->margesq + 10;
459
                //se paisagem multiplica a largura do canhoto pela quantidade de canhotos
460
                //$this->wCanhoto *= $this->qCanhoto;
461
            }
462
        }
463
        //total inicial de paginas
464
        $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...
465
        //largura imprimivel em mm: largura da folha menos as margens esq/direita
466
        $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...
467
        //comprimento (altura) imprimivel em mm: altura da folha menos as margens
468
        //superior e inferior
469
        $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...
470
        // estabelece contagem de paginas
471
        $this->pdf->aliasNbPages();
472
        // fixa as margens
473
        $this->pdf->setMargins($this->margesq, $this->margsup);
474
        $this->pdf->setDrawColor(0, 0, 0);
475
        $this->pdf->setFillColor(255, 255, 255);
476
        // inicia o documento
477
        $this->pdf->open();
478
        // adiciona a primeira página
479
        $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...
480
        $this->pdf->setLineWidth(0.1);
481
        $this->pdf->settextcolor(0, 0, 0);
482
483
        //##################################################################
484
        // CALCULO DO NUMERO DE PAGINAS A SEREM IMPRESSAS
485
        //##################################################################
486
        //Verificando quantas linhas serão usadas para impressão das duplicatas
487
        $linhasDup = 0;
488
        $qtdPag    = 0;
489
        if (isset($this->dup) && $this->dup->length > 0) {
490
            $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...
491
        } 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...
492
            $qtdPag = $this->detPag->length;
493
        }
494
        if (($qtdPag > 0) && ($qtdPag <= 7)) {
495
            $linhasDup = 1;
496
        } elseif (($qtdPag > 7) && ($qtdPag <= 14)) {
497
            $linhasDup = 2;
498
        } elseif (($qtdPag > 14) && ($qtdPag <= 21)) {
499
            $linhasDup = 3;
500
        } elseif ($qtdPag > 21) {
501
            // chinnonsantos 11/05/2016: Limite máximo de impressão de duplicatas na NFe,
502
            // só vai ser exibito as 21 primeiras duplicatas (parcelas de pagamento),
503
            // se não oculpa espaço d+, cada linha comporta até 7 duplicatas.
504
            $linhasDup = 3;
505
        }
506
        //verifica se será impressa a linha dos serviços ISSQN
507
        $linhaISSQN = 0;
508
        if ((isset($this->ISSQNtot)) && ($this->getTagValue($this->ISSQNtot, 'vServ') > 0)) {
509
            $linhaISSQN = 1;
510
        }
511
        //calcular a altura necessária para os dados adicionais
512
        if ($this->orientacao == 'P') {
513
            $this->wAdic = round($this->wPrint * 0.66, 0);
514
        } else {
515
            $this->wAdic = round(($this->wPrint - $this->wCanhoto) * 0.5, 0);
516
        }
517
        $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...
518
519
        $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...
520
521
        //altura disponivel para os campos da DANFE
522
        $hcabecalho    = 47;//para cabeçalho
523
        $hdestinatario = 25;//para destinatario
524
        $hduplicatas   = 12;//para cada grupo de 7 duplicatas
525
        if (isset($this->entrega)) {
526
            $hlocalentrega = 25;
527
        } else {
528
            $hlocalentrega = 0;
529
        }
530
        if (isset($this->retirada)) {
531
            $hlocalretirada = 25;
532
        } else {
533
            $hlocalretirada = 0;
534
        }
535
        $himposto    = 18;// para imposto
536
        $htransporte = 25;// para transporte
537
        $hissqn      = 11;// para issqn
538
        $hfooter     = 5;// para rodape
539
        $hCabecItens = 4;//cabeçalho dos itens
540
        $hOCUPADA    = $hcabecalho
541
            + $hdestinatario
542
            + $hlocalentrega
543
            + $hlocalretirada
544
            + ($linhasDup * $hduplicatas)
545
            + $himposto + $htransporte
546
            + ($linhaISSQN * $hissqn)
547
            + $this->hdadosadic
548
            + $hfooter
549
            + $hCabecItens
550
            + $this->sizeExtraTextoFatura();
551
552
        //alturas disponiveis para os dados
553
        $hDispo1 = $this->hPrint - $hOCUPADA;
554
        /*($hcabecalho +
555
        //$hdestinatario + ($linhasDup * $hduplicatas) + $himposto + $htransporte +
556
        $hdestinatario + $hlocalentrega + $hlocalretirada +
557
        ($linhasDup * $hduplicatas) + $himposto + $htransporte +
558
        ($linhaISSQN * $hissqn) + $this->hdadosadic + $hfooter + $hCabecItens +
559
        $this->sizeExtraTextoFatura());*/
560
561
        if ($this->orientacao == 'P') {
562
            $hDispo1 -= 24 * $this->qCanhoto;//para canhoto
563
            $w       = $this->wPrint;
564
        } else {
565
            $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...
566
            $w        = $this->wPrint - $this->wCanhoto;
567
        }
568
        //$hDispo1 += 14;
569
        $hDispo2 = $this->hPrint - ($hcabecalho + $hfooter + $hCabecItens);
570
        //Contagem da altura ocupada para impressão dos itens
571
        $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...
572
        $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...
573
        $hUsado    = $hCabecItens;
574
        $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...
575
        $hDispo    = $hDispo1;
576
        $totPag    = 1;
577
        $i         = 0;
578
        while ($i < $this->det->length) {
579
            $itemProd = $this->det->item($i);
580
            $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...
581
            $mostrarUnidadeTributavel = false;
0 ignored issues
show
Unused Code introduced by
$mostrarUnidadeTributavel is not used, you could remove the assignment.

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

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

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

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

Loading history...
582
583
            $prod = $itemProd->getElementsByTagName('prod')->item(0);
584
            $uCom = $prod->getElementsByTagName("uCom")->item(0)->nodeValue;
0 ignored issues
show
Unused Code introduced by
$uCom is not used, you could remove the assignment.

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

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

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

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

Loading history...
585
            $vUnCom = $prod->getElementsByTagName("vUnCom")->item(0)->nodeValue;
586
            $uTrib = $prod->getElementsByTagName("uTrib")->item(0);
587
            $qTrib = $prod->getElementsByTagName("qTrib")->item(0);
588
            $vUnTrib = !empty($prod->getElementsByTagName("vUnTrib")->item(0)->nodeValue)
589
                ? $prod->getElementsByTagName("vUnTrib")->item(0)->nodeValue
590
                : 0;
591
            //se as unidades forem diferentes e q qtda de qTrib for maior que 0
592
            //mostrat as unidades
593
            $mostrarUnidadeTributavel = (
594
                !empty($uTrib)
595
                && !empty($qTrib)
596
                && number_format($vUnCom, 2, ',', '') !== number_format($vUnTrib, 2, ',', '')
597
            );
598
            $hUsado += $this->calculeHeight($itemProd, $mostrarUnidadeTributavel);
599
            if ($hUsado > $hDispo) {
600
                $totPag ++;
601
                $hDispo = $hDispo2;
602
                $hUsado = $hCabecItens;
603
                $i --; // decrementa para readicionar o item que não coube nessa pagina na outra.
604
            }
605
            $i ++;
606
        } //fim da soma das areas de itens usadas
607
        $qtdeItens = $i; //controle da quantidade de itens no DANFE
608
        //montagem da primeira página
609
        $pag = 1;
610
611
        $x = $this->margesq;
612
        $y = $this->margsup;
613
        //coloca o(s) canhoto(s) da NFe
614
        if ($this->orientacao == 'P') {
615
            $y = $this->canhoto($this->margesq, $this->margsup);
616
        } else {
617
            $this->canhoto($this->margesq, $this->margsup);
618
            $x = 25;
619
        }
620
        //coloca o cabeçalho
621
        $y = $this->header($x, $y, $pag, $totPag);
622
        //coloca os dados do destinatário
623
        $y = $this->destinatarioDANFE($x, $y + 1);
624
        //coloca os dados do local de retirada
625
        if (isset($this->retirada)) {
626
            $y = $this->localRetiradaDANFE($x, $y + 1);
627
        }
628
        //coloca os dados do local de entrega
629
        if (isset($this->entrega)) {
630
            $y = $this->localEntregaDANFE($x, $y + 1);
631
        }
632
633
        //Verifica as formas de pagamento da nota fiscal
634
        $formaPag = [];
635
        if (isset($this->detPag) && $this->detPag->length > 0) {
636
            foreach ($this->detPag as $k => $d) {
637
                $fPag            = ! empty($this->detPag->item($k)->getElementsByTagName('tPag')->item(0)->nodeValue)
638
                    ? $this->detPag->item($k)->getElementsByTagName('tPag')->item(0)->nodeValue
639
                    : '0';
640
                $formaPag[$fPag] = $fPag;
641
            }
642
        }
643
        //caso tenha boleto imprimir fatura
644
        if ($this->dup->length > 0) {
645
            $y = $this->fatura($x, $y + 1);
646
        } else {
647
            //Se somente tiver a forma de pagamento sem pagamento não imprimir nada
648
            if (count($formaPag) == '1' && isset($formaPag[90])) {
649
                $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...
650
            } else {
651
                //caso tenha mais de uma forma de pagamento ou seja diferente de boleto exibe a
652
                //forma de pagamento e o valor
653
                $y = $this->pagamento($x, $y + 1);
654
            }
655
        }
656
        //coloca os dados dos impostos e totais da NFe
657
        $y = $this->imposto($x, $y + 1);
658
        //coloca os dados do trasnporte
659
        $y = $this->transporte($x, $y + 1);
660
        //itens da DANFE
661
        $nInicial = 0;
662
663
        $y = $this->itens($x, $y + 1, $nInicial, $hDispo1, $pag, $totPag, $hCabecItens);
664
665
        //coloca os dados do ISSQN
666
        if ($linhaISSQN == 1) {
667
            $y = $this->issqn($x, $y + 4);
668
        } else {
669
            $y += 4;
670
        }
671
        //coloca os dados adicionais da NFe
672
        $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...
673
        //coloca o rodapé da página
674
        if ($this->orientacao == 'P') {
675
            $this->rodape($xInic);
676
        } else {
677
            $this->rodape($xInic);
678
        }
679
680
        //loop para páginas seguintes
681
        for ($n = 2; $n <= $totPag; $n ++) {
682
            // fixa as margens
683
            $this->pdf->setMargins($this->margesq, $this->margsup);
684
            //adiciona nova página
685
            $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...
686
            //ajusta espessura das linhas
687
            $this->pdf->setLineWidth(0.1);
688
            //seta a cor do texto para petro
689
            $this->pdf->settextcolor(0, 0, 0);
690
            // posição inicial do relatorio
691
            $x = $this->margesq;
692
            $y = $this->margsup;
693
            //coloca o cabeçalho na página adicional
694
            $y = $this->header($x, $y, $n, $totPag);
695
            //coloca os itens na página adicional
696
            $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...
697
            //coloca o rodapé da página
698
            if ($this->orientacao == 'P') {
699
                $this->rodape($this->margesq);
700
            } else {
701
                $this->rodape($this->margesq);
702
            }
703
            //se estiver na última página e ainda restar itens para inserir, adiciona mais uma página
704
            if ($n == $totPag && $this->qtdeItensProc < $qtdeItens) {
705
                $totPag ++;
706
            }
707
        }
708
    }
709
710
    /**
711
     * anfavea
712
     * Função para transformar o campo cdata do padrão ANFAVEA para
713
     * texto imprimível
714
     *
715
     * @param string $cdata campo CDATA
716
     *
717
     * @return string conteúdo do campo CDATA como string
718
     */
719
    protected function anfaveaDANFE($cdata = '')
720
    {
721
        if ($cdata == '') {
722
            return '';
723
        }
724
        //remove qualquer texto antes ou depois da tag CDATA
725
        $cdata    = str_replace('<![CDATA[', '<CDATA>', $cdata);
726
        $cdata    = str_replace(']]>', '</CDATA>', $cdata);
727
        $cdata    = preg_replace('/\s\s+/', ' ', $cdata);
728
        $cdata    = str_replace("> <", "><", $cdata);
729
        $len      = strlen($cdata);
730
        $startPos = strpos($cdata, '<');
731
        if ($startPos === false) {
732
            return $cdata;
733
        }
734
        for ($x = $len; $x > 0; $x --) {
735
            if (substr($cdata, $x, 1) == '>') {
736
                $endPos = $x;
737
                break;
738
            }
739
        }
740
        if ($x === 0) {
741
            return $cdata;
742
        }
743
        if ($startPos > 0) {
744
            $parte1 = substr($cdata, 0, $startPos);
745
        } else {
746
            $parte1 = '';
747
        }
748
        $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...
749
        if ($endPos < $len) {
750
            $parte3 = substr($cdata, $endPos + 1, $len - $endPos - 1);
751
        } else {
752
            $parte3 = '';
753
        }
754
        $texto = trim($parte1) . ' ' . trim($parte3);
755
        if (strpos($parte2, '<CDATA>') === false) {
756
            $cdata = '<CDATA>' . $parte2 . '</CDATA>';
757
        } else {
758
            $cdata = $parte2;
759
        }
760
        //Retira a tag <FONTE IBPT> (caso existir) pois não é uma estrutura válida XML
761
        $cdata = str_replace('<FONTE IBPT>', '', $cdata);
762
        //carrega o xml CDATA em um objeto DOM
763
        $dom = new Dom();
764
        $dom->loadXML($cdata, LIBXML_NOBLANKS | LIBXML_NOEMPTYTAG);
765
        //$xml = $dom->saveXML();
766
        //grupo CDATA infADprod
767
        $id   = $dom->getElementsByTagName('id')->item(0);
768
        $div  = $dom->getElementsByTagName('div')->item(0);
769
        $entg = $dom->getElementsByTagName('entg')->item(0);
770
        $dest = $dom->getElementsByTagName('dest')->item(0);
771
        $ctl  = $dom->getElementsByTagName('ctl')->item(0);
772
        $ref  = $dom->getElementsByTagName('ref')->item(0);
773
        if (isset($id)) {
774
            if ($id->hasAttributes()) {
775
                foreach ($id->attributes as $attr) {
776
                    $name  = $attr->nodeName;
777
                    $value = $attr->nodeValue;
778
                    $texto .= " $name : $value";
779
                }
780
            }
781
        }
782
        if (isset($div)) {
783
            if ($div->hasAttributes()) {
784
                foreach ($div->attributes as $attr) {
785
                    $name  = $attr->nodeName;
786
                    $value = $attr->nodeValue;
787
                    $texto .= " $name : $value";
788
                }
789
            }
790
        }
791
        if (isset($entg)) {
792
            if ($entg->hasAttributes()) {
793
                foreach ($entg->attributes as $attr) {
794
                    $name  = $attr->nodeName;
795
                    $value = $attr->nodeValue;
796
                    $texto .= " $name : $value";
797
                }
798
            }
799
        }
800
        if (isset($dest)) {
801
            if ($dest->hasAttributes()) {
802
                foreach ($dest->attributes as $attr) {
803
                    $name  = $attr->nodeName;
804
                    $value = $attr->nodeValue;
805
                    $texto .= " $name : $value";
806
                }
807
            }
808
        }
809
        if (isset($ctl)) {
810
            if ($ctl->hasAttributes()) {
811
                foreach ($ctl->attributes as $attr) {
812
                    $name  = $attr->nodeName;
813
                    $value = $attr->nodeValue;
814
                    $texto .= " $name : $value";
815
                }
816
            }
817
        }
818
        if (isset($ref)) {
819
            if ($ref->hasAttributes()) {
820
                foreach ($ref->attributes as $attr) {
821
                    $name  = $attr->nodeName;
822
                    $value = $attr->nodeValue;
823
                    $texto .= " $name : $value";
824
                }
825
            }
826
        }
827
        //grupo CADATA infCpl
828
        $t          = $dom->getElementsByTagName('transmissor')->item(0);
829
        $r          = $dom->getElementsByTagName('receptor')->item(0);
830
        $versao     = ! empty($dom->getElementsByTagName('versao')->item(0)->nodeValue) ?
831
            'Versao:' . $dom->getElementsByTagName('versao')->item(0)->nodeValue . ' ' : '';
832
        $especieNF  = ! empty($dom->getElementsByTagName('especieNF')->item(0)->nodeValue) ?
833
            'Especie:' . $dom->getElementsByTagName('especieNF')->item(0)->nodeValue . ' ' : '';
834
        $fabEntrega = ! empty($dom->getElementsByTagName('fabEntrega')->item(0)->nodeValue) ?
835
            'Entrega:' . $dom->getElementsByTagName('fabEntrega')->item(0)->nodeValue . ' ' : '';
836
        $dca        = ! empty($dom->getElementsByTagName('dca')->item(0)->nodeValue) ?
837
            'dca:' . $dom->getElementsByTagName('dca')->item(0)->nodeValue . ' ' : '';
838
        $texto      .= "" . $versao . $especieNF . $fabEntrega . $dca;
839
        if (isset($t)) {
840
            if ($t->hasAttributes()) {
841
                $texto .= " Transmissor ";
842
                foreach ($t->attributes as $attr) {
843
                    $name  = $attr->nodeName;
844
                    $value = $attr->nodeValue;
845
                    $texto .= " $name : $value";
846
                }
847
            }
848
        }
849
        if (isset($r)) {
850
            if ($r->hasAttributes()) {
851
                $texto .= " Receptor ";
852
                foreach ($r->attributes as $attr) {
853
                    $name  = $attr->nodeName;
854
                    $value = $attr->nodeValue;
855
                    $texto .= " $name : $value";
856
                }
857
            }
858
        }
859
860
        return $texto;
861
    }
862
863
    /**
864
     * Verifica o status da NFe
865
     *
866
     * @return array
867
     */
868
    protected function statusNFe()
869
    {
870
        $resp = [
871
            'status' => true,
872
            'message' => [],
873
            'submessage' => ''
874
        ];
875
        if (!empty($this->epec)) {
876
            return $resp;
877
        }
878
        if (!isset($this->nfeProc)) {
879
            $resp['status'] = false;
880
            $resp['message'][] = 'NFe NÃO PROTOCOLADA';
881
        } else {
882
            if ($this->getTagValue($this->ide, "tpAmb") == '2') {
883
                $resp['status'] = false;
884
                $resp['message'][] =  "NFe EMITIDA EM HOMOLOGAÇÃO";
885
            }
886
            $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...
887
            $cStat = $this->getTagValue($this->nfeProc, "cStat");
888
            if ($cStat == '110' ||
889
                $cStat == '301' ||
890
                $cStat == '302'
891
            ) {
892
                $resp['status'] = false;
893
                $resp['message'][] = "NFe DENEGADA";
894
            } elseif ($cStat == '101'
895
                || $cStat == '151'
896
                || $cStat == '135'
897
                || $cStat == '155'
898
                || $this->cancelFlag === true
899
            ) {
900
                $resp['status'] = false;
901
                $resp['message'][] = "NFe CANCELADA";
902
            } elseif (!empty($retEvento)) {
903
                $infEvento = $retEvento->getElementsByTagName('infEvento')->item(0);
904
                $cStat = $this->getTagValue($infEvento, "cStat");
905
                $tpEvento= $this->getTagValue($infEvento, "tpEvento");
906
                $dhEvento = date("d/m/Y H:i:s", $this->toTimestamp($this->getTagValue($infEvento, "dhRegEvento")));
907
                $nProt = $this->getTagValue($infEvento, "nProt");
908
                if ($tpEvento == '110111' &&
909
                    ($cStat == '101' ||
910
                     $cStat == '151' ||
911
                     $cStat == '135' ||
912
                     $cStat == '155')
913
                ) {
914
                    $resp['status'] = false;
915
                    $resp['message'][] = "NFe CANCELADA";
916
                    $resp['submessage'] = "{$dhEvento} - {$nProt}";
917
                }
918
            }
919
        }
920
        return $resp;
921
    }
922
923
    /**
924
     *header
925
     * Monta o cabelhalho da DANFE (retrato e paisagem)
926
     *
927
     * @param number $x      Posição horizontal inicial, canto esquerdo
928
     * @param number $y      Posição vertical inicial, canto superior
929
     * @param number $pag    Número da Página
930
     * @param number $totPag Total de páginas
931
     *
932
     * @return number Posição vertical final
933
     */
934
    protected function header($x = 0, $y = 0, $pag = '1', $totPag = '1')
935
    {
936
        $oldX = $x;
937
        $oldY = $y;
938
        if ($this->orientacao == 'P') {
939
            $maxW = $this->wPrint;
940
        } else {
941
            if ($pag == 1) { // primeira página
942
                $maxW = $this->wPrint - $this->wCanhoto;
943
            } else { // páginas seguintes
944
                $maxW = $this->wPrint;
945
            }
946
        }
947
        //####################################################################################
948
        //coluna esquerda identificação do emitente
949
        $w = round($maxW * 0.41, 0);
950
        if ($this->orientacao == 'P') {
951
            $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => 'I'];
952
        } else {
953
            $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'];
954
        }
955
        $w1   = $w;
956
        $h    = 32;
957
        $oldY += $h;
958
        $this->pdf->textBox($x, $y, $w, $h);
959
        $texto = 'IDENTIFICAÇÃO DO EMITENTE';
960
        $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...
961
        //estabelecer o alinhamento
962
        //pode ser left L, center C, right R, full logo L
963
        //se for left separar 1/3 da largura para o tamanho da imagem
964
        //os outros 2/3 serão usados para os dados do emitente
965
        //se for center separar 1/2 da altura para o logo e 1/2 para os dados
966
        //se for right separa 2/3 para os dados e o terço seguinte para o logo
967
        //se não houver logo centraliza dos dados do emitente
968
        // coloca o logo
969
        if (! empty($this->logomarca)) {
970
            $logoInfo = getimagesize($this->logomarca);
971
            //largura da imagem em mm
972
            $logoWmm = ($logoInfo[0] / 72) * 25.4;
973
            //altura da imagem em mm
974
            $logoHmm = ($logoInfo[1] / 72) * 25.4;
975
            if ($this->logoAlign == 'L') {
976
                $nImgW = round($w / 3, 0);
977
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
978
                $xImg  = $x + 1;
979
                $yImg  = round(($h - $nImgH) / 2, 0) + $y;
980
                //estabelecer posições do texto
981
                $x1 = round($xImg + $nImgW + 1, 0);
982
                $y1 = round($h / 3 + $y, 0);
983
                $tw = round(2 * $w / 3, 0);
984
            } elseif ($this->logoAlign == 'C') {
985
                $nImgH = round($h / 3, 0);
986
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
987
                $xImg  = round(($w - $nImgW) / 2 + $x, 0);
988
                $yImg  = $y + 3;
989
                $x1    = $x;
990
                $y1    = round($yImg + $nImgH + 1, 0);
991
                $tw    = $w;
992
            } elseif ($this->logoAlign == 'R') {
993
                $nImgW = round($w / 3, 0);
994
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
995
                $xImg  = round($x + ($w - (1 + $nImgW)), 0);
996
                $yImg  = round(($h - $nImgH) / 2, 0) + $y;
997
                $x1    = $x;
998
                $y1    = round($h / 3 + $y, 0);
999
                $tw    = round(2 * $w / 3, 0);
1000
            } elseif ($this->logoAlign == 'F') {
1001
                $nImgH = round($h - 5, 0);
1002
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
1003
                $xImg  = round(($w - $nImgW) / 2 + $x, 0);
1004
                $yImg  = $y + 3;
1005
                $x1    = $x;
1006
                $y1    = round($yImg + $nImgH + 1, 0);
1007
                $tw    = $w;
1008
            }
1009
            $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...
1010
            $this->pdf->Image($this->logomarca, $xImg, $yImg, $nImgW, $nImgH, 'jpeg');
0 ignored issues
show
Bug introduced by
The variable $nImgH does not seem to be defined for all execution paths leading up to this point.

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
Bug introduced by
The variable $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...
1011
        } else {
1012
            $x1 = $x;
1013
            $y1 = round($h / 3 + $y, 0);
1014
            $tw = $w;
1015
        }
1016
        // monta as informações apenas se diferente de full logo
1017
        if ($this->logoAlign !== 'F') {
1018
            //Nome emitente
1019
            $aFont = ['font' => $this->fontePadrao, 'size' => 12, 'style' => 'B'];
1020
            $texto = $this->emit->getElementsByTagName("xNome")->item(0)->nodeValue;
1021
            $this->pdf->textBox($x1, $y1, $tw, 8, $texto, $aFont, 'T', 'C', 0, '');
0 ignored issues
show
Bug introduced by
The variable $tw does not seem to be defined for all execution paths leading up to this point.

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

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

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

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

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

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

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1022
            //endereço
1023
            $y1     = $y1 + 5;
1024
            $aFont  = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
1025
            $fone   = ! empty($this->enderEmit->getElementsByTagName("fone")->item(0)->nodeValue)
1026
                ? $this->enderEmit->getElementsByTagName("fone")->item(0)->nodeValue
1027
                : '';
1028
            $lgr    = $this->getTagValue($this->enderEmit, "xLgr");
1029
            $nro    = $this->getTagValue($this->enderEmit, "nro");
1030
            $cpl    = $this->getTagValue($this->enderEmit, "xCpl", " - ");
1031
            $bairro = $this->getTagValue($this->enderEmit, "xBairro");
1032
            $CEP    = $this->getTagValue($this->enderEmit, "CEP");
1033
            $CEP    = $this->formatField($CEP, "#####-###");
1034
            $mun    = $this->getTagValue($this->enderEmit, "xMun");
1035
            $UF     = $this->getTagValue($this->enderEmit, "UF");
1036
            $texto  = $lgr . ", " . $nro . $cpl . "\n" . $bairro . " - "
1037
                . $CEP . "\n" . $mun . " - " . $UF . " "
1038
                . "Fone/Fax: " . $fone;
1039
            $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...
1040
        }
1041
1042
        //####################################################################################
1043
        //coluna central Danfe
1044
        $x  += $w;
1045
        $w  = round($maxW * 0.17, 0);//35;
1046
        $w2 = $w;
1047
        $h  = 32;
1048
        $this->pdf->textBox($x, $y, $w, $h);
1049
1050
        $texto = "DANFE";
1051
        $aFont = ['font' => $this->fontePadrao, 'size' => 14, 'style' => 'B'];
1052
        $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...
1053
        $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
1054
        $texto = 'Documento Auxiliar da Nota Fiscal Eletrônica';
1055
        $h     = 20;
1056
        $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...
1057
1058
        $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
1059
        $texto = '0 - ENTRADA';
1060
        $y1    = $y + 14;
1061
        $h     = 8;
1062
        $this->pdf->textBox($x + 2, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1063
        $texto = '1 - SAÍDA';
1064
        $y1    = $y + 17;
1065
        $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...
1066
        //tipo de nF
1067
        $aFont = ['font' => $this->fontePadrao, 'size' => 12, 'style' => 'B'];
1068
        $y1    = $y + 13;
1069
        $h     = 7;
1070
        $texto = $this->ide->getElementsByTagName('tpNF')->item(0)->nodeValue;
1071
        $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...
1072
        //numero da NF
1073
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1074
        $y1    = $y + 20;
1075
        $numNF = str_pad(
1076
            $this->ide->getElementsByTagName('nNF')->item(0)->nodeValue,
1077
            9,
1078
            "0",
1079
            STR_PAD_LEFT
1080
        );
1081
        $numNF = $this->formatField($numNF, "###.###.###");
1082
        $texto = "Nº. " . $numNF;
1083
        $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...
1084
        //Série
1085
        $y1    = $y + 23;
1086
        $serie = str_pad(
1087
            $this->ide->getElementsByTagName('serie')->item(0)->nodeValue,
1088
            3,
1089
            "0",
1090
            STR_PAD_LEFT
1091
        );
1092
        $texto = "Série " . $serie;
1093
        $this->pdf->textBox($x, $y1, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1094
        //numero paginas
1095
        $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'I'];
1096
        $y1    = $y + 26;
1097
        $texto = "Folha " . $pag . "/" . $totPag;
1098
        $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...
1099
1100
        //####################################################################################
1101
        //coluna codigo de barras
1102
        $x  += $w;
1103
        $w  = ($maxW - $w1 - $w2);//85;
1104
        $w3 = $w;
1105
        $h  = 32;
1106
        $this->pdf->textBox($x, $y, $w, $h);
1107
        $this->pdf->setFillColor(0, 0, 0);
1108
        $chave_acesso = str_replace('NFe', '', $this->infNFe->getAttribute("Id"));
1109
        $bW           = 75;
1110
        $bH           = 12;
1111
        //codigo de barras
1112
        $this->pdf->code128($x + (($w - $bW) / 2), $y + 2, $chave_acesso, $bW, $bH);
1113
        //linhas divisorias
1114
        $this->pdf->line($x, $y + 4 + $bH, $x + $w, $y + 4 + $bH);
1115
        $this->pdf->line($x, $y + 12 + $bH, $x + $w, $y + 12 + $bH);
1116
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1117
        $y1    = $y + 4 + $bH;
1118
        $h     = 7;
1119
        $texto = 'CHAVE DE ACESSO';
1120
        $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...
1121
        $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'];
1122
        $y1    = $y + 8 + $bH;
1123
        $texto = $this->formatField($chave_acesso, $this->formatoChave);
1124
        $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...
1125
        $y1                = $y + 12 + $bH;
1126
        $aFont             = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
1127
        $chaveContingencia = "";
1128
        if (!empty($this->epec)) {
1129
            $cabecalhoProtoAutorizacao = 'NÚMERO DE REGISTRO EPEC';
1130
        } else {
1131
            $cabecalhoProtoAutorizacao = 'PROTOCOLO DE AUTORIZAÇÃO DE USO';
1132
        }
1133
        if (($this->tpEmis == 2 || $this->tpEmis == 5) && empty($this->epec)) {
1134
            $cabecalhoProtoAutorizacao = "DADOS DA NF-E";
1135
            $chaveContingencia         = $this->geraChaveAdicionalDeContingencia();
1136
            $this->pdf->setFillColor(0, 0, 0);
1137
            //codigo de barras
1138
            $this->pdf->code128($x + 11, $y1 + 1, $chaveContingencia, $bW * .9, $bH / 2);
1139
        } else {
1140
            $texto = 'Consulta de autenticidade no portal nacional da NF-e';
1141
            $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...
1142
            $y1    = $y + 16 + $bH;
1143
            $texto = 'www.nfe.fazenda.gov.br/portal ou no site da Sefaz Autorizadora';
1144
            $this->pdf->textBox(
1145
                $x + 2,
1146
                $y1,
1147
                $w - 2,
1148
                $h,
1149
                $texto,
1150
                $aFont,
1151
                'T',
1152
                'C',
1153
                0,
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1154
                'http://www.nfe.fazenda.gov.br/portal ou no site da Sefaz Autorizadora'
1155
            );
1156
        }
1157
1158
        //####################################################################################
1159
        //Dados da NF do cabeçalho
1160
        //natureza da operação
1161
        $texto = 'NATUREZA DA OPERAÇÃO';
1162
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1163
        $w     = $w1 + $w2;
1164
        $y     = $oldY;
1165
        $oldY  += $h;
1166
        $x     = $oldX;
1167
        $h     = 7;
1168
        $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...
1169
        $texto = $this->ide->getElementsByTagName("natOp")->item(0)->nodeValue;
1170
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1171
        $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...
1172
        $x += $w;
1173
        $w = $w3;
1174
        //PROTOCOLO DE AUTORIZAÇÃO DE USO ou DADOS da NF-E
1175
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1176
        $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...
1177
        // algumas NFe podem estar sem o protocolo de uso portanto sua existencia deve ser
1178
        // testada antes de tentar obter a informação.
1179
        // NOTA : DANFE sem protocolo deve existir somente no caso de contingência !!!
1180
        // Além disso, existem várias NFes em contingência que eu recebo com protocolo de autorização.
1181
        // Na minha opinião, deveríamos mostra-lo, mas o  manual  da NFe v4.01 diz outra coisa...
1182
        if (($this->tpEmis == 2 || $this->tpEmis == 5) && empty($this->epec)) {
1183
            $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'];
1184
            $texto = $this->formatField(
1185
                $chaveContingencia,
1186
                "#### #### #### #### #### #### #### #### ####"
1187
            );
1188
            $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...
1189
        } else {
1190
            $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1191
            if (!empty($this->epec)) {
1192
                $texto = $this->epec['protocolo'] . ' - ' . $this->epec['data'];
1193
                $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...
1194
            } else {
1195
                if (isset($this->nfeProc)) {
1196
                    $texto  = ! empty($this->nfeProc->getElementsByTagName("nProt")->item(0)->nodeValue)
1197
                        ? $this->nfeProc->getElementsByTagName("nProt")->item(0)->nodeValue
1198
                        : '';
1199
                    $tsHora = $this->toTimestamp(
1200
                        $this->nfeProc->getElementsByTagName("dhRecbto")->item(0)->nodeValue
1201
                    );
1202
                    if ($texto != '') {
1203
                        $texto .= "  -  " . date('d/m/Y H:i:s', $tsHora);
1204
                    }
1205
                    $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...
1206
                } else {
1207
                    $texto = '';
1208
                    $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...
1209
                }
1210
            }
1211
        }
1212
        $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...
1213
        //####################################################################################
1214
        //INSCRIÇÃO ESTADUAL
1215
        $w     = round($maxW * 0.250, 0);
1216
        $y     += $h;
1217
        $oldY  += $h;
1218
        $x     = $oldX;
1219
        $texto = 'INSCRIÇÃO ESTADUAL';
1220
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1221
        $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...
1222
        $texto = $this->getTagValue($this->emit, "IE");
1223
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1224
        $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...
1225
        //INSCRIÇÃO MUNICIPAL
1226
        $x     += $w;
1227
        $texto = 'INSCRIÇÃO MUNICIPAL';
1228
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1229
        $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...
1230
        $texto = $this->getTagValue($this->emit, "IM");
1231
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1232
        $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...
1233
        //INSCRIÇÃO ESTADUAL DO SUBST. TRIBUT.
1234
        $x     += $w;
1235
        $texto = 'INSCRIÇÃO ESTADUAL DO SUBST. TRIBUT.';
1236
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1237
        $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...
1238
        $texto = ! empty($this->emit->getElementsByTagName("IEST")->item(0)->nodeValue)
1239
            ? $this->emit->getElementsByTagName("IEST")->item(0)->nodeValue
1240
            : '';
1241
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1242
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1243
        //CNPJ
1244
        $x     += $w;
1245
        $w     = ($maxW - (3 * $w));
1246
        $texto = 'CNPJ / CPF';
1247
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1248
        $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...
1249
        //Pegando valor do CPF/CNPJ
1250
        if (! empty($this->emit->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1251
            $texto = $this->formatField(
1252
                $this->emit->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1253
                "###.###.###/####-##"
1254
            );
1255
        } else {
1256
            $texto = ! empty($this->emit->getElementsByTagName("CPF")->item(0)->nodeValue)
1257
                ? $this->formatField(
1258
                    $this->emit->getElementsByTagName("CPF")->item(0)->nodeValue,
1259
                    "###.###.###-##"
1260
                )
1261
                : '';
1262
        }
1263
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1264
        $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...
1265
1266
        //####################################################################################
1267
        //Indicação de NF Homologação, cancelamento e falta de protocolo
1268
        $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...
1269
        //indicar cancelamento
1270
        $resp = $this->statusNFe();
1271
        if (!$resp['status']) {
1272
            $n = count($resp['message']);
1273
            $alttot = $n * 15;
1274
            $x = 10;
1275
            $y = $this->hPrint/2 - $alttot/2;
1276
            $h = 15;
1277
            $w = $maxW - (2 * $x);
1278
            $this->pdf->settextcolor(90, 90, 90);
1279
            
1280
            foreach ($resp['message'] as $msg) {
1281
                $aFont = ['font' => $this->fontePadrao, 'size' => 48, 'style' => 'B'];
1282
                $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...
1283
                $y += $h;
1284
            }
1285
            $texto = $resp['submessage'];
1286
            if (!empty($texto)) {
1287
                $y += 3;
1288
                $h = 5;
1289
                $aFont = ['font' => $this->fontePadrao, 'size' => 20, 'style' => 'B'];
1290
                $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...
1291
                $y += $h;
1292
            }
1293
            $y += 5;
1294
            $w = $maxW - (2 * $x);
1295
            $texto = "SEM VALOR FISCAL";
1296
            $aFont = ['font' => $this->fontePadrao, 'size' => 48, 'style' => 'B'];
1297
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1298
            $this->pdf->settextcolor(0, 0, 0);
1299
        }
1300
        if (!empty($this->epec) || $this->tpEmis == 4) {
1301
            //EPEC
1302
            $x = 10;
1303
            $y = $this->hPrint - 130;
1304
            $h = 25;
1305
            $w = $maxW - (2 * $x);
1306
            $this->pdf->SetTextColor(200, 200, 200);
1307
            $texto = "DANFE impresso em contingência -\n" .
1308
                "EPEC regularmente recebido pela Receita\n" .
1309
                "Federal do Brasil";
1310
            $aFont = ['font' => $this->fontePadrao, 'size' => 48, 'style' => 'B'];
1311
            $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...
1312
            $this->pdf->SetTextColor(0, 0, 0);
1313
        }
1314
1315
        return $oldY;
1316
    } //fim header
1317
1318
    /**
1319
     * destinatarioDANFE
1320
     * Monta o campo com os dados do destinatário na DANFE. (retrato e paisagem)
1321
     *
1322
     * @name   destinatarioDANFE
1323
     *
1324
     * @param number $x Posição horizontal canto esquerdo
1325
     * @param number $y Posição vertical canto superior
1326
     *
1327
     * @return number Posição vertical final
1328
     */
1329
    protected function destinatarioDANFE($x = 0, $y = 0)
1330
    {
1331
        //####################################################################################
1332
        //DESTINATÁRIO / REMETENTE
1333
        $oldX = $x;
1334
        $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...
1335
        if ($this->orientacao == 'P') {
1336
            $maxW = $this->wPrint;
1337
        } else {
1338
            $maxW = $this->wPrint - $this->wCanhoto;
1339
        }
1340
        $w     = $maxW;
1341
        $h     = 7;
1342
        $texto = 'DESTINATÁRIO / REMETENTE';
1343
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1344
        $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...
1345
        //NOME / RAZÃO SOCIAL
1346
        $w     = round($maxW * 0.61, 0);
1347
        $w1    = $w;
1348
        $y     += 3;
1349
        $texto = 'NOME / RAZÃO SOCIAL';
1350
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1351
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1352
        $texto = $this->dest->getElementsByTagName("xNome")->item(0)->nodeValue;
1353
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1354
        if ($this->orientacao == 'P') {
1355
            $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...
1356
        } else {
1357
            $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...
1358
        }
1359
        //CNPJ / CPF
1360
        $x     += $w;
1361
        $w     = round($maxW * 0.23, 0);
1362
        $w2    = $w;
1363
        $texto = 'CNPJ / CPF';
1364
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1365
        $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...
1366
        //Pegando valor do CPF/CNPJ
1367
        if (! empty($this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1368
            $texto = $this->formatField(
1369
                $this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1370
                "###.###.###/####-##"
1371
            );
1372
        } else {
1373
            $texto = ! empty($this->dest->getElementsByTagName("CPF")->item(0)->nodeValue)
1374
                ? $this->formatField(
1375
                    $this->dest->getElementsByTagName("CPF")->item(0)->nodeValue,
1376
                    "###.###.###-##"
1377
                )
1378
                : '';
1379
        }
1380
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1381
        $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...
1382
        //DATA DA EMISSÃO
1383
        $x     += $w;
1384
        $w     = $maxW - ($w1 + $w2);
1385
        $wx    = $w;
1386
        $texto = 'DATA DA EMISSÃO';
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
        $dEmi = ! empty($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue)
1390
            ? $this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue
1391
            : '';
1392
        if ($dEmi == '') {
1393
            $dEmi  = ! empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue)
1394
                ? $this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue
1395
                : '';
1396
            $aDemi = explode('T', $dEmi);
1397
            $dEmi  = $aDemi[0];
1398
        }
1399
        $texto = $this->ymdTodmy($dEmi);
1400
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1401
        if ($this->orientacao == 'P') {
1402
            $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...
1403
        } else {
1404
            $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...
1405
        }
1406
        //ENDEREÇO
1407
        $w     = round($maxW * 0.47, 0);
1408
        $w1    = $w;
1409
        $y     += $h;
1410
        $x     = $oldX;
1411
        $texto = 'ENDEREÇO';
1412
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1413
        $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...
1414
        $texto = $this->dest->getElementsByTagName("xLgr")->item(0)->nodeValue;
1415
        $texto .= ', ' . $this->dest->getElementsByTagName("nro")->item(0)->nodeValue;
1416
        $texto .= $this->getTagValue($this->dest, "xCpl", " - ");
1417
1418
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1419
        $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...
1420
        //BAIRRO / DISTRITO
1421
        $x     += $w;
1422
        $w     = round($maxW * 0.21, 0);
1423
        $w2    = $w;
1424
        $texto = 'BAIRRO / DISTRITO';
1425
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1426
        $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...
1427
        $texto = $this->dest->getElementsByTagName("xBairro")->item(0)->nodeValue;
1428
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1429
        $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...
1430
        //CEP
1431
        $x     += $w;
1432
        $w     = $maxW - $w1 - $w2 - $wx;
1433
        $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...
1434
        $texto = 'CEP';
1435
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1436
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1437
        $texto = ! empty($this->dest->getElementsByTagName("CEP")->item(0)->nodeValue)
1438
            ? $this->dest->getElementsByTagName("CEP")->item(0)->nodeValue
1439
            : '';
1440
        $texto = $this->formatField($texto, "#####-###");
1441
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1442
        $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...
1443
        //DATA DA SAÍDA
1444
        $x     += $w;
1445
        $w     = $wx;
1446
        $texto = 'DATA DA SAÍDA/ENTRADA';
1447
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1448
        $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...
1449
        $dSaiEnt = ! empty($this->ide->getElementsByTagName("dSaiEnt")->item(0)->nodeValue)
1450
            ? $this->ide->getElementsByTagName("dSaiEnt")->item(0)->nodeValue
1451
            : '';
1452
        if ($dSaiEnt == '') {
1453
            $dSaiEnt  = ! empty($this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue)
1454
                ? $this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue
1455
                : '';
1456
            $aDsaient = explode('T', $dSaiEnt);
1457
            $dSaiEnt  = $aDsaient[0];
1458
        }
1459
        $texto = $this->ymdTodmy($dSaiEnt);
1460
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1461
        $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...
1462
        //MUNICÍPIO
1463
        $w     = $w1;
1464
        $y     += $h;
1465
        $x     = $oldX;
1466
        $texto = 'MUNICÍPIO';
1467
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1468
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1469
        $texto = $this->dest->getElementsByTagName("xMun")->item(0)->nodeValue;
1470
        if (strtoupper(trim($texto)) == "EXTERIOR"
1471
            && $this->dest->getElementsByTagName("xPais")->length > 0
1472
        ) {
1473
            $texto .= " - " . $this->dest->getElementsByTagName("xPais")->item(0)->nodeValue;
1474
        }
1475
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1476
        $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...
1477
        //UF
1478
        $x     += $w;
1479
        $w     = 8;
1480
        $texto = 'UF';
1481
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1482
        $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...
1483
        $texto = $this->dest->getElementsByTagName("UF")->item(0)->nodeValue;
1484
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1485
        $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...
1486
        //FONE / FAX
1487
        $x     += $w;
1488
        $w     = round(($maxW - $w1 - $wx - 8) / 2, 0);
1489
        $w3    = $w;
1490
        $texto = 'FONE / FAX';
1491
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1492
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1493
        $texto = ! empty($this->dest->getElementsByTagName("fone")->item(0)->nodeValue)
1494
            ? $this->dest->getElementsByTagName("fone")->item(0)->nodeValue
1495
            : '';
1496
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1497
        $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...
1498
        //INSCRIÇÃO ESTADUAL
1499
        $x     += $w;
1500
        $w     = $maxW - $w1 - $wx - 8 - $w3;
1501
        $texto = 'INSCRIÇÃO ESTADUAL';
1502
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1503
        $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...
1504
        $IE    = $this->dest->getElementsByTagName("IE");
1505
        $texto = ($IE && $IE->length > 0) ? $IE->item(0)->nodeValue : '';
1506
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1507
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1508
        //HORA DA SAÍDA
1509
        $x     += $w;
1510
        $w     = $wx;
1511
        $texto = 'HORA DA SAÍDA/ENTRADA';
1512
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1513
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1514
        $hSaiEnt = ! empty($this->ide->getElementsByTagName("hSaiEnt")->item(0)->nodeValue)
1515
            ? $this->ide->getElementsByTagName("hSaiEnt")->item(0)->nodeValue
1516
            : '';
1517
        if ($hSaiEnt == '') {
1518
            $dhSaiEnt   = ! empty($this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue)
1519
                ? $this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue
1520
                : '';
1521
            $tsDhSaiEnt = $this->toTimestamp($dhSaiEnt);
1522
            if ($tsDhSaiEnt != '') {
1523
                $hSaiEnt = date('H:i:s', $tsDhSaiEnt);
1524
            }
1525
        }
1526
        $texto = $hSaiEnt;
1527
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1528
        $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...
1529
1530
        return ($y + $h);
1531
    } //fim da função destinatarioDANFE
1532
1533
    /**
1534
     * localEntregaDANFE
1535
     * Monta o campo com os dados do local de entrega na DANFE. (retrato e paisagem)
1536
     *
1537
     * @name   localEntregaDANFE
1538
     *
1539
     * @param number $x Posição horizontal canto esquerdo
1540
     * @param number $y Posição vertical canto superior
1541
     *
1542
     * @return number Posição vertical final
1543
     */
1544
    protected function localEntregaDANFE($x = 0, $y = 0)
1545
    {
1546
        //####################################################################################
1547
        //LOCAL DE ENTREGA
1548
        $oldX = $x;
1549
        if ($this->orientacao == 'P') {
1550
            $maxW = $this->wPrint;
1551
        } else {
1552
            $maxW = $this->wPrint - $this->wCanhoto;
1553
        }
1554
        $w     = $maxW;
1555
        $h     = 7;
1556
        $texto = 'INFORMAÇÕES DO LOCAL DE ENTREGA';
1557
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1558
        $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...
1559
        //NOME / RAZÃO SOCIAL
1560
        $w     = round($maxW * 0.61, 0);
1561
        $w1    = $w;
1562
        $y     += 3;
1563
        $texto = 'NOME / RAZÃO SOCIAL';
1564
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1565
        $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...
1566
        $texto = '';
1567
        if ($this->entrega->getElementsByTagName("xNome")->item(0)) {
1568
            $texto = $this->entrega->getElementsByTagName("xNome")->item(0)->nodeValue;
1569
        }
1570
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1571
        if ($this->orientacao == 'P') {
1572
            $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...
1573
        } else {
1574
            $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...
1575
        }
1576
        //CNPJ / CPF
1577
        $x     += $w;
1578
        $w     = round($maxW * 0.23, 0);
1579
        $w2    = $w;
1580
        $texto = 'CNPJ / CPF';
1581
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1582
        $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...
1583
        //Pegando valor do CPF/CNPJ
1584
        if (! empty($this->entrega->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1585
            $texto = $this->formatField(
1586
                $this->entrega->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1587
                "###.###.###/####-##"
1588
            );
1589
        } else {
1590
            $texto = ! empty($this->entrega->getElementsByTagName("CPF")->item(0)->nodeValue) ?
1591
                $this->formatField(
1592
                    $this->entrega->getElementsByTagName("CPF")->item(0)->nodeValue,
1593
                    "###.###.###-##"
1594
                ) : '';
1595
        }
1596
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1597
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1598
        //INSCRIÇÃO ESTADUAL
1599
        $x     += $w;
1600
        $w     = $maxW - ($w1 + $w2);
1601
        $wx    = $w;
1602
        $texto = 'INSCRIÇÃO ESTADUAL';
1603
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1604
        $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...
1605
        $texto = '';
1606
        if ($this->entrega->getElementsByTagName("IE")->item(0)) {
1607
            $texto = $this->entrega->getElementsByTagName("IE")->item(0)->nodeValue;
1608
        }
1609
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1610
        if ($this->orientacao == 'P') {
1611
            $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...
1612
        } else {
1613
            $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...
1614
        }
1615
        //ENDEREÇO
1616
        $w     = round($maxW * 0.355, 0) + $wx;
1617
        $w1    = $w;
1618
        $y     += $h;
1619
        $x     = $oldX;
1620
        $texto = 'ENDEREÇO';
1621
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1622
        $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...
1623
        $texto = $this->entrega->getElementsByTagName("xLgr")->item(0)->nodeValue;
1624
        $texto .= ', ' . $this->entrega->getElementsByTagName("nro")->item(0)->nodeValue;
1625
        $texto .= $this->getTagValue($this->entrega, "xCpl", " - ");
1626
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1627
        $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...
1628
        //BAIRRO / DISTRITO
1629
        $x     += $w;
1630
        $w     = round($maxW * 0.335, 0);
1631
        $w2    = $w;
1632
        $texto = 'BAIRRO / DISTRITO';
1633
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1634
        $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...
1635
        $texto = $this->entrega->getElementsByTagName("xBairro")->item(0)->nodeValue;
1636
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1637
        $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...
1638
        //CEP
1639
        $x     += $w;
1640
        $w     = $maxW - ($w1 + $w2);
1641
        $texto = 'CEP';
1642
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1643
        $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...
1644
        $texto = ! empty($this->entrega->getElementsByTagName("CEP")->item(0)->nodeValue) ?
1645
            $this->entrega->getElementsByTagName("CEP")->item(0)->nodeValue : '';
1646
        $texto = $this->formatField($texto, "#####-###");
1647
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1648
        $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...
1649
        //MUNICÍPIO
1650
        $w     = round($maxW * 0.805, 0);
1651
        $w1    = $w;
1652
        $y     += $h;
1653
        $x     = $oldX;
1654
        $texto = 'MUNICÍPIO';
1655
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1656
        $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...
1657
        $texto = $this->entrega->getElementsByTagName("xMun")->item(0)->nodeValue;
1658
        if (strtoupper(trim($texto)) == "EXTERIOR" && $this->entrega->getElementsByTagName("xPais")->length > 0) {
1659
            $texto .= " - " . $this->entrega->getElementsByTagName("xPais")->item(0)->nodeValue;
1660
        }
1661
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1662
        $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...
1663
        //UF
1664
        $x     += $w;
1665
        $w     = 8;
1666
        $texto = 'UF';
1667
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1668
        $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...
1669
        $texto = $this->entrega->getElementsByTagName("UF")->item(0)->nodeValue;
1670
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1671
        $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...
1672
        //FONE / FAX
1673
        $x     += $w;
1674
        $w     = $maxW - $w - $w1;
1675
        $texto = 'FONE / FAX';
1676
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1677
        $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...
1678
        $texto = ! empty($this->entrega->getElementsByTagName("fone")->item(0)->nodeValue) ?
1679
            $this->entrega->getElementsByTagName("fone")->item(0)->nodeValue : '';
1680
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1681
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1682
1683
        return ($y + $h);
1684
    } //fim da função localEntregaDANFE
1685
1686
    /**
1687
     * localretiradaDANFE
1688
     * Monta o campo com os dados do local de entrega na DANFE. (retrato e paisagem)
1689
     *
1690
     * @name   localretiradaDANFE
1691
     *
1692
     * @param number $x Posição horizontal canto esquerdo
1693
     * @param number $y Posição vertical canto superior
1694
     *
1695
     * @return number Posição vertical final
1696
     */
1697
    protected function localRetiradaDANFE($x = 0, $y = 0)
1698
    {
1699
        //####################################################################################
1700
        //LOCAL DE RETIRADA
1701
        $oldX = $x;
1702
        if ($this->orientacao == 'P') {
1703
            $maxW = $this->wPrint;
1704
        } else {
1705
            $maxW = $this->wPrint - $this->wCanhoto;
1706
        }
1707
        $w     = $maxW;
1708
        $h     = 7;
1709
        $texto = 'INFORMAÇÕES DO LOCAL DE RETIRADA';
1710
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1711
        $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...
1712
        //NOME / RAZÃO SOCIAL
1713
        $w     = round($maxW * 0.61, 0);
1714
        $w1    = $w;
1715
        $y     += 3;
1716
        $texto = 'NOME / RAZÃO SOCIAL';
1717
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1718
        $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...
1719
        $texto = '';
1720
        if ($this->retirada->getElementsByTagName("xNome")->item(0)) {
1721
            $texto = $this->retirada->getElementsByTagName("xNome")->item(0)->nodeValue;
1722
        }
1723
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1724
        if ($this->orientacao == 'P') {
1725
            $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...
1726
        } else {
1727
            $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...
1728
        }
1729
        //CNPJ / CPF
1730
        $x     += $w;
1731
        $w     = round($maxW * 0.23, 0);
1732
        $w2    = $w;
1733
        $texto = 'CNPJ / CPF';
1734
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1735
        $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...
1736
        //Pegando valor do CPF/CNPJ
1737
        if (! empty($this->retirada->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1738
            $texto = $this->formatField(
1739
                $this->retirada->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1740
                "###.###.###/####-##"
1741
            );
1742
        } else {
1743
            $texto = ! empty($this->retirada->getElementsByTagName("CPF")->item(0)->nodeValue) ?
1744
                $this->formatField(
1745
                    $this->retirada->getElementsByTagName("CPF")->item(0)->nodeValue,
1746
                    "###.###.###-##"
1747
                ) : '';
1748
        }
1749
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1750
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1751
        //INSCRIÇÃO ESTADUAL
1752
        $x     += $w;
1753
        $w     = $maxW - ($w1 + $w2);
1754
        $wx    = $w;
1755
        $texto = 'INSCRIÇÃO ESTADUAL';
1756
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1757
        $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...
1758
        $texto = '';
1759
        if ($this->retirada->getElementsByTagName("IE")->item(0)) {
1760
            $texto = $this->retirada->getElementsByTagName("IE")->item(0)->nodeValue;
1761
        }
1762
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1763
        if ($this->orientacao == 'P') {
1764
            $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...
1765
        } else {
1766
            $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...
1767
        }
1768
        //ENDEREÇO
1769
        $w     = round($maxW * 0.355, 0) + $wx;
1770
        $w1    = $w;
1771
        $y     += $h;
1772
        $x     = $oldX;
1773
        $texto = 'ENDEREÇO';
1774
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1775
        $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...
1776
        $texto = $this->retirada->getElementsByTagName("xLgr")->item(0)->nodeValue;
1777
        $texto .= ', ' . $this->retirada->getElementsByTagName("nro")->item(0)->nodeValue;
1778
        $texto .= $this->getTagValue($this->retirada, "xCpl", " - ");
1779
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1780
        $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...
1781
        //BAIRRO / DISTRITO
1782
        $x     += $w;
1783
        $w     = round($maxW * 0.335, 0);
1784
        $w2    = $w;
1785
        $texto = 'BAIRRO / DISTRITO';
1786
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1787
        $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...
1788
        $texto = $this->retirada->getElementsByTagName("xBairro")->item(0)->nodeValue;
1789
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1790
        $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...
1791
        //CEP
1792
        $x     += $w;
1793
        $w     = $maxW - ($w1 + $w2);
1794
        $texto = 'CEP';
1795
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1796
        $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...
1797
        $texto = ! empty($this->retirada->getElementsByTagName("CEP")->item(0)->nodeValue) ?
1798
            $this->retirada->getElementsByTagName("CEP")->item(0)->nodeValue : '';
1799
        $texto = $this->formatField($texto, "#####-###");
1800
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1801
        $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...
1802
        //MUNICÍPIO
1803
        $w     = round($maxW * 0.805, 0);
1804
        $w1    = $w;
1805
        $y     += $h;
1806
        $x     = $oldX;
1807
        $texto = 'MUNICÍPIO';
1808
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1809
        $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...
1810
        $texto = $this->retirada->getElementsByTagName("xMun")->item(0)->nodeValue;
1811
        if (strtoupper(trim($texto)) == "EXTERIOR" && $this->retirada->getElementsByTagName("xPais")->length > 0) {
1812
            $texto .= " - " . $this->retirada->getElementsByTagName("xPais")->item(0)->nodeValue;
1813
        }
1814
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1815
        $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...
1816
        //UF
1817
        $x     += $w;
1818
        $w     = 8;
1819
        $texto = 'UF';
1820
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1821
        $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...
1822
        $texto = $this->retirada->getElementsByTagName("UF")->item(0)->nodeValue;
1823
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1824
        $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...
1825
        //FONE / FAX
1826
        $x     += $w;
1827
        $w     = $maxW - $w - $w1;
1828
        $texto = 'FONE / FAX';
1829
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1830
        $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...
1831
        $texto = ! empty($this->retirada->getElementsByTagName("fone")->item(0)->nodeValue) ?
1832
            $this->retirada->getElementsByTagName("fone")->item(0)->nodeValue : '';
1833
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1834
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1835
1836
        return ($y + $h);
1837
    } //fim da função localRetiradaDANFE
1838
1839
    /**
1840
     * getTextoFatura
1841
     * Gera a String do Texto da Fatura
1842
     *
1843
     * @name   getTextoFatura
1844
     * @return uma String com o texto ou "";
1845
     */
1846
    protected function getTextoFatura()
1847
    {
1848
        if (isset($this->cobr)) {
1849
            $fat = $this->cobr->getElementsByTagName("fat")->item(0);
1850
            if (isset($fat)) {
1851
                if (! empty($this->getTagValue($this->ide, "indPag"))) {
1852
                    $textoIndPag = "";
1853
                    $indPag      = $this->getTagValue($this->ide, "indPag");
1854
                    if ($indPag === "0") {
1855
                        $textoIndPag = "Pagamento à Vista - ";
1856
                    } elseif ($indPag === "1") {
1857
                        $textoIndPag = "Pagamento à Prazo - ";
1858
                    }
1859
                    $nFat  = $this->getTagValue($fat, "nFat", "Fatura: ");
1860
                    $vOrig = $this->getTagValue($fat, "vOrig", " Valor Original: ");
1861
                    $vDesc = $this->getTagValue($fat, "vDesc", " Desconto: ");
1862
                    $vLiq  = $this->getTagValue($fat, "vLiq", " Valor Líquido: ");
1863
                    $texto = $textoIndPag . $nFat . $vOrig . $vDesc . $vLiq;
1864
1865
                    return $texto;
1866
                } else {
1867
                    $pag = $this->dom->getElementsByTagName("pag");
1868
                    if ($tPag = $this->getTagValue($pag->item(0), "tPag")) {
1869
                        return $this->tipoPag($tPag);
1870
                    }
1871
                }
1872
            }
1873
        }
1874
        return "";
1875
    }
1876
1877
    /**
1878
     * sizeExtraTextoFatura
1879
     * Calcula o espaço ocupado pelo texto da fatura. Este espaço só é utilizado quando não houver duplicata.
1880
     *
1881
     * @name   sizeExtraTextoFatura
1882
     * @return integer
1883
     */
1884
    protected function sizeExtraTextoFatura()
1885
    {
1886
        $textoFatura = $this->getTextoFatura();
1887
        //verificar se existem duplicatas
1888
        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...
1889
            return 10;
1890
        }
1891
1892
        return 0;
1893
    }
1894
1895
    /**
1896
     * fatura
1897
     * Monta o campo de duplicatas da DANFE (retrato e paisagem)
1898
     *
1899
     * @name   fatura
1900
     *
1901
     * @param number $x Posição horizontal canto esquerdo
1902
     * @param number $y Posição vertical canto superior
1903
     *
1904
     * @return number Posição vertical final
1905
     */
1906
    protected function fatura($x, $y)
1907
    {
1908
        $linha       = 1;
1909
        $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...
1910
        $oldx        = $x;
1911
        $textoFatura = $this->getTextoFatura();
1912
        //verificar se existem duplicatas
1913
        if ($this->dup->length > 0 || $textoFatura !== "") {
1914
            //#####################################################################
1915
            //FATURA / DUPLICATA
1916
            $texto = "FATURA / DUPLICATA";
1917
            if ($this->orientacao == 'P') {
1918
                $w = $this->wPrint;
1919
            } else {
1920
                $w = 271;
1921
            }
1922
            $h     = 8;
1923
            $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1924
            $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...
1925
            $y       += 3;
1926
            $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...
1927
            $dupcont = 0;
1928
            $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...
1929
            if ($nFat > 7) {
1930
                $myH = 6;
1931
                $myW = $this->wPrint;
1932
                if ($this->orientacao == 'L') {
1933
                    $myW -= $this->wCanhoto;
1934
                }
1935
                $aFont = ['font' => $this->fontePadrao, 'size' => 9, 'style' => ''];
1936
                $texto = "Existem mais de 7 duplicatas registradas, portanto não "
1937
                    . "serão exibidas, confira diretamente pelo XML.";
1938
                $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...
1939
1940
                return ($y + $h - 3);
1941
            }
1942
            if ($textoFatura !== "" && $this->exibirTextoFatura) {
1943
                $myH = 6;
1944
                $myW = $this->wPrint;
1945
                if ($this->orientacao == 'L') {
1946
                    $myW -= $this->wCanhoto;
1947
                }
1948
                $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
1949
                $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...
1950
                $y += $myH + 1;
1951
            }
1952
            if ($this->orientacao == 'P') {
1953
                $w = round($this->wPrint / 7.018, 0) - 1;
1954
            } else {
1955
                $w = 28;
1956
            }
1957
            $increm = 1;
1958
            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...
1959
                $nDup  = ! empty($this->dup->item($k)->getElementsByTagName('nDup')->item(0)->nodeValue)
1960
                    ? $this->dup->item($k)->getElementsByTagName('nDup')->item(0)->nodeValue
1961
                    : '';
1962
                $dDup  = ! empty($this->dup->item($k)->getElementsByTagName('dVenc')->item(0)->nodeValue)
1963
                    ? $this->ymdTodmy($this->dup->item($k)->getElementsByTagName('dVenc')->item(0)->nodeValue)
1964
                    : '';
1965
                $vDup  = ! empty($this->dup->item($k)->getElementsByTagName('vDup')->item(0)->nodeValue)
1966
                    ? 'R$ ' . number_format(
1967
                        $this->dup->item($k)->getElementsByTagName('vDup')->item(0)->nodeValue,
1968
                        2,
1969
                        ",",
1970
                        "."
1971
                    )
1972
                    : '';
1973
                $h     = 8;
1974
                $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...
1975
                if ($nDup != '0' && $nDup != '') {
1976
                    $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1977
                    $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...
1978
                    $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1979
                    $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...
1980
                } else {
1981
                    $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1982
                    $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...
1983
                }
1984
                $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1985
                $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...
1986
                $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1987
                $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...
1988
                $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1989
                $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...
1990
                $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1991
                $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...
1992
                $x       += $w + $increm;
1993
                $dupcont += 1;
1994
                if ($this->orientacao == 'P') {
1995
                    $maxDupCont = 6;
1996
                } else {
1997
                    $maxDupCont = 8;
1998
                }
1999
                if ($dupcont > $maxDupCont) {
2000
                    $y       += 9;
2001
                    $x       = $oldx;
2002
                    $dupcont = 0;
2003
                    $linha   += 1;
2004
                }
2005
                if ($linha == 5) {
2006
                    $linha = 4;
2007
                    break;
2008
                }
2009
            }
2010
            if ($dupcont == 0) {
2011
                $y -= 9;
2012
                $linha --;
2013
            }
2014
2015
            return ($y + $h);
2016
        } else {
2017
            $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...
2018
2019
            return ($y - 2);
2020
        }
2021
    }
2022
2023
    /**
2024
     * pagamento
2025
     * Monta o campo de pagamentos da DANFE (retrato e paisagem) (foi baseada na fatura)
2026
     *
2027
     * @name   pagamento
2028
     *
2029
     * @param number $x Posição horizontal canto esquerdo
2030
     * @param number $y Posição vertical canto superior
2031
     *
2032
     * @return number Posição vertical final
2033
     */
2034
    protected function pagamento($x, $y)
2035
    {
2036
        $linha = 1;
2037
        $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...
2038
        $oldx  = $x;
2039
        //verificar se existem cobranças definidas
2040
        if (isset($this->detPag) && $this->detPag->length > 0) {
2041
            //#####################################################################
2042
            //Tipo de pagamento
2043
            $texto = "PAGAMENTO";
2044
            if ($this->orientacao == 'P') {
2045
                $w = $this->wPrint;
2046
            } else {
2047
                $w = 271;
2048
            }
2049
            $h     = 8;
2050
            $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2051
            $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...
2052
            $y       += 3;
2053
            $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...
2054
            $dupcont = 0;
2055
            if ($this->orientacao == 'P') {
2056
                $w = round($this->wPrint / 7.018, 0) - 1;
2057
            } else {
2058
                $w = 28;
2059
            }
2060
            if ($this->orientacao == 'P') {
2061
                $maxDupCont = 6;
2062
            } else {
2063
                $maxDupCont = 8;
2064
            }
2065
            $increm         = 1;
2066
            $formaPagamento = [
2067
                '01' => 'Dinheiro',
2068
                '02' => 'Cheque',
2069
                '03' => 'Cartão de Crédito',
2070
                '04' => 'Cartão de Débito',
2071
                '05' => 'Crédito Loja',
2072
                '10' => 'Vale Alimentação',
2073
                '11' => 'Vale Refeição',
2074
                '12' => 'Vale Presente',
2075
                '13' => 'Vale Combustível',
2076
                '14' => 'Duplicata Mercantil',
2077
                '15' => 'Boleto',
2078
                '16' => 'Depósito Bancário',
2079
                '17' => 'Pagamento Instantâneo (PIX)',
2080
                '18' => 'Transferência bancária, Carteira Digital',
2081
                '19' => 'Programa de fidelidade, Cashback, Crédito Virtual',
2082
                '90' => 'Sem pagamento',
2083
                '99' => 'Outros'
2084
            ];
2085
            $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...
2086
                '01' => 'Visa',
2087
                '02' => 'Mastercard',
2088
                '03' => 'American',
2089
                '04' => 'Sorocred',
2090
                '05' => 'Diners',
2091
                '06' => 'Elo',
2092
                '07' => 'Hipercard',
2093
                '08' => 'Aura',
2094
                '09' => 'Cabal',
2095
                '99' => 'Outros'
2096
            ];
2097
            foreach ($this->detPag as $k => $d) {
2098
                $fPag  = ! empty($this->detPag->item($k)->getElementsByTagName('tPag')->item(0)->nodeValue)
2099
                    ? $this->detPag->item($k)->getElementsByTagName('tPag')->item(0)->nodeValue
2100
                    : '0';
2101
                $vPag  = ! empty($this->detPag->item($k)->getElementsByTagName('vPag')->item(0)->nodeValue)
2102
                    ? 'R$ ' . number_format(
2103
                        $this->detPag->item($k)->getElementsByTagName('vPag')->item(0)->nodeValue,
2104
                        2,
2105
                        ",",
2106
                        "."
2107
                    )
2108
                    : '';
2109
                $h     = 6;
2110
                $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...
2111
                if (isset($formaPagamento[$fPag])) {
2112
                    /*Exibir Item sem pagamento*/
2113
                    if ($fPag == '90') {
2114
                        continue;
2115
                    }
2116
                    $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2117
                    $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...
2118
                    $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2119
                    $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...
2120
                } else {
2121
                    $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
2122
                    $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...
2123
                }
2124
                $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2125
                $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...
2126
                $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2127
                $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...
2128
                $x       += $w + $increm;
2129
                $dupcont += 1;
2130
2131
                if ($dupcont > $maxDupCont) {
2132
                    $y       += 9;
2133
                    $x       = $oldx;
2134
                    $dupcont = 0;
2135
                    $linha   += 1;
2136
                }
2137
                if ($linha == 5) {
2138
                    $linha = 4;
2139
                    break;
2140
                }
2141
            }
2142
            if ($dupcont == 0) {
2143
                $y -= 9;
2144
                $linha --;
2145
            }
2146
2147
            return ($y + $h);
2148
        } else {
2149
            $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...
2150
2151
            return ($y - 2);
2152
        }
2153
    } //fim da função pagamento
2154
2155
    /**
2156
     * impostoHelper
2157
     * Auxilia a montagem dos campos de impostos e totais da DANFE
2158
     *
2159
     * @name   impostoHelper
2160
     *
2161
     * @param float $x Posição horizontal canto esquerdo
2162
     * @param float $y Posição vertical canto superior
2163
     * @param float $w Largura do campo
2164
     * @param float $h Altura do campo
2165
     * @param float $h Título do campo
2166
     * @param float $h Valor do imposto
2167
     *
2168
     * @return float Sugestão do $x do próximo imposto
2169
     */
2170
    protected function impostoHelper($x, $y, $w, $h, $titulo, $campoImposto)
2171
    {
2172
        $valorImposto = '0,00';
2173
        $the_field    = $this->ICMSTot->getElementsByTagName($campoImposto)->item(0);
2174
        if (isset($the_field)) {
2175
            $the_value = $the_field->nodeValue;
2176
            if (! empty($the_value)) {
2177
                $valorImposto = number_format($the_value, 2, ",", ".");
2178
            }
2179
        }
2180
2181
        $fontTitulo = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2182
        $fontValor  = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2183
        $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...
2184
        $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...
2185
2186
        $next_x = $x + $w;
2187
2188
        return $next_x;
2189
    }
2190
2191
    /**
2192
     * imposto
2193
     * Monta o campo de impostos e totais da DANFE (retrato e paisagem)
2194
     *
2195
     * @param number $x Posição horizontal canto esquerdo
2196
     * @param number $y Posição vertical canto superior
2197
     *
2198
     * @return number Posição vertical final
2199
     */
2200
    protected function imposto($x, $y)
2201
    {
2202
        $x_inicial = $x;
2203
        //#####################################################################
2204
        $campos_por_linha = 9;
2205
        if (! $this->exibirPIS) {
2206
            $campos_por_linha --;
2207
        }
2208
        if (! $this->exibirIcmsInterestadual) {
2209
            $campos_por_linha -= 2;
2210
        }
2211
2212
        if ($this->orientacao == 'P') {
2213
            $maxW       = $this->wPrint;
2214
            $title_size = 31;
2215
        } else {
2216
            $maxW       = $this->wPrint - $this->wCanhoto;
2217
            $title_size = 40;
2218
        }
2219
        $w = $maxW / $campos_por_linha;
2220
2221
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2222
        $texto = "CÁLCULO DO IMPOSTO";
2223
        $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...
2224
        $y += 3;
2225
        $h = 7;
2226
2227
        $x = $this->impostoHelper($x, $y, $w, $h, "BASE DE CÁLC. DO ICMS", "vBC");
2228
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO ICMS", "vICMS");
2229
        $x = $this->impostoHelper($x, $y, $w, $h, "BASE DE CÁLC. ICMS S.T.", "vBCST");
2230
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO ICMS SUBST.", "vST");
2231
        $x = $this->impostoHelper($x, $y, $w, $h, "V. IMP. IMPORTAÇÃO", "vII");
2232
2233
        if ($this->exibirIcmsInterestadual) {
2234
            $x = $this->impostoHelper($x, $y, $w, $h, "V. ICMS UF REMET.", "vICMSUFRemet");
2235
            $x = $this->impostoHelper($x, $y, $w, $h, "V. FCP UF DEST.", "vFCPUFDest");
2236
        }
2237
2238
        if ($this->exibirPIS) {
2239
            $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO PIS", "vPIS");
2240
        }
2241
2242
        $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...
2243
2244
        //
2245
2246
        $y += $h;
2247
        $x = $x_inicial;
2248
2249
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO FRETE", "vFrete");
2250
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO SEGURO", "vSeg");
2251
        $x = $this->impostoHelper($x, $y, $w, $h, "DESCONTO", "vDesc");
2252
        $x = $this->impostoHelper($x, $y, $w, $h, "OUTRAS DESPESAS", "vOutro");
2253
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR TOTAL IPI", "vIPI");
2254
2255
        if ($this->exibirIcmsInterestadual) {
2256
            $x = $this->impostoHelper($x, $y, $w, $h, "V. ICMS UF DEST.", "vICMSUFDest");
2257
            $x = $this->impostoHelper($x, $y, $w, $h, "V. TOT. TRIB.", "vTotTrib");
2258
        }
2259
        if ($this->exibirPIS) {
2260
            $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DA COFINS", "vCOFINS");
2261
        }
2262
        $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...
2263
2264
        return ($y + $h);
2265
    } //fim imposto
2266
2267
    /**
2268
     * transporte
2269
     * Monta o campo de transportes da DANFE (retrato e paisagem)
2270
     *
2271
     * @name   transporte
2272
     *
2273
     * @param float $x Posição horizontal canto esquerdo
2274
     * @param float $y Posição vertical canto superior
2275
     *
2276
     * @return float Posição vertical final
2277
     */
2278
    protected function transporte($x, $y)
2279
    {
2280
        $oldX = $x;
2281
        if ($this->orientacao == 'P') {
2282
            $maxW = $this->wPrint;
2283
        } else {
2284
            $maxW = $this->wPrint - $this->wCanhoto;
2285
        }
2286
        //#####################################################################
2287
        //TRANSPORTADOR / VOLUMES TRANSPORTADOS
2288
        $texto = "TRANSPORTADOR / VOLUMES TRANSPORTADOS";
2289
        $w     = $maxW;
2290
        $h     = 7;
2291
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2292
        $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...
2293
        //NOME / RAZÃO SOCIAL
2294
        $w1    = $maxW * 0.29;
2295
        $y     += 3;
2296
        $texto = 'NOME / RAZÃO SOCIAL';
2297
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2298
        $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...
2299
        if (isset($this->transporta)) {
2300
            $texto = ! empty($this->transporta->getElementsByTagName("xNome")->item(0)->nodeValue)
2301
                ? $this->transporta->getElementsByTagName("xNome")->item(0)->nodeValue
2302
                : '';
2303
        } else {
2304
            $texto = '';
2305
        }
2306
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2307
        $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...
2308
        //FRETE POR CONTA
2309
        $x     += $w1;
2310
        $w2    = $maxW * 0.15;
2311
        $texto = 'FRETE';
2312
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2313
        $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...
2314
        $tipoFrete = ! empty($this->transp->getElementsByTagName("modFrete")->item(0)->nodeValue)
2315
            ? $this->transp->getElementsByTagName("modFrete")->item(0)->nodeValue
2316
            : '0';
2317
        switch ($tipoFrete) {
2318
            case 0:
2319
                $texto = "0-Por conta do Rem";
2320
                break;
2321
            case 1:
2322
                $texto = "1-Por conta do Dest";
2323
                break;
2324
            case 2:
2325
                $texto = "2-Por conta de Terceiros";
2326
                break;
2327
            case 3:
2328
                $texto = "3-Próprio por conta do Rem";
2329
                break;
2330
            case 4:
2331
                $texto = "4-Próprio por conta do Dest";
2332
                break;
2333
            case 9:
2334
                $texto = "9-Sem Transporte";
2335
                break;
2336
        }
2337
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2338
        $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...
2339
        //CÓDIGO ANTT
2340
        $x     += $w2;
2341
        $texto = 'CÓDIGO ANTT';
2342
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2343
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
2344
        if (isset($this->veicTransp)) {
2345
            $texto = ! empty($this->veicTransp->getElementsByTagName("RNTC")->item(0)->nodeValue)
2346
                ? $this->veicTransp->getElementsByTagName("RNTC")->item(0)->nodeValue
2347
                : '';
2348
        } else {
2349
            $texto = '';
2350
        }
2351
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2352
        $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...
2353
        //PLACA DO VEÍC
2354
        $x     += $w2;
2355
        $texto = 'PLACA DO VEÍCULO';
2356
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2357
        $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...
2358
        if (isset($this->veicTransp)) {
2359
            $texto = ! empty($this->veicTransp->getElementsByTagName("placa")->item(0)->nodeValue)
2360
                ? $this->veicTransp->getElementsByTagName("placa")->item(0)->nodeValue
2361
                : '';
2362
        } elseif (isset($this->reboque)) {
2363
            $texto = ! empty($this->reboque->getElementsByTagName("placa")->item(0)->nodeValue)
2364
                ? $this->reboque->getElementsByTagName("placa")->item(0)->nodeValue
2365
                : '';
2366
        } else {
2367
            $texto = '';
2368
        }
2369
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2370
        $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...
2371
        //UF
2372
        $x     += $w2;
2373
        $w3    = round($maxW * 0.04, 0);
2374
        $texto = 'UF';
2375
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2376
        $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...
2377
        if (isset($this->veicTransp)) {
2378
            $texto = ! empty($this->veicTransp->getElementsByTagName("UF")->item(0)->nodeValue)
2379
                ? $this->veicTransp->getElementsByTagName("UF")->item(0)->nodeValue
2380
                : '';
2381
        } elseif (isset($this->reboque)) {
2382
            $texto = ! empty($this->reboque->getElementsByTagName("UF")->item(0)->nodeValue)
2383
                ? $this->reboque->getElementsByTagName("UF")->item(0)->nodeValue
2384
                : '';
2385
        } else {
2386
            $texto = '';
2387
        }
2388
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2389
        $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...
2390
        //CNPJ / CPF
2391
        $x     += $w3;
2392
        $w     = $maxW - ($w1 + 3 * $w2 + $w3);
2393
        $texto = 'CNPJ / CPF';
2394
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2395
        $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...
2396
        if (isset($this->transporta)) {
2397
            $texto = ! empty($this->transporta->getElementsByTagName("CNPJ")->item(0)->nodeValue)
2398
                ? $this->formatField(
2399
                    $this->transporta->getElementsByTagName("CNPJ")->item(0)->nodeValue,
2400
                    "##.###.###/####-##"
2401
                )
2402
                : '';
2403
            if ($texto == '') {
2404
                $texto = ! empty($this->transporta->getElementsByTagName("CPF")->item(0)->nodeValue)
2405
                    ? $this->formatField(
2406
                        $this->transporta->getElementsByTagName("CPF")->item(0)->nodeValue,
2407
                        "###.###.###-##"
2408
                    )
2409
                    : '';
2410
            }
2411
        } else {
2412
            $texto = '';
2413
        }
2414
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2415
        $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...
2416
        //#####################################################################
2417
        //ENDEREÇO
2418
        $y     += $h;
2419
        $x     = $oldX;
2420
        $h     = 7;
2421
        $w1    = $maxW * 0.44;
2422
        $texto = 'ENDEREÇO';
2423
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2424
        $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...
2425
        if (isset($this->transporta)) {
2426
            $texto = ! empty($this->transporta->getElementsByTagName("xEnder")->item(0)->nodeValue)
2427
                ? $this->transporta->getElementsByTagName("xEnder")->item(0)->nodeValue
2428
                : '';
2429
        } else {
2430
            $texto = '';
2431
        }
2432
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2433
        $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...
2434
        //MUNICÍPIO
2435
        $x     += $w1;
2436
        $w2    = round($maxW * 0.30, 0);
2437
        $texto = 'MUNICÍPIO';
2438
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2439
        $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...
2440
        if (isset($this->transporta)) {
2441
            $texto = ! empty($this->transporta->getElementsByTagName("xMun")->item(0)->nodeValue)
2442
                ? $this->transporta->getElementsByTagName("xMun")->item(0)->nodeValue
2443
                : '';
2444
        } else {
2445
            $texto = '';
2446
        }
2447
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2448
        $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...
2449
        //UF
2450
        $x     += $w2;
2451
        $w3    = round($maxW * 0.04, 0);
2452
        $texto = 'UF';
2453
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2454
        $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...
2455
        if (isset($this->transporta)) {
2456
            $texto = ! empty($this->transporta->getElementsByTagName("UF")->item(0)->nodeValue)
2457
                ? $this->transporta->getElementsByTagName("UF")->item(0)->nodeValue
2458
                : '';
2459
        } else {
2460
            $texto = '';
2461
        }
2462
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2463
        $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...
2464
        //INSCRIÇÃO ESTADUAL
2465
        $x     += $w3;
2466
        $w     = $maxW - ($w1 + $w2 + $w3);
2467
        $texto = 'INSCRIÇÃO ESTADUAL';
2468
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2469
        $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...
2470
        $texto = '';
2471
        if (isset($this->transporta)) {
2472
            if (! empty($this->transporta->getElementsByTagName("IE")->item(0)->nodeValue)) {
2473
                $texto = $this->transporta->getElementsByTagName("IE")->item(0)->nodeValue;
2474
            }
2475
        }
2476
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2477
        $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...
2478
        //Tratar Multiplos volumes
2479
        $volumes     = $this->transp->getElementsByTagName('vol');
2480
        $quantidade  = 0;
2481
        $especie     = '';
2482
        $marca       = '';
2483
        $numero      = '';
2484
        $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...
2485
        $pesoBruto   = 0;
2486
        $pesoLiquido = 0;
2487
        foreach ($volumes as $volume) {
2488
            $quantidade  += ! empty($volume->getElementsByTagName("qVol")->item(0)->nodeValue) ?
2489
                $volume->getElementsByTagName("qVol")->item(0)->nodeValue : 0;
2490
            $pesoBruto   += ! empty($volume->getElementsByTagName("pesoB")->item(0)->nodeValue) ?
2491
                $volume->getElementsByTagName("pesoB")->item(0)->nodeValue : 0;
2492
            $pesoLiquido += ! empty($volume->getElementsByTagName("pesoL")->item(0)->nodeValue) ?
2493
                $volume->getElementsByTagName("pesoL")->item(0)->nodeValue : 0;
2494
            $texto       = ! empty($this->transp->getElementsByTagName("esp")->item(0)->nodeValue) ?
2495
                $this->transp->getElementsByTagName("esp")->item(0)->nodeValue : '';
2496
            if ($texto != $especie && $especie != '') {
2497
                //tem várias especies
2498
                $especie = 'VARIAS';
2499
            } else {
2500
                $especie = $texto;
2501
            }
2502
            $texto = ! empty($this->transp->getElementsByTagName("marca")->item(0)->nodeValue)
2503
                ? $this->transp->getElementsByTagName("marca")->item(0)->nodeValue
2504
                : '';
2505
            if ($texto != $marca && $marca != '') {
2506
                //tem várias especies
2507
                $marca = 'VARIAS';
2508
            } else {
2509
                $marca = $texto;
2510
            }
2511
            $texto = ! empty($this->transp->getElementsByTagName("nVol")->item(0)->nodeValue)
2512
                ? $this->transp->getElementsByTagName("nVol")->item(0)->nodeValue
2513
                : '';
2514
            if ($texto != $numero && $numero != '') {
2515
                //tem várias especies
2516
                $numero = 'VARIOS';
2517
            } else {
2518
                $numero = $texto;
2519
            }
2520
        }
2521
2522
        //#####################################################################
2523
        //QUANTIDADE
2524
        $y     += $h;
2525
        $x     = $oldX;
2526
        $h     = 7;
2527
        $w1    = round($maxW * 0.10, 0);
2528
        $texto = 'QUANTIDADE';
2529
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2530
        $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...
2531
        if (! empty($quantidade)) {
2532
            $texto = $quantidade;
2533
            $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2534
            $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...
2535
        }
2536
        //ESPÉCIE
2537
        $x     += $w1;
2538
        $w2    = round($maxW * 0.17, 0);
2539
        $texto = 'ESPÉCIE';
2540
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2541
        $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...
2542
        $texto = $especie;
2543
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2544
        $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...
2545
        //MARCA
2546
        $x     += $w2;
2547
        $texto = 'MARCA';
2548
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2549
        $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...
2550
        $texto = ! empty($this->transp->getElementsByTagName("marca")->item(0)->nodeValue) ?
2551
            $this->transp->getElementsByTagName("marca")->item(0)->nodeValue : '';
2552
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2553
        $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...
2554
        //NUMERAÇÃO
2555
        $x     += $w2;
2556
        $texto = 'NUMERAÇÃO';
2557
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2558
        $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...
2559
        $texto = $numero;
2560
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2561
        $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...
2562
        //PESO BRUTO
2563
        $x     += $w2;
2564
        $w3    = round($maxW * 0.20, 0);
2565
        $texto = 'PESO BRUTO';
2566
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2567
        $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...
2568
        if (is_numeric($pesoBruto) && $pesoBruto > 0) {
2569
            $texto = number_format($pesoBruto, 3, ",", ".");
2570
        } else {
2571
            $texto = '';
2572
        }
2573
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2574
        $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...
2575
        //PESO LÍQUIDO
2576
        $x     += $w3;
2577
        $w     = $maxW - ($w1 + 3 * $w2 + $w3);
2578
        $texto = 'PESO LÍQUIDO';
2579
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2580
        $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...
2581
        if (is_numeric($pesoLiquido) && $pesoLiquido > 0) {
2582
            $texto = number_format($pesoLiquido, 3, ",", ".");
2583
        } else {
2584
            $texto = '';
2585
        }
2586
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
2587
        $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...
2588
2589
        return ($y + $h);
2590
    } //fim transporte
2591
2592
2593
    protected function descricaoProdutoHelper($origem, $campo, $formato)
2594
    {
2595
        $valor_original = $origem->getElementsByTagName($campo)->item(0);
2596
        if (! isset($valor_original)) {
2597
            return "";
2598
        }
2599
        $valor_original = $valor_original->nodeValue;
2600
        $valor          = ! empty($valor_original) ? number_format($valor_original, 2, ",", ".") : '';
2601
2602
        if ($valor != "") {
2603
            return sprintf($formato, $valor);
2604
        }
2605
2606
        return "";
2607
    }
2608
2609
    /**
2610
     * descricaoProduto
2611
     * Monta a string de descrição de cada Produto
2612
     *
2613
     * @name   descricaoProduto
2614
     *
2615
     * @param DOMNode itemProd
2616
     *
2617
     * @return string descricao do produto
2618
     */
2619
    protected function descricaoProduto($itemProd)
2620
    {
2621
        $prod       = $itemProd->getElementsByTagName('prod')->item(0);
2622
        $ICMS       = $itemProd->getElementsByTagName("ICMS")->item(0);
2623
        $ICMSUFDest = $itemProd->getElementsByTagName("ICMSUFDest")->item(0);
2624
        $impostos   = '';
2625
2626
        if (! empty($ICMS)) {
2627
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vBCFCP", " BcFcp=%s");
2628
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pFCP", " pFcp=%s%%");
2629
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vFCP", " vFcp=%s");
2630
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pRedBC", " pRedBC=%s%%");
2631
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pMVAST", " IVA/MVA=%s%%");
2632
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pICMSST", " pIcmsSt=%s%%");
2633
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vBCST", " BcIcmsSt=%s");
2634
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vICMSST", " vIcmsSt=%s");
2635
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vBCFCPST", " BcFcpSt=%s");
2636
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pFCPST", " pFcpSt=%s%%");
2637
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vFCPST", " vFcpSt=%s");
2638
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vBCSTRet", " Retido na compra: BASE ICMS ST=%s");
2639
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pST", " pSt=%s");
2640
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vICMSSTRet", " VALOR ICMS ST=%s");
2641
        }
2642
        if (! empty($ICMSUFDest)) {
2643
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "pFCPUFDest", " pFCPUFDest=%s%%");
2644
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "pICMSUFDest", " pICMSUFDest=%s%%");
2645
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "pICMSInterPart", " pICMSInterPart=%s%%");
2646
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "vFCPUFDest", " vFCPUFDest=%s");
2647
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "vICMSUFDest", " vICMSUFDest=%s");
2648
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "vICMSUFRemet", " vICMSUFRemet=%s");
2649
        }
2650
        $infAdProd = ! empty($itemProd->getElementsByTagName('infAdProd')->item(0)->nodeValue)
2651
            ? substr(
2652
                $this->anfaveaDANFE($itemProd->getElementsByTagName('infAdProd')->item(0)->nodeValue),
2653
                0,
2654
                500
2655
            )
2656
            : '';
2657
        if (! empty($infAdProd)) {
2658
            $infAdProd = trim($infAdProd);
2659
            $infAdProd .= ' ';
2660
        }
2661
        $loteTxt = '';
2662
        $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...
2663
        if (! empty($prod->getElementsByTagName("rastro"))) {
2664
            $rastro = $prod->getElementsByTagName("rastro");
2665
            $i      = 0;
2666
            while ($i < $rastro->length) {
2667
                $loteTxt .= $this->getTagValue($rastro->item($i), 'nLote', ' Lote: ');
2668
                $loteTxt .= $this->getTagValue($rastro->item($i), 'qLote', ' Quant: ');
2669
                $loteTxt .= $this->getTagDate($rastro->item($i), 'dFab', ' Fab: ');
2670
                $loteTxt .= $this->getTagDate($rastro->item($i), 'dVal', ' Val: ');
2671
                $loteTxt .= $this->getTagValue($rastro->item($i), 'vPMC', ' PMC: ');
2672
                $i ++;
2673
            }
2674
            if ($loteTxt != '') {
2675
                $loteTxt .= ' ';
2676
            }
2677
        }
2678
        //NT2013.006 FCI
2679
        $nFCI   = (! empty($itemProd->getElementsByTagName('nFCI')->item(0)->nodeValue)) ?
2680
            ' FCI:' . $itemProd->getElementsByTagName('nFCI')->item(0)->nodeValue : '';
2681
        $tmp_ad = $infAdProd . ($this->descProdInfoComplemento ? $loteTxt . $impostos . $nFCI : '');
2682
        $texto  = $prod->getElementsByTagName("xProd")->item(0)->nodeValue
2683
            . (strlen($tmp_ad) != 0 ? "\n    " . $tmp_ad : '');
2684
        //decodifica os caracteres html no xml
2685
        $texto = html_entity_decode($texto);
2686
        if ($this->descProdQuebraLinha) {
2687
            $texto = str_replace(";", "\n", $texto);
2688
        }
2689
2690
        return $texto;
2691
    }
2692
2693
    /**
2694
     * itens
2695
     * Monta o campo de itens da DANFE (retrato e paisagem)
2696
     *
2697
     * @name   itens
2698
     *
2699
     * @param float $x       Posição horizontal canto esquerdo
2700
     * @param float $y       Posição vertical canto superior
2701
     * @param float $nInicio Número do item inicial
2702
     * @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...
2703
     * @param float $hmax    Altura máxima do campo de itens em mm
2704
     *
2705
     * @return float Posição vertical final
2706
     */
2707
    protected function itens($x, $y, &$nInicio, $hmax, $pag = 0, $totpag = 0, $hCabecItens = 7)
2708
    {
2709
        $oldX = $x;
2710
        $oldY = $y;
2711
        $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...
2712
        //#####################################################################
2713
        //DADOS DOS PRODUTOS / SERVIÇOS
2714
        $texto = "DADOS DOS PRODUTOS / SERVIÇOS";
2715
        if ($this->orientacao == 'P') {
2716
            $w = $this->wPrint;
2717
        } else {
2718
            if ($nInicio < 2) { // primeira página
2719
                $w = $this->wPrint - $this->wCanhoto;
2720
            } else { // páginas seguintes
2721
                $w = $this->wPrint;
2722
            }
2723
        }
2724
        $h     = 4;
2725
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
2726
        $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...
2727
        $y += 3;
2728
        //desenha a caixa dos dados dos itens da NF
2729
        $hmax  += 1;
2730
        $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...
2731
        $this->pdf->textBox($x, $y, $w, $hmax);
2732
        //##################################################################################
2733
        // cabecalho LOOP COM OS DADOS DOS PRODUTOS
2734
        //CÓDIGO PRODUTO
2735
        $texto = "CÓDIGO PRODUTO";
2736
        $w1    = round($w * 0.09, 0);
2737
        $h     = 4;
2738
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2739
        $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...
2740
        $this->pdf->line($x + $w1, $y, $x + $w1, $y + $hmax);
2741
        //DESCRIÇÃO DO PRODUTO / SERVIÇO
2742
        $x     += $w1;
2743
        $w2    = round($w * 0.25, 0);
2744
        $texto = 'DESCRIÇÃO DO PRODUTO / SERVIÇO';
2745
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2746
        $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...
2747
        $this->pdf->line($x + $w2, $y, $x + $w2, $y + $hmax);
2748
        //NCM/SH
2749
        $x     += $w2;
2750
        $w3    = round($w * 0.06, 0);
2751
        $texto = 'NCM/SH';
2752
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2753
        $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...
2754
        $this->pdf->line($x + $w3, $y, $x + $w3, $y + $hmax);
2755
        //O/CST ou O/CSOSN
2756
        $x     += $w3;
2757
        $w4    = round($w * 0.05, 0);
2758
        $texto = 'O/CST'; // CRT = 2 ou CRT = 3
2759
        if ($this->getTagValue($this->emit, 'CRT') == '1') {
2760
            $texto = 'O/CSOSN';//Regime do Simples CRT = 1
2761
        }
2762
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2763
        $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...
2764
        $this->pdf->line($x + $w4, $y, $x + $w4, $y + $hmax);
2765
        //CFOP
2766
        $x     += $w4;
2767
        $w5    = round($w * 0.04, 0);
2768
        $texto = 'CFOP';
2769
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2770
        $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...
2771
        $this->pdf->line($x + $w5, $y, $x + $w5, $y + $hmax);
2772
        //UN
2773
        $x     += $w5;
2774
        $w6    = round($w * 0.03, 0);
2775
        $texto = 'UN';
2776
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2777
        $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...
2778
        $this->pdf->line($x + $w6, $y, $x + $w6, $y + $hmax);
2779
        //QUANT
2780
        $x     += $w6;
2781
        $w7    = round($w * 0.08, 0);
2782
        $texto = 'QUANT';
2783
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2784
        $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...
2785
        $this->pdf->line($x + $w7, $y, $x + $w7, $y + $hmax);
2786
        //VALOR UNIT
2787
        $x     += $w7;
2788
        $w8    = round($w * 0.06, 0);
2789
        $texto = 'VALOR UNIT';
2790
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2791
        $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...
2792
        $this->pdf->line($x + $w8, $y, $x + $w8, $y + $hmax);
2793
        //VALOR TOTAL
2794
        $x     += $w8;
2795
        $w9    = round($w * 0.06, 0);
2796
        $texto = 'VALOR TOTAL';
2797
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2798
        $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...
2799
        $this->pdf->line($x + $w9, $y, $x + $w9, $y + $hmax);
2800
        //VALOR DESCONTO
2801
        $x     += $w9;
2802
        $w10   = round($w * 0.05, 0);
2803
        $texto = 'VALOR DESC';
2804
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2805
        $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...
2806
        $this->pdf->line($x + $w10, $y, $x + $w10, $y + $hmax);
2807
        //B.CÁLC ICMS
2808
        $x     += $w10;
2809
        $w11   = round($w * 0.06, 0);
2810
        $texto = 'B.CÁLC ICMS';
2811
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2812
        $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...
2813
        $this->pdf->line($x + $w11, $y, $x + $w11, $y + $hmax);
2814
        //VALOR ICMS
2815
        $x     += $w11;
2816
        $w12   = round($w * 0.06, 0);
2817
        $texto = 'VALOR ICMS';
2818
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2819
        $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...
2820
        $this->pdf->line($x + $w12, $y, $x + $w12, $y + $hmax);
2821
        //VALOR IPI
2822
        $x     += $w12;
2823
        $w13   = round($w * 0.05, 0);
2824
        $texto = 'VALOR IPI';
2825
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2826
        $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...
2827
        $this->pdf->line($x + $w13, $y, $x + $w13, $y + $hmax);
2828
        //ALÍQ. ICMS
2829
        $x     += $w13;
2830
        $w14   = round($w * 0.04, 0);
2831
        $texto = 'ALÍQ. ICMS';
2832
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
2833
        $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...
2834
        $this->pdf->line($x + $w14, $y, $x + $w14, $y + $hmax);
2835
        //ALÍQ. IPI
2836
        $x     += $w14;
2837
        $w15   = $w - ($w1 + $w2 + $w3 + $w4 + $w5 + $w6 + $w7 + $w8 + $w9 + $w10 + $w11 + $w12 + $w13 + $w14);
2838
        $texto = 'ALÍQ. IPI';
2839
        $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...
2840
        $this->pdf->line($oldX, $y + $h + 1, $oldX + $w, $y + $h + 1);
2841
        $y += 5;
2842
        //##################################################################################
2843
        // LOOP COM OS DADOS DOS PRODUTOS
2844
        $i      = 0;
2845
        $hUsado = $hCabecItens;
2846
        $aFont  = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
2847
2848
        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...
2849
            if ($i >= $nInicio) {
2850
                $thisItem = $this->det->item($i);
2851
                //carrega as tags do item
2852
                $prod         = $thisItem->getElementsByTagName("prod")->item(0);
2853
                $imposto      = $this->det->item($i)->getElementsByTagName("imposto")->item(0);
2854
                $ICMS         = $imposto->getElementsByTagName("ICMS")->item(0);
2855
                $IPI          = $imposto->getElementsByTagName("IPI")->item(0);
2856
                $textoProduto = $this->descricaoProduto($thisItem);
2857
                
2858
2859
                // Posição y dos dados das unidades tributaveis.
2860
                $yTrib = $this->pdf->fontSize + .5;
2861
2862
                $uCom = $prod->getElementsByTagName("uCom")->item(0)->nodeValue;
2863
                $vUnCom = $prod->getElementsByTagName("vUnCom")->item(0)->nodeValue;
2864
                $uTrib = $prod->getElementsByTagName("uTrib")->item(0);
2865
                $qTrib = $prod->getElementsByTagName("qTrib")->item(0);
2866
                $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...
2867
                $vUnTrib = !empty($prod->getElementsByTagName("vUnTrib")->item(0)->nodeValue)
2868
                    ? $prod->getElementsByTagName("vUnTrib")->item(0)->nodeValue
2869
                    : 0;
2870
                // A Configuração serve para informar se irá exibir
2871
                //   de forma obrigatória, estando diferente ou não,
2872
                //   a unidade de medida tributária.
2873
                // ========
2874
                // A Exibição será realizada sempre que a unidade comercial for
2875
                //   diferente da unidade de medida tributária.
2876
                // "Nas situações em que o valor unitário comercial for diferente do valor unitário tributável,
2877
                //   ambas as informações deverão estar expressas e identificadas no DANFE, podendo ser
2878
                //   utilizada uma das linhas adicionais previstas, ou o campo de informações adicionais."
2879
                // > Manual Integração - Contribuinte 4.01 - NT2009.006, Item 7.1.5, página 91.
2880
                $mostrarUnidadeTributavel = (
2881
                    !empty($uTrib)
2882
                    && !empty($qTrib)
2883
                    && number_format($vUnCom, 2, ',', '') !== number_format($vUnTrib, 2, ',', '')
2884
                );
2885
2886
                // Informação sobre unidade de medida tributavel.
2887
                // Se não for para exibir a unidade de medida tributavel, então
2888
                // A Escrita irá começar em 0.
2889
                if (! $mostrarUnidadeTributavel) {
2890
                    $yTrib = 0;
2891
                }
2892
                $h = $this->calculeHeight($thisItem, $mostrarUnidadeTributavel);
2893
                $hUsado += $h;
2894
2895
                $yTrib += $y;
2896
                $diffH = $hmax - $hUsado;
2897
2898
                if ($pag != $totpag) {
2899
                    if (1 > $diffH && $i < $totItens) {
2900
                        //ultrapassa a capacidade para uma única página
2901
                        //o restante dos dados serão usados nas proximas paginas
2902
                        $nInicio = $i;
2903
                        break;
2904
                    }
2905
                }
2906
                $y_linha = $y + $h;
2907
                // linha entre itens
2908
                $this->pdf->dashedHLine($oldX, $y_linha, $w, 0.1, 120);
2909
                //corrige o x
2910
                $x = $oldX;
2911
                //codigo do produto
2912
                $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...
2913
                $texto = $prod->getElementsByTagName("cProd")->item(0)->nodeValue;
2914
                $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...
2915
                $x += $w1;
2916
                //DESCRIÇÃO
2917
                if ($this->orientacao == 'P') {
2918
                    $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...
2919
                } else {
2920
                    $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...
2921
                }
2922
                $x += $w2;
2923
                //NCM
2924
                $texto = ! empty($prod->getElementsByTagName("NCM")->item(0)->nodeValue) ?
2925
                    $prod->getElementsByTagName("NCM")->item(0)->nodeValue : '';
2926
                $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...
2927
                $x += $w3;
2928
                //CST
2929
                if (isset($ICMS)) {
2930
                    $origem = $this->getTagValue($ICMS, "orig");
2931
                    $cst    = $this->getTagValue($ICMS, "CST");
2932
                    $csosn  = $this->getTagValue($ICMS, "CSOSN");
2933
                    $texto  = $origem . $cst . $csosn;
2934
                    $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...
2935
                }
2936
                //CFOP
2937
                $x     += $w4;
2938
                $texto = $prod->getElementsByTagName("CFOP")->item(0)->nodeValue;
2939
                $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...
2940
                //Unidade
2941
                $x     += $w5;
2942
                $texto = $uCom;
2943
                $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...
2944
                //Unidade de medida tributável
2945
                $qTrib = $prod->getElementsByTagName("qTrib")->item(0)->nodeValue;
0 ignored issues
show
Unused Code introduced by
$qTrib is not used, you could remove the assignment.

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

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

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

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

Loading history...
2946
                if ($mostrarUnidadeTributavel) {
2947
                    $texto = $uTrib->nodeValue;
2948
                    $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...
2949
                }
2950
                $x += $w6;
2951
                if ($this->orientacao == 'P') {
2952
                    $alinhamento = 'R';
2953
                } else {
2954
                    $alinhamento = 'R';
2955
                }
2956
                // QTDADE
2957
                $qCom  = $prod->getElementsByTagName("qCom")->item(0);
2958
                $texto = number_format($qCom->nodeValue, $this->qComCasasDec, ",", ".");
2959
                $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...
2960
                // QTDADE Tributável
2961
                if ($mostrarUnidadeTributavel) {
2962
                    $qTrib = $prod->getElementsByTagName("qTrib")->item(0);
2963
                    if (! empty($qTrib)) {
2964
                        $texto = number_format($qTrib->nodeValue, $this->qComCasasDec, ",", ".");
2965
                        $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...
2966
                    }
2967
                }
2968
                $x += $w7;
2969
                // Valor Unitário
2970
                $vUnCom = $prod->getElementsByTagName("vUnCom")->item(0);
2971
                $texto  = number_format($vUnCom->nodeValue, $this->vUnComCasasDec, ",", ".");
2972
                $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...
2973
                // Valor Unitário Tributável
2974
                if ($mostrarUnidadeTributavel) {
2975
                    $vUnTrib = $prod->getElementsByTagName("vUnTrib")->item(0);
2976
                    if (! empty($vUnTrib)) {
2977
                        $texto = number_format($vUnTrib->nodeValue, $this->vUnComCasasDec, ",", ".");
2978
                        $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...
2979
                    }
2980
                }
2981
                $x += $w8;
2982
                // Valor do Produto
2983
                $texto = "";
2984
                if (is_numeric($prod->getElementsByTagName("vProd")->item(0)->nodeValue)) {
2985
                    $texto = number_format($prod->getElementsByTagName("vProd")->item(0)->nodeValue, 2, ",", ".");
2986
                }
2987
                $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...
2988
                $x += $w9;
2989
                //Valor do Desconto
2990
                $vdesc = ! empty($prod->getElementsByTagName("vDesc")->item(0)->nodeValue)
2991
                    ? $prod->getElementsByTagName("vDesc")->item(0)->nodeValue : 0;
2992
2993
                $texto = number_format($vdesc, 2, ",", ".");
2994
                $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...
2995
                //Valor da Base de calculo
2996
                $x += $w10;
2997
                if (isset($ICMS)) {
2998
                    $texto = ! empty($ICMS->getElementsByTagName("vBC")->item(0)->nodeValue)
2999
                        ? number_format(
3000
                            $ICMS->getElementsByTagName("vBC")->item(0)->nodeValue,
3001
                            2,
3002
                            ",",
3003
                            "."
3004
                        )
3005
                        : '0,00';
3006
                    $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...
3007
                }
3008
                //Valor do ICMS
3009
                $x += $w11;
3010
                if (isset($ICMS)) {
3011
                    $texto = ! empty($ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue)
3012
                        ? number_format(
3013
                            $ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue,
3014
                            2,
3015
                            ",",
3016
                            "."
3017
                        )
3018
                        : '0,00';
3019
                    $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...
3020
                }
3021
                //Valor do IPI
3022
                $x += $w12;
3023
                if (isset($IPI)) {
3024
                    $texto = ! empty($IPI->getElementsByTagName("vIPI")->item(0)->nodeValue)
3025
                        ? number_format(
3026
                            $IPI->getElementsByTagName("vIPI")->item(0)->nodeValue,
3027
                            2,
3028
                            ",",
3029
                            "."
3030
                        )
3031
                        : '';
3032
                } else {
3033
                    $texto = '';
3034
                }
3035
                $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...
3036
                // %ICMS
3037
                $x += $w13;
3038
                if (isset($ICMS)) {
3039
                    $texto = ! empty($ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue)
3040
                        ? number_format(
3041
                            $ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue,
3042
                            2,
3043
                            ",",
3044
                            "."
3045
                        )
3046
                        : '0,00';
3047
                    $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...
3048
                }
3049
                //%IPI
3050
                $x += $w14;
3051
                if (isset($IPI)) {
3052
                    $texto = ! empty($IPI->getElementsByTagName("pIPI")->item(0)->nodeValue)
3053
                        ? number_format(
3054
                            $IPI->getElementsByTagName("pIPI")->item(0)->nodeValue,
3055
                            2,
3056
                            ",",
3057
                            "."
3058
                        )
3059
                        : '';
3060
                } else {
3061
                    $texto = '';
3062
                }
3063
                $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...
3064
3065
3066
                // Dados do Veiculo Somente para veiculo 0 Km
3067
                $veicProd = $prod->getElementsByTagName("veicProd")->item(0);
3068
                // Tag somente é gerada para veiculo 0k, e só é permitido um veiculo por NF-e por conta do detran
3069
                // Verifica se a Tag existe
3070
                if (! empty($veicProd)) {
3071
                    $this->dadosItenVeiculoDANFE($oldX, $y, $nInicio, $h, $prod);
3072
                }
3073
3074
3075
                $y += $h;
3076
                $i ++;
3077
                //incrementa o controle dos itens processados.
3078
                $this->qtdeItensProc ++;
3079
            } else {
3080
                $i ++;
3081
            }
3082
        }
3083
3084
        return $oldY + $hmax;
3085
    }
3086
3087
3088
    /**
3089
     * dadosItenVeiculoDANFE
3090
     * Coloca os dados do veiculo abaixo do item da NFe. (retrato e paisagem)
3091
     *
3092
     * @param float  $x    Posição horizontal
3093
     *                     canto esquerdo
3094
     * @param float  $y    Posição vertical
3095
     *                     canto superior
3096
     * @param        $nInicio
3097
     * @param float  $h    altura do campo
3098
     * @param object $prod Contendo todos os dados do item
3099
     */
3100
3101
    protected function dadosItenVeiculoDANFE($x, $y, &$nInicio, $h, $prod)
3102
    {
3103
        $oldX = $x;
3104
        $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...
3105
3106
        if ($this->orientacao == 'P') {
3107
            $w = $this->wPrint;
3108
        } else {
3109
            if ($nInicio < 2) { // primeira página
3110
                $w = $this->wPrint - $this->wCanhoto;
3111
            } else { // páginas seguintes
3112
                $w = $this->wPrint;
3113
            }
3114
        }
3115
3116
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
3117
3118
        $w1 = round($w * 0.09, 0);
3119
3120
        // Tabela Renavam Combustivel
3121
        $renavamCombustivel = [
3122
            1  => 'ALCOOL',
3123
            2  => 'GASOLINA',
3124
            3  => 'DIESEL',
3125
            4  => 'GASOGENIO',
3126
            5  => 'GAS METANO',
3127
            6  => 'ELETRICO/FONTE INTERNA',
3128
            7  => 'ELETRICO/FONTE EXTERNA',
3129
            8  => 'GASOL/GAS NATURAL COMBUSTIVEL',
3130
            9  => 'ALCOOL/GAS NATURAL COMBUSTIVEL',
3131
            10 => 'DIESEL/GAS NATURAL COMBUSTIVEL',
3132
            11 => 'VIDE/CAMPO/OBSERVACAO',
3133
            12 => 'ALCOOL/GAS NATURAL VEICULAR',
3134
            13 => 'GASOLINA/GAS NATURAL VEICULAR',
3135
            14 => 'DIESEL/GAS NATURAL VEICULAR',
3136
            15 => 'GAS NATURAL VEICULAR',
3137
            16 => 'ALCOOL/GASOLINA',
3138
            17 => 'GASOLINA/ALCOOL/GAS NATURAL',
3139
            18 => 'GASOLINA/ELETRICO'
3140
        ];
3141
3142
        $renavamEspecie = [
3143
            1 => 'PASSAGEIRO',
3144
            2 => 'CARGA',
3145
            3 => 'MISTO',
3146
            4 => 'CORRIDA',
3147
            5 => 'TRACAO',
3148
            6 => 'ESPECIAL',
3149
            7 => 'COLECAO'
3150
        ];
3151
3152
        $renavamTiposVeiculos = [
3153
            1  => 'BICICLETA',
3154
            2  => 'CICLOMOTOR',
3155
            3  => 'MOTONETA',
3156
            4  => 'MOTOCICLETA',
3157
            5  => 'TRICICLO',
3158
            6  => 'AUTOMOVEL',
3159
            7  => 'MICROONIBUS',
3160
            8  => 'ONIBUS',
3161
            9  => 'BONDE',
3162
            10 => 'REBOQUE',
3163
            11 => 'SEMI-REBOQUE',
3164
            12 => 'CHARRETE',
3165
            13 => 'CAMIONETA',
3166
            14 => 'CAMINHAO',
3167
            15 => 'CARROCA',
3168
            16 => 'CARRO DE MAO',
3169
            17 => 'CAMINHAO TRATOR',
3170
            18 => 'TRATOR DE RODAS',
3171
            19 => 'TRATOR DE ESTEIRAS',
3172
            20 => 'TRATOR MISTO',
3173
            21 => 'QUADRICICLO',
3174
            22 => 'CHASSI/PLATAFORMA',
3175
            23 => 'CAMINHONETE',
3176
            24 => 'SIDE-CAR',
3177
            25 => 'UTILITARIO',
3178
            26 => 'MOTOR-CASA'
3179
        ];
3180
3181
        $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...
3182
            'F' => 'FOSCA',
3183
            'S' => 'SÓLIDA',
3184
            'P' => 'PEROLIZADA',
3185
            'M' => 'METALICA',
3186
        ];
3187
3188
        $veicProd = $prod->getElementsByTagName("veicProd")->item(0);
3189
3190
        $veiculoChassi     = $veicProd->getElementsByTagName("chassi")->item(0)->nodeValue;
3191
        $veiculoCor        = $veicProd->getElementsByTagName("xCor")->item(0)->nodeValue;
3192
        $veiculoCilindrada = $veicProd->getElementsByTagName("cilin")->item(0)->nodeValue;
3193
        $veiculoCmkg       = $veicProd->getElementsByTagName("CMT")->item(0)->nodeValue;
3194
        $veiculoTipo       = $veicProd->getElementsByTagName("tpVeic")->item(0)->nodeValue;
3195
3196
        $veiculoMotor       = $veicProd->getElementsByTagName("nMotor")->item(0)->nodeValue;
3197
        $veiculoRenavam     = $veicProd->getElementsByTagName("cMod")->item(0)->nodeValue;
3198
        $veiculoHp          = $veicProd->getElementsByTagName("pot")->item(0)->nodeValue;
3199
        $veiculoPlaca       = ''; //$veiculo->getElementsByTagName("CMT")->item(0)->nodeValue;
3200
        $veiculoTipoPintura = $veicProd->getElementsByTagName("tpPint")->item(0)->nodeValue;
3201
        $veiculoMarcaModelo = $prod->getElementsByTagName("xProd")->item(0)->nodeValue;
3202
        $veiculoEspecie     = $veicProd->getElementsByTagName("espVeic")->item(0)->nodeValue;
3203
        $veiculoCombustivel = $veicProd->getElementsByTagName("tpComb")->item(0)->nodeValue;
3204
        $veiculoSerial      = $veicProd->getElementsByTagName("nSerie")->item(0)->nodeValue;
3205
        $veiculoFabricacao  = $veicProd->getElementsByTagName("anoFab")->item(0)->nodeValue;
3206
        $veiculoModelo      = $veicProd->getElementsByTagName("anoMod")->item(0)->nodeValue;
3207
        $veiculoDistancia   = $veicProd->getElementsByTagName("dist")->item(0)->nodeValue;
3208
3209
        $x = $oldX;
3210
3211
        $yVeic = $y + $h;
3212
        $texto = 'Chassi: ............: ' . $veiculoChassi;
3213
        $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...
3214
        $yVeic += $h;
3215
        $texto = 'Cor...................: ' . $veiculoCor;
3216
        $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...
3217
        $yVeic += $h;
3218
        $texto = 'Cilindrada........: ' . $veiculoCilindrada;
3219
        $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...
3220
        $yVeic += $h;
3221
        $texto = 'Cmkg...............: ' . $veiculoCmkg;
3222
        $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...
3223
        $yVeic += $h;
3224
        $texto = 'Tipo.................: ' . ($renavamTiposVeiculos[intval($veiculoTipo)] ?? $veiculoTipo);
3225
        $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...
3226
        $yVeic = $y + $h;
3227
        $xVeic = $x + 65;
3228
        $texto = 'Nº Motor: .........: ' . $veiculoMotor;
3229
        $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...
3230
        $yVeic += $h;
3231
        $texto = 'Renavam...........: ' . $veiculoRenavam;
3232
        $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...
3233
        $yVeic += $h;
3234
        $texto = 'HP.....................: ' . $veiculoHp;
3235
        $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...
3236
        $yVeic += $h;
3237
        $texto = 'Placa.................: ' . $veiculoPlaca;
3238
        $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...
3239
        $yVeic += $h;
3240
        $texto = 'Tipo Pintura......: ' . ($renavamEspecie[intval($veiculoTipoPintura)] ?? $veiculoTipoPintura);
3241
        $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...
3242
        $yVeic = $y + $h;
3243
        $xVeic = $xVeic + 55;
3244
        $texto = 'Marca / Modelo.....: ' . $veiculoMarcaModelo;
3245
        $this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
3246
        $yVeic += $h;
3247
        $texto = 'Especie..................: ' . ($renavamEspecie[intval($veiculoEspecie)] ?? $veiculoEspecie);
3248
        $this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
3249
        $yVeic += $h;
3250
        $texto = 'Combustivel..........: ' . ($renavamCombustivel[intval($veiculoCombustivel)] ?? $veiculoCombustivel);
3251
        $this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
3252
        $yVeic += $h;
3253
        $texto = 'Serial.....................: ' . $veiculoSerial;
3254
        $this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
3255
        $yVeic += $h;
3256
        $texto = 'Ano Fab/Mod........: ' . $veiculoFabricacao . '/' . $veiculoModelo;
3257
        $this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

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