Passed
Pull Request — master (#110)
by
unknown
04:09
created

DacteV3::zhDashedLine()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 7
nc 4
nop 5
dl 0
loc 12
ccs 0
cts 12
cp 0
crap 20
rs 9.2
c 1
b 0
f 0
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
            $textoAdic = number_format($this->pSimpleGetValue($this->imp, "vTotTrib"), 2, ",", ".");
207
            $this->textoAdic = "o valor aproximado de tributos incidentes sobre o preço deste serviço é de R$"
208
                    .$textoAdic;
209
            $this->toma4 = $this->dom->getElementsByTagName("toma4")->item(0);
210
            $this->toma03 = $this->dom->getElementsByTagName("toma3")->item(0);
211
            //Tag tomador é identificado por toma03 na versão 2.00
212
            if ($this->infCte->getAttribute("versao")=="2.00") {
213
                $this->toma03 = $this->dom->getElementsByTagName("toma03")->item(0);
214
            }
215
            //modal aquaviário
216
            $this->aquav = $this->dom->getElementsByTagName("aquav")->item(0);
217
            $tomador = $this->pSimpleGetValue($this->toma03, "toma");
218
            //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...
219
            switch ($tomador) {
220
                case '0':
221
                    $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...
222
                    $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...
223
                    break;
224
                case '1':
225
                    $this->toma = $this->exped;
226
                    $this->enderToma = $this->enderExped;
227
                    break;
228
                case '2':
229
                    $this->toma = $this->receb;
230
                    $this->enderToma = $this->enderReceb;
231
                    break;
232
                case '3':
233
                    $this->toma = $this->dest;
234
                    $this->enderToma = $this->enderDest;
235
                    break;
236
                default:
237
                    $this->toma = $this->toma4;
238
                    $this->enderToma = $this->pSimpleGetValue($this->toma4, "enderToma");
239
                    break;
240
            }
241
            /*$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...
242
            switch ($seguro) {
243
                case '0':
244
                    $this->respSeg = 'Remetente';
245
                    break;
246
                case '1':
247
                    $this->respSeg = 'Expedidor';
248
                    break;
249
                case '2':
250
                    $this->respSeg = 'Recebedor';
251
                    break;
252
                case '3':
253
                    $this->respSeg = 'Destinatário';
254
                    break;
255
                case '4':
256
                    $this->respSeg = 'Emitente';
257
                    break;
258
                case '5':
259
                    $this->respSeg = 'Tomador';
260
                    break;
261
                default:
262
                    $this->respSeg = '';
263
                    break;
264
            }*/
265
            $this->tpEmis = $this->pSimpleGetValue($this->ide, "tpEmis");
266
            $this->tpImp = $this->pSimpleGetValue($this->ide, "tpImp");
267
            $this->tpAmb = $this->pSimpleGetValue($this->ide, "tpAmb");
268
            $this->tpCTe = $this->pSimpleGetValue($this->ide, "tpCTe");
269
270
            $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...
271
            //01-Rodoviário; //02-Aéreo; //03-Aquaviário; //04-Ferroviário;//05-Dutoviário
272
            $this->modal = $this->pSimpleGetValue($this->ide, "modal");
273
        }
274
    }
275
276
    /**
277
     * monta
278
     * @param string $orientacao L ou P
279
     * @param string $papel A4
280
     * @param string $logoAlign C, L ou R
281
     * @param Pdf $classPDF
282
     * @return string montagem
283
     */
284
    public function monta(
285
        $orientacao = '',
286
        $papel = 'A4',
287
        $logoAlign = 'C',
288
        $classPDF = false
289
    ) {
290
291
        return $this->montaDACTE($orientacao, $papel, $logoAlign, $classPDF);
0 ignored issues
show
Bug introduced by
It seems like $classPDF defined by parameter $classPDF on line 288 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...
292
    }
293
294
    /**
295
     * printDocument
296
     * @param string $nome
297
     * @param string $destino
298
     * @param string $printer
299
     * @return
300
     */
301
    public function printDocument($nome = '', $destino = 'I', $printer = '')
302
    {
303
        return $this->printDACTE($nome, $destino, $printer);
304
    }
305
306
    /**
307
     * Dados brutos do PDF
308
     * @return string
309
     */
310
    public function render()
311
    {
312
        return $this->pdf->getPdf();
313
    }
314
315
316
    protected function zCteDPEC()
317
    {
318
        return $this->situacao_externa == self::SIT_DPEC && $this->numero_registro_dpec != '';
319
    }
320
321
322
    /**
323
     * montaDACTE
324
     * Esta função monta a DACTE conforme as informações fornecidas para a classe
325
     * durante sua construção.
326
     * A definição de margens e posições iniciais para a impressão são estabelecidas no
327
     * pelo conteúdo da funçao e podem ser modificados.
328
     *
329
     * @param  string $orientacao (Opcional) Estabelece a orientação da
330
     *                impressão (ex. P-retrato), se nada for fornecido será
331
     *                usado o padrão da NFe
332
     * @param  string $papel (Opcional) Estabelece o tamanho do papel (ex. A4)
333
     * @return string O ID da NFe numero de 44 digitos extraido do arquivo XML
334
     */
335
    public function montaDACTE(
336
        $orientacao = '',
337
        $papel = 'A4',
338
        $logoAlign = 'C',
339
        $classPDF = false
340
    ) {
341
342
        //se a orientação estiver em branco utilizar o padrão estabelecido na NF
343
        if ($orientacao == '') {
344
            if ($this->tpImp == '1') {
345
                $orientacao = 'P';
346
            } else {
347
                $orientacao = 'P';
348
            }
349
        }
350
        $this->orientacao = $orientacao;
351
        $this->papel = $papel;
352
        $this->logoAlign = $logoAlign;
353
354
        //$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...
355
        //instancia a classe pdf
356
        if ($classPDF !== false) {
357
            $this->pdf = $classPDF;
358
        } else {
359
            $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
360
        }
361
        if ($this->orientacao == 'P') {
362
            // margens do PDF
363
            $margSup = 2;
364
            $margEsq = 2;
365
            $margDir = 2;
366
            // posição inicial do relatorio
367
            $xInic = 1;
368
            $yInic = 1;
369
            if ($papel == 'A4') {
370
                //A4 210x297mm
371
                $maxW = 210;
372
                $maxH = 297;
373
            }
374
        } else {
375
            // margens do PDF
376
            $margSup = 3;
377
            $margEsq = 3;
378
            $margDir = 3;
379
            // posição inicial do relatorio
380
            $xInic = 5;
381
            $yInic = 5;
382
            if ($papel == 'A4') {
383
                //A4 210x297mm
384
                $maxH = 210;
385
                $maxW = 297;
386
                $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...
387
            }
388
        }
389
        //total inicial de paginas
390
        $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...
391
        //largura imprimivel em mm
392
        $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...
393
        //comprimento imprimivel em mm
394
        $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...
395
        // estabelece contagem de paginas
396
        $this->pdf->AliasNbPages();
397
        // fixa as margens
398
        $this->pdf->SetMargins($margEsq, $margSup, $margDir);
399
        $this->pdf->SetDrawColor(0, 0, 0);
400
        $this->pdf->SetFillColor(255, 255, 255);
401
        // inicia o documento
402
        $this->pdf->Open();
403
        // adiciona a primeira página
404
        $this->pdf->AddPage($this->orientacao, $this->papel);
405
        $this->pdf->SetLineWidth(0.1);
406
        $this->pdf->SetTextColor(0, 0, 0);
407
        //calculo do numero de páginas ???
408
        $totPag = 1;
409
        //montagem da primeira página
410
        $pag = 1;
411
        $x = $xInic;
412
        $y = $yInic;
413
        //coloca o cabeçalho
414
        //$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...
415
        $y += 70;
416
        $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...
417
        $x = $this->wPrint * 0.5 + 2;
418
        $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...
419
        $y += 19;
420
        $x = $xInic;
421
        $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...
422
        $x = $this->wPrint * 0.5 + 2;
423
        $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...
424
        $y += 19;
425
        $x = $xInic;
426
        $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...
427
        if ($this->tpCTe == '0') {
428
            //Normal
429
            $y += 10;
430
            $x = $xInic;
431
            $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...
432
            $y += 17;
433
            $x = $xInic;
434
            $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...
435
            $y += 25;
436
            $x = $xInic;
437
            $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...
438
            $y += 13;
439
            $x = $xInic;
440
            $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...
441
            if ($this->modal == '1') {
442
                if ($this->lota == 1) {
443
                    //$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...
444
                    $y += 35;
445
                } else {
446
                    $y += 53;
447
                }
448
            } elseif ($this->modal == '2') {
449
                $y += 53;
450
            } elseif ($this->modal == '3') {
451
                $y += 37.75;
452
            } else {
453
                $y += 24.95;
454
            }
455
            $x = $xInic;
456
            $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...
457
            $y = $y-6;
458
            switch ($this->modal) {
459
                case '1':
460
                    $y += 25.9;
461
                    $x = $xInic;
462
                    $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...
463
                    break;
464
                case '2':
465
                    $y += 25.9;
466
                    $x = $xInic;
467
                    $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...
468
                    break;
469
                case '3':
470
                    $y += 17.9;
471
                    $x = $xInic;
472
                    $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...
473
                    break;
474
                case '4':
475
                    $y += 17.9;
476
                    $x = $xInic;
477
                    $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...
478
                    break;
479
                case '5':
480
                    $y += 17.9;
481
                    $x = $xInic;
482
                    // TODO fmertins 31/10/14: este método não existe...
483
                    $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...
484
                    break;
485
            }
486
            if ($this->modal == '1') {
487
                if ($this->lota == 1) {
488
                    $y += 37;
489
                } else {
490
                    $y += 8.9;
491
                }
492
            } elseif ($this->modal == '2') {
493
                $y += 8.9;
494
            } elseif ($this->modal == '3') {
495
                $y += 24.15;
496
            } else {
497
                $y += 37;
498
            }
499
        } else {
500
            $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...
501
            //Complementado
502
            $y += 10;
503
            $x = $xInic;
504
            $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...
505
            $y += 80;
506
            $x = $xInic;
507
            $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...
508
            $y += 25;
509
            $x = $xInic;
510
            $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...
511
            $y += 13;
512
            $x = $xInic;
513
            $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...
514
            $y += 15;
515
        }
516
        $x = $xInic;
517
        $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...
518
519
        //$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...
520
        $y += 11;
521
        $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...
522
523
        //coloca o rodapé da página
524
        if ($this->orientacao == 'P') {
525
            $this->zRodape(2, $this->hPrint - 2);
526
        } else {
527
            $this->zRodape($xInic, $this->hPrint + 2.3);
528
        }
529
        if ($this->flagDocOrigContinuacao == 1) {
530
            $this->zdocOrigContinuacao(1, 71);
531
        }
532
        //retorna o ID na CTe
533
        if ($classPDF !== false) {
534
            $aR = array('id' => str_replace('CTe', '', $this->infCte->getAttribute("Id")), 'classe_PDF' => $this->pdf);
535
            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...
536
        } else {
537
            return str_replace('CTe', '', $this->infCte->getAttribute("Id"));
538
        }
539
    } //fim da função montaDACTE
540
541
    /**
542
     * printDACTE
543
     * Esta função envia a DACTE em PDF criada para o dispositivo informado.
544
     * O destino da impressão pode ser :
545
     * I-browser
546
     * D-browser com download
547
     * F-salva em um arquivo local com o nome informado
548
     * S-retorna o documento como uma string e o nome é ignorado.
549
     * Para enviar o pdf diretamente para uma impressora indique o
550
     * nome da impressora e o destino deve ser 'S'.
551
     *
552
     * @param  string $nome Path completo com o nome do arquivo pdf
553
     * @param  string $destino Direção do envio do PDF
554
     * @param  string $printer Identificação da impressora no sistema
555
     * @return string Caso o destino seja S o pdf é retornado como uma string
556
     * @todo Rotina de impressão direta do arquivo pdf criado
557
     */
558
    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...
559
    {
560
        $arq = $this->pdf->Output($nome, $destino);
561
        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...
562
            //aqui pode entrar a rotina de impressão direta
563
        }
564
        return $arq;
565
    } //fim função printDACTE
566
567
    /**
568
     * zCabecalho
569
     * Monta o cabelhalho da DACTE ( retrato e paisagem )
570
     *
571
     * @param  number $x Posição horizontal inicial, canto esquerdo
572
     * @param  number $y Posição vertical inicial, canto superior
573
     * @param  number $pag Número da Página
574
     * @param  number $totPag Total de páginas
575
     * @return number Posição vertical final
576
     */
577
    protected function zCabecalho($x = 0, $y = 0, $pag = '1', $totPag = '1')
578
    {
579
        $oldX = $x;
580
        $oldY = $y;
581
        if ($this->orientacao == 'P') {
582
            $maxW = $this->wPrint;
583
        } else {
584
            if ($pag == 1) {
585
                // primeira página
586
                $maxW = $this->wPrint - $this->wCanhoto;
587
            } else {
588
                // páginas seguintes
589
                $maxW = $this->wPrint;
590
            }
591
        }
592
        //##################################################################
593
        //coluna esquerda identificação do emitente
594
        $w = round($maxW * 0.42);
595
        if ($this->orientacao == 'P') {
596
            $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...
597
                'font' => $this->fontePadrao,
598
                'size' => 6,
599
                'style' => '');
600
        } else {
601
            $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...
602
        }
603
        $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...
604
        $h = 35;
605
        $oldY += $h;
606
        //desenha a caixa
607
        $this->pTextBox($x, $y, $w + 2, $h + 1);
608
        // coloca o logo
609
        if (is_file($this->logomarca)) {
610
            $logoInfo = getimagesize($this->logomarca);
611
            //largura da imagem em mm
612
            $logoWmm = ($logoInfo[0] / 72) * 25.4;
613
            //altura da imagem em mm
614
            $logoHmm = ($logoInfo[1] / 72) * 25.4;
615
            if ($this->logoAlign == 'L') {
616
                $nImgW = round($w / 3, 0);
617
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
618
                $xImg = $x + 1;
619
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
620
                //estabelecer posições do texto
621
                $x1 = round($xImg + $nImgW + 1, 0);
622
                $y1 = round($h / 3 + $y, 0);
623
                $tw = round(2 * $w / 3, 0);
624
            } elseif ($this->logoAlign == 'C') {
625
                $nImgH = round($h / 3, 0);
626
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
627
                $xImg = round(($w - $nImgW) / 2 + $x, 0);
628
                $yImg = $y + 3;
629
                $x1 = $x;
630
                $y1 = round($yImg + $nImgH + 1, 0);
631
                $tw = $w;
632
            } elseif ($this->logoAlign == 'R') {
633
                $nImgW = round($w / 3, 0);
634
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
635
                $xImg = round($x + ($w - (1 + $nImgW)), 0);
636
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
637
                $x1 = $x;
638
                $y1 = round($h / 3 + $y, 0);
639
                $tw = round(2 * $w / 3, 0);
640
            }
641
            $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...
642
        } else {
643
            $x1 = $x;
644
            $y1 = round($h / 3 + $y, 0);
645
            $tw = $w;
646
        }
647
        //Nome emitente
648
        $aFont = array(
649
            'font' => $this->fontePadrao,
650
            'size' => 9,
651
            'style' => 'B');
652
        $texto = $this->pSimpleGetValue($this->emit, "xNome");
653
        $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...
654
        //endereço
655
        $y1 = $y1 + 3;
656
        $aFont = array(
657
            'font' => $this->fontePadrao,
658
            'size' => 7,
659
            'style' => '');
660
        $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...
661
        $lgr = $this->pSimpleGetValue($this->enderEmit, "xLgr");
662
        $nro = $this->pSimpleGetValue($this->enderEmit, "nro");
663
        $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...
664
        $bairro = $this->pSimpleGetValue($this->enderEmit, "xBairro");
665
        $CEP = $this->pSimpleGetValue($this->enderEmit, "CEP");
666
        $CEP = $this->pFormat($CEP, "#####-###");
667
        $mun = $this->pSimpleGetValue($this->enderEmit, "xMun");
668
        $UF = $this->pSimpleGetValue($this->enderEmit, "UF");
669
        $xPais = $this->pSimpleGetValue($this->enderEmit, "xPais");
670
        $texto = $lgr . "," . $nro . "\n" . $bairro . " - "
671
            . $CEP . " - " . $mun . " - " . $UF . " " . $xPais
672
            . "\n  Fone/Fax: " . $fone;
673
        $this->pTextBox($x1 - 5, $y1 + 2, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
674
        //CNPJ/CPF IE
675
        $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...
676
        $ie = $this->pSimpleGetValue($this->emit, "IE");
677
        $texto = 'CNPJ/CPF:  ' . $cpfCnpj . '     Insc.Estadual: ' . $ie;
678
        $this->pTextBox($x1 - 1, $y1 + 12, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
679
        //outra caixa
680
        $h1 = 17.5;
681
        $y1 = $y + $h + 1;
682
        $this->pTextBox($x, $y1, $w + 2, $h1);
683
        //TIPO DO CT-E
684
        $texto = 'TIPO DO CTE';
685
        $wa = 37;
686
        $aFont = array(
687
            'font' => $this->fontePadrao,
688
            'size' => 8,
689
            'style' => '');
690
        $this->pTextBox($x, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
691
        $tpCTe = $this->pSimpleGetValue($this->ide, "tpCTe");
692
        //0 - CT-e Normal,1 - CT-e de Complemento de Valores,
693
        //2 - CT-e de Anulação de Valores,3 - CT-e Substituto
694
        switch ($tpCTe) {
695
            case '0':
696
                $texto = 'Normal';
697
                break;
698
            case '1':
699
                $texto = 'Complemento de Valores';
700
                break;
701
            case '2':
702
                $texto = 'Anulação de Valores';
703
                break;
704
            case '3':
705
                $texto = 'Substituto';
706
                break;
707
            default:
708
                $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...
709
        }
710
        $aFont = $this->formatNegrito;
711
        $this->pTextBox($x, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
712
        //TIPO DO SERVIÇO
713
        $texto = 'TIPO DO SERVIÇO';
714
        $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...
715
        $aFont = array(
716
            'font' => $this->fontePadrao,
717
            'size' => 8,
718
            'style' => '');
719
        $this->pTextBox($x + $wa + 4.5, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
720
        $tpServ = $this->pSimpleGetValue($this->ide, "tpServ");
721
        //0 - Normal;1 - Subcontratação;2 - Redespacho;3 - Redespacho Intermediário
722
        switch ($tpServ) {
723
            case '0':
724
                $texto = 'Normal';
725
                break;
726
            case '1':
727
                $texto = 'Subcontratação';
728
                break;
729
            case '2':
730
                $texto = 'Redespacho';
731
                break;
732
            case '3':
733
                $texto = 'Redespacho Intermediário';
734
                break;
735
            default:
736
                $texto = 'ERRO' . $tpServ;
737
        }
738
        $aFont = $this->formatNegrito;
739
        $this->pTextBox($x + $wa + 4.5, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
740
        $this->pdf->Line($w * 0.5, $y1, $w * 0.5, $y1 + $h1);
741
        //TOMADOR DO SERVIÇO
742
        $texto = 'INDICADOR DO CT-E GLOBALIZADO';
743
        $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...
744
        $y2 = $y1 + 8;
745
        $aFont = array(
746
            'font' => $this->fontePadrao,
747
            'size' => 6,
748
            'style' => '');
749
        $this->pTextBox($x, $y2, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
750
        $this->pdf->Line($x, $y1 + 8, $w + 3, $y1 + 8);
751
        $toma = $this->pSimpleGetValue($this->ide, "indGlobalizado");
752
        //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...
753
        if ($toma==1) {
754
            $aFont = array(
755
            'font' => $this->fontePadrao,
756
            'size' => 11,
757
            'style' => '');
758
            $this->pTextBox($x-14.5, $y2 + 3.5, $w * 0.5, $h1, 'X', $aFont, 'T', 'C', 0, '', false);
759
        } else {
760
            $aFont = array(
761
            'font' => $this->fontePadrao,
762
            'size' => 11,
763
            'style' => '');
764
            $this->pTextBox($x+3.5, $y2 + 3.5, $w * 0.5, $h1, 'X', $aFont, 'T', 'C', 0, '', false);
765
        }
766
        $aFont = $this->formatNegrito;
767
        $this->pdf->Line($x+5, $x+48, $x+5, $x+52);
768
        $this->pdf->Line($x+10, $x+48, $x+10, $x+52);
769
        $this->pdf->Line($x+5, $x+48, $x+10, $x+48);
770
        $this->pdf->Line($x+5, $x+52, $x+10, $x+52);
771
        $this->pTextBox($x-9, $y2+1.4 + 3, $w * 0.5, $h1, 'SIM', $aFont, 'T', 'C', 0, '', false);
772
773
        $this->pdf->Line($x+23, $x+48, $x+23, $x+52);
774
        $this->pdf->Line($x+28, $x+48, $x+28, $x+52);
775
        $this->pdf->Line($x+23, $x+48, $x+28, $x+48);
776
        $this->pdf->Line($x+23, $x+52, $x+28, $x+52);
777
        $this->pTextBox($x+9.8, $y2+1.4 + 3, $w * 0.5, $h1, 'NÃO', $aFont, 'T', 'C', 0, '', false);
778
779
        //FORMA DE PAGAMENTO
780
        $texto = 'INFORMAÇÕES DO CT-E GLOBALIZADO';
781
        $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...
782
        $aFont = array(
783
            'font' => $this->fontePadrao,
784
            'size' => 8,
785
            'style' => '');
786
        $this->pTextBox($x+2 + $wa + 4.5, $y2-0.7, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
787
        $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...
788
        //##################################################################
789
        //coluna direita
790
        $x += $w + 2;
791
        $w = round($maxW * 0.335);
792
        $w1 = $w;
793
        $h = 11;
794
        $this->pTextBox($x, $y, $w + 2, $h + 1);
795
        $texto = "DACTE";
796
        $aFont = array(
797
            'font' => $this->fontePadrao,
798
            'size' => 10,
799
            'style' => 'B');
800
        $this->pTextBox($x, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
801
        $aFont = array(
802
            'font' => $this->fontePadrao,
803
            'size' => 8,
804
            'style' => '');
805
        $texto = "Documento Auxiliar do Conhecimento\nde Transporte Eletrônico";
806
        $h = 10;
807
        $this->pTextBox($x, $y + 4, $w, $h, $texto, $aFont, 'T', 'C', 0, '', false);
808
        $x1 = $x + $w + 2;
809
        $w = round($maxW * 0.22, 0);
810
        $w2 = $w;
811
        $h = 11;
812
        $this->pTextBox($x1, $y, $w + 0.5, $h + 1);
813
        $texto = "MODAL";
814
        $aFont = array(
815
            'font' => $this->fontePadrao,
816
            'size' => 8,
817
            'style' => '');
818
        $this->pTextBox($x1, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
819
        switch ($this->modal) {
820
            case '1':
821
                $texto = 'Rodoviário';
822
                break;
823
            case '2':
824
                $texto = 'Aéreo';
825
                break;
826
            case '3':
827
                $texto = 'Aquaviário';
828
                break;
829
            case '4':
830
                $texto = 'Ferroviário';
831
                break;
832
            case '5':
833
                $texto = 'Dutoviário';
834
                break;
835
        }
836
        $aFont = array(
837
            'font' => $this->fontePadrao,
838
            'size' => 10,
839
            'style' => 'B');
840
        $this->pTextBox($x1, $y + 5, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
841
        //outra caixa
842
        $y += 12;
843
        $h = 9;
844
        $w = $w1 + $w2 + 2;
845
        $this->pTextBox($x, $y, $w + 0.5, $h + 1);
846
        //modelo
847
        $wa = 12;
848
        $xa = $x;
849
        $texto = 'MODELO';
850
        $aFont = array(
851
            'font' => $this->fontePadrao,
852
            'size' => 8,
853
            'style' => '');
854
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
855
        $texto = $this->pSimpleGetValue($this->ide, "mod");
856
        $aFont = $this->formatNegrito;
857
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
858
        $this->pdf->Line($x + $wa, $y, $x + $wa, $y + $h + 1);
859
        //serie
860
        $xa += $wa;
861
        $texto = 'SÉRIE';
862
        $aFont = array(
863
            'font' => $this->fontePadrao,
864
            'size' => 8,
865
            'style' => '');
866
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
867
        $texto = $this->pSimpleGetValue($this->ide, "serie");
868
        $aFont = $this->formatNegrito;
869
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
870
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
871
        //numero
872
        $xa += $wa;
873
        $wa = 20;
874
        $texto = 'NÚMERO';
875
        $aFont = array(
876
            'font' => $this->fontePadrao,
877
            'size' => 8,
878
            'style' => '');
879
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
880
        $texto = $this->pSimpleGetValue($this->ide, "nCT");
881
        $aFont = $this->formatNegrito;
882
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
883
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
884
        //folha
885
        $xa += $wa;
886
        $wa = 12;
887
        $texto = 'FL';
888
        $aFont = array(
889
            'font' => $this->fontePadrao,
890
            'size' => 8,
891
            'style' => '');
892
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
893
        //$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...
894
        $texto = $pag."/".$totPag;
895
        $aFont = $this->formatNegrito;
896
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
897
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
898
        //data  hora de emissão
899
        $xa += $wa;
900
        $wa = 30;
901
        $texto = 'DATA E HORA DE EMISSÃO';
902
        $aFont = array(
903
            'font' => $this->fontePadrao,
904
            'size' => 8,
905
            'style' => '');
906
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
907
        $texto = !empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
908
            date('d/m/Y H:i:s', $this->pConvertTime($this->pSimpleGetValue($this->ide, "dhEmi"))) : '';
909
        $aFont = $this->formatNegrito;
910
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
911
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
912
        //ISUF
913
        $xa += $wa;
914
        $wa = 32;
915
        $texto = 'INSC. SUFRAMA DO DESTINATÁRIO';
916
        $aFont = $this->formatPadrao;
917
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
918
        $texto = $this->pSimpleGetValue($this->dest, "ISUF");
919
        $aFont = array(
920
            'font' => $this->fontePadrao,
921
            'size' => 7,
922
            'style' => 'B');
923
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
924
        //outra caixa
925
        $y += $h + 1;
926
        $h = 23;
927
        $h1 = 14;
928
        $this->pTextBox($x, $y, $w + 0.5, $h1);
929
        //CODIGO DE BARRAS
930
        $chave_acesso = str_replace('CTe', '', $this->infCte->getAttribute("Id"));
931
        $bW = 85;
932
        $bH = 10;
933
        //codigo de barras
934
        $this->pdf->SetFillColor(0, 0, 0);
935
        $this->pdf->Code128($x + (($w - $bW) / 2), $y + 2, $chave_acesso, $bW, $bH);
936
        $this->pTextBox($x, $y + $h1, $w + 0.5, $h1 - 6);
937
        $texto = 'CHAVE DE ACESSO';
938
        $aFont = $this->formatPadrao;
939
        $this->pTextBox($x, $y + $h1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
940
        $aFont = $this->formatNegrito;
941
        $texto = $this->pFormat($chave_acesso, '##.####.##.###.###/####-##-##-###-###.###.###-###.###.###-#');
942
        $this->pTextBox($x, $y + $h1 + 3, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
943
        $this->pTextBox($x, $y + $h1 + 8, $w + 0.5, $h1 - 4.5);
944
        $texto = "Consulta de autenticidade no portal nacional do CT-e, ";
945
        $texto .= "no site da Sefaz Autorizadora, \r\n ou em http://www.cte.fazenda.gov.br";
946
        if ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
947
            $texto = "";
948
            $this->pdf->SetFillColor(0, 0, 0);
949
            if ($this->tpEmis == 5) {
950
                $chaveContingencia = $this->zGeraChaveAdicCont();
951
                $this->pdf->Code128($x + 20, $y1 + 10, $chaveContingencia, $bW * .9, $bH / 2);
952
            } else {
953
                $chaveContingencia = $this->pSimpleGetValue($this->protCTe, "nProt");
954
                $this->pdf->Code128($x + 40, $y1 + 10, $chaveContingencia, $bW * .4, $bH / 2);
955
            }
956
            //codigo de barras
957
        }
958
        $aFont = array(
959
            'font' => $this->fontePadrao,
960
            'size' => 8,
961
            'style' => '');
962
        $this->pTextBox($x, $y + $h1 + 9, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
963
        //outra caixa
964
        $y += $h + 1;
965
        $h = 8.5;
966
        $wa = $w;
967
        $this->pTextBox($x, $y + 7.5, $w + 0.5, $h);
968
        if ($this->zCteDPEC()) {
969
            $texto = 'NÚMERO DE REGISTRO DPEC';
970
        } elseif ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
971
            $texto = "DADOS DO CT-E";
972
        } else {
973
            $texto = 'PROTOCOLO DE AUTORIZAÇÃO DE USO';
974
        }
975
        $aFont = $this->formatPadrao;
976
        $this->pTextBox($x, $y + 7.5, $wa, $h, $texto, $aFont, 'T', 'L', 0, '');
977
        if ($this->zCteDPEC()) {
978
            $texto = $this->numero_registro_dpec;
979
        } elseif ($this->tpEmis == 5) {
980
            $chaveContingencia = $this->zGeraChaveAdicCont();
981
            $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...
982
                'font' => $this->fontePadrao,
983
                'size' => 8,
984
                'style' => 'B');
985
            $texto = $this->pFormat($chaveContingencia, "#### #### #### #### #### #### #### #### ####");
986
            $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...
987
        } else {
988
            $texto = $this->pSimpleGetValue($this->protCTe, "nProt") . " - ";
989
            // 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...
990
            if (!empty($this->protCTe)
991
                && !empty($this->protCTe->getElementsByTagName("dhRecbto")->item(0)->nodeValue)
992
            ) {
993
                $texto .= date(
994
                    'd/m/Y   H:i:s',
995
                    $this->pConvertTime($this->pSimpleGetValue($this->protCTe, "dhRecbto"))
996
                );
997
            }
998
            $texto = $this->pSimpleGetValue($this->protCTe, "nProt") == '' ? '' : $texto;
999
        }
1000
        $aFont = $this->formatNegrito;
1001
        $this->pTextBox($x, $y + 12, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
1002
        //CFOP
1003
        $x = $oldX;
1004
        $h = 8.5;
1005
        $w = round($maxW * 0.42);
1006
        $y1 = $y + 7.5;
1007
        $this->pTextBox($x, $y1, $w + 2, $h);
1008
        $texto = 'CFOP - NATUREZA DA PRESTAÇÃO';
1009
        $aFont = array(
1010
            'font' => $this->fontePadrao,
1011
            'size' => 8,
1012
            'style' => '');
1013
        $this->pTextBox($x, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1014
        $texto = $this->pSimpleGetValue($this->ide, "CFOP") . ' - ' . $this->pSimpleGetValue($this->ide, "natOp");
1015
        $aFont = $this->formatNegrito;
1016
        $this->pTextBox($x, $y1 + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1017
        //ORIGEM DA PRESTAÇÃO
1018
        $y += $h + 7.5;
1019
        $x = $oldX;
1020
        $h = 8;
1021
        $w = ($maxW * 0.5);
1022
        $this->pTextBox($x, $y, $w + 0.5, $h);
1023
        $texto = 'INÍCIO DA PRESTAÇÃO';
1024
        $aFont = array(
1025
            'font' => $this->fontePadrao,
1026
            'size' => 8,
1027
            'style' => '');
1028
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1029
        $texto = $this->pSimpleGetValue($this->ide, "xMunIni") . ' - ' . $this->pSimpleGetValue($this->ide, "UFIni");
1030
        $aFont = $this->formatNegrito;
1031
        $this->pTextBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1032
        //DESTINO DA PRESTAÇÃO
1033
        $x = $oldX + $w + 1;
1034
        $h = 8;
1035
        $w = $w - 1.3;
1036
        $this->pTextBox($x - 0.5, $y, $w + 0.5, $h);
1037
        $texto = 'TÉRMINO DA PRESTAÇÃO';
1038
        $aFont = array(
1039
            'font' => $this->fontePadrao,
1040
            'size' => 8,
1041
            'style' => '');
1042
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1043
        $texto = $this->pSimpleGetValue($this->ide, "xMunFim") . ' - ' . $this->pSimpleGetValue($this->ide, "UFFim");
1044
        $aFont = $this->formatNegrito;
1045
        $this->pTextBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1046
        //#########################################################################
1047
        //Indicação de CTe Homologação, cancelamento e falta de protocolo
1048
        $tpAmb = $this->ide->getElementsByTagName('tpAmb')->item(0)->nodeValue;
1049
        //indicar cancelamento
1050
        $cStat = $this->pSimpleGetValue($this->cteProc, "cStat");
1051
        if ($cStat == '101' || $cStat == '135' || $this->situacao_externa == self::NFEPHP_SITUACAO_EXTERNA_CANCELADA) {
1052
            //101 Cancelamento
1053
            $x = 10;
1054
            $y = $this->hPrint - 130;
1055
            $h = 25;
1056
            $w = $maxW - (2 * $x);
1057
            $this->pdf->SetTextColor(90, 90, 90);
1058
            $texto = "CTe CANCELADO";
1059
            $aFont = array(
1060
                'font' => $this->fontePadrao,
1061
                'size' => 48,
1062
                'style' => 'B');
1063
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1064
            $this->pdf->SetTextColor(0, 0, 0);
1065
        }
1066
        $cStat = $this->pSimpleGetValue($this->cteProc, "cStat");
1067
        if ($cStat == '110' ||
1068
            $cStat == '301' ||
1069
            $cStat == '302' ||
1070
            $this->situacao_externa == self::NFEPHP_SITUACAO_EXTERNA_DENEGADA
1071
        ) {
1072
            //110 Denegada
1073
            $x = 10;
1074
            $y = $this->hPrint - 130;
1075
            $h = 25;
1076
            $w = $maxW - (2 * $x);
1077
            $this->pdf->SetTextColor(90, 90, 90);
1078
            $texto = "CTe USO DENEGADO";
1079
            $aFont = array(
1080
                'font' => $this->fontePadrao,
1081
                'size' => 48,
1082
                'style' => 'B');
1083
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1084
            $y += $h;
1085
            $h = 5;
1086
            $w = $maxW - (2 * $x);
1087
            $texto = "SEM VALOR FISCAL";
1088
            $aFont = array(
1089
                'font' => $this->fontePadrao,
1090
                'size' => 48,
1091
                'style' => 'B');
1092
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1093
            $this->pdf->SetTextColor(0, 0, 0);
1094
        }
1095
        //indicar sem valor
1096
        if ($tpAmb != 1 && $this->preVisualizar=='0') { // caso não seja uma DA de produção
1097
            $x = 10;
1098
            if ($this->orientacao == 'P') {
1099
                $y = round($this->hPrint * 2 / 3, 0);
1100
            } else {
1101
                $y = round($this->hPrint / 2, 0);
1102
            }
1103
            $h = 5;
1104
            $w = $maxW - (2 * $x);
1105
            $this->pdf->SetTextColor(90, 90, 90);
1106
            $texto = "SEM VALOR FISCAL";
1107
            $aFont = array(
1108
                'font' => $this->fontePadrao,
1109
                'size' => 48,
1110
                'style' => 'B');
1111
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1112
            $aFont = array(
1113
                'font' => $this->fontePadrao,
1114
                'size' => 30,
1115
                'style' => 'B');
1116
            $texto = "AMBIENTE DE HOMOLOGAÇÃO";
1117
            $this->pTextBox($x, $y + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1118
            $this->pdf->SetTextColor(0, 0, 0);
1119
        } elseif ($this->preVisualizar=='1') { // caso seja uma DA de Pré-Visualização
1120
            $h = 5;
1121
            $w = $maxW - (2 * 10);
1122
            $x = 55;
1123
            $y = 240;
1124
            $this->pdf->SetTextColor(255, 100, 100);
1125
            $aFont = array(
1126
                'font' => $this->fontePadrao,
1127
                'size' => 40,
1128
                'style' => 'B');
1129
            $texto = "Pré-visualização";
1130
            $this->pTextBox90($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1131
            $this->pdf->SetTextColor(255, 100, 100);
1132
            $aFont = array(
1133
                'font' => $this->fontePadrao,
1134
                'size' => 41,
1135
                'style' => 'B');
1136
            $texto = "Sem Validade Jurídica";
1137
            $this->pTextBox90($x+20, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1138
            $this->pdf->SetTextColor(90, 90, 90);
1139
            $texto = "SEM VALOR FISCAL";
1140
            $aFont = array(
1141
                'font' => $this->fontePadrao,
1142
                'size' => 48,
1143
                'style' => 'B');
1144
            $this->pTextBox90($x+40, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1145
            $this->pdf->SetTextColor(0, 0, 0); // voltar a cor default
1146
        } else {
1147
            $x = 10;
1148
            if ($this->orientacao == 'P') {
1149
                $y = round($this->hPrint * 2 / 3, 0);
1150
            } else {
1151
                $y = round($this->hPrint / 2, 0);
1152
            } //fim orientacao
1153
            $h = 5;
1154
            $w = $maxW - (2 * $x);
1155
            $this->pdf->SetTextColor(90, 90, 90);
1156
            //indicar FALTA DO PROTOCOLO se NFe não for em contingência
1157
            if (($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) && !$this->zCteDPEC()) {
1158
                //Contingência
1159
                $texto = "DACTE Emitido em Contingência";
1160
                $aFont = array(
1161
                    'font' => $this->fontePadrao,
1162
                    'size' => 48,
1163
                    'style' => 'B');
1164
                $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1165
                $aFont = array(
1166
                    'font' => $this->fontePadrao,
1167
                    'size' => 30,
1168
                    'style' => 'B');
1169
                $texto = "devido à problemas técnicos";
1170
                $this->pTextBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1171
            } else {
1172
                if (!isset($this->protCTe)) {
1173
                    if (!$this->zCteDPEC()) {
1174
                        $texto = "SEM VALOR FISCAL";
1175
                        $aFont = array(
1176
                            'font' => $this->fontePadrao,
1177
                            'size' => 48,
1178
                            'style' => 'B');
1179
                        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1180
                    }
1181
                    $aFont = array(
1182
                        'font' => $this->fontePadrao,
1183
                        'size' => 30,
1184
                        'style' => 'B');
1185
                    $texto = "FALTA PROTOCOLO DE APROVAÇÃO DA SEFAZ";
1186
                    if (!$this->zCteDPEC()) {
1187
                        $this->pTextBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1188
                    } else {
1189
                        $this->pTextBox($x, $y + 25, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1190
                    }
1191
                } //fim cteProc
1192
                if ($this->tpEmis == 4) {
1193
                    //DPEC
1194
                    $x = 10;
1195
                    $y = $this->hPrint - 130;
1196
                    $h = 25;
1197
                    $w = $maxW - (2 * $x);
1198
                    $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...
1199
                    $texto = "DACTE impresso em contingência -\n"
1200
                        . "DPEC regularmente recebido pela Receita\n"
1201
                        . "Federal do Brasil";
1202
                    $aFont = array(
1203
                        'font' => $this->fontePadrao,
1204
                        'size' => 48,
1205
                        'style' => 'B');
1206
                    $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1207
                    $this->pdf->SetTextColor(0, 0, 0);
1208
                }
1209
            } //fim tpEmis
1210
            $this->pdf->SetTextColor(0, 0, 0);
1211
        }
1212
        return $oldY;
1213
    } //fim zCabecalho
1214
1215
    /**
1216
     * rodapeDACTE
1217
     * Monta o rodape no final da DACTE ( retrato e paisagem )
1218
     *
1219
     * @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...
1220
     * @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...
1221
     */
1222
    protected function zRodape($x, $y)
1223
    {
1224
        $texto = "Impresso em  " . date('d/m/Y   H:i:s');
1225
        $w = $this->wPrint - 4;
1226
        $aFont = array(
1227
            'font' => $this->fontePadrao,
1228
            'size' => 6,
1229
            'style' => '');
1230
        $this->pTextBox($x, $y, $w, 4, $texto, $aFont, 'T', 'L', 0, '');
1231
        $texto = 'Desenvolvido por '.$this->nomeDesenvolvedor . ' - '. $this->siteDesenvolvedor;
1232
        $aFont = array(
1233
            'font' => $this->fontePadrao,
1234
            'size' => 6,
1235
            'style' => '');
1236
        $this->pTextBox($x, $y, $w, 4, $texto, $aFont, 'T', 'R', 0, $this->siteDesenvolvedor);
1237
    } //fim zRodape
1238
1239
    /**
1240
     * zRemetente
1241
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1242
     *
1243
     * @param  number $x Posição horizontal canto esquerdo
1244
     * @param  number $y Posição vertical canto superior
1245
     * @return number Posição vertical final
1246
     */
1247
    protected function zRemetente($x = 0, $y = 0)
1248
    {
1249
        $oldX = $x;
1250
        $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...
1251
        if ($this->orientacao == 'P') {
1252
            $maxW = $this->wPrint;
1253
        } else {
1254
            $maxW = $this->wPrint - $this->wCanhoto;
1255
        }
1256
        $w = $maxW * 0.5 + 0.5;
1257
        $h = 19;
1258
        $x1 = $x + 16;
1259
        $texto = 'REMETENTE';
1260
        $aFont = $this->formatPadrao;
1261
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1262
        $aFont = $this->formatNegrito;
1263
        $texto = $this->pSimpleGetValue($this->rem, "xNome");
1264
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1265
        $y += 3;
1266
        $texto = 'ENDEREÇO';
1267
        $aFont = $this->formatPadrao;
1268
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1269
        $aFont = $this->formatNegrito;
1270
        $texto = $this->pSimpleGetValue($this->enderReme, "xLgr") . ',';
1271
        $texto .= $this->pSimpleGetValue($this->enderReme, "nro");
1272
        $texto .= ($this->pSimpleGetValue($this->enderReme, "xCpl") != "") ?
1273
            ' - ' . $this->pSimpleGetValue($this->enderReme, "xCpl") : '';
1274
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1275
        $y += 3;
1276
        $texto = $this->pSimpleGetValue($this->enderReme, "xBairro");
1277
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1278
        $y += 3;
1279
        $texto = 'MUNICÍPIO';
1280
        $aFont = $this->formatPadrao;
1281
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1282
        $texto = $this->pSimpleGetValue($this->enderReme, "xMun") . ' - ';
1283
        $texto .= $this->pSimpleGetValue($this->enderReme, "UF");
1284
        $aFont = $this->formatNegrito;
1285
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1286
        $x = $w - 18;
1287
        $texto = 'CEP';
1288
        $aFont = $this->formatPadrao;
1289
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1290
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderReme, "CEP"), "#####-###");
1291
        $aFont = $this->formatNegrito;
1292
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1293
        $x = $oldX;
1294
        $y += 3;
1295
        $texto = 'CNPJ/CPF';
1296
        $aFont = $this->formatPadrao;
1297
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1298
        $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...
1299
        $aFont = $this->formatNegrito;
1300
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1301
        $x = $w - 45;
1302
        $texto = 'INSCRIÇÃO ESTADUAL';
1303
        $aFont = $this->formatPadrao;
1304
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1305
        $texto = $this->pSimpleGetValue($this->rem, "IE");
1306
        $aFont = $this->formatNegrito;
1307
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1308
        $x = $oldX;
1309
        $y += 3;
1310
        $texto = 'PAÍS';
1311
        $aFont = $this->formatPadrao;
1312
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1313
        $texto = $this->pSimpleGetValue($this->rem, "xPais") != "" ?
1314
            $this->pSimpleGetValue($this->rem, "xPais") : 'BRASIL';
1315
        $aFont = $this->formatNegrito;
1316
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1317
        $x = $w - 25;
1318
        $texto = 'FONE';
1319
        $aFont = $this->formatPadrao;
1320
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1321
        //$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...
1322
        $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...
1323
        $aFont = $this->formatNegrito;
1324
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1325
    } //fim da função remetenteDACTE
1326
1327
    /**
1328
     * zDestinatario
1329
     * Monta o campo com os dados do destinatário na DACTE.
1330
     *
1331
     * @param  number $x Posição horizontal canto esquerdo
1332
     * @param  number $y Posição vertical canto superior
1333
     * @return number Posição vertical final
1334
     */
1335
    protected function zDestinatario($x = 0, $y = 0)
1336
    {
1337
        $oldX = $x;
1338
        $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...
1339
        if ($this->orientacao == 'P') {
1340
            $maxW = $this->wPrint;
1341
        } else {
1342
            $maxW = $this->wPrint - $this->wCanhoto;
1343
        }
1344
        $w = ($maxW * 0.5) - 0.7;
1345
        $h = 19;
1346
        $x1 = $x + 19;
1347
        $texto = 'DESTINATÁRIO';
1348
        $aFont = $this->formatPadrao;
1349
        $this->pTextBox($x - 0.5, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1350
        $aFont = $this->formatNegrito;
1351
        $texto = $this->pSimpleGetValue($this->dest, "xNome");
1352
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1353
        $y += 3;
1354
        $texto = 'ENDEREÇO';
1355
        $aFont = $this->formatPadrao;
1356
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1357
        $aFont = $this->formatNegrito;
1358
        $texto = $this->pSimpleGetValue($this->enderDest, "xLgr") . ',';
1359
        $texto .= $this->pSimpleGetValue($this->enderDest, "nro");
1360
        $texto .= $this->pSimpleGetValue($this->enderDest, "xCpl") != "" ?
1361
            ' - ' . $this->pSimpleGetValue($this->enderDest, "xCpl") : '';
1362
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1363
        $y += 3;
1364
        $texto = $this->pSimpleGetValue($this->enderDest, "xBairro");
1365
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1366
        $y += 3;
1367
        $texto = 'MUNICÍPIO';
1368
        $aFont = $this->formatPadrao;
1369
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1370
        $texto = $this->pSimpleGetValue($this->enderDest, "xMun") . ' - ';
1371
        $texto .= $this->pSimpleGetValue($this->enderDest, "UF");
1372
        $aFont = $this->formatNegrito;
1373
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1374
        $x = $w - 19 + $oldX;
1375
        $texto = 'CEP';
1376
        $aFont = $this->formatPadrao;
1377
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1378
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderDest, "CEP"), "#####-###");
1379
        $aFont = $this->formatNegrito;
1380
        $this->pTextBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1381
        $x = $oldX;
1382
        $y += 3;
1383
        $texto = 'CNPJ/CPF';
1384
        $aFont = $this->formatPadrao;
1385
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1386
        $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...
1387
        $aFont = $this->formatNegrito;
1388
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1389
        $x = $w - 47.5 + $oldX;
1390
        $texto = 'INSCRIÇÃO ESTADUAL';
1391
        $aFont = $this->formatPadrao;
1392
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1393
        $texto = $this->pSimpleGetValue($this->dest, "IE");
1394
        $aFont = $this->formatNegrito;
1395
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1396
        $x = $oldX;
1397
        $y += 3;
1398
        $texto = 'PAÍS';
1399
        $aFont = $this->formatPadrao;
1400
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1401
        $texto = $this->pSimpleGetValue($this->dest, "xPais");
1402
        $aFont = $this->formatNegrito;
1403
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1404
        $x = $w - 27 + $oldX;
1405
        $texto = 'FONE';
1406
        $aFont = $this->formatPadrao;
1407
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1408
        //$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...
1409
        $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...
1410
        $aFont = $this->formatNegrito;
1411
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1412
    } //fim da função destinatarioDACTE
1413
1414
    /**
1415
     * zExpedidor
1416
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1417
     *
1418
     * @param  number $x Posição horizontal canto esquerdo
1419
     * @param  number $y Posição vertical canto superior
1420
     * @return number Posição vertical final
1421
     */
1422
    protected function zExpedidor($x = 0, $y = 0)
1423
    {
1424
        $oldX = $x;
1425
        $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...
1426
        if ($this->orientacao == 'P') {
1427
            $maxW = $this->wPrint;
1428
        } else {
1429
            $maxW = $this->wPrint - $this->wCanhoto;
1430
        }
1431
        $w = $maxW * 0.5 + 0.5;
1432
        $h = 19;
1433
        $x1 = $x + 16;
1434
        $texto = 'EXPEDIDOR';
1435
        $aFont = $this->formatPadrao;
1436
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1437
        $aFont = $this->formatNegrito;
1438
        $texto = $this->pSimpleGetValue($this->exped, "xNome");
1439
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1440
        $y += 3;
1441
        $texto = 'ENDEREÇO';
1442
        $aFont = $this->formatPadrao;
1443
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1444
        $aFont = $this->formatNegrito;
1445
        if (isset($this->enderExped)) {
1446
            $texto = $this->pSimpleGetValue($this->enderExped, "xLgr") . ', ';
1447
            $texto .= $this->pSimpleGetValue($this->enderExped, "nro");
1448
            $texto .= $this->pSimpleGetValue($this->enderExped, "xCpl") != "" ?
1449
                ' - ' . $this->pSimpleGetValue($this->enderExped, "xCpl") :
1450
                '';
1451
        } else {
1452
            $texto = '';
1453
        }
1454
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1455
        $y += 3;
1456
        $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...
1457
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1458
        $y += 3;
1459
        $texto = 'MUNICÍPIO';
1460
        $aFont = $this->formatPadrao;
1461
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1462
        if (isset($this->enderExped)) {
1463
            $texto = $this->pSimpleGetValue($this->enderExped, "xMun") . ' - ';
1464
            $texto .= $this->pSimpleGetValue($this->enderExped, "UF");
1465
        } else {
1466
            $texto = '';
1467
        }
1468
        $aFont = $this->formatNegrito;
1469
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1470
        $x = $w - 18;
1471
        $texto = 'CEP';
1472
        $aFont = $this->formatPadrao;
1473
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1474
        $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...
1475
        $aFont = $this->formatNegrito;
1476
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1477
        $x = $oldX;
1478
        $y += 3;
1479
        $texto = 'CNPJ/CPF';
1480
        $aFont = $this->formatPadrao;
1481
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1482
        $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...
1483
        $aFont = $this->formatNegrito;
1484
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1485
        $x = $w - 45;
1486
        $texto = 'INSCRIÇÃO ESTADUAL';
1487
        $aFont = $this->formatPadrao;
1488
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1489
        $texto = $this->pSimpleGetValue($this->exped, "IE");
1490
        $aFont = $this->formatNegrito;
1491
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1492
        $x = $oldX;
1493
        $y += 3;
1494
        $texto = 'PAÍS';
1495
        $aFont = $this->formatPadrao;
1496
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1497
        $texto = $this->pSimpleGetValue($this->exped, "xPais");
1498
        $aFont = $this->formatNegrito;
1499
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1500
        $x = $w - 25;
1501
        $texto = 'FONE';
1502
        $aFont = $this->formatPadrao;
1503
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1504
        if (isset($this->exped)) {
1505
            $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...
1506
            $aFont = $this->formatNegrito;
1507
            $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1508
        }
1509
    } //fim da função remetenteDACTE
1510
1511
    /**
1512
     * zRecebedor
1513
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1514
     *
1515
     * @param  number $x Posição horizontal canto esquerdo
1516
     * @param  number $y Posição vertical canto superior
1517
     * @return number Posição vertical final
1518
     */
1519
    protected function zRecebedor($x = 0, $y = 0)
1520
    {
1521
        $oldX = $x;
1522
        $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...
1523
        if ($this->orientacao == 'P') {
1524
            $maxW = $this->wPrint;
1525
        } else {
1526
            $maxW = $this->wPrint - $this->wCanhoto;
1527
        }
1528
        $w = ($maxW * 0.5) - 0.7;
1529
        $h = 19;
1530
        $x1 = $x + 19;
1531
        $texto = 'RECEBEDOR';
1532
        $aFont = $this->formatPadrao;
1533
        $this->pTextBox($x - 0.5, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1534
        $aFont = $this->formatNegrito;
1535
        $texto = $this->pSimpleGetValue($this->receb, "xNome");
1536
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1537
        $y += 3;
1538
        $texto = 'ENDEREÇO';
1539
        $aFont = $this->formatPadrao;
1540
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1541
        $aFont = $this->formatNegrito;
1542
        if (isset($this->enderReceb)) {
1543
            $texto = $this->pSimpleGetValue($this->enderReceb, "xLgr") . ', ';
1544
            $texto .= $this->pSimpleGetValue($this->enderReceb, "nro");
1545
            $texto .= ($this->pSimpleGetValue($this->enderReceb, "xCpl") != "") ?
1546
                ' - ' . $this->pSimpleGetValue($this->enderReceb, "xCpl") :
1547
                '';
1548
        } else {
1549
            $texto = '';
1550
        }
1551
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1552
        $y += 3;
1553
        $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...
1554
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1555
        $y += 3;
1556
        $texto = 'MUNICÍPIO';
1557
        $aFont = $this->formatPadrao;
1558
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1559
        if (isset($this->enderReceb)) {
1560
            $texto = $this->pSimpleGetValue($this->enderReceb, "xMun") . ' - ';
1561
            $texto .= $this->pSimpleGetValue($this->enderReceb, "UF");
1562
        } else {
1563
            $texto = '';
1564
        }
1565
        $aFont = $this->formatNegrito;
1566
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1567
        $x = $w - 19 + $oldX;
1568
        $texto = 'CEP';
1569
        $aFont = $this->formatPadrao;
1570
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1571
        $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...
1572
        $aFont = $this->formatNegrito;
1573
        $this->pTextBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1574
        $x = $oldX;
1575
        $y += 3;
1576
        $texto = 'CNPJ/CPF';
1577
        $aFont = $this->formatPadrao;
1578
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1579
        $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...
1580
        $aFont = $this->formatNegrito;
1581
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1582
        $x = $w - 47 + $oldX;
1583
        $texto = 'INSCRIÇÃO ESTADUAL';
1584
        $aFont = $this->formatPadrao;
1585
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1586
        $texto = $this->pSimpleGetValue($this->receb, "IE");
1587
        $aFont = $this->formatNegrito;
1588
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1589
        $x = $oldX;
1590
        $y += 3;
1591
        $texto = 'PAÍS';
1592
        $aFont = $this->formatPadrao;
1593
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1594
        $texto = $this->pSimpleGetValue($this->receb, "xPais");
1595
        $aFont = $this->formatNegrito;
1596
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1597
        $x = $w - 27 + $oldX;
1598
        $texto = 'FONE';
1599
        $aFont = $this->formatPadrao;
1600
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1601
        if (isset($this->receb)) {
1602
            $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...
1603
            $aFont = $this->formatNegrito;
1604
            $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1605
        }
1606
    } //fim da função recebedorDACTE
1607
1608
    /**
1609
     * zTomador
1610
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1611
     *
1612
     * @param  number $x Posição horizontal canto esquerdo
1613
     * @param  number $y Posição vertical canto superior
1614
     * @return number Posição vertical final
1615
     */
1616
    protected function zTomador($x = 0, $y = 0)
1617
    {
1618
        $oldX = $x;
1619
        $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...
1620
        if ($this->orientacao == 'P') {
1621
            $maxW = $this->wPrint;
1622
        } else {
1623
            $maxW = $this->wPrint - $this->wCanhoto;
1624
        }
1625
        $w = $maxW;
1626
        $h = 10;
1627
        $texto = 'TOMADOR DO SERVIÇO';
1628
        $aFont = $this->formatPadrao;
1629
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1630
        $aFont = $this->formatNegrito;
1631
        $texto = $this->pSimpleGetValue($this->toma, "xNome");
1632
        $this->pTextBox($x + 29, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1633
        $x = $maxW * 0.60;
1634
        $texto = 'MUNICÍPIO';
1635
        $aFont = $this->formatPadrao;
1636
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1637
        $texto = $this->pSimpleGetValue($this->toma, "xMun");
1638
        $aFont = $this->formatNegrito;
1639
        $this->pTextBox($x + 15, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1640
        $x = $maxW * 0.85;
1641
        $texto = 'UF';
1642
        $aFont = $this->formatPadrao;
1643
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1644
        $texto = $this->pSimpleGetValue($this->toma, "UF");
1645
        $aFont = $this->formatNegrito;
1646
        $this->pTextBox($x + 4, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1647
        $x = $w - 18;
1648
        $texto = 'CEP';
1649
        $aFont = $this->formatPadrao;
1650
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1651
        $texto = $this->pFormat($this->pSimpleGetValue($this->toma, "CEP"), "#####-###");
1652
        $aFont = $this->formatNegrito;
1653
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1654
        $y += 3;
1655
        $x = $oldX;
1656
        $texto = 'ENDEREÇO';
1657
        $aFont = $this->formatPadrao;
1658
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1659
        $aFont = $this->formatNegrito;
1660
        $texto = $this->pSimpleGetValue($this->toma, "xLgr") . ',';
1661
        $texto .= $this->pSimpleGetValue($this->toma, "nro");
1662
        $texto .= ($this->pSimpleGetValue($this->toma, "xCpl") != "") ?
1663
            ' - ' . $this->pSimpleGetValue($this->toma, "xCpl") : '';
1664
        $texto .= ' - ' . $this->pSimpleGetValue($this->toma, "xBairro");
1665
        $this->pTextBox($x + 16, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1666
        $y += 3;
1667
        $texto = 'CNPJ/CPF';
1668
        $aFont = $this->formatPadrao;
1669
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1670
        $texto = $this->zFormatCNPJCPF($this->toma);
1671
        $aFont = $this->formatNegrito;
1672
        $this->pTextBox($x + 13, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1673
        $x = $x + 65;
1674
        $texto = 'INSCRIÇÃO ESTADUAL';
1675
        $aFont = $this->formatPadrao;
1676
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1677
        $texto = $this->pSimpleGetValue($this->toma, "IE");
1678
        $aFont = $this->formatNegrito;
1679
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1680
        $x = $w * 0.75;
1681
        $texto = 'PAÍS';
1682
        $aFont = $this->formatPadrao;
1683
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1684
        $texto = $this->pSimpleGetValue($this->toma, "xPais") != "" ?
1685
            $this->pSimpleGetValue($this->toma, "xPais") : 'BRASIL';
1686
        $aFont = $this->formatNegrito;
1687
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1688
        $x = $w - 27;
1689
        $texto = 'FONE';
1690
        $aFont = $this->formatPadrao;
1691
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1692
        $texto = $this->pSimpleGetValue($this->toma, "fone")!=""? $this->zFormatFone($this->toma):'';
1693
        $aFont = $this->formatNegrito;
1694
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1695
    } //fim da função tomadorDACTE
1696
1697
    /**
1698
     * zDescricaoCarga
1699
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1700
     *
1701
     * @param  number $x Posição horizontal canto esquerdo
1702
     * @param  number $y Posição vertical canto superior
1703
     * @return number Posição vertical final
1704
     */
1705
    protected function zDescricaoCarga($x = 0, $y = 0)
1706
    {
1707
        $oldX = $x;
1708
        $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...
1709
        if ($this->orientacao == 'P') {
1710
            $maxW = $this->wPrint;
1711
        } else {
1712
            $maxW = $this->wPrint - $this->wCanhoto;
1713
        }
1714
        $w = $maxW;
1715
        $h = 17;
1716
        $texto = 'PRODUTO PREDOMINANTE';
1717
        $aFont = array(
1718
            'font' => $this->fontePadrao,
1719
            'size' => 6,
1720
            'style' => '');
1721
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1722
        $texto = $this->pSimpleGetValue($this->infCarga, "proPred");
1723
        $aFont = $this->formatNegrito;
1724
        $this->pTextBox($x, $y + 2.8, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1725
        $x = $w * 0.56;
1726
        $this->pdf->Line($x, $y, $x, $y + 8);
1727
        $aFont = $this->formatPadrao;
1728
        $texto = 'OUTRAS CARACTERÍSTICAS DA CARGA';
1729
        $this->pTextBox($x + 1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1730
        $texto = $this->pSimpleGetValue($this->infCarga, "xOutCat");
1731
        $aFont = $this->formatNegrito;
1732
        $this->pTextBox($x + 1, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1733
        $x = $w * 0.8;
1734
        $this->pdf->Line($x, $y, $x, $y + 8);
1735
        $aFont = $this->formatPadrao;
1736
        $texto = 'VALOR TOTAL DA CARGA';
1737
        $this->pTextBox($x + 1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1738
        $texto = $this->pSimpleGetValue($this->infCarga, "vCarga") == "" ?
1739
            $this->pSimpleGetValue($this->infCarga, "vMerc") : $this->pSimpleGetValue($this->infCarga, "vCarga");
1740
        $texto = number_format($texto, 2, ",", ".");
1741
        $aFont = $this->formatNegrito;
1742
        $this->pTextBox($x + 1, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1743
        $y += 8;
1744
        $x = $oldX;
1745
        $this->pdf->Line($x, $y, $w + 1, $y);
1746
        //Identifica código da unidade
1747
        //01 = KG (QUILOS)
1748
        if ($this->pSimpleGetValue($this->infQ->item(0), "cUnid") == '01') {
1749
            $qCarga = $this->pSimpleGetValue($this->infQ->item(0), "qCarga");
1750
        } elseif ($this->pSimpleGetValue($this->infQ->item(1), "cUnid") == '01') {
1751
            $qCarga = $this->pSimpleGetValue($this->infQ->item(1), "qCarga");
1752
        } elseif ($this->pSimpleGetValue($this->infQ->item(2), "cUnid") == '01') {
1753
            $qCarga = $this->pSimpleGetValue($this->infQ->item(2), "qCarga");
1754
        }
1755
        $texto = 'PESO BRUTO (KG)';
1756
        $aFont = array(
1757
            'font' => $this->fontePadrao,
1758
            'size' => 5,
1759
            'style' => '');
1760
        $this->pTextBox($x+8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1761
        $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...
1762
        $aFont = array(
1763
            'font' => $this->fontePadrao,
1764
            'size' => 7,
1765
            'style' => 'B');
1766
        $this->pTextBox($x+2, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1767
        $x = $w * 0.12;
1768
        $this->pdf->Line($x+13.5, $y, $x+13.5, $y + 9);
1769
        $texto = 'PESO BASE CÁLCULO (KG)';
1770
        $aFont = array(
1771
            'font' => $this->fontePadrao,
1772
            'size' => 5,
1773
            'style' => '');
1774
        $this->pTextBox($x+20, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1775
        $texto = number_format($qCarga, 3, ",", ".");
1776
        $aFont = array(
1777
            'font' => $this->fontePadrao,
1778
            'size' => 7,
1779
            'style' => 'B');
1780
        $this->pTextBox($x+17, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1781
        $x = $w * 0.24;
1782
        $this->pdf->Line($x+25, $y, $x+25, $y + 9);
1783
        $texto = 'PESO AFERIDO (KG)';
1784
        $aFont = array(
1785
            'font' => $this->fontePadrao,
1786
            'size' => 5,
1787
            'style' => '');
1788
        $this->pTextBox($x+35, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1789
        $texto = number_format($qCarga, 3, ",", ".");
1790
        $aFont = array(
1791
            'font' => $this->fontePadrao,
1792
            'size' => 7,
1793
            'style' => 'B');
1794
        $this->pTextBox($x+28, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1795
        $x = $w * 0.36;
1796
        $this->pdf->Line($x+41.3, $y, $x+41.3, $y + 9);
1797
        $texto = 'CUBAGEM(M3)';
1798
        $aFont = $this->formatPadrao;
1799
        $this->pTextBox($x+60, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1800
        $qCarga = '';
1801
        if ($this->pSimpleGetValue($this->infQ->item(0), "cUnid") == '00') {
1802
            $qCarga = $this->pSimpleGetValue($this->infQ->item(0), "qCarga");
1803
        } elseif ($this->pSimpleGetValue($this->infQ->item(1), "cUnid") == '00') {
1804
            $qCarga = $this->pSimpleGetValue($this->infQ->item(1), "qCarga");
1805
        } elseif ($this->pSimpleGetValue($this->infQ->item(2), "cUnid") == '00') {
1806
            $qCarga = $this->pSimpleGetValue($this->infQ->item(2), "qCarga");
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
        if ($this->pSimpleGetValue($this->infQ->item(2), "cUnid") == 03) {
1821
            $qCarga = $this->pSimpleGetValue($this->infQ->item(2), "qCarga");
1822
        } elseif ($this->pSimpleGetValue($this->infQ->item(1), "cUnid") == 03) {
1823
            $qCarga = $this->pSimpleGetValue($this->infQ->item(1), "qCarga");
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.18;
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 * 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...
2031
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2032
        $texto = 'ICMS ST';
2033
        $aFont = $this->formatPadrao;
2034
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
2035
         * */
2036
2037
        $x = $oldX;
2038
        $y = $y + 4;
2039
        $texto = $this->pSimpleGetValue($this->ICMS, "CST");
2040
        switch ($texto) {
2041
            case '00':
2042
                $texto = "00 - Tributação normal ICMS";
2043
                break;
2044
            case '20':
2045
                $texto = "20 - Tributação com BC reduzida do ICMS";
2046
                break;
2047
            case '40':
2048
                $texto = "40 - ICMS isenção";
2049
                break;
2050
            case '41':
2051
                $texto = "41 - ICMS não tributada";
2052
                break;
2053
            case '51':
2054
                $texto = "51 - ICMS diferido";
2055
                break;
2056
            case '60':
2057
                $texto = "60 - ICMS cobrado anteriormente por substituição tributária";
2058
                break;
2059
            case '90':
2060
                if ($this->ICMSOutraUF) {
2061
                    $texto = "90 - ICMS Outra UF";
2062
                } else {
2063
                    $texto = "90 - ICMS Outros";
2064
                }
2065
                break;
2066
        }
2067
        $texto = $this->pSimpleGetValue($this->ICMSSN, "indSN") == 1 ? 'Simples Nacional' : $texto;
2068
        $aFont = $this->formatNegrito;
2069
        $this->pTextBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
2070
        $x += $w * 0.26;
2071
2072
        $texto = !empty($this->ICMS->getElementsByTagName("vBC")->item(0)->nodeValue) ?
2073
            number_format($this->pSimpleGetValue($this->ICMS, "vBC"), 2, ",", ".") : (
2074
                !empty($this->ICMS->getElementsByTagName("vBCOutraUF")->item(0)->nodeValue) ?
2075
                number_format($this->pSimpleGetValue($this->ICMS, "vBCOutraUF"), 2, ",", ".") : ''
2076
            );
2077
        $aFont = $this->formatNegrito;
2078
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2079
        $x += $w * $wCol02;
2080
2081
        $texto = !empty($this->ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue) ?
2082
            number_format($this->pSimpleGetValue($this->ICMS, "pICMS"), 2, ",", ".") : (
2083
                !empty($this->ICMS->getElementsByTagName("pICMSOutraUF")->item(0)->nodeValue) ?
2084
                number_format($this->pSimpleGetValue($this->ICMS, "pICMSOutraUF"), 2, ",", ".") : ''
2085
            );
2086
        $aFont = $this->formatNegrito;
2087
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2088
        $x += $w * $wCol02;
2089
2090
        $texto = !empty($this->ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue) ?
2091
            number_format($this->pSimpleGetValue($this->ICMS, "vICMS"), 2, ",", ".") : (
2092
                !empty($this->ICMS->getElementsByTagName("vICMSOutraUF")->item(0)->nodeValue) ?
2093
                number_format($this->pSimpleGetValue($this->ICMS, "vICMSOutraUF"), 2, ",", ".") : ''
2094
            );
2095
        $aFont = $this->formatNegrito;
2096
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2097
        $x += $w * $wCol02;
2098
2099
        $texto = !empty($this->ICMS->getElementsByTagName("pRedBC")->item(0)->nodeValue) ?
2100
            number_format($this->pSimpleGetValue($this->ICMS, "pRedBC"), 2, ",", ".") : (
2101
                !empty($this->ICMS->getElementsByTagName("pRedBCOutraUF")->item(0)->nodeValue) ?
2102
            number_format($this->pSimpleGetValue($this->ICMS, "pRedBCOutraUF"), 2, ",", ".") : ''
2103
            );
2104
        $aFont = $this->formatNegrito;
2105
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2106
2107
        /*$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...
2108
        $texto = '';
2109
        $aFont = $this->formatNegrito;
2110
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');*/
2111
    } //fim da função compValorDACTE
2112
2113
    /**
2114
     * zGeraChaveAdicCont
2115
     *
2116
     * @return string chave
2117
     */
2118
    protected function zGeraChaveAdicCont()
2119
    {
2120
        //cUF tpEmis CNPJ vNF ICMSp ICMSs DD  DV
2121
        // 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...
2122
        $forma = "%02d%d%s%014d%01d%01d%02d";
2123
        $cUF = $this->ide->getElementsByTagName('cUF')->item(0)->nodeValue;
2124
        $CNPJ = "00000000000000" . $this->emit->getElementsByTagName('CNPJ')->item(0)->nodeValue;
2125
        $CNPJ = substr($CNPJ, -14);
2126
        $vCT = number_format($this->pSimpleGetValue($this->vPrest, "vRec"), 2, "", "") * 100;
2127
        $ICMS_CST = $this->pSimpleGetValue($this->ICMS, "CST");
2128
        switch ($ICMS_CST) {
2129
            case '00':
2130
            case '20':
2131
                $ICMSp = '1';
2132
                $ICMSs = '2';
2133
                break;
2134
            case '40':
2135
            case '41':
2136
            case '51':
2137
            case '90':
2138
                $ICMSp = '2';
2139
                $ICMSs = '2';
2140
                break;
2141
            case '60':
2142
                $ICMSp = '2';
2143
                $ICMSs = '1';
2144
                break;
2145
        }
2146
        $dd = $this->ide->getElementsByTagName('dEmi')->item(0)->nodeValue;
2147
        $rpos = strrpos($dd, '-');
2148
        $dd = substr($dd, $rpos + 1);
2149
        $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...
2150
        $chave = $chave . $this->pModulo11($chave);
2151
        return $chave;
2152
    } //fim zGeraChaveAdicCont
2153
2154
    /**
2155
     * zDocOrig
2156
     * Monta o campo com os documentos originarios.
2157
     *
2158
     * @param  number $x Posição horizontal canto esquerdo
2159
     * @param  number $y Posição vertical canto superior
2160
     * @return number Posição vertical final
2161
     */
2162
    protected function zDocOrig($x = 0, $y = 0)
2163
    {
2164
        $oldX = $x;
2165
        $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...
2166
        if ($this->orientacao == 'P') {
2167
            $maxW = $this->wPrint;
2168
        } else {
2169
            $maxW = $this->wPrint - $this->wCanhoto;
2170
        }
2171
        $w = $maxW;
2172
2173
        // SE FOR RODOVIARIO ( BTR-SEMPRE SERÁ )
2174
        if ($this->modal == '1') {
2175
            // 0 - Não; 1 - Sim Será lotação quando houver um único conhecimento de transporte por veículo,
2176
            // ou combinação veicular, e por viagem
2177
            $h = $this->lota == 1 ? 35 : 53;
2178
        } elseif ($this->modal == '2') {
2179
            $h = 53;
2180
        } elseif ($this->modal == '3') {
2181
            $h = 37.6;
2182
        } else {
2183
            $h = 35;
2184
        }
2185
        $texto = 'DOCUMENTOS ORIGINÁRIOS';
2186
        $aFont = $this->formatPadrao;
2187
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2188
        $descr1 = 'TIPO DOC';
2189
        $descr2 = 'CNPJ/CHAVE/OBS';
2190
        $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2191
2192
        $y += 3.4;
2193
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA ABAIXO DO TEXTO: "DOCUMENTOS ORIGINÁRIOS
2194
        $texto = $descr1;
2195
        $aFont = $this->formatPadrao;
2196
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2197
        $yIniDados = $y;
2198
2199
        $x += $w * 0.07;
2200
        $texto = $descr2;
2201
        $aFont = $this->formatPadrao;
2202
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2203
2204
        $x += $w * 0.28;
2205
        $texto = $descr3;
2206
        $aFont = $this->formatPadrao;
2207
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2208
2209
        $x += $w * 0.14;
2210
        if ($this->modal == '1') {
2211
            if ($this->lota == 1) {
2212
                $this->pdf->Line($x, $y, $x, $y + 31.5); // TESTE
2213
            } else {
2214
                $this->pdf->Line($x, $y, $x, $y + 49.5); // TESTE
2215
            }
2216
        } elseif ($this->modal == '2') {
2217
            $this->pdf->Line($x, $y, $x, $y + 49.5);
2218
        } elseif ($this->modal == '3') {
2219
            $this->pdf->Line($x, $y, $x, $y + 34.1);
2220
        } else {
2221
            $this->pdf->Line($x, $y, $x, $y + 21.5);
2222
        }
2223
        $texto = $descr1;
2224
        $aFont = $this->formatPadrao;
2225
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2226
2227
        $x += $w * 0.08;
2228
        $texto = $descr2;
2229
        $aFont = $this->formatPadrao;
2230
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2231
2232
        $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2233
        $texto = $descr3;
2234
        $aFont = $this->formatPadrao;
2235
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2236
        $auxX = $oldX;
2237
        $yIniDados += 3;
2238
        foreach ($this->infNF as $k => $d) {
2239
            $mod = $this->infNF->item($k)->getElementsByTagName('mod');
2240
            $tp = ($mod && $mod->length > 0) ? $mod->item(0)->nodeValue : '';
2241
            $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...
2242
            $doc = $this->infNF->item($k)->getElementsByTagName('serie')->item(0)->nodeValue;
2243
            $doc .= '/' . $this->infNF->item($k)->getElementsByTagName('nDoc')->item(0)->nodeValue;
2244
            if ($auxX > $w * 0.90) {
2245
                $yIniDados = $yIniDados + 3;
2246
                $auxX = $oldX;
2247
            }
2248
            $texto = $tp;
2249
            $aFont = array(
2250
                'font' => $this->fontePadrao,
2251
                'size' => 8,
2252
                'style' => '');
2253
            //$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...
2254
            $this->pTextBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2255
            //$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...
2256
            $auxX += $w * 0.07;
2257
            $texto = $cnpj;
2258
            $aFont = array(
2259
                'font' => $this->fontePadrao,
2260
                'size' => 8,
2261
                'style' => '');
2262
            $this->pTextBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2263
            $auxX += $w * 0.28;
2264
            $texto = $doc;
2265
            $aFont = array(
2266
                'font' => $this->fontePadrao,
2267
                'size' => 8,
2268
                'style' => '');
2269
            $this->pTextBox($auxX, $yIniDados, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2270
            $auxX += $w * 0.15;
2271
        }
2272
2273
        foreach ($this->infNFe as $k => $d) {
2274
            $chaveNFe = $this->infNFe->item($k)->getElementsByTagName('chave')->item(0)->nodeValue;
2275
            $this->arrayNFe[] = $chaveNFe;
2276
        }
2277
        $qtdeNFe = 1;
2278
        if (count($this->arrayNFe) >15) {
2279
            $this->flagDocOrigContinuacao = 1;
2280
            $qtdeNFe = count($this->arrayNFe);
2281
        }
2282
//        $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...
2283
        switch ($qtdeNFe) {
2284
            default:
2285
                $this->totPag = 1;
2286
            case ($qtdeNFe >= 1044):
2287
                $this->totPag = 11;
2288
                break;
2289
            case ($qtdeNFe > 928):
2290
                $this->totPag = 10;
2291
                break;
2292
            case ($qtdeNFe > 812):
2293
                $this->totPag = 9;
2294
                break;
2295
            case ($qtdeNFe > 696):
2296
                $this->totPag = 8;
2297
                break;
2298
            case ($qtdeNFe > 580):
2299
                $this->totPag = 7;
2300
                break;
2301
            case ($qtdeNFe > 464):
2302
                $this->totPag = 6;
2303
                break;
2304
            case ($qtdeNFe > 348):
2305
                $this->totPag = 5;
2306
                break;
2307
            case ($qtdeNFe > 232):
2308
                $this->totPag = 4;
2309
                break;
2310
            case ($qtdeNFe > 116):
2311
                $this->totPag = 3;
2312
                break;
2313
            case ($qtdeNFe > 16):
2314
                $this->totPag = 2;
2315
                break;
2316
            case ($qtdeNFe <= 16):
2317
                $this->totPag = 1;
2318
                break;
2319
        }
2320
        $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...
2321
        $contador = 0;
2322
        while ($contador < count($this->arrayNFe)) {
2323
            if ($contador == 15) {
2324
                break;
2325
            }
2326
            $tp = 'NF-e';
2327
            $chaveNFe = $this->arrayNFe[$contador];
2328
            $numNFe = substr($chaveNFe, 25, 9);
2329
            $serieNFe = substr($chaveNFe, 22, 3);
2330
            $doc = $serieNFe . '/' . $numNFe;
2331
            if ($auxX > $w * 0.90) {
2332
                $yIniDados = $yIniDados + 3.5;
2333
                $auxX = $oldX;
2334
            }
2335
            $texto = $tp;
2336
            $aFont = array(
2337
                'font' => $this->fontePadrao,
2338
                'size' => 7,
2339
                'style' => '');
2340
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2341
            $auxX += $w * 0.07;
2342
            $texto = $chaveNFe;
2343
            $aFont = array(
2344
                'font' => $this->fontePadrao,
2345
                'size' => 7,
2346
                'style' => '');
2347
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2348
            $auxX += $w * 0.28;
2349
            $texto = $doc;
2350
            $aFont = array(
2351
                'font' => $this->fontePadrao,
2352
                'size' => 7,
2353
                'style' => '');
2354
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2355
            $auxX += $w * 0.15;
2356
            $contador++;
2357
        }
2358
2359
        foreach ($this->infOutros as $k => $d) {
2360
            $temp = $this->infOutros->item($k);
2361
            $tpDoc = $this->pSimpleGetValue($temp, "tpDoc");
2362
            $descOutros = $this->pSimpleGetValue($temp, "descOutros");
2363
            $nDoc = $this->pSimpleGetValue($temp, "nDoc");
2364
            $dEmi = $this->pSimpleGetDate($temp, "dEmi", "Emissão: ");
2365
            $vDocFisc = $this->pSimpleGetValue($temp, "vDocFisc", "Valor: ");
2366
            $dPrev = $this->pSimpleGetDate($temp, "dPrev", "Entrega: ");
2367
            switch ($tpDoc) {
2368
                case "00":
2369
                    $tpDoc = "00 - Declaração";
2370
                    break;
2371
                case "10":
2372
                    $tpDoc = "10 - Dutoviário";
2373
                    break;
2374
                case "99":
2375
                    $tpDoc = "99 - Outros: [" . $descOutros . "]";
2376
                    break;
2377
                default:
2378
                    break;
2379
            }
2380
            $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...
2381
            $cnpjChave = $dEmi . " " . $vDocFisc . " " . $dPrev;
2382
            if ($auxX > $w * 0.90) {
2383
                $yIniDados = $yIniDados + 4;
2384
                $auxX = $oldX;
2385
            }
2386
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $tpDoc, $aFont, 'T', 'L', 0, '');
2387
            $auxX += $w * 0.09;
2388
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $cnpjChave, $aFont, 'T', 'L', 0, '');
2389
            $auxX += $w * 0.28;
2390
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $nDoc, $aFont, 'T', 'L', 0, '');
2391
            $auxX += $w * 0.14;
2392
        }
2393
        foreach ($this->idDocAntEle as $k => $d) {
2394
            $tp = 'CT-e';
2395
            $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...
2396
            $numCTe = substr($chaveCTe, 25, 9);
2397
            $serieCTe = substr($chaveCTe, 22, 3);
2398
            $doc = $serieCTe . '/' . $numCTe;
2399
            if ($auxX > $w * 0.90) {
2400
                $yIniDados = $yIniDados + 4;
2401
                $auxX = $oldX;
2402
            }
2403
            $texto = $tp;
2404
            $aFont = array(
2405
                'font' => $this->fontePadrao,
2406
                'size' => 8,
2407
                'style' => '');
2408
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2409
            $auxX += $w * 0.09;
2410
            $texto = $chaveCTe;
2411
            $aFont = array(
2412
                'font' => $this->fontePadrao,
2413
                'size' => 8,
2414
                'style' => '');
2415
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2416
            $auxX += $w * 0.28;
2417
            $texto = $doc;
2418
            $aFont = array(
2419
                'font' => $this->fontePadrao,
2420
                'size' => 8,
2421
                'style' => '');
2422
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2423
            $auxX += $w * 0.14;
2424
        }
2425
    } //fim da função zDocOrig
2426
2427
    /**
2428
     * zDocOrigContinuacao
2429
     * Monta o campo com os documentos originarios.
2430
     *
2431
     * @param  number $x Posição horizontal canto esquerdo
2432
     * @param  number $y Posição vertical canto superior
2433
     * @return number Posição vertical final
2434
     */
2435
    protected function zDocOrigContinuacao($x = 0, $y = 0)
2436
    {
2437
        $x2 = $x;
2438
        $y2 = $y;
2439
        $contador = 16;
2440
        for ($i = 2; $i <= $this->totPag; $i++) {
2441
            $x = $x2;
2442
            $y = $y2;
2443
            $this->pdf->AddPage($this->orientacao, $this->papel);
2444
            $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...
2445
            $oldX = $x;
2446
            $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...
2447
            if ($this->orientacao == 'P') {
2448
                $maxW = $this->wPrint;
2449
            } else {
2450
                $maxW = $this->wPrint - $this->wCanhoto;
2451
            }
2452
            $w = $maxW;
2453
2454
            //$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...
2455
            //$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...
2456
            //$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...
2457
            //$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...
2458
            $h = (( ( count($this->arrayNFe)/2 ) - 9) * 3.5)+9;
2459
            if (count($this->arrayNFe)%2 !=0) {
2460
                $h = $h+3.5;
2461
            } // Caso tenha apenas 1 registro na ultima linha
2462
2463
            $texto = 'DOCUMENTOS ORIGINÁRIOS - CONTINUACÃO';
2464
            $aFont = $this->formatPadrao;
2465
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2466
            $descr1 = 'TIPO DOC';
2467
            $descr2 = 'CNPJ/CHAVE/OBS';
2468
            $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2469
2470
            $y += 3.4;
2471
            $this->pdf->Line($x, $y, $w + 1, $y);
2472
            $texto = $descr1;
2473
            $aFont = $this->formatPadrao;
2474
            $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2475
            $yIniDados = $y;
2476
2477
            $x += $w * 0.07; // COLUNA CNPJ/CHAVE/OBS
2478
            $texto = $descr2;
2479
            $aFont = $this->formatPadrao;
2480
            $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2481
2482
            $x += $w * 0.28;
2483
            $texto = $descr3;
2484
            $aFont = $this->formatPadrao;
2485
            $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2486
2487
            $x += $w * 0.14;
2488
            if ($this->modal == '1') {
2489
                if ($this->lota == 1) {
2490
                    $this->pdf->Line($x, $y, $x, $y + 31.5);
2491
                } else {
2492
                    $this->pdf->Line($x, $y, $x, $y + 49.5);
2493
                }
2494
            } elseif ($this->modal == '2') {
2495
                $this->pdf->Line($x, $y, $x, $y + 49.5);
2496
            } elseif ($this->modal == '3') {
2497
                $this->pdf->Line($x, $y, $x, $y + 34.1);
2498
            } else {
2499
                $this->pdf->Line($x, $y, $x, $y + 21.5);
2500
            }
2501
            $texto = $descr1;
2502
            $aFont = $this->formatPadrao;
2503
            $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2504
2505
            $x += $w * 0.08;
2506
            $texto = $descr2;
2507
            $aFont = $this->formatPadrao;
2508
            $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2509
2510
            $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2511
            $texto = $descr3;
2512
            $aFont = $this->formatPadrao;
2513
            $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2514
            $auxX = $oldX;
2515
            $yIniDados += 3;
2516
2517
            while ($contador < (count($this->arrayNFe))) {
2518
                if ($contador%(116*($i-1)) == 0) {
2519
//                    $contador++;
2520
                    break;
2521
                }
2522
                $tp = 'NF-e';
2523
                $chaveNFe = $this->arrayNFe[$contador];
2524
                $numNFe = substr($chaveNFe, 25, 9);
2525
                $serieNFe = substr($chaveNFe, 22, 3);
2526
                $doc = $serieNFe . '/' . $numNFe;
2527
                if ($auxX > $w * 0.90) {
2528
                    $yIniDados = $yIniDados + 3.5;
2529
                    $auxX = $oldX;
2530
                }
2531
                $texto = $tp;
2532
                $aFont = array(
2533
                    'font' => $this->fontePadrao,
2534
                    'size' => 7,
2535
                    'style' => '');
2536
                $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2537
                $auxX += $w * 0.07;
2538
                $texto = $chaveNFe;
2539
                $aFont = array(
2540
                    'font' => $this->fontePadrao,
2541
                    'size' => 7,
2542
                    'style' => '');
2543
                $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2544
                $auxX += $w * 0.28;
2545
                $texto = $doc;
2546
                $aFont = array(
2547
                    'font' => $this->fontePadrao,
2548
                    'size' => 7,
2549
                    'style' => '');
2550
                $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2551
                $auxX += $w * 0.15;
2552
                $contador++;
2553
            }
2554
        }
2555
    } //fim da função zDocOrigContinuacao
2556
2557
    /**
2558
     * zDocCompl
2559
     * Monta o campo com os dados do remetente na DACTE.
2560
     *
2561
     * @param number $x Posição horizontal canto esquerdo
2562
     * @param number $y Posição vertical canto superior
2563
     * @return number Posição vertical final
2564
     */
2565
    protected function zDocCompl($x = 0, $y = 0)
2566
    {
2567
        $oldX = $x;
2568
        $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...
2569
        if ($this->orientacao == 'P') {
2570
            $maxW = $this->wPrint;
2571
        } else {
2572
            $maxW = $this->wPrint - $this->wCanhoto;
2573
        }
2574
        $w = $maxW;
2575
        $h = 80;
2576
        if ($this->tpCTe == 1) {
2577
            $texto = 'DETALHAMENTO DO CT-E COMPLEMENTADO';
2578
            $descr1 = 'CHAVE DO CT-E COMPLEMENTADO';
2579
            $descr2 = 'VALOR COMPLEMENTADO';
2580
        } else {
2581
            $texto = 'DETALHAMENTO DO CT-E ANULADO';
2582
            $descr1 = 'CHAVE DO CT-E ANULADO';
2583
            $descr2 = 'VALOR ANULADO';
2584
        }
2585
2586
        $aFont = $this->formatPadrao;
2587
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2588
2589
        $y += 3.4;
2590
        $this->pdf->Line($x, $y, $w + 1, $y);
2591
        $texto = $descr1;
2592
        $aFont = $this->formatPadrao;
2593
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2594
        $yIniDados = $y;
2595
        $x += $w * 0.37;
2596
        $texto = $descr2;
2597
        $aFont = $this->formatPadrao;
2598
        $this->pTextBox($x - 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2599
        $x += $w * 0.13;
2600
        $this->pdf->Line($x, $y, $x, $y + 76.5);
2601
        $texto = $descr1;
2602
        $aFont = $this->formatPadrao;
2603
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2604
        $x += $w * 0.3;
2605
        $texto = $descr2;
2606
        $aFont = $this->formatPadrao;
2607
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2608
        $auxX = $oldX;
2609
        $yIniDados += 4;
2610
        if ($auxX > $w * 0.90) {
2611
            $yIniDados = $yIniDados + 4;
2612
            $auxX = $oldX;
2613
        }
2614
        $texto = $this->chaveCTeRef;
2615
        $aFont = array(
2616
            'font' => $this->fontePadrao,
2617
            'size' => 8,
2618
            'style' => '');
2619
        $this->pTextBox($auxX, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2620
        $texto = number_format($this->pSimpleGetValue($this->vPrest, "vTPrest"), 2, ",", ".");
2621
        $aFont = array(
2622
            'font' => $this->fontePadrao,
2623
            'size' => 8,
2624
            'style' => '');
2625
        $this->pTextBox($w * 0.40, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2626
    } //fim da função zDocCompl
2627
2628
    /**
2629
     * zObs
2630
     * Monta o campo com os dados do remetente na DACTE.
2631
     *
2632
     * @param  number $x Posição horizontal canto esquerdo
2633
     * @param  number $y Posição vertical canto superior
2634
     * @return number Posição vertical final
2635
     */
2636
    protected function zObs($x = 0, $y = 0)
2637
    {
2638
        $oldX = $x;
2639
        $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...
2640
        if ($this->orientacao == 'P') {
2641
            $maxW = $this->wPrint;
2642
        } else {
2643
            $maxW = $this->wPrint - $this->wCanhoto;
2644
        }
2645
        $w = $maxW;
2646
        //$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...
2647
        $h = 18.8;
2648
        $texto = 'OBSERVAÇÕES';
2649
        $aFont = $this->formatPadrao;
2650
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2651
        $y += 3.4;
2652
        $this->pdf->Line($x, $y, $w + 1, $y);
2653
        $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...
2654
        $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...
2655
        $texto = '';
2656
        foreach ($this->compl as $k => $d) {
2657
            $xObs = $this->pSimpleGetValue($this->compl->item($k), "xObs");
2658
            $texto .= $xObs;
2659
        }
2660
        $textoObs = explode("Motorista:", $texto);
2661
        $textoObs[1] = isset($textoObs[1]) ? "Motorista: ".$textoObs[1]: '';
2662
        $texto .= $this->pSimpleGetValue($this->imp, "infAdFisco", "\r\n");
2663
        $aFont = array(
2664
            'font' => $this->fontePadrao,
2665
            'size' => 7.5,
2666
            'style' => '');
2667
        $this->pTextBox($x, $y, $w, $h, $textoObs[0], $aFont, 'T', 'L', 0, '', false);
2668
        $this->pTextBox($x, $y+11.5, $w, $h, $textoObs[1], $aFont, 'T', 'L', 0, '', false);
2669
    } //fim da função obsDACTE
2670
2671
    /**
2672
     * zModalRod
2673
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2674
     *
2675
     * @param  number $x Posição horizontal canto esquerdo
2676
     * @param  number $y Posição vertical canto superior
2677
     * @return number Posição vertical final
2678
     */
2679
    protected function zModalRod($x = 0, $y = 0)
2680
    {
2681
        $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...
2682
        $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...
2683
        $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...
2684
        if ($this->orientacao == 'P') {
2685
            $maxW = $this->wPrint;
2686
        } else {
2687
            $maxW = $this->wPrint - $this->wCanhoto;
2688
        }
2689
        $w = $maxW;
2690
        $h = 3;
2691
        $texto = 'DADOS ESPECÍFICOS DO MODAL RODOVIÁRIO';
2692
        $aFont = $this->formatPadrao;
2693
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2694
        if ($this->lota == 1) {
2695
            $this->pdf->Line($x, $y + 12, $w + 1, $y + 12); // LINHA DE BAIXO
2696
        }
2697
        $y += 3.4;
2698
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA DE CIMA
2699
        $texto = 'RNTRC DA EMPRESA';
2700
        $aFont = $this->formatPadrao;
2701
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2702
        $texto = $this->pSimpleGetValue($this->rodo, "RNTRC");
2703
        $aFont = $this->formatNegrito;
2704
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2705
        $x += $w * 0.23;
2706
2707
        $this->pdf->Line($x-20, $y, $x-20, $y + 6); // LINHA A FRENTE DA RNTRC DA EMPRESA
2708
2709
        $texto = 'ESTE CONHECIMENTO DE TRANSPORTE ATENDE À LEGISLAÇÃO DE TRANSPORTE RODOVIÁRIO EM VIGOR';
2710
        $aFont = $this->formatPadrao;
2711
        $this->pTextBox($x-20, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'C', 0, '');
2712
    } //fim da função zModalRod
2713
2714
    /**
2715
     * zModalAereo
2716
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2717
     *
2718
     * @param  number $x Posição horizontal canto esquerdo
2719
     * @param  number $y Posição vertical canto superior
2720
     * @return number Posição vertical final
2721
     */
2722
    protected function zModalAereo($x = 0, $y = 0)
2723
    {
2724
        $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...
2725
        $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...
2726
        $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...
2727
        if ($this->orientacao == 'P') {
2728
            $maxW = $this->wPrint;
2729
        } else {
2730
            $maxW = $this->wPrint - $this->wCanhoto;
2731
        }
2732
        $w = $maxW;
2733
        $h = 3;
2734
        $texto = 'DADOS ESPECÍFICOS DO MODAL AÉREO';
2735
        $aFont = $this->formatPadrao;
2736
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2737
        $y += 3.4;
2738
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA DE CIMA
2739
        $texto = 'NÚMERO OPERACIONAL DO CONHECIMENTO AÉREO';
2740
        $aFont = $this->formatPadrao;
2741
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2742
2743
        $texto = 'CLASSE DA TARIFA';
2744
        $aFont = $this->formatPadrao;
2745
        $this->pTextBox($x+50, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2746
        $texto = 'CÓDIGO DA TARIFA';
2747
        $aFont = $this->formatPadrao;
2748
        $this->pTextBox($x+80, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2749
        $texto = 'VALOR DA TARIFA';
2750
        $aFont = $this->formatPadrao;
2751
        $this->pTextBox($x+110, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2752
2753
        $texto = $this->pSimpleGetValue($this->aereo, "nOCA");
2754
        $aFont = $this->formatNegrito;
2755
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2756
        $x += $w * 0.23;
2757
2758
        $this->pdf->Line($x, $y, $x, $y + 6); // LINHA APÓS NÚMERO OP. DO CT-E AEREO
2759
2760
        $texto = $this->pSimpleGetValue($this->aereo, "CL");
2761
        $aFont = $this->formatNegrito;
2762
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2763
        $x += 30;
2764
        $this->pdf->Line($x, $y, $x, $y + 6); // LINHA APÓS CLASSE DA TARIFA
2765
2766
        $texto = $this->pSimpleGetValue($this->aereo, "cTar");
2767
        $aFont = $this->formatNegrito;
2768
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2769
        $x += 30;
2770
        $this->pdf->Line($x, $y, $x, $y + 6); // LINHA APÓS COD DA TARIFA
2771
2772
        $texto = $this->pSimpleGetValue($this->aereo, "vTar");
2773
        $aFont = $this->formatNegrito;
2774
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2775
    } //fim da função zModalAereo
2776
2777
    /**
2778
     * zModalAquaviario
2779
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2780
     *
2781
     * @param  number $x Posição horizontal canto esquerdo
2782
     * @param  number $y Posição vertical canto superior
2783
     * @return number Posição vertical final
2784
     */
2785
    protected function zModalAquaviario($x = 0, $y = 0)
2786
    {
2787
        $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...
2788
        $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...
2789
        if ($this->orientacao == 'P') {
2790
            $maxW = $this->wPrint;
2791
        } else {
2792
            $maxW = $this->wPrint - $this->wCanhoto;
2793
        }
2794
        $w = $maxW;
2795
        $h = 8.5;
2796
        $texto = 'DADOS ESPECÍFICOS DO MODAL AQUAVIÁRIO';
2797
        $aFont = $this->formatPadrao;
2798
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2799
        $y += 3.4;
2800
        $this->pdf->Line($x, $y, $w + 1, $y);
2801
        $texto = 'PORTO DE EMBARQUE';
2802
        $aFont = $this->formatPadrao;
2803
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2804
        $texto = $this->pSimpleGetValue($this->aquav, "prtEmb");
2805
        $aFont = $this->formatNegrito;
2806
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2807
        $x += $w * 0.50;
2808
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2809
        $texto = 'PORTO DE DESTINO';
2810
        $aFont = $this->formatPadrao;
2811
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2812
        $texto = $this->pSimpleGetValue($this->aquav, "prtDest");
2813
        $aFont = $this->formatNegrito;
2814
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2815
        $y += 8;
2816
        $this->pdf->Line(208, $y, 1, $y);
2817
        $x = 1;
2818
        $texto = 'IDENTIFICAÇÃO DO NAVIO / REBOCADOR';
2819
        $aFont = $this->formatPadrao;
2820
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2821
        $texto = $this->pSimpleGetValue($this->aquav, "xNavio");
2822
        $aFont = $this->formatNegrito;
2823
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2824
        $x += $w * 0.50;
2825
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2826
        $texto = 'VR DA B. DE CALC. AFRMM';
2827
        $aFont = $this->formatPadrao;
2828
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2829
        $texto = $this->pSimpleGetValue($this->aquav, "vPrest");
2830
        $aFont = $this->formatNegrito;
2831
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2832
        $x += $w * 0.17;
2833
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2834
        $texto = 'VALOR DO AFRMM';
2835
        $aFont = $this->formatPadrao;
2836
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2837
        $texto = $this->pSimpleGetValue($this->aquav, "vAFRMM");
2838
        $aFont = $this->formatNegrito;
2839
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2840
        $x += $w * 0.12;
2841
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2842
        $texto = 'TIPO DE NAVEGAÇÃO';
2843
        $aFont = $this->formatPadrao;
2844
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2845
        $texto = $this->pSimpleGetValue($this->aquav, "tpNav");
2846
        switch ($texto) {
2847
            case '0':
2848
                $texto = 'INTERIOR';
2849
                break;
2850
            case '1':
2851
                $texto = 'CABOTAGEM';
2852
                break;
2853
        }
2854
        $aFont = $this->formatNegrito;
2855
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2856
        $x += $w * 0.14;
2857
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2858
        $texto = 'DIREÇÃO';
2859
        $aFont = $this->formatPadrao;
2860
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2861
        $texto = $this->pSimpleGetValue($this->aquav, "direc");
2862
        switch ($texto) {
2863
            case 'N':
2864
                $texto = 'NORTE';
2865
                break;
2866
            case 'L':
2867
                $texto = 'LESTE';
2868
                break;
2869
            case 'S':
2870
                $texto = 'SUL';
2871
                break;
2872
            case 'O':
2873
                $texto = 'OESTE';
2874
                break;
2875
        }
2876
        $aFont = $this->formatNegrito;
2877
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2878
        $y += 8;
2879
        $this->pdf->Line(208, $y, 1, $y);
2880
        $x = 1;
2881
        $texto = 'IDENTIFICAÇÃO DOS CONTEINERS';
2882
        $aFont = $this->formatPadrao;
2883
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2884
        if ($this->infNF->item(0) !== null && $this->infNF->item(0)->getElementsByTagName('infUnidCarga') !== null) {
2885
            $texto = $this->infNF
2886
                ->item(0)
2887
                ->getElementsByTagName('infUnidCarga')
2888
                ->item(0)
2889
                ->getElementsByTagName('idUnidCarga')
2890
                ->item(0)->nodeValue;
2891
        } elseif ($this->infNFe->item(0) !== null
2892
            && $this->infNFe->item(0)->getElementsByTagName('infUnidCarga') !== null
2893
        ) {
2894
            $texto = $this->infNFe
2895
                ->item(0)
2896
                ->getElementsByTagName('infUnidCarga')
2897
                ->item(0)
2898
                ->getElementsByTagName('idUnidCarga')
2899
                ->item(0)
2900
                ->nodeValue;
2901
        } elseif ($this->infOutros->item(0) !== null
2902
            && $this->infOutros->item(0)->getElementsByTagName('infUnidCarga') !== null
2903
        ) {
2904
            $texto = $this->infOutros
2905
                ->item(0)
2906
                ->getElementsByTagName('infUnidCarga')
2907
                ->item(0)
2908
                ->getElementsByTagName('idUnidCarga')
2909
                ->item(0)
2910
                ->nodeValue;
2911
        } else {
2912
            $texto = '';
2913
        }
2914
        $aFont = $this->formatNegrito;
2915
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2916
        $x += $w * 0.50;
2917
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2918
        $texto = 'IDENTIFICAÇÃO DAS BALSAS';
2919
        $aFont = $this->formatPadrao;
2920
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2921
        $texto = '';
2922
        if ($this->pSimpleGetValue($this->aquav, "balsa") !== '') {
2923
            foreach ($this->aquav->getElementsByTagName('balsa') as $k => $d) {
2924
                if ($k == 0) {
2925
                    $texto = $this->aquav
2926
                        ->getElementsByTagName('balsa')
2927
                        ->item($k)
2928
                        ->getElementsByTagName('xBalsa')
2929
                        ->item(0)
2930
                        ->nodeValue;
2931
                } else {
2932
                    $texto = $texto
2933
                        . ' / '
2934
                        . $this->aquav
2935
                            ->getElementsByTagName('balsa')
2936
                            ->item($k)
2937
                            ->getElementsByTagName('xBalsa')
2938
                            ->item(0)
2939
                            ->nodeValue;
2940
                }
2941
            }
2942
        }
2943
        $aFont = $this->formatNegrito;
2944
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2945
    } //fim da função zModalRod
2946
2947
    /**
2948
     * zModalFerr
2949
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2950
     *
2951
     * @param  number $x Posição horizontal canto esquerdo
2952
     * @param  number $y Posição vertical canto superior
2953
     * @return number Posição vertical final
2954
     */
2955
    protected function zModalFerr($x = 0, $y = 0)
2956
    {
2957
        $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...
2958
        $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...
2959
        if ($this->orientacao == 'P') {
2960
            $maxW = $this->wPrint;
2961
        } else {
2962
            $maxW = $this->wPrint - $this->wCanhoto;
2963
        }
2964
        $w = $maxW;
2965
        $h = 19.6;
2966
        $texto = 'DADOS ESPECÍFICOS DO MODAL FERROVIÁRIO';
2967
        $aFont = $this->formatPadrao;
2968
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2969
        $y += 3.4;
2970
        $this->pdf->Line($x, $y, $w + 1, $y);
2971
        $texto = 'DCL';
2972
        $aFont = array(
2973
            'font' => $this->fontePadrao,
2974
            'size' => 7,
2975
            'style' => 'B');
2976
        $this->pTextBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'C', 0, '');
2977
        $this->pdf->Line($x + 49.6, $y, $x + 49.6, $y + 3.5);
2978
        $texto = 'VAGÕES';
2979
        $aFont = array(
2980
            'font' => $this->fontePadrao,
2981
            'size' => 7,
2982
            'style' => 'B');
2983
        $this->pTextBox($x + 50, $y, $w * 0.5, $h, $texto, $aFont, 'T', 'C', 0, '');
2984
        $y += 3.4;
2985
        $this->pdf->Line($x, $y, $w + 1, $y);
2986
        // DCL
2987
        $texto = 'ID TREM';
2988
        $aFont = array(
2989
            'font' => $this->fontePadrao,
2990
            'size' => 6,
2991
            'style' => '');
2992
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2993
        $texto = $this->pSimpleGetValue($this->ferrov, "idTrem");
2994
        $aFont = array(
2995
            'font' => $this->fontePadrao,
2996
            'size' => 6,
2997
            'style' => 'B');
2998
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2999
        $x += $w * 0.06;
3000
        $y1 = $y + 12.5;
3001
        $this->pdf->Line($x, $y, $x, $y1);
3002
        $texto = 'NUM';
3003
        $aFont = array(
3004
            'font' => $this->fontePadrao,
3005
            'size' => 6,
3006
            'style' => '');
3007
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3008
        $texto = $this->pSimpleGetValue($this->rem, "nDoc");
3009
        $aFont = array(
3010
            'font' => $this->fontePadrao,
3011
            'size' => 6,
3012
            'style' => 'B');
3013
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3014
        $x += $w * 0.06;
3015
        $this->pdf->Line($x, $y, $x, $y1);
3016
        $texto = 'SÉRIE';
3017
        $aFont = array(
3018
            'font' => $this->fontePadrao,
3019
            'size' => 6,
3020
            'style' => '');
3021
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3022
        $texto = $this->pSimpleGetValue($this->rem, "serie");
3023
        $aFont = array(
3024
            'font' => $this->fontePadrao,
3025
            'size' => 6,
3026
            'style' => 'B');
3027
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3028
        $x += $w * 0.06;
3029
        $this->pdf->Line($x, $y, $x, $y1);
3030
        $texto = 'EMISSÃO';
3031
        $aFont = array(
3032
            'font' => $this->fontePadrao,
3033
            'size' => 6,
3034
            'style' => '');
3035
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3036
        $texto = $this->pYmd2dmy($this->pSimpleGetValue($this->rem, "dEmi"));
3037
        $aFont = array(
3038
            'font' => $this->fontePadrao,
3039
            'size' => 6,
3040
            'style' => 'B');
3041
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3042
        // VAGOES
3043
        $x += $w * 0.06;
3044
        $this->pdf->Line($x, $y, $x, $y1);
3045
        $texto = 'NUM';
3046
        $aFont = array(
3047
            'font' => $this->fontePadrao,
3048
            'size' => 6,
3049
            'style' => '');
3050
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3051
        $texto = $this->pSimpleGetValue($this->ferrov, "nVag");
3052
        $aFont = array(
3053
            'font' => $this->fontePadrao,
3054
            'size' => 6,
3055
            'style' => 'B');
3056
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3057
        $x += $w * 0.06;
3058
        $this->pdf->Line($x, $y, $x, $y1);
3059
        $texto = 'TIPO';
3060
        $aFont = array(
3061
            'font' => $this->fontePadrao,
3062
            'size' => 6,
3063
            'style' => '');
3064
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3065
        $texto = $this->pSimpleGetValue($this->ferrov, "tpVag");
3066
        $aFont = array(
3067
            'font' => $this->fontePadrao,
3068
            'size' => 6,
3069
            'style' => 'B');
3070
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3071
        $x += $w * 0.06;
3072
        $this->pdf->Line($x, $y, $x, $y1);
3073
        $texto = 'CAPACIDADE';
3074
        $aFont = array(
3075
            'font' => $this->fontePadrao,
3076
            'size' => 6,
3077
            'style' => '');
3078
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3079
        $texto = $this->pSimpleGetValue($this->ferrov, "cap");
3080
        $aFont = array(
3081
            'font' => $this->fontePadrao,
3082
            'size' => 6,
3083
            'style' => 'B');
3084
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3085
        $x += $w * 0.08;
3086
        $this->pdf->Line($x, $y, $x, $y1);
3087
        $texto = 'PESO REAL/TON';
3088
        $aFont = array(
3089
            'font' => $this->fontePadrao,
3090
            'size' => 6,
3091
            'style' => '');
3092
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3093
        $texto = $this->pSimpleGetValue($this->ferrov, "pesoR");
3094
        $aFont = array(
3095
            'font' => $this->fontePadrao,
3096
            'size' => 6,
3097
            'style' => 'B');
3098
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3099
        $x += $w * 0.09;
3100
        $this->pdf->Line($x, $y, $x, $y1);
3101
        $texto = 'PESO BRUTO/TON';
3102
        $aFont = array(
3103
            'font' => $this->fontePadrao,
3104
            'size' => 6,
3105
            'style' => '');
3106
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3107
        $texto = $this->pSimpleGetValue($this->ferrov, "pesoBC");
3108
        $aFont = array(
3109
            'font' => $this->fontePadrao,
3110
            'size' => 6,
3111
            'style' => 'B');
3112
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3113
        $x += $w * 0.1;
3114
        $this->pdf->Line($x, $y, $x, $y1);
3115
        $texto = 'IDENTIFICAÇÃO DOS CONTÊINERES';
3116
        $aFont = array(
3117
            'font' => $this->fontePadrao,
3118
            'size' => 6,
3119
            'style' => '');
3120
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3121
        $texto = $this->pSimpleGetValue($this->ferrov, "nCont");
3122
        $aFont = array(
3123
            'font' => $this->fontePadrao,
3124
            'size' => 6,
3125
            'style' => 'B');
3126
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3127
        // FLUXO
3128
        $x = 1;
3129
        $y += 12.9;
3130
        $h1 = $h * 0.5 + 0.27;
3131
        $wa = round($w * 0.103) + 0.5;
3132
        $texto = 'FLUXO FERROVIARIO';
3133
        $aFont = $this->formatPadrao;
3134
        $this->pTextBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
3135
        $texto = $this->pSimpleGetValue($this->ferrov, "fluxo");
3136
        $aFont = array(
3137
            'font' => $this->fontePadrao,
3138
            'size' => 7,
3139
            'style' => 'B');
3140
        $this->pTextBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
3141
        $y += 10;
3142
        $texto = 'TIPO DE TRÁFEGO';
3143
        $aFont = $this->formatPadrao;
3144
        $this->pTextBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
3145
        $texto = $this->zConvertUnidTrafego($this->pSimpleGetValue($this->ferrov, "tpTraf"));
3146
        $aFont = array(
3147
            'font' => $this->fontePadrao,
3148
            'size' => 7,
3149
            'style' => 'B');
3150
        $this->pTextBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
3151
        // Novo Box Relativo a Modal Ferroviário
3152
        $x = 22.5;
3153
        $y += -10.2;
3154
        $texto = 'INFORMAÇÕES DAS FERROVIAS ENVOLVIDAS';
3155
        $aFont = $this->formatPadrao;
3156
        $this->pTextBox($x, $y, $w - 21.5, $h1 * 2.019, $texto, $aFont, 'T', 'C', 1, '');
3157
        $y += 3.4;
3158
        $this->pdf->Line($x, $y, $w + 1, $y);
3159
        $w = $w * 0.2;
3160
        $h = $h * 1.04;
3161
        $texto = 'CÓDIGO INTERNO';
3162
        $aFont = array(
3163
            'font' => $this->fontePadrao,
3164
            'size' => 6,
3165
            'style' => '');
3166
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3167
        $texto = $this->pSimpleGetValue($this->ferrov, "cInt");
3168
        $aFont = array(
3169
            'font' => $this->fontePadrao,
3170
            'size' => 6,
3171
            'style' => 'B');
3172
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3173
        $texto = 'CNPJ';
3174
        $aFont = array(
3175
            'font' => $this->fontePadrao,
3176
            'size' => 6,
3177
            'style' => '');
3178
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3179
        $texto = $this->pSimpleGetValue($this->ferrov, "CNPJ");
3180
        $aFont = array(
3181
            'font' => $this->fontePadrao,
3182
            'size' => 6,
3183
            'style' => 'B');
3184
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3185
        $x += 50;
3186
        $texto = 'NOME';
3187
        $aFont = array(
3188
            'font' => $this->fontePadrao,
3189
            'size' => 6,
3190
            'style' => '');
3191
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3192
        $texto = $this->pSimpleGetValue($this->ferrov, "xNome");
3193
        $aFont = array(
3194
            'font' => $this->fontePadrao,
3195
            'size' => 6,
3196
            'style' => 'B');
3197
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3198
        $texto = 'INSCRICAO ESTADUAL';
3199
        $aFont = array(
3200
            'font' => $this->fontePadrao,
3201
            'size' => 6,
3202
            'style' => '');
3203
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3204
        $texto = $this->pSimpleGetValue($this->ferrov, "IE");
3205
        $aFont = array(
3206
            'font' => $this->fontePadrao,
3207
            'size' => 6,
3208
            'style' => 'B');
3209
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3210
        $x += 50;
3211
        $texto = 'PARTICIPAÇÃO OUTRA FERROVIA';
3212
        $aFont = array(
3213
            'font' => $this->fontePadrao,
3214
            'size' => 6,
3215
            'style' => '');
3216
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3217
        $texto = '';
3218
        $aFont = array(
3219
            'font' => $this->fontePadrao,
3220
            'size' => 6,
3221
            'style' => 'B');
3222
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3223
    } //fim da função zModalFerr
3224
3225
    /**
3226
     * zCanhoto
3227
     * Monta o campo com os dados do remetente na DACTE.
3228
     *
3229
     * @param  number $x Posição horizontal canto esquerdo
3230
     * @param  number $y Posição vertical canto superior
3231
     * @return number Posição vertical final
3232
     */
3233
    protected function zCanhoto($x = 0, $y = 0)
3234
    {
3235
        $this->zhDashedLine($x, $y+2, $this->wPrint, 0.1, 80);
3236
        $y = $y + 2;
3237
        $oldX = $x;
3238
        $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...
3239
        if ($this->orientacao == 'P') {
3240
            $maxW = $this->wPrint;
3241
        } else {
3242
            $maxW = $this->wPrint - $this->wCanhoto;
3243
        }
3244
        $w = $maxW - 1;
3245
        $h = 20;
3246
        $y = $y + 1;
3247
        $texto = 'DECLARO QUE RECEBI OS VOLUMES DESTE CONHECIMENTO EM PERFEITO ESTADO ';
3248
        $texto .= 'PELO QUE DOU POR CUMPRIDO O PRESENTE CONTRATO DE TRANSPORTE';
3249
        $aFont = $this->formatPadrao;
3250
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3251
        $y += 3.4;
3252
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA ABAICO DO TEXTO DECLARO QUE RECEBI...
3253
3254
        $texto = 'NOME';
3255
        $aFont = array(
3256
            'font' => $this->fontePadrao,
3257
            'size' => 6,
3258
            'style' => '');
3259
        $this->pTextBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'L', 0, '');
3260
        $x += $w * 0.25;
3261
3262
        $this->pdf->Line($x, $y, $x, $y + 16.5);
3263
3264
        $texto = 'ASSINATURA / CARIMBO';
3265
        $aFont = array(
3266
            'font' => $this->fontePadrao,
3267
            'size' => 6,
3268
            'style' => '');
3269
        $this->pTextBox($x, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'B', 'C', 0, '');
3270
        $x += $w * 0.25;
3271
3272
        $this->pdf->Line($x, $y, $x, $y + 16.5);
3273
3274
        $texto = 'TÉRMINO DA PRESTAÇÃO - DATA/HORA' . "\r\n" . "\r\n" . "\r\n". "\r\n";
3275
        $texto .= ' INÍCIO DA PRESTAÇÃO - DATA/HORA';
3276
        $aFont = array(
3277
            'font' => $this->fontePadrao,
3278
            'size' => 6,
3279
            'style' => '');
3280
        $this->pTextBox($x + 10, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'T', 'C', 0, '');
3281
        $x = $oldX;
3282
        $y = $y + 5;
3283
3284
        $this->pdf->Line($x, $y+3, $w * 0.255, $y+3); // LINHA HORIZONTAL ACIMA DO RG ABAIXO DO NOME
3285
3286
        $texto = 'RG';
3287
        $aFont = array(
3288
            'font' => $this->fontePadrao,
3289
            'size' => 6,
3290
            'style' => '');
3291
        $this->pTextBox($x, $y+3, $w * 0.33, $h, $texto, $aFont, 'T', 'L', 0, '');
3292
        $x += $w * 0.85;
3293
3294
        $this->pdf->Line($x, $y + 11.5, $x, $y - 5); // LINHA VERTICAL PROXIMO AO CT-E
3295
3296
        $texto = "CT-E";
3297
        $aFont = $this->formatNegrito;
3298
        $this->pTextBox($x, $y - 5, $w * 0.15, $h, $texto, $aFont, 'T', 'C', 0, '');
3299
        $texto = "\r\n Nº. DOCUMENTO  " . $this->pSimpleGetValue($this->ide, "nCT") . " \n";
3300
        $texto .= "\r\n SÉRIE  " . $this->pSimpleGetValue($this->ide, "serie");
3301
        $aFont = array(
3302
            'font' => $this->fontePadrao,
3303
            'size' => 6,
3304
            'style' => '');
3305
        $this->pTextBox($x, $y - 8, $w * 0.15, $h, $texto, $aFont, 'C', 'C', 0, '');
3306
        $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...
3307
        //$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...
3308
    } //fim da função canhotoDACTE
3309
3310
    /**
3311
     * zDadosAdic
3312
     * Coloca o grupo de dados adicionais da DACTE.
3313
     *
3314
     * @param  number $x Posição horizontal canto esquerdo
3315
     * @param  number $y Posição vertical canto superior
3316
     * @param  number $h altura do campo
3317
     * @return number Posição vertical final
3318
     */
3319
    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...
3320
    {
3321
        $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...
3322
        //###########################################################################
3323
        //DADOS ADICIONAIS DACTE
3324
        if ($this->orientacao == 'P') {
3325
            $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...
3326
        } else {
3327
            $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...
3328
        }
3329
        //INFORMAÇÕES COMPLEMENTARES
3330
        $texto = "USO EXCLUSIVO DO EMISSOR DO CT-E";
3331
        $y += 3;
3332
        $w = $this->wAdic;
3333
        $h = 8; //mudar
3334
        $aFont = array(
3335
            'font' => $this->fontePadrao,
3336
            'size' => 6,
3337
            'style' => '');
3338
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3339
        //$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...
3340
        $this->pdf->Line($x, $y + 3, $w * 1.385, $y + 3);
3341
        //o texto com os dados adicionais foi obtido na função xxxxxx
3342
        //e carregado em uma propriedade privada da classe
3343
        //$this->wAdic com a largura do campo
3344
        //$this->textoAdic com o texto completo do campo
3345
        $y += 1;
3346
        $aFont = $this->formatPadrao;
3347
        $this->pTextBox($x, $y + 3, $w - 2, $h - 3, $this->textoAdic, $aFont, 'T', 'L', 0, '', false);
3348
        //RESERVADO AO FISCO
3349
        $texto = "RESERVADO AO FISCO";
3350
        $x += $w;
3351
        $y -= 1;
3352
        if ($this->orientacao == 'P') {
3353
            $w = $this->wPrint - $w;
3354
        } else {
3355
            $w = $this->wPrint - $w - $this->wCanhoto;
3356
        }
3357
        $aFont = array(
3358
            'font' => $this->fontePadrao,
3359
            'size' => 6,
3360
            'style' => '');
3361
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3362
        //inserir texto informando caso de contingência
3363
        //1 – Normal – emissão normal;
3364
        //2 – Contingência FS – emissão em contingência com impressão do DACTE em Formulário de Segurança;
3365
        //3 – Contingência SCAN – emissão em contingência  – SCAN;
3366
        //4 – Contingência DPEC - emissão em contingência com envio da Declaração Prévia de
3367
        //Emissão em Contingência – DPEC;
3368
        //5 – Contingência FS-DA - emissão em contingência com impressão do DACTE em Formulário de
3369
        //Segurança para Impressão de Documento Auxiliar de Documento Fiscal Eletrônico (FS-DA).
3370
        $xJust = $this->pSimpleGetValue($this->ide, 'xJust', 'Justificativa: ');
3371
        $dhCont = $this->pSimpleGetValue($this->ide, 'dhCont', ' Entrada em contingência : ');
3372
        $texto = '';
3373
        switch ($this->tpEmis) {
3374
            case 2:
3375
                $texto = 'CONTINGÊNCIA FS' . $dhCont . $xJust;
3376
                break;
3377
            case 3:
3378
                $texto = 'CONTINGÊNCIA SCAN' . $dhCont . $xJust;
3379
                break;
3380
            case 4:
3381
                $texto = 'CONTINGÊNCIA DPEC' . $dhCont . $xJust;
3382
                break;
3383
            case 5:
3384
                $texto = 'CONTINGÊNCIA FSDA' . $dhCont . $xJust;
3385
                break;
3386
        }
3387
        $y += 2;
3388
        $aFont = $this->formatPadrao;
3389
        $this->pTextBox($x, $y + 2, $w - 2, $h - 3, $texto, $aFont, 'T', 'L', 0, '', false);
3390
        return $y + $h;
3391
    } //fim zDadosAdic
3392
3393
    /**
3394
     * zhDashedLine
3395
     * Desenha uma linha horizontal tracejada com o FPDF
3396
     *
3397
     * @param  number $x Posição horizontal inicial, em mm
3398
     * @param  number $y Posição vertical inicial, em mm
3399
     * @param  number $w Comprimento da linha, em mm
3400
     * @param  number $h Espessura da linha, em mm
3401
     * @param  number $n Numero de traços na seção da linha com o comprimento $w
3402
     * @return none
3403
     */
3404
    protected function zhDashedLine($x, $y, $w, $h, $n)
3405
    {
3406
        $this->pdf->SetLineWidth($h);
3407
        $wDash = ($w / $n) / 2; // comprimento dos traços
3408
        for ($i = $x; $i <= $x + $w; $i += $wDash + $wDash) {
3409
            for ($j = $i; $j <= ($i + $wDash); $j++) {
3410
                if ($j <= ($x + $w - 1)) {
3411
                    $this->pdf->Line($j, $y, $j + 1, $y);
3412
                }
3413
            }
3414
        }
3415
    } //fim função hDashedLine
3416
3417
    /**
3418
     * zhDashedVerticalLine
3419
     * Desenha uma linha vertical tracejada com o FPDF
3420
     *
3421
     * @param  number $x Posição horizontal inicial, em mm
3422
     * @param  number $y Posição vertical inicial, em mm
3423
     * @param  number $w Comprimento da linha, em mm
3424
     * @param  number $yfinal Espessura da linha, em mm
3425
     * @param  number $n Numero de traços na seção da linha com o comprimento $w
3426
     * @return none
3427
     */
3428
    protected function zhDashedVerticalLine($x, $y, $w, $yfinal, $n)
3429
    {
3430
        $this->pdf->SetLineWidth($w);
3431
        /* Organizando valores */
3432
        if ($y > $yfinal) {
3433
            $aux = $yfinal;
3434
            $yfinal = $y;
3435
            $y = $aux;
3436
        }
3437
        while ($y < $yfinal && $n > 0) {
3438
            $this->pdf->Line($x, $y, $x, $y + 1);
3439
            $y += 3;
3440
            $n--;
3441
        }
3442
    } //fim função hDashedVerticalLine
3443
3444
    /**
3445
     * zFormatCNPJCPF
3446
     * Formata campo CnpjCpf contida na CTe
3447
     *
3448
     * @param  string $field campo cnpjCpf da CT-e
3449
     * @return string
3450
     */
3451
    protected function zFormatCNPJCPF($field)
3452
    {
3453
        if (!isset($field)) {
3454
            return '';
3455
        }
3456
        $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...
3457
            $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...
3458
        if ($cnpj != "" && $cnpj != "00000000000000") {
3459
            $cnpj = $this->pFormat($cnpj, '###.###.###/####-##');
3460
        } else {
3461
            $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...
3462
                $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...
3463
        }
3464
        return $cnpj;
3465
    } //fim formatCNPJCPF
3466
3467
    /**
3468
     * zFormatFone
3469
     * Formata campo fone contida na CTe
3470
     *
3471
     * @param  string $field campo fone da CT-e
3472
     * @return string
3473
     */
3474
    protected function zFormatFone($field)
3475
    {
3476
        try {
3477
            $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...
3478
            $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...
3479
            $foneLen = strlen($fone);
3480
            if ($foneLen > 0) {
3481
                $fone2 = substr($fone, 0, $foneLen - 4);
3482
                $fone1 = substr($fone, 0, $foneLen - 8);
3483
                $fone = '(' . $fone1 . ') ' . substr($fone2, -4) . '-' . substr($fone, -4);
3484
            } else {
3485
                $fone = '';
3486
            }
3487
            return $fone;
3488
        } catch (Exception $exc) {
3489
            return '';
3490
        }
3491
    } //fim formatFone
3492
3493
    /**
3494
     * zUnidade
3495
     * Converte a imformação de peso contida na CTe
3496
     *
3497
     * @param  string $c unidade de trafego extraida da CTe
3498
     * @return string
3499
     */
3500
    protected function zUnidade($c = '')
3501
    {
3502
        switch ($c) {
3503
            case '00':
3504
                $r = 'M3';
3505
                break;
3506
            case '01':
3507
                $r = 'KG';
3508
                break;
3509
            case '02':
3510
                $r = 'TON';
3511
                break;
3512
            case '03':
3513
                $r = 'UN';
3514
                break;
3515
            case '04':
3516
                $r = 'LT';
3517
                break;
3518
            case '05':
3519
                $r = 'MMBTU';
3520
                break;
3521
            default:
3522
                $r = '';
3523
        }
3524
        return $r;
3525
    } //fim unidade
3526
3527
    /**
3528
     * zConvertUnidTrafego
3529
     * Converte a imformação de peso contida na CTe
3530
     *
3531
     * @param  string $U Informação de trafego extraida da CTe
3532
     * @return string
3533
     */
3534
    protected function zConvertUnidTrafego($U = '')
3535
    {
3536
        if ($U) {
3537
            switch ($U) {
3538
                case '0':
3539
                    $stringU = 'Próprio';
3540
                    break;
3541
                case '1':
3542
                    $stringU = 'Mútuo';
3543
                    break;
3544
                case '2':
3545
                    $stringU = 'Rodoferroviário';
3546
                    break;
3547
                case '3':
3548
                    $stringU = 'Rodoviário';
3549
                    break;
3550
            }
3551
            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...
3552
        }
3553
    } //fim da função zConvertUnidTrafego
3554
3555
    /**
3556
     * zMultiUniPeso
3557
     * Fornece a imformação multiplicação de peso contida na CTe
3558
     *
3559
     * @param  interger $U Informação de peso extraida da CTe
3560
     * @return interger
3561
     */
3562
    protected function zMultiUniPeso($U = '')
3563
    {
3564
        if ($U === "01") {
3565
            // tonelada
3566
            //return 1000;
3567
            return 1;
3568
        }
3569
        return 1; // M3, KG, Unidade, litros, mmbtu
3570
    } //fim da função zMultiUniPeso
3571
}
3572