Completed
Pull Request — master (#146)
by
unknown
03:44
created

DacteV3::zModalAereo()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 54

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 2
dl 0
loc 54
ccs 0
cts 48
cp 0
crap 6
rs 9.0036
c 0
b 0
f 0

How to fix   Long Method   

Long Method

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

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

Commonly applied refactorings include:

1
<?php
2
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
        $texto = $this->pSimpleGetValue($this->ICMSSN, "indSN") == 1 ? 'Simples Nacional' : $texto;
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("vBC")->item(0)->nodeValue) ?
2079
            number_format($this->pSimpleGetValue($this->ICMS, "vBC"), 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("pICMS")->item(0)->nodeValue) ?
2088
            number_format($this->pSimpleGetValue($this->ICMS, "pICMS"), 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
2119
        /*$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...
2120
        $texto = '';
2121
        $aFont = $this->formatNegrito;
2122
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');*/
2123
    } //fim da função compValorDACTE
2124
2125
    /**
2126
     * zGeraChaveAdicCont
2127
     *
2128
     * @return string chave
2129
     */
2130
    protected function zGeraChaveAdicCont()
2131
    {
2132
        //cUF tpEmis CNPJ vNF ICMSp ICMSs DD  DV
2133
        // 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...
2134
        $forma = "%02d%d%s%014d%01d%01d%02d";
2135
        $cUF = $this->ide->getElementsByTagName('cUF')->item(0)->nodeValue;
2136
        $CNPJ = "00000000000000" . $this->emit->getElementsByTagName('CNPJ')->item(0)->nodeValue;
2137
        $CNPJ = substr($CNPJ, -14);
2138
        $vCT = number_format($this->pSimpleGetValue($this->vPrest, "vRec"), 2, "", "") * 100;
2139
        $ICMS_CST = $this->pSimpleGetValue($this->ICMS, "CST");
2140
        switch ($ICMS_CST) {
2141
            case '00':
2142
            case '20':
2143
                $ICMSp = '1';
2144
                $ICMSs = '2';
2145
                break;
2146
            case '40':
2147
            case '41':
2148
            case '51':
2149
            case '90':
2150
                $ICMSp = '2';
2151
                $ICMSs = '2';
2152
                break;
2153
            case '60':
2154
                $ICMSp = '2';
2155
                $ICMSs = '1';
2156
                break;
2157
        }
2158
        $dd = $this->ide->getElementsByTagName('dEmi')->item(0)->nodeValue;
2159
        $rpos = strrpos($dd, '-');
2160
        $dd = substr($dd, $rpos + 1);
2161
        $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...
2162
        $chave = $chave . $this->pModulo11($chave);
2163
        return $chave;
2164
    } //fim zGeraChaveAdicCont
2165
2166
    /**
2167
     * zDocOrig
2168
     * Monta o campo com os documentos originarios.
2169
     *
2170
     * @param  number $x Posição horizontal canto esquerdo
2171
     * @param  number $y Posição vertical canto superior
2172
     * @return number Posição vertical final
2173
     */
2174
    protected function zDocOrig($x = 0, $y = 0)
2175
    {
2176
        $oldX = $x;
2177
        $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...
2178
        if ($this->orientacao == 'P') {
2179
            $maxW = $this->wPrint;
2180
        } else {
2181
            $maxW = $this->wPrint - $this->wCanhoto;
2182
        }
2183
        $w = $maxW;
2184
2185
        // SE FOR RODOVIARIO ( BTR-SEMPRE SERÁ )
2186
        if ($this->modal == '1') {
2187
            // 0 - Não; 1 - Sim Será lotação quando houver um único conhecimento de transporte por veículo,
2188
            // ou combinação veicular, e por viagem
2189
            $h = $this->lota == 1 ? 35 : 53;
2190
        } elseif ($this->modal == '2') {
2191
            $h = 53;
2192
        } elseif ($this->modal == '3') {
2193
            $h = 37.6;
2194
        } else {
2195
            $h = 35;
2196
        }
2197
        $texto = 'DOCUMENTOS ORIGINÁRIOS';
2198
        $aFont = $this->formatPadrao;
2199
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2200
        $descr1 = 'TIPO DOC';
2201
        $descr2 = 'CNPJ/CHAVE/OBS';
2202
        $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2203
2204
        $y += 3.4;
2205
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA ABAIXO DO TEXTO: "DOCUMENTOS ORIGINÁRIOS
2206
        $texto = $descr1;
2207
        $aFont = $this->formatPadrao;
2208
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2209
        $yIniDados = $y;
2210
2211
        $x += $w * 0.07;
2212
        $texto = $descr2;
2213
        $aFont = $this->formatPadrao;
2214
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2215
2216
        $x += $w * 0.28;
2217
        $texto = $descr3;
2218
        $aFont = $this->formatPadrao;
2219
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2220
2221
        $x += $w * 0.14;
2222
        if ($this->modal == '1') {
2223
            if ($this->lota == 1) {
2224
                $this->pdf->Line($x, $y, $x, $y + 31.5); // TESTE
2225
            } else {
2226
                $this->pdf->Line($x, $y, $x, $y + 49.5); // TESTE
2227
            }
2228
        } elseif ($this->modal == '2') {
2229
            $this->pdf->Line($x, $y, $x, $y + 49.5);
2230
        } elseif ($this->modal == '3') {
2231
            $this->pdf->Line($x, $y, $x, $y + 34.1);
2232
        } else {
2233
            $this->pdf->Line($x, $y, $x, $y + 21.5);
2234
        }
2235
        $texto = $descr1;
2236
        $aFont = $this->formatPadrao;
2237
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2238
2239
        $x += $w * 0.08;
2240
        $texto = $descr2;
2241
        $aFont = $this->formatPadrao;
2242
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2243
2244
        $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2245
        $texto = $descr3;
2246
        $aFont = $this->formatPadrao;
2247
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2248
        $auxX = $oldX;
2249
        $yIniDados += 3;
2250
        foreach ($this->infNF as $k => $d) {
2251
            $mod = $this->infNF->item($k)->getElementsByTagName('mod');
2252
            $tp = ($mod && $mod->length > 0) ? $mod->item(0)->nodeValue : '';
2253
            $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...
2254
            $doc = $this->infNF->item($k)->getElementsByTagName('serie')->item(0)->nodeValue;
2255
            $doc .= '/' . $this->infNF->item($k)->getElementsByTagName('nDoc')->item(0)->nodeValue;
2256
            if ($auxX > $w * 0.90) {
2257
                $yIniDados = $yIniDados + 3;
2258
                $auxX = $oldX;
2259
            }
2260
            $texto = $tp;
2261
            $aFont = array(
2262
                'font' => $this->fontePadrao,
2263
                'size' => 8,
2264
                'style' => '');
2265
            //$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...
2266
            $this->pTextBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2267
            //$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...
2268
            $auxX += $w * 0.07;
2269
            $texto = $cnpj;
2270
            $aFont = array(
2271
                'font' => $this->fontePadrao,
2272
                'size' => 8,
2273
                'style' => '');
2274
            $this->pTextBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2275
            $auxX += $w * 0.28;
2276
            $texto = $doc;
2277
            $aFont = array(
2278
                'font' => $this->fontePadrao,
2279
                'size' => 8,
2280
                'style' => '');
2281
            $this->pTextBox($auxX, $yIniDados, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2282
            $auxX += $w * 0.15;
2283
        }
2284
2285
        foreach ($this->infNFe as $k => $d) {
2286
            $chaveNFe = $this->infNFe->item($k)->getElementsByTagName('chave')->item(0)->nodeValue;
2287
            $this->arrayNFe[] = $chaveNFe;
2288
        }
2289
        $qtdeNFe = 1;
2290
        if (count($this->arrayNFe) >15) {
2291
            $this->flagDocOrigContinuacao = 1;
2292
            $qtdeNFe = count($this->arrayNFe);
2293
        }
2294
//        $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...
2295
        switch ($qtdeNFe) {
2296
            default:
2297
                $this->totPag = 1;
2298
            case ($qtdeNFe >= 1044):
2299
                $this->totPag = 11;
2300
                break;
2301
            case ($qtdeNFe > 928):
2302
                $this->totPag = 10;
2303
                break;
2304
            case ($qtdeNFe > 812):
2305
                $this->totPag = 9;
2306
                break;
2307
            case ($qtdeNFe > 696):
2308
                $this->totPag = 8;
2309
                break;
2310
            case ($qtdeNFe > 580):
2311
                $this->totPag = 7;
2312
                break;
2313
            case ($qtdeNFe > 464):
2314
                $this->totPag = 6;
2315
                break;
2316
            case ($qtdeNFe > 348):
2317
                $this->totPag = 5;
2318
                break;
2319
            case ($qtdeNFe > 232):
2320
                $this->totPag = 4;
2321
                break;
2322
            case ($qtdeNFe > 116):
2323
                $this->totPag = 3;
2324
                break;
2325
            case ($qtdeNFe > 16):
2326
                $this->totPag = 2;
2327
                break;
2328
            case ($qtdeNFe <= 16):
2329
                $this->totPag = 1;
2330
                break;
2331
        }
2332
        $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...
2333
        $contador = 0;
2334
        while ($contador < count($this->arrayNFe)) {
2335
            if ($contador == 15) {
2336
                break;
2337
            }
2338
            $tp = 'NF-e';
2339
            $chaveNFe = $this->arrayNFe[$contador];
2340
            $numNFe = substr($chaveNFe, 25, 9);
2341
            $serieNFe = substr($chaveNFe, 22, 3);
2342
            $doc = $serieNFe . '/' . $numNFe;
2343
            if ($auxX > $w * 0.90) {
2344
                $yIniDados = $yIniDados + 3.5;
2345
                $auxX = $oldX;
2346
            }
2347
            $texto = $tp;
2348
            $aFont = array(
2349
                'font' => $this->fontePadrao,
2350
                'size' => 7,
2351
                'style' => '');
2352
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2353
            $auxX += $w * 0.07;
2354
            $texto = $chaveNFe;
2355
            $aFont = array(
2356
                'font' => $this->fontePadrao,
2357
                'size' => 7,
2358
                'style' => '');
2359
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2360
            $auxX += $w * 0.28;
2361
            $texto = $doc;
2362
            $aFont = array(
2363
                'font' => $this->fontePadrao,
2364
                'size' => 7,
2365
                'style' => '');
2366
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2367
            $auxX += $w * 0.15;
2368
            $contador++;
2369
        }
2370
2371
        foreach ($this->infOutros as $k => $d) {
2372
            $temp = $this->infOutros->item($k);
2373
            $tpDoc = $this->pSimpleGetValue($temp, "tpDoc");
2374
            $descOutros = $this->pSimpleGetValue($temp, "descOutros");
2375
            $nDoc = $this->pSimpleGetValue($temp, "nDoc");
2376
            $dEmi = $this->pSimpleGetDate($temp, "dEmi", "Emissão: ");
2377
            $vDocFisc = $this->pSimpleGetValue($temp, "vDocFisc", "Valor: ");
2378
            $dPrev = $this->pSimpleGetDate($temp, "dPrev", "Entrega: ");
2379
            switch ($tpDoc) {
2380
                case "00":
2381
                    $tpDoc = "00 - Declaração";
2382
                    break;
2383
                case "10":
2384
                    $tpDoc = "10 - Dutoviário";
2385
                    break;
2386
                case "99":
2387
                    $tpDoc = "99 - Outros: [" . $descOutros . "]";
2388
                    break;
2389
                default:
2390
                    break;
2391
            }
2392
            $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...
2393
            $cnpjChave = $dEmi . " " . $vDocFisc . " " . $dPrev;
2394
            if ($auxX > $w * 0.90) {
2395
                $yIniDados = $yIniDados + 4;
2396
                $auxX = $oldX;
2397
            }
2398
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $tpDoc, $aFont, 'T', 'L', 0, '');
2399
            $auxX += $w * 0.09;
2400
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $cnpjChave, $aFont, 'T', 'L', 0, '');
2401
            $auxX += $w * 0.28;
2402
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $nDoc, $aFont, 'T', 'L', 0, '');
2403
            $auxX += $w * 0.14;
2404
        }
2405
        foreach ($this->idDocAntEle as $k => $d) {
2406
            $tp = 'CT-e';
2407
            $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...
2408
            $numCTe = substr($chaveCTe, 25, 9);
2409
            $serieCTe = substr($chaveCTe, 22, 3);
2410
            $doc = $serieCTe . '/' . $numCTe;
2411
            if ($auxX > $w * 0.90) {
2412
                $yIniDados = $yIniDados + 4;
2413
                $auxX = $oldX;
2414
            }
2415
            $texto = $tp;
2416
            $aFont = array(
2417
                'font' => $this->fontePadrao,
2418
                'size' => 8,
2419
                'style' => '');
2420
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2421
            $auxX += $w * 0.09;
2422
            $texto = $chaveCTe;
2423
            $aFont = array(
2424
                'font' => $this->fontePadrao,
2425
                'size' => 8,
2426
                'style' => '');
2427
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2428
            $auxX += $w * 0.28;
2429
            $texto = $doc;
2430
            $aFont = array(
2431
                'font' => $this->fontePadrao,
2432
                'size' => 8,
2433
                'style' => '');
2434
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2435
            $auxX += $w * 0.14;
2436
        }
2437
    } //fim da função zDocOrig
2438
2439
    /**
2440
     * zDocOrigContinuacao
2441
     * Monta o campo com os documentos originarios.
2442
     *
2443
     * @param  number $x Posição horizontal canto esquerdo
2444
     * @param  number $y Posição vertical canto superior
2445
     * @return number Posição vertical final
2446
     */
2447
    protected function zDocOrigContinuacao($x = 0, $y = 0)
2448
    {
2449
        $x2 = $x;
2450
        $y2 = $y;
2451
        $contador = 16;
2452
        for ($i = 2; $i <= $this->totPag; $i++) {
2453
            $x = $x2;
2454
            $y = $y2;
2455
            $this->pdf->AddPage($this->orientacao, $this->papel);
2456
            $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...
2457
            $oldX = $x;
2458
            $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...
2459
            if ($this->orientacao == 'P') {
2460
                $maxW = $this->wPrint;
2461
            } else {
2462
                $maxW = $this->wPrint - $this->wCanhoto;
2463
            }
2464
            $w = $maxW;
2465
2466
            //$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...
2467
            //$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...
2468
            //$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...
2469
            //$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...
2470
            $h = (( ( count($this->arrayNFe)/2 ) - 9) * 3.5)+9;
2471
            if (count($this->arrayNFe)%2 !=0) {
2472
                $h = $h+3.5;
2473
            } // Caso tenha apenas 1 registro na ultima linha
2474
2475
            $texto = 'DOCUMENTOS ORIGINÁRIOS - CONTINUACÃO';
2476
            $aFont = $this->formatPadrao;
2477
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2478
            $descr1 = 'TIPO DOC';
2479
            $descr2 = 'CNPJ/CHAVE/OBS';
2480
            $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2481
2482
            $y += 3.4;
2483
            $this->pdf->Line($x, $y, $w + 1, $y);
2484
            $texto = $descr1;
2485
            $aFont = $this->formatPadrao;
2486
            $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2487
            $yIniDados = $y;
2488
2489
            $x += $w * 0.07; // COLUNA CNPJ/CHAVE/OBS
2490
            $texto = $descr2;
2491
            $aFont = $this->formatPadrao;
2492
            $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2493
2494
            $x += $w * 0.28;
2495
            $texto = $descr3;
2496
            $aFont = $this->formatPadrao;
2497
            $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2498
2499
            $x += $w * 0.14;
2500
            if ($this->modal == '1') {
2501
                if ($this->lota == 1) {
2502
                    $this->pdf->Line($x, $y, $x, $y + 31.5);
2503
                } else {
2504
                    $this->pdf->Line($x, $y, $x, $y + 49.5);
2505
                }
2506
            } elseif ($this->modal == '2') {
2507
                $this->pdf->Line($x, $y, $x, $y + 49.5);
2508
            } elseif ($this->modal == '3') {
2509
                $this->pdf->Line($x, $y, $x, $y + 34.1);
2510
            } else {
2511
                $this->pdf->Line($x, $y, $x, $y + 21.5);
2512
            }
2513
            $texto = $descr1;
2514
            $aFont = $this->formatPadrao;
2515
            $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2516
2517
            $x += $w * 0.08;
2518
            $texto = $descr2;
2519
            $aFont = $this->formatPadrao;
2520
            $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2521
2522
            $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2523
            $texto = $descr3;
2524
            $aFont = $this->formatPadrao;
2525
            $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2526
            $auxX = $oldX;
2527
            $yIniDados += 3;
2528
2529
            while ($contador < (count($this->arrayNFe))) {
2530
                if ($contador%(116*($i-1)) == 0) {
2531
//                    $contador++;
2532
                    break;
2533
                }
2534
                $tp = 'NF-e';
2535
                $chaveNFe = $this->arrayNFe[$contador];
2536
                $numNFe = substr($chaveNFe, 25, 9);
2537
                $serieNFe = substr($chaveNFe, 22, 3);
2538
                $doc = $serieNFe . '/' . $numNFe;
2539
                if ($auxX > $w * 0.90) {
2540
                    $yIniDados = $yIniDados + 3.5;
2541
                    $auxX = $oldX;
2542
                }
2543
                $texto = $tp;
2544
                $aFont = array(
2545
                    'font' => $this->fontePadrao,
2546
                    'size' => 7,
2547
                    'style' => '');
2548
                $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2549
                $auxX += $w * 0.07;
2550
                $texto = $chaveNFe;
2551
                $aFont = array(
2552
                    'font' => $this->fontePadrao,
2553
                    'size' => 7,
2554
                    'style' => '');
2555
                $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2556
                $auxX += $w * 0.28;
2557
                $texto = $doc;
2558
                $aFont = array(
2559
                    'font' => $this->fontePadrao,
2560
                    'size' => 7,
2561
                    'style' => '');
2562
                $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2563
                $auxX += $w * 0.15;
2564
                $contador++;
2565
            }
2566
        }
2567
    } //fim da função zDocOrigContinuacao
2568
2569
    /**
2570
     * zDocCompl
2571
     * Monta o campo com os dados do remetente na DACTE.
2572
     *
2573
     * @param number $x Posição horizontal canto esquerdo
2574
     * @param number $y Posição vertical canto superior
2575
     * @return number Posição vertical final
2576
     */
2577
    protected function zDocCompl($x = 0, $y = 0)
2578
    {
2579
        $oldX = $x;
2580
        $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...
2581
        if ($this->orientacao == 'P') {
2582
            $maxW = $this->wPrint;
2583
        } else {
2584
            $maxW = $this->wPrint - $this->wCanhoto;
2585
        }
2586
        $w = $maxW;
2587
        $h = 80;
2588
        if ($this->tpCTe == 1) {
2589
            $texto = 'DETALHAMENTO DO CT-E COMPLEMENTADO';
2590
            $descr1 = 'CHAVE DO CT-E COMPLEMENTADO';
2591
            $descr2 = 'VALOR COMPLEMENTADO';
2592
        } else {
2593
            $texto = 'DETALHAMENTO DO CT-E ANULADO';
2594
            $descr1 = 'CHAVE DO CT-E ANULADO';
2595
            $descr2 = 'VALOR ANULADO';
2596
        }
2597
2598
        $aFont = $this->formatPadrao;
2599
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2600
2601
        $y += 3.4;
2602
        $this->pdf->Line($x, $y, $w + 1, $y);
2603
        $texto = $descr1;
2604
        $aFont = $this->formatPadrao;
2605
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2606
        $yIniDados = $y;
2607
        $x += $w * 0.37;
2608
        $texto = $descr2;
2609
        $aFont = $this->formatPadrao;
2610
        $this->pTextBox($x - 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2611
        $x += $w * 0.13;
2612
        $this->pdf->Line($x, $y, $x, $y + 76.5);
2613
        $texto = $descr1;
2614
        $aFont = $this->formatPadrao;
2615
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2616
        $x += $w * 0.3;
2617
        $texto = $descr2;
2618
        $aFont = $this->formatPadrao;
2619
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2620
        $auxX = $oldX;
2621
        $yIniDados += 4;
2622
        if ($auxX > $w * 0.90) {
2623
            $yIniDados = $yIniDados + 4;
2624
            $auxX = $oldX;
2625
        }
2626
        $texto = $this->chaveCTeRef;
2627
        $aFont = array(
2628
            'font' => $this->fontePadrao,
2629
            'size' => 8,
2630
            'style' => '');
2631
        $this->pTextBox($auxX, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2632
        $texto = number_format($this->pSimpleGetValue($this->vPrest, "vTPrest"), 2, ",", ".");
2633
        $aFont = array(
2634
            'font' => $this->fontePadrao,
2635
            'size' => 8,
2636
            'style' => '');
2637
        $this->pTextBox($w * 0.40, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2638
    } //fim da função zDocCompl
2639
2640
    /**
2641
     * zObs
2642
     * Monta o campo com os dados do remetente na DACTE.
2643
     *
2644
     * @param  number $x Posição horizontal canto esquerdo
2645
     * @param  number $y Posição vertical canto superior
2646
     * @return number Posição vertical final
2647
     */
2648
    protected function zObs($x = 0, $y = 0)
2649
    {
2650
        $oldX = $x;
2651
        $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...
2652
        if ($this->orientacao == 'P') {
2653
            $maxW = $this->wPrint;
2654
        } else {
2655
            $maxW = $this->wPrint - $this->wCanhoto;
2656
        }
2657
        $w = $maxW;
2658
        //$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...
2659
        $h = 18.8;
2660
        $texto = 'OBSERVAÇÕES';
2661
        $aFont = $this->formatPadrao;
2662
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2663
        $y += 3.4;
2664
        $this->pdf->Line($x, $y, $w + 1, $y);
2665
        $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...
2666
        $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...
2667
        $texto = '';
2668
        foreach ($this->compl as $k => $d) {
2669
            $xObs = $this->pSimpleGetValue($this->compl->item($k), "xObs");
2670
            $texto .= $xObs;
2671
        }
2672
        $textoObs = explode("Motorista:", $texto);
2673
        $textoObs[1] = isset($textoObs[1]) ? "Motorista: ".$textoObs[1]: '';
2674
        $texto .= $this->pSimpleGetValue($this->imp, "infAdFisco", "\r\n");
2675
        $aFont = array(
2676
            'font' => $this->fontePadrao,
2677
            'size' => 7.5,
2678
            'style' => '');
2679
        $this->pTextBox($x, $y, $w, $h, $textoObs[0], $aFont, 'T', 'L', 0, '', false);
2680
        $this->pTextBox($x, $y+11.5, $w, $h, $textoObs[1], $aFont, 'T', 'L', 0, '', false);
2681
    } //fim da função obsDACTE
2682
2683
    /**
2684
     * zModalRod
2685
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2686
     *
2687
     * @param  number $x Posição horizontal canto esquerdo
2688
     * @param  number $y Posição vertical canto superior
2689
     * @return number Posição vertical final
2690
     */
2691
    protected function zModalRod($x = 0, $y = 0)
2692
    {
2693
        $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...
2694
        $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...
2695
        $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...
2696
        if ($this->orientacao == 'P') {
2697
            $maxW = $this->wPrint;
2698
        } else {
2699
            $maxW = $this->wPrint - $this->wCanhoto;
2700
        }
2701
        $w = $maxW;
2702
        $h = 3;
2703
        $texto = 'DADOS ESPECÍFICOS DO MODAL RODOVIÁRIO';
2704
        $aFont = $this->formatPadrao;
2705
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2706
        if ($this->lota == 1) {
2707
            $this->pdf->Line($x, $y + 12, $w + 1, $y + 12); // LINHA DE BAIXO
2708
        }
2709
        $y += 3.4;
2710
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA DE CIMA
2711
        $texto = 'RNTRC DA EMPRESA';
2712
        $aFont = $this->formatPadrao;
2713
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2714
        $texto = $this->pSimpleGetValue($this->rodo, "RNTRC");
2715
        $aFont = $this->formatNegrito;
2716
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2717
        $x += $w * 0.23;
2718
2719
        $this->pdf->Line($x-20, $y, $x-20, $y + 6); // LINHA A FRENTE DA RNTRC DA EMPRESA
2720
2721
        $texto = 'ESTE CONHECIMENTO DE TRANSPORTE ATENDE À LEGISLAÇÃO DE TRANSPORTE RODOVIÁRIO EM VIGOR';
2722
        $aFont = $this->formatPadrao;
2723
        $this->pTextBox($x-20, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'C', 0, '');
2724
    } //fim da função zModalRod
2725
2726
    /**
2727
     * zModalAereo
2728
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2729
     *
2730
     * @param  number $x Posição horizontal canto esquerdo
2731
     * @param  number $y Posição vertical canto superior
2732
     * @return number Posição vertical final
2733
     */
2734
    protected function zModalAereo($x = 0, $y = 0)
2735
    {
2736
        $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...
2737
        $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...
2738
        $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...
2739
        if ($this->orientacao == 'P') {
2740
            $maxW = $this->wPrint;
2741
        } else {
2742
            $maxW = $this->wPrint - $this->wCanhoto;
2743
        }
2744
        $w = $maxW;
2745
        $h = 3;
2746
        $texto = 'DADOS ESPECÍFICOS DO MODAL AÉREO';
2747
        $aFont = $this->formatPadrao;
2748
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2749
        $y += 3.4;
2750
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA DE CIMA
2751
        $texto = 'NÚMERO OPERACIONAL DO CONHECIMENTO AÉREO';
2752
        $aFont = $this->formatPadrao;
2753
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2754
2755
        $texto = 'CLASSE DA TARIFA';
2756
        $aFont = $this->formatPadrao;
2757
        $this->pTextBox($x+50, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2758
        $texto = 'CÓDIGO DA TARIFA';
2759
        $aFont = $this->formatPadrao;
2760
        $this->pTextBox($x+80, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2761
        $texto = 'VALOR DA TARIFA';
2762
        $aFont = $this->formatPadrao;
2763
        $this->pTextBox($x+110, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2764
2765
        $texto = $this->pSimpleGetValue($this->aereo, "nOCA");
2766
        $aFont = $this->formatNegrito;
2767
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2768
        $x += $w * 0.23;
2769
2770
        $this->pdf->Line($x, $y, $x, $y + 6); // LINHA APÓS NÚMERO OP. DO CT-E AEREO
2771
2772
        $texto = $this->pSimpleGetValue($this->aereo, "CL");
2773
        $aFont = $this->formatNegrito;
2774
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2775
        $x += 30;
2776
        $this->pdf->Line($x, $y, $x, $y + 6); // LINHA APÓS CLASSE DA TARIFA
2777
2778
        $texto = $this->pSimpleGetValue($this->aereo, "cTar");
2779
        $aFont = $this->formatNegrito;
2780
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2781
        $x += 30;
2782
        $this->pdf->Line($x, $y, $x, $y + 6); // LINHA APÓS COD DA TARIFA
2783
2784
        $texto = $this->pSimpleGetValue($this->aereo, "vTar");
2785
        $aFont = $this->formatNegrito;
2786
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2787
    } //fim da função zModalAereo
2788
2789
    /**
2790
     * zModalAquaviario
2791
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2792
     *
2793
     * @param  number $x Posição horizontal canto esquerdo
2794
     * @param  number $y Posição vertical canto superior
2795
     * @return number Posição vertical final
2796
     */
2797
    protected function zModalAquaviario($x = 0, $y = 0)
2798
    {
2799
        $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...
2800
        $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...
2801
        if ($this->orientacao == 'P') {
2802
            $maxW = $this->wPrint;
2803
        } else {
2804
            $maxW = $this->wPrint - $this->wCanhoto;
2805
        }
2806
        $w = $maxW;
2807
        $h = 8.5;
2808
        $texto = 'DADOS ESPECÍFICOS DO MODAL AQUAVIÁRIO';
2809
        $aFont = $this->formatPadrao;
2810
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2811
        $y += 3.4;
2812
        $this->pdf->Line($x, $y, $w + 1, $y);
2813
        $texto = 'PORTO DE EMBARQUE';
2814
        $aFont = $this->formatPadrao;
2815
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2816
        $texto = $this->pSimpleGetValue($this->aquav, "prtEmb");
2817
        $aFont = $this->formatNegrito;
2818
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2819
        $x += $w * 0.50;
2820
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2821
        $texto = 'PORTO DE DESTINO';
2822
        $aFont = $this->formatPadrao;
2823
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2824
        $texto = $this->pSimpleGetValue($this->aquav, "prtDest");
2825
        $aFont = $this->formatNegrito;
2826
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2827
        $y += 8;
2828
        $this->pdf->Line(208, $y, 1, $y);
2829
        $x = 1;
2830
        $texto = 'IDENTIFICAÇÃO DO NAVIO / REBOCADOR';
2831
        $aFont = $this->formatPadrao;
2832
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2833
        $texto = $this->pSimpleGetValue($this->aquav, "xNavio");
2834
        $aFont = $this->formatNegrito;
2835
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2836
        $x += $w * 0.50;
2837
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2838
        $texto = 'VR DA B. DE CALC. AFRMM';
2839
        $aFont = $this->formatPadrao;
2840
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2841
        $texto = $this->pSimpleGetValue($this->aquav, "vPrest");
2842
        $aFont = $this->formatNegrito;
2843
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2844
        $x += $w * 0.17;
2845
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2846
        $texto = 'VALOR DO AFRMM';
2847
        $aFont = $this->formatPadrao;
2848
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2849
        $texto = $this->pSimpleGetValue($this->aquav, "vAFRMM");
2850
        $aFont = $this->formatNegrito;
2851
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2852
        $x += $w * 0.12;
2853
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2854
        $texto = 'TIPO DE NAVEGAÇÃO';
2855
        $aFont = $this->formatPadrao;
2856
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2857
        $texto = $this->pSimpleGetValue($this->aquav, "tpNav");
2858
        switch ($texto) {
2859
            case '0':
2860
                $texto = 'INTERIOR';
2861
                break;
2862
            case '1':
2863
                $texto = 'CABOTAGEM';
2864
                break;
2865
        }
2866
        $aFont = $this->formatNegrito;
2867
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2868
        $x += $w * 0.14;
2869
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2870
        $texto = 'DIREÇÃO';
2871
        $aFont = $this->formatPadrao;
2872
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2873
        $texto = $this->pSimpleGetValue($this->aquav, "direc");
2874
        switch ($texto) {
2875
            case 'N':
2876
                $texto = 'NORTE';
2877
                break;
2878
            case 'L':
2879
                $texto = 'LESTE';
2880
                break;
2881
            case 'S':
2882
                $texto = 'SUL';
2883
                break;
2884
            case 'O':
2885
                $texto = 'OESTE';
2886
                break;
2887
        }
2888
        $aFont = $this->formatNegrito;
2889
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2890
        $y += 8;
2891
        $this->pdf->Line(208, $y, 1, $y);
2892
        $x = 1;
2893
        $texto = 'IDENTIFICAÇÃO DOS CONTEINERS';
2894
        $aFont = $this->formatPadrao;
2895
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2896
        if ($this->infNF->item(0) !== null && $this->infNF->item(0)->getElementsByTagName('infUnidCarga') !== null) {
2897
            $texto = $this->infNF
2898
                ->item(0)
2899
                ->getElementsByTagName('infUnidCarga')
2900
                ->item(0)
2901
                ->getElementsByTagName('idUnidCarga')
2902
                ->item(0)->nodeValue;
2903
        } elseif ($this->infNFe->item(0) !== null
2904
            && $this->infNFe->item(0)->getElementsByTagName('infUnidCarga') !== null
2905
        ) {
2906
            $texto = $this->infNFe
2907
                ->item(0)
2908
                ->getElementsByTagName('infUnidCarga')
2909
                ->item(0)
2910
                ->getElementsByTagName('idUnidCarga')
2911
                ->item(0)
2912
                ->nodeValue;
2913
        } elseif ($this->infOutros->item(0) !== null
2914
            && $this->infOutros->item(0)->getElementsByTagName('infUnidCarga') !== null
2915
        ) {
2916
            $texto = $this->infOutros
2917
                ->item(0)
2918
                ->getElementsByTagName('infUnidCarga')
2919
                ->item(0)
2920
                ->getElementsByTagName('idUnidCarga')
2921
                ->item(0)
2922
                ->nodeValue;
2923
        } else {
2924
            $texto = '';
2925
        }
2926
        $aFont = $this->formatNegrito;
2927
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2928
        $x += $w * 0.50;
2929
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2930
        $texto = 'IDENTIFICAÇÃO DAS BALSAS';
2931
        $aFont = $this->formatPadrao;
2932
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2933
        $texto = '';
2934
        if ($this->pSimpleGetValue($this->aquav, "balsa") !== '') {
2935
            foreach ($this->aquav->getElementsByTagName('balsa') as $k => $d) {
2936
                if ($k == 0) {
2937
                    $texto = $this->aquav
2938
                        ->getElementsByTagName('balsa')
2939
                        ->item($k)
2940
                        ->getElementsByTagName('xBalsa')
2941
                        ->item(0)
2942
                        ->nodeValue;
2943
                } else {
2944
                    $texto = $texto
2945
                        . ' / '
2946
                        . $this->aquav
2947
                            ->getElementsByTagName('balsa')
2948
                            ->item($k)
2949
                            ->getElementsByTagName('xBalsa')
2950
                            ->item(0)
2951
                            ->nodeValue;
2952
                }
2953
            }
2954
        }
2955
        $aFont = $this->formatNegrito;
2956
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2957
    } //fim da função zModalRod
2958
2959
    /**
2960
     * zModalFerr
2961
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2962
     *
2963
     * @param  number $x Posição horizontal canto esquerdo
2964
     * @param  number $y Posição vertical canto superior
2965
     * @return number Posição vertical final
2966
     */
2967
    protected function zModalFerr($x = 0, $y = 0)
2968
    {
2969
        $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...
2970
        $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...
2971
        if ($this->orientacao == 'P') {
2972
            $maxW = $this->wPrint;
2973
        } else {
2974
            $maxW = $this->wPrint - $this->wCanhoto;
2975
        }
2976
        $w = $maxW;
2977
        $h = 19.6;
2978
        $texto = 'DADOS ESPECÍFICOS DO MODAL FERROVIÁRIO';
2979
        $aFont = $this->formatPadrao;
2980
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2981
        $y += 3.4;
2982
        $this->pdf->Line($x, $y, $w + 1, $y);
2983
        $texto = 'DCL';
2984
        $aFont = array(
2985
            'font' => $this->fontePadrao,
2986
            'size' => 7,
2987
            'style' => 'B');
2988
        $this->pTextBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'C', 0, '');
2989
        $this->pdf->Line($x + 49.6, $y, $x + 49.6, $y + 3.5);
2990
        $texto = 'VAGÕES';
2991
        $aFont = array(
2992
            'font' => $this->fontePadrao,
2993
            'size' => 7,
2994
            'style' => 'B');
2995
        $this->pTextBox($x + 50, $y, $w * 0.5, $h, $texto, $aFont, 'T', 'C', 0, '');
2996
        $y += 3.4;
2997
        $this->pdf->Line($x, $y, $w + 1, $y);
2998
        // DCL
2999
        $texto = 'ID TREM';
3000
        $aFont = array(
3001
            'font' => $this->fontePadrao,
3002
            'size' => 6,
3003
            'style' => '');
3004
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3005
        $texto = $this->pSimpleGetValue($this->ferrov, "idTrem");
3006
        $aFont = array(
3007
            'font' => $this->fontePadrao,
3008
            'size' => 6,
3009
            'style' => 'B');
3010
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3011
        $x += $w * 0.06;
3012
        $y1 = $y + 12.5;
3013
        $this->pdf->Line($x, $y, $x, $y1);
3014
        $texto = 'NUM';
3015
        $aFont = array(
3016
            'font' => $this->fontePadrao,
3017
            'size' => 6,
3018
            'style' => '');
3019
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3020
        $texto = $this->pSimpleGetValue($this->rem, "nDoc");
3021
        $aFont = array(
3022
            'font' => $this->fontePadrao,
3023
            'size' => 6,
3024
            'style' => 'B');
3025
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3026
        $x += $w * 0.06;
3027
        $this->pdf->Line($x, $y, $x, $y1);
3028
        $texto = 'SÉRIE';
3029
        $aFont = array(
3030
            'font' => $this->fontePadrao,
3031
            'size' => 6,
3032
            'style' => '');
3033
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3034
        $texto = $this->pSimpleGetValue($this->rem, "serie");
3035
        $aFont = array(
3036
            'font' => $this->fontePadrao,
3037
            'size' => 6,
3038
            'style' => 'B');
3039
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3040
        $x += $w * 0.06;
3041
        $this->pdf->Line($x, $y, $x, $y1);
3042
        $texto = 'EMISSÃO';
3043
        $aFont = array(
3044
            'font' => $this->fontePadrao,
3045
            'size' => 6,
3046
            'style' => '');
3047
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3048
        $texto = $this->pYmd2dmy($this->pSimpleGetValue($this->rem, "dEmi"));
3049
        $aFont = array(
3050
            'font' => $this->fontePadrao,
3051
            'size' => 6,
3052
            'style' => 'B');
3053
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3054
        // VAGOES
3055
        $x += $w * 0.06;
3056
        $this->pdf->Line($x, $y, $x, $y1);
3057
        $texto = 'NUM';
3058
        $aFont = array(
3059
            'font' => $this->fontePadrao,
3060
            'size' => 6,
3061
            'style' => '');
3062
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3063
        $texto = $this->pSimpleGetValue($this->ferrov, "nVag");
3064
        $aFont = array(
3065
            'font' => $this->fontePadrao,
3066
            'size' => 6,
3067
            'style' => 'B');
3068
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3069
        $x += $w * 0.06;
3070
        $this->pdf->Line($x, $y, $x, $y1);
3071
        $texto = 'TIPO';
3072
        $aFont = array(
3073
            'font' => $this->fontePadrao,
3074
            'size' => 6,
3075
            'style' => '');
3076
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3077
        $texto = $this->pSimpleGetValue($this->ferrov, "tpVag");
3078
        $aFont = array(
3079
            'font' => $this->fontePadrao,
3080
            'size' => 6,
3081
            'style' => 'B');
3082
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3083
        $x += $w * 0.06;
3084
        $this->pdf->Line($x, $y, $x, $y1);
3085
        $texto = 'CAPACIDADE';
3086
        $aFont = array(
3087
            'font' => $this->fontePadrao,
3088
            'size' => 6,
3089
            'style' => '');
3090
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3091
        $texto = $this->pSimpleGetValue($this->ferrov, "cap");
3092
        $aFont = array(
3093
            'font' => $this->fontePadrao,
3094
            'size' => 6,
3095
            'style' => 'B');
3096
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3097
        $x += $w * 0.08;
3098
        $this->pdf->Line($x, $y, $x, $y1);
3099
        $texto = 'PESO REAL/TON';
3100
        $aFont = array(
3101
            'font' => $this->fontePadrao,
3102
            'size' => 6,
3103
            'style' => '');
3104
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3105
        $texto = $this->pSimpleGetValue($this->ferrov, "pesoR");
3106
        $aFont = array(
3107
            'font' => $this->fontePadrao,
3108
            'size' => 6,
3109
            'style' => 'B');
3110
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3111
        $x += $w * 0.09;
3112
        $this->pdf->Line($x, $y, $x, $y1);
3113
        $texto = 'PESO BRUTO/TON';
3114
        $aFont = array(
3115
            'font' => $this->fontePadrao,
3116
            'size' => 6,
3117
            'style' => '');
3118
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3119
        $texto = $this->pSimpleGetValue($this->ferrov, "pesoBC");
3120
        $aFont = array(
3121
            'font' => $this->fontePadrao,
3122
            'size' => 6,
3123
            'style' => 'B');
3124
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3125
        $x += $w * 0.1;
3126
        $this->pdf->Line($x, $y, $x, $y1);
3127
        $texto = 'IDENTIFICAÇÃO DOS CONTÊINERES';
3128
        $aFont = array(
3129
            'font' => $this->fontePadrao,
3130
            'size' => 6,
3131
            'style' => '');
3132
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3133
        $texto = $this->pSimpleGetValue($this->ferrov, "nCont");
3134
        $aFont = array(
3135
            'font' => $this->fontePadrao,
3136
            'size' => 6,
3137
            'style' => 'B');
3138
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3139
        // FLUXO
3140
        $x = 1;
3141
        $y += 12.9;
3142
        $h1 = $h * 0.5 + 0.27;
3143
        $wa = round($w * 0.103) + 0.5;
3144
        $texto = 'FLUXO FERROVIARIO';
3145
        $aFont = $this->formatPadrao;
3146
        $this->pTextBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
3147
        $texto = $this->pSimpleGetValue($this->ferrov, "fluxo");
3148
        $aFont = array(
3149
            'font' => $this->fontePadrao,
3150
            'size' => 7,
3151
            'style' => 'B');
3152
        $this->pTextBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
3153
        $y += 10;
3154
        $texto = 'TIPO DE TRÁFEGO';
3155
        $aFont = $this->formatPadrao;
3156
        $this->pTextBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
3157
        $texto = $this->zConvertUnidTrafego($this->pSimpleGetValue($this->ferrov, "tpTraf"));
3158
        $aFont = array(
3159
            'font' => $this->fontePadrao,
3160
            'size' => 7,
3161
            'style' => 'B');
3162
        $this->pTextBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
3163
        // Novo Box Relativo a Modal Ferroviário
3164
        $x = 22.5;
3165
        $y += -10.2;
3166
        $texto = 'INFORMAÇÕES DAS FERROVIAS ENVOLVIDAS';
3167
        $aFont = $this->formatPadrao;
3168
        $this->pTextBox($x, $y, $w - 21.5, $h1 * 2.019, $texto, $aFont, 'T', 'C', 1, '');
3169
        $y += 3.4;
3170
        $this->pdf->Line($x, $y, $w + 1, $y);
3171
        $w = $w * 0.2;
3172
        $h = $h * 1.04;
3173
        $texto = 'CÓDIGO INTERNO';
3174
        $aFont = array(
3175
            'font' => $this->fontePadrao,
3176
            'size' => 6,
3177
            'style' => '');
3178
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3179
        $texto = $this->pSimpleGetValue($this->ferrov, "cInt");
3180
        $aFont = array(
3181
            'font' => $this->fontePadrao,
3182
            'size' => 6,
3183
            'style' => 'B');
3184
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3185
        $texto = 'CNPJ';
3186
        $aFont = array(
3187
            'font' => $this->fontePadrao,
3188
            'size' => 6,
3189
            'style' => '');
3190
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3191
        $texto = $this->pSimpleGetValue($this->ferrov, "CNPJ");
3192
        $aFont = array(
3193
            'font' => $this->fontePadrao,
3194
            'size' => 6,
3195
            'style' => 'B');
3196
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3197
        $x += 50;
3198
        $texto = 'NOME';
3199
        $aFont = array(
3200
            'font' => $this->fontePadrao,
3201
            'size' => 6,
3202
            'style' => '');
3203
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3204
        $texto = $this->pSimpleGetValue($this->ferrov, "xNome");
3205
        $aFont = array(
3206
            'font' => $this->fontePadrao,
3207
            'size' => 6,
3208
            'style' => 'B');
3209
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3210
        $texto = 'INSCRICAO ESTADUAL';
3211
        $aFont = array(
3212
            'font' => $this->fontePadrao,
3213
            'size' => 6,
3214
            'style' => '');
3215
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3216
        $texto = $this->pSimpleGetValue($this->ferrov, "IE");
3217
        $aFont = array(
3218
            'font' => $this->fontePadrao,
3219
            'size' => 6,
3220
            'style' => 'B');
3221
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3222
        $x += 50;
3223
        $texto = 'PARTICIPAÇÃO OUTRA FERROVIA';
3224
        $aFont = array(
3225
            'font' => $this->fontePadrao,
3226
            'size' => 6,
3227
            'style' => '');
3228
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3229
        $texto = '';
3230
        $aFont = array(
3231
            'font' => $this->fontePadrao,
3232
            'size' => 6,
3233
            'style' => 'B');
3234
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3235
    } //fim da função zModalFerr
3236
3237
    /**
3238
     * zCanhoto
3239
     * Monta o campo com os dados do remetente na DACTE.
3240
     *
3241
     * @param  number $x Posição horizontal canto esquerdo
3242
     * @param  number $y Posição vertical canto superior
3243
     * @return number Posição vertical final
3244
     */
3245
    protected function zCanhoto($x = 0, $y = 0)
3246
    {
3247
        $this->zhDashedLine($x, $y+2, $this->wPrint, 0.1, 80);
3248
        $y = $y + 2;
3249
        $oldX = $x;
3250
        $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...
3251
        if ($this->orientacao == 'P') {
3252
            $maxW = $this->wPrint;
3253
        } else {
3254
            $maxW = $this->wPrint - $this->wCanhoto;
3255
        }
3256
        $w = $maxW - 1;
3257
        $h = 20;
3258
        $y = $y + 1;
3259
        $texto = 'DECLARO QUE RECEBI OS VOLUMES DESTE CONHECIMENTO EM PERFEITO ESTADO ';
3260
        $texto .= 'PELO QUE DOU POR CUMPRIDO O PRESENTE CONTRATO DE TRANSPORTE';
3261
        $aFont = $this->formatPadrao;
3262
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3263
        $y += 3.4;
3264
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA ABAICO DO TEXTO DECLARO QUE RECEBI...
3265
3266
        $texto = 'NOME';
3267
        $aFont = array(
3268
            'font' => $this->fontePadrao,
3269
            'size' => 6,
3270
            'style' => '');
3271
        $this->pTextBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'L', 0, '');
3272
        $x += $w * 0.25;
3273
3274
        $this->pdf->Line($x, $y, $x, $y + 16.5);
3275
3276
        $texto = 'ASSINATURA / CARIMBO';
3277
        $aFont = array(
3278
            'font' => $this->fontePadrao,
3279
            'size' => 6,
3280
            'style' => '');
3281
        $this->pTextBox($x, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'B', 'C', 0, '');
3282
        $x += $w * 0.25;
3283
3284
        $this->pdf->Line($x, $y, $x, $y + 16.5);
3285
3286
        $texto = 'TÉRMINO DA PRESTAÇÃO - DATA/HORA' . "\r\n" . "\r\n" . "\r\n". "\r\n";
3287
        $texto .= ' INÍCIO DA PRESTAÇÃO - DATA/HORA';
3288
        $aFont = array(
3289
            'font' => $this->fontePadrao,
3290
            'size' => 6,
3291
            'style' => '');
3292
        $this->pTextBox($x + 10, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'T', 'C', 0, '');
3293
        $x = $oldX;
3294
        $y = $y + 5;
3295
3296
        $this->pdf->Line($x, $y+3, $w * 0.255, $y+3); // LINHA HORIZONTAL ACIMA DO RG ABAIXO DO NOME
3297
3298
        $texto = 'RG';
3299
        $aFont = array(
3300
            'font' => $this->fontePadrao,
3301
            'size' => 6,
3302
            'style' => '');
3303
        $this->pTextBox($x, $y+3, $w * 0.33, $h, $texto, $aFont, 'T', 'L', 0, '');
3304
        $x += $w * 0.85;
3305
3306
        $this->pdf->Line($x, $y + 11.5, $x, $y - 5); // LINHA VERTICAL PROXIMO AO CT-E
3307
3308
        $texto = "CT-E";
3309
        $aFont = $this->formatNegrito;
3310
        $this->pTextBox($x, $y - 5, $w * 0.15, $h, $texto, $aFont, 'T', 'C', 0, '');
3311
        $texto = "\r\n Nº. DOCUMENTO  " . $this->pSimpleGetValue($this->ide, "nCT") . " \n";
3312
        $texto .= "\r\n SÉRIE  " . $this->pSimpleGetValue($this->ide, "serie");
3313
        $aFont = array(
3314
            'font' => $this->fontePadrao,
3315
            'size' => 6,
3316
            'style' => '');
3317
        $this->pTextBox($x, $y - 8, $w * 0.15, $h, $texto, $aFont, 'C', 'C', 0, '');
3318
        $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...
3319
        //$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...
3320
    } //fim da função canhotoDACTE
3321
3322
    /**
3323
     * zDadosAdic
3324
     * Coloca o grupo de dados adicionais da DACTE.
3325
     *
3326
     * @param  number $x Posição horizontal canto esquerdo
3327
     * @param  number $y Posição vertical canto superior
3328
     * @param  number $h altura do campo
3329
     * @return number Posição vertical final
3330
     */
3331
    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...
3332
    {
3333
        $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...
3334
        //###########################################################################
3335
        //DADOS ADICIONAIS DACTE
3336
        if ($this->orientacao == 'P') {
3337
            $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...
3338
        } else {
3339
            $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...
3340
        }
3341
        //INFORMAÇÕES COMPLEMENTARES
3342
        $texto = "USO EXCLUSIVO DO EMISSOR DO CT-E";
3343
        $y += 3;
3344
        $w = $this->wAdic;
3345
        $h = 8; //mudar
3346
        $aFont = array(
3347
            'font' => $this->fontePadrao,
3348
            'size' => 6,
3349
            'style' => '');
3350
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3351
        //$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...
3352
        $this->pdf->Line($x, $y + 3, $w * 1.385, $y + 3);
3353
        //o texto com os dados adicionais foi obtido na função xxxxxx
3354
        //e carregado em uma propriedade privada da classe
3355
        //$this->wAdic com a largura do campo
3356
        //$this->textoAdic com o texto completo do campo
3357
        $y += 1;
3358
        $aFont = $this->formatPadrao;
3359
        $this->pTextBox($x, $y + 3, $w - 2, $h - 3, $this->textoAdic, $aFont, 'T', 'L', 0, '', false);
3360
        //RESERVADO AO FISCO
3361
        $texto = "RESERVADO AO FISCO";
3362
        $x += $w;
3363
        $y -= 1;
3364
        if ($this->orientacao == 'P') {
3365
            $w = $this->wPrint - $w;
3366
        } else {
3367
            $w = $this->wPrint - $w - $this->wCanhoto;
3368
        }
3369
        $aFont = array(
3370
            'font' => $this->fontePadrao,
3371
            'size' => 6,
3372
            'style' => '');
3373
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3374
        //inserir texto informando caso de contingência
3375
        //1 – Normal – emissão normal;
3376
        //2 – Contingência FS – emissão em contingência com impressão do DACTE em Formulário de Segurança;
3377
        //3 – Contingência SCAN – emissão em contingência  – SCAN;
3378
        //4 – Contingência DPEC - emissão em contingência com envio da Declaração Prévia de
3379
        //Emissão em Contingência – DPEC;
3380
        //5 – Contingência FS-DA - emissão em contingência com impressão do DACTE em Formulário de
3381
        //Segurança para Impressão de Documento Auxiliar de Documento Fiscal Eletrônico (FS-DA).
3382
        $xJust = $this->pSimpleGetValue($this->ide, 'xJust', 'Justificativa: ');
3383
        $dhCont = $this->pSimpleGetValue($this->ide, 'dhCont', ' Entrada em contingência : ');
3384
        $texto = '';
3385
        switch ($this->tpEmis) {
3386
            case 2:
3387
                $texto = 'CONTINGÊNCIA FS' . $dhCont . $xJust;
3388
                break;
3389
            case 3:
3390
                $texto = 'CONTINGÊNCIA SCAN' . $dhCont . $xJust;
3391
                break;
3392
            case 4:
3393
                $texto = 'CONTINGÊNCIA DPEC' . $dhCont . $xJust;
3394
                break;
3395
            case 5:
3396
                $texto = 'CONTINGÊNCIA FSDA' . $dhCont . $xJust;
3397
                break;
3398
        }
3399
        $y += 2;
3400
        $aFont = $this->formatPadrao;
3401
        $this->pTextBox($x, $y + 2, $w - 2, $h - 3, $texto, $aFont, 'T', 'L', 0, '', false);
3402
        return $y + $h;
3403
    } //fim zDadosAdic
3404
3405
    /**
3406
     * zhDashedLine
3407
     * Desenha uma linha horizontal tracejada com o FPDF
3408
     *
3409
     * @param  number $x Posição horizontal inicial, em mm
3410
     * @param  number $y Posição vertical inicial, em mm
3411
     * @param  number $w Comprimento da linha, em mm
3412
     * @param  number $h Espessura da linha, em mm
3413
     * @param  number $n Numero de traços na seção da linha com o comprimento $w
3414
     * @return none
3415
     */
3416
    protected function zhDashedLine($x, $y, $w, $h, $n)
3417
    {
3418
        $this->pdf->SetLineWidth($h);
3419
        $wDash = ($w / $n) / 2; // comprimento dos traços
3420
        for ($i = $x; $i <= $x + $w; $i += $wDash + $wDash) {
3421
            for ($j = $i; $j <= ($i + $wDash); $j++) {
3422
                if ($j <= ($x + $w - 1)) {
3423
                    $this->pdf->Line($j, $y, $j + 1, $y);
3424
                }
3425
            }
3426
        }
3427
    } //fim função hDashedLine
3428
3429
    /**
3430
     * zhDashedVerticalLine
3431
     * Desenha uma linha vertical tracejada com o FPDF
3432
     *
3433
     * @param  number $x Posição horizontal inicial, em mm
3434
     * @param  number $y Posição vertical inicial, em mm
3435
     * @param  number $w Comprimento da linha, em mm
3436
     * @param  number $yfinal Espessura da linha, em mm
3437
     * @param  number $n Numero de traços na seção da linha com o comprimento $w
3438
     * @return none
3439
     */
3440
    protected function zhDashedVerticalLine($x, $y, $w, $yfinal, $n)
3441
    {
3442
        $this->pdf->SetLineWidth($w);
3443
        /* Organizando valores */
3444
        if ($y > $yfinal) {
3445
            $aux = $yfinal;
3446
            $yfinal = $y;
3447
            $y = $aux;
3448
        }
3449
        while ($y < $yfinal && $n > 0) {
3450
            $this->pdf->Line($x, $y, $x, $y + 1);
3451
            $y += 3;
3452
            $n--;
3453
        }
3454
    } //fim função hDashedVerticalLine
3455
3456
    /**
3457
     * zFormatCNPJCPF
3458
     * Formata campo CnpjCpf contida na CTe
3459
     *
3460
     * @param  string $field campo cnpjCpf da CT-e
3461
     * @return string
3462
     */
3463
    protected function zFormatCNPJCPF($field)
3464
    {
3465
        if (!isset($field)) {
3466
            return '';
3467
        }
3468
        $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...
3469
            $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...
3470
        if ($cnpj != "" && $cnpj != "00000000000000") {
3471
            $cnpj = $this->pFormat($cnpj, '###.###.###/####-##');
3472
        } else {
3473
            $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...
3474
                $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...
3475
        }
3476
        return $cnpj;
3477
    } //fim formatCNPJCPF
3478
3479
    /**
3480
     * zFormatFone
3481
     * Formata campo fone contida na CTe
3482
     *
3483
     * @param  string $field campo fone da CT-e
3484
     * @return string
3485
     */
3486
    protected function zFormatFone($field)
3487
    {
3488
        try {
3489
            $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...
3490
            $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...
3491
            $foneLen = strlen($fone);
3492
            if ($foneLen > 0) {
3493
                $fone2 = substr($fone, 0, $foneLen - 4);
3494
                $fone1 = substr($fone, 0, $foneLen - 8);
3495
                $fone = '(' . $fone1 . ') ' . substr($fone2, -4) . '-' . substr($fone, -4);
3496
            } else {
3497
                $fone = '';
3498
            }
3499
            return $fone;
3500
        } catch (Exception $exc) {
3501
            return '';
3502
        }
3503
    } //fim formatFone
3504
3505
    /**
3506
     * zUnidade
3507
     * Converte a imformação de peso contida na CTe
3508
     *
3509
     * @param  string $c unidade de trafego extraida da CTe
3510
     * @return string
3511
     */
3512
    protected function zUnidade($c = '')
3513
    {
3514
        switch ($c) {
3515
            case '00':
3516
                $r = 'M3';
3517
                break;
3518
            case '01':
3519
                $r = 'KG';
3520
                break;
3521
            case '02':
3522
                $r = 'TON';
3523
                break;
3524
            case '03':
3525
                $r = 'UN';
3526
                break;
3527
            case '04':
3528
                $r = 'LT';
3529
                break;
3530
            case '05':
3531
                $r = 'MMBTU';
3532
                break;
3533
            default:
3534
                $r = '';
3535
        }
3536
        return $r;
3537
    } //fim unidade
3538
3539
    /**
3540
     * zConvertUnidTrafego
3541
     * Converte a imformação de peso contida na CTe
3542
     *
3543
     * @param  string $U Informação de trafego extraida da CTe
3544
     * @return string
3545
     */
3546
    protected function zConvertUnidTrafego($U = '')
3547
    {
3548
        if ($U) {
3549
            switch ($U) {
3550
                case '0':
3551
                    $stringU = 'Próprio';
3552
                    break;
3553
                case '1':
3554
                    $stringU = 'Mútuo';
3555
                    break;
3556
                case '2':
3557
                    $stringU = 'Rodoferroviário';
3558
                    break;
3559
                case '3':
3560
                    $stringU = 'Rodoviário';
3561
                    break;
3562
            }
3563
            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...
3564
        }
3565
    } //fim da função zConvertUnidTrafego
3566
3567
    /**
3568
     * zMultiUniPeso
3569
     * Fornece a imformação multiplicação de peso contida na CTe
3570
     *
3571
     * @param  interger $U Informação de peso extraida da CTe
3572
     * @return interger
3573
     */
3574
    protected function zMultiUniPeso($U = '')
3575
    {
3576
        if ($U === "01") {
3577
            // tonelada
3578
            //return 1000;
3579
            return 1;
3580
        }
3581
        return 1; // M3, KG, Unidade, litros, mmbtu
3582
    } //fim da função zMultiUniPeso
3583
}
3584