Completed
Pull Request — master (#430)
by Roberto
05:08 queued 02:05
created

Danfe::statusNFe()   C

Complexity

Conditions 17
Paths 15

Size

Total Lines 44

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 306

Importance

Changes 0
Metric Value
cc 17
nc 15
nop 0
dl 0
loc 44
ccs 0
cts 44
cp 0
crap 306
rs 5.2166
c 0
b 0
f 0

How to fix   Complexity   

Long Method

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

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

Commonly applied refactorings include:

1
<?php
2
namespace NFePHP\DA\NFe;
3
4
use NFePHP\DA\Legacy\Dom;
5
use NFePHP\DA\Legacy\Pdf;
6
use \NFePHP\DA\Common\DaCommon;
7
8
class Danfe extends DaCommon
9
{
10
11
    /**
12
     * Posição
13
     *
14
     * @var float
15
     */
16
    protected $yDados = 0;
17
    /**
18
     * Parâmetro para exibir ou ocultar os valores do PIS/COFINS.
19
     *
20
     * @var boolean
21
     */
22
    protected $qCanhoto = 1;
23
    /**
24
     * Define a exbição dos valores de PIS e Cofins
25
     *
26
     * @var bool
27
     */
28
    protected $exibirPIS = true;
29
    /**
30
     * Parâmetro para exibir ou ocultar os valores do ICMS Interestadual e Valor Total dos Impostos.
31
     *
32
     * @var boolean
33
     */
34
    protected $exibirIcmsInterestadual = true;
35
    /**
36
     * Parâmetro para exibir ou ocultar o texto sobre valor aproximado dos tributos.
37
     *
38
     * @var boolean
39
     */
40
    protected $exibirValorTributos = true;
41
    /**
42
     * Parâmetro para exibir ou ocultar o texto adicional sobre a forma de pagamento
43
     * e as informações de fatura/duplicata.
44
     *
45
     * @var boolean
46
     */
47
    protected $exibirTextoFatura = false;
48
    /**
49
     * Parâmetro do controle se deve concatenar automaticamente informações complementares
50
     * na descrição do produto, como por exemplo, informações sobre impostos.
51
     *
52
     * @var boolean
53
     */
54
    public $descProdInfoComplemento = true;
55
    /**
56
     *`Parâmetro que habilita a geração de automatica de informações
57
     *
58
     * @var boolean
59
     */
60
    public $gerarInformacoesAutomaticas = true;
61
    /**
62
     * Parâmetro do controle se deve gerar quebras de linha com "\n" a partir de ";" na descrição do produto.
63
     *
64
     * @var boolean
65
     */
66
    protected $descProdQuebraLinha = true;
67
    /**
68
     * XML NFe
69
     *
70
     * @var string
71
     */
72
    protected $xml;
73
    /**
74
     * mesagens de erro
75
     *
76
     * @var string
77
     */
78
    protected $errMsg = '';
79
    /**
80
     * status de erro true um erro ocorreu false sem erros
81
     *
82
     * @var boolean
83
     */
84
    protected $errStatus = false;
85
    /**
86
     * Texto adicional da DANFE
87
     *
88
     * @var string
89
     */
90
    protected $textoAdic = '';
91
    /**
92
     * Largura
93
     *
94
     * @var float
95
     */
96
    protected $wAdic = 0;
97
    /**
98
     * largura do canhoto (25mm) apenas para a formatação paisagem
99
     *
100
     * @var float
101
     */
102
    protected $wCanhoto = 25;
103
    /**
104
     * Formato chave
105
     *
106
     * @var string
107
     */
108
    protected $formatoChave = "#### #### #### #### #### #### #### #### #### #### ####";
109
    /**
110
     * quantidade de itens já processados na montagem do DANFE
111
     *
112
     * @var integer
113
     */
114
    protected $qtdeItensProc;
115
    /**
116
     * Dom Document
117
     *
118
     * @var \NFePHP\DA\Legacy\Dom
119
     */
120
    protected $dom;
121
    /**
122
     * Node
123
     *
124
     * @var \DOMNode
125
     */
126
    protected $infNFe;
127
    /**
128
     * Node
129
     *
130
     * @var \DOMNode
131
     */
132
    protected $ide;
133
    /**
134
     * Node
135
     *
136
     * @var \DOMNode
137
     */
138
    protected $entrega;
139
    /**
140
     * Node
141
     *
142
     * @var \DOMNode
143
     */
144
    protected $retirada;
145
    /**
146
     * Node
147
     *
148
     * @var \DOMNode
149
     */
150
    protected $emit;
151
    /**
152
     * Node
153
     *
154
     * @var \DOMNode
155
     */
156
    protected $dest;
157
    /**
158
     * Node
159
     *
160
     * @var \DOMNode
161
     */
162
    protected $enderEmit;
163
    /**
164
     * Node
165
     *
166
     * @var \DOMNode
167
     */
168
    protected $enderDest;
169
    /**
170
     * Node
171
     *
172
     * @var \DOMNode
173
     */
174
    protected $det;
175
    /**
176
     * Node
177
     *
178
     * @var \DOMNode
179
     */
180
    protected $cobr;
181
    /**
182
     * Node
183
     *
184
     * @var \DOMNode
185
     */
186
    protected $dup;
187
    /**
188
     * Node
189
     *
190
     * @var \DOMNode
191
     */
192
    protected $ICMSTot;
193
    /**
194
     * Node
195
     *
196
     * @var \DOMNode
197
     */
198
    protected $ISSQNtot;
199
    /**
200
     * Node
201
     *
202
     * @var \DOMNode
203
     */
204
    protected $transp;
205
    /**
206
     * Node
207
     *
208
     * @var \DOMNode
209
     */
210
    protected $transporta;
211
    /**
212
     * Node
213
     *
214
     * @var \DOMNode
215
     */
216
    protected $veicTransp;
217
    /**
218
     * Node reboque
219
     *
220
     * @var \DOMNode
221
     */
222
    protected $reboque;
223
    /**
224
     * Node infAdic
225
     *
226
     * @var \DOMNode
227
     */
228
    protected $infAdic;
229
    /**
230
     * Tipo de emissão
231
     *
232
     * @var integer
233
     */
234
    protected $tpEmis;
235
    /**
236
     * Node infProt
237
     *
238
     * @var \DOMNode
239
     */
240
    protected $infProt;
241
    /**
242
     * 1-Retrato/ 2-Paisagem
243
     *
244
     * @var integer
245
     */
246
    protected $tpImp;
247
    /**
248
     * Node compra
249
     *
250
     * @var \DOMNode
251
     */
252
    protected $compra;
253
    /**
254
     * @var int
255
     */
256
    protected $textadicfontsize;
257
    /**
258
     * Número de casas para a quantidade de itens da unidade comercial.
259
     *
260
     * @var integer
261
     */
262
    protected $qComCasasDec = 4;
263
264
    /**
265
     * Número de casas decimais para o valor da unidade comercial.
266
     *
267
     * @var integer
268
     */
269
    protected $vUnComCasasDec = 4;
270
271
    /**
272
     * @var int
273
     */
274
    protected $hdadosadic = 10;
275
276
    /**
277
     * __construct
278
     *
279
     * @name  __construct
280
     *
281
     * @param string $xml Conteúdo XML da NF-e (com ou sem a tag nfeProc)
282
     */
283
    public function __construct($xml)
284
    {
285
        $this->loadDoc($xml);
286
    }
287
288
289
    /**
290
     * Define a quantidade de casas decimais para unidade comercial.
291
     *
292
     * @param integer $vUnComCasasDec
293
     */
294
    public function setVUnComCasasDec($vUnComCasasDec)
295
    {
296
        $this->vUnComCasasDec = $vUnComCasasDec;
297
    }
298
299
    /**
300
     * Define a quantidade de casas decimais para unidade comercial.
301
     *
302
     * @param integer $qComCasasDec
303
     */
304
    public function setQComCasasDec($qComCasasDec)
305
    {
306
        $this->qComCasasDec = $qComCasasDec;
307
    }
308
309
    protected function calculoEspacoVericalDadosAdicionais()
310
    {
311
        $this->textoAdic = '';
312
        //informações adicionais
313
        $fontProduto            = [
314
            'font'  => $this->fontePadrao,
315
            'size'  => 8,
316
            'style' => ''
317
        ];
318
        $k                      = $this->pdf->k;
319
        $this->textadicfontsize = $fontProduto['size'] / $k;
0 ignored issues
show
Documentation Bug introduced by
It seems like $fontProduto['size'] / $k can also be of type double. However, the property $textadicfontsize is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
320
        $this->textoAdic        .= $this->geraInformacoesDasNotasReferenciadas();
321
        if (isset($this->infAdic)) {
322
            $i = 0;
323
            if ($this->textoAdic != '') {
324
                $this->textoAdic .= ". \n";
325
            }
326
            $this->textoAdic .= ! empty($this->getTagValue($this->infAdic, "infCpl"))
327
                ? 'Inf. Contribuinte: ' . $this->anfaveaDANFE($this->getTagValue($this->infAdic, "infCpl"))
328
                : '';
329
            $infPedido       = $this->geraInformacoesDaTagCompra();
330
            if ($infPedido != "") {
331
                $this->textoAdic .= $infPedido;
332
            }
333
            $this->textoAdic .= $this->getTagValue($this->dest, "email", ' Email do Destinatário: ');
334
            $this->textoAdic .= ! empty($this->getTagValue($this->infAdic, "infAdFisco"))
335
                ? "\n Inf. fisco: " . $this->getTagValue($this->infAdic, "infAdFisco")
336
                : '';
337
            $obsCont         = $this->infAdic->getElementsByTagName("obsCont");
338
            if (isset($obsCont)) {
339
                foreach ($obsCont as $obs) {
340
                    $campo           = $obsCont->item($i)->getAttribute("xCampo");
341
                    $xTexto          = ! empty($obsCont->item($i)->getElementsByTagName("xTexto")->item(0)->nodeValue)
342
                        ? $obsCont->item($i)->getElementsByTagName("xTexto")->item(0)->nodeValue
343
                        : '';
344
                    $this->textoAdic .= "\n" . $campo . ':  ' . trim($xTexto);
345
                    $i ++;
346
                }
347
            }
348
        }
349
        //INCLUSO pela NT 2013.003 Lei da Transparência
350
        //verificar se a informação sobre o valor aproximado dos tributos
351
        //já se encontra no campo de informações adicionais
352
        if ($this->exibirValorTributos) {
353
            $flagVTT  = strpos(strtolower(trim($this->textoAdic)), 'valor');
354
            $flagVTT  = $flagVTT || strpos(strtolower(trim($this->textoAdic)), 'vl');
355
            $flagVTT  = $flagVTT && strpos(strtolower(trim($this->textoAdic)), 'aprox');
356
            $flagVTT  = $flagVTT && (strpos(strtolower(trim($this->textoAdic)), 'trib') ||
357
                    strpos(strtolower(trim($this->textoAdic)), 'imp'));
358
            $vTotTrib = $this->getTagValue($this->ICMSTot, 'vTotTrib');
359
            if ($vTotTrib != '' && ! $flagVTT) {
360
                $this->textoAdic .= "\n Valor Aproximado dos Tributos : R$ "
361
                    . number_format($vTotTrib, 2, ",", ".");
362
            }
363
        }
364
        //fim da alteração NT 2013.003 Lei da Transparência
365
        $this->textoAdic        = str_replace(";", "\n", $this->textoAdic);
366
        $numlinhasdados         = $this->pdf->getNumLines($this->textoAdic, $this->wAdic, $fontProduto) + 1.5;
367
        $this->textadicfontsize = $this->pdf->fontSize;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->pdf->fontSize can also be of type double. However, the property $textadicfontsize is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
368
        $hdadosadic             = ceil($numlinhasdados * ($this->textadicfontsize));
369
        if ($hdadosadic > 70) {
370
            for ($f = 8; $f > 3; $f --) {
371
                $this->pdf->setFont($this->fontePadrao, '', $f);
372
                $fontProduto            = [
373
                    'font'  => $this->fontePadrao,
374
                    'size'  => $f,
375
                    'style' => ''
376
                ];
377
                $numlinhasdados         = $this->pdf->getNumLines($this->textoAdic, $this->wAdic, $fontProduto) + 3;
378
                $this->textadicfontsize = $this->pdf->fontSize;
379
                $hdadosadic             = ceil($numlinhasdados * $this->textadicfontsize);
380
                echo $hdadosadic;
381
                if ($hdadosadic <= 90) {
382
                    $hdadosadic = ceil($hdadosadic);
383
                    break;
384
                }
385
            }
386
        }
387
        if ($hdadosadic < 10) {
388
            $hdadosadic = 10;
389
        }
390
391
        return $hdadosadic;
392
    }
393
394
    protected function calculoItensPorPagina()
395
    {
396
    }
397
398
    /**
399
     * monta
400
     * Monta a DANFE conforme as informações fornecidas para a classe durante sua
401
     * construção. Constroi DANFEs com até 3 páginas podendo conter até 56 itens.
402
     * A definição de margens e posições iniciais para a impressão são estabelecidas
403
     * pelo conteúdo da funçao e podem ser modificados.
404
     *
405
     * @return string O ID da NFe numero de 44 digitos extraido do arquivo XML
406
     */
407
    protected function monta(
408
        $logo = ''
409
    ) {
410
        $this->pdf       = '';
0 ignored issues
show
Documentation Bug introduced by
It seems like '' of type string is incompatible with the declared type object<NFePHP\DA\Legacy\Pdf> of property $pdf.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
411
        $this->logomarca = $this->adjustImage($logo);
412
        //se a orientação estiver em branco utilizar o padrão estabelecido na NF
413
        if (empty($this->orientacao)) {
414
            if ($this->tpImp == '2') {
415
                $this->orientacao = 'L';
416
            } else {
417
                $this->orientacao = 'P';
418
            }
419
        }
420
        //instancia a classe pdf
421
        $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
0 ignored issues
show
Bug introduced by
It seems like $this->papel can also be of type array; however, NFePHP\DA\Legacy\Pdf::__construct() does only seem to accept string, maybe add an additional type check?

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

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

    return array();
}

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

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

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

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

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

$answer = 42;

$correct = false;

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

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

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

$answer = 42;

$correct = false;

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

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

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

$answer = 42;

$correct = false;

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

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

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

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
436
                $xInic      = $this->margesq + 10;
437
                //se paisagem multiplica a largura do canhoto pela quantidade de canhotos
438
                //$this->wCanhoto *= $this->qCanhoto;
439
            }
440
        }
441
        //total inicial de paginas
442
        $totPag = 1;
0 ignored issues
show
Unused Code introduced by
$totPag is not used, you could remove the assignment.

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

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

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

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

Loading history...
443
        //largura imprimivel em mm: largura da folha menos as margens esq/direita
444
        $this->wPrint = $this->maxW - ($this->margesq * 2);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->maxW - $this->margesq * 2 can also be of type integer. However, the property $wPrint is declared as type double. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
445
        //comprimento (altura) imprimivel em mm: altura da folha menos as margens
446
        //superior e inferior
447
        $this->hPrint = $this->maxH - $this->margsup - $this->marginf;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->maxH - $this->margsup - $this->marginf can also be of type integer. However, the property $hPrint is declared as type double. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
448
        // estabelece contagem de paginas
449
        $this->pdf->aliasNbPages();
450
        // fixa as margens
451
        $this->pdf->setMargins($this->margesq, $this->margsup);
452
        $this->pdf->setDrawColor(0, 0, 0);
453
        $this->pdf->setFillColor(255, 255, 255);
454
        // inicia o documento
455
        $this->pdf->open();
456
        // adiciona a primeira página
457
        $this->pdf->addPage($this->orientacao, $this->papel);
0 ignored issues
show
Bug introduced by
It seems like $this->papel can also be of type array; however, NFePHP\DA\Legacy\FPDF\Fpdf::addPage() does only seem to accept string, maybe add an additional type check?

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

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

    return array();
}

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

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

Loading history...
458
        $this->pdf->setLineWidth(0.1);
459
        $this->pdf->settextcolor(0, 0, 0);
460
461
        //##################################################################
462
        // CALCULO DO NUMERO DE PAGINAS A SEREM IMPRESSAS
463
        //##################################################################
464
        //Verificando quantas linhas serão usadas para impressão das duplicatas
465
        $linhasDup = 0;
466
        $qtdPag    = 0;
467
        if (isset($this->dup) && $this->dup->length > 0) {
468
            $qtdPag = $this->dup->length;
0 ignored issues
show
Bug introduced by
The property length does not seem to exist in DOMNode.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
469
        } elseif (isset($this->detPag) && $this->detPag->length > 0) {
0 ignored issues
show
Bug introduced by
The property detPag does not exist. Did you maybe forget to declare it?

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
470
            $qtdPag = $this->detPag->length;
471
        }
472
        if (($qtdPag > 0) && ($qtdPag <= 7)) {
473
            $linhasDup = 1;
474
        } elseif (($qtdPag > 7) && ($qtdPag <= 14)) {
475
            $linhasDup = 2;
476
        } elseif (($qtdPag > 14) && ($qtdPag <= 21)) {
477
            $linhasDup = 3;
478
        } elseif ($qtdPag > 21) {
479
            // chinnonsantos 11/05/2016: Limite máximo de impressão de duplicatas na NFe,
480
            // só vai ser exibito as 21 primeiras duplicatas (parcelas de pagamento),
481
            // se não oculpa espaço d+, cada linha comporta até 7 duplicatas.
482
            $linhasDup = 3;
483
        }
484
        //verifica se será impressa a linha dos serviços ISSQN
485
        $linhaISSQN = 0;
486
        if ((isset($this->ISSQNtot)) && ($this->getTagValue($this->ISSQNtot, 'vServ') > 0)) {
487
            $linhaISSQN = 1;
488
        }
489
        //calcular a altura necessária para os dados adicionais
490
        if ($this->orientacao == 'P') {
491
            $this->wAdic = round($this->wPrint * 0.66, 0);
492
        } else {
493
            $this->wAdic = round(($this->wPrint - $this->wCanhoto) * 0.5, 0);
494
        }
495
        $fontProduto = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
0 ignored issues
show
Unused Code introduced by
$fontProduto is not used, you could remove the assignment.

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

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

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

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

Loading history...
496
497
        $this->hdadosadic = $this->calculoEspacoVericalDadosAdicionais();
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->calculoEspacoVericalDadosAdicionais() can also be of type double. However, the property $hdadosadic is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
498
499
        //altura disponivel para os campos da DANFE
500
        $hcabecalho    = 47;//para cabeçalho
501
        $hdestinatario = 25;//para destinatario
502
        $hduplicatas   = 12;//para cada grupo de 7 duplicatas
503
        if (isset($this->entrega)) {
504
            $hlocalentrega = 25;
505
        } else {
506
            $hlocalentrega = 0;
507
        }
508
        if (isset($this->retirada)) {
509
            $hlocalretirada = 25;
510
        } else {
511
            $hlocalretirada = 0;
512
        }
513
        $himposto    = 18;// para imposto
514
        $htransporte = 25;// para transporte
515
        $hissqn      = 11;// para issqn
516
        $hfooter     = 5;// para rodape
517
        $hCabecItens = 4;//cabeçalho dos itens
518
        $hOCUPADA    = $hcabecalho
519
            + $hdestinatario
520
            + $hlocalentrega
521
            + $hlocalretirada
522
            + ($linhasDup * $hduplicatas)
523
            + $himposto + $htransporte
524
            + ($linhaISSQN * $hissqn)
525
            + $this->hdadosadic
526
            + $hfooter
527
            + $hCabecItens
528
            + $this->sizeExtraTextoFatura();
529
530
        //alturas disponiveis para os dados
531
        $hDispo1 = $this->hPrint - $hOCUPADA;
532
        /*($hcabecalho +
533
        //$hdestinatario + ($linhasDup * $hduplicatas) + $himposto + $htransporte +
534
        $hdestinatario + $hlocalentrega + $hlocalretirada +
535
        ($linhasDup * $hduplicatas) + $himposto + $htransporte +
536
        ($linhaISSQN * $hissqn) + $this->hdadosadic + $hfooter + $hCabecItens +
537
        $this->sizeExtraTextoFatura());*/
538
539
        if ($this->orientacao == 'P') {
540
            $hDispo1 -= 24 * $this->qCanhoto;//para canhoto
541
            $w       = $this->wPrint;
542
        } else {
543
            $hcanhoto = $this->hPrint;//para canhoto
0 ignored issues
show
Unused Code introduced by
$hcanhoto is not used, you could remove the assignment.

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

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

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

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

Loading history...
544
            $w        = $this->wPrint - $this->wCanhoto;
545
        }
546
        //$hDispo1 += 14;
547
        $hDispo2 = $this->hPrint - ($hcabecalho + $hfooter + $hCabecItens);
548
        //Contagem da altura ocupada para impressão dos itens
549
        $aFont     = ['font' => $this->fontePadrao, 'size' => 7, 'style' => ''];
0 ignored issues
show
Unused Code introduced by
$aFont is not used, you could remove the assignment.

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

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

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

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

Loading history...
550
        $numlinhas = 0;
0 ignored issues
show
Unused Code introduced by
$numlinhas is not used, you could remove the assignment.

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

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

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

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

Loading history...
551
        $hUsado    = $hCabecItens;
552
        $w2        = round($w * 0.25, 0);
0 ignored issues
show
Unused Code introduced by
$w2 is not used, you could remove the assignment.

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

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

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

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

Loading history...
553
        $hDispo    = $hDispo1;
554
        $totPag    = 1;
555
        $i         = 0;
556
        while ($i < $this->det->length) {
557
            $itemProd = $this->det->item($i);
558
            $texto = $this->descricaoProduto($itemProd);
0 ignored issues
show
Unused Code introduced by
$texto is not used, you could remove the assignment.

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

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

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

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

Loading history...
559
            $mostrarUnidadeTributavel = false;
560
561
            $prod = $itemProd->getElementsByTagName('prod')->item(0);
562
            $uCom = $prod->getElementsByTagName("uCom")->item(0)->nodeValue;
563
            $uTrib = $prod->getElementsByTagName("uTrib")->item(0);
564
            if (! empty($uTrib) && strcmp($uCom, $uTrib->nodeValue) != 0) {
565
                $mostrarUnidadeTributavel = true;
566
            }
567
568
            $hUsado += $this->calculeHeight($itemProd, $mostrarUnidadeTributavel);
569
            if ($hUsado > $hDispo) {
570
                $totPag ++;
571
                $hDispo = $hDispo2;
572
                $hUsado = $hCabecItens;
573
                $i --; // decrementa para readicionar o item que não coube nessa pagina na outra.
574
            }
575
            $i ++;
576
        } //fim da soma das areas de itens usadas
577
        $qtdeItens = $i; //controle da quantidade de itens no DANFE
578
        //montagem da primeira página
579
        $pag = 1;
580
581
        $x = $this->margesq;
582
        $y = $this->margsup;
583
        //coloca o(s) canhoto(s) da NFe
584
        if ($this->orientacao == 'P') {
585
            $y = $this->canhoto($this->margesq, $this->margsup);
586
        } else {
587
            $this->canhoto($this->margesq, $this->margsup);
588
            $x = 25;
589
        }
590
        //coloca o cabeçalho
591
        $y = $this->header($x, $y, $pag, $totPag);
592
        //coloca os dados do destinatário
593
        $y = $this->destinatarioDANFE($x, $y + 1);
594
        //coloca os dados do local de retirada
595
        if (isset($this->retirada)) {
596
            $y = $this->localRetiradaDANFE($x, $y + 1);
597
        }
598
        //coloca os dados do local de entrega
599
        if (isset($this->entrega)) {
600
            $y = $this->localEntregaDANFE($x, $y + 1);
601
        }
602
603
        //Verifica as formas de pagamento da nota fiscal
604
        $formaPag = [];
605
        if (isset($this->detPag) && $this->detPag->length > 0) {
606
            foreach ($this->detPag as $k => $d) {
607
                $fPag            = ! empty($this->detPag->item($k)->getElementsByTagName('tPag')->item(0)->nodeValue)
608
                    ? $this->detPag->item($k)->getElementsByTagName('tPag')->item(0)->nodeValue
609
                    : '0';
610
                $formaPag[$fPag] = $fPag;
611
            }
612
        }
613
        //caso tenha boleto imprimir fatura
614
        if ($this->dup->length > 0) {
615
            $y = $this->fatura($x, $y + 1);
616
        } else {
617
            //Se somente tiver a forma de pagamento sem pagamento não imprimir nada
618
            if (count($formaPag) == '1' && isset($formaPag[90])) {
619
                $y = $y;
0 ignored issues
show
Bug introduced by
Why assign $y to itself?

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

This assignement can be removed without consequences.

Loading history...
620
            } else {
621
                //caso tenha mais de uma forma de pagamento ou seja diferente de boleto exibe a
622
                //forma de pagamento e o valor
623
                $y = $this->pagamento($x, $y + 1);
624
            }
625
        }
626
        //coloca os dados dos impostos e totais da NFe
627
        $y = $this->imposto($x, $y + 1);
628
        //coloca os dados do trasnporte
629
        $y = $this->transporte($x, $y + 1);
630
        //itens da DANFE
631
        $nInicial = 0;
632
633
        $y = $this->itens($x, $y + 1, $nInicial, $hDispo1, $pag, $totPag, $hCabecItens);
634
635
        //coloca os dados do ISSQN
636
        if ($linhaISSQN == 1) {
637
            $y = $this->issqn($x, $y + 4);
638
        } else {
639
            $y += 4;
640
        }
641
        //coloca os dados adicionais da NFe
642
        $y = $this->dadosAdicionais($x, $y, $this->hdadosadic);
0 ignored issues
show
Unused Code introduced by
$y is not used, you could remove the assignment.

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

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

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

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

Loading history...
643
        //coloca o rodapé da página
644
        if ($this->orientacao == 'P') {
645
            $this->rodape($xInic);
646
        } else {
647
            $this->rodape($xInic);
648
        }
649
650
        //loop para páginas seguintes
651
        for ($n = 2; $n <= $totPag; $n ++) {
652
            // fixa as margens
653
            $this->pdf->setMargins($this->margesq, $this->margsup);
654
            //adiciona nova página
655
            $this->pdf->addPage($this->orientacao, $this->papel);
0 ignored issues
show
Bug introduced by
It seems like $this->papel can also be of type array; however, NFePHP\DA\Legacy\FPDF\Fpdf::addPage() does only seem to accept string, maybe add an additional type check?

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

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

    return array();
}

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

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

Loading history...
656
            //ajusta espessura das linhas
657
            $this->pdf->setLineWidth(0.1);
658
            //seta a cor do texto para petro
659
            $this->pdf->settextcolor(0, 0, 0);
660
            // posição inicial do relatorio
661
            $x = $this->margesq;
662
            $y = $this->margsup;
663
            //coloca o cabeçalho na página adicional
664
            $y = $this->header($x, $y, $n, $totPag);
665
            //coloca os itens na página adicional
666
            $y = $this->itens($x, $y + 1, $nInicial, $hDispo2, $n, $totPag, $hCabecItens);
0 ignored issues
show
Unused Code introduced by
$y is not used, you could remove the assignment.

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

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

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

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

Loading history...
667
            //coloca o rodapé da página
668
            if ($this->orientacao == 'P') {
669
                $this->rodape($this->margesq);
670
            } else {
671
                $this->rodape($this->margesq);
672
            }
673
            //se estiver na última página e ainda restar itens para inserir, adiciona mais uma página
674
            if ($n == $totPag && $this->qtdeItensProc < $qtdeItens) {
675
                $totPag ++;
676
            }
677
        }
678
    }
679
680
    /**
681
     * anfavea
682
     * Função para transformar o campo cdata do padrão ANFAVEA para
683
     * texto imprimível
684
     *
685
     * @param string $cdata campo CDATA
686
     *
687
     * @return string conteúdo do campo CDATA como string
688
     */
689
    protected function anfaveaDANFE($cdata = '')
690
    {
691
        if ($cdata == '') {
692
            return '';
693
        }
694
        //remove qualquer texto antes ou depois da tag CDATA
695
        $cdata    = str_replace('<![CDATA[', '<CDATA>', $cdata);
696
        $cdata    = str_replace(']]>', '</CDATA>', $cdata);
697
        $cdata    = preg_replace('/\s\s+/', ' ', $cdata);
698
        $cdata    = str_replace("> <", "><", $cdata);
699
        $len      = strlen($cdata);
700
        $startPos = strpos($cdata, '<');
701
        if ($startPos === false) {
702
            return $cdata;
703
        }
704
        for ($x = $len; $x > 0; $x --) {
705
            if (substr($cdata, $x, 1) == '>') {
706
                $endPos = $x;
707
                break;
708
            }
709
        }
710
        if ($x === 0) {
711
            return $cdata;
712
        }
713
        if ($startPos > 0) {
714
            $parte1 = substr($cdata, 0, $startPos);
715
        } else {
716
            $parte1 = '';
717
        }
718
        $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...
719
        if ($endPos < $len) {
720
            $parte3 = substr($cdata, $endPos + 1, $len - $endPos - 1);
721
        } else {
722
            $parte3 = '';
723
        }
724
        $texto = trim($parte1) . ' ' . trim($parte3);
725
        if (strpos($parte2, '<CDATA>') === false) {
726
            $cdata = '<CDATA>' . $parte2 . '</CDATA>';
727
        } else {
728
            $cdata = $parte2;
729
        }
730
        //Retira a tag <FONTE IBPT> (caso existir) pois não é uma estrutura válida XML
731
        $cdata = str_replace('<FONTE IBPT>', '', $cdata);
732
        //carrega o xml CDATA em um objeto DOM
733
        $dom = new Dom();
734
        $dom->loadXML($cdata, LIBXML_NOBLANKS | LIBXML_NOEMPTYTAG);
735
        //$xml = $dom->saveXML();
736
        //grupo CDATA infADprod
737
        $id   = $dom->getElementsByTagName('id')->item(0);
738
        $div  = $dom->getElementsByTagName('div')->item(0);
739
        $entg = $dom->getElementsByTagName('entg')->item(0);
740
        $dest = $dom->getElementsByTagName('dest')->item(0);
741
        $ctl  = $dom->getElementsByTagName('ctl')->item(0);
742
        $ref  = $dom->getElementsByTagName('ref')->item(0);
743
        if (isset($id)) {
744
            if ($id->hasAttributes()) {
745
                foreach ($id->attributes as $attr) {
746
                    $name  = $attr->nodeName;
747
                    $value = $attr->nodeValue;
748
                    $texto .= " $name : $value";
749
                }
750
            }
751
        }
752
        if (isset($div)) {
753
            if ($div->hasAttributes()) {
754
                foreach ($div->attributes as $attr) {
755
                    $name  = $attr->nodeName;
756
                    $value = $attr->nodeValue;
757
                    $texto .= " $name : $value";
758
                }
759
            }
760
        }
761
        if (isset($entg)) {
762
            if ($entg->hasAttributes()) {
763
                foreach ($entg->attributes as $attr) {
764
                    $name  = $attr->nodeName;
765
                    $value = $attr->nodeValue;
766
                    $texto .= " $name : $value";
767
                }
768
            }
769
        }
770
        if (isset($dest)) {
771
            if ($dest->hasAttributes()) {
772
                foreach ($dest->attributes as $attr) {
773
                    $name  = $attr->nodeName;
774
                    $value = $attr->nodeValue;
775
                    $texto .= " $name : $value";
776
                }
777
            }
778
        }
779
        if (isset($ctl)) {
780
            if ($ctl->hasAttributes()) {
781
                foreach ($ctl->attributes as $attr) {
782
                    $name  = $attr->nodeName;
783
                    $value = $attr->nodeValue;
784
                    $texto .= " $name : $value";
785
                }
786
            }
787
        }
788
        if (isset($ref)) {
789
            if ($ref->hasAttributes()) {
790
                foreach ($ref->attributes as $attr) {
791
                    $name  = $attr->nodeName;
792
                    $value = $attr->nodeValue;
793
                    $texto .= " $name : $value";
794
                }
795
            }
796
        }
797
        //grupo CADATA infCpl
798
        $t          = $dom->getElementsByTagName('transmissor')->item(0);
799
        $r          = $dom->getElementsByTagName('receptor')->item(0);
800
        $versao     = ! empty($dom->getElementsByTagName('versao')->item(0)->nodeValue) ?
801
            'Versao:' . $dom->getElementsByTagName('versao')->item(0)->nodeValue . ' ' : '';
802
        $especieNF  = ! empty($dom->getElementsByTagName('especieNF')->item(0)->nodeValue) ?
803
            'Especie:' . $dom->getElementsByTagName('especieNF')->item(0)->nodeValue . ' ' : '';
804
        $fabEntrega = ! empty($dom->getElementsByTagName('fabEntrega')->item(0)->nodeValue) ?
805
            'Entrega:' . $dom->getElementsByTagName('fabEntrega')->item(0)->nodeValue . ' ' : '';
806
        $dca        = ! empty($dom->getElementsByTagName('dca')->item(0)->nodeValue) ?
807
            'dca:' . $dom->getElementsByTagName('dca')->item(0)->nodeValue . ' ' : '';
808
        $texto      .= "" . $versao . $especieNF . $fabEntrega . $dca;
809
        if (isset($t)) {
810
            if ($t->hasAttributes()) {
811
                $texto .= " Transmissor ";
812
                foreach ($t->attributes as $attr) {
813
                    $name  = $attr->nodeName;
814
                    $value = $attr->nodeValue;
815
                    $texto .= " $name : $value";
816
                }
817
            }
818
        }
819
        if (isset($r)) {
820
            if ($r->hasAttributes()) {
821
                $texto .= " Receptor ";
822
                foreach ($r->attributes as $attr) {
823
                    $name  = $attr->nodeName;
824
                    $value = $attr->nodeValue;
825
                    $texto .= " $name : $value";
826
                }
827
            }
828
        }
829
830
        return $texto;
831
    }
832
833
    /**
834
     * Verifica o status da NFe
835
     *
836
     * @return array
837
     */
838
    protected function statusNFe()
839
    {
840
        $resp = [
841
            'status' => true,
842
            'message' => [],
843
            'submessage' => ''
844
        ];
845
        if (!isset($this->nfeProc)) {
846
            $resp['status'] = false;
847
            $resp['message'][] = 'NFe NÃO PROTOCOLADA';
848
        } elseif ($this->getTagValue($this->ide, "tpAmb") == '2') {
849
            $resp['status'] = false;
850
            $resp['message'][] =  "NFe EMITIDA EM HOMOLOGAÇÃO";
851
        }
852
        $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...
853
        $cStat = $this->getTagValue($this->nfeProc, "cStat");
854
        if ($cStat == '110' ||
855
            $cStat == '301' ||
856
            $cStat == '302'
857
        ) {
858
            $resp['status'] = false;
859
            $resp['message'][] = "NFe DENEGADA";
860
        } elseif ($cStat == '101'
861
            || $cStat == '151'
862
            || $cStat == '135'
863
            || $cStat == '155'
864
            || $this->cancelFlag === true
865
        ) {
866
            $resp['status'] = false;
867
            $resp['message'][] = "NFe CANCELADA";
868
        } elseif (!empty($retEvento)) {
869
            $infEvento = $retEvento->getElementsByTagName('infEvento')->item(0);
870
            $cStat = $this->getTagValue($infEvento, "cStat");
871
            $tpEvento= $this->getTagValue($infEvento, "tpEvento");
872
            $dhEvento = date("d/m/Y H:i:s", $this->toTimestamp($this->getTagValue($infEvento, "dhRegEvento")));
873
            $nProt = $this->getTagValue($infEvento, "nProt");
874
            if ($tpEvento == '110111' && ($cStat == '101' || $cStat == '151' || $cStat == '135' || $cStat == '155')) {
875
                $resp['status'] = false;
876
                $resp['message'][] = "NFe CANCELADA";
877
                $resp['submessage'] = "{$dhEvento} - {$nProt}";
878
            }
879
        }
880
        return $resp;
881
    }
882
883
    protected function notaDPEC()
884
    {
885
        return ! empty($this->numdepec);
886
    }
887
888
    /**
889
     *header
890
     * Monta o cabelhalho da DANFE (retrato e paisagem)
891
     *
892
     * @param number $x      Posição horizontal inicial, canto esquerdo
893
     * @param number $y      Posição vertical inicial, canto superior
894
     * @param number $pag    Número da Página
895
     * @param number $totPag Total de páginas
896
     *
897
     * @return number Posição vertical final
898
     */
899
    protected function header($x = 0, $y = 0, $pag = '1', $totPag = '1')
900
    {
901
        $oldX = $x;
902
        $oldY = $y;
903
        if ($this->orientacao == 'P') {
904
            $maxW = $this->wPrint;
905
        } else {
906
            if ($pag == 1) { // primeira página
907
                $maxW = $this->wPrint - $this->wCanhoto;
908
            } else { // páginas seguintes
909
                $maxW = $this->wPrint;
910
            }
911
        }
912
        //####################################################################################
913
        //coluna esquerda identificação do emitente
914
        $w = round($maxW * 0.41, 0);
915
        if ($this->orientacao == 'P') {
916
            $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => 'I'];
917
        } else {
918
            $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'];
919
        }
920
        $w1   = $w;
921
        $h    = 32;
922
        $oldY += $h;
923
        $this->pdf->textBox($x, $y, $w, $h);
924
        $texto = 'IDENTIFICAÇÃO DO EMITENTE';
925
        $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...
926
        //estabelecer o alinhamento
927
        //pode ser left L, center C, right R, full logo L
928
        //se for left separar 1/3 da largura para o tamanho da imagem
929
        //os outros 2/3 serão usados para os dados do emitente
930
        //se for center separar 1/2 da altura para o logo e 1/2 para os dados
931
        //se for right separa 2/3 para os dados e o terço seguinte para o logo
932
        //se não houver logo centraliza dos dados do emitente
933
        // coloca o logo
934
        if (! empty($this->logomarca)) {
935
            $logoInfo = getimagesize($this->logomarca);
936
            //largura da imagem em mm
937
            $logoWmm = ($logoInfo[0] / 72) * 25.4;
938
            //altura da imagem em mm
939
            $logoHmm = ($logoInfo[1] / 72) * 25.4;
940
            if ($this->logoAlign == 'L') {
941
                $nImgW = round($w / 3, 0);
942
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
943
                $xImg  = $x + 1;
944
                $yImg  = round(($h - $nImgH) / 2, 0) + $y;
945
                //estabelecer posições do texto
946
                $x1 = round($xImg + $nImgW + 1, 0);
947
                $y1 = round($h / 3 + $y, 0);
948
                $tw = round(2 * $w / 3, 0);
949
            } elseif ($this->logoAlign == 'C') {
950
                $nImgH = round($h / 3, 0);
951
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
952
                $xImg  = round(($w - $nImgW) / 2 + $x, 0);
953
                $yImg  = $y + 3;
954
                $x1    = $x;
955
                $y1    = round($yImg + $nImgH + 1, 0);
956
                $tw    = $w;
957
            } elseif ($this->logoAlign == 'R') {
958
                $nImgW = round($w / 3, 0);
959
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
960
                $xImg  = round($x + ($w - (1 + $nImgW)), 0);
961
                $yImg  = round(($h - $nImgH) / 2, 0) + $y;
962
                $x1    = $x;
963
                $y1    = round($h / 3 + $y, 0);
964
                $tw    = round(2 * $w / 3, 0);
965
            } elseif ($this->logoAlign == 'F') {
966
                $nImgH = round($h - 5, 0);
967
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
968
                $xImg  = round(($w - $nImgW) / 2 + $x, 0);
969
                $yImg  = $y + 3;
970
                $x1    = $x;
971
                $y1    = round($yImg + $nImgH + 1, 0);
972
                $tw    = $w;
973
            }
974
            $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...
975
            $this->pdf->Image($this->logomarca, $xImg, $yImg, $nImgW, $nImgH, 'jpeg');
0 ignored issues
show
Bug introduced by
The variable $xImg does not seem to be defined for all execution paths leading up to this point.

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

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

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

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

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

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

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
976
        } else {
977
            $x1 = $x;
978
            $y1 = round($h / 3 + $y, 0);
979
            $tw = $w;
980
        }
981
        // monta as informações apenas se diferente de full logo
982
        if ($this->logoAlign !== 'F') {
983
            //Nome emitente
984
            $aFont = ['font' => $this->fontePadrao, 'size' => 12, 'style' => 'B'];
985
            $texto = $this->emit->getElementsByTagName("xNome")->item(0)->nodeValue;
986
            $this->pdf->textBox($x1, $y1, $tw, 8, $texto, $aFont, 'T', 'C', 0, '');
0 ignored issues
show
Bug introduced by
The variable $x1 does not seem to be defined for all execution paths leading up to this point.

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

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

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

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

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

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

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
987
            //endereço
988
            $y1     = $y1 + 5;
989
            $aFont  = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
990
            $fone   = ! empty($this->enderEmit->getElementsByTagName("fone")->item(0)->nodeValue)
991
                ? $this->enderEmit->getElementsByTagName("fone")->item(0)->nodeValue
992
                : '';
993
            $lgr    = $this->getTagValue($this->enderEmit, "xLgr");
994
            $nro    = $this->getTagValue($this->enderEmit, "nro");
995
            $cpl    = $this->getTagValue($this->enderEmit, "xCpl", " - ");
996
            $bairro = $this->getTagValue($this->enderEmit, "xBairro");
997
            $CEP    = $this->getTagValue($this->enderEmit, "CEP");
998
            $CEP    = $this->formatField($CEP, "#####-###");
999
            $mun    = $this->getTagValue($this->enderEmit, "xMun");
1000
            $UF     = $this->getTagValue($this->enderEmit, "UF");
1001
            $texto  = $lgr . ", " . $nro . $cpl . "\n" . $bairro . " - "
1002
                . $CEP . "\n" . $mun . " - " . $UF . " "
1003
                . "Fone/Fax: " . $fone;
1004
            $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...
1005
        }
1006
1007
        //####################################################################################
1008
        //coluna central Danfe
1009
        $x  += $w;
1010
        $w  = round($maxW * 0.17, 0);//35;
1011
        $w2 = $w;
1012
        $h  = 32;
1013
        $this->pdf->textBox($x, $y, $w, $h);
1014
1015
        $texto = "DANFE";
1016
        $aFont = ['font' => $this->fontePadrao, 'size' => 14, 'style' => 'B'];
1017
        $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...
1018
        $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
1019
        $texto = 'Documento Auxiliar da Nota Fiscal Eletrônica';
1020
        $h     = 20;
1021
        $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...
1022
1023
        $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
1024
        $texto = '0 - ENTRADA';
1025
        $y1    = $y + 14;
1026
        $h     = 8;
1027
        $this->pdf->textBox($x + 2, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1028
        $texto = '1 - SAÍDA';
1029
        $y1    = $y + 17;
1030
        $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...
1031
        //tipo de nF
1032
        $aFont = ['font' => $this->fontePadrao, 'size' => 12, 'style' => 'B'];
1033
        $y1    = $y + 13;
1034
        $h     = 7;
1035
        $texto = $this->ide->getElementsByTagName('tpNF')->item(0)->nodeValue;
1036
        $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...
1037
        //numero da NF
1038
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1039
        $y1    = $y + 20;
1040
        $numNF = str_pad(
1041
            $this->ide->getElementsByTagName('nNF')->item(0)->nodeValue,
1042
            9,
1043
            "0",
1044
            STR_PAD_LEFT
1045
        );
1046
        $numNF = $this->formatField($numNF, "###.###.###");
1047
        $texto = "Nº. " . $numNF;
1048
        $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...
1049
        //Série
1050
        $y1    = $y + 23;
1051
        $serie = str_pad(
1052
            $this->ide->getElementsByTagName('serie')->item(0)->nodeValue,
1053
            3,
1054
            "0",
1055
            STR_PAD_LEFT
1056
        );
1057
        $texto = "Série " . $serie;
1058
        $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...
1059
        //numero paginas
1060
        $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'I'];
1061
        $y1    = $y + 26;
1062
        $texto = "Folha " . $pag . "/" . $totPag;
1063
        $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...
1064
1065
        //####################################################################################
1066
        //coluna codigo de barras
1067
        $x  += $w;
1068
        $w  = ($maxW - $w1 - $w2);//85;
1069
        $w3 = $w;
1070
        $h  = 32;
1071
        $this->pdf->textBox($x, $y, $w, $h);
1072
        $this->pdf->setFillColor(0, 0, 0);
1073
        $chave_acesso = str_replace('NFe', '', $this->infNFe->getAttribute("Id"));
1074
        $bW           = 75;
1075
        $bH           = 12;
1076
        //codigo de barras
1077
        $this->pdf->code128($x + (($w - $bW) / 2), $y + 2, $chave_acesso, $bW, $bH);
1078
        //linhas divisorias
1079
        $this->pdf->line($x, $y + 4 + $bH, $x + $w, $y + 4 + $bH);
1080
        $this->pdf->line($x, $y + 12 + $bH, $x + $w, $y + 12 + $bH);
1081
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1082
        $y1    = $y + 4 + $bH;
1083
        $h     = 7;
1084
        $texto = 'CHAVE DE ACESSO';
1085
        $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...
1086
        $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'];
1087
        $y1    = $y + 8 + $bH;
1088
        $texto = $this->formatField($chave_acesso, $this->formatoChave);
1089
        $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...
1090
        $y1                = $y + 12 + $bH;
1091
        $aFont             = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
1092
        $chaveContingencia = "";
1093
        if ($this->notaDpec()) {
1094
            $cabecalhoProtoAutorizacao = 'NÚMERO DE REGISTRO DPEC';
1095
        } else {
1096
            $cabecalhoProtoAutorizacao = 'PROTOCOLO DE AUTORIZAÇÃO DE USO';
1097
        }
1098
        if (($this->tpEmis == 2 || $this->tpEmis == 5) && ! $this->notaDpec()) {
1099
            $cabecalhoProtoAutorizacao = "DADOS DA NF-E";
1100
            $chaveContingencia         = $this->geraChaveAdicionalDeContingencia();
1101
            $this->pdf->setFillColor(0, 0, 0);
1102
            //codigo de barras
1103
            $this->pdf->code128($x + 11, $y1 + 1, $chaveContingencia, $bW * .9, $bH / 2);
1104
        } else {
1105
            $texto = 'Consulta de autenticidade no portal nacional da NF-e';
1106
            $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...
1107
            $y1    = $y + 16 + $bH;
1108
            $texto = 'www.nfe.fazenda.gov.br/portal ou no site da Sefaz Autorizadora';
1109
            $this->pdf->textBox(
1110
                $x + 2,
1111
                $y1,
1112
                $w - 2,
1113
                $h,
1114
                $texto,
1115
                $aFont,
1116
                'T',
1117
                'C',
1118
                0,
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

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

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1230
1231
        //####################################################################################
1232
        //Indicação de NF Homologação, cancelamento e falta de protocolo
1233
        $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...
1234
        //indicar cancelamento
1235
        $resp = $this->statusNFe();
1236
        if (!$resp['status']) {
1237
            $n = count($resp['message']);
1238
            $alttot = $n * 15;
1239
            $x = 10;
1240
            $y = $this->hPrint/2 - $alttot/2;
1241
            $h = 15;
1242
            $w = $maxW - (2 * $x);
1243
            $this->pdf->settextcolor(90, 90, 90);
1244
            
1245
            foreach ($resp['message'] as $msg) {
0 ignored issues
show
Bug introduced by
The expression $resp['message'] of type boolean|array|string is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

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

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

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

Loading history...
1246
                $aFont = ['font' => $this->fontePadrao, 'size' => 48, 'style' => 'B'];
1247
                $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...
1248
                $y += $h;
1249
            }
1250
            $texto = $resp['submessage'];
1251
            if (!empty($texto)) {
1252
                $y += 3;
1253
                $h = 5;
1254
                $aFont = ['font' => $this->fontePadrao, 'size' => 20, 'style' => 'B'];
1255
                $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...
1256
                $y += $h;
1257
            }
1258
            $y += 5;
1259
            $w = $maxW - (2 * $x);
1260
            $texto = "SEM VALOR FISCAL";
1261
            $aFont = ['font' => $this->fontePadrao, 'size' => 48, 'style' => 'B'];
1262
            $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...
1263
            $this->pdf->settextcolor(0, 0, 0);
1264
        }
1265
        if ($this->notaDpec() || $this->tpEmis == 4) {
1266
            //DPEC
1267
            $x = 10;
1268
            $y = $this->hPrint - 130;
1269
            $h = 25;
1270
            $w = $maxW - (2 * $x);
1271
            $this->pdf->SetTextColor(200, 200, 200);
1272
            $texto = "DANFE impresso em contingência -\n" .
1273
                "DPEC regularmente recebido pela Receita\n" .
1274
                "Federal do Brasil";
1275
            $aFont = ['font' => $this->fontePadrao, 'size' => 48, 'style' => 'B'];
1276
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1277
            $this->pdf->SetTextColor(0, 0, 0);
1278
        }
1279
1280
        return $oldY;
1281
    } //fim header
1282
1283
    /**
1284
     * destinatarioDANFE
1285
     * Monta o campo com os dados do destinatário na DANFE. (retrato e paisagem)
1286
     *
1287
     * @name   destinatarioDANFE
1288
     *
1289
     * @param number $x Posição horizontal canto esquerdo
1290
     * @param number $y Posição vertical canto superior
1291
     *
1292
     * @return number Posição vertical final
1293
     */
1294
    protected function destinatarioDANFE($x = 0, $y = 0)
1295
    {
1296
        //####################################################################################
1297
        //DESTINATÁRIO / REMETENTE
1298
        $oldX = $x;
1299
        $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...
1300
        if ($this->orientacao == 'P') {
1301
            $maxW = $this->wPrint;
1302
        } else {
1303
            $maxW = $this->wPrint - $this->wCanhoto;
1304
        }
1305
        $w     = $maxW;
1306
        $h     = 7;
1307
        $texto = 'DESTINATÁRIO / REMETENTE';
1308
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1309
        $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...
1310
        //NOME / RAZÃO SOCIAL
1311
        $w     = round($maxW * 0.61, 0);
1312
        $w1    = $w;
1313
        $y     += 3;
1314
        $texto = 'NOME / RAZÃO SOCIAL';
1315
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1316
        $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...
1317
        $texto = $this->dest->getElementsByTagName("xNome")->item(0)->nodeValue;
1318
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1319
        if ($this->orientacao == 'P') {
1320
            $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...
1321
        } else {
1322
            $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...
1323
        }
1324
        //CNPJ / CPF
1325
        $x     += $w;
1326
        $w     = round($maxW * 0.23, 0);
1327
        $w2    = $w;
1328
        $texto = 'CNPJ / CPF';
1329
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1330
        $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...
1331
        //Pegando valor do CPF/CNPJ
1332
        if (! empty($this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1333
            $texto = $this->formatField(
1334
                $this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1335
                "###.###.###/####-##"
1336
            );
1337
        } else {
1338
            $texto = ! empty($this->dest->getElementsByTagName("CPF")->item(0)->nodeValue)
1339
                ? $this->formatField(
1340
                    $this->dest->getElementsByTagName("CPF")->item(0)->nodeValue,
1341
                    "###.###.###-##"
1342
                )
1343
                : '';
1344
        }
1345
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1346
        $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...
1347
        //DATA DA EMISSÃO
1348
        $x     += $w;
1349
        $w     = $maxW - ($w1 + $w2);
1350
        $wx    = $w;
1351
        $texto = 'DATA DA EMISSÃO';
1352
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1353
        $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...
1354
        $dEmi = ! empty($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue)
1355
            ? $this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue
1356
            : '';
1357
        if ($dEmi == '') {
1358
            $dEmi  = ! empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue)
1359
                ? $this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue
1360
                : '';
1361
            $aDemi = explode('T', $dEmi);
1362
            $dEmi  = $aDemi[0];
1363
        }
1364
        $texto = $this->ymdTodmy($dEmi);
1365
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1366
        if ($this->orientacao == 'P') {
1367
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1368
        } else {
1369
            $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...
1370
        }
1371
        //ENDEREÇO
1372
        $w     = round($maxW * 0.47, 0);
1373
        $w1    = $w;
1374
        $y     += $h;
1375
        $x     = $oldX;
1376
        $texto = 'ENDEREÇO';
1377
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1378
        $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...
1379
        $texto = $this->dest->getElementsByTagName("xLgr")->item(0)->nodeValue;
1380
        $texto .= ', ' . $this->dest->getElementsByTagName("nro")->item(0)->nodeValue;
1381
        $texto .= $this->getTagValue($this->dest, "xCpl", " - ");
1382
1383
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1384
        $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...
1385
        //BAIRRO / DISTRITO
1386
        $x     += $w;
1387
        $w     = round($maxW * 0.21, 0);
1388
        $w2    = $w;
1389
        $texto = 'BAIRRO / DISTRITO';
1390
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1391
        $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...
1392
        $texto = $this->dest->getElementsByTagName("xBairro")->item(0)->nodeValue;
1393
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1394
        $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...
1395
        //CEP
1396
        $x     += $w;
1397
        $w     = $maxW - $w1 - $w2 - $wx;
1398
        $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...
1399
        $texto = 'CEP';
1400
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1401
        $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...
1402
        $texto = ! empty($this->dest->getElementsByTagName("CEP")->item(0)->nodeValue)
1403
            ? $this->dest->getElementsByTagName("CEP")->item(0)->nodeValue
1404
            : '';
1405
        $texto = $this->formatField($texto, "#####-###");
1406
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1407
        $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...
1408
        //DATA DA SAÍDA
1409
        $x     += $w;
1410
        $w     = $wx;
1411
        $texto = 'DATA DA SAÍDA/ENTRADA';
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
        $dSaiEnt = ! empty($this->ide->getElementsByTagName("dSaiEnt")->item(0)->nodeValue)
1415
            ? $this->ide->getElementsByTagName("dSaiEnt")->item(0)->nodeValue
1416
            : '';
1417
        if ($dSaiEnt == '') {
1418
            $dSaiEnt  = ! empty($this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue)
1419
                ? $this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue
1420
                : '';
1421
            $aDsaient = explode('T', $dSaiEnt);
1422
            $dSaiEnt  = $aDsaient[0];
1423
        }
1424
        $texto = $this->ymdTodmy($dSaiEnt);
1425
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1426
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

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

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1434
        $texto = $this->dest->getElementsByTagName("xMun")->item(0)->nodeValue;
1435
        if (strtoupper(trim($texto)) == "EXTERIOR"
1436
            && $this->dest->getElementsByTagName("xPais")->length > 0
1437
        ) {
1438
            $texto .= " - " . $this->dest->getElementsByTagName("xPais")->item(0)->nodeValue;
1439
        }
1440
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1441
        $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...
1442
        //UF
1443
        $x     += $w;
1444
        $w     = 8;
1445
        $texto = 'UF';
1446
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1447
        $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...
1448
        $texto = $this->dest->getElementsByTagName("UF")->item(0)->nodeValue;
1449
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1450
        $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...
1451
        //FONE / FAX
1452
        $x     += $w;
1453
        $w     = round(($maxW - $w1 - $wx - 8) / 2, 0);
1454
        $w3    = $w;
1455
        $texto = 'FONE / FAX';
1456
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1457
        $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...
1458
        $texto = ! empty($this->dest->getElementsByTagName("fone")->item(0)->nodeValue)
1459
            ? $this->dest->getElementsByTagName("fone")->item(0)->nodeValue
1460
            : '';
1461
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1462
        $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...
1463
        //INSCRIÇÃO ESTADUAL
1464
        $x     += $w;
1465
        $w     = $maxW - $w1 - $wx - 8 - $w3;
1466
        $texto = 'INSCRIÇÃO ESTADUAL';
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
        $IE    = $this->dest->getElementsByTagName("IE");
1470
        $texto = ($IE && $IE->length > 0) ? $IE->item(0)->nodeValue : '';
1471
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1472
        $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...
1473
        //HORA DA SAÍDA
1474
        $x     += $w;
1475
        $w     = $wx;
1476
        $texto = 'HORA DA SAÍDA/ENTRADA';
1477
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1478
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1479
        $hSaiEnt = ! empty($this->ide->getElementsByTagName("hSaiEnt")->item(0)->nodeValue)
1480
            ? $this->ide->getElementsByTagName("hSaiEnt")->item(0)->nodeValue
1481
            : '';
1482
        if ($hSaiEnt == '') {
1483
            $dhSaiEnt   = ! empty($this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue)
1484
                ? $this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue
1485
                : '';
1486
            $tsDhSaiEnt = $this->toTimestamp($dhSaiEnt);
1487
            if ($tsDhSaiEnt != '') {
1488
                $hSaiEnt = date('H:i:s', $tsDhSaiEnt);
1489
            }
1490
        }
1491
        $texto = $hSaiEnt;
1492
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1493
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1494
1495
        return ($y + $h);
1496
    } //fim da função destinatarioDANFE
1497
1498
    /**
1499
     * localEntregaDANFE
1500
     * Monta o campo com os dados do local de entrega na DANFE. (retrato e paisagem)
1501
     *
1502
     * @name   localEntregaDANFE
1503
     *
1504
     * @param number $x Posição horizontal canto esquerdo
1505
     * @param number $y Posição vertical canto superior
1506
     *
1507
     * @return number Posição vertical final
1508
     */
1509
    protected function localEntregaDANFE($x = 0, $y = 0)
1510
    {
1511
        //####################################################################################
1512
        //LOCAL DE ENTREGA
1513
        $oldX = $x;
1514
        if ($this->orientacao == 'P') {
1515
            $maxW = $this->wPrint;
1516
        } else {
1517
            $maxW = $this->wPrint - $this->wCanhoto;
1518
        }
1519
        $w     = $maxW;
1520
        $h     = 7;
1521
        $texto = 'INFORMAÇÕES DO LOCAL DE ENTREGA';
1522
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1523
        $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...
1524
        //NOME / RAZÃO SOCIAL
1525
        $w     = round($maxW * 0.61, 0);
1526
        $w1    = $w;
1527
        $y     += 3;
1528
        $texto = 'NOME / RAZÃO SOCIAL';
1529
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1530
        $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...
1531
        $texto = '';
1532
        if ($this->entrega->getElementsByTagName("xNome")->item(0)) {
1533
            $texto = $this->entrega->getElementsByTagName("xNome")->item(0)->nodeValue;
1534
        }
1535
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1536
        if ($this->orientacao == 'P') {
1537
            $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...
1538
        } else {
1539
            $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...
1540
        }
1541
        //CNPJ / CPF
1542
        $x     += $w;
1543
        $w     = round($maxW * 0.23, 0);
1544
        $w2    = $w;
1545
        $texto = 'CNPJ / CPF';
1546
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1547
        $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...
1548
        //Pegando valor do CPF/CNPJ
1549
        if (! empty($this->entrega->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1550
            $texto = $this->formatField(
1551
                $this->entrega->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1552
                "###.###.###/####-##"
1553
            );
1554
        } else {
1555
            $texto = ! empty($this->entrega->getElementsByTagName("CPF")->item(0)->nodeValue) ?
1556
                $this->formatField(
1557
                    $this->entrega->getElementsByTagName("CPF")->item(0)->nodeValue,
1558
                    "###.###.###-##"
1559
                ) : '';
1560
        }
1561
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1562
        $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...
1563
        //INSCRIÇÃO ESTADUAL
1564
        $x     += $w;
1565
        $w     = $maxW - ($w1 + $w2);
1566
        $wx    = $w;
1567
        $texto = 'INSCRIÇÃO ESTADUAL';
1568
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1569
        $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...
1570
        $texto = '';
1571
        if ($this->entrega->getElementsByTagName("IE")->item(0)) {
1572
            $texto = $this->entrega->getElementsByTagName("IE")->item(0)->nodeValue;
1573
        }
1574
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1575
        if ($this->orientacao == 'P') {
1576
            $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...
1577
        } else {
1578
            $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...
1579
        }
1580
        //ENDEREÇO
1581
        $w     = round($maxW * 0.355, 0) + $wx;
1582
        $w1    = $w;
1583
        $y     += $h;
1584
        $x     = $oldX;
1585
        $texto = 'ENDEREÇO';
1586
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1587
        $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...
1588
        $texto = $this->entrega->getElementsByTagName("xLgr")->item(0)->nodeValue;
1589
        $texto .= ', ' . $this->entrega->getElementsByTagName("nro")->item(0)->nodeValue;
1590
        $texto .= $this->getTagValue($this->entrega, "xCpl", " - ");
1591
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1592
        $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...
1593
        //BAIRRO / DISTRITO
1594
        $x     += $w;
1595
        $w     = round($maxW * 0.335, 0);
1596
        $w2    = $w;
1597
        $texto = 'BAIRRO / DISTRITO';
1598
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1599
        $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...
1600
        $texto = $this->entrega->getElementsByTagName("xBairro")->item(0)->nodeValue;
1601
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1602
        $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...
1603
        //CEP
1604
        $x     += $w;
1605
        $w     = $maxW - ($w1 + $w2);
1606
        $texto = 'CEP';
1607
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1608
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1609
        $texto = ! empty($this->entrega->getElementsByTagName("CEP")->item(0)->nodeValue) ?
1610
            $this->entrega->getElementsByTagName("CEP")->item(0)->nodeValue : '';
1611
        $texto = $this->formatField($texto, "#####-###");
1612
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1613
        $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...
1614
        //MUNICÍPIO
1615
        $w     = round($maxW * 0.805, 0);
1616
        $w1    = $w;
1617
        $y     += $h;
1618
        $x     = $oldX;
1619
        $texto = 'MUNICÍPIO';
1620
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1621
        $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...
1622
        $texto = $this->entrega->getElementsByTagName("xMun")->item(0)->nodeValue;
1623
        if (strtoupper(trim($texto)) == "EXTERIOR" && $this->entrega->getElementsByTagName("xPais")->length > 0) {
1624
            $texto .= " - " . $this->entrega->getElementsByTagName("xPais")->item(0)->nodeValue;
1625
        }
1626
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1627
        $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...
1628
        //UF
1629
        $x     += $w;
1630
        $w     = 8;
1631
        $texto = 'UF';
1632
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1633
        $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...
1634
        $texto = $this->entrega->getElementsByTagName("UF")->item(0)->nodeValue;
1635
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1636
        $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...
1637
        //FONE / FAX
1638
        $x     += $w;
1639
        $w     = $maxW - $w - $w1;
1640
        $texto = 'FONE / FAX';
1641
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1642
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1643
        $texto = ! empty($this->entrega->getElementsByTagName("fone")->item(0)->nodeValue) ?
1644
            $this->entrega->getElementsByTagName("fone")->item(0)->nodeValue : '';
1645
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1646
        $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...
1647
1648
        return ($y + $h);
1649
    } //fim da função localEntregaDANFE
1650
1651
    /**
1652
     * localretiradaDANFE
1653
     * Monta o campo com os dados do local de entrega na DANFE. (retrato e paisagem)
1654
     *
1655
     * @name   localretiradaDANFE
1656
     *
1657
     * @param number $x Posição horizontal canto esquerdo
1658
     * @param number $y Posição vertical canto superior
1659
     *
1660
     * @return number Posição vertical final
1661
     */
1662
    protected function localRetiradaDANFE($x = 0, $y = 0)
1663
    {
1664
        //####################################################################################
1665
        //LOCAL DE RETIRADA
1666
        $oldX = $x;
1667
        if ($this->orientacao == 'P') {
1668
            $maxW = $this->wPrint;
1669
        } else {
1670
            $maxW = $this->wPrint - $this->wCanhoto;
1671
        }
1672
        $w     = $maxW;
1673
        $h     = 7;
1674
        $texto = 'INFORMAÇÕES DO LOCAL DE RETIRADA';
1675
        $aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B'];
1676
        $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...
1677
        //NOME / RAZÃO SOCIAL
1678
        $w     = round($maxW * 0.61, 0);
1679
        $w1    = $w;
1680
        $y     += 3;
1681
        $texto = 'NOME / RAZÃO SOCIAL';
1682
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1683
        $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...
1684
        $texto = '';
1685
        if ($this->retirada->getElementsByTagName("xNome")->item(0)) {
1686
            $texto = $this->retirada->getElementsByTagName("xNome")->item(0)->nodeValue;
1687
        }
1688
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1689
        if ($this->orientacao == 'P') {
1690
            $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...
1691
        } else {
1692
            $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...
1693
        }
1694
        //CNPJ / CPF
1695
        $x     += $w;
1696
        $w     = round($maxW * 0.23, 0);
1697
        $w2    = $w;
1698
        $texto = 'CNPJ / CPF';
1699
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1700
        $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...
1701
        //Pegando valor do CPF/CNPJ
1702
        if (! empty($this->retirada->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1703
            $texto = $this->formatField(
1704
                $this->retirada->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1705
                "###.###.###/####-##"
1706
            );
1707
        } else {
1708
            $texto = ! empty($this->retirada->getElementsByTagName("CPF")->item(0)->nodeValue) ?
1709
                $this->formatField(
1710
                    $this->retirada->getElementsByTagName("CPF")->item(0)->nodeValue,
1711
                    "###.###.###-##"
1712
                ) : '';
1713
        }
1714
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1715
        $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...
1716
        //INSCRIÇÃO ESTADUAL
1717
        $x     += $w;
1718
        $w     = $maxW - ($w1 + $w2);
1719
        $wx    = $w;
1720
        $texto = 'INSCRIÇÃO ESTADUAL';
1721
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1722
        $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...
1723
        $texto = '';
1724
        if ($this->retirada->getElementsByTagName("IE")->item(0)) {
1725
            $texto = $this->retirada->getElementsByTagName("IE")->item(0)->nodeValue;
1726
        }
1727
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1728
        if ($this->orientacao == 'P') {
1729
            $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...
1730
        } else {
1731
            $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...
1732
        }
1733
        //ENDEREÇO
1734
        $w     = round($maxW * 0.355, 0) + $wx;
1735
        $w1    = $w;
1736
        $y     += $h;
1737
        $x     = $oldX;
1738
        $texto = 'ENDEREÇO';
1739
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1740
        $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...
1741
        $texto = $this->retirada->getElementsByTagName("xLgr")->item(0)->nodeValue;
1742
        $texto .= ', ' . $this->retirada->getElementsByTagName("nro")->item(0)->nodeValue;
1743
        $texto .= $this->getTagValue($this->retirada, "xCpl", " - ");
1744
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1745
        $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...
1746
        //BAIRRO / DISTRITO
1747
        $x     += $w;
1748
        $w     = round($maxW * 0.335, 0);
1749
        $w2    = $w;
1750
        $texto = 'BAIRRO / DISTRITO';
1751
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1752
        $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...
1753
        $texto = $this->retirada->getElementsByTagName("xBairro")->item(0)->nodeValue;
1754
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1755
        $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...
1756
        //CEP
1757
        $x     += $w;
1758
        $w     = $maxW - ($w1 + $w2);
1759
        $texto = 'CEP';
1760
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1761
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1762
        $texto = ! empty($this->retirada->getElementsByTagName("CEP")->item(0)->nodeValue) ?
1763
            $this->retirada->getElementsByTagName("CEP")->item(0)->nodeValue : '';
1764
        $texto = $this->formatField($texto, "#####-###");
1765
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1766
        $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...
1767
        //MUNICÍPIO
1768
        $w     = round($maxW * 0.805, 0);
1769
        $w1    = $w;
1770
        $y     += $h;
1771
        $x     = $oldX;
1772
        $texto = 'MUNICÍPIO';
1773
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1774
        $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...
1775
        $texto = $this->retirada->getElementsByTagName("xMun")->item(0)->nodeValue;
1776
        if (strtoupper(trim($texto)) == "EXTERIOR" && $this->retirada->getElementsByTagName("xPais")->length > 0) {
1777
            $texto .= " - " . $this->retirada->getElementsByTagName("xPais")->item(0)->nodeValue;
1778
        }
1779
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1780
        $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...
1781
        //UF
1782
        $x     += $w;
1783
        $w     = 8;
1784
        $texto = 'UF';
1785
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1786
        $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...
1787
        $texto = $this->retirada->getElementsByTagName("UF")->item(0)->nodeValue;
1788
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
1789
        $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...
1790
        //FONE / FAX
1791
        $x     += $w;
1792
        $w     = $maxW - $w - $w1;
1793
        $texto = 'FONE / FAX';
1794
        $aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => ''];
1795
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

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

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
3166
        $yVeic += $h;
3167
        $texto = 'Cor...................: ' . $veiculoCor;
3168
        $this->pdf->textBox($x, $yVeic, $w1 + 40, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
3169
        $yVeic += $h;
3170
        $texto = 'Cilindrada........: ' . $veiculoCilindrada;
3171
        $this->pdf->textBox($x, $yVeic, $w1 + 40, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
3172
        $yVeic += $h;
3173
        $texto = 'Cmkg...............: ' . $veiculoCmkg;
3174
        $this->pdf->textBox($x, $yVeic, $w1 + 40, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
3175
        $yVeic += $h;
3176
        $texto = 'Tipo.................: ' . ($renavamTiposVeiculos[intval($veiculoTipo)] ?? $veiculoTipo);
3177
        $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...
3178
        $yVeic = $y + $h;
3179
        $xVeic = $x + 65;
3180
        $texto = 'Nº Motor: .........: ' . $veiculoMotor;
3181
        $this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

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

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

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

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

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

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
3191
        $yVeic += $h;
3192
        $texto = 'Tipo Pintura......: ' . ($renavamEspecie[intval($veiculoTipoPintura)] ?? $veiculoTipoPintura);
3193
        $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...
3194
        $yVeic = $y + $h;
3195
        $xVeic = $xVeic + 55;
3196
        $texto = 'Marca / Modelo.....: ' . $veiculoMarcaModelo;
3197
        $this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

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

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

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

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

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

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

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

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

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

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

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