Completed
Push — master ( e40ab2...2d4eb1 )
by Roberto
05:08 queued 12s
created

Daevento::creditsIntegratorFooter()   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 1
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\NFe;
4
5
/**
6
 * Esta classe gera a representação em PDF de um evento de NFe
7
 * NOTA: Esse documento NÃO É NORMALIZADO, nem é requerido pela SEFAZ
8
 *
9
 * @category  Library
10
 * @package   nfephp-org/sped-da
11
 * @name      Daevento.php
12
 * @copyright 2009-2019 NFePHP
13
 * @license   http://www.gnu.org/licenses/lgpl.html GNU/LGPL v.3
14
 * @link      http://github.com/nfephp-org/sped-da for the canonical source repository
15
 * @author    Roberto L. Machado <linux.rlm at gmail dot com>
16
 */
17
18
use Exception;
19
use NFePHP\DA\Legacy\Dom;
20
use NFePHP\DA\Legacy\Pdf;
21
use NFePHP\DA\Common\DaCommon;
22
23
class Daevento extends DaCommon
24
{
25
    public $chNFe;
26
27
    protected $yDados = 0;
28
    protected $dadosEmitente = array();
29
    protected $xml;
30
    protected $errMsg = '';
31
    protected $errStatus = false;
32
    protected $version = '0.1.4';
33
    protected $wCanhoto;
34
    protected $formatoChave = "#### #### #### #### #### #### #### #### #### #### ####";
35
    protected $id;
36
    protected $tpAmb;
37
    protected $cOrgao;
38
    protected $xCorrecao;
39
    protected $xCondUso;
40
    protected $dhEvento;
41
    protected $cStat;
42
    protected $xMotivo;
43
    protected $xJust;
44
    protected $CNPJDest = '';
45
    protected $CPFDest = '';
46
    protected $dhRegEvento;
47
    protected $nProt;
48
    protected $tpEvento;
49
50
    private $dom;
51
    private $procEventoNFe;
52
    private $evento;
53
    private $infEvento;
54
    private $retEvento;
55
    private $rinfEvento;
56
57
    /**
58
     * __construct
59
     *
60
     * @param string $xml Arquivo XML (diretório ou string)
61
     * @param array $dadosEmitente Dados do endereço do emitente
62
     */
63
    public function __construct($xml, $dadosEmitente)
64
    {
65
        $this->dadosEmitente = $dadosEmitente;
66
        $this->debugMode();
67
        $this->loadDoc($xml);
68
    }
69
70
    /**
71
     * Ativa ou desativa o modo debug
72
     * @param bool $activate
73
     * @return bool
74
     */
75
    public function debugMode($activate = null)
76
    {
77
        if (isset($activate) && is_bool($activate)) {
78
            $this->debugmode = $activate;
79
        }
80
        if ($this->debugmode) {
81
            //ativar modo debug
82
            error_reporting(E_ALL);
83
            ini_set('display_errors', 'On');
84
        } else {
85
            //desativar modo debug
86
            error_reporting(0);
87
            ini_set('display_errors', 'Off');
88
        }
89
        return $this->debugmode;
90
    }
91
92
    /**
93
     * Dados brutos do PDF
94
     * @return string
95
     */
96
    public function render(
97
        $logo = null,
98
        $orientacao = 'P',
99
        $papel = 'A4',
100
        $logoAlign = 'C'
101
    ) {
102
        if (empty($this->pdf)) {
103
            $this->monta($logo, $orientacao, $papel, $logoAlign);
0 ignored issues
show
Unused Code introduced by
The call to Daevento::monta() has too many arguments starting with $orientacao.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
104
        }
105
        return $this->pdf->getPdf();
106
    }
107
108
    protected function loadDoc($xml)
109
    {
110
        $this->dom = new Dom();
111
        $this->dom->loadXML($xml);
112
        $this->procEventoNFe = $this->dom->getElementsByTagName("procEventoNFe")->item(0);
113
        $this->evento = $this->dom->getElementsByTagName("evento")->item(0);
114
        $this->infEvento = $this->evento->getElementsByTagName("infEvento")->item(0);
115
        $this->retEvento = $this->dom->getElementsByTagName("retEvento")->item(0);
116
        $this->rinfEvento = $this->retEvento->getElementsByTagName("infEvento")->item(0);
117
        $this->tpEvento = $this->infEvento->getElementsByTagName("tpEvento")->item(0)->nodeValue;
118
        if (!in_array($this->tpEvento, ['110110','110111'])) {
119
            $this->errMsg = 'Evento não implementado ' . $tpEvento . ' !!';
0 ignored issues
show
Bug introduced by
The variable $tpEvento does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
120
            $this->errStatus = true;
121
            return false;
122
        }
123
        $this->id = str_replace('ID', '', $this->infEvento->getAttribute("Id"));
124
        $this->chNFe = $this->infEvento->getElementsByTagName("chNFe")->item(0)->nodeValue;
125
        $this->dadosEmitente['CNPJ'] = $this->infEvento->getElementsByTagName("CNPJ")->item(0)->nodeValue;
126
        $this->tpAmb = $this->infEvento->getElementsByTagName("tpAmb")->item(0)->nodeValue;
127
        $this->cOrgao = $this->infEvento->getElementsByTagName("cOrgao")->item(0)->nodeValue;
128
        $this->xCorrecao = $this->infEvento->getElementsByTagName("xCorrecao")->item(0);
129
        $this->xCorrecao = (empty($this->xCorrecao) ? '' : $this->xCorrecao->nodeValue);
130
        $this->xCondUso = $this->infEvento->getElementsByTagName("xCondUso")->item(0);
131
        $this->xCondUso = (empty($this->xCondUso) ? '' : $this->xCondUso->nodeValue);
132
        $this->xJust = $this->infEvento->getElementsByTagName("xJust")->item(0);
133
        $this->xJust = (empty($this->xJust) ? '' : $this->xJust->nodeValue);
134
        $this->dhEvento = $this->infEvento->getElementsByTagName("dhEvento")->item(0)->nodeValue;
135
        $this->cStat = $this->rinfEvento->getElementsByTagName("cStat")->item(0)->nodeValue;
136
        $this->xMotivo = $this->rinfEvento->getElementsByTagName("xMotivo")->item(0)->nodeValue;
137
        $this->CNPJDest = !empty($this->rinfEvento->getElementsByTagName("CNPJDest")->item(0)->nodeValue) ?
138
            $this->rinfEvento->getElementsByTagName("CNPJDest")->item(0)->nodeValue :
139
            '';
140
        $this->CPFDest = !empty($this->rinfEvento->getElementsByTagName("CPFDest")->item(0)->nodeValue) ?
141
            $this->rinfEvento->getElementsByTagName("CPFDest")->item(0)->nodeValue :
142
            '';
143
        $this->dhRegEvento = $this->rinfEvento->getElementsByTagName("dhRegEvento")->item(0)->nodeValue;
144
        $this->nProt = $this->rinfEvento->getElementsByTagName("nProt")->item(0)->nodeValue;
145
    }
146
147
    /**
148
     * monta
149
     *
150
     * Esta função monta a DaEventoNFe conforme as informações fornecidas para a classe
151
     * durante sua construção.
152
     * A definição de margens e posições iniciais para a impressão são estabelecidas no
153
     * pelo conteúdo da funçao e podem ser modificados.
154
     *
155
     * @param  string $logo
156
     * @return string O ID do evento extraido do arquivo XML
157
     */
158
    protected function monta(
159
        $logo = ''
160
    ) {
161
        if (!empty($logo)) {
162
            $this->logomarca = $this->adjustImage($logo);
163
        }
164
        if (empty($this->orientacao)) {
165
            $this->orientacao = 'P';
166
        }
167
        $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
0 ignored issues
show
Bug introduced by
It seems like $this->papel can also be of type array; however, NFePHP\DA\Legacy\Pdf::__construct() does only seem to accept string, maybe add an additional type check?

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

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

    return array();
}

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

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

Loading history...
168
        if ($this->orientacao == 'P') {
169
            // margens do PDF
170
            $margSup = 2;
171
            $margEsq = 2;
172
            $margDir = 2;
173
            // posição inicial do relatorio
174
            $xInic = 1;
175
            $yInic = 1;
176
            if ($this->papel == 'A4') { // A4 210x297mm
177
                $maxW = 210;
178
                $maxH = 297;
179
            }
180
        } else {
181
            // margens do PDF
182
            $margSup = 3;
183
            $margEsq = 3;
184
            $margDir = 3;
185
            // posição inicial do relatorio
186
            $xInic = 5;
187
            $yInic = 5;
188
            if ($papel == 'A4') { // A4 210x297mm
0 ignored issues
show
Bug introduced by
The variable $papel does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
189
                $maxH = 210;
190
                $maxW = 297;
191
            }
192
        }
193
        // largura imprimivel em mm
194
        $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...
Documentation Bug introduced by
The property $wPrint was declared of type double, but $maxW - ($margEsq + $xInic) is of type integer. Maybe add a type cast?

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

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

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
195
        // comprimento imprimivel em mm
196
        $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...
Documentation Bug introduced by
The property $hPrint was declared of type double, but $maxH - ($margSup + $yInic) is of type integer. Maybe add a type cast?

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

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

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
197
        // estabelece contagem de paginas
198
        $this->pdf->aliasNbPages();
199
        // fixa as margens
200
        $this->pdf->setMargins($margEsq, $margSup, $margDir);
201
        $this->pdf->setDrawColor(0, 0, 0);
202
        $this->pdf->setFillColor(255, 255, 255);
203
        // inicia o documento
204
        $this->pdf->open();
205
        // adiciona a primeira página
206
        $this->pdf->addPage($this->orientacao, $this->papel);
0 ignored issues
show
Bug introduced by
It seems like $this->papel can also be of type array; however, NFePHP\DA\Legacy\FPDF\Fpdf::addPage() does only seem to accept string, maybe add an additional type check?

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

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

    return array();
}

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

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

Loading history...
207
        $this->pdf->setLineWidth(0.1);
208
        $this->pdf->setTextColor(0, 0, 0);
209
        // montagem da página
210
        $pag = 1;
211
        $x = $xInic;
212
        $y = $yInic;
213
        // coloca o cabeçalho
214
        $y = $this->header($x, $y, $pag);
215
        // coloca os dados da CCe
216
        $y = $this->body($x, $y + 15);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->body($x, $y + 15) (which targets NFePHP\DA\NFe\Daevento::body()) 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...
217
        // coloca os dados da CCe
218
        $y = $this->footer($x, $y + $this->hPrint - 20);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->footer($x, $y + $this->hPrint - 20) (which targets NFePHP\DA\NFe\Daevento::footer()) 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...
219
    }
220
221
    /**
222
     * header
223
     * @param  number $x
224
     * @param  number $y
225
     * @param  number $pag
226
     * @return number
227
     */
228
    private function header($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...
229
    {
230
        $oldX = $x;
231
        $oldY = $y;
232
        $maxW = $this->wPrint;
233
        // ######################################################################
234
        // coluna esquerda identificação do emitente
235
        $w = round($maxW * 0.41, 0); // 80;
236
        if ($this->orientacao == 'P') {
237
            $aFont = ['font' => $this->fontePadrao,'size' => 6,'style' => 'I'];
238
        } else {
239
            $aFont = ['font' => $this->fontePadrao,'size' => 8,'style' => 'B'];
240
        }
241
        $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...
242
        $h = 32;
243
        $oldY += $h;
244
        $this->pdf->textBox($x, $y, $w, $h);
245
        $texto = 'IDENTIFICAÇÃO DO EMITENTE';
246
        $this->pdf->textBox($x, $y, $w, 5, $texto, $aFont, 'T', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
247
        if (!empty($this->logomarca)) {
248
            $logoInfo = getimagesize($this->logomarca);
249
            // largura da imagem em mm
250
            $logoWmm = ($logoInfo[0] / 72) * 25.4;
251
            // altura da imagem em mm
252
            $logoHmm = ($logoInfo[1] / 72) * 25.4;
253
            if ($this->logoAlign == 'L') {
254
                $nImgW = round($w / 3, 0);
255
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
256
                $xImg = $x + 1;
257
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
258
                // estabelecer posições do texto
259
                $x1 = round($xImg + $nImgW + 1, 0);
260
                $y1 = round($h / 3 + $y, 0);
261
                $tw = round(2 * $w / 3, 0);
262
            }
263
            if ($this->logoAlign == 'C') {
264
                $nImgH = round($h / 3, 0);
265
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
266
                $xImg = round(($w - $nImgW) / 2 + $x, 0);
267
                $yImg = $y + 3;
268
                $x1 = $x;
269
                $y1 = round($yImg + $nImgH + 1, 0);
270
                $tw = $w;
271
            }
272
            if ($this->logoAlign == 'R') {
273
                $nImgW = round($w / 3, 0);
274
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
275
                $xImg = round($x + ($w - (1 + $nImgW)), 0);
276
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
277
                $x1 = $x;
278
                $y1 = round($h / 3 + $y, 0);
279
                $tw = round(2 * $w / 3, 0);
280
            }
281
            $type = (substr($this->logomarca, 0, 7) === 'data://') ? 'jpg' : null;
0 ignored issues
show
Unused Code introduced by
$type is not used, you could remove the assignment.

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

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

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

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

Loading history...
282
            $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...
283
        } else {
284
            $x1 = $x;
285
            $y1 = round($h / 3 + $y, 0);
286
            $tw = $w;
287
        }
288
        // Nome emitente
289
        $aFont = array(
290
            'font' => $this->fontePadrao,
291
            'size' => 12,
292
            'style' => 'B'
293
        );
294
        $texto = (isset($this->dadosEmitente['razao']) ? $this->dadosEmitente['razao'] : '');
295
        $this->pdf->textBox($x1, $y1, $tw, 8, $texto, $aFont, 'T', 'C', 0, '');
0 ignored issues
show
Bug introduced by
The variable $x1 does not seem to be defined for all execution paths leading up to this point.

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

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

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

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

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

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

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
296
        // endereço
297
        $y1 = $y1 + 6;
298
        $aFont = array(
299
            'font' => $this->fontePadrao,
300
            'size' => 8,
301
            'style' => ''
302
        );
303
        $lgr = (isset($this->dadosEmitente['logradouro']) ? $this->dadosEmitente['logradouro'] : '');
304
        $nro = (isset($this->dadosEmitente['numero']) ? $this->dadosEmitente['numero'] : '');
305
        $cpl = (isset($this->dadosEmitente['complemento']) ? $this->dadosEmitente['complemento'] : '');
306
        $bairro = (isset($this->dadosEmitente['bairro']) ? $this->dadosEmitente['bairro'] : '');
307
        $CEP = (isset($this->dadosEmitente['CEP']) ? $this->dadosEmitente['CEP'] : '');
308
        $CEP = $this->formatField($CEP, "#####-###");
309
        $mun = (isset($this->dadosEmitente['municipio']) ? $this->dadosEmitente['municipio'] : '');
310
        $UF = (isset($this->dadosEmitente['UF']) ? $this->dadosEmitente['UF'] : '');
311
        $fone = (isset($this->dadosEmitente['telefone']) ? $this->dadosEmitente['telefone'] : '');
312
        $email = (isset($this->dadosEmitente['email']) ? $this->dadosEmitente['email'] : '');
313
        $foneLen = strlen($fone);
314
        if ($foneLen > 0) {
315
            $fone2 = substr($fone, 0, $foneLen - 4);
316
            $fone1 = substr($fone, 0, $foneLen - 8);
317
            $fone = '(' . $fone1 . ') ' . substr($fone2, - 4) . '-' . substr($fone, - 4);
318
        } else {
319
            $fone = '';
320
        }
321
        if ($email != '') {
322
            $email = 'Email: ' . $email;
323
        }
324
        $texto = "";
325
        $tmp_txt = trim(($lgr != '' ? "$lgr, " : '') . ($nro != 0 ? $nro : "SN") . ($cpl != '' ? " - $cpl" : ''));
326
        $tmp_txt = ($tmp_txt == 'SN' ? '' : $tmp_txt);
327
        $texto .= ($texto != '' && $tmp_txt != '' ? "\n" : '') . $tmp_txt;
328
        $tmp_txt = trim($bairro . ($bairro != '' && $CEP != '' ? " - " : '') . $CEP);
329
        $texto .= ($texto != '' && $tmp_txt != '' ? "\n" : '') . $tmp_txt;
330
        $tmp_txt = $mun;
331
        $tmp_txt .= ($tmp_txt != '' && $UF != '' ? " - " : '') . $UF;
332
        $tmp_txt .= ($tmp_txt != '' && $fone != '' ? " " : '') . $fone;
333
        $texto .= ($texto != '' && $tmp_txt != '' ? "\n" : '') . $tmp_txt;
334
        $tmp_txt = $email;
335
        $texto .= ($texto != '' && $tmp_txt != '' ? "\n" : '') . $tmp_txt;
336
        $this->pdf->textBox($x1, $y1 - 2, $tw, 8, $texto, $aFont, 'T', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
337
        // ##################################################
338
        $w2 = round($maxW - $w, 0);
339
        $x += $w;
340
        $this->pdf->textBox($x, $y, $w2, $h);
341
        $y1 = $y + $h;
342
        $aFont = array(
343
            'font' => $this->fontePadrao,
344
            'size' => 16,
345
            'style' => 'B'
346
        );
347
        if ($this->tpEvento == '110110') {
348
            $texto = 'Representação Gráfica de CC-e';
349
        } else {
350
            $texto = 'Representação Gráfica de Evento';
351
        }
352
        $this->pdf->textBox($x, $y + 2, $w2, 8, $texto, $aFont, 'T', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
353
        $aFont = array(
354
            'font' => $this->fontePadrao,
355
            'size' => 12,
356
            'style' => 'I'
357
        );
358
        if ($this->tpEvento == '110110') {
359
            $texto = '(Carta de Correção Eletrônica)';
360
        } elseif ($this->tpEvento == '110111') {
361
            $texto = '(Cancelamento de NFe)';
362
        }
363
        $this->pdf->textBox($x, $y + 7, $w2, 8, $texto, $aFont, 'T', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
364
        $texto = 'ID do Evento: ' . $this->id;
365
        $aFont = array(
366
            'font' => $this->fontePadrao,
367
            'size' => 10,
368
            'style' => ''
369
        );
370
        $this->pdf->textBox($x, $y + 15, $w2, 8, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
371
        $tsHora = $this->toTimestamp($this->dhEvento);
372
        $texto = 'Criado em : ' . date('d/m/Y   H:i:s', $tsHora);
373
        $this->pdf->textBox($x, $y + 20, $w2, 8, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
374
        $tsHora = $this->toTimestamp($this->dhRegEvento);
375
        $texto = 'Prococolo: ' . $this->nProt . '  -  Registrado na SEFAZ em: ' . date('d/m/Y   H:i:s', $tsHora);
376
        $this->pdf->textBox($x, $y + 25, $w2, 8, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
377
        // ####################################################
378
        $x = $oldX;
379
        $this->pdf->textBox($x, $y1, $maxW, 40);
380
        $sY = $y1 + 40;
381
        if ($this->tpEvento == '110110') {
382
            $texto = 'De acordo com as determinações legais vigentes, vimos por meio desta '
383
                . 'comunicar-lhe que a Nota Fiscal, abaixo referenciada, contém irregularidades'
384
                . ' que estão destacadas e suas respectivas correções, solicitamos que sejam aplicadas '
385
                . 'essas correções ao executar seus lançamentos fiscais.';
386
        } elseif ($this->tpEvento == '110111') {
387
            $texto = 'De acordo com as determinações legais vigentes, '
388
                . 'vimos por meio desta comunicar-lhe que a Nota Fiscal, '
389
                . 'abaixo referenciada, está cancelada, solicitamos que sejam '
390
                . 'aplicadas essas correções ao executar seus lançamentos fiscais.';
391
        }
392
        $aFont = ['font' => $this->fontePadrao,'size' => 10,'style' => ''];
393
        $this->pdf->textBox($x + 5, $y1, $maxW - 5, 20, $texto, $aFont, 'T', 'L', 0, '', false);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
394
        // ############################################
395
        $x = $oldX;
396
        $y = $y1;
397
        if ($this->CNPJDest != '') {
398
            $texto = 'CNPJ do Destinatário: ' . $this->formatField($this->CNPJDest, "##.###.###/####-##");
399
        }
400
        if ($this->CPFDest != '') {
401
            $texto = 'CPF do Destinatário: ' . $this->formatField($this->CPFDest, "###.###.###-##");
402
        }
403
        $aFont = ['font' => $this->fontePadrao,'size' => 12,'style' => 'B'];
404
        $this->pdf->textBox($x + 2, $y + 13, $w2, 8, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
405
        $numNF = substr($this->chNFe, 25, 9);
406
        $serie = substr($this->chNFe, 22, 3);
407
        $numNF = $this->formatField($numNF, "###.###.###");
408
        $texto = "Nota Fiscal: " . $numNF . '  -   Série: ' . $serie;
409
        $this->pdf->textBox($x + 2, $y + 19, $w2, 8, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
410
        $bW = 87;
411
        $bH = 15;
412
        $x = 55;
413
        $y = $y1 + 13;
414
        $w = $maxW;
415
        $this->pdf->setFillColor(0, 0, 0);
416
        $this->pdf->code128($x + (($w - $bW) / 2), $y + 2, $this->chNFe, $bW, $bH);
417
        $this->pdf->setFillColor(255, 255, 255);
418
        $y1 = $y + 2 + $bH;
419
        $aFont = ['font' => $this->fontePadrao,'size' => 10,'style' => ''];
420
        $texto = $this->formatField($this->chNFe, $this->formatoChave);
421
        $this->pdf->textBox($x, $y1, $w - 2, $h, $texto, $aFont, 'T', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
422
        $retVal = $sY + 2;
423
        if ($this->tpEvento == '110110') {
424
            $x = $oldX;
425
            $this->pdf->textBox($x, $sY, $maxW, 15);
426
            $texto = $this->xCondUso;
427
            $aFont = ['font' => $this->fontePadrao,'size' => 8,'style' => 'I'];
428
            $this->pdf->textBox($x + 2, $sY + 2, $maxW - 2, 15, $texto, $aFont, 'T', 'L', 0, '', false);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
429
            $retVal = $sY + 2;
430
        }
431
        // indicar sem valor
432
        if ($this->tpAmb != 1) {
433
            $x = 10;
434
            if ($this->orientacao == 'P') {
435
                $y = round($this->hPrint * 2 / 3, 0);
436
            } else {
437
                $y = round($this->hPrint / 2, 0);
438
            }
439
            $h = 5;
440
            $w = $maxW - (2 * $x);
441
            $this->pdf->setTextColor(90, 90, 90);
442
            $texto = "SEM VALOR FISCAL";
443
            $aFont = ['font' => $this->fontePadrao,'size' => 48,'style' => 'B'];
444
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
445
            $aFont = ['font' => $this->fontePadrao,'size' => 30,'style' => 'B'];
446
            $texto = "AMBIENTE DE HOMOLOGAÇÃO";
447
            $this->pdf->textBox($x, $y + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
448
            $this->pdf->setTextColor(0, 0, 0);
449
        }
450
        return $retVal;
451
    }
452
453
    /**
454
     * body
455
     *
456
     * @param number $x
457
     * @param number $y
458
     */
459
    private function body($x, $y)
460
    {
461
        $maxW = $this->wPrint;
462
        if ($this->tpEvento == '110110') {
463
            $texto = 'CORREÇÕES A SEREM CONSIDERADAS';
464
        } else {
465
            $texto = 'JUSTIFICATIVA DO CANCELAMENTO';
466
        }
467
        $aFont = ['font' => $this->fontePadrao,'size' => 10,'style' => 'B'];
468
        $this->pdf->textBox($x, $y, $maxW, 5, $texto, $aFont, 'T', 'L', 0, '', false);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
469
        $y += 5;
470
        $this->pdf->textBox($x, $y, $maxW, 190);
471
        if ($this->tpEvento == '110110') {
472
            $texto = $this->xCorrecao;
473
        } elseif ($this->tpEvento == '110111') {
474
            $texto = $this->xJust;
475
        }
476
        $aFont = ['font' => $this->fontePadrao,'size' => 12,'style' => 'B'];
477
        $this->pdf->textBox($x + 2, $y + 2, $maxW - 2, 150, $texto, $aFont, 'T', 'L', 0, '', false);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
478
    }
479
480
    /**
481
     * footer
482
     *
483
     * @param number $x
484
     * @param number $y
485
     */
486
    private function footer($x, $y)
487
    {
488
        $w = $this->wPrint;
489
        if ($this->tpEvento == '110110') {
490
            $texto = "Este documento é uma representação gráfica da CC-e "
491
                . "e foi impresso apenas para sua informação e não possui validade "
492
                . "fiscal.\n A CC-e deve ser recebida e mantida em arquivo eletrônico XML "
493
                . "e pode ser consultada através dos Portais das SEFAZ.";
494
        } elseif ($this->tpEvento == '110111') {
495
            $texto = "Este documento é uma representação gráfica do evento de NFe e "
496
                . "foi impresso apenas para sua informação e não possui validade "
497
                . "fiscal.\n O Evento deve ser recebido e mantido em arquivo "
498
                . "eletrônico XML e pode ser consultada através dos Portais "
499
                . "das SEFAZ.";
500
        }
501
        $aFont = ['font' => $this->fontePadrao,'size' => 10,'style' => 'I'];
502
        $this->pdf->textBox($x, $y, $w, 20, $texto, $aFont, 'T', 'C', 0, '', false);
0 ignored issues
show
Bug introduced by
The variable $texto does not seem to be defined for all execution paths leading up to this point.

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

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

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
503
        $y = $this->hPrint - 4;
504
        $texto = "Impresso em  " . date('d/m/Y   H:i:s') . ' ' . $this->creditos;
505
        $w = $this->wPrint - 4;
506
        $aFont = ['font' => $this->fontePadrao,'size' => 6,'style' => 'I'];
507
        $this->pdf->textBox($x, $y, $w, 4, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
508
        $texto = $this->powered ? "Powered by NFePHP®" : '';
509
        $aFont = ['font' => $this->fontePadrao,'size' => 6,'style' => 'I'];
510
        $this->pdf->textBox($x, $y, $w, 4, $texto, $aFont, 'T', 'R', 0, 'http://www.nfephp.org');
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
511
    }
512
}
513