Passed
Push — master ( 1be3b6...256efe )
by Roberto
03:58
created

DacteV3::__construct()   F

Complexity

Conditions 13
Paths 492

Size

Total Lines 165

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 182

Importance

Changes 0
Metric Value
cc 13
nc 492
nop 11
dl 0
loc 165
ccs 0
cts 129
cp 0
crap 182
rs 2.5244
c 0
b 0
f 0

How to fix   Long Method    Complexity    Many Parameters   

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:

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
namespace NFePHP\DA\CTe;
4
5
/**
6
 * Classe para ageração do PDF da CTe, conforme regras e estruturas
7
 * estabelecidas pela SEFAZ.
8
 *
9
 * @category  Library
10
 * @package   nfephp-org/sped-da
11
 * @name      Dacte .php
12
 * @copyright 2009-2016 NFePHP
13
 * @license   http://www.gnu.org/licenses/lesser.html LGPL v3
14
 * @link      http://github.com/nfephp-org/sped-da for the canonical source repository
15
 * @author    Roberto L. Machado <linux dot rlm at gmail dot com>
16
 */
17
18
use Exception;
19
use NFePHP\DA\Legacy\Dom;
20
use NFePHP\DA\Legacy\Pdf;
21
use NFePHP\DA\Legacy\Common;
22
23
class DacteV3 extends Common
24
{
25
    const NFEPHP_SITUACAO_EXTERNA_CANCELADA = 1;
26
    const NFEPHP_SITUACAO_EXTERNA_DENEGADA = 2;
27
    const SIT_DPEC = 3;
28
29
    protected $logoAlign = 'C';
30
    protected $yDados = 0;
31
    protected $situacao_externa = 0;
32
    protected $numero_registro_dpec = '';
33
    protected $pdf;
34
    protected $xml;
35
    protected $logomarca = '';
36
    protected $errMsg = '';
37
    protected $errStatus = false;
38
    protected $orientacao = 'P';
39
    protected $papel = 'A4';
40
    protected $destino = 'I';
41
    protected $pdfDir = '';
42
    protected $fontePadrao = 'Times';
43
    protected $version = '1.3.0';
44
    protected $wPrint;
45
    protected $hPrint;
46
    protected $dom;
47
    protected $infCte;
48
    protected $infCteComp;
49
    protected $infCteAnu;
50
    protected $chaveCTeRef;
51
    protected $tpCTe;
52
    protected $ide;
53
    protected $emit;
54
    protected $enderEmit;
55
    protected $rem;
56
    protected $enderReme;
57
    protected $dest;
58
    protected $enderDest;
59
    protected $exped;
60
    protected $enderExped;
61
    protected $receb;
62
    protected $enderReceb;
63
    protected $infCarga;
64
    protected $infQ;
65
    protected $seg;
66
    protected $modal;
67
    protected $rodo;
68
    protected $moto;
69
    protected $veic;
70
    protected $ferrov;
71
    protected $Comp;
72
    protected $infNF;
73
    protected $infNFe;
74
    protected $compl;
75
    protected $ICMS;
76
    protected $ICMSSN;
77
    protected $ICMSOutraUF;
78
    protected $imp;
79
    protected $toma4;
80
    protected $toma03;
81
    protected $tpEmis;
82
    protected $tpImp;
83
    protected $tpAmb;
84
    protected $vPrest;
85
    protected $wAdic = 150;
86
    protected $textoAdic = '';
87
    protected $debugMode = 2;
88
    protected $formatPadrao;
89
    protected $formatNegrito;
90
    protected $aquav;
91
    protected $preVisualizar;
92
    protected $flagDocOrigContinuacao;
93
    protected $arrayNFe = array();
94
    protected $siteDesenvolvedor;
95
    protected $nomeDesenvolvedor;
96
    protected $totPag;
97
    protected $idDocAntEle = [];
98
99
    /**
100
     * __construct
101
     *
102
     * @param string $docXML Arquivo XML da CTe
103
     * @param string $sOrientacao (Opcional) Orientação da impressão P ou L
104
     * @param string $sPapel Tamanho do papel (Ex. A4)
105
     * @param string $sPathLogo Caminho para o arquivo do logo
106
     * @param string $sDestino Estabelece a direção do envio do documento PDF
107
     * @param string $sDirPDF Caminho para o diretorio de armaz. dos PDF
108
     * @param string $fonteDACTE Nome da fonte a ser utilizada
109
     * @param number $mododebug 0-Não 1-Sim e 2-nada (2 default)
110
     * @param string $preVisualizar 0-Não 1-Sim
111
     */
112
    public function __construct(
113
        $docXML = '',
114
        $sOrientacao = '',
115
        $sPapel = '',
116
        $sPathLogo = '',
117
        $sDestino = 'I',
118
        $sDirPDF = '',
119
        $fonteDACTE = '',
120
        $mododebug = 2,
121
        $preVisualizar = false,
122
        $nomeDesenvolvedor = 'Powered by NFePHP (GNU/GPLv3 GNU/LGPLv3) © www.nfephp.org',
123
        $siteDesenvolvedor = 'http://www.nfephp.org'
124
    ) {
125
126
        if (is_numeric($mododebug)) {
127
            $this->debugMode = $mododebug;
0 ignored issues
show
Documentation Bug introduced by
It seems like $mododebug can also be of type double or string. However, the property $debugMode 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...
128
        }
129
        if ($mododebug == 1) {
130
            //ativar modo debug
131
            error_reporting(E_ALL);
132
            ini_set('display_errors', 'On');
133
        } elseif ($mododebug == 0) {
134
            //desativar modo debug
135
            error_reporting(0);
136
            ini_set('display_errors', 'Off');
137
        }
138
        $this->orientacao = $sOrientacao;
139
        $this->papel = $sPapel;
140
        $this->pdf = '';
141
        $this->xml = $docXML;
142
        $this->logomarca = $sPathLogo;
143
        $this->destino = $sDestino;
144
        $this->pdfDir = $sDirPDF;
145
        $this->preVisualizar = $preVisualizar;
146
        $this->siteDesenvolvedor = $siteDesenvolvedor;
147
        $this->nomeDesenvolvedor = $nomeDesenvolvedor;
148
        // verifica se foi passa a fonte a ser usada
149
        if (!empty($fonteDACTE)) {
150
            $this->fontePadrao = $fonteDACTE;
151
        }
152
        $this->formatPadrao = array(
153
            'font' => $this->fontePadrao,
154
            'size' => 6,
155
            'style' => '');
156
        $this->formatNegrito = array(
157
            'font' => $this->fontePadrao,
158
            'size' => 7,
159
            'style' => 'B');
160
        //se for passado o xml
161
        if (!empty($this->xml)) {
162
            $this->dom = new Dom();
163
            $this->dom->loadXML($this->xml);
164
            $this->cteProc = $this->dom->getElementsByTagName("cteProc")->item(0);
0 ignored issues
show
Bug introduced by
The property cteProc 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...
165
            $this->infCte = $this->dom->getElementsByTagName("infCte")->item(0);
166
            $this->ide = $this->dom->getElementsByTagName("ide")->item(0);
167
            $this->tpCTe = $this->pSimpleGetValue($this->ide, "tpCTe");
168
            $this->emit = $this->dom->getElementsByTagName("emit")->item(0);
169
            $this->enderEmit = $this->dom->getElementsByTagName("enderEmit")->item(0);
170
            $this->rem = $this->dom->getElementsByTagName("rem")->item(0);
171
            $this->enderReme = $this->dom->getElementsByTagName("enderReme")->item(0);
172
            $this->dest = $this->dom->getElementsByTagName("dest")->item(0);
173
            $this->enderDest = $this->dom->getElementsByTagName("enderDest")->item(0);
174
            $this->exped = $this->dom->getElementsByTagName("exped")->item(0);
175
            $this->enderExped = $this->dom->getElementsByTagName("enderExped")->item(0);
176
            $this->receb = $this->dom->getElementsByTagName("receb")->item(0);
177
            $this->enderReceb = $this->dom->getElementsByTagName("enderReceb")->item(0);
178
            $this->infCarga = $this->dom->getElementsByTagName("infCarga")->item(0);
179
            $this->infQ = $this->dom->getElementsByTagName("infQ");
180
            $this->seg = $this->dom->getElementsByTagName("seg")->item(0);
181
            $this->rodo = $this->dom->getElementsByTagName("rodo")->item(0);
182
            $this->aereo = $this->dom->getElementsByTagName("aereo")->item(0);
0 ignored issues
show
Bug introduced by
The property aereo 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...
183
            $this->lota = $this->pSimpleGetValue($this->rodo, "lota");
0 ignored issues
show
Bug introduced by
The property lota 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...
184
            $this->moto = $this->dom->getElementsByTagName("moto")->item(0);
185
            $this->veic = $this->dom->getElementsByTagName("veic");
186
            $this->ferrov = $this->dom->getElementsByTagName("ferrov")->item(0);
187
            // adicionar outros modais
188
189
            $this->infCteComp = $this->dom->getElementsByTagName("infCteComp")->item(0);
190
            $this->infCteAnu = $this->dom->getElementsByTagName("infCteAnu")->item(0);
191
            if ($this->tpCTe == 1) {
192
                $this->chaveCTeRef = $this->pSimpleGetValue($this->infCteComp, "chCTe");
193
            } else {
194
                $this->chaveCTeRef = $this->pSimpleGetValue($this->infCteAnu, "chCte");
195
            }
196
            $this->vPrest = $this->dom->getElementsByTagName("vPrest")->item(0);
197
            $this->Comp = $this->dom->getElementsByTagName("Comp");
198
            $this->infNF = $this->dom->getElementsByTagName("infNF");
199
            $this->infNFe = $this->dom->getElementsByTagName("infNFe");
200
            $this->infOutros = $this->dom->getElementsByTagName("infOutros");
0 ignored issues
show
Bug introduced by
The property infOutros 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...
201
            $this->compl = $this->dom->getElementsByTagName("compl");
202
            $this->ICMS = $this->dom->getElementsByTagName("ICMS")->item(0);
203
            $this->ICMSSN = $this->dom->getElementsByTagName("ICMSSN")->item(0);
204
            $this->ICMSOutraUF = $this->dom->getElementsByTagName("ICMSOutraUF")->item(0);
205
            $this->imp = $this->dom->getElementsByTagName("imp")->item(0);
206
            if (!empty($this->pSimpleGetValue($this->imp, "vTotTrib"))) {
207
                $textoAdic = number_format($this->pSimpleGetValue($this->imp, "vTotTrib"), 2, ",", ".");
208
                $this->textoAdic = "o valor aproximado de tributos incidentes sobre o preço deste serviço é de R$"
209
                        .$textoAdic;
210
            }
211
            $this->toma4 = $this->dom->getElementsByTagName("toma4")->item(0);
212
            $this->toma03 = $this->dom->getElementsByTagName("toma3")->item(0);
213
            //Tag tomador é identificado por toma03 na versão 2.00
214
            if ($this->infCte->getAttribute("versao")=="2.00") {
215
                $this->toma03 = $this->dom->getElementsByTagName("toma03")->item(0);
216
            }
217
            //modal aquaviário
218
            $this->aquav = $this->dom->getElementsByTagName("aquav")->item(0);
219
            $tomador = $this->pSimpleGetValue($this->toma03, "toma");
220
            //0-Remetente;1-Expedidor;2-Recebedor;3-Destinatário;4-Outros
0 ignored issues
show
Unused Code Comprehensibility introduced by
48% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
221
            switch ($tomador) {
222
                case '0':
223
                    $this->toma = $this->rem;
0 ignored issues
show
Bug introduced by
The property toma 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...
224
                    $this->enderToma = $this->enderReme;
0 ignored issues
show
Bug introduced by
The property enderToma 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...
225
                    break;
226
                case '1':
227
                    $this->toma = $this->exped;
228
                    $this->enderToma = $this->enderExped;
229
                    break;
230
                case '2':
231
                    $this->toma = $this->receb;
232
                    $this->enderToma = $this->enderReceb;
233
                    break;
234
                case '3':
235
                    $this->toma = $this->dest;
236
                    $this->enderToma = $this->enderDest;
237
                    break;
238
                default:
239
                    $this->toma = $this->toma4;
240
                    $this->enderToma = $this->pSimpleGetValue($this->toma4, "enderToma");
241
                    break;
242
            }
243
            /*$seguro = $this->pSimpleGetValue($this->seg, "respSeg");
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
244
            switch ($seguro) {
245
                case '0':
246
                    $this->respSeg = 'Remetente';
247
                    break;
248
                case '1':
249
                    $this->respSeg = 'Expedidor';
250
                    break;
251
                case '2':
252
                    $this->respSeg = 'Recebedor';
253
                    break;
254
                case '3':
255
                    $this->respSeg = 'Destinatário';
256
                    break;
257
                case '4':
258
                    $this->respSeg = 'Emitente';
259
                    break;
260
                case '5':
261
                    $this->respSeg = 'Tomador';
262
                    break;
263
                default:
264
                    $this->respSeg = '';
265
                    break;
266
            }*/
267
            $this->tpEmis = $this->pSimpleGetValue($this->ide, "tpEmis");
268
            $this->tpImp = $this->pSimpleGetValue($this->ide, "tpImp");
269
            $this->tpAmb = $this->pSimpleGetValue($this->ide, "tpAmb");
270
            $this->tpCTe = $this->pSimpleGetValue($this->ide, "tpCTe");
271
272
            $this->protCTe = $this->dom->getElementsByTagName("protCTe")->item(0);
0 ignored issues
show
Bug introduced by
The property protCTe 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...
273
            //01-Rodoviário; //02-Aéreo; //03-Aquaviário; //04-Ferroviário;//05-Dutoviário
274
            $this->modal = $this->pSimpleGetValue($this->ide, "modal");
275
        }
276
    }
277
278
    /**
279
     * monta
280
     * @param string $orientacao L ou P
281
     * @param string $papel A4
282
     * @param string $logoAlign C, L ou R
283
     * @param Pdf $classPDF
284
     * @return string montagem
285
     */
286
    public function monta(
287
        $orientacao = '',
288
        $papel = 'A4',
289
        $logoAlign = 'C',
290
        $classPDF = false
291
    ) {
292
293
        return $this->montaDACTE($orientacao, $papel, $logoAlign, $classPDF);
0 ignored issues
show
Bug introduced by
It seems like $classPDF defined by parameter $classPDF on line 290 can also be of type object<NFePHP\DA\Legacy\Pdf>; however, NFePHP\DA\CTe\DacteV3::montaDACTE() does only seem to accept boolean, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
294
    }
295
296
    /**
297
     * printDocument
298
     * @param string $nome
299
     * @param string $destino
300
     * @param string $printer
301
     * @return
302
     */
303
    public function printDocument($nome = '', $destino = 'I', $printer = '')
304
    {
305
        return $this->printDACTE($nome, $destino, $printer);
306
    }
307
308
    /**
309
     * Dados brutos do PDF
310
     * @return string
311
     */
312
    public function render()
313
    {
314
        return $this->pdf->getPdf();
315
    }
316
317
318
    protected function zCteDPEC()
319
    {
320
        return $this->situacao_externa == self::SIT_DPEC && $this->numero_registro_dpec != '';
321
    }
322
323
324
    /**
325
     * montaDACTE
326
     * Esta função monta a DACTE conforme as informações fornecidas para a classe
327
     * durante sua construção.
328
     * A definição de margens e posições iniciais para a impressão são estabelecidas no
329
     * pelo conteúdo da funçao e podem ser modificados.
330
     *
331
     * @param  string $orientacao (Opcional) Estabelece a orientação da
332
     *                impressão (ex. P-retrato), se nada for fornecido será
333
     *                usado o padrão da NFe
334
     * @param  string $papel (Opcional) Estabelece o tamanho do papel (ex. A4)
335
     * @return string O ID da NFe numero de 44 digitos extraido do arquivo XML
336
     */
337
    public function montaDACTE(
338
        $orientacao = '',
339
        $papel = 'A4',
340
        $logoAlign = 'C',
341
        $classPDF = false
342
    ) {
343
344
        //se a orientação estiver em branco utilizar o padrão estabelecido na NF
345
        if ($orientacao == '') {
346
            if ($this->tpImp == '1') {
347
                $orientacao = 'P';
348
            } else {
349
                $orientacao = 'P';
350
            }
351
        }
352
        $this->orientacao = $orientacao;
353
        $this->papel = $papel;
354
        $this->logoAlign = $logoAlign;
355
356
        //$this->situacao_externa = $situacao_externa;
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
357
        //instancia a classe pdf
358
        if ($classPDF !== false) {
359
            $this->pdf = $classPDF;
360
        } else {
361
            $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
362
        }
363
        if ($this->orientacao == 'P') {
364
            // margens do PDF
365
            $margSup = 2;
366
            $margEsq = 2;
367
            $margDir = 2;
368
            // posição inicial do relatorio
369
            $xInic = 1;
370
            $yInic = 1;
371
            if ($papel == 'A4') {
372
                //A4 210x297mm
373
                $maxW = 210;
374
                $maxH = 297;
375
            }
376
        } else {
377
            // margens do PDF
378
            $margSup = 3;
379
            $margEsq = 3;
380
            $margDir = 3;
381
            // posição inicial do relatorio
382
            $xInic = 5;
383
            $yInic = 5;
384
            if ($papel == 'A4') {
385
                //A4 210x297mm
386
                $maxH = 210;
387
                $maxW = 297;
388
                $this->wCanhoto = 25;
0 ignored issues
show
Bug introduced by
The property wCanhoto 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...
389
            }
390
        }
391
        //total inicial de paginas
392
        $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...
393
        //largura imprimivel em mm
394
        $this->wPrint = $maxW - ($margEsq + $xInic);
0 ignored issues
show
Bug introduced by
The variable $maxW 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...
395
        //comprimento imprimivel em mm
396
        $this->hPrint = $maxH - ($margSup + $yInic);
0 ignored issues
show
Bug introduced by
The variable $maxH 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...
397
        // estabelece contagem de paginas
398
        $this->pdf->AliasNbPages();
399
        // fixa as margens
400
        $this->pdf->SetMargins($margEsq, $margSup, $margDir);
401
        $this->pdf->SetDrawColor(0, 0, 0);
402
        $this->pdf->SetFillColor(255, 255, 255);
403
        // inicia o documento
404
        $this->pdf->Open();
405
        // adiciona a primeira página
406
        $this->pdf->AddPage($this->orientacao, $this->papel);
407
        $this->pdf->SetLineWidth(0.1);
408
        $this->pdf->SetTextColor(0, 0, 0);
409
        //calculo do numero de páginas ???
410
        $totPag = 1;
411
        //montagem da primeira página
412
        $pag = 1;
413
        $x = $xInic;
414
        $y = $yInic;
415
        //coloca o cabeçalho
416
        //$r = $this->zCabecalho($x, $y, $pag, $totPag);
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
417
        $y += 70;
418
        $r = $this->zRemetente($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
419
        $x = $this->wPrint * 0.5 + 2;
420
        $r = $this->zDestinatario($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
421
        $y += 19;
422
        $x = $xInic;
423
        $r = $this->zExpedidor($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
424
        $x = $this->wPrint * 0.5 + 2;
425
        $r = $this->zRecebedor($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
426
        $y += 19;
427
        $x = $xInic;
428
        $r = $this->zTomador($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
429
        if ($this->tpCTe == '0') {
430
            //Normal
431
            $y += 10;
432
            $x = $xInic;
433
            $r = $this->zDescricaoCarga($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
434
            $y += 17;
435
            $x = $xInic;
436
            $r = $this->zCompValorServ($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
437
            $y += 25;
438
            $x = $xInic;
439
            $r = $this->zImpostos($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
440
            $y += 13;
441
            $x = $xInic;
442
            $r = $this->zDocOrig($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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
            if ($this->modal == '1') {
444
                if ($this->lota == 1) {
445
                    //$y += 24.95;
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
446
                    $y += 35;
447
                } else {
448
                    $y += 53;
449
                }
450
            } elseif ($this->modal == '2') {
451
                $y += 53;
452
            } elseif ($this->modal == '3') {
453
                $y += 37.75;
454
            } else {
455
                $y += 24.95;
456
            }
457
            $x = $xInic;
458
            $r = $this->zObs($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
459
            $y = $y-6;
460
            switch ($this->modal) {
461
                case '1':
462
                    $y += 25.9;
463
                    $x = $xInic;
464
                    $r = $this->zModalRod($x, $y);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
465
                    break;
466
                case '2':
467
                    $y += 25.9;
468
                    $x = $xInic;
469
                    $r = $this->zModalAereo($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
470
                    break;
471
                case '3':
472
                    $y += 17.9;
473
                    $x = $xInic;
474
                    $r = $this->zModalAquaviario($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
475
                    break;
476
                case '4':
477
                    $y += 17.9;
478
                    $x = $xInic;
479
                    $r = $this->zModalFerr($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
480
                    break;
481
                case '5':
482
                    $y += 17.9;
483
                    $x = $xInic;
484
                    // TODO fmertins 31/10/14: este método não existe...
485
                    $r = $this->zModalDutoviario($x, $y);
0 ignored issues
show
Bug introduced by
The method zModalDutoviario() does not seem to exist on object<NFePHP\DA\CTe\DacteV3>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Unused Code introduced by
$r 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...
486
                    break;
487
            }
488
            if ($this->modal == '1') {
489
                if ($this->lota == 1) {
490
                    $y += 37;
491
                } else {
492
                    $y += 8.9;
493
                }
494
            } elseif ($this->modal == '2') {
495
                $y += 8.9;
496
            } elseif ($this->modal == '3') {
497
                $y += 24.15;
498
            } else {
499
                $y += 37;
500
            }
501
        } else {
502
            $r = $this->zCabecalho(1, 1, $pag, $totPag);
0 ignored issues
show
Unused Code introduced by
$r 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...
503
            //Complementado
504
            $y += 10;
505
            $x = $xInic;
506
            $r = $this->zDocCompl($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
507
            $y += 80;
508
            $x = $xInic;
509
            $r = $this->zCompValorServ($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
510
            $y += 25;
511
            $x = $xInic;
512
            $r = $this->zImpostos($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
513
            $y += 13;
514
            $x = $xInic;
515
            $r = $this->zObs($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
516
            $y += 15;
517
        }
518
        $x = $xInic;
519
        $r = $this->zDadosAdic($x, $y, $pag, $totPag);
0 ignored issues
show
Unused Code introduced by
$r 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...
520
521
        //$y += 19;
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
522
        $y += 11;
523
        $y = $this->zCanhoto($x, $y);
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...
524
525
        //coloca o rodapé da página
526
        if ($this->orientacao == 'P') {
527
            $this->zRodape(2, $this->hPrint - 2);
528
        } else {
529
            $this->zRodape($xInic, $this->hPrint + 2.3);
530
        }
531
        if ($this->flagDocOrigContinuacao == 1) {
532
            $this->zdocOrigContinuacao(1, 71);
533
        }
534
        //retorna o ID na CTe
535
        if ($classPDF !== false) {
536
            $aR = array('id' => str_replace('CTe', '', $this->infCte->getAttribute("Id")), 'classe_PDF' => $this->pdf);
537
            return $aR;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $aR; (array) is incompatible with the return type documented by NFePHP\DA\CTe\DacteV3::montaDACTE of type string.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

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

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
538
        } else {
539
            return str_replace('CTe', '', $this->infCte->getAttribute("Id"));
540
        }
541
    } //fim da função montaDACTE
542
543
    /**
544
     * printDACTE
545
     * Esta função envia a DACTE em PDF criada para o dispositivo informado.
546
     * O destino da impressão pode ser :
547
     * I-browser
548
     * D-browser com download
549
     * F-salva em um arquivo local com o nome informado
550
     * S-retorna o documento como uma string e o nome é ignorado.
551
     * Para enviar o pdf diretamente para uma impressora indique o
552
     * nome da impressora e o destino deve ser 'S'.
553
     *
554
     * @param  string $nome Path completo com o nome do arquivo pdf
555
     * @param  string $destino Direção do envio do PDF
556
     * @param  string $printer Identificação da impressora no sistema
557
     * @return string Caso o destino seja S o pdf é retornado como uma string
558
     * @todo Rotina de impressão direta do arquivo pdf criado
559
     */
560
    public function printDACTE($nome = '', $destino = 'I', $printer = '')
0 ignored issues
show
Unused Code introduced by
The parameter $printer 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...
561
    {
562
        $arq = $this->pdf->Output($nome, $destino);
563
        if ($destino == 'S') {
0 ignored issues
show
Unused Code introduced by
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
564
            //aqui pode entrar a rotina de impressão direta
565
        }
566
        return $arq;
567
    } //fim função printDACTE
568
569
    /**
570
     * zCabecalho
571
     * Monta o cabelhalho da DACTE ( retrato e paisagem )
572
     *
573
     * @param  number $x Posição horizontal inicial, canto esquerdo
574
     * @param  number $y Posição vertical inicial, canto superior
575
     * @param  number $pag Número da Página
576
     * @param  number $totPag Total de páginas
577
     * @return number Posição vertical final
578
     */
579
    protected function zCabecalho($x = 0, $y = 0, $pag = '1', $totPag = '1')
580
    {
581
        $oldX = $x;
582
        $oldY = $y;
583
        if ($this->orientacao == 'P') {
584
            $maxW = $this->wPrint;
585
        } else {
586
            if ($pag == 1) {
587
                // primeira página
588
                $maxW = $this->wPrint - $this->wCanhoto;
589
            } else {
590
                // páginas seguintes
591
                $maxW = $this->wPrint;
592
            }
593
        }
594
        //##################################################################
595
        //coluna esquerda identificação do emitente
596
        $w = round($maxW * 0.42);
597
        if ($this->orientacao == 'P') {
598
            $aFont = array(
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...
599
                'font' => $this->fontePadrao,
600
                'size' => 6,
601
                'style' => '');
602
        } else {
603
            $aFont = $this->formatNegrito;
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...
604
        }
605
        $w1 = $w;
0 ignored issues
show
Unused Code introduced by
$w1 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...
606
        $h = 35;
607
        $oldY += $h;
608
        //desenha a caixa
609
        $this->pTextBox($x, $y, $w + 2, $h + 1);
610
        // coloca o logo
611
        if (is_file($this->logomarca)) {
612
            $logoInfo = getimagesize($this->logomarca);
613
            //largura da imagem em mm
614
            $logoWmm = ($logoInfo[0] / 72) * 25.4;
615
            //altura da imagem em mm
616
            $logoHmm = ($logoInfo[1] / 72) * 25.4;
617
            if ($this->logoAlign == 'L') {
618
                $nImgW = round($w / 3, 0);
619
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
620
                $xImg = $x + 1;
621
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
622
                //estabelecer posições do texto
623
                $x1 = round($xImg + $nImgW + 1, 0);
624
                $y1 = round($h / 3 + $y, 0);
625
                $tw = round(2 * $w / 3, 0);
626
            } elseif ($this->logoAlign == 'C') {
627
                $nImgH = round($h / 3, 0);
628
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
629
                $xImg = round(($w - $nImgW) / 2 + $x, 0);
630
                $yImg = $y + 3;
631
                $x1 = $x;
632
                $y1 = round($yImg + $nImgH + 1, 0);
633
                $tw = $w;
634
            } elseif ($this->logoAlign == 'R') {
635
                $nImgW = round($w / 3, 0);
636
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
637
                $xImg = round($x + ($w - (1 + $nImgW)), 0);
638
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
639
                $x1 = $x;
640
                $y1 = round($h / 3 + $y, 0);
641
                $tw = round(2 * $w / 3, 0);
642
            }
643
            $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...
644
        } else {
645
            $x1 = $x;
646
            $y1 = round($h / 3 + $y, 0);
647
            $tw = $w;
648
        }
649
        //Nome emitente
650
        $aFont = array(
651
            'font' => $this->fontePadrao,
652
            'size' => 9,
653
            'style' => 'B');
654
        $texto = $this->pSimpleGetValue($this->emit, "xNome");
655
        $this->pTextBox($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...
656
        //endereço
657
        $y1 = $y1 + 3;
658
        $aFont = array(
659
            'font' => $this->fontePadrao,
660
            'size' => 7,
661
            'style' => '');
662
        $fone = $this->pSimpleGetValue($this->enderEmit, "fone")!=""? $this->zFormatFone($this->enderEmit):'';
0 ignored issues
show
Documentation introduced by
$this->enderEmit is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
663
        $lgr = $this->pSimpleGetValue($this->enderEmit, "xLgr");
664
        $nro = $this->pSimpleGetValue($this->enderEmit, "nro");
665
        $cpl = $this->pSimpleGetValue($this->enderEmit, "xCpl");
0 ignored issues
show
Unused Code introduced by
$cpl 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...
666
        $bairro = $this->pSimpleGetValue($this->enderEmit, "xBairro");
667
        $CEP = $this->pSimpleGetValue($this->enderEmit, "CEP");
668
        $CEP = $this->pFormat($CEP, "#####-###");
669
        $mun = $this->pSimpleGetValue($this->enderEmit, "xMun");
670
        $UF = $this->pSimpleGetValue($this->enderEmit, "UF");
671
        $xPais = $this->pSimpleGetValue($this->enderEmit, "xPais");
672
        $texto = $lgr . "," . $nro . "\n" . $bairro . " - "
673
            . $CEP . " - " . $mun . " - " . $UF . " " . $xPais
674
            . "\n  Fone/Fax: " . $fone;
675
        $this->pTextBox($x1 - 5, $y1 + 2, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
676
        //CNPJ/CPF IE
677
        $cpfCnpj = $this->zFormatCNPJCPF($this->emit);
0 ignored issues
show
Documentation introduced by
$this->emit is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
678
        $ie = $this->pSimpleGetValue($this->emit, "IE");
679
        $texto = 'CNPJ/CPF:  ' . $cpfCnpj . '     Insc.Estadual: ' . $ie;
680
        $this->pTextBox($x1 - 1, $y1 + 12, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
681
        //outra caixa
682
        $h1 = 17.5;
683
        $y1 = $y + $h + 1;
684
        $this->pTextBox($x, $y1, $w + 2, $h1);
685
        //TIPO DO CT-E
686
        $texto = 'TIPO DO CTE';
687
        $wa = 37;
688
        $aFont = array(
689
            'font' => $this->fontePadrao,
690
            'size' => 8,
691
            'style' => '');
692
        $this->pTextBox($x, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
693
        $tpCTe = $this->pSimpleGetValue($this->ide, "tpCTe");
694
        //0 - CT-e Normal,1 - CT-e de Complemento de Valores,
695
        //2 - CT-e de Anulação de Valores,3 - CT-e Substituto
696
        switch ($tpCTe) {
697
            case '0':
698
                $texto = 'Normal';
699
                break;
700
            case '1':
701
                $texto = 'Complemento de Valores';
702
                break;
703
            case '2':
704
                $texto = 'Anulação de Valores';
705
                break;
706
            case '3':
707
                $texto = 'Substituto';
708
                break;
709
            default:
710
                $texto = 'ERRO' . $tpCTe . $tpServ;
0 ignored issues
show
Bug introduced by
The variable $tpServ seems only to be defined at a later point. Did you maybe move this code here without moving the variable definition?

This error can happen if you refactor code and forget to move the variable initialization.

Let’s take a look at a simple example:

function someFunction() {
    $x = 5;
    echo $x;
}

The above code is perfectly fine. Now imagine that we re-order the statements:

function someFunction() {
    echo $x;
    $x = 5;
}

In that case, $x would be read before it is initialized. This was a very basic example, however the principle is the same for the found issue.

Loading history...
711
        }
712
        $aFont = $this->formatNegrito;
713
        $this->pTextBox($x, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
714
        //TIPO DO SERVIÇO
715
        $texto = 'TIPO DO SERVIÇO';
716
        $wb = 36;
0 ignored issues
show
Unused Code introduced by
$wb 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...
717
        $aFont = array(
718
            'font' => $this->fontePadrao,
719
            'size' => 8,
720
            'style' => '');
721
        $this->pTextBox($x + $wa + 4.5, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
722
        $tpServ = $this->pSimpleGetValue($this->ide, "tpServ");
723
        //0 - Normal;1 - Subcontratação;2 - Redespacho;3 - Redespacho Intermediário
724
        switch ($tpServ) {
725
            case '0':
726
                $texto = 'Normal';
727
                break;
728
            case '1':
729
                $texto = 'Subcontratação';
730
                break;
731
            case '2':
732
                $texto = 'Redespacho';
733
                break;
734
            case '3':
735
                $texto = 'Redespacho Intermediário';
736
                break;
737
            default:
738
                $texto = 'ERRO' . $tpServ;
739
        }
740
        $aFont = $this->formatNegrito;
741
        $this->pTextBox($x + $wa + 4.5, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
742
        $this->pdf->Line($w * 0.5, $y1, $w * 0.5, $y1 + $h1);
743
        //TOMADOR DO SERVIÇO
744
        $texto = 'INDICADOR DO CT-E GLOBALIZADO';
745
        $wc = 37;
0 ignored issues
show
Unused Code introduced by
$wc 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...
746
        $y2 = $y1 + 8;
747
        $aFont = array(
748
            'font' => $this->fontePadrao,
749
            'size' => 6,
750
            'style' => '');
751
        $this->pTextBox($x, $y2, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
752
        $this->pdf->Line($x, $y1 + 8, $w + 3, $y1 + 8);
753
        $toma = $this->pSimpleGetValue($this->ide, "indGlobalizado");
754
        //0-Remetente;1-Expedidor;2-Recebedor;3-Destinatário;4 - Outros
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
755
        if ($toma==1) {
756
            $aFont = array(
757
            'font' => $this->fontePadrao,
758
            'size' => 11,
759
            'style' => '');
760
            $this->pTextBox($x-14.5, $y2 + 3.5, $w * 0.5, $h1, 'X', $aFont, 'T', 'C', 0, '', false);
761
        } else {
762
            $aFont = array(
763
            'font' => $this->fontePadrao,
764
            'size' => 11,
765
            'style' => '');
766
            $this->pTextBox($x+3.5, $y2 + 3.5, $w * 0.5, $h1, 'X', $aFont, 'T', 'C', 0, '', false);
767
        }
768
        $aFont = $this->formatNegrito;
769
        $this->pdf->Line($x+5, $x+48, $x+5, $x+52);
770
        $this->pdf->Line($x+10, $x+48, $x+10, $x+52);
771
        $this->pdf->Line($x+5, $x+48, $x+10, $x+48);
772
        $this->pdf->Line($x+5, $x+52, $x+10, $x+52);
773
        $this->pTextBox($x-9, $y2+1.4 + 3, $w * 0.5, $h1, 'SIM', $aFont, 'T', 'C', 0, '', false);
774
775
        $this->pdf->Line($x+23, $x+48, $x+23, $x+52);
776
        $this->pdf->Line($x+28, $x+48, $x+28, $x+52);
777
        $this->pdf->Line($x+23, $x+48, $x+28, $x+48);
778
        $this->pdf->Line($x+23, $x+52, $x+28, $x+52);
779
        $this->pTextBox($x+9.8, $y2+1.4 + 3, $w * 0.5, $h1, 'NÃO', $aFont, 'T', 'C', 0, '', false);
780
781
        //FORMA DE PAGAMENTO
782
        $texto = 'INFORMAÇÕES DO CT-E GLOBALIZADO';
783
        $wd = 36;
0 ignored issues
show
Unused Code introduced by
$wd 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...
784
        $aFont = array(
785
            'font' => $this->fontePadrao,
786
            'size' => 8,
787
            'style' => '');
788
        $this->pTextBox($x+2 + $wa + 4.5, $y2-0.7, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
789
        $forma = $this->pSimpleGetValue($this->ide, "forPag");
0 ignored issues
show
Unused Code introduced by
$forma 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...
790
        //##################################################################
791
        //coluna direita
792
        $x += $w + 2;
793
        $w = round($maxW * 0.335);
794
        $w1 = $w;
795
        $h = 11;
796
        $this->pTextBox($x, $y, $w + 2, $h + 1);
797
        $texto = "DACTE";
798
        $aFont = array(
799
            'font' => $this->fontePadrao,
800
            'size' => 10,
801
            'style' => 'B');
802
        $this->pTextBox($x, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
803
        $aFont = array(
804
            'font' => $this->fontePadrao,
805
            'size' => 8,
806
            'style' => '');
807
        $texto = "Documento Auxiliar do Conhecimento\nde Transporte Eletrônico";
808
        $h = 10;
809
        $this->pTextBox($x, $y + 4, $w, $h, $texto, $aFont, 'T', 'C', 0, '', false);
810
        $x1 = $x + $w + 2;
811
        $w = round($maxW * 0.22, 0);
812
        $w2 = $w;
813
        $h = 11;
814
        $this->pTextBox($x1, $y, $w + 0.5, $h + 1);
815
        $texto = "MODAL";
816
        $aFont = array(
817
            'font' => $this->fontePadrao,
818
            'size' => 8,
819
            'style' => '');
820
        $this->pTextBox($x1, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
821
        switch ($this->modal) {
822
            case '1':
823
                $texto = 'Rodoviário';
824
                break;
825
            case '2':
826
                $texto = 'Aéreo';
827
                break;
828
            case '3':
829
                $texto = 'Aquaviário';
830
                break;
831
            case '4':
832
                $texto = 'Ferroviário';
833
                break;
834
            case '5':
835
                $texto = 'Dutoviário';
836
                break;
837
        }
838
        $aFont = array(
839
            'font' => $this->fontePadrao,
840
            'size' => 10,
841
            'style' => 'B');
842
        $this->pTextBox($x1, $y + 5, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
843
        //outra caixa
844
        $y += 12;
845
        $h = 9;
846
        $w = $w1 + $w2 + 2;
847
        $this->pTextBox($x, $y, $w + 0.5, $h + 1);
848
        //modelo
849
        $wa = 12;
850
        $xa = $x;
851
        $texto = 'MODELO';
852
        $aFont = array(
853
            'font' => $this->fontePadrao,
854
            'size' => 8,
855
            'style' => '');
856
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
857
        $texto = $this->pSimpleGetValue($this->ide, "mod");
858
        $aFont = $this->formatNegrito;
859
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
860
        $this->pdf->Line($x + $wa, $y, $x + $wa, $y + $h + 1);
861
        //serie
862
        $xa += $wa;
863
        $texto = 'SÉRIE';
864
        $aFont = array(
865
            'font' => $this->fontePadrao,
866
            'size' => 8,
867
            'style' => '');
868
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
869
        $texto = $this->pSimpleGetValue($this->ide, "serie");
870
        $aFont = $this->formatNegrito;
871
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
872
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
873
        //numero
874
        $xa += $wa;
875
        $wa = 20;
876
        $texto = 'NÚMERO';
877
        $aFont = array(
878
            'font' => $this->fontePadrao,
879
            'size' => 8,
880
            'style' => '');
881
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
882
        $texto = $this->pSimpleGetValue($this->ide, "nCT");
883
        $aFont = $this->formatNegrito;
884
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
885
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
886
        //folha
887
        $xa += $wa;
888
        $wa = 12;
889
        $texto = 'FL';
890
        $aFont = array(
891
            'font' => $this->fontePadrao,
892
            'size' => 8,
893
            'style' => '');
894
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
895
        //$texto = '1/1';
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
896
        $texto = $pag."/".$totPag;
897
        $aFont = $this->formatNegrito;
898
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
899
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
900
        //data  hora de emissão
901
        $xa += $wa;
902
        $wa = 30;
903
        $texto = 'DATA E HORA DE EMISSÃO';
904
        $aFont = array(
905
            'font' => $this->fontePadrao,
906
            'size' => 8,
907
            'style' => '');
908
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
909
        $texto = !empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
910
            date('d/m/Y H:i:s', $this->pConvertTime($this->pSimpleGetValue($this->ide, "dhEmi"))) : '';
911
        $aFont = $this->formatNegrito;
912
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
913
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
914
        //ISUF
915
        $xa += $wa;
916
        $wa = 32;
917
        $texto = 'INSC. SUFRAMA DO DESTINATÁRIO';
918
        $aFont = $this->formatPadrao;
919
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
920
        $texto = $this->pSimpleGetValue($this->dest, "ISUF");
921
        $aFont = array(
922
            'font' => $this->fontePadrao,
923
            'size' => 7,
924
            'style' => 'B');
925
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
926
        //outra caixa
927
        $y += $h + 1;
928
        $h = 23;
929
        $h1 = 14;
930
        $this->pTextBox($x, $y, $w + 0.5, $h1);
931
        //CODIGO DE BARRAS
932
        $chave_acesso = str_replace('CTe', '', $this->infCte->getAttribute("Id"));
933
        $bW = 85;
934
        $bH = 10;
935
        //codigo de barras
936
        $this->pdf->SetFillColor(0, 0, 0);
937
        $this->pdf->Code128($x + (($w - $bW) / 2), $y + 2, $chave_acesso, $bW, $bH);
938
        $this->pTextBox($x, $y + $h1, $w + 0.5, $h1 - 6);
939
        $texto = 'CHAVE DE ACESSO';
940
        $aFont = $this->formatPadrao;
941
        $this->pTextBox($x, $y + $h1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
942
        $aFont = $this->formatNegrito;
943
        $texto = $this->pFormat($chave_acesso, '##.####.##.###.###/####-##-##-###-###.###.###-###.###.###-#');
944
        $this->pTextBox($x, $y + $h1 + 3, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
945
        $this->pTextBox($x, $y + $h1 + 8, $w + 0.5, $h1 - 4.5);
946
        $texto = "Consulta de autenticidade no portal nacional do CT-e, ";
947
        $texto .= "no site da Sefaz Autorizadora, \r\n ou em http://www.cte.fazenda.gov.br";
948
        if ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
949
            $texto = "";
950
            $this->pdf->SetFillColor(0, 0, 0);
951
            if ($this->tpEmis == 5) {
952
                $chaveContingencia = $this->zGeraChaveAdicCont();
953
                $this->pdf->Code128($x + 20, $y1 + 10, $chaveContingencia, $bW * .9, $bH / 2);
954
            } else {
955
                $chaveContingencia = $this->pSimpleGetValue($this->protCTe, "nProt");
956
                $this->pdf->Code128($x + 40, $y1 + 10, $chaveContingencia, $bW * .4, $bH / 2);
957
            }
958
            //codigo de barras
959
        }
960
        $aFont = array(
961
            'font' => $this->fontePadrao,
962
            'size' => 8,
963
            'style' => '');
964
        $this->pTextBox($x, $y + $h1 + 9, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
965
        //outra caixa
966
        $y += $h + 1;
967
        $h = 8.5;
968
        $wa = $w;
969
        $this->pTextBox($x, $y + 7.5, $w + 0.5, $h);
970
        if ($this->zCteDPEC()) {
971
            $texto = 'NÚMERO DE REGISTRO DPEC';
972
        } elseif ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
973
            $texto = "DADOS DO CT-E";
974
        } else {
975
            $texto = 'PROTOCOLO DE AUTORIZAÇÃO DE USO';
976
        }
977
        $aFont = $this->formatPadrao;
978
        $this->pTextBox($x, $y + 7.5, $wa, $h, $texto, $aFont, 'T', 'L', 0, '');
979
        if ($this->zCteDPEC()) {
980
            $texto = $this->numero_registro_dpec;
981
        } elseif ($this->tpEmis == 5) {
982
            $chaveContingencia = $this->zGeraChaveAdicCont();
983
            $aFont = array(
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...
984
                'font' => $this->fontePadrao,
985
                'size' => 8,
986
                'style' => 'B');
987
            $texto = $this->pFormat($chaveContingencia, "#### #### #### #### #### #### #### #### ####");
988
            $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...
989
        } else {
990
            $texto = $this->pSimpleGetValue($this->protCTe, "nProt") . " - ";
991
            // empty($volume->getElementsByTagName("qVol")->item(0)->nodeValue)
0 ignored issues
show
Unused Code Comprehensibility introduced by
77% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
992
            if (!empty($this->protCTe)
993
                && !empty($this->protCTe->getElementsByTagName("dhRecbto")->item(0)->nodeValue)
994
            ) {
995
                $texto .= date(
996
                    'd/m/Y   H:i:s',
997
                    $this->pConvertTime($this->pSimpleGetValue($this->protCTe, "dhRecbto"))
998
                );
999
            }
1000
            $texto = $this->pSimpleGetValue($this->protCTe, "nProt") == '' ? '' : $texto;
1001
        }
1002
        $aFont = $this->formatNegrito;
1003
        $this->pTextBox($x, $y + 12, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
1004
        //CFOP
1005
        $x = $oldX;
1006
        $h = 8.5;
1007
        $w = round($maxW * 0.42);
1008
        $y1 = $y + 7.5;
1009
        $this->pTextBox($x, $y1, $w + 2, $h);
1010
        $texto = 'CFOP - NATUREZA DA PRESTAÇÃO';
1011
        $aFont = array(
1012
            'font' => $this->fontePadrao,
1013
            'size' => 8,
1014
            'style' => '');
1015
        $this->pTextBox($x, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1016
        $texto = $this->pSimpleGetValue($this->ide, "CFOP") . ' - ' . $this->pSimpleGetValue($this->ide, "natOp");
1017
        $aFont = $this->formatNegrito;
1018
        $this->pTextBox($x, $y1 + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1019
        //ORIGEM DA PRESTAÇÃO
1020
        $y += $h + 7.5;
1021
        $x = $oldX;
1022
        $h = 8;
1023
        $w = ($maxW * 0.5);
1024
        $this->pTextBox($x, $y, $w + 0.5, $h);
1025
        $texto = 'INÍCIO DA PRESTAÇÃO';
1026
        $aFont = array(
1027
            'font' => $this->fontePadrao,
1028
            'size' => 8,
1029
            'style' => '');
1030
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1031
        $texto = $this->pSimpleGetValue($this->ide, "xMunIni") . ' - ' . $this->pSimpleGetValue($this->ide, "UFIni");
1032
        $aFont = $this->formatNegrito;
1033
        $this->pTextBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1034
        //DESTINO DA PRESTAÇÃO
1035
        $x = $oldX + $w + 1;
1036
        $h = 8;
1037
        $w = $w - 1.3;
1038
        $this->pTextBox($x - 0.5, $y, $w + 0.5, $h);
1039
        $texto = 'TÉRMINO DA PRESTAÇÃO';
1040
        $aFont = array(
1041
            'font' => $this->fontePadrao,
1042
            'size' => 8,
1043
            'style' => '');
1044
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1045
        $texto = $this->pSimpleGetValue($this->ide, "xMunFim") . ' - ' . $this->pSimpleGetValue($this->ide, "UFFim");
1046
        $aFont = $this->formatNegrito;
1047
        $this->pTextBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1048
        //#########################################################################
1049
        //Indicação de CTe Homologação, cancelamento e falta de protocolo
1050
        $tpAmb = $this->ide->getElementsByTagName('tpAmb')->item(0)->nodeValue;
1051
        //indicar cancelamento
1052
        $cStat = $this->pSimpleGetValue($this->cteProc, "cStat");
1053
        if ($cStat == '101' || $cStat == '135' || $this->situacao_externa == self::NFEPHP_SITUACAO_EXTERNA_CANCELADA) {
1054
            //101 Cancelamento
1055
            $x = 10;
1056
            $y = $this->hPrint - 130;
1057
            $h = 25;
1058
            $w = $maxW - (2 * $x);
1059
            $this->pdf->SetTextColor(90, 90, 90);
1060
            $texto = "CTe CANCELADO";
1061
            $aFont = array(
1062
                'font' => $this->fontePadrao,
1063
                'size' => 48,
1064
                'style' => 'B');
1065
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1066
            $this->pdf->SetTextColor(0, 0, 0);
1067
        }
1068
        $cStat = $this->pSimpleGetValue($this->cteProc, "cStat");
1069
        if ($cStat == '110' ||
1070
            $cStat == '301' ||
1071
            $cStat == '302' ||
1072
            $this->situacao_externa == self::NFEPHP_SITUACAO_EXTERNA_DENEGADA
1073
        ) {
1074
            //110 Denegada
1075
            $x = 10;
1076
            $y = $this->hPrint - 130;
1077
            $h = 25;
1078
            $w = $maxW - (2 * $x);
1079
            $this->pdf->SetTextColor(90, 90, 90);
1080
            $texto = "CTe USO DENEGADO";
1081
            $aFont = array(
1082
                'font' => $this->fontePadrao,
1083
                'size' => 48,
1084
                'style' => 'B');
1085
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1086
            $y += $h;
1087
            $h = 5;
1088
            $w = $maxW - (2 * $x);
1089
            $texto = "SEM VALOR FISCAL";
1090
            $aFont = array(
1091
                'font' => $this->fontePadrao,
1092
                'size' => 48,
1093
                'style' => 'B');
1094
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1095
            $this->pdf->SetTextColor(0, 0, 0);
1096
        }
1097
        //indicar sem valor
1098
        if ($tpAmb != 1 && $this->preVisualizar=='0') { // caso não seja uma DA de produção
1099
            $x = 10;
1100
            if ($this->orientacao == 'P') {
1101
                $y = round($this->hPrint * 2 / 3, 0);
1102
            } else {
1103
                $y = round($this->hPrint / 2, 0);
1104
            }
1105
            $h = 5;
1106
            $w = $maxW - (2 * $x);
1107
            $this->pdf->SetTextColor(90, 90, 90);
1108
            $texto = "SEM VALOR FISCAL";
1109
            $aFont = array(
1110
                'font' => $this->fontePadrao,
1111
                'size' => 48,
1112
                'style' => 'B');
1113
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1114
            $aFont = array(
1115
                'font' => $this->fontePadrao,
1116
                'size' => 30,
1117
                'style' => 'B');
1118
            $texto = "AMBIENTE DE HOMOLOGAÇÃO";
1119
            $this->pTextBox($x, $y + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1120
            $this->pdf->SetTextColor(0, 0, 0);
1121
        } elseif ($this->preVisualizar=='1') { // caso seja uma DA de Pré-Visualização
1122
            $h = 5;
1123
            $w = $maxW - (2 * 10);
1124
            $x = 55;
1125
            $y = 240;
1126
            $this->pdf->SetTextColor(255, 100, 100);
1127
            $aFont = array(
1128
                'font' => $this->fontePadrao,
1129
                'size' => 40,
1130
                'style' => 'B');
1131
            $texto = "Pré-visualização";
1132
            $this->pTextBox90($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1133
            $this->pdf->SetTextColor(255, 100, 100);
1134
            $aFont = array(
1135
                'font' => $this->fontePadrao,
1136
                'size' => 41,
1137
                'style' => 'B');
1138
            $texto = "Sem Validade Jurídica";
1139
            $this->pTextBox90($x+20, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1140
            $this->pdf->SetTextColor(90, 90, 90);
1141
            $texto = "SEM VALOR FISCAL";
1142
            $aFont = array(
1143
                'font' => $this->fontePadrao,
1144
                'size' => 48,
1145
                'style' => 'B');
1146
            $this->pTextBox90($x+40, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1147
            $this->pdf->SetTextColor(0, 0, 0); // voltar a cor default
1148
        } else {
1149
            $x = 10;
1150
            if ($this->orientacao == 'P') {
1151
                $y = round($this->hPrint * 2 / 3, 0);
1152
            } else {
1153
                $y = round($this->hPrint / 2, 0);
1154
            } //fim orientacao
1155
            $h = 5;
1156
            $w = $maxW - (2 * $x);
1157
            $this->pdf->SetTextColor(90, 90, 90);
1158
            //indicar FALTA DO PROTOCOLO se NFe não for em contingência
1159
            if (($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) && !$this->zCteDPEC()) {
1160
                //Contingência
1161
                $texto = "DACTE Emitido em Contingência";
1162
                $aFont = array(
1163
                    'font' => $this->fontePadrao,
1164
                    'size' => 48,
1165
                    'style' => 'B');
1166
                $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1167
                $aFont = array(
1168
                    'font' => $this->fontePadrao,
1169
                    'size' => 30,
1170
                    'style' => 'B');
1171
                $texto = "devido à problemas técnicos";
1172
                $this->pTextBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1173
            } else {
1174
                if (!isset($this->protCTe)) {
1175
                    if (!$this->zCteDPEC()) {
1176
                        $texto = "SEM VALOR FISCAL";
1177
                        $aFont = array(
1178
                            'font' => $this->fontePadrao,
1179
                            'size' => 48,
1180
                            'style' => 'B');
1181
                        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1182
                    }
1183
                    $aFont = array(
1184
                        'font' => $this->fontePadrao,
1185
                        'size' => 30,
1186
                        'style' => 'B');
1187
                    $texto = "FALTA PROTOCOLO DE APROVAÇÃO DA SEFAZ";
1188
                    if (!$this->zCteDPEC()) {
1189
                        $this->pTextBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1190
                    } else {
1191
                        $this->pTextBox($x, $y + 25, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1192
                    }
1193
                } //fim cteProc
1194
                if ($this->tpEmis == 4) {
1195
                    //DPEC
1196
                    $x = 10;
1197
                    $y = $this->hPrint - 130;
1198
                    $h = 25;
1199
                    $w = $maxW - (2 * $x);
1200
                    $this->pdf->SetTextColor(200, 200, 200); // 90,90,90 é muito escuro
0 ignored issues
show
Unused Code Comprehensibility introduced by
42% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
1201
                    $texto = "DACTE impresso em contingência -\n"
1202
                        . "DPEC regularmente recebido pela Receita\n"
1203
                        . "Federal do Brasil";
1204
                    $aFont = array(
1205
                        'font' => $this->fontePadrao,
1206
                        'size' => 48,
1207
                        'style' => 'B');
1208
                    $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1209
                    $this->pdf->SetTextColor(0, 0, 0);
1210
                }
1211
            } //fim tpEmis
1212
            $this->pdf->SetTextColor(0, 0, 0);
1213
        }
1214
        return $oldY;
1215
    } //fim zCabecalho
1216
1217
    /**
1218
     * rodapeDACTE
1219
     * Monta o rodape no final da DACTE ( retrato e paisagem )
1220
     *
1221
     * @param number $xInic Posição horizontal canto esquerdo
0 ignored issues
show
Bug introduced by
There is no parameter named $xInic. 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...
1222
     * @param number $yFinal Posição vertical final para impressão
0 ignored issues
show
Bug introduced by
There is no parameter named $yFinal. 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...
1223
     */
1224
    protected function zRodape($x, $y)
1225
    {
1226
        $texto = "Impresso em  " . date('d/m/Y   H:i:s');
1227
        $w = $this->wPrint - 4;
1228
        $aFont = array(
1229
            'font' => $this->fontePadrao,
1230
            'size' => 6,
1231
            'style' => '');
1232
        $this->pTextBox($x, $y, $w, 4, $texto, $aFont, 'T', 'L', 0, '');
1233
        $texto = 'Desenvolvido por '.$this->nomeDesenvolvedor . ' - '. $this->siteDesenvolvedor;
1234
        $aFont = array(
1235
            'font' => $this->fontePadrao,
1236
            'size' => 6,
1237
            'style' => '');
1238
        $this->pTextBox($x, $y, $w, 4, $texto, $aFont, 'T', 'R', 0, $this->siteDesenvolvedor);
1239
    } //fim zRodape
1240
1241
    /**
1242
     * zRemetente
1243
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1244
     *
1245
     * @param  number $x Posição horizontal canto esquerdo
1246
     * @param  number $y Posição vertical canto superior
1247
     * @return number Posição vertical final
1248
     */
1249
    protected function zRemetente($x = 0, $y = 0)
1250
    {
1251
        $oldX = $x;
1252
        $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...
1253
        if ($this->orientacao == 'P') {
1254
            $maxW = $this->wPrint;
1255
        } else {
1256
            $maxW = $this->wPrint - $this->wCanhoto;
1257
        }
1258
        $w = $maxW * 0.5 + 0.5;
1259
        $h = 19;
1260
        $x1 = $x + 16;
1261
        $texto = 'REMETENTE';
1262
        $aFont = $this->formatPadrao;
1263
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1264
        $aFont = $this->formatNegrito;
1265
        $texto = $this->pSimpleGetValue($this->rem, "xNome");
1266
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1267
        $y += 3;
1268
        $texto = 'ENDEREÇO';
1269
        $aFont = $this->formatPadrao;
1270
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1271
        $aFont = $this->formatNegrito;
1272
        $texto = $this->pSimpleGetValue($this->enderReme, "xLgr") . ',';
1273
        $texto .= $this->pSimpleGetValue($this->enderReme, "nro");
1274
        $texto .= ($this->pSimpleGetValue($this->enderReme, "xCpl") != "") ?
1275
            ' - ' . $this->pSimpleGetValue($this->enderReme, "xCpl") : '';
1276
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1277
        $y += 3;
1278
        $texto = $this->pSimpleGetValue($this->enderReme, "xBairro");
1279
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1280
        $y += 3;
1281
        $texto = 'MUNICÍPIO';
1282
        $aFont = $this->formatPadrao;
1283
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1284
        $texto = $this->pSimpleGetValue($this->enderReme, "xMun") . ' - ';
1285
        $texto .= $this->pSimpleGetValue($this->enderReme, "UF");
1286
        $aFont = $this->formatNegrito;
1287
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1288
        $x = $w - 18;
1289
        $texto = 'CEP';
1290
        $aFont = $this->formatPadrao;
1291
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1292
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderReme, "CEP"), "#####-###");
1293
        $aFont = $this->formatNegrito;
1294
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1295
        $x = $oldX;
1296
        $y += 3;
1297
        $texto = 'CNPJ/CPF';
1298
        $aFont = $this->formatPadrao;
1299
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1300
        $cpfCnpj = $this->zFormatCNPJCPF($this->rem);
0 ignored issues
show
Documentation introduced by
$this->rem is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1301
        $aFont = $this->formatNegrito;
1302
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1303
        $x = $w - 45;
1304
        $texto = 'INSCRIÇÃO ESTADUAL';
1305
        $aFont = $this->formatPadrao;
1306
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1307
        $texto = $this->pSimpleGetValue($this->rem, "IE");
1308
        $aFont = $this->formatNegrito;
1309
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1310
        $x = $oldX;
1311
        $y += 3;
1312
        $texto = 'PAÍS';
1313
        $aFont = $this->formatPadrao;
1314
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1315
        $texto = $this->pSimpleGetValue($this->rem, "xPais") != "" ?
1316
            $this->pSimpleGetValue($this->rem, "xPais") : 'BRASIL';
1317
        $aFont = $this->formatNegrito;
1318
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1319
        $x = $w - 25;
1320
        $texto = 'FONE';
1321
        $aFont = $this->formatPadrao;
1322
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1323
        //$texto = $this->zFormatFone($this->rem);
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
1324
        $texto = $this->pSimpleGetValue($this->rem, "fone")!=""? $this->zFormatFone($this->rem):'';
0 ignored issues
show
Documentation introduced by
$this->rem is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1325
        $aFont = $this->formatNegrito;
1326
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1327
    } //fim da função remetenteDACTE
1328
1329
    /**
1330
     * zDestinatario
1331
     * Monta o campo com os dados do destinatário na DACTE.
1332
     *
1333
     * @param  number $x Posição horizontal canto esquerdo
1334
     * @param  number $y Posição vertical canto superior
1335
     * @return number Posição vertical final
1336
     */
1337
    protected function zDestinatario($x = 0, $y = 0)
1338
    {
1339
        $oldX = $x;
1340
        $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...
1341
        if ($this->orientacao == 'P') {
1342
            $maxW = $this->wPrint;
1343
        } else {
1344
            $maxW = $this->wPrint - $this->wCanhoto;
1345
        }
1346
        $w = ($maxW * 0.5) - 0.7;
1347
        $h = 19;
1348
        $x1 = $x + 19;
1349
        $texto = 'DESTINATÁRIO';
1350
        $aFont = $this->formatPadrao;
1351
        $this->pTextBox($x - 0.5, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1352
        $aFont = $this->formatNegrito;
1353
        $texto = $this->pSimpleGetValue($this->dest, "xNome");
1354
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1355
        $y += 3;
1356
        $texto = 'ENDEREÇO';
1357
        $aFont = $this->formatPadrao;
1358
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1359
        $aFont = $this->formatNegrito;
1360
        $texto = $this->pSimpleGetValue($this->enderDest, "xLgr") . ',';
1361
        $texto .= $this->pSimpleGetValue($this->enderDest, "nro");
1362
        $texto .= $this->pSimpleGetValue($this->enderDest, "xCpl") != "" ?
1363
            ' - ' . $this->pSimpleGetValue($this->enderDest, "xCpl") : '';
1364
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1365
        $y += 3;
1366
        $texto = $this->pSimpleGetValue($this->enderDest, "xBairro");
1367
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1368
        $y += 3;
1369
        $texto = 'MUNICÍPIO';
1370
        $aFont = $this->formatPadrao;
1371
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1372
        $texto = $this->pSimpleGetValue($this->enderDest, "xMun") . ' - ';
1373
        $texto .= $this->pSimpleGetValue($this->enderDest, "UF");
1374
        $aFont = $this->formatNegrito;
1375
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1376
        $x = $w - 19 + $oldX;
1377
        $texto = 'CEP';
1378
        $aFont = $this->formatPadrao;
1379
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1380
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderDest, "CEP"), "#####-###");
1381
        $aFont = $this->formatNegrito;
1382
        $this->pTextBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1383
        $x = $oldX;
1384
        $y += 3;
1385
        $texto = 'CNPJ/CPF';
1386
        $aFont = $this->formatPadrao;
1387
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1388
        $cpfCnpj = $this->zFormatCNPJCPF($this->dest);
0 ignored issues
show
Documentation introduced by
$this->dest is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1389
        $aFont = $this->formatNegrito;
1390
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1391
        $x = $w - 47.5 + $oldX;
1392
        $texto = 'INSCRIÇÃO ESTADUAL';
1393
        $aFont = $this->formatPadrao;
1394
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1395
        $texto = $this->pSimpleGetValue($this->dest, "IE");
1396
        $aFont = $this->formatNegrito;
1397
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1398
        $x = $oldX;
1399
        $y += 3;
1400
        $texto = 'PAÍS';
1401
        $aFont = $this->formatPadrao;
1402
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1403
        $texto = $this->pSimpleGetValue($this->dest, "xPais");
1404
        $aFont = $this->formatNegrito;
1405
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1406
        $x = $w - 27 + $oldX;
1407
        $texto = 'FONE';
1408
        $aFont = $this->formatPadrao;
1409
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1410
        //$texto = $this->zFormatFone($this->dest);
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
1411
        $texto = $this->pSimpleGetValue($this->dest, "fone")!=""? $this->zFormatFone($this->dest):'';
0 ignored issues
show
Documentation introduced by
$this->dest is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1412
        $aFont = $this->formatNegrito;
1413
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1414
    } //fim da função destinatarioDACTE
1415
1416
    /**
1417
     * zExpedidor
1418
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1419
     *
1420
     * @param  number $x Posição horizontal canto esquerdo
1421
     * @param  number $y Posição vertical canto superior
1422
     * @return number Posição vertical final
1423
     */
1424
    protected function zExpedidor($x = 0, $y = 0)
1425
    {
1426
        $oldX = $x;
1427
        $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...
1428
        if ($this->orientacao == 'P') {
1429
            $maxW = $this->wPrint;
1430
        } else {
1431
            $maxW = $this->wPrint - $this->wCanhoto;
1432
        }
1433
        $w = $maxW * 0.5 + 0.5;
1434
        $h = 19;
1435
        $x1 = $x + 16;
1436
        $texto = 'EXPEDIDOR';
1437
        $aFont = $this->formatPadrao;
1438
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1439
        $aFont = $this->formatNegrito;
1440
        $texto = $this->pSimpleGetValue($this->exped, "xNome");
1441
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1442
        $y += 3;
1443
        $texto = 'ENDEREÇO';
1444
        $aFont = $this->formatPadrao;
1445
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1446
        $aFont = $this->formatNegrito;
1447
        if (isset($this->enderExped)) {
1448
            $texto = $this->pSimpleGetValue($this->enderExped, "xLgr") . ', ';
1449
            $texto .= $this->pSimpleGetValue($this->enderExped, "nro");
1450
            $texto .= $this->pSimpleGetValue($this->enderExped, "xCpl") != "" ?
1451
                ' - ' . $this->pSimpleGetValue($this->enderExped, "xCpl") :
1452
                '';
1453
        } else {
1454
            $texto = '';
1455
        }
1456
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1457
        $y += 3;
1458
        $texto = $this->pSimpleGetValue($this->enderExped, "xBairro");
0 ignored issues
show
Bug introduced by
It seems like $this->enderExped can be null; however, pSimpleGetValue() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
1459
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1460
        $y += 3;
1461
        $texto = 'MUNICÍPIO';
1462
        $aFont = $this->formatPadrao;
1463
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1464
        if (isset($this->enderExped)) {
1465
            $texto = $this->pSimpleGetValue($this->enderExped, "xMun") . ' - ';
1466
            $texto .= $this->pSimpleGetValue($this->enderExped, "UF");
1467
        } else {
1468
            $texto = '';
1469
        }
1470
        $aFont = $this->formatNegrito;
1471
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1472
        $x = $w - 18;
1473
        $texto = 'CEP';
1474
        $aFont = $this->formatPadrao;
1475
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1476
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderExped, "CEP"), "#####-###");
0 ignored issues
show
Bug introduced by
It seems like $this->enderExped can be null; however, pSimpleGetValue() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
1477
        $aFont = $this->formatNegrito;
1478
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1479
        $x = $oldX;
1480
        $y += 3;
1481
        $texto = 'CNPJ/CPF';
1482
        $aFont = $this->formatPadrao;
1483
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1484
        $cpfCnpj = $this->zFormatCNPJCPF($this->exped);
0 ignored issues
show
Documentation introduced by
$this->exped is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1485
        $aFont = $this->formatNegrito;
1486
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1487
        $x = $w - 45;
1488
        $texto = 'INSCRIÇÃO ESTADUAL';
1489
        $aFont = $this->formatPadrao;
1490
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1491
        $texto = $this->pSimpleGetValue($this->exped, "IE");
1492
        $aFont = $this->formatNegrito;
1493
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1494
        $x = $oldX;
1495
        $y += 3;
1496
        $texto = 'PAÍS';
1497
        $aFont = $this->formatPadrao;
1498
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1499
        $texto = $this->pSimpleGetValue($this->exped, "xPais");
1500
        $aFont = $this->formatNegrito;
1501
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1502
        $x = $w - 25;
1503
        $texto = 'FONE';
1504
        $aFont = $this->formatPadrao;
1505
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1506
        if (isset($this->exped)) {
1507
            $texto = $this->pSimpleGetValue($this->exped, "fone")!=""? $this->zFormatFone($this->exped):'';
0 ignored issues
show
Documentation introduced by
$this->exped is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1508
            $aFont = $this->formatNegrito;
1509
            $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1510
        }
1511
    } //fim da função remetenteDACTE
1512
1513
    /**
1514
     * zRecebedor
1515
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1516
     *
1517
     * @param  number $x Posição horizontal canto esquerdo
1518
     * @param  number $y Posição vertical canto superior
1519
     * @return number Posição vertical final
1520
     */
1521
    protected function zRecebedor($x = 0, $y = 0)
1522
    {
1523
        $oldX = $x;
1524
        $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...
1525
        if ($this->orientacao == 'P') {
1526
            $maxW = $this->wPrint;
1527
        } else {
1528
            $maxW = $this->wPrint - $this->wCanhoto;
1529
        }
1530
        $w = ($maxW * 0.5) - 0.7;
1531
        $h = 19;
1532
        $x1 = $x + 19;
1533
        $texto = 'RECEBEDOR';
1534
        $aFont = $this->formatPadrao;
1535
        $this->pTextBox($x - 0.5, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1536
        $aFont = $this->formatNegrito;
1537
        $texto = $this->pSimpleGetValue($this->receb, "xNome");
1538
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1539
        $y += 3;
1540
        $texto = 'ENDEREÇO';
1541
        $aFont = $this->formatPadrao;
1542
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1543
        $aFont = $this->formatNegrito;
1544
        if (isset($this->enderReceb)) {
1545
            $texto = $this->pSimpleGetValue($this->enderReceb, "xLgr") . ', ';
1546
            $texto .= $this->pSimpleGetValue($this->enderReceb, "nro");
1547
            $texto .= ($this->pSimpleGetValue($this->enderReceb, "xCpl") != "") ?
1548
                ' - ' . $this->pSimpleGetValue($this->enderReceb, "xCpl") :
1549
                '';
1550
        } else {
1551
            $texto = '';
1552
        }
1553
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1554
        $y += 3;
1555
        $texto = $this->pSimpleGetValue($this->enderReceb, "xBairro");
0 ignored issues
show
Bug introduced by
It seems like $this->enderReceb can be null; however, pSimpleGetValue() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
1556
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1557
        $y += 3;
1558
        $texto = 'MUNICÍPIO';
1559
        $aFont = $this->formatPadrao;
1560
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1561
        if (isset($this->enderReceb)) {
1562
            $texto = $this->pSimpleGetValue($this->enderReceb, "xMun") . ' - ';
1563
            $texto .= $this->pSimpleGetValue($this->enderReceb, "UF");
1564
        } else {
1565
            $texto = '';
1566
        }
1567
        $aFont = $this->formatNegrito;
1568
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1569
        $x = $w - 19 + $oldX;
1570
        $texto = 'CEP';
1571
        $aFont = $this->formatPadrao;
1572
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1573
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderReceb, "CEP"), "#####-###");
0 ignored issues
show
Bug introduced by
It seems like $this->enderReceb can be null; however, pSimpleGetValue() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
1574
        $aFont = $this->formatNegrito;
1575
        $this->pTextBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1576
        $x = $oldX;
1577
        $y += 3;
1578
        $texto = 'CNPJ/CPF';
1579
        $aFont = $this->formatPadrao;
1580
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1581
        $texto = $this->zFormatCNPJCPF($this->receb);
0 ignored issues
show
Documentation introduced by
$this->receb is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1582
        $aFont = $this->formatNegrito;
1583
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1584
        $x = $w - 47 + $oldX;
1585
        $texto = 'INSCRIÇÃO ESTADUAL';
1586
        $aFont = $this->formatPadrao;
1587
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1588
        $texto = $this->pSimpleGetValue($this->receb, "IE");
1589
        $aFont = $this->formatNegrito;
1590
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1591
        $x = $oldX;
1592
        $y += 3;
1593
        $texto = 'PAÍS';
1594
        $aFont = $this->formatPadrao;
1595
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1596
        $texto = $this->pSimpleGetValue($this->receb, "xPais");
1597
        $aFont = $this->formatNegrito;
1598
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1599
        $x = $w - 27 + $oldX;
1600
        $texto = 'FONE';
1601
        $aFont = $this->formatPadrao;
1602
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1603
        if (isset($this->receb)) {
1604
            $texto = $this->pSimpleGetValue($this->receb, "fone")!=""? $this->zFormatFone($this->receb):'';
0 ignored issues
show
Documentation introduced by
$this->receb is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1605
            $aFont = $this->formatNegrito;
1606
            $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1607
        }
1608
    } //fim da função recebedorDACTE
1609
1610
    /**
1611
     * zTomador
1612
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1613
     *
1614
     * @param  number $x Posição horizontal canto esquerdo
1615
     * @param  number $y Posição vertical canto superior
1616
     * @return number Posição vertical final
1617
     */
1618
    protected function zTomador($x = 0, $y = 0)
1619
    {
1620
        $oldX = $x;
1621
        $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...
1622
        if ($this->orientacao == 'P') {
1623
            $maxW = $this->wPrint;
1624
        } else {
1625
            $maxW = $this->wPrint - $this->wCanhoto;
1626
        }
1627
        $w = $maxW;
1628
        $h = 10;
1629
        $texto = 'TOMADOR DO SERVIÇO';
1630
        $aFont = $this->formatPadrao;
1631
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1632
        $aFont = $this->formatNegrito;
1633
        $texto = $this->pSimpleGetValue($this->toma, "xNome");
1634
        $this->pTextBox($x + 29, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1635
        $x = $maxW * 0.60;
1636
        $texto = 'MUNICÍPIO';
1637
        $aFont = $this->formatPadrao;
1638
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1639
        $texto = $this->pSimpleGetValue($this->toma, "xMun");
1640
        $aFont = $this->formatNegrito;
1641
        $this->pTextBox($x + 15, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1642
        $x = $maxW * 0.85;
1643
        $texto = 'UF';
1644
        $aFont = $this->formatPadrao;
1645
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1646
        $texto = $this->pSimpleGetValue($this->toma, "UF");
1647
        $aFont = $this->formatNegrito;
1648
        $this->pTextBox($x + 4, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1649
        $x = $w - 18;
1650
        $texto = 'CEP';
1651
        $aFont = $this->formatPadrao;
1652
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1653
        $texto = $this->pFormat($this->pSimpleGetValue($this->toma, "CEP"), "#####-###");
1654
        $aFont = $this->formatNegrito;
1655
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1656
        $y += 3;
1657
        $x = $oldX;
1658
        $texto = 'ENDEREÇO';
1659
        $aFont = $this->formatPadrao;
1660
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1661
        $aFont = $this->formatNegrito;
1662
        $texto = $this->pSimpleGetValue($this->toma, "xLgr") . ',';
1663
        $texto .= $this->pSimpleGetValue($this->toma, "nro");
1664
        $texto .= ($this->pSimpleGetValue($this->toma, "xCpl") != "") ?
1665
            ' - ' . $this->pSimpleGetValue($this->toma, "xCpl") : '';
1666
        $texto .= ' - ' . $this->pSimpleGetValue($this->toma, "xBairro");
1667
        $this->pTextBox($x + 16, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1668
        $y += 3;
1669
        $texto = 'CNPJ/CPF';
1670
        $aFont = $this->formatPadrao;
1671
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1672
        $texto = $this->zFormatCNPJCPF($this->toma);
1673
        $aFont = $this->formatNegrito;
1674
        $this->pTextBox($x + 13, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1675
        $x = $x + 65;
1676
        $texto = 'INSCRIÇÃO ESTADUAL';
1677
        $aFont = $this->formatPadrao;
1678
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1679
        $texto = $this->pSimpleGetValue($this->toma, "IE");
1680
        $aFont = $this->formatNegrito;
1681
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1682
        $x = $w * 0.75;
1683
        $texto = 'PAÍS';
1684
        $aFont = $this->formatPadrao;
1685
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1686
        $texto = $this->pSimpleGetValue($this->toma, "xPais") != "" ?
1687
            $this->pSimpleGetValue($this->toma, "xPais") : 'BRASIL';
1688
        $aFont = $this->formatNegrito;
1689
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1690
        $x = $w - 27;
1691
        $texto = 'FONE';
1692
        $aFont = $this->formatPadrao;
1693
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1694
        $texto = $this->pSimpleGetValue($this->toma, "fone")!=""? $this->zFormatFone($this->toma):'';
1695
        $aFont = $this->formatNegrito;
1696
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1697
    } //fim da função tomadorDACTE
1698
1699
    /**
1700
     * zDescricaoCarga
1701
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1702
     *
1703
     * @param  number $x Posição horizontal canto esquerdo
1704
     * @param  number $y Posição vertical canto superior
1705
     * @return number Posição vertical final
1706
     */
1707
    protected function zDescricaoCarga($x = 0, $y = 0)
1708
    {
1709
        $oldX = $x;
1710
        $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...
1711
        if ($this->orientacao == 'P') {
1712
            $maxW = $this->wPrint;
1713
        } else {
1714
            $maxW = $this->wPrint - $this->wCanhoto;
1715
        }
1716
        $w = $maxW;
1717
        $h = 17;
1718
        $texto = 'PRODUTO PREDOMINANTE';
1719
        $aFont = array(
1720
            'font' => $this->fontePadrao,
1721
            'size' => 6,
1722
            'style' => '');
1723
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1724
        $texto = $this->pSimpleGetValue($this->infCarga, "proPred");
1725
        $aFont = $this->formatNegrito;
1726
        $this->pTextBox($x, $y + 2.8, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1727
        $x = $w * 0.56;
1728
        $this->pdf->Line($x, $y, $x, $y + 8);
1729
        $aFont = $this->formatPadrao;
1730
        $texto = 'OUTRAS CARACTERÍSTICAS DA CARGA';
1731
        $this->pTextBox($x + 1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1732
        $texto = $this->pSimpleGetValue($this->infCarga, "xOutCat");
1733
        $aFont = $this->formatNegrito;
1734
        $this->pTextBox($x + 1, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1735
        $x = $w * 0.8;
1736
        $this->pdf->Line($x, $y, $x, $y + 8);
1737
        $aFont = $this->formatPadrao;
1738
        $texto = 'VALOR TOTAL DA CARGA';
1739
        $this->pTextBox($x + 1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1740
        $texto = $this->pSimpleGetValue($this->infCarga, "vCarga") == "" ?
1741
            $this->pSimpleGetValue($this->infCarga, "vMerc") : $this->pSimpleGetValue($this->infCarga, "vCarga");
1742
        $texto = number_format($texto, 2, ",", ".");
1743
        $aFont = $this->formatNegrito;
1744
        $this->pTextBox($x + 1, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1745
        $y += 8;
1746
        $x = $oldX;
1747
        $this->pdf->Line($x, $y, $w + 1, $y);
1748
        //Identifica código da unidade
1749
        //01 = KG (QUILOS)
1750
        if ($this->pSimpleGetValue($this->infQ->item(0), "cUnid") == '01') {
1751
            $qCarga = $this->pSimpleGetValue($this->infQ->item(0), "qCarga");
1752
        } elseif ($this->pSimpleGetValue($this->infQ->item(1), "cUnid") == '01') {
1753
            $qCarga = $this->pSimpleGetValue($this->infQ->item(1), "qCarga");
1754
        } elseif ($this->pSimpleGetValue($this->infQ->item(2), "cUnid") == '01') {
1755
            $qCarga = $this->pSimpleGetValue($this->infQ->item(2), "qCarga");
1756
        }
1757
        $texto = 'PESO BRUTO (KG)';
1758
        $aFont = array(
1759
            'font' => $this->fontePadrao,
1760
            'size' => 5,
1761
            'style' => '');
1762
        $this->pTextBox($x+8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1763
        $texto = number_format($qCarga, 3, ",", ".");
0 ignored issues
show
Bug introduced by
The variable $qCarga 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...
1764
        $aFont = array(
1765
            'font' => $this->fontePadrao,
1766
            'size' => 7,
1767
            'style' => 'B');
1768
        $this->pTextBox($x+2, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1769
        $x = $w * 0.12;
1770
        $this->pdf->Line($x+13.5, $y, $x+13.5, $y + 9);
1771
        $texto = 'PESO BASE CÁLCULO (KG)';
1772
        $aFont = array(
1773
            'font' => $this->fontePadrao,
1774
            'size' => 5,
1775
            'style' => '');
1776
        $this->pTextBox($x+20, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1777
        $texto = number_format($qCarga, 3, ",", ".");
1778
        $aFont = array(
1779
            'font' => $this->fontePadrao,
1780
            'size' => 7,
1781
            'style' => 'B');
1782
        $this->pTextBox($x+17, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1783
        $x = $w * 0.24;
1784
        $this->pdf->Line($x+25, $y, $x+25, $y + 9);
1785
        $texto = 'PESO AFERIDO (KG)';
1786
        $aFont = array(
1787
            'font' => $this->fontePadrao,
1788
            'size' => 5,
1789
            'style' => '');
1790
        $this->pTextBox($x+35, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1791
        $texto = number_format($qCarga, 3, ",", ".");
1792
        $aFont = array(
1793
            'font' => $this->fontePadrao,
1794
            'size' => 7,
1795
            'style' => 'B');
1796
        $this->pTextBox($x+28, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1797
        $x = $w * 0.36;
1798
        $this->pdf->Line($x+41.3, $y, $x+41.3, $y + 9);
1799
        $texto = 'CUBAGEM(M3)';
1800
        $aFont = $this->formatPadrao;
1801
        $this->pTextBox($x+60, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1802
        $qCarga = '';
1803
        foreach ($this->infQ as $infQ) {
1804
            if ($this->pSimpleGetValue($infQ, "cUnid") == '00') {
1805
                $qCarga = $this->pSimpleGetValue($infQ, "qCarga");
1806
            }
1807
        }
1808
        $texto = !empty($qCarga) ? number_format($qCarga, 3, ",", ".") : '';
1809
        $aFont = array(
1810
            'font' => $this->fontePadrao,
1811
            'size' => 7,
1812
            'style' => 'B');
1813
        $this->pTextBox($x+50, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1814
        $x = $w * 0.45;
1815
        //$this->pdf->Line($x+37, $y, $x+37, $y + 9);
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
1816
        $texto = 'QTDE(VOL)';
1817
        $aFont = $this->formatPadrao;
1818
        $this->pTextBox($x+85, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1819
        $qCarga = '';
1820
        foreach ($this->infQ as $infQ) {
1821
            if ($this->pSimpleGetValue($infQ, "cUnid") == '03') {
1822
                $qCarga = $this->pSimpleGetValue($infQ, "qCarga");
1823
            }
1824
        }
1825
        $texto = !empty($qCarga) ? number_format($qCarga, 3, ",", ".") : '';
1826
        $aFont = array(
1827
            'font' => $this->fontePadrao,
1828
            'size' => 7,
1829
            'style' => 'B');
1830
        $this->pTextBox($x+85, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1831
        $x = $w * 0.53;
1832
        $this->pdf->Line($x+56, $y, $x+56, $y + 9);
1833
        /*$texto = 'NOME DA SEGURADORA';
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
1834
        $aFont = $this->formatPadrao;
1835
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1836
        $texto = $this->pSimpleGetValue($this->seg, "xSeg");
1837
        $aFont = array(
1838
            'font' => $this->fontePadrao,
1839
            'size' => 7,
1840
            'style' => 'B');
1841
        $this->pTextBox($x + 31, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1842
        $y += 3;
1843
        $this->pdf->Line($x, $y, $w + 1, $y);
1844
        $texto = 'RESPONSÁVEL';
1845
        $aFont = $this->formatPadrao;
1846
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1847
        $texto = $this->respSeg;
1848
        $aFont = array(
1849
            'font' => $this->fontePadrao,
1850
            'size' => 7,
1851
            'style' => 'B');
1852
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1853
        $x = $w * 0.68;
1854
        $this->pdf->Line($x, $y, $x, $y + 6);
1855
        $texto = 'NÚMERO DA APOLICE';
1856
        $aFont = $this->formatPadrao;
1857
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1858
        $texto = $this->pSimpleGetValue($this->seg, "nApol");
1859
        $aFont = array(
1860
            'font' => $this->fontePadrao,
1861
            'size' => 7,
1862
            'style' => 'B');
1863
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1864
        $x = $w * 0.85;
1865
        $this->pdf->Line($x, $y, $x, $y + 6);
1866
        $texto = 'NÚMERO DA AVERBAÇÃO';
1867
        $aFont = $this->formatPadrao;
1868
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1869
        $texto = $this->pSimpleGetValue($this->seg, "nAver");
1870
        $aFont = array(
1871
            'font' => $this->fontePadrao,
1872
            'size' => 7,
1873
            'style' => 'B');
1874
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');*/
1875
    } //fim da função zDescricaoCarga
1876
1877
    /**
1878
     * zCompValorServ
1879
     * Monta o campo com os componentes da prestação de serviços.
1880
     *
1881
     * @param  number $x Posição horizontal canto esquerdo
1882
     * @param  number $y Posição vertical canto superior
1883
     * @return number Posição vertical final
1884
     */
1885
    protected function zCompValorServ($x = 0, $y = 0)
1886
    {
1887
        $oldX = $x;
1888
        $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...
1889
        if ($this->orientacao == 'P') {
1890
            $maxW = $this->wPrint;
1891
        } else {
1892
            $maxW = $this->wPrint - $this->wCanhoto;
1893
        }
1894
        $w = $maxW;
1895
        $h = 25;
1896
        $texto = 'COMPONENTES DO VALOR DA PRESTAÇÃO DO SERVIÇO';
1897
        $aFont = $this->formatPadrao;
1898
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1899
        $y += 3.4;
1900
        $this->pdf->Line($x, $y, $w + 1, $y);
1901
        $texto = 'NOME';
1902
        $aFont = $this->formatPadrao;
1903
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1904
        $yIniDados = $y;
1905
        $x = $w * 0.14;
1906
        $texto = 'VALOR';
1907
        $aFont = $this->formatPadrao;
1908
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1909
        $x = $w * 0.28;
1910
        $this->pdf->Line($x, $y, $x, $y + 21.5);
1911
        $texto = 'NOME';
1912
        $aFont = $this->formatPadrao;
1913
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1914
        $x = $w * 0.42;
1915
        $texto = 'VALOR';
1916
        $aFont = $this->formatPadrao;
1917
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1918
        $x = $w * 0.56;
1919
        $this->pdf->Line($x, $y, $x, $y + 21.5);
1920
        $texto = 'NOME';
1921
        $aFont = $this->formatPadrao;
1922
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1923
        $x = $w * 0.70;
1924
        $texto = 'VALOR';
1925
        $aFont = $this->formatPadrao;
1926
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1927
        $x = $w * 0.86;
1928
        $this->pdf->Line($x, $y, $x, $y + 21.5);
1929
        $y += 1;
1930
        $texto = 'VALOR TOTAL DO SERVIÇO';
1931
        $aFont = $this->formatPadrao;
1932
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1933
        $texto = number_format($this->pSimpleGetValue($this->vPrest, "vTPrest"), 2, ",", ".");
1934
        $aFont = array(
1935
            'font' => $this->fontePadrao,
1936
            'size' => 9,
1937
            'style' => 'B');
1938
        $this->pTextBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1939
        $y += 10;
1940
        $this->pdf->Line($x, $y, $w + 1, $y);
1941
        $y += 1;
1942
        $texto = 'VALOR A RECEBER';
1943
        $aFont = $this->formatPadrao;
1944
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1945
        $texto = number_format($this->pSimpleGetValue($this->vPrest, "vRec"), 2, ",", ".");
1946
        $aFont = array(
1947
            'font' => $this->fontePadrao,
1948
            'size' => 9,
1949
            'style' => 'B');
1950
        $this->pTextBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1951
        $auxX = $oldX;
1952
        $yIniDados += 4;
1953
        foreach ($this->Comp as $k => $d) {
1954
            $nome = $this->Comp->item($k)->getElementsByTagName('xNome')->item(0)->nodeValue;
1955
            $valor = number_format(
1956
                $this->Comp->item($k)->getElementsByTagName('vComp')->item(0)->nodeValue,
1957
                2,
1958
                ",",
1959
                "."
1960
            );
1961
            if ($auxX > $w * 0.60) {
1962
                $yIniDados = $yIniDados + 4;
1963
                $auxX = $oldX;
1964
            }
1965
            $texto = $nome;
1966
            $aFont = $this->formatPadrao;
1967
            $this->pTextBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1968
            $auxX += $w * 0.14;
1969
            $texto = $valor;
1970
            $aFont = $this->formatPadrao;
1971
            $this->pTextBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1972
            $auxX += $w * 0.14;
1973
        }
1974
    } //fim da função compValorDACTE
1975
1976
    /**
1977
     * zImpostos
1978
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1979
     *
1980
     * @param  number $x Posição horizontal canto esquerdo
1981
     * @param  number $y Posição vertical canto superior
1982
     * @return number Posição vertical final
1983
     */
1984
    protected function zImpostos($x = 0, $y = 0)
1985
    {
1986
        $oldX = $x;
1987
        $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...
1988
        if ($this->orientacao == 'P') {
1989
            $maxW = $this->wPrint;
1990
        } else {
1991
            $maxW = $this->wPrint - $this->wCanhoto;
1992
        }
1993
        $w = $maxW;
1994
        $h = 13;
1995
        $texto = 'INFORMAÇÕES RELATIVAS AO IMPOSTO';
1996
        $aFont = $this->formatPadrao;
1997
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1998
1999
        $y += 3.4;
2000
        $this->pdf->Line($x, $y, $w + 1, $y);
2001
        $texto = 'SITUAÇÃO TRIBUTÁRIA';
2002
        $aFont = $this->formatPadrao;
2003
        $this->pTextBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
2004
2005
        $x += $w * 0.26;
2006
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2007
        $texto = 'BASE DE CALCULO';
2008
        $aFont = $this->formatPadrao;
2009
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
2010
2011
        $wCol02=0.15;
2012
        $x += $w * $wCol02;
2013
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2014
        $texto = 'ALÍQ ICMS';
2015
        $aFont = $this->formatPadrao;
2016
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2017
2018
        $x += $w * $wCol02;
2019
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2020
        $texto = 'VALOR ICMS';
2021
        $aFont = $this->formatPadrao;
2022
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2023
2024
        $x += $w * $wCol02;
2025
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2026
        $texto = '% RED. BC ICMS';
2027
        $aFont = $this->formatPadrao;
2028
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2029
2030
        $x += $w * $wCol02;
2031
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2032
        $texto = 'VALOR ICMS ST';
2033
        $aFont = $this->formatPadrao;
2034
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2035
2036
        /*$x += $w * 0.14;
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2037
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2038
        $texto = 'ICMS ST';
2039
        $aFont = $this->formatPadrao;
2040
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
2041
         * */
2042
2043
        $x = $oldX;
2044
        $y = $y + 4;
2045
        $texto = $this->pSimpleGetValue($this->ICMS, "CST");
2046
        switch ($texto) {
2047
            case '00':
2048
                $texto = "00 - Tributação normal ICMS";
2049
                break;
2050
            case '20':
2051
                $texto = "20 - Tributação com BC reduzida do ICMS";
2052
                break;
2053
            case '40':
2054
                $texto = "40 - ICMS isenção";
2055
                break;
2056
            case '41':
2057
                $texto = "41 - ICMS não tributada";
2058
                break;
2059
            case '51':
2060
                $texto = "51 - ICMS diferido";
2061
                break;
2062
            case '60':
2063
                $texto = "60 - ICMS cobrado anteriormente por substituição tributária";
2064
                break;
2065
            case '90':
2066
                if ($this->ICMSOutraUF) {
2067
                    $texto = "90 - ICMS Outra UF";
2068
                } else {
2069
                    $texto = "90 - ICMS Outros";
2070
                }
2071
                break;
2072
        }
2073
        if ($this->pSimpleGetValue($this->ICMS, "CST") == '60') {
2074
            $aFont = $this->formatNegrito;
2075
            $this->pTextBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
2076
            $x += $w * 0.26;
2077
2078
            $texto = !empty($this->ICMS->getElementsByTagName("vBCSTRet")->item(0)->nodeValue) ?
2079
                number_format($this->pSimpleGetValue($this->ICMS, "vBCSTRet"), 2, ",", ".") : (
2080
                    !empty($this->ICMS->getElementsByTagName("vBCOutraUF")->item(0)->nodeValue) ?
2081
                    number_format($this->pSimpleGetValue($this->ICMS, "vBCOutraUF"), 2, ",", ".") : ''
2082
                );
2083
            $aFont = $this->formatNegrito;
2084
            $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2085
            $x += $w * $wCol02;
2086
2087
            $texto = !empty($this->ICMS->getElementsByTagName("pICMSSTRet")->item(0)->nodeValue) ?
2088
                number_format($this->pSimpleGetValue($this->ICMS, "pICMSSTRet"), 2, ",", ".") : (
2089
                    !empty($this->ICMS->getElementsByTagName("pICMSOutraUF")->item(0)->nodeValue) ?
2090
                    number_format($this->pSimpleGetValue($this->ICMS, "pICMSOutraUF"), 2, ",", ".") : ''
2091
                );
2092
            $aFont = $this->formatNegrito;
2093
            $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2094
            $x += $w * $wCol02;
2095
2096
            $texto = !empty($this->ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue) ?
2097
                number_format($this->pSimpleGetValue($this->ICMS, "vICMS"), 2, ",", ".") : (
2098
                    !empty($this->ICMS->getElementsByTagName("vICMSOutraUF")->item(0)->nodeValue) ?
2099
                    number_format($this->pSimpleGetValue($this->ICMS, "vICMSOutraUF"), 2, ",", ".") : ''
2100
                );
2101
            $aFont = $this->formatNegrito;
2102
            $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2103
            $x += $w * $wCol02;
2104
2105
            $texto = !empty($this->ICMS->getElementsByTagName("pRedBC")->item(0)->nodeValue) ?
2106
                number_format($this->pSimpleGetValue($this->ICMS, "pRedBC"), 2, ",", ".") : (
2107
                    !empty($this->ICMS->getElementsByTagName("pRedBCOutraUF")->item(0)->nodeValue) ?
2108
                number_format($this->pSimpleGetValue($this->ICMS, "pRedBCOutraUF"), 2, ",", ".") : ''
2109
                );
2110
            $aFont = $this->formatNegrito;
2111
            $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2112
            $x += $w * $wCol02;
2113
2114
            $texto = !empty($this->ICMS->getElementsByTagName("vICMSSTRet")->item(0)->nodeValue) ?
2115
                number_format($this->pSimpleGetValue($this->ICMS, "vICMSSTRet"), 2, ",", ".") : '';
2116
            $aFont = $this->formatNegrito;
2117
            $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2118
        } else {
2119
            $texto = $this->pSimpleGetValue($this->ICMSSN, "indSN") == 1 ? 'Simples Nacional' : $texto;
2120
            $aFont = $this->formatNegrito;
2121
            $this->pTextBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
2122
            $x += $w * 0.26;
2123
2124
            $texto = !empty($this->ICMS->getElementsByTagName("vBC")->item(0)->nodeValue) ?
2125
                number_format($this->pSimpleGetValue($this->ICMS, "vBC"), 2, ",", ".") : (
2126
                    !empty($this->ICMS->getElementsByTagName("vBCOutraUF")->item(0)->nodeValue) ?
2127
                    number_format($this->pSimpleGetValue($this->ICMS, "vBCOutraUF"), 2, ",", ".") : ''
2128
                );
2129
            $aFont = $this->formatNegrito;
2130
            $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2131
            $x += $w * $wCol02;
2132
2133
            $texto = !empty($this->ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue) ?
2134
                number_format($this->pSimpleGetValue($this->ICMS, "pICMS"), 2, ",", ".") : (
2135
                    !empty($this->ICMS->getElementsByTagName("pICMSOutraUF")->item(0)->nodeValue) ?
2136
                    number_format($this->pSimpleGetValue($this->ICMS, "pICMSOutraUF"), 2, ",", ".") : ''
2137
                );
2138
            $aFont = $this->formatNegrito;
2139
            $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2140
            $x += $w * $wCol02;
2141
2142
            $texto = !empty($this->ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue) ?
2143
                number_format($this->pSimpleGetValue($this->ICMS, "vICMS"), 2, ",", ".") : (
2144
                    !empty($this->ICMS->getElementsByTagName("vICMSOutraUF")->item(0)->nodeValue) ?
2145
                    number_format($this->pSimpleGetValue($this->ICMS, "vICMSOutraUF"), 2, ",", ".") : ''
2146
                );
2147
            $aFont = $this->formatNegrito;
2148
            $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2149
            $x += $w * $wCol02;
2150
2151
            $texto = !empty($this->ICMS->getElementsByTagName("pRedBC")->item(0)->nodeValue) ?
2152
                number_format($this->pSimpleGetValue($this->ICMS, "pRedBC"), 2, ",", ".") : (
2153
                    !empty($this->ICMS->getElementsByTagName("pRedBCOutraUF")->item(0)->nodeValue) ?
2154
                number_format($this->pSimpleGetValue($this->ICMS, "pRedBCOutraUF"), 2, ",", ".") : ''
2155
                );
2156
            $aFont = $this->formatNegrito;
2157
            $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2158
            $x += $w * $wCol02;
2159
2160
            $texto = !empty($this->ICMS->getElementsByTagName("vICMSSTRet")->item(0)->nodeValue) ?
2161
                number_format($this->pSimpleGetValue($this->ICMS, "vICMSSTRet"), 2, ",", ".") : '';
2162
            $aFont = $this->formatNegrito;
2163
            $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2164
        }
2165
2166
        /*$x += $w * 0.14;
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2167
        $texto = '';
2168
        $aFont = $this->formatNegrito;
2169
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');*/
2170
    } //fim da função compValorDACTE
2171
2172
    /**
2173
     * zGeraChaveAdicCont
2174
     *
2175
     * @return string chave
2176
     */
2177
    protected function zGeraChaveAdicCont()
2178
    {
2179
        //cUF tpEmis CNPJ vNF ICMSp ICMSs DD  DV
2180
        // Quantidade de caracteres  02   01      14  14    01    01  02 01
0 ignored issues
show
Unused Code Comprehensibility introduced by
37% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2181
        $forma = "%02d%d%s%014d%01d%01d%02d";
2182
        $cUF = $this->ide->getElementsByTagName('cUF')->item(0)->nodeValue;
2183
        $CNPJ = "00000000000000" . $this->emit->getElementsByTagName('CNPJ')->item(0)->nodeValue;
2184
        $CNPJ = substr($CNPJ, -14);
2185
        $vCT = number_format($this->pSimpleGetValue($this->vPrest, "vRec"), 2, "", "") * 100;
2186
        $ICMS_CST = $this->pSimpleGetValue($this->ICMS, "CST");
2187
        switch ($ICMS_CST) {
2188
            case '00':
2189
            case '20':
2190
                $ICMSp = '1';
2191
                $ICMSs = '2';
2192
                break;
2193
            case '40':
2194
            case '41':
2195
            case '51':
2196
            case '90':
2197
                $ICMSp = '2';
2198
                $ICMSs = '2';
2199
                break;
2200
            case '60':
2201
                $ICMSp = '2';
2202
                $ICMSs = '1';
2203
                break;
2204
        }
2205
        $dd = $this->ide->getElementsByTagName('dEmi')->item(0)->nodeValue;
2206
        $rpos = strrpos($dd, '-');
2207
        $dd = substr($dd, $rpos + 1);
2208
        $chave = sprintf($forma, $cUF, $this->tpEmis, $CNPJ, $vCT, $ICMSp, $ICMSs, $dd);
0 ignored issues
show
Bug introduced by
The variable $ICMSp 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 $ICMSs 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...
2209
        $chave = $chave . $this->pModulo11($chave);
2210
        return $chave;
2211
    } //fim zGeraChaveAdicCont
2212
2213
    /**
2214
     * zDocOrig
2215
     * Monta o campo com os documentos originarios.
2216
     *
2217
     * @param  number $x Posição horizontal canto esquerdo
2218
     * @param  number $y Posição vertical canto superior
2219
     * @return number Posição vertical final
2220
     */
2221
    protected function zDocOrig($x = 0, $y = 0)
2222
    {
2223
        $oldX = $x;
2224
        $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...
2225
        if ($this->orientacao == 'P') {
2226
            $maxW = $this->wPrint;
2227
        } else {
2228
            $maxW = $this->wPrint - $this->wCanhoto;
2229
        }
2230
        $w = $maxW;
2231
2232
        // SE FOR RODOVIARIO ( BTR-SEMPRE SERÁ )
2233
        if ($this->modal == '1') {
2234
            // 0 - Não; 1 - Sim Será lotação quando houver um único conhecimento de transporte por veículo,
2235
            // ou combinação veicular, e por viagem
2236
            $h = $this->lota == 1 ? 35 : 53;
2237
        } elseif ($this->modal == '2') {
2238
            $h = 53;
2239
        } elseif ($this->modal == '3') {
2240
            $h = 37.6;
2241
        } else {
2242
            $h = 35;
2243
        }
2244
        $texto = 'DOCUMENTOS ORIGINÁRIOS';
2245
        $aFont = $this->formatPadrao;
2246
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2247
        $descr1 = 'TIPO DOC';
2248
        $descr2 = 'CNPJ/CHAVE/OBS';
2249
        $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2250
2251
        $y += 3.4;
2252
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA ABAIXO DO TEXTO: "DOCUMENTOS ORIGINÁRIOS
2253
        $texto = $descr1;
2254
        $aFont = $this->formatPadrao;
2255
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2256
        $yIniDados = $y;
2257
2258
        $x += $w * 0.07;
2259
        $texto = $descr2;
2260
        $aFont = $this->formatPadrao;
2261
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2262
2263
        $x += $w * 0.28;
2264
        $texto = $descr3;
2265
        $aFont = $this->formatPadrao;
2266
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2267
2268
        $x += $w * 0.14;
2269
        if ($this->modal == '1') {
2270
            if ($this->lota == 1) {
2271
                $this->pdf->Line($x, $y, $x, $y + 31.5); // TESTE
2272
            } else {
2273
                $this->pdf->Line($x, $y, $x, $y + 49.5); // TESTE
2274
            }
2275
        } elseif ($this->modal == '2') {
2276
            $this->pdf->Line($x, $y, $x, $y + 49.5);
2277
        } elseif ($this->modal == '3') {
2278
            $this->pdf->Line($x, $y, $x, $y + 34.1);
2279
        } else {
2280
            $this->pdf->Line($x, $y, $x, $y + 21.5);
2281
        }
2282
        $texto = $descr1;
2283
        $aFont = $this->formatPadrao;
2284
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2285
2286
        $x += $w * 0.08;
2287
        $texto = $descr2;
2288
        $aFont = $this->formatPadrao;
2289
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2290
2291
        $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2292
        $texto = $descr3;
2293
        $aFont = $this->formatPadrao;
2294
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2295
        $auxX = $oldX;
2296
        $yIniDados += 3;
2297
        foreach ($this->infNF as $k => $d) {
2298
            $mod = $this->infNF->item($k)->getElementsByTagName('mod');
2299
            $tp = ($mod && $mod->length > 0) ? $mod->item(0)->nodeValue : '';
2300
            $cnpj = $this->zFormatCNPJCPF($this->rem);
0 ignored issues
show
Documentation introduced by
$this->rem is of type object<DOMNode>, but the function expects a string.

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

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

We suggest to add an explicit type cast like 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
            $doc = $this->infNF->item($k)->getElementsByTagName('serie')->item(0)->nodeValue;
2302
            $doc .= '/' . $this->infNF->item($k)->getElementsByTagName('nDoc')->item(0)->nodeValue;
2303
            if ($auxX > $w * 0.90) {
2304
                $yIniDados = $yIniDados + 3;
2305
                $auxX = $oldX;
2306
            }
2307
            $texto = $tp;
2308
            $aFont = array(
2309
                'font' => $this->fontePadrao,
2310
                'size' => 8,
2311
                'style' => '');
2312
            //$this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Unused Code Comprehensibility introduced by
66% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2313
            $this->pTextBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2314
            //$auxX += $w * 0.09;
0 ignored issues
show
Unused Code Comprehensibility introduced by
37% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2315
            $auxX += $w * 0.07;
2316
            $texto = $cnpj;
2317
            $aFont = array(
2318
                'font' => $this->fontePadrao,
2319
                'size' => 8,
2320
                'style' => '');
2321
            $this->pTextBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2322
            $auxX += $w * 0.28;
2323
            $texto = $doc;
2324
            $aFont = array(
2325
                'font' => $this->fontePadrao,
2326
                'size' => 8,
2327
                'style' => '');
2328
            $this->pTextBox($auxX, $yIniDados, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2329
            $auxX += $w * 0.15;
2330
        }
2331
2332
        foreach ($this->infNFe as $k => $d) {
2333
            $chaveNFe = $this->infNFe->item($k)->getElementsByTagName('chave')->item(0)->nodeValue;
2334
            $this->arrayNFe[] = $chaveNFe;
2335
        }
2336
        $qtdeNFe = 1;
2337
        if (count($this->arrayNFe) >15) {
2338
            $this->flagDocOrigContinuacao = 1;
2339
            $qtdeNFe = count($this->arrayNFe);
2340
        }
2341
//        $totPag = count($this->arrayNFe) > 15 ? '2' : '1';
0 ignored issues
show
Unused Code Comprehensibility introduced by
46% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2342
        switch ($qtdeNFe) {
2343
            default:
2344
                $this->totPag = 1;
2345
            case ($qtdeNFe >= 1044):
2346
                $this->totPag = 11;
2347
                break;
2348
            case ($qtdeNFe > 928):
2349
                $this->totPag = 10;
2350
                break;
2351
            case ($qtdeNFe > 812):
2352
                $this->totPag = 9;
2353
                break;
2354
            case ($qtdeNFe > 696):
2355
                $this->totPag = 8;
2356
                break;
2357
            case ($qtdeNFe > 580):
2358
                $this->totPag = 7;
2359
                break;
2360
            case ($qtdeNFe > 464):
2361
                $this->totPag = 6;
2362
                break;
2363
            case ($qtdeNFe > 348):
2364
                $this->totPag = 5;
2365
                break;
2366
            case ($qtdeNFe > 232):
2367
                $this->totPag = 4;
2368
                break;
2369
            case ($qtdeNFe > 116):
2370
                $this->totPag = 3;
2371
                break;
2372
            case ($qtdeNFe > 16):
2373
                $this->totPag = 2;
2374
                break;
2375
            case ($qtdeNFe <= 16):
2376
                $this->totPag = 1;
2377
                break;
2378
        }
2379
        $r = $this->zCabecalho(1, 1, '1', $this->totPag);
0 ignored issues
show
Unused Code introduced by
$r 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...
2380
        $contador = 0;
2381
        while ($contador < count($this->arrayNFe)) {
2382
            if ($contador == 15) {
2383
                break;
2384
            }
2385
            $tp = 'NF-e';
2386
            $chaveNFe = $this->arrayNFe[$contador];
2387
            $numNFe = substr($chaveNFe, 25, 9);
2388
            $serieNFe = substr($chaveNFe, 22, 3);
2389
            $doc = $serieNFe . '/' . $numNFe;
2390
            if ($auxX > $w * 0.90) {
2391
                $yIniDados = $yIniDados + 3.5;
2392
                $auxX = $oldX;
2393
            }
2394
            $texto = $tp;
2395
            $aFont = array(
2396
                'font' => $this->fontePadrao,
2397
                'size' => 7,
2398
                'style' => '');
2399
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2400
            $auxX += $w * 0.07;
2401
            $texto = $chaveNFe;
2402
            $aFont = array(
2403
                'font' => $this->fontePadrao,
2404
                'size' => 7,
2405
                'style' => '');
2406
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2407
            $auxX += $w * 0.28;
2408
            $texto = $doc;
2409
            $aFont = array(
2410
                'font' => $this->fontePadrao,
2411
                'size' => 7,
2412
                'style' => '');
2413
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2414
            $auxX += $w * 0.15;
2415
            $contador++;
2416
        }
2417
2418
        foreach ($this->infOutros as $k => $d) {
2419
            $temp = $this->infOutros->item($k);
2420
            $tpDoc = $this->pSimpleGetValue($temp, "tpDoc");
2421
            $descOutros = $this->pSimpleGetValue($temp, "descOutros");
2422
            $nDoc = $this->pSimpleGetValue($temp, "nDoc");
2423
            $dEmi = $this->pSimpleGetDate($temp, "dEmi", "Emissão: ");
2424
            $vDocFisc = $this->pSimpleGetValue($temp, "vDocFisc", "Valor: ");
2425
            $dPrev = $this->pSimpleGetDate($temp, "dPrev", "Entrega: ");
2426
            switch ($tpDoc) {
2427
                case "00":
2428
                    $tpDoc = "00 - Declaração";
2429
                    break;
2430
                case "10":
2431
                    $tpDoc = "10 - Dutoviário";
2432
                    break;
2433
                case "99":
2434
                    $tpDoc = "99 - Outros: [" . $descOutros . "]";
2435
                    break;
2436
                default:
2437
                    break;
2438
            }
2439
            $numeroDocumento = $nDoc;
0 ignored issues
show
Unused Code introduced by
$numeroDocumento 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...
2440
            $cnpjChave = $dEmi . " " . $vDocFisc . " " . $dPrev;
2441
            if ($auxX > $w * 0.90) {
2442
                $yIniDados = $yIniDados + 4;
2443
                $auxX = $oldX;
2444
            }
2445
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $tpDoc, $aFont, 'T', 'L', 0, '');
2446
            $auxX += $w * 0.09;
2447
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $cnpjChave, $aFont, 'T', 'L', 0, '');
2448
            $auxX += $w * 0.28;
2449
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $nDoc, $aFont, 'T', 'L', 0, '');
2450
            $auxX += $w * 0.14;
2451
        }
2452
        foreach ($this->idDocAntEle as $k => $d) {
2453
            $tp = 'CT-e';
2454
            $chaveCTe = $this->idDocAntEle->item($k)->getElementsByTagName('chave')->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The method item cannot be called on $this->idDocAntEle (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
2455
            $numCTe = substr($chaveCTe, 25, 9);
2456
            $serieCTe = substr($chaveCTe, 22, 3);
2457
            $doc = $serieCTe . '/' . $numCTe;
2458
            if ($auxX > $w * 0.90) {
2459
                $yIniDados = $yIniDados + 4;
2460
                $auxX = $oldX;
2461
            }
2462
            $texto = $tp;
2463
            $aFont = array(
2464
                'font' => $this->fontePadrao,
2465
                'size' => 8,
2466
                'style' => '');
2467
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2468
            $auxX += $w * 0.09;
2469
            $texto = $chaveCTe;
2470
            $aFont = array(
2471
                'font' => $this->fontePadrao,
2472
                'size' => 8,
2473
                'style' => '');
2474
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2475
            $auxX += $w * 0.28;
2476
            $texto = $doc;
2477
            $aFont = array(
2478
                'font' => $this->fontePadrao,
2479
                'size' => 8,
2480
                'style' => '');
2481
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2482
            $auxX += $w * 0.14;
2483
        }
2484
    } //fim da função zDocOrig
2485
2486
    /**
2487
     * zDocOrigContinuacao
2488
     * Monta o campo com os documentos originarios.
2489
     *
2490
     * @param  number $x Posição horizontal canto esquerdo
2491
     * @param  number $y Posição vertical canto superior
2492
     * @return number Posição vertical final
2493
     */
2494
    protected function zDocOrigContinuacao($x = 0, $y = 0)
2495
    {
2496
        $x2 = $x;
2497
        $y2 = $y;
2498
        $contador = 16;
2499
        for ($i = 2; $i <= $this->totPag; $i++) {
2500
            $x = $x2;
2501
            $y = $y2;
2502
            $this->pdf->AddPage($this->orientacao, $this->papel);
2503
            $r = $this->zCabecalho(1, 1, $i, $this->totPag);
0 ignored issues
show
Unused Code introduced by
$r 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...
2504
            $oldX = $x;
2505
            $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...
2506
            if ($this->orientacao == 'P') {
2507
                $maxW = $this->wPrint;
2508
            } else {
2509
                $maxW = $this->wPrint - $this->wCanhoto;
2510
            }
2511
            $w = $maxW;
2512
2513
            //$h = 6; // de sub-titulo
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2514
            //$h = 6 + 3; // de altura do texto (primeira linha
0 ignored issues
show
Unused Code Comprehensibility introduced by
37% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2515
            //$h = 9 + 3.5 ;// segunda linha
0 ignored issues
show
Unused Code Comprehensibility introduced by
37% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2516
            //$h = 9 + 3.5+ 3.5 ;// segunda linha
0 ignored issues
show
Unused Code Comprehensibility introduced by
36% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2517
            $h = (( ( count($this->arrayNFe)/2 ) - 9) * 3.5)+9;
2518
            if (count($this->arrayNFe)%2 !=0) {
2519
                $h = $h+3.5;
2520
            } // Caso tenha apenas 1 registro na ultima linha
2521
2522
            $texto = 'DOCUMENTOS ORIGINÁRIOS - CONTINUACÃO';
2523
            $aFont = $this->formatPadrao;
2524
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2525
            $descr1 = 'TIPO DOC';
2526
            $descr2 = 'CNPJ/CHAVE/OBS';
2527
            $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2528
2529
            $y += 3.4;
2530
            $this->pdf->Line($x, $y, $w + 1, $y);
2531
            $texto = $descr1;
2532
            $aFont = $this->formatPadrao;
2533
            $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2534
            $yIniDados = $y;
2535
2536
            $x += $w * 0.07; // COLUNA CNPJ/CHAVE/OBS
2537
            $texto = $descr2;
2538
            $aFont = $this->formatPadrao;
2539
            $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2540
2541
            $x += $w * 0.28;
2542
            $texto = $descr3;
2543
            $aFont = $this->formatPadrao;
2544
            $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2545
2546
            $x += $w * 0.14;
2547
            if ($this->modal == '1') {
2548
                if ($this->lota == 1) {
2549
                    $this->pdf->Line($x, $y, $x, $y + 31.5);
2550
                } else {
2551
                    $this->pdf->Line($x, $y, $x, $y + 49.5);
2552
                }
2553
            } elseif ($this->modal == '2') {
2554
                $this->pdf->Line($x, $y, $x, $y + 49.5);
2555
            } elseif ($this->modal == '3') {
2556
                $this->pdf->Line($x, $y, $x, $y + 34.1);
2557
            } else {
2558
                $this->pdf->Line($x, $y, $x, $y + 21.5);
2559
            }
2560
            $texto = $descr1;
2561
            $aFont = $this->formatPadrao;
2562
            $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2563
2564
            $x += $w * 0.08;
2565
            $texto = $descr2;
2566
            $aFont = $this->formatPadrao;
2567
            $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2568
2569
            $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2570
            $texto = $descr3;
2571
            $aFont = $this->formatPadrao;
2572
            $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2573
            $auxX = $oldX;
2574
            $yIniDados += 3;
2575
2576
            while ($contador < (count($this->arrayNFe))) {
2577
                if ($contador%(116*($i-1)) == 0) {
2578
//                    $contador++;
2579
                    break;
2580
                }
2581
                $tp = 'NF-e';
2582
                $chaveNFe = $this->arrayNFe[$contador];
2583
                $numNFe = substr($chaveNFe, 25, 9);
2584
                $serieNFe = substr($chaveNFe, 22, 3);
2585
                $doc = $serieNFe . '/' . $numNFe;
2586
                if ($auxX > $w * 0.90) {
2587
                    $yIniDados = $yIniDados + 3.5;
2588
                    $auxX = $oldX;
2589
                }
2590
                $texto = $tp;
2591
                $aFont = array(
2592
                    'font' => $this->fontePadrao,
2593
                    'size' => 7,
2594
                    'style' => '');
2595
                $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2596
                $auxX += $w * 0.07;
2597
                $texto = $chaveNFe;
2598
                $aFont = array(
2599
                    'font' => $this->fontePadrao,
2600
                    'size' => 7,
2601
                    'style' => '');
2602
                $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2603
                $auxX += $w * 0.28;
2604
                $texto = $doc;
2605
                $aFont = array(
2606
                    'font' => $this->fontePadrao,
2607
                    'size' => 7,
2608
                    'style' => '');
2609
                $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2610
                $auxX += $w * 0.15;
2611
                $contador++;
2612
            }
2613
        }
2614
    } //fim da função zDocOrigContinuacao
2615
2616
    /**
2617
     * zDocCompl
2618
     * Monta o campo com os dados do remetente na DACTE.
2619
     *
2620
     * @param number $x Posição horizontal canto esquerdo
2621
     * @param number $y Posição vertical canto superior
2622
     * @return number Posição vertical final
2623
     */
2624
    protected function zDocCompl($x = 0, $y = 0)
2625
    {
2626
        $oldX = $x;
2627
        $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...
2628
        if ($this->orientacao == 'P') {
2629
            $maxW = $this->wPrint;
2630
        } else {
2631
            $maxW = $this->wPrint - $this->wCanhoto;
2632
        }
2633
        $w = $maxW;
2634
        $h = 80;
2635
        if ($this->tpCTe == 1) {
2636
            $texto = 'DETALHAMENTO DO CT-E COMPLEMENTADO';
2637
            $descr1 = 'CHAVE DO CT-E COMPLEMENTADO';
2638
            $descr2 = 'VALOR COMPLEMENTADO';
2639
        } else {
2640
            $texto = 'DETALHAMENTO DO CT-E ANULADO';
2641
            $descr1 = 'CHAVE DO CT-E ANULADO';
2642
            $descr2 = 'VALOR ANULADO';
2643
        }
2644
2645
        $aFont = $this->formatPadrao;
2646
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2647
2648
        $y += 3.4;
2649
        $this->pdf->Line($x, $y, $w + 1, $y);
2650
        $texto = $descr1;
2651
        $aFont = $this->formatPadrao;
2652
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2653
        $yIniDados = $y;
2654
        $x += $w * 0.37;
2655
        $texto = $descr2;
2656
        $aFont = $this->formatPadrao;
2657
        $this->pTextBox($x - 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2658
        $x += $w * 0.13;
2659
        $this->pdf->Line($x, $y, $x, $y + 76.5);
2660
        $texto = $descr1;
2661
        $aFont = $this->formatPadrao;
2662
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2663
        $x += $w * 0.3;
2664
        $texto = $descr2;
2665
        $aFont = $this->formatPadrao;
2666
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2667
        $auxX = $oldX;
2668
        $yIniDados += 4;
2669
        if ($auxX > $w * 0.90) {
2670
            $yIniDados = $yIniDados + 4;
2671
            $auxX = $oldX;
2672
        }
2673
        $texto = $this->chaveCTeRef;
2674
        $aFont = array(
2675
            'font' => $this->fontePadrao,
2676
            'size' => 8,
2677
            'style' => '');
2678
        $this->pTextBox($auxX, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2679
        $texto = number_format($this->pSimpleGetValue($this->vPrest, "vTPrest"), 2, ",", ".");
2680
        $aFont = array(
2681
            'font' => $this->fontePadrao,
2682
            'size' => 8,
2683
            'style' => '');
2684
        $this->pTextBox($w * 0.40, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2685
    } //fim da função zDocCompl
2686
2687
    /**
2688
     * zObs
2689
     * Monta o campo com os dados do remetente na DACTE.
2690
     *
2691
     * @param  number $x Posição horizontal canto esquerdo
2692
     * @param  number $y Posição vertical canto superior
2693
     * @return number Posição vertical final
2694
     */
2695
    protected function zObs($x = 0, $y = 0)
2696
    {
2697
        $oldX = $x;
2698
        $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...
2699
        if ($this->orientacao == 'P') {
2700
            $maxW = $this->wPrint;
2701
        } else {
2702
            $maxW = $this->wPrint - $this->wCanhoto;
2703
        }
2704
        $w = $maxW;
2705
        //$h = 18;
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2706
        $h = 18.8;
2707
        $texto = 'OBSERVAÇÕES';
2708
        $aFont = $this->formatPadrao;
2709
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2710
        $y += 3.4;
2711
        $this->pdf->Line($x, $y, $w + 1, $y);
2712
        $auxX = $oldX;
0 ignored issues
show
Unused Code introduced by
$auxX 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...
2713
        $yIniDados = $y;
0 ignored issues
show
Unused Code introduced by
$yIniDados 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...
2714
        $texto = '';
2715
        foreach ($this->compl as $k => $d) {
2716
            $xObs = $this->pSimpleGetValue($this->compl->item($k), "xObs");
2717
            $texto .= $xObs;
2718
        }
2719
        $textoObs = explode("Motorista:", $texto);
2720
        $textoObs[1] = isset($textoObs[1]) ? "Motorista: ".$textoObs[1]: '';
2721
        $texto .= $this->pSimpleGetValue($this->imp, "infAdFisco", "\r\n");
2722
        $aFont = array(
2723
            'font' => $this->fontePadrao,
2724
            'size' => 7.5,
2725
            'style' => '');
2726
        $this->pTextBox($x, $y, $w, $h, $textoObs[0], $aFont, 'T', 'L', 0, '', false);
2727
        $this->pTextBox($x, $y+11.5, $w, $h, $textoObs[1], $aFont, 'T', 'L', 0, '', false);
2728
    } //fim da função obsDACTE
2729
2730
    /**
2731
     * zModalRod
2732
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2733
     *
2734
     * @param  number $x Posição horizontal canto esquerdo
2735
     * @param  number $y Posição vertical canto superior
2736
     * @return number Posição vertical final
2737
     */
2738
    protected function zModalRod($x = 0, $y = 0)
2739
    {
2740
        $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...
2741
        $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...
2742
        $lotacao = '';
0 ignored issues
show
Unused Code introduced by
$lotacao 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...
2743
        if ($this->orientacao == 'P') {
2744
            $maxW = $this->wPrint;
2745
        } else {
2746
            $maxW = $this->wPrint - $this->wCanhoto;
2747
        }
2748
        $w = $maxW;
2749
        $h = 3;
2750
        $texto = 'DADOS ESPECÍFICOS DO MODAL RODOVIÁRIO';
2751
        $aFont = $this->formatPadrao;
2752
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2753
        if ($this->lota == 1) {
2754
            $this->pdf->Line($x, $y + 12, $w + 1, $y + 12); // LINHA DE BAIXO
2755
        }
2756
        $y += 3.4;
2757
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA DE CIMA
2758
        $texto = 'RNTRC DA EMPRESA';
2759
        $aFont = $this->formatPadrao;
2760
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2761
        $texto = $this->pSimpleGetValue($this->rodo, "RNTRC");
2762
        $aFont = $this->formatNegrito;
2763
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2764
        $x += $w * 0.23;
2765
2766
        $this->pdf->Line($x-20, $y, $x-20, $y + 6); // LINHA A FRENTE DA RNTRC DA EMPRESA
2767
2768
        $texto = 'ESTE CONHECIMENTO DE TRANSPORTE ATENDE À LEGISLAÇÃO DE TRANSPORTE RODOVIÁRIO EM VIGOR';
2769
        $aFont = $this->formatPadrao;
2770
        $this->pTextBox($x-20, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'C', 0, '');
2771
    } //fim da função zModalRod
2772
2773
    /**
2774
     * zModalAereo
2775
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2776
     *
2777
     * @param  number $x Posição horizontal canto esquerdo
2778
     * @param  number $y Posição vertical canto superior
2779
     * @return number Posição vertical final
2780
     */
2781
    protected function zModalAereo($x = 0, $y = 0)
2782
    {
2783
        $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...
2784
        $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...
2785
        $lotacao = '';
0 ignored issues
show
Unused Code introduced by
$lotacao 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...
2786
        if ($this->orientacao == 'P') {
2787
            $maxW = $this->wPrint;
2788
        } else {
2789
            $maxW = $this->wPrint - $this->wCanhoto;
2790
        }
2791
        $w = $maxW;
2792
        $h = 3;
2793
        $texto = 'DADOS ESPECÍFICOS DO MODAL AÉREO';
2794
        $aFont = $this->formatPadrao;
2795
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2796
        $y += 3.4;
2797
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA DE CIMA
2798
        $texto = 'NÚMERO OPERACIONAL DO CONHECIMENTO AÉREO';
2799
        $aFont = $this->formatPadrao;
2800
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2801
2802
        $texto = 'CLASSE DA TARIFA';
2803
        $aFont = $this->formatPadrao;
2804
        $this->pTextBox($x+50, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2805
        $texto = 'CÓDIGO DA TARIFA';
2806
        $aFont = $this->formatPadrao;
2807
        $this->pTextBox($x+80, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2808
        $texto = 'VALOR DA TARIFA';
2809
        $aFont = $this->formatPadrao;
2810
        $this->pTextBox($x+110, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2811
2812
        $texto = $this->pSimpleGetValue($this->aereo, "nOCA");
2813
        $aFont = $this->formatNegrito;
2814
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2815
        $x += $w * 0.23;
2816
2817
        $this->pdf->Line($x, $y, $x, $y + 6); // LINHA APÓS NÚMERO OP. DO CT-E AEREO
2818
2819
        $texto = $this->pSimpleGetValue($this->aereo, "CL");
2820
        $aFont = $this->formatNegrito;
2821
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2822
        $x += 30;
2823
        $this->pdf->Line($x, $y, $x, $y + 6); // LINHA APÓS CLASSE DA TARIFA
2824
2825
        $texto = $this->pSimpleGetValue($this->aereo, "cTar");
2826
        $aFont = $this->formatNegrito;
2827
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2828
        $x += 30;
2829
        $this->pdf->Line($x, $y, $x, $y + 6); // LINHA APÓS COD DA TARIFA
2830
2831
        $texto = $this->pSimpleGetValue($this->aereo, "vTar");
2832
        $aFont = $this->formatNegrito;
2833
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2834
    } //fim da função zModalAereo
2835
2836
    /**
2837
     * zModalAquaviario
2838
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2839
     *
2840
     * @param  number $x Posição horizontal canto esquerdo
2841
     * @param  number $y Posição vertical canto superior
2842
     * @return number Posição vertical final
2843
     */
2844
    protected function zModalAquaviario($x = 0, $y = 0)
2845
    {
2846
        $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...
2847
        $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...
2848
        if ($this->orientacao == 'P') {
2849
            $maxW = $this->wPrint;
2850
        } else {
2851
            $maxW = $this->wPrint - $this->wCanhoto;
2852
        }
2853
        $w = $maxW;
2854
        $h = 8.5;
2855
        $texto = 'DADOS ESPECÍFICOS DO MODAL AQUAVIÁRIO';
2856
        $aFont = $this->formatPadrao;
2857
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2858
        $y += 3.4;
2859
        $this->pdf->Line($x, $y, $w + 1, $y);
2860
        $texto = 'PORTO DE EMBARQUE';
2861
        $aFont = $this->formatPadrao;
2862
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2863
        $texto = $this->pSimpleGetValue($this->aquav, "prtEmb");
2864
        $aFont = $this->formatNegrito;
2865
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2866
        $x += $w * 0.50;
2867
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2868
        $texto = 'PORTO DE DESTINO';
2869
        $aFont = $this->formatPadrao;
2870
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2871
        $texto = $this->pSimpleGetValue($this->aquav, "prtDest");
2872
        $aFont = $this->formatNegrito;
2873
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2874
        $y += 8;
2875
        $this->pdf->Line(208, $y, 1, $y);
2876
        $x = 1;
2877
        $texto = 'IDENTIFICAÇÃO DO NAVIO / REBOCADOR';
2878
        $aFont = $this->formatPadrao;
2879
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2880
        $texto = $this->pSimpleGetValue($this->aquav, "xNavio");
2881
        $aFont = $this->formatNegrito;
2882
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2883
        $x += $w * 0.50;
2884
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2885
        $texto = 'VR DA B. DE CALC. AFRMM';
2886
        $aFont = $this->formatPadrao;
2887
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2888
        $texto = $this->pSimpleGetValue($this->aquav, "vPrest");
2889
        $aFont = $this->formatNegrito;
2890
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2891
        $x += $w * 0.17;
2892
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2893
        $texto = 'VALOR DO AFRMM';
2894
        $aFont = $this->formatPadrao;
2895
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2896
        $texto = $this->pSimpleGetValue($this->aquav, "vAFRMM");
2897
        $aFont = $this->formatNegrito;
2898
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2899
        $x += $w * 0.12;
2900
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2901
        $texto = 'TIPO DE NAVEGAÇÃO';
2902
        $aFont = $this->formatPadrao;
2903
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2904
        $texto = $this->pSimpleGetValue($this->aquav, "tpNav");
2905
        switch ($texto) {
2906
            case '0':
2907
                $texto = 'INTERIOR';
2908
                break;
2909
            case '1':
2910
                $texto = 'CABOTAGEM';
2911
                break;
2912
        }
2913
        $aFont = $this->formatNegrito;
2914
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2915
        $x += $w * 0.14;
2916
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2917
        $texto = 'DIREÇÃO';
2918
        $aFont = $this->formatPadrao;
2919
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2920
        $texto = $this->pSimpleGetValue($this->aquav, "direc");
2921
        switch ($texto) {
2922
            case 'N':
2923
                $texto = 'NORTE';
2924
                break;
2925
            case 'L':
2926
                $texto = 'LESTE';
2927
                break;
2928
            case 'S':
2929
                $texto = 'SUL';
2930
                break;
2931
            case 'O':
2932
                $texto = 'OESTE';
2933
                break;
2934
        }
2935
        $aFont = $this->formatNegrito;
2936
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2937
        $y += 8;
2938
        $this->pdf->Line(208, $y, 1, $y);
2939
        $x = 1;
2940
        $texto = 'IDENTIFICAÇÃO DOS CONTEINERS';
2941
        $aFont = $this->formatPadrao;
2942
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2943
        if ($this->infNF->item(0) !== null && $this->infNF->item(0)->getElementsByTagName('infUnidCarga') !== null) {
2944
            $texto = $this->infNF
2945
                ->item(0)
2946
                ->getElementsByTagName('infUnidCarga')
2947
                ->item(0)
2948
                ->getElementsByTagName('idUnidCarga')
2949
                ->item(0)->nodeValue;
2950
        } elseif ($this->infNFe->item(0) !== null
2951
            && $this->infNFe->item(0)->getElementsByTagName('infUnidCarga') !== null
2952
        ) {
2953
            $texto = $this->infNFe
2954
                ->item(0)
2955
                ->getElementsByTagName('infUnidCarga')
2956
                ->item(0)
2957
                ->getElementsByTagName('idUnidCarga')
2958
                ->item(0)
2959
                ->nodeValue;
2960
        } elseif ($this->infOutros->item(0) !== null
2961
            && $this->infOutros->item(0)->getElementsByTagName('infUnidCarga') !== null
2962
        ) {
2963
            $texto = $this->infOutros
2964
                ->item(0)
2965
                ->getElementsByTagName('infUnidCarga')
2966
                ->item(0)
2967
                ->getElementsByTagName('idUnidCarga')
2968
                ->item(0)
2969
                ->nodeValue;
2970
        } else {
2971
            $texto = '';
2972
        }
2973
        $aFont = $this->formatNegrito;
2974
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2975
        $x += $w * 0.50;
2976
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2977
        $texto = 'IDENTIFICAÇÃO DAS BALSAS';
2978
        $aFont = $this->formatPadrao;
2979
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2980
        $texto = '';
2981
        if ($this->pSimpleGetValue($this->aquav, "balsa") !== '') {
2982
            foreach ($this->aquav->getElementsByTagName('balsa') as $k => $d) {
2983
                if ($k == 0) {
2984
                    $texto = $this->aquav
2985
                        ->getElementsByTagName('balsa')
2986
                        ->item($k)
2987
                        ->getElementsByTagName('xBalsa')
2988
                        ->item(0)
2989
                        ->nodeValue;
2990
                } else {
2991
                    $texto = $texto
2992
                        . ' / '
2993
                        . $this->aquav
2994
                            ->getElementsByTagName('balsa')
2995
                            ->item($k)
2996
                            ->getElementsByTagName('xBalsa')
2997
                            ->item(0)
2998
                            ->nodeValue;
2999
                }
3000
            }
3001
        }
3002
        $aFont = $this->formatNegrito;
3003
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
3004
    } //fim da função zModalRod
3005
3006
    /**
3007
     * zModalFerr
3008
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
3009
     *
3010
     * @param  number $x Posição horizontal canto esquerdo
3011
     * @param  number $y Posição vertical canto superior
3012
     * @return number Posição vertical final
3013
     */
3014
    protected function zModalFerr($x = 0, $y = 0)
3015
    {
3016
        $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...
3017
        $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...
3018
        if ($this->orientacao == 'P') {
3019
            $maxW = $this->wPrint;
3020
        } else {
3021
            $maxW = $this->wPrint - $this->wCanhoto;
3022
        }
3023
        $w = $maxW;
3024
        $h = 19.6;
3025
        $texto = 'DADOS ESPECÍFICOS DO MODAL FERROVIÁRIO';
3026
        $aFont = $this->formatPadrao;
3027
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3028
        $y += 3.4;
3029
        $this->pdf->Line($x, $y, $w + 1, $y);
3030
        $texto = 'DCL';
3031
        $aFont = array(
3032
            'font' => $this->fontePadrao,
3033
            'size' => 7,
3034
            'style' => 'B');
3035
        $this->pTextBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'C', 0, '');
3036
        $this->pdf->Line($x + 49.6, $y, $x + 49.6, $y + 3.5);
3037
        $texto = 'VAGÕES';
3038
        $aFont = array(
3039
            'font' => $this->fontePadrao,
3040
            'size' => 7,
3041
            'style' => 'B');
3042
        $this->pTextBox($x + 50, $y, $w * 0.5, $h, $texto, $aFont, 'T', 'C', 0, '');
3043
        $y += 3.4;
3044
        $this->pdf->Line($x, $y, $w + 1, $y);
3045
        // DCL
3046
        $texto = 'ID TREM';
3047
        $aFont = array(
3048
            'font' => $this->fontePadrao,
3049
            'size' => 6,
3050
            'style' => '');
3051
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3052
        $texto = $this->pSimpleGetValue($this->ferrov, "idTrem");
3053
        $aFont = array(
3054
            'font' => $this->fontePadrao,
3055
            'size' => 6,
3056
            'style' => 'B');
3057
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3058
        $x += $w * 0.06;
3059
        $y1 = $y + 12.5;
3060
        $this->pdf->Line($x, $y, $x, $y1);
3061
        $texto = 'NUM';
3062
        $aFont = array(
3063
            'font' => $this->fontePadrao,
3064
            'size' => 6,
3065
            'style' => '');
3066
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3067
        $texto = $this->pSimpleGetValue($this->rem, "nDoc");
3068
        $aFont = array(
3069
            'font' => $this->fontePadrao,
3070
            'size' => 6,
3071
            'style' => 'B');
3072
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3073
        $x += $w * 0.06;
3074
        $this->pdf->Line($x, $y, $x, $y1);
3075
        $texto = 'SÉRIE';
3076
        $aFont = array(
3077
            'font' => $this->fontePadrao,
3078
            'size' => 6,
3079
            'style' => '');
3080
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3081
        $texto = $this->pSimpleGetValue($this->rem, "serie");
3082
        $aFont = array(
3083
            'font' => $this->fontePadrao,
3084
            'size' => 6,
3085
            'style' => 'B');
3086
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3087
        $x += $w * 0.06;
3088
        $this->pdf->Line($x, $y, $x, $y1);
3089
        $texto = 'EMISSÃO';
3090
        $aFont = array(
3091
            'font' => $this->fontePadrao,
3092
            'size' => 6,
3093
            'style' => '');
3094
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3095
        $texto = $this->pYmd2dmy($this->pSimpleGetValue($this->rem, "dEmi"));
3096
        $aFont = array(
3097
            'font' => $this->fontePadrao,
3098
            'size' => 6,
3099
            'style' => 'B');
3100
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3101
        // VAGOES
3102
        $x += $w * 0.06;
3103
        $this->pdf->Line($x, $y, $x, $y1);
3104
        $texto = 'NUM';
3105
        $aFont = array(
3106
            'font' => $this->fontePadrao,
3107
            'size' => 6,
3108
            'style' => '');
3109
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3110
        $texto = $this->pSimpleGetValue($this->ferrov, "nVag");
3111
        $aFont = array(
3112
            'font' => $this->fontePadrao,
3113
            'size' => 6,
3114
            'style' => 'B');
3115
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3116
        $x += $w * 0.06;
3117
        $this->pdf->Line($x, $y, $x, $y1);
3118
        $texto = 'TIPO';
3119
        $aFont = array(
3120
            'font' => $this->fontePadrao,
3121
            'size' => 6,
3122
            'style' => '');
3123
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3124
        $texto = $this->pSimpleGetValue($this->ferrov, "tpVag");
3125
        $aFont = array(
3126
            'font' => $this->fontePadrao,
3127
            'size' => 6,
3128
            'style' => 'B');
3129
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3130
        $x += $w * 0.06;
3131
        $this->pdf->Line($x, $y, $x, $y1);
3132
        $texto = 'CAPACIDADE';
3133
        $aFont = array(
3134
            'font' => $this->fontePadrao,
3135
            'size' => 6,
3136
            'style' => '');
3137
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3138
        $texto = $this->pSimpleGetValue($this->ferrov, "cap");
3139
        $aFont = array(
3140
            'font' => $this->fontePadrao,
3141
            'size' => 6,
3142
            'style' => 'B');
3143
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3144
        $x += $w * 0.08;
3145
        $this->pdf->Line($x, $y, $x, $y1);
3146
        $texto = 'PESO REAL/TON';
3147
        $aFont = array(
3148
            'font' => $this->fontePadrao,
3149
            'size' => 6,
3150
            'style' => '');
3151
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3152
        $texto = $this->pSimpleGetValue($this->ferrov, "pesoR");
3153
        $aFont = array(
3154
            'font' => $this->fontePadrao,
3155
            'size' => 6,
3156
            'style' => 'B');
3157
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3158
        $x += $w * 0.09;
3159
        $this->pdf->Line($x, $y, $x, $y1);
3160
        $texto = 'PESO BRUTO/TON';
3161
        $aFont = array(
3162
            'font' => $this->fontePadrao,
3163
            'size' => 6,
3164
            'style' => '');
3165
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3166
        $texto = $this->pSimpleGetValue($this->ferrov, "pesoBC");
3167
        $aFont = array(
3168
            'font' => $this->fontePadrao,
3169
            'size' => 6,
3170
            'style' => 'B');
3171
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3172
        $x += $w * 0.1;
3173
        $this->pdf->Line($x, $y, $x, $y1);
3174
        $texto = 'IDENTIFICAÇÃO DOS CONTÊINERES';
3175
        $aFont = array(
3176
            'font' => $this->fontePadrao,
3177
            'size' => 6,
3178
            'style' => '');
3179
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3180
        $texto = $this->pSimpleGetValue($this->ferrov, "nCont");
3181
        $aFont = array(
3182
            'font' => $this->fontePadrao,
3183
            'size' => 6,
3184
            'style' => 'B');
3185
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3186
        // FLUXO
3187
        $x = 1;
3188
        $y += 12.9;
3189
        $h1 = $h * 0.5 + 0.27;
3190
        $wa = round($w * 0.103) + 0.5;
3191
        $texto = 'FLUXO FERROVIARIO';
3192
        $aFont = $this->formatPadrao;
3193
        $this->pTextBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
3194
        $texto = $this->pSimpleGetValue($this->ferrov, "fluxo");
3195
        $aFont = array(
3196
            'font' => $this->fontePadrao,
3197
            'size' => 7,
3198
            'style' => 'B');
3199
        $this->pTextBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
3200
        $y += 10;
3201
        $texto = 'TIPO DE TRÁFEGO';
3202
        $aFont = $this->formatPadrao;
3203
        $this->pTextBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
3204
        $texto = $this->zConvertUnidTrafego($this->pSimpleGetValue($this->ferrov, "tpTraf"));
3205
        $aFont = array(
3206
            'font' => $this->fontePadrao,
3207
            'size' => 7,
3208
            'style' => 'B');
3209
        $this->pTextBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
3210
        // Novo Box Relativo a Modal Ferroviário
3211
        $x = 22.5;
3212
        $y += -10.2;
3213
        $texto = 'INFORMAÇÕES DAS FERROVIAS ENVOLVIDAS';
3214
        $aFont = $this->formatPadrao;
3215
        $this->pTextBox($x, $y, $w - 21.5, $h1 * 2.019, $texto, $aFont, 'T', 'C', 1, '');
3216
        $y += 3.4;
3217
        $this->pdf->Line($x, $y, $w + 1, $y);
3218
        $w = $w * 0.2;
3219
        $h = $h * 1.04;
3220
        $texto = 'CÓDIGO INTERNO';
3221
        $aFont = array(
3222
            'font' => $this->fontePadrao,
3223
            'size' => 6,
3224
            'style' => '');
3225
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3226
        $texto = $this->pSimpleGetValue($this->ferrov, "cInt");
3227
        $aFont = array(
3228
            'font' => $this->fontePadrao,
3229
            'size' => 6,
3230
            'style' => 'B');
3231
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3232
        $texto = 'CNPJ';
3233
        $aFont = array(
3234
            'font' => $this->fontePadrao,
3235
            'size' => 6,
3236
            'style' => '');
3237
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3238
        $texto = $this->pSimpleGetValue($this->ferrov, "CNPJ");
3239
        $aFont = array(
3240
            'font' => $this->fontePadrao,
3241
            'size' => 6,
3242
            'style' => 'B');
3243
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3244
        $x += 50;
3245
        $texto = 'NOME';
3246
        $aFont = array(
3247
            'font' => $this->fontePadrao,
3248
            'size' => 6,
3249
            'style' => '');
3250
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3251
        $texto = $this->pSimpleGetValue($this->ferrov, "xNome");
3252
        $aFont = array(
3253
            'font' => $this->fontePadrao,
3254
            'size' => 6,
3255
            'style' => 'B');
3256
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3257
        $texto = 'INSCRICAO ESTADUAL';
3258
        $aFont = array(
3259
            'font' => $this->fontePadrao,
3260
            'size' => 6,
3261
            'style' => '');
3262
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3263
        $texto = $this->pSimpleGetValue($this->ferrov, "IE");
3264
        $aFont = array(
3265
            'font' => $this->fontePadrao,
3266
            'size' => 6,
3267
            'style' => 'B');
3268
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3269
        $x += 50;
3270
        $texto = 'PARTICIPAÇÃO OUTRA FERROVIA';
3271
        $aFont = array(
3272
            'font' => $this->fontePadrao,
3273
            'size' => 6,
3274
            'style' => '');
3275
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3276
        $texto = '';
3277
        $aFont = array(
3278
            'font' => $this->fontePadrao,
3279
            'size' => 6,
3280
            'style' => 'B');
3281
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3282
    } //fim da função zModalFerr
3283
3284
    /**
3285
     * zCanhoto
3286
     * Monta o campo com os dados do remetente na DACTE.
3287
     *
3288
     * @param  number $x Posição horizontal canto esquerdo
3289
     * @param  number $y Posição vertical canto superior
3290
     * @return number Posição vertical final
3291
     */
3292
    protected function zCanhoto($x = 0, $y = 0)
3293
    {
3294
        $this->zhDashedLine($x, $y+2, $this->wPrint, 0.1, 80);
3295
        $y = $y + 2;
3296
        $oldX = $x;
3297
        $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...
3298
        if ($this->orientacao == 'P') {
3299
            $maxW = $this->wPrint;
3300
        } else {
3301
            $maxW = $this->wPrint - $this->wCanhoto;
3302
        }
3303
        $w = $maxW - 1;
3304
        $h = 20;
3305
        $y = $y + 1;
3306
        $texto = 'DECLARO QUE RECEBI OS VOLUMES DESTE CONHECIMENTO EM PERFEITO ESTADO ';
3307
        $texto .= 'PELO QUE DOU POR CUMPRIDO O PRESENTE CONTRATO DE TRANSPORTE';
3308
        $aFont = $this->formatPadrao;
3309
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3310
        $y += 3.4;
3311
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA ABAICO DO TEXTO DECLARO QUE RECEBI...
3312
3313
        $texto = 'NOME';
3314
        $aFont = array(
3315
            'font' => $this->fontePadrao,
3316
            'size' => 6,
3317
            'style' => '');
3318
        $this->pTextBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'L', 0, '');
3319
        $x += $w * 0.25;
3320
3321
        $this->pdf->Line($x, $y, $x, $y + 16.5);
3322
3323
        $texto = 'ASSINATURA / CARIMBO';
3324
        $aFont = array(
3325
            'font' => $this->fontePadrao,
3326
            'size' => 6,
3327
            'style' => '');
3328
        $this->pTextBox($x, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'B', 'C', 0, '');
3329
        $x += $w * 0.25;
3330
3331
        $this->pdf->Line($x, $y, $x, $y + 16.5);
3332
3333
        $texto = 'TÉRMINO DA PRESTAÇÃO - DATA/HORA' . "\r\n" . "\r\n" . "\r\n". "\r\n";
3334
        $texto .= ' INÍCIO DA PRESTAÇÃO - DATA/HORA';
3335
        $aFont = array(
3336
            'font' => $this->fontePadrao,
3337
            'size' => 6,
3338
            'style' => '');
3339
        $this->pTextBox($x + 10, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'T', 'C', 0, '');
3340
        $x = $oldX;
3341
        $y = $y + 5;
3342
3343
        $this->pdf->Line($x, $y+3, $w * 0.255, $y+3); // LINHA HORIZONTAL ACIMA DO RG ABAIXO DO NOME
3344
3345
        $texto = 'RG';
3346
        $aFont = array(
3347
            'font' => $this->fontePadrao,
3348
            'size' => 6,
3349
            'style' => '');
3350
        $this->pTextBox($x, $y+3, $w * 0.33, $h, $texto, $aFont, 'T', 'L', 0, '');
3351
        $x += $w * 0.85;
3352
3353
        $this->pdf->Line($x, $y + 11.5, $x, $y - 5); // LINHA VERTICAL PROXIMO AO CT-E
3354
3355
        $texto = "CT-E";
3356
        $aFont = $this->formatNegrito;
3357
        $this->pTextBox($x, $y - 5, $w * 0.15, $h, $texto, $aFont, 'T', 'C', 0, '');
3358
        $texto = "\r\n Nº. DOCUMENTO  " . $this->pSimpleGetValue($this->ide, "nCT") . " \n";
3359
        $texto .= "\r\n SÉRIE  " . $this->pSimpleGetValue($this->ide, "serie");
3360
        $aFont = array(
3361
            'font' => $this->fontePadrao,
3362
            'size' => 6,
3363
            'style' => '');
3364
        $this->pTextBox($x, $y - 8, $w * 0.15, $h, $texto, $aFont, 'C', 'C', 0, '');
3365
        $x = $oldX;
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...
3366
        //$this->zhDashedLine($x, $y + 7.5, $this->wPrint, 0.1, 80);
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
3367
    } //fim da função canhotoDACTE
3368
3369
    /**
3370
     * zDadosAdic
3371
     * Coloca o grupo de dados adicionais da DACTE.
3372
     *
3373
     * @param  number $x Posição horizontal canto esquerdo
3374
     * @param  number $y Posição vertical canto superior
3375
     * @param  number $h altura do campo
3376
     * @return number Posição vertical final
3377
     */
3378
    protected function zDadosAdic($x, $y, $pag, $h)
0 ignored issues
show
Unused Code introduced by
The parameter $pag 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...
Unused Code introduced by
The parameter $h 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...
3379
    {
3380
        $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...
3381
        //###########################################################################
3382
        //DADOS ADICIONAIS DACTE
3383
        if ($this->orientacao == 'P') {
3384
            $w = $this->wPrint;
0 ignored issues
show
Unused Code introduced by
$w 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...
3385
        } else {
3386
            $w = $this->wPrint - $this->wCanhoto;
0 ignored issues
show
Unused Code introduced by
$w 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...
3387
        }
3388
        //INFORMAÇÕES COMPLEMENTARES
3389
        $texto = "USO EXCLUSIVO DO EMISSOR DO CT-E";
3390
        $y += 3;
3391
        $w = $this->wAdic;
3392
        $h = 8; //mudar
3393
        $aFont = array(
3394
            'font' => $this->fontePadrao,
3395
            'size' => 6,
3396
            'style' => '');
3397
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3398
        //$this->pdf->Line($x, $y + 3, $w * 1.385, $y + 3);
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
3399
        $this->pdf->Line($x, $y + 3, $w * 1.385, $y + 3);
3400
        //o texto com os dados adicionais foi obtido na função xxxxxx
3401
        //e carregado em uma propriedade privada da classe
3402
        //$this->wAdic com a largura do campo
3403
        //$this->textoAdic com o texto completo do campo
3404
        $y += 1;
3405
        $aFont = $this->formatPadrao;
3406
        $this->pTextBox($x, $y + 3, $w - 2, $h - 3, $this->textoAdic, $aFont, 'T', 'L', 0, '', false);
3407
        //RESERVADO AO FISCO
3408
        $texto = "RESERVADO AO FISCO";
3409
        $x += $w;
3410
        $y -= 1;
3411
        if ($this->orientacao == 'P') {
3412
            $w = $this->wPrint - $w;
3413
        } else {
3414
            $w = $this->wPrint - $w - $this->wCanhoto;
3415
        }
3416
        $aFont = array(
3417
            'font' => $this->fontePadrao,
3418
            'size' => 6,
3419
            'style' => '');
3420
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3421
        //inserir texto informando caso de contingência
3422
        //1 – Normal – emissão normal;
3423
        //2 – Contingência FS – emissão em contingência com impressão do DACTE em Formulário de Segurança;
3424
        //3 – Contingência SCAN – emissão em contingência  – SCAN;
3425
        //4 – Contingência DPEC - emissão em contingência com envio da Declaração Prévia de
3426
        //Emissão em Contingência – DPEC;
3427
        //5 – Contingência FS-DA - emissão em contingência com impressão do DACTE em Formulário de
3428
        //Segurança para Impressão de Documento Auxiliar de Documento Fiscal Eletrônico (FS-DA).
3429
        $xJust = $this->pSimpleGetValue($this->ide, 'xJust', 'Justificativa: ');
3430
        $dhCont = $this->pSimpleGetValue($this->ide, 'dhCont', ' Entrada em contingência : ');
3431
        $texto = '';
3432
        switch ($this->tpEmis) {
3433
            case 2:
3434
                $texto = 'CONTINGÊNCIA FS' . $dhCont . $xJust;
3435
                break;
3436
            case 3:
3437
                $texto = 'CONTINGÊNCIA SCAN' . $dhCont . $xJust;
3438
                break;
3439
            case 4:
3440
                $texto = 'CONTINGÊNCIA DPEC' . $dhCont . $xJust;
3441
                break;
3442
            case 5:
3443
                $texto = 'CONTINGÊNCIA FSDA' . $dhCont . $xJust;
3444
                break;
3445
        }
3446
        $y += 2;
3447
        $aFont = $this->formatPadrao;
3448
        $this->pTextBox($x, $y + 2, $w - 2, $h - 3, $texto, $aFont, 'T', 'L', 0, '', false);
3449
        return $y + $h;
3450
    } //fim zDadosAdic
3451
3452
    /**
3453
     * zhDashedLine
3454
     * Desenha uma linha horizontal tracejada com o FPDF
3455
     *
3456
     * @param  number $x Posição horizontal inicial, em mm
3457
     * @param  number $y Posição vertical inicial, em mm
3458
     * @param  number $w Comprimento da linha, em mm
3459
     * @param  number $h Espessura da linha, em mm
3460
     * @param  number $n Numero de traços na seção da linha com o comprimento $w
3461
     * @return none
3462
     */
3463
    protected function zhDashedLine($x, $y, $w, $h, $n)
3464
    {
3465
        $this->pdf->SetLineWidth($h);
3466
        $wDash = ($w / $n) / 2; // comprimento dos traços
3467
        for ($i = $x; $i <= $x + $w; $i += $wDash + $wDash) {
3468
            for ($j = $i; $j <= ($i + $wDash); $j++) {
3469
                if ($j <= ($x + $w - 1)) {
3470
                    $this->pdf->Line($j, $y, $j + 1, $y);
3471
                }
3472
            }
3473
        }
3474
    } //fim função hDashedLine
3475
3476
    /**
3477
     * zhDashedVerticalLine
3478
     * Desenha uma linha vertical tracejada com o FPDF
3479
     *
3480
     * @param  number $x Posição horizontal inicial, em mm
3481
     * @param  number $y Posição vertical inicial, em mm
3482
     * @param  number $w Comprimento da linha, em mm
3483
     * @param  number $yfinal Espessura da linha, em mm
3484
     * @param  number $n Numero de traços na seção da linha com o comprimento $w
3485
     * @return none
3486
     */
3487
    protected function zhDashedVerticalLine($x, $y, $w, $yfinal, $n)
3488
    {
3489
        $this->pdf->SetLineWidth($w);
3490
        /* Organizando valores */
3491
        if ($y > $yfinal) {
3492
            $aux = $yfinal;
3493
            $yfinal = $y;
3494
            $y = $aux;
3495
        }
3496
        while ($y < $yfinal && $n > 0) {
3497
            $this->pdf->Line($x, $y, $x, $y + 1);
3498
            $y += 3;
3499
            $n--;
3500
        }
3501
    } //fim função hDashedVerticalLine
3502
3503
    /**
3504
     * zFormatCNPJCPF
3505
     * Formata campo CnpjCpf contida na CTe
3506
     *
3507
     * @param  string $field campo cnpjCpf da CT-e
3508
     * @return string
3509
     */
3510
    protected function zFormatCNPJCPF($field)
3511
    {
3512
        if (!isset($field)) {
3513
            return '';
3514
        }
3515
        $cnpj = !empty($field->getElementsByTagName("CNPJ")->item(0)->nodeValue) ?
0 ignored issues
show
Bug introduced by
The method getElementsByTagName cannot be called on $field (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
3516
            $field->getElementsByTagName("CNPJ")->item(0)->nodeValue : "";
0 ignored issues
show
Bug introduced by
The method getElementsByTagName cannot be called on $field (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
3517
        if ($cnpj != "" && $cnpj != "00000000000000") {
3518
            $cnpj = $this->pFormat($cnpj, '###.###.###/####-##');
3519
        } else {
3520
            $cnpj = !empty($field->getElementsByTagName("CPF")->item(0)->nodeValue) ?
0 ignored issues
show
Bug introduced by
The method getElementsByTagName cannot be called on $field (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
3521
                $this->pFormat($field->getElementsByTagName("CPF")->item(0)->nodeValue, '###.###.###.###-##') : '';
0 ignored issues
show
Bug introduced by
The method getElementsByTagName cannot be called on $field (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
3522
        }
3523
        return $cnpj;
3524
    } //fim formatCNPJCPF
3525
3526
    /**
3527
     * zFormatFone
3528
     * Formata campo fone contida na CTe
3529
     *
3530
     * @param  string $field campo fone da CT-e
3531
     * @return string
3532
     */
3533
    protected function zFormatFone($field)
3534
    {
3535
        try {
3536
            $fone = !empty($field->getElementsByTagName("fone")->item(0)->nodeValue) ?
0 ignored issues
show
Bug introduced by
The method getElementsByTagName cannot be called on $field (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
3537
            $field->getElementsByTagName("fone")->item(0)->nodeValue : '';
0 ignored issues
show
Bug introduced by
The method getElementsByTagName cannot be called on $field (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
3538
            $foneLen = strlen($fone);
3539
            if ($foneLen > 0) {
3540
                $fone2 = substr($fone, 0, $foneLen - 4);
3541
                $fone1 = substr($fone, 0, $foneLen - 8);
3542
                $fone = '(' . $fone1 . ') ' . substr($fone2, -4) . '-' . substr($fone, -4);
3543
            } else {
3544
                $fone = '';
3545
            }
3546
            return $fone;
3547
        } catch (Exception $exc) {
3548
            return '';
3549
        }
3550
    } //fim formatFone
3551
3552
    /**
3553
     * zUnidade
3554
     * Converte a imformação de peso contida na CTe
3555
     *
3556
     * @param  string $c unidade de trafego extraida da CTe
3557
     * @return string
3558
     */
3559
    protected function zUnidade($c = '')
3560
    {
3561
        switch ($c) {
3562
            case '00':
3563
                $r = 'M3';
3564
                break;
3565
            case '01':
3566
                $r = 'KG';
3567
                break;
3568
            case '02':
3569
                $r = 'TON';
3570
                break;
3571
            case '03':
3572
                $r = 'UN';
3573
                break;
3574
            case '04':
3575
                $r = 'LT';
3576
                break;
3577
            case '05':
3578
                $r = 'MMBTU';
3579
                break;
3580
            default:
3581
                $r = '';
3582
        }
3583
        return $r;
3584
    } //fim unidade
3585
3586
    /**
3587
     * zConvertUnidTrafego
3588
     * Converte a imformação de peso contida na CTe
3589
     *
3590
     * @param  string $U Informação de trafego extraida da CTe
3591
     * @return string
3592
     */
3593
    protected function zConvertUnidTrafego($U = '')
3594
    {
3595
        if ($U) {
3596
            switch ($U) {
3597
                case '0':
3598
                    $stringU = 'Próprio';
3599
                    break;
3600
                case '1':
3601
                    $stringU = 'Mútuo';
3602
                    break;
3603
                case '2':
3604
                    $stringU = 'Rodoferroviário';
3605
                    break;
3606
                case '3':
3607
                    $stringU = 'Rodoviário';
3608
                    break;
3609
            }
3610
            return $stringU;
0 ignored issues
show
Bug introduced by
The variable $stringU 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...
3611
        }
3612
    } //fim da função zConvertUnidTrafego
3613
3614
    /**
3615
     * zMultiUniPeso
3616
     * Fornece a imformação multiplicação de peso contida na CTe
3617
     *
3618
     * @param  interger $U Informação de peso extraida da CTe
3619
     * @return interger
3620
     */
3621
    protected function zMultiUniPeso($U = '')
3622
    {
3623
        if ($U === "01") {
3624
            // tonelada
3625
            //return 1000;
3626
            return 1;
3627
        }
3628
        return 1; // M3, KG, Unidade, litros, mmbtu
3629
    } //fim da função zMultiUniPeso
3630
}
3631