Completed
Pull Request — master (#259)
by Roberto
02:22
created

Damdfe::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace NFePHP\DA\MDFe;
4
5
/**
6
 * Esta classe gera do PDF do MDFDe, conforme regras e estruturas
7
 * estabelecidas pela SEFAZ.
8
 *
9
 * @category  Library
10
 * @package   nfephp-org/sped-da
11
 * @name      Damdfe.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    Leandro C. Lopez <leandro dot castoldi at gmail dot com>
16
 */
17
18
use Com\Tecnick\Barcode\Barcode;
19
use NFePHP\DA\Legacy\Dom;
20
use NFePHP\DA\Legacy\Common;
21
use NFePHP\DA\Legacy\Pdf;
22
23
class Damdfe extends Common
24
{
25
    //publicas
26
    public $logoAlign = 'L'; //alinhamento do logo
27
    public $yDados = 0;
28
    public $debugMode = 0; //ativa ou desativa o modo de debug
29
    //privadas
30
    protected $pdf; // objeto fpdf()
31
    protected $xml; // string XML NFe
32
    protected $logomarca = ''; // path para logomarca em jpg
33
    protected $errMsg = ''; // mesagens de erro
34
    protected $errStatus = false;// status de erro TRUE um erro ocorreu false sem erros
35
    protected $orientacao = 'P'; //orientação da DANFE P-Retrato ou L-Paisagem
36
    protected $papel = 'A4'; //formato do papel
37
    //destivo do arquivo pdf I-borwser, S-retorna o arquivo, D-força download, F-salva em arquivo local
38
    protected $destino = 'I';
39
    protected $pdfDir = ''; //diretorio para salvar o pdf com a opção de destino = F
40
    protected $fontePadrao = 'Times'; //Nome da Fonte para gerar o DANFE
41
    protected $version = '3.00a';
42
    protected $wPrint; //largura imprimivel
43
    protected $hPrint; //comprimento imprimivel
44
    protected $formatoChave = "#### #### #### #### #### #### #### #### #### #### ####";
45
    protected $margemInterna = 2;
46
47
    //variaveis da damdfe
48
    protected $id;
49
    protected $chMDFe;
50
    protected $tpAmb;
51
    protected $cOrgao;
52
    protected $xCondUso;
53
    protected $dhEvento;
54
    protected $cStat;
55
    protected $xMotivo;
56
    protected $CNPJDest = '';
57
    protected $dhRegEvento;
58
    protected $nProt;
59
    protected $tpEmis;
60
    protected $qrCodMDFe;
61
    //objetos
62
    private $dom;
63
    private $creditos;
64
65
    /**
66
     * __construct
67
     *
68
     * @param string $xmlfile Arquivo XML da MDFe
69
     * @param string $sOrientacao (Opcional) Orientação da impressão P-retrato L-Paisagem
70
     * @param string $sPapel Tamanho do papel (Ex. A4)
71
     * @param string $sPathLogo Caminho para o arquivo do logo
72
     * @param string $sDestino Estabelece a direção do envio do documento PDF I-browser D-browser com download S-
73
     * @param string $sDirPDF Caminho para o diretorio de armazenamento dos arquivos PDF
74
     * @param string $fonteDAMDFE Nome da fonte alternativa do DAnfe
0 ignored issues
show
Bug introduced by
There is no parameter named $fonteDAMDFE. 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...
75
     * @param integer $mododebug 0-Não 1-Sim e 2-nada (2 default)
76
     */
77
    public function __construct(
78
        $xmlfile = '',
79
        $sOrientacao = '',
80
        $sPapel = '',
81
        $sPathLogo = '',
82
        $sDestino = 'I',
83
        $sDirPDF = '',
84
        $fontePDF = '',
85
        $mododebug = 2
86
    ) {
87
        //define o caminho base da instalação do sistema
88
        if (!defined('PATH_ROOT')) {
89
            define('PATH_ROOT', dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR);
90
        }
91
        //ajuste do tempo limite de resposta do processo
92
        set_time_limit(1800);
93
        //definição do caminho para o diretorio com as fontes do FDPF
94
        if (!defined('FPDF_FONTPATH')) {
95
            define('FPDF_FONTPATH', 'font/');
96
        }
97
98
        if (is_numeric($mododebug)) {
99
            $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...
100
        }
101
        if ($this->debugMode) {
102
            //ativar modo debug
103
            error_reporting(E_ALL);
104
            ini_set('display_errors', 'On');
105
        } else {
106
            //desativar modo debug
107
            error_reporting(0);
108
            ini_set('display_errors', 'Off');
109
        }
110
        $this->orientacao = $sOrientacao;
111
        $this->papel = $sPapel;
112
        $this->pdf = '';
113
        $this->xml = $xmlfile;
114
        $this->logomarca = $sPathLogo;
115
        $this->destino = $sDestino;
116
        $this->pdfDir = $sDirPDF;
117
        // verifica se foi passa a fonte a ser usada
118
        if (empty($fontePDF)) {
119
            $this->fontePadrao = 'Times';
120
        } else {
121
            $this->fontePadrao = $fontePDF;
122
        }
123
        //se for passado o xml
124
        if (empty($xmlfile)) {
125
            $this->errMsg = 'Um caminho para o arquivo xml da MDFe deve ser passado!';
126
            $this->errStatus = true;
127
        }
128
        if (!is_file($xmlfile)) {
129
            $this->errMsg = 'Um caminho para o arquivo xml da MDFe deve ser passado!';
130
            $this->errStatus = true;
131
        }
132
133
        $this->dom = new Dom();
134
        $this->dom->loadXML($this->xml);
135
        $this->mdfeProc = $this->dom->getElementsByTagName("mdfeProc")->item(0);
0 ignored issues
show
Bug introduced by
The property mdfeProc 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...
136
        $this->infMDFe = $this->dom->getElementsByTagName("infMDFe")->item(0);
0 ignored issues
show
Bug introduced by
The property infMDFe 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...
137
        $this->emit = $this->dom->getElementsByTagName("emit")->item(0);
0 ignored issues
show
Bug introduced by
The property emit 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...
138
        if ($this->dom->getElementsByTagName("CPF")->item(0)) {
139
            $this->CPF = $this->dom->getElementsByTagName("CPF")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property CPF 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...
140
        } else {
141
            $this->CNPJ = $this->dom->getElementsByTagName("CNPJ")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property CNPJ 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...
142
        }
143
        $this->IE = $this->dom->getElementsByTagName("IE")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property IE 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...
144
        $this->xNome = $this->dom->getElementsByTagName("xNome")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property xNome 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...
145
        $this->enderEmit = $this->dom->getElementsByTagName("enderEmit")->item(0);
0 ignored issues
show
Bug introduced by
The property enderEmit 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...
146
        $this->xLgr = $this->dom->getElementsByTagName("xLgr")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property xLgr 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...
147
        $this->nro = $this->dom->getElementsByTagName("nro")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property nro 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...
148
        $this->xBairro = $this->dom->getElementsByTagName("xBairro")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property xBairro 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...
149
        $this->UF = $this->dom->getElementsByTagName("UF")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property UF 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...
150
        $this->xMun = $this->dom->getElementsByTagName("xMun")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property xMun 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...
151
        $this->CEP = $this->dom->getElementsByTagName("CEP")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property CEP 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...
152
        $this->ide = $this->dom->getElementsByTagName("ide")->item(0);
0 ignored issues
show
Bug introduced by
The property ide 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...
153
        $this->tpAmb = $this->dom->getElementsByTagName("tpAmb")->item(0)->nodeValue;
154
        $this->mod = $this->dom->getElementsByTagName("mod")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property mod 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...
155
        $this->serie = $this->dom->getElementsByTagName("serie")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property serie 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...
156
        $this->dhEmi = $this->dom->getElementsByTagName("dhEmi")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property dhEmi 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...
157
        $this->UFIni = $this->dom->getElementsByTagName("UFIni")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property UFIni 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...
158
        $this->UFFim = $this->dom->getElementsByTagName("UFFim")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property UFFim 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...
159
        $this->nMDF = $this->dom->getElementsByTagName("nMDF")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property nMDF 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...
160
        $this->tpEmis = $this->dom->getElementsByTagName("tpEmis")->item(0)->nodeValue;
161
        $this->tot = $this->dom->getElementsByTagName("tot")->item(0);
0 ignored issues
show
Bug introduced by
The property tot 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...
162
        $this->qMDFe = "";
0 ignored issues
show
Bug introduced by
The property qMDFe 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...
163
        if ($this->dom->getElementsByTagName("qMDFe")->item(0) != "") {
164
            $this->qMDFe = $this->dom->getElementsByTagName("qMDFe")->item(0)->nodeValue;
165
        }
166
        $this->qNFe = "";
0 ignored issues
show
Bug introduced by
The property qNFe 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...
167
        if ($this->dom->getElementsByTagName("qNFe")->item(0) != "") {
168
            $this->qNFe = $this->dom->getElementsByTagName("qNFe")->item(0)->nodeValue;
169
        }
170
        $this->qNF = "";
0 ignored issues
show
Bug introduced by
The property qNF 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...
171
        if ($this->dom->getElementsByTagName("qNF")->item(0) != "") {
172
            $this->qNF = $this->dom->getElementsByTagName("qNF")->item(0)->nodeValue;
173
        }
174
        $this->qCTe = "";
0 ignored issues
show
Bug introduced by
The property qCTe 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...
175
        if ($this->dom->getElementsByTagName("qCTe")->item(0) != "") {
176
            $this->qCTe = $this->dom->getElementsByTagName("qCTe")->item(0)->nodeValue;
177
        }
178
        $this->qCT = "";
0 ignored issues
show
Bug introduced by
The property qCT 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...
179
        if ($this->dom->getElementsByTagName("qCT")->item(0) != "") {
180
            $this->qCT = $this->dom->getElementsByTagName("qCT")->item(0)->nodeValue;
181
        }
182
        $this->qCarga = $this->dom->getElementsByTagName("qCarga")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property qCarga 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->infModal = $this->dom->getElementsByTagName("infModal")->item(0);
0 ignored issues
show
Bug introduced by
The property infModal 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->rodo = $this->dom->getElementsByTagName("rodo")->item(0);
0 ignored issues
show
Bug introduced by
The property rodo 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...
185
        $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...
186
        $this->aquav = $this->dom->getElementsByTagName("aquav")->item(0);
0 ignored issues
show
Bug introduced by
The property aquav 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...
187
        $this->ferrov = $this->dom->getElementsByTagName("ferrov")->item(0);
0 ignored issues
show
Bug introduced by
The property ferrov 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...
188
        $this->ciot = "";
0 ignored issues
show
Bug introduced by
The property ciot 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...
189
        if ($this->dom->getElementsByTagName('CIOT')->item(0) != "") {
190
            $this->ciot = $this->dom->getElementsByTagName('CIOT')->item(0)->nodeValue;
191
        }
192
        $this->veicTracao = $this->dom->getElementsByTagName("veicTracao")->item(0);
0 ignored issues
show
Bug introduced by
The property veicTracao 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...
193
        $this->veicReboque = $this->dom->getElementsByTagName("veicReboque");
0 ignored issues
show
Bug introduced by
The property veicReboque 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...
194
        $this->valePed = "";
0 ignored issues
show
Bug introduced by
The property valePed 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...
195
        if ($this->dom->getElementsByTagName("valePed")->item(0) != "") {
196
            $this->valePed = $this->dom->getElementsByTagName("valePed")->item(0)->getElementsByTagName("disp");
197
        }
198
        $this->infCpl = ($infCpl = $this->dom->getElementsByTagName('infCpl')->item(0)) ? $infCpl->nodeValue : "";
0 ignored issues
show
Bug introduced by
The property infCpl 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...
199
        $this->chMDFe = str_replace(
200
            'MDFe',
201
            '',
202
            $this->infMDFe->getAttribute("Id")
203
        );
204
        $this->qrCodMDFe = $this->dom->getElementsByTagName('qrCodMDFe')->item(0) ?
205
            $this->dom->getElementsByTagName('qrCodMDFe')->item(0)->nodeValue : 'SEM INFORMAÇÃO DE QRCODE';
206
        if (is_object($this->mdfeProc)) {
207
            $this->nProt = !empty($this->mdfeProc->getElementsByTagName("nProt")->item(0)->nodeValue) ?
208
                $this->mdfeProc->getElementsByTagName("nProt")->item(0)->nodeValue : '';
209
            $this->dhRecbto = $this->mdfeProc->getElementsByTagName("dhRecbto")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property dhRecbto 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...
210
        }
211
    }//fim construct
212
213
    /**
214
     *buildMDFe
215
     *
216
     */
217
    public function buildMDFe()
218
    {
219
        $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
220
        if ($this->orientacao == 'P') {
221
            // margens do PDF
222
            $margSup = 7;
223
            $margEsq = 7;
224
            $margDir = 7;
225
            // posição inicial do relatorio
226
            $xInic = 7;
227
            $yInic = 7;
228
            if ($this->papel == 'A4') { //A4 210x297mm
229
                $maxW = 210;
230
                $maxH = 297;
231
            }
232
        } else {
233
            // margens do PDF
234
            $margSup = 7;
235
            $margEsq = 7;
236
            $margDir = 7;
237
            // posição inicial do relatorio
238
            $xInic = 7;
239
            $yInic = 7;
240
            if ($this->papel == 'A4') { //A4 210x297mm
241
                $maxH = 210;
242
                $maxW = 297;
243
            }
244
        }//orientação
245
        //largura imprimivel em mm
246
        $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...
247
        //comprimento imprimivel em mm
248
        $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...
249
        // estabelece contagem de paginas
250
        $this->pdf->aliasNbPages();
251
        // fixa as margens
252
        $this->pdf->setMargins($margEsq, $margSup, $margDir);
253
        $this->pdf->setDrawColor(0, 0, 0);
254
        $this->pdf->setFillColor(255, 255, 255);
255
        // inicia o documento
256
        $this->pdf->open();
257
        // adiciona a primeira página
258
        $this->pdf->addPage($this->orientacao, $this->papel);
259
        $this->pdf->setLineWidth(0.1);
260
        $this->pdf->setTextColor(0, 0, 0);
261
        //montagem da página
262
        $pag = 1;
263
        $x = $xInic;
264
        $y = $yInic;
265
        //coloca o cabeçalho Paisagem
266
        if ($this->orientacao == 'P') {
267
            $y = $this->headerMDFeRetrato($x, $y, $pag);
268
        } else {
269
            $y = $this->headerMDFePaisagem($x, $y, $pag);
270
        }
271
        //coloca os dados da MDFe
272
        $y = $this->bodyMDFe($x, $y);
273
        //coloca os dados da MDFe
274
        $y = $this->footerMDFe($x, $y);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->footerMDFe($x, $y) (which targets NFePHP\DA\MDFe\Damdfe::footerMDFe()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
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...
275
    } //fim buildCCe
276
277
    /**
278
     * headerMDFePaisagem
279
     * @param float $x
280
     * @param float $y
281
     * @param integer $pag
282
     * @return string
283
     */
284
    private function headerMDFePaisagem($x, $y, $pag)
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...
285
    {
286
        $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...
287
        $oldY = $y;
288
        $maxW = $this->wPrint;
289
        //####################################################################################
290
        //coluna esquerda identificação do emitente
291
        //$w = $maxW; //round($maxW*0.41, 0);// 80;
292
        $w = round($maxW * 0.70, 0);
293
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'B');
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...
294
        $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...
295
        $h = 30;
296
        $oldY += $h;
297
        $this->pdf->textBox($x, $y, $w, $h);
298
        if (is_file($this->logomarca)) {
299
            $logoInfo = getimagesize($this->logomarca);
300
            //largura da imagem em mm
301
            $logoWmm = ($logoInfo[0] / 72) * 25.4;
302
            //altura da imagem em mm
303
            $logoHmm = ($logoInfo[1] / 72) * 25.4;
304
            if ($this->logoAlign == 'L') {
305
                $nImgW = round($w / 3, 0);
306
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
307
                $xImg = $x + 1;
308
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
309
                //estabelecer posições do texto
310
                $x1 = round($xImg + $nImgW + 1, 0);
311
                $y1 = round($y + 2, 0);
312
                $tw = round(2 * $w / 3, 0);
313
            }
314
            if ($this->logoAlign == 'C') {
315
                $nImgH = round($h / 3, 0);
316
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
317
                $xImg = round(($w - $nImgW) / 2 + $x, 0);
318
                $yImg = $y + 3;
319
                $x1 = $x;
320
                $y1 = round($yImg + $nImgH + 1, 0);
321
                $tw = $w;
322
            }
323
            if ($this->logoAlign == 'R') {
324
                $nImgW = round($w / 3, 0);
325
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
326
                $xImg = round($x + ($w - (1 + $nImgW)), 0);
327
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
328
                $x1 = $x;
329
                $y1 = round($h / 3 + $y, 0);
330
                $tw = round(2 * $w / 3, 0);
331
            }
332
            $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...
333
        } else {
334
            $x1 = $x;
335
            $y1 = round($h / 3 + $y, 0);
336
            $tw = $w;
337
        }
338
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
0 ignored issues
show
Unused Code introduced by
$aFont is not used, you could remove the assignment.

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

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

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

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

Loading history...
339
        $razao = $this->xNome;
0 ignored issues
show
Unused Code introduced by
$razao is not used, you could remove the assignment.

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

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

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

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

Loading history...
340
        if (isset($this->CPF)) {
341
            $cpfcnpj = 'CPF: ' . $this->formatField($this->CPF, "###.###.###-##");
342
        } else {
343
            $cpfcnpj = 'CNPJ: ' . $this->formatField($this->CNPJ, "###.###.###/####-##");
344
        }
345
        $ie = 'IE: ' . $this->formatField($this->IE, '##/########');
346
        $lgr = 'Logradouro: ' . $this->xLgr;
347
        $nro = 'Nº: ' . $this->nro;
348
        $bairro = 'Bairro: ' . $this->xBairro;
349
        $CEP = $this->CEP;
350
        $CEP = 'CEP: ' . $this->formatField($CEP, "##.###-###");
351
        $UF = 'UF: ' . $this->UF;
352
        $mun = 'Municipio: ' . $this->xMun;
353
354
        $texto = $cpfcnpj . ' - ' . $ie . "\n";
355
        $texto .= $lgr . ' - ' . $nro . "\n";
356
        $texto .= $bairro . "\n";
357
        $texto .= $UF . ' - ' . $mun . ' - ' . $CEP;
358
        $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
359
        $this->pdf->textBox($x1, $y1 + 6, $tw, 8, $texto, $aFont, 'T', 'L', 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...
360
        //##################################################
361
        $w = round($maxW * 0.70, 0);
362
        $y = $h + 9;
363
        $this->pdf->textBox($x, $y, $w, 6);
364
        $aFont = ['font' => $this->fontePadrao, 'size' => 12, 'style' => 'I'];
365
        $this->pdf->textBox(
366
            $x,
367
            $y,
368
            $w,
369
            8,
370
            'DAMDFE - Documento Auxiliar de Manifesto Eletronico de Documentos Fiscais',
371
            $aFont,
372
            'T',
373
            'C',
374
            0,
375
            ''
376
        );
377
378
        if ($this->tpAmb != 1) {
379
            $x = 10;
380
            if ($this->orientacao == 'P') {
381
                $yy = round($this->hPrint * 2 / 3, 0);
382
            } else {
383
                $yy = round($this->hPrint / 2, 0);
384
            }
385
            $h = 5;
386
            $w = $maxW - (2 * $x);
387
            $this->pdf->setTextColor(90, 90, 90);
388
            $texto = "SEM VALOR FISCAL";
389
            $aFont = ['font' => $this->fontePadrao, 'size' => 48, 'style' => 'B'];
390
            $this->pdf->textBox($x, $yy, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
391
            $aFont = ['font' => $this->fontePadrao, 'size' => 30, 'style' => 'B'];
392
            $texto = "AMBIENTE DE HOMOLOGAÇÃO";
393
            $this->pdf->textBox($x, $yy + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
394
            $this->pdf->setTextColor(0, 0, 0);
395
        } else {
396
            $x = 10;
397
            if ($this->orientacao == 'P') {
398
                $yy = round($this->hPrint * 2 / 3, 0);
399
            } else {
400
                $yy = round($this->hPrint / 2, 0);
401
            }//fim orientacao
402
            $h = 5;
403
            $w = $maxW - (2 * $x);
404
            $this->pdf->setTextColor(90, 90, 90);
405
            //indicar FALTA DO PROTOCOLO se MDFe não for em contingência
406
            if (($this->tpEmis == 2 || $this->tpEmis == 5)) {
407
                //Contingência
408
                $texto = "DAMDFE Emitido em Contingência";
409
                $aFont = ['font' => $this->fontePadrao, 'size' => 48, 'style' => 'B'];
410
                $this->pdf->textBox($x, $yy, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
411
                $aFont = ['font' => $this->fontePadrao, 'size' => 30, 'style' => 'B'];
412
                $texto = "devido à problemas técnicos";
413
                $this->pdf->textBox($x, $yy + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
414
            }
415
            $this->pdf->setTextColor(0, 0, 0);
416
        }
417
        return $y + 8;
418
    }// fim headerMDFe
419
420
    /**
421
     * headerMDFeRetrato
422
     *
423
     * @param float $x
424
     * @param float $y
425
     * @param integer $pag
426
     * @return string
427
     */
428
    private function headerMDFeRetrato($x, $y, $pag)
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...
429
    {
430
        $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...
431
        $oldY = $y;
432
        $maxW = $this->wPrint;
433
        //####################################################################################
434
        //coluna esquerda identificação do emitente
435
        //$w = $maxW; //round($maxW*0.41, 0);// 80;
436
        $w = round($maxW * 0.70, 0);
437
        $aFont = array('font' => $this->fontePadrao, 'size' => 6, 'style' => 'I');
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...
438
        $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...
439
        $h = 20;
440
        $oldY += $h;
441
        $this->pdf->textBox($x, $y, $w, $h);
442
        if (is_file($this->logomarca)) {
443
            $logoInfo = getimagesize($this->logomarca);
444
            //largura da imagem em mm
445
            $logoWmm = ($logoInfo[0] / 72) * 25.4;
446
            //altura da imagem em mm
447
            $logoHmm = ($logoInfo[1] / 72) * 25.4;
448
            if ($this->logoAlign == 'L') {
449
                // ajusta a dimensão do logo
450
                $nImgW = round((round($maxW * 0.50, 0)) / 3, 0);
451
                $nImgH = round(($h - $y) - 2, 0) + $y;
452
                $xImg = $x + 1;
453
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
454
                //estabelecer posições do texto
455
                $x1 = round($xImg + $nImgW + 4, 0);
456
                $y1 = round($y + 2, 0);
457
                $tw = round(2 * $w / 3, 0);
458
            }
459
            if ($this->logoAlign == 'C') {
460
                $nImgH = round($h / 3, 0);
461
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
462
                $xImg = round(($w - $nImgW) / 2 + $x, 0);
463
                $yImg = $y + 3;
464
                $x1 = $x;
465
                $y1 = round($yImg + $nImgH + 1, 0);
466
                $tw = $w;
467
            }
468
            if ($this->logoAlign == 'R') {
469
                $nImgW = round($w / 3, 0);
470
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
471
                $xImg = round($x + ($w - (1 + $nImgW)), 0);
472
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
473
                $x1 = $x;
474
                $y1 = round($h / 3 + $y, 0);
475
                $tw = round(2 * $w / 3, 0);
476
            }
477
            $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...
478
        } else {
479
            $x1 = $x;
480
            $y1 = $y;
481
            $tw = $w;
482
        }
483
484
        if ($this->qrCodMDFe !== null) {
485
            $this->qrCodeDamdfe($y - 3);
486
        }
487
488
        $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'];
489
        $texto = $this->xNome;
490
        $this->pdf->textBox($x1, $y1, $tw, 8, $texto, $aFont, 'T', 'L', 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...
491
        if (isset($this->CPF)) {
492
            $cpfcnpj = 'CPF: ' . $this->formatField($this->CPF, "###.###.###-##");
493
        } else {
494
            $cpfcnpj = 'CNPJ: ' . $this->formatField($this->CNPJ, "###.###.###/####-##");
495
        }
496
        $ie = 'IE: ' . $this->formatField($this->IE, '###/#######');
497
        $lgr = 'Logradouro: ' . $this->xLgr;
498
        $nro = 'Nº: ' . $this->nro;
499
        $bairro = 'Bairro: ' . $this->xBairro;
500
        $CEP = $this->CEP;
501
        $CEP = 'CEP: ' . $this->formatField($CEP, "##.###-###");
502
        $mun = 'Municipio: ' . $this->xMun;
503
        $UF = 'UF: ' . $this->UF;
504
        $texto = $cpfcnpj . ' - ' . $ie . "\n";
505
        $texto .= $lgr . ' - ' . $nro . "\n";
506
        $texto .= $bairro . "\n";
507
        $texto .= $UF . ' - ' . $mun . ' - ' . $CEP;
508
        $aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
509
        $this->pdf->textBox($x1, $y1 + 4, $tw, 8, $texto, $aFont, 'T', 'L', 0, '');
510
        //##################################################
511
        $w = round($maxW * 0.70, 0);
512
        $y = $h + 9;
513
        $this->pdf->textBox($x, $y, $w, 6);
514
        $aFont = array('font' => $this->fontePadrao, 'size' => 12, 'style' => 'I');
515
        $this->pdf->textBox(
516
            $x,
517
            $y,
518
            $w,
519
            8,
520
            'DAMDFE - Documento Auxiliar de Manifesto Eletronico de Documentos Fiscais',
521
            $aFont,
522
            'T',
523
            'C',
524
            0,
525
            ''
526
        );
527
        if ($this->tpAmb != 1) {
528
            $x = 10;
529
            if ($this->orientacao == 'P') {
530
                $yy = round($this->hPrint * 2 / 3, 0);
531
            } else {
532
                $yy = round($this->hPrint / 2, 0);
533
            }
534
            $h = 5;
535
            $w = $maxW - (2 * $x);
536
            $this->pdf->setTextColor(90, 90, 90);
537
            $texto = "SEM VALOR FISCAL";
538
            $aFont = array('font' => $this->fontePadrao, 'size' => 48, 'style' => 'B');
539
            $this->pdf->textBox($x, $yy, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
540
            $aFont = array('font' => $this->fontePadrao, 'size' => 30, 'style' => 'B');
541
            $texto = "AMBIENTE DE HOMOLOGAÇÃO";
542
            $this->pdf->textBox($x, $yy + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
543
            $this->pdf->setTextColor(0, 0, 0);
544
        } else {
545
            $x = 10;
546
            if ($this->orientacao == 'P') {
547
                $yy = round($this->hPrint * 2 / 3, 0);
548
            } else {
549
                $yy = round($this->hPrint / 2, 0);
550
            }//fim orientacao
551
            $h = 5;
552
            $w = $maxW - (2 * $x);
553
            $this->pdf->setTextColor(90, 90, 90);
554
            //indicar FALTA DO PROTOCOLO se MDFe não for em contingência
555
            if (($this->tpEmis == 2 || $this->tpEmis == 5)) {
556
                //Contingência
557
                $texto = "DAMDFE Emitido em Contingência";
558
                $aFont = array('font' => $this->fontePadrao, 'size' => 48, 'style' => 'B');
559
                $this->pdf->textBox($x, $yy, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
560
                $aFont = array('font' => $this->fontePadrao, 'size' => 30, 'style' => 'B');
561
                $texto = "devido à problemas técnicos";
562
                $this->pdf->textBox($x, $yy + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
563
            }
564
            $this->pdf->setTextColor(0, 0, 0);
565
        }
566
        return $y + 8;
567
    }
568
569
    /**
570
     * bodyMDFe
571
     *
572
     * @param float $x
573
     * @param float $y
574
     * @return void
575
     */
576
    private function bodyMDFe($x, $y)
577
    {
578
        if ($this->orientacao == 'P') {
579
            $maxW = $this->wPrint;
580
        } else {
581
            //$maxW = $this->wPrint / 2;
582
            $maxW = $this->wPrint * 0.9;
583
        }
584
        $x2 = ($maxW / 6);
585
        $x1 = $x2;
586
        $this->pdf->textBox($x, $y, $x2 - 22, 12);
587
        $texto = 'Modelo';
588
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
589
        $this->pdf->textBox($x, $y, $x2 - 22, 8, $texto, $aFont, 'T', 'C', 0, '', false);
590
        $texto = $this->mod;
591
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
592
        $this->pdf->textBox($x, $y + 4, $x2 - 22, 8, $texto, $aFont, 'T', 'C', 0, '', false);
593
594
        if ($this->orientacao == 'P') {
595
            $x1 += $x2 - 47.5;
596
        } else {
597
            $x1 += $x2 - 57.5;
598
        }
599
        $this->pdf->textBox($x1, $y, $x2 - 22, 12);
600
        $texto = 'Série';
601
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
602
        $this->pdf->textBox($x1, $y, $x2 - 22, 8, $texto, $aFont, 'T', 'C', 0, '', false);
603
        $texto = $this->serie;
604
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
605
        $this->pdf->textBox($x1, $y + 4, $x2 - 22, 10, $texto, $aFont, 'T', 'C', 0, '', false);
606
607
        $x1 += $x2 - 22;
608
        $this->pdf->textBox($x1, $y, $x2 - 5, 12);
609
        $texto = 'Número';
610
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
611
        $this->pdf->textBox($x1, $y, $x2 - 5, 8, $texto, $aFont, 'T', 'C', 0, '', false);
612
        $texto = $this->formatField(str_pad($this->nMDF, 9, '0', STR_PAD_LEFT), '###.###.###');
613
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
614
        $this->pdf->textBox($x1, $y + 4, $x2 - 5, 10, $texto, $aFont, 'T', 'C', 0, '', false);
615
        $x1 += $x2 - 5;
616
        $this->pdf->textBox($x1, $y, $x2 - 22, 12);
617
        $texto = 'FL';
618
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
619
        $this->pdf->textBox($x1, $y, $x2 - 22, 8, $texto, $aFont, 'T', 'C', 0, '', false);
620
        $texto = '1';
621
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
622
        $this->pdf->textBox($x1, $y + 4, $x2 - 22, 10, $texto, $aFont, 'T', 'C', 0, '', false);
623
        $x1 += $x2 - 22;
624
        if ($this->orientacao == 'P') {
625
            $x3 = $x2 + 10.5;
626
        } else {
627
            $x3 = $x2 + 3;
628
        }
629
        $this->pdf->textBox($x1, $y, $x3, 12);
630
        $texto = 'Data e Hora de Emissão';
631
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
632
        $this->pdf->textBox($x1, $y, $x3, 8, $texto, $aFont, 'T', 'C', 0, '', false);
633
        $data = explode('T', $this->dhEmi);
634
        $texto = $this->ymdTodmy($data[0]) . ' - ' . $data[1];
635
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B');
636
        $this->pdf->textBox($x1, $y + 4, $x3, 10, $texto, $aFont, 'T', 'C', 0, '', false);
637
        $x1 += $x3;
638
639
        $this->pdf->textBox($x1, $y, $x2 - 15, 12);
640
        $texto = 'UF Carreg.';
641
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
642
        $this->pdf->textBox($x1, $y, $x2 - 15, 8, $texto, $aFont, 'T', 'C', 0, '', false);
643
        $texto = $this->UFIni;
644
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B');
645
        $this->pdf->textBox($x1, $y + 4, $x2 - 15, 10, $texto, $aFont, 'T', 'C', 0, '', false);
646
        $maxW = $this->wPrint;
0 ignored issues
show
Unused Code introduced by
$maxW is not used, you could remove the assignment.

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

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

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

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

Loading history...
647
648
        $x1 += $x2 - 15;
649
        $this->pdf->textBox($x1, $y, $x2 - 16, 12);
650
        $texto = 'UF Descar.';
651
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
652
        $this->pdf->textBox($x1, $y, $x2 - 16, 8, $texto, $aFont, 'T', 'C', 0, '', false);
653
        $texto = $this->UFFim;
654
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B');
655
        $this->pdf->textBox($x1, $y + 4, $x2 - 16, 10, $texto, $aFont, 'T', 'C', 0, '', false);
656
        $maxW = $this->wPrint;
657
658
        if ($this->aquav) {
659
            $x1 = $x;
660
            $x2 = $maxW;
661
            $y += 14;
662
            $this->pdf->textBox($x1, $y, $x2, 10);
663
            $texto = 'Embarcação';
664
            $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
665
            $this->pdf->textBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
666
            $texto = $this->aquav->getElementsByTagName('cEmbar')->item(0)->nodeValue;
667
            $texto .= ' - ';
668
            $texto .= $this->aquav->getElementsByTagName('xEmbar')->item(0)->nodeValue;
669
            $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B');
670
            $this->pdf->textBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'L', 0, '', false);
671
        }
672
673
        $x1 = $x;
674
        $x2 = $maxW;
675
        $y += 13;
676
        $this->pdf->textBox($x1, $y, $x2, 43);
677
        if ($this->rodo) {
678
            $texto = 'Modal Rodoviário de Carga';
679
        }
680
        if ($this->aereo) {
681
            $texto = 'Modal Aéreo de Carga';
682
        }
683
        if ($this->aquav) {
684
            $texto = 'Modal Aquaviário de Carga';
685
        }
686
        if ($this->ferrov) {
687
            $texto = 'Modal Ferroviário de Carga';
688
        }
689
        $aFont = array('font' => $this->fontePadrao, 'size' => 12, 'style' => 'B');
690
        $this->pdf->textBox($x1, $y + 1, $x2 / 2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
691
        $texto = 'CONTROLE DO FISCO';
692
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
693
        $this->pdf->textBox($x1 + ($x2 / 2), $y + 1, $x2 / 2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
694
695
        $x1 = $x;
696
        $x2 = ($maxW / 6);
697
        $y += 6;
698
        $this->pdf->textBox($x1, $y, $x2, 12);
699
        $texto = 'Qtd. CT-e';
700
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
701
        $this->pdf->textBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
702
        $texto = str_pad($this->qCTe, 3, '0', STR_PAD_LEFT);
703
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B');
704
        $this->pdf->textBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
705
        $x1 += $x2;
706
        $this->pdf->textBox($x1, $y, $x2, 12);
707
        $texto = 'Qtd. NF-e';
708
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
709
        $this->pdf->textBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
710
        $texto = str_pad($this->qNFe, 3, '0', STR_PAD_LEFT);
711
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B');
712
        $this->pdf->textBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
713
        $x1 += $x2;
714
        $this->pdf->textBox($x1, $y, $x2, 12);
715
716
        if ($this->rodo ||
717
            $this->aereo ||
718
            $this->ferrov) {
719
            $texto = 'Peso Total (Kg)';
720
            $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
721
            $this->pdf->textBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
722
            $texto = number_format($this->qCarga, 4, ',', '.');
723
            $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B');
724
            $this->pdf->textBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
725
        }
726
727
        if ($this->aquav) {
728
            $texto = 'Qtd. MDF-e Ref.';
729
            $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
730
            $this->pdf->textBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
731
            $texto = str_pad($this->qMDFe, 3, '0', STR_PAD_LEFT);
732
            $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B');
733
            $this->pdf->textBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
734
735
            $ya = $y + 12;
736
            $this->pdf->textBox($x, $ya, $maxW / 2, 12);
737
            $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
738
            $texto = 'Peso Total (Kg)';
739
            $this->pdf->textBox($x, $ya, $maxW / 2, 8, $texto, $aFont, 'T', 'L', 0, '');
740
            $texto = number_format($this->qCarga, 4, ',', '.');
741
            $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B');
742
            $this->pdf->textBox($x, $ya + 4, $x2, 10, $texto, $aFont, 'T', 'L', 0, '', false);
743
        }
744
745
        // codigo de barras da chave
746
        $x1 += $x2;
747
        //$y = $y + 8;
748
        $this->pdf->textBox($x1, $y, $maxW / 2, 20);
749
        $bH = 16;
750
        $w = $maxW;
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...
751
        $this->pdf->setFillColor(0, 0, 0);
752
        $this->pdf->code128($x1 + 5, $y + 2, $this->chMDFe, ($maxW / 2) - 10, $bH);
753
        $this->pdf->setFillColor(255, 255, 255);
754
755
        // protocolo de autorização
756
        $y = $y + 24;
757
        $this->pdf->textBox($x, $y, $maxW / 2, 13);
758
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'B');
759
        $texto = 'Protocolo de Autorização';
760
        $this->pdf->textBox($x, $y, $maxW / 2, 8, $texto, $aFont, 'T', 'L', 0, '');
761
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
762
        if (is_object($this->mdfeProc)) {
763
            $tsHora = $this->convertTime($this->dhRecbto);
764
            $texto = $this->nProt . ' - ' . date('d/m/Y   H:i:s', $tsHora);
765
        } else {
766
            $texto = 'DAMDFE impresso em contingência - ' . date('d/m/Y   H:i:s');
767
        }
768
        $this->pdf->textBox($x, $y + 4, $maxW / 2, 8, $texto, $aFont, 'T', 'C', 0, '');
769
770
        $y -= 4;
771
772
        // chave de acesso
773
        $this->pdf->textBox($x + $maxW / 2, $y, $maxW / 2, 17);
774
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'I');
775
        $tsHora = $this->convertTime($this->dhEvento);
0 ignored issues
show
Unused Code introduced by
$tsHora is not used, you could remove the assignment.

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

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

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

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

Loading history...
776
        $texto = 'Chave de Acesso';
777
        $this->pdf->textBox($x + $maxW / 2, $y, $maxW / 2, 6, $texto, $aFont, 'T', 'L', 0, '');
778
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
779
        $texto = $this->formatField($this->chMDFe, $this->formatoChave);
780
        $this->pdf->textBox($x + $maxW / 2, $y + 4, $maxW / 2, 6, $texto, $aFont, 'T', 'C', 0, '');
781
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B');
782
        $texto = 'Consulte em https://dfe-portal.sefazvirtual.rs.gov.br/MDFe/consulta';
783
        $this->pdf->textBox($x + $maxW / 2, $y + 10, $maxW / 2, 6, $texto, $aFont, 'T', 'C', 0, '');
784
785
        $x1 = $x;
786
        $y += 20;
787
        $yold = $y;
788
        $x2 = round($maxW / 2, 0);
789
790
        if ($this->rodo) {
791
            $texto = 'Veículo';
792
            $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
793
            $this->pdf->textBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
794
            $y += 5;
795
            $x2 = round($maxW / 4, 0);
796
            $tamanho = 22;
797
            $this->pdf->textBox($x1, $y, $x2, $tamanho);
798
            $texto = 'Placa';
799
            $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
800
            $this->pdf->textBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
801
            $texto = $this->veicTracao->getElementsByTagName("placa")->item(0)->nodeValue;
802
            $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
803
            $this->pdf->textBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
804
            $altura = $y + 4;
805
            /** @var \DOMNodeList $veicReboque */
806
            $veicReboque = $this->veicReboque;
807
            foreach ($veicReboque as $item) {
808
                /** @var \DOMElement $item */
809
                $altura += 4;
810
                $texto = $item->getElementsByTagName('placa')->item(0)->nodeValue;
811
                $this->pdf->textBox($x1, $altura, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
812
            }
813
            $x1 += $x2;
814
            $this->pdf->textBox($x1, $y, $x2, $tamanho);
815
            $texto = 'RNTRC';
816
            $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
817
            $this->pdf->textBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
818
            // RNTRC Não informado
819
            if ($this->rodo->getElementsByTagName("RNTRC")->length > 0) {
820
                $texto = $this->rodo->getElementsByTagName("RNTRC")->item(0)->nodeValue;
821
            } else {
822
                $texto = "";
823
            }
824
            $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
825
            $this->pdf->textBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
826
            $altura = $y + 4;
827
            /** @var \DOMNodeList $veicReboque */
828
            $veicReboque = $this->veicReboque;
829
            foreach ($veicReboque as $item) {
830
                /** @var \DOMElement $item */
831
                $DOMNodeList = $item->getElementsByTagName('RNTRC');
832
                if ($DOMNodeList->length > 0) {
833
                    $altura += 4;
834
                    $texto = $DOMNodeList->item(0)->nodeValue;
835
                    $this->pdf->textBox($x1, $altura, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
836
                }
837
            }
838
            $x1 = $x;
839
            $y += 22;
840
            $x2 = round($maxW / 2, 0);
841
            $valesPedagios = 1;
842
            $temVales = false;
843
            if ($this->valePed != "" && $this->valePed->length > 0) {
844
                $valesPedagios = $this->valePed->length;
845
                $temVales = true;
846
            }
847
            $tamanho = ($valesPedagios * 7.5);
848
            if (!$temVales) {
849
                $valesPedagios = 0;
850
            }
851
            $this->pdf->textBox($x1, $y, $x2, 11 + $tamanho / 2);
852
            $texto = 'Vale Pedágio';
853
            $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
854
            $this->pdf->textBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
855
            $y += 5;
856
            $x2 = ($x2 / 3);
857
            $this->pdf->textBox($x1, $y, $x2 - 3, 6 + ($tamanho / 2));
858
            $texto = 'Responsável CNPJ';
859
            $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
860
            $this->pdf->textBox($x1, $y, $x2 - 4, 8, $texto, $aFont, 'T', 'L', 0, '', false);
861
            $altura = $y;
862
            for ($i = 0; $i < $valesPedagios; $i++) {
863
                $altura += 4;
864
                $texto = $this->valePed->item($i)->getElementsByTagName('CNPJForn')->item(0)->nodeValue;
865
                $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
866
                $this->pdf->textBox($x1 + 1, $altura, $x2 - 5, 10, $texto, $aFont, 'T', 'L', 0, '', false);
867
            }
868
            $x1 += $x2 - 3;
869
            $this->pdf->textBox($x1, $y, $x2 - 3, 6 + ($tamanho / 2));
870
            $texto = 'Fornecedora CNPJ';
871
            $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
872
            $this->pdf->textBox($x1, $y, $x2 - 4, 8, $texto, $aFont, 'T', 'L', 0, '', false);
873
            $altura = $y;
874
            for ($i = 0; $i < $valesPedagios; $i++) {
875
                $altura += 4;
876
                $texto = $this->valePed->item($i)->getElementsByTagName('CNPJPg')->item(0)->nodeValue;
877
                $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
878
                $this->pdf->textBox($x1 + 1, $altura, $x2 - 5, 10, $texto, $aFont, 'T', 'L', 0, '', false);
879
            }
880
            $x1 += $x2 - 3;
881
            $this->pdf->textBox($x1, $y, $x2 + 6, 6 + ($tamanho / 2));
882
            $texto = 'Nº Comprovante';
883
            $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
884
            $this->pdf->textBox($x1, $y, $x2 + 6, 8, $texto, $aFont, 'T', 'L', 0, '', false);
885
            $altura = $y;
886
            for ($i = 0; $i < $valesPedagios; $i++) {
887
                $altura += 4;
888
                $texto = $this->valePed->item($i)->getElementsByTagName('nCompra')->item(0)->nodeValue;
889
                $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
890
                $this->pdf->textBox($x1 + 1, $altura, $x2 + 5, 10, $texto, $aFont, 'T', 'L', 0, '', false);
891
            }
892
            if (!$temVales) {
893
                $altura += 4;
894
            }
895
            $this->condutor = $this->veicTracao->getElementsByTagName('condutor');
0 ignored issues
show
Bug introduced by
The property condutor 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...
896
            $x1 = round($maxW / 2, 0) + 7;
897
            $y = $yold;
898
            $x2 = round($maxW / 2, 0);
899
            $texto = 'Condutor';
900
            $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
901
            $this->pdf->textBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
902
            $y += 5;
903
            $x2 = ($maxW / 6);
904
            $this->pdf->textBox($x1, $y, $x2, 33 + ($tamanho / 2));
905
            $texto = 'CPF';
906
            $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
907
            $this->pdf->textBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
908
            $yold = $y;
909
            for ($i = 0; $i < $this->condutor->length; $i++) {
910
                $y += 4;
911
                $texto = $this->condutor->item($i)->getElementsByTagName('CPF')->item(0)->nodeValue;
912
                $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
913
                $this->pdf->textBox($x1 + 1, $y, $x2 - 1, 10, $texto, $aFont, 'T', 'L', 0, '', false);
914
            }
915
            $y = $yold;
916
            $x1 += $x2;
917
            $x2 = $x2 * 2;
918
            $this->pdf->textBox($x1, $y, $x2, 33 + ($tamanho / 2));
919
            $texto = 'Nome';
920
            $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
921
            $this->pdf->textBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
922
            for ($i = 0; $i < $this->condutor->length; $i++) {
923
                $y += 4;
924
                $texto = $this->condutor->item($i)->getElementsByTagName('xNome')->item(0)->nodeValue;
925
                $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
926
                $this->pdf->textBox($x1 + 1, $y, $x2 - 1, 8, $texto, $aFont, 'T', 'L', 0, '', false);
927
            }
928
        }
929
930
        if ($this->aereo) {
931
            $altura = $y + 4;
932
        }
933
934
        if ($this->aquav) {
935
            $x1 = $x;
936
            $x2 = $maxW;
937
938
            $initial = $y;
939
            $initialA = $y + 2;
940
            $initialB = $y + 2;
941
942
            $texto = 'Carregamento';
943
            $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'B');
944
            $this->pdf->textBox($x, $initial + 2, ($x2 / 2), 8, $texto, $aFont, 'T', 'L', 0, '', false);
945
            foreach ($this->aquav->getElementsByTagName('infTermCarreg') as $item) {
946
                $initialA += 4.5;
947
948
                $texto = $item->getElementsByTagName('cTermCarreg')->item(0)->nodeValue;
949
                $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
950
                $this->pdf->textBox($x1 + 1, $initialA, ($x2 / 2) - 1, 10, $texto, $aFont, 'T', 'L', 0, '', false);
951
952
                $texto = $item->getElementsByTagName('xTermCarreg')->item(0)->nodeValue;
953
                $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
954
                $this->pdf->textBox($x1 + 25, $initialA, ($x2 / 2) - 25, 10, $texto, $aFont, 'T', 'L', 0, '', false);
955
956
                if (strlen($texto) > 50) {
957
                    $initialA += 2;
958
                }
959
            }
960
            if ($this->aquav->getElementsByTagName('infTermCarreg')->item(0) != null) {
961
                $this->pdf->textBox($x1, $initial + 6, ($x2 / 2), $initialA - $y);
962
            }
963
964
            $texto = 'Descarregamento';
965
            $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'B');
966
            $this->pdf->textBox($x1 + ($x2 / 2), $initial + 2, $x2 / 2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
967
            foreach ($this->aquav->getElementsByTagName('infTermDescarreg') as $item) {
968
                $initialB += 4.5;
969
970
                $texto = $item->getElementsByTagName('cTermDescarreg')->item(0)->nodeValue;
971
                $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
972
                $this->pdf->textBox(
973
                    ($x1 + ($x2 / 2)) + 1,
974
                    $initialB,
975
                    ($x2 / 2) - 1,
976
                    10,
977
                    $texto,
978
                    $aFont,
979
                    'T',
980
                    'L',
981
                    0,
982
                    '',
983
                    false
984
                );
985
986
                $texto = $item->getElementsByTagName('xTermDescarreg')->item(0)->nodeValue;
987
                $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
988
989
                $this->pdf->textBox(
990
                    ($x1 + ($x2 / 2)) + 25,
991
                    $initialB,
992
                    ($x2 / 2) - 25,
993
                    10,
994
                    $texto,
995
                    $aFont,
996
                    'T',
997
                    'L',
998
                    0,
999
                    '',
1000
                    false
1001
                );
1002
1003
                if (strlen($texto) > 50) {
1004
                    $initialB += 2;
1005
                }
1006
            }
1007
            if ($this->aquav->getElementsByTagName('infTermDescarreg')->item(0) != null) {
1008
                $this->pdf->textBox(($x1 + ($x2 / 2)), $initial + 6, ($x2 / 2), $initialB - $y);
1009
            }
1010
1011
            $altura = $initialA > $initialB ? $initialA : $initialB;
1012
            $altura += 6;
1013
1014
            $y = $altura + 3;
1015
1016
            $initial = $y;
1017
            $initialA = $y + 2;
1018
            $initialB = $y + 2;
1019
1020
            $texto = 'Unidade de Transporte';
1021
            $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'B');
1022
            $this->pdf->textBox($x, $initial + 2, ($x2 / 2), 8, $texto, $aFont, 'T', 'L', 0, '', false);
1023
1024
            $texto = 'Unidade de Carga';
1025
            $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'B');
1026
            $this->pdf->textBox($x1 + ($x2 / 4), $initial + 2, ($x2 / 2), 8, $texto, $aFont, 'T', 'L', 0, '', false);
1027
1028
            foreach ($this->aquav->getElementsByTagName('infUnidCargaVazia') as $item) {
1029
                $initialA += 4.5;
1030
1031
                $texto = $item->getElementsByTagName('idUnidCargaVazia')->item(0)->nodeValue;
1032
                $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
1033
                $this->pdf->textBox($x1 + 1, $initialA, ($x2 / 2) - 1, 10, $texto, $aFont, 'T', 'L', 0, '', false);
1034
1035
                $texto = $item->getElementsByTagName('tpUnidCargaVazia')->item(0)->nodeValue;
1036
                $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
1037
                $this->pdf->textBox(
1038
                    $x1 + ($x2 / 4),
1039
                    $initialA,
1040
                    ($x2 / 2) - 25,
1041
                    10,
1042
                    $texto,
1043
                    $aFont,
1044
                    'T',
1045
                    'L',
1046
                    0,
1047
                    '',
1048
                    false
1049
                );
1050
1051
                if (strlen($texto) > 50) {
1052
                    $initialA += 2;
1053
                }
1054
            }
1055
            if ($this->aquav->getElementsByTagName('infUnidCargaVazia')->item(0) != null) {
1056
                $this->pdf->textBox($x1, $initial + 6, ($x2 / 2), $initialA - $y);
1057
            }
1058
1059
            $texto = 'Unidade de Transporte';
1060
            $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'B');
1061
            $this->pdf->textBox($x1 + ($x2 / 2), $initial + 2, $x2 / 2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
1062
1063
            $texto = 'Unidade de Carga';
1064
            $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'B');
1065
            $this->pdf->textBox($x1 + ($x2 / 1.33), $initial + 2, ($x2 / 2), 8, $texto, $aFont, 'T', 'L', 0, '', false);
1066
1067
            foreach ($this->aquav->getElementsByTagName('infUnidTranspVazia') as $item) {
1068
                $initialB += 4.5;
1069
1070
                $texto = $item->getElementsByTagName('idUnidTranspVazia')->item(0)->nodeValue;
1071
                $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
1072
1073
                $this->pdf->textBox(
1074
                    ($x1 + ($x2 / 2)) + 1,
1075
                    $initialB,
1076
                    ($x2 / 2) - 1,
1077
                    10,
1078
                    $texto,
1079
                    $aFont,
1080
                    'T',
1081
                    'L',
1082
                    0,
1083
                    '',
1084
                    false
1085
                );
1086
1087
                $texto = $item->getElementsByTagName('tpUnidTranspVazia')->item(0)->nodeValue;
1088
                $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
1089
                $this->pdf->textBox(
1090
                    ($x1 + ($x2 / 1.33)),
1091
                    $initialB,
1092
                    ($x2 / 2) - 25,
1093
                    10,
1094
                    $texto,
1095
                    $aFont,
1096
                    'T',
1097
                    'L',
1098
                    0,
1099
                    '',
1100
                    false
1101
                );
1102
1103
                if (strlen($texto) > 50) {
1104
                    $initialB += 2;
1105
                }
1106
            }
1107
            if ($this->aquav->getElementsByTagName('infUnidTranspVazia')->item(0) != null) {
1108
                $this->pdf->textBox(($x1 + ($x2 / 2)), $initial + 6, ($x2 / 2), $initialB - $y);
1109
            }
1110
1111
            $altura = $initialA > $initialB ? $initialA : $initialB;
1112
            $altura += 6;
1113
        }
1114
1115
        if ($this->ferrov) {
1116
            $altura = $y + 4;
1117
        }
1118
1119
        return $altura + 10;
0 ignored issues
show
Bug introduced by
The variable $altura 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...
1120
    }
1121
1122
1123
    protected function qrCodeDamdfe($y = 0)
1124
    {
1125
        $margemInterna = $this->margemInterna;
1126
        $barcode = new Barcode();
1127
        $bobj = $barcode->getBarcodeObj(
1128
            'QRCODE,M',
1129
            $this->qrCodMDFe,
1130
            -4,
1131
            -4,
1132
            'black',
1133
            array(-2, -2, -2, -2)
1134
        )->setBackgroundColor('white');
1135
        $qrcode = $bobj->getPngData();
1136
        $wQr = 35;
1137
        $hQr = 35;
1138
        $yQr = ($y + $margemInterna);
1139
        if ($this->orientacao == 'P') {
1140
            $xQr = 160;
1141
        } else {
1142
            $xQr = 235;
1143
        }
1144
        // prepare a base64 encoded "data url"
1145
        $pic = 'data://text/plain;base64,' . base64_encode($qrcode);
1146
        $this->pdf->image($pic, $xQr, $yQr, $wQr, $hQr, 'PNG');
1147
    }
1148
1149
1150
    /**
1151
     * footerMDFe
1152
     *
1153
     * @param float $x
1154
     * @param float $y
1155
     */
1156
    private function footerMDFe($x, $y)
1157
    {
1158
        $maxW = $this->wPrint;
1159
        $x2 = $maxW;
1160
        $this->pdf->textBox($x, $y, $x2, 30);
1161
        $texto = 'Observação
1162
        ' . $this->infCpl;
1163
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
1164
        $this->pdf->textBox($x, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
1165
        $y = $this->hPrint - 4;
1166
        $texto = "Impresso em  " . date('d/m/Y H:i:s');
1167
        $w = $this->wPrint - 4;
1168
        $aFont = array('font' => $this->fontePadrao, 'size' => 6, 'style' => 'I');
1169
        $this->pdf->textBox($x, $y, $w, 4, $texto, $aFont, 'T', 'L', 0, '');
1170
        $texto = $this->creditos .  "  Powered by NFePHP®";
1171
        $this->pdf->textBox($x, $y, $w, 0, $texto, $aFont, 'T', 'R', false, '');
0 ignored issues
show
Documentation introduced by
false is of type boolean, but the function expects a integer.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1172
    }
1173
1174
    /**
1175
     * printMDFe
1176
     *
1177
     * @param string $nome
1178
     * @param string $destino
1179
     * @param string $printer
1180
     * @return string
1181
     */
1182
    public function printMDFe($nome = '', $destino = 'I', $printer = '')
1183
    {
1184
        //monta
1185
        $command = '';
1186
        if ($nome == '') {
1187
            $file = $this->pdfDir . 'mdfe.pdf';
1188
        } else {
1189
            $file = $this->pdfDir . $nome;
1190
        }
1191
        if ($destino != 'I' && $destino != 'S' && $destino != 'F') {
1192
            $destino = 'I';
1193
        }
1194
        if ($printer != '') {
1195
            $command = "-P $printer";
1196
        }
1197
1198
        $this->buildMDFe();
1199
        $arq = $this->pdf->output($file, $destino);
1200
        if ($destino == 'S' && $command != '') {
1201
            //aqui pode entrar a rotina de impressão direta
1202
            $command = "lpr $command $file";
1203
            system($command, $retorno);
1204
        }
1205
1206
        return $arq;
1207
    }
1208
1209
    /**
1210
     * Dados brutos do PDF
1211
     * @return string
1212
     */
1213
    public function render()
1214
    {
1215
        return $this->pdf->getPdf();
1216
    }
1217
    
1218
    /**
1219
     * Add the credits to the integrator in the footer message
1220
     * @param string $message
1221
     */
1222
    public function creditsIntegratorFooter($message = '')
1223
    {
1224
        $this->creditos = trim($message);
1225
    }
1226
}
1227