Passed
Push — master ( b6c7f7...cb9572 )
by Roberto
09:19 queued 06:19
created

Danfce   F

Complexity

Total Complexity 107

Size/Duplication

Total Lines 1027
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 1027
ccs 0
cts 874
cp 0
rs 1.492
c 0
b 0
f 0
wmc 107
lcom 2
cbo 5

19 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 42 6
A creditsIntegratorFooter() 0 4 1
A render() 0 8 2
A setPaperWidth() 0 4 1
A printParameters() 0 4 1
D monta() 0 127 11
B cabecalhoDANFE() 0 62 5
A cabecalhoSecundarioDANFE() 0 15 1
B produtosDANFE() 0 166 3
B totalDANFE() 0 56 1
B pagamentosDANFE() 0 84 5
A fiscalDANFE() 0 53 4
C consumidorDANFE() 0 70 10
A qrCodeDANFE() 0 39 2
A infAdic() 0 22 3
F anfaveaDANFE() 0 137 36
B getCardName() 0 23 6
A checkCancelada() 0 11 5
A checkDenegada() 0 12 4

How to fix   Complexity   

Complex Class

Complex classes like Danfce often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Danfce, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace NFePHP\DA\NFe;
4
5
/**
6
 * Classe para a impressão em PDF do Documento Auxiliar de NFe Consumidor
7
 * NOTA: Esta classe não é a indicada para quem faz uso de impressoras térmicas ESCPOS
8
 *
9
 * @category  Library
10
 * @package   nfephp-org/sped-da
11
 * @copyright 2009-2019 NFePHP
12
 * @license   http://www.gnu.org/licenses/lesser.html LGPL v3
13
 * @link      http://github.com/nfephp-org/sped-da for the canonical source repository
14
 * @author    Roberto Spadim <roberto at spadim dot com dot br>
15
 */
16
use Exception;
17
use InvalidArgumentException;
18
use NFePHP\DA\Legacy\Dom;
19
use NFePHP\DA\Legacy\Pdf;
20
use NFePHP\DA\Common\DaCommon;
21
use Com\Tecnick\Barcode\Barcode;
22
use DateTime;
23
24
class Danfce extends DaCommon
25
{
26
    protected $papel;
27
    protected $paperwidth = 80;
28
    protected $xml; // string XML NFe
29
    protected $logomarca=''; // path para logomarca em jpg
30
    protected $formatoChave="#### #### #### #### #### #### #### #### #### #### ####";
31
    protected $nfeProc;
32
    protected $nfe;
33
    protected $infNFe;
34
    protected $ide;
35
    protected $enderDest;
36
    protected $ICMSTot;
37
    protected $imposto;
38
    protected $emit;
39
    protected $enderEmit;
40
    protected $qrCode;
41
    protected $urlChave;
42
    protected $det;
43
    protected $infAdic;
44
    protected $textoAdic;
45
    protected $tpEmis;
46
    protected $pag;
47
    protected $vTroco;
48
    protected $dest;
49
    protected $imgQRCode;
50
    protected $urlQR = '';
51
    protected $pdf;
52
    protected $margemInterna = 2;
53
    protected $hMaxLinha = 9;
54
    protected $hBoxLinha = 6;
55
    protected $hLinha = 3;
56
  
57
    /**
58
     * __contruct
59
     *
60
     * @param string $docXML
61
     */
62
    public function __construct(
63
        $docXML
64
    ) {
65
        
66
        $this->xml = $docXML;
67
      
68
        if (!empty($this->xml)) {
69
            $this->dom = new Dom();
0 ignored issues
show
Bug introduced by
The property dom 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...
70
            $this->dom->loadXML($this->xml);
71
            $this->nfeProc = $this->dom->getElementsByTagName("nfeProc")->item(0);
72
            $this->nfe = $this->dom->getElementsByTagName("NFe")->item(0);
73
            $this->infNFe = $this->dom->getElementsByTagName("infNFe")->item(0);
74
            $this->ide = $this->dom->getElementsByTagName("ide")->item(0);
75
            $this->emit = $this->dom->getElementsByTagName("emit")->item(0);
76
            $this->enderEmit = $this->dom->getElementsByTagName("enderEmit")->item(0);
77
            $this->det = $this->dom->getElementsByTagName("det");
78
            $this->dest = $this->dom->getElementsByTagName("dest")->item(0);
79
            $this->imposto = $this->dom->getElementsByTagName("imposto")->item(0);
80
            $this->ICMSTot = $this->dom->getElementsByTagName("ICMSTot")->item(0);
81
            $this->tpImp = $this->ide->getElementsByTagName("tpImp")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property tpImp 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...
82
            $this->infAdic = $this->dom->getElementsByTagName("infAdic")->item(0);
83
            $this->tpEmis = $this->dom->getValue($this->ide, "tpEmis");
0 ignored issues
show
Documentation introduced by
$this->ide is of type object<DOMNode>, but the function expects a object<NFePHP\DA\Legacy\DOMElement>.

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...
84
            
85
            //se for o layout 4.0 busca pelas tags de detalhe do pagamento
86
            //senao, busca pelas tags de pagamento principal
87
            if ($this->infNFe->getAttribute("versao") == "4.00") {
88
                $this->pag = $this->dom->getElementsByTagName("detPag");
89
                
90
                $tagPag = $this->dom->getElementsByTagName("pag")->item(0);
91
                $this->vTroco = $this->getTagValue($tagPag, "vTroco");
92
            } else {
93
                $this->pag = $this->dom->getElementsByTagName("pag");
94
            }
95
        }
96
        $this->qrCode = !empty($this->dom->getElementsByTagName('qrCode')->item(0)->nodeValue)
97
            ? $this->dom->getElementsByTagName('qrCode')->item(0)->nodeValue : null;
98
        $this->urlChave = !empty($this->dom->getElementsByTagName('urlChave')->item(0)->nodeValue)
99
            ? $this->dom->getElementsByTagName('urlChave')->item(0)->nodeValue : null;
100
        if ($this->getTagValue($this->ide, "mod") != '65') {
101
            throw new InvalidArgumentException("O xml do DANFE deve ser uma NFC-e modelo 65");
102
        }
103
    }
104
    
105
    /**
106
     * Add the credits to the integrator in the footer message
107
     * @param string $message
108
     */
109
    public function creditsIntegratorFooter($message = '')
110
    {
111
        $this->creditos = trim($message);
112
    }
113
    
114
    /**
115
     * Dados brutos do PDF
116
     * @return string
117
     */
118
    public function render(
119
        $logo = ''
120
    ) {
121
        if (empty($this->pdf)) {
122
            $this->monta($logo);
123
        }
124
        return $this->pdf->getPdf();
125
    }
126
    
127
    /**
128
     * Seta a largura do papel de impressão
129
     * @param int $width
130
     */
131
    public function setPaperWidth($width = 80)
132
    {
133
        $this->paperwidth = $width;
134
    }
135
    
136
    /**
137
     * Parametros de impressão
138
     * @param string $orientacao
139
     * @param string $papel
140
     * @param int $margSup
141
     * @param int $margEsq
142
     */
143
    public function printParameters($orientacao = '', $papel = 'A4', $margSup = 2, $margEsq = 2)
144
    {
145
        //do nothing
146
    }
147
    
148
    /**
149
     *
150
     * @param string $logo
151
     */
152
    protected function monta(
153
        $logo = ''
154
    ) {
155
        
156
        $this->aFontTit = array('font' => $this->fontePadrao, 'size' => 9, 'style' => 'B');
0 ignored issues
show
Bug introduced by
The property aFontTit 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->aFontTex = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
0 ignored issues
show
Bug introduced by
The property aFontTex 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
        if (!empty($logo)) {
159
            $this->logomarca = $this->adjustImage($logo, true);
160
        }
161
        $qtdItens = $this->det->length;
162
        $qtdPgto = $this->pag->length;
163
        $hMaxLinha = $this->hMaxLinha;
164
        $hBoxLinha = $this->hBoxLinha;
0 ignored issues
show
Unused Code introduced by
$hBoxLinha 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...
165
        $hLinha = $this->hLinha;
166
        $tamPapelVert = 160 + 16 + 12 + (($qtdItens - 1) * $hMaxLinha) + ($qtdPgto * $hLinha);
167
        // verifica se existe informações adicionais
168
        $this->textoAdic = '';
169
        if (isset($this->infAdic)) {
170
            $this->textoAdic .= !empty($this->infAdic->getElementsByTagName('infCpl')->item(0)->nodeValue) ?
171
            'Inf. Contribuinte: '.
172
            trim($this->anfaveaDANFE($this->infAdic->getElementsByTagName('infCpl')->item(0)->nodeValue)) : '';
173
            if (!empty($this->textoAdic)) {
174
                $this->textoAdic = str_replace(";", "\n", $this->textoAdic);
175
                $alinhas = explode("\n", $this->textoAdic);
176
                $numlinhasdados = 0;
177
                $tempPDF = new Pdf(); // cria uma instancia temporaria da class pdf
178
                $tempPDF->setFont('times', '', '8'); // seta a font do PDF
179
                foreach ($alinhas as $linha) {
180
                    $linha = trim($linha);
181
                    $numlinhasdados += $tempPDF->wordWrap($linha, 76 - 0.2);
0 ignored issues
show
Documentation introduced by
$linha is of type string, but the function expects a object<NFePHP\DA\Legacy\type>.

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...
Documentation introduced by
76 - 0.2 is of type double, but the function expects a object<NFePHP\DA\Legacy\type>.

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...
182
                }
183
                $hdadosadic = round(($numlinhasdados + 1) * $tempPDF->fontSize, 0);
184
                if ($hdadosadic < 5) {
185
                    $hdadosadic = 5;
186
                }
187
                // seta o tamanho do papel
188
                $tamPapelVert += $hdadosadic;
189
            }
190
        }
191
        $this->orientacao = 'P';
192
        $this->papel = [$this->paperwidth, $tamPapelVert];
193
        $this->logoAlign = 'L';
194
        $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
0 ignored issues
show
Documentation introduced by
$this->papel is of type array<integer,integer|do...,"1":"double|integer"}>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
195
        
196
        //margens do PDF, em milímetros. Obs.: a margem direita é sempre igual à
197
        //margem esquerda. A margem inferior *não* existe na FPDF, é definida aqui
198
        //apenas para controle se necessário ser maior do que a margem superior
199
        $margSup = 2;
200
        $margEsq = 2;
201
        $margInf = 2;
202
        // posição inicial do conteúdo, a partir do canto superior esquerdo da página
203
        $xInic = $margEsq;
204
        $yInic = $margSup;
205
        $maxW = 80;
206
        $maxH = $tamPapelVert;
207
        //total inicial de paginas
208
        $totPag = 1;
0 ignored issues
show
Unused Code introduced by
$totPag is not used, you could remove the assignment.

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

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

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

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

Loading history...
209
        //largura imprimivel em mm: largura da folha menos as margens esq/direita
210
        $this->wPrint = $maxW-($margEsq*2);
0 ignored issues
show
Documentation Bug introduced by
The property $wPrint was declared of type double, but $maxW - $margEsq * 2 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...
211
        //comprimento (altura) imprimivel em mm: altura da folha menos as margens
212
        //superior e inferior
213
        $this->hPrint = $maxH-$margSup-$margInf;
0 ignored issues
show
Documentation Bug introduced by
It seems like $maxH - $margSup - $margInf can also be of type integer. However, the property $hPrint is declared as type double. 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...
214
        // estabelece contagem de paginas
215
        $this->pdf->aliasNbPages();
216
        $this->pdf->setMargins($margEsq, $margSup); // fixa as margens
217
        $this->pdf->setDrawColor(0, 0, 0);
218
        $this->pdf->setFillColor(255, 255, 255);
219
        $this->pdf->open(); // inicia o documento
220
        $this->pdf->addPage($this->orientacao, $this->papel); // adiciona a primeira página
0 ignored issues
show
Documentation introduced by
$this->papel is of type array<integer,integer|do...,"1":"double|integer"}>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
221
        $this->pdf->setLineWidth(0.1); // define a largura da linha
222
        $this->pdf->setTextColor(0, 0, 0);
223
        $this->pdf->textBox(0, 0, $maxW, $maxH); // POR QUE PRECISO DESA LINHA?
224
        $hcabecalho = 27;//para cabeçalho (dados emitente mais logomarca)  (FIXO)
225
        $hcabecalhoSecundario = 10 + 3;//para cabeçalho secundário (cabeçalho sefaz) (FIXO)
226
        $hprodutos = $hLinha + ($qtdItens * $hMaxLinha) ;//box poduto
227
        $hTotal = 12; //box total (FIXO)
228
        $hpagamentos = $hLinha + ($qtdPgto * $hLinha) + 3;//para pagamentos
229
        if (!empty($this->vTroco)) {
230
            $hpagamentos += $hLinha;
231
        }
232
                
233
        $hmsgfiscal = 21 + 2; // para imposto (FIXO)
234
        $hcliente = !isset($this->dest) ? 6 : 12; // para cliente (FIXO)
235
        $hcontingencia = $this->tpEmis == 9 ? 6 : 0; // para contingência (FIXO)
0 ignored issues
show
Unused Code introduced by
$hcontingencia 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...
236
        $hQRCode = 50; // para qrcode (FIXO)
237
        $hCabecItens = 4; //cabeçalho dos itens
238
        
239
        $hUsado = $hCabecItens;
0 ignored issues
show
Unused Code introduced by
$hUsado 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...
240
        $w2 = round($this->wPrint * 0.31, 0);
0 ignored issues
show
Unused Code introduced by
$w2 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...
241
        $totPag = 1;
242
        $pag = 1;
243
        $x = $xInic;
244
        //COLOCA CABEÇALHO
245
        $y = $yInic;
246
        $y = $this->cabecalhoDANFE($x, $y, $hcabecalho, $pag, $totPag);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->cabecalhoDANFE($x...becalho, $pag, $totPag) (which targets NFePHP\DA\NFe\Danfce::cabecalhoDANFE()) 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...
247
        //COLOCA CABEÇALHO SECUNDÁRIO
248
        $y = $hcabecalho;
249
        $y = $this->cabecalhoSecundarioDANFE($x, $y, $hcabecalhoSecundario);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->cabecalhoSecundar... $hcabecalhoSecundario) (which targets NFePHP\DA\NFe\Danfce::cabecalhoSecundarioDANFE()) 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...
250
        $jj = $hcabecalho + $hcabecalhoSecundario;
0 ignored issues
show
Unused Code introduced by
$jj 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...
251
        //COLOCA PRODUTOS
252
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario;
253
        $y = $this->produtosDANFE($x, $y, $hprodutos);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->produtosDANFE($x, $y, $hprodutos) (which targets NFePHP\DA\NFe\Danfce::produtosDANFE()) 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...
254
        //COLOCA TOTAL
255
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos;
256
        $y = $this->totalDANFE($x, $y, $hTotal);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->totalDANFE($x, $y, $hTotal) (which targets NFePHP\DA\NFe\Danfce::totalDANFE()) 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...
257
        //COLOCA PAGAMENTOS
258
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos + $hTotal;
259
        $y = $this->pagamentosDANFE($x, $y, $hpagamentos);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->pagamentosDANFE($x, $y, $hpagamentos) (which targets NFePHP\DA\NFe\Danfce::pagamentosDANFE()) 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...
260
        //COLOCA MENSAGEM FISCAL
261
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos + $hTotal+ $hpagamentos;
262
        $y = $this->fiscalDANFE($x, $y, $hmsgfiscal);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->fiscalDANFE($x, $y, $hmsgfiscal) (which targets NFePHP\DA\NFe\Danfce::fiscalDANFE()) 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...
263
        //COLOCA CONSUMIDOR
264
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos + $hTotal + $hpagamentos + $hmsgfiscal;
265
        $y = $this->consumidorDANFE($x, $y, $hcliente);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->consumidorDANFE($x, $y, $hcliente) (which targets NFePHP\DA\NFe\Danfce::consumidorDANFE()) 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...
266
        //COLOCA QRCODE
267
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos
268
            + $hTotal + $hpagamentos + $hmsgfiscal + $hcliente;
269
        $y = $this->qrCodeDANFE($x, $y, $hQRCode);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->qrCodeDANFE($x, $y, $hQRCode) (which targets NFePHP\DA\NFe\Danfce::qrCodeDANFE()) 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...
270
        
271
        //adiciona as informações opcionais
272
        if (!empty($this->textoAdic)) {
273
            $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos
274
            + $hTotal + $hpagamentos + $hmsgfiscal + $hcliente + $hQRCode;
275
            $hInfAdic = 0;
276
            $y = $this->infAdic($x, $y, $hInfAdic);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->infAdic($x, $y, $hInfAdic) (which targets NFePHP\DA\NFe\Danfce::infAdic()) 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...
277
        }
278
    }
279
    
280
    protected function cabecalhoDANFE($x = 0, $y = 0, $h = 0, $pag = '1', $totPag = '1')
0 ignored issues
show
Unused Code introduced by
The parameter $x is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $pag is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $totPag 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...
281
    {
282
        $emitRazao  = $this->getTagValue($this->emit, "xNome");
283
        $emitCnpj   = $this->getTagValue($this->emit, "CNPJ");
284
        $emitCnpj   = $this->formatField($emitCnpj, "##.###.###/####-##");
285
        $emitIE     = $this->getTagValue($this->emit, "IE");
286
        $emitIM     = $this->getTagValue($this->emit, "IM");
287
        $emitFone = $this->getTagValue($this->enderEmit, "fone");
288
        $foneLen = strlen($emitFone);
289
        if ($foneLen>0) {
290
            $ddd = substr($emitFone, 0, 2);
291
            $fone1 = substr($emitFone, -8);
292
            $digito9 = ' ';
293
            if ($foneLen == 11) {
294
                $digito9 = substr($emitFone, 2, 1);
295
            }
296
            $emitFone = ' - ('.$ddd.') '.$digito9. ' ' . substr($fone1, 0, 4) . '-' . substr($fone1, -4);
297
        } else {
298
            $emitFone = '';
299
        }
300
        $emitLgr = $this->getTagValue($this->enderEmit, "xLgr");
301
        $emitNro = $this->getTagValue($this->enderEmit, "nro");
302
        $emitCpl = $this->getTagValue($this->enderEmit, "xCpl", "");
303
        $emitBairro = $this->getTagValue($this->enderEmit, "xBairro");
304
        $emitCEP = $this->formatField($this->getTagValue($this->enderEmit, "CEP"), "#####-###");
305
        $emitMun = $this->getTagValue($this->enderEmit, "xMun");
306
        $emitUF = $this->getTagValue($this->enderEmit, "UF");
307
        // CONFIGURAÇÃO DE POSIÇÃO
308
        $margemInterna = $this->margemInterna;
309
        $maxW = $this->wPrint;
310
        $h = $h-($margemInterna);
311
        //COLOCA LOGOMARCA
312
        if (!empty($this->logomarca)) {
313
            $xImg = $margemInterna;
314
            $yImg = $margemInterna + 1;
0 ignored issues
show
Unused Code introduced by
$yImg 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...
315
            $logoInfo = getimagesize($this->logomarca);
316
            $logoWmm = ($logoInfo[0]/72)*25.4;
317
            $logoHmm = ($logoInfo[1]/72)*25.4;
318
            $nImgW = 30;
319
            $nImgH = round($logoHmm * ($nImgW/$logoWmm), 0);
320
            $yImg = $margemInterna + $nImgH/2;
321
            $this->pdf->image($this->logomarca, $xImg, $yImg, $nImgW, $nImgH, 'jpeg');
322
            $xRs = ($maxW*0.4) + $margemInterna;
323
            $wRs = ($maxW*0.6);
324
            $alignEmit = 'L';
325
        } else {
326
            $xRs = $margemInterna;
327
            $wRs = ($maxW*1);
328
            $alignEmit = 'L';
329
        }
330
        //COLOCA RAZÃO SOCIAL
331
        $texto = $emitRazao;
332
        $texto = $texto . "\nCNPJ:" . $emitCnpj;
333
        $texto = $texto . "\nIE:" . $emitIE;
334
        if (!empty($emitIM)) {
335
            $texto = $texto . " - IM:" . $emitIM;
336
        }
337
        $texto = $texto . "\n" . $emitLgr . "," . $emitNro . " " . $emitCpl . "," . $emitBairro
338
                . ". CEP:" . $emitCEP . ". " . $emitMun . "-" . $emitUF . $emitFone;
339
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
340
        $this->pdf->textBox($xRs, $y, $wRs, $h, $texto, $aFont, 'C', $alignEmit, 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...
341
    }
342
    
343
    protected function cabecalhoSecundarioDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
344
    {
345
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna 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...
346
        $maxW = $this->wPrint;
347
        $w = ($maxW*1);
348
        $hBox1 = 7;
349
        $texto = "DANFE NFC-e\nDocumento Auxiliar da Nota Fiscal de Consumidor Eletrônica";
350
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B');
351
        $this->pdf->textBox($x, $y, $w, $hBox1, $texto, $aFont, 'C', 'C', 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...
352
        $hBox2 = 4;
353
        $yBox2 = $y + $hBox1;
354
        $texto = "\nNFC-e não permite aproveitamento de crédito de ICMS";
355
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'');
356
        $this->pdf->textBox($x, $yBox2, $w, $hBox2, $texto, $aFont, 'C', 'C', 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...
357
    }
358
    
359
    protected function produtosDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
360
    {
361
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna 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...
362
        $maxW = $this->wPrint;
363
        $qtdItens = $this->det->length;
364
        $w = ($maxW*1);
365
        $hLinha = $this->hLinha;
366
        $aFontCabProdutos = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
367
        $wBoxCod = $w*0.17;
368
        $texto = "CÓDIGO";
369
        $this->pdf->textBox($x, $y, $wBoxCod, $hLinha, $texto, $aFontCabProdutos, '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...
370
        $wBoxDescricao = $w*0.43;
371
        $xBoxDescricao = $wBoxCod + $x;
372
        $texto = "DESCRICÃO";
373
        $this->pdf->textBox(
374
            $xBoxDescricao,
375
            $y,
376
            $wBoxDescricao,
377
            $hLinha,
378
            $texto,
379
            $aFontCabProdutos,
380
            'T',
381
            'L',
382
            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...
383
            '',
384
            false
385
        );
386
        $wBoxQt = $w*0.08;
387
        $xBoxQt = $wBoxDescricao + $xBoxDescricao;
388
        $texto = "QT";
389
        $this->pdf->textBox($xBoxQt, $y, $wBoxQt, $hLinha, $texto, $aFontCabProdutos, '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...
390
        $wBoxUn = $w*0.06;
391
        $xBoxUn = $wBoxQt + $xBoxQt;
392
        $texto = "UN";
393
        $this->pdf->textBox($xBoxUn, $y, $wBoxUn, $hLinha, $texto, $aFontCabProdutos, '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
        $wBoxVl = $w*0.13;
395
        $xBoxVl = $wBoxUn + $xBoxUn;
396
        $texto = "VALOR";
397
        $this->pdf->textBox($xBoxVl, $y, $wBoxVl, $hLinha, $texto, $aFontCabProdutos, '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...
398
        $wBoxTotal = $w*0.13;
399
        $xBoxTotal = $wBoxVl + $xBoxVl;
400
        $texto = "TOTAL";
401
        $this->pdf->textBox($xBoxTotal, $y, $wBoxTotal, $hLinha, $texto, $aFontCabProdutos, '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...
402
        $hBoxLinha = $this->hBoxLinha;
0 ignored issues
show
Unused Code introduced by
$hBoxLinha 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...
403
        $hMaxLinha = $this->hMaxLinha;
404
        $cont = 0;
405
        $aFontProdutos = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'');
406
        if ($qtdItens > 0) {
407
            foreach ($this->det as $detI) {
408
                $thisItem   = $detI;
409
                $prod       = $thisItem->getElementsByTagName("prod")->item(0);
410
                $nitem      = $thisItem->getAttribute("nItem");
0 ignored issues
show
Unused Code introduced by
$nitem 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...
411
                $cProd      = $this->getTagValue($prod, "cProd");
412
                $xProd      = $this->getTagValue($prod, "xProd");
413
                $qCom       = number_format($this->getTagValue($prod, "qCom"), 2, ",", ".");
414
                $uCom       = $this->getTagValue($prod, "uCom");
415
                $vUnCom     = number_format($this->getTagValue($prod, "vUnCom"), 2, ",", ".");
416
                $vProd      = number_format($this->getTagValue($prod, "vProd"), 2, ",", ".");
417
                //COLOCA PRODUTO
418
                $yBoxProd = $y + $hLinha + ($cont*$hMaxLinha);
419
                //COLOCA PRODUTO CÓDIGO
420
                $wBoxCod = $w*0.17;
421
                $texto = $cProd;
422
                $this->pdf->textBox(
423
                    $x,
424
                    $yBoxProd,
425
                    $wBoxCod,
426
                    $hMaxLinha,
427
                    $texto,
428
                    $aFontProdutos,
429
                    'C',
430
                    'C',
431
                    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...
432
                    '',
433
                    false
434
                );
435
                //COLOCA PRODUTO DESCRIÇÃO
436
                $wBoxDescricao = $w*0.43;
437
                $xBoxDescricao = $wBoxCod + $x;
438
                $texto = $xProd;
439
                $this->pdf->textBox(
440
                    $xBoxDescricao,
441
                    $yBoxProd,
442
                    $wBoxDescricao,
443
                    $hMaxLinha,
444
                    $texto,
445
                    $aFontProdutos,
446
                    'C',
447
                    'L',
448
                    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...
449
                    '',
450
                    false
451
                );
452
                //COLOCA PRODUTO QUANTIDADE
453
                $wBoxQt = $w*0.08;
454
                $xBoxQt = $wBoxDescricao + $xBoxDescricao;
455
                $texto = $qCom;
456
                $this->pdf->textBox(
457
                    $xBoxQt,
458
                    $yBoxProd,
459
                    $wBoxQt,
460
                    $hMaxLinha,
461
                    $texto,
462
                    $aFontProdutos,
463
                    'C',
464
                    'C',
465
                    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...
466
                    '',
467
                    false
468
                );
469
                //COLOCA PRODUTO UNIDADE
470
                $wBoxUn = $w*0.06;
471
                $xBoxUn = $wBoxQt + $xBoxQt;
472
                $texto = $uCom;
473
                $this->pdf->textBox(
474
                    $xBoxUn,
475
                    $yBoxProd,
476
                    $wBoxUn,
477
                    $hMaxLinha,
478
                    $texto,
479
                    $aFontProdutos,
480
                    'C',
481
                    'C',
482
                    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...
483
                    '',
484
                    false
485
                );
486
                //COLOCA PRODUTO VL UNITÁRIO
487
                $wBoxVl = $w*0.13;
488
                $xBoxVl = $wBoxUn + $xBoxUn;
489
                $texto = $vUnCom;
490
                $this->pdf->textBox(
491
                    $xBoxVl,
492
                    $yBoxProd,
493
                    $wBoxVl,
494
                    $hMaxLinha,
495
                    $texto,
496
                    $aFontProdutos,
497
                    'C',
498
                    'R',
499
                    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...
500
                    '',
501
                    false
502
                );
503
                //COLOCA PRODUTO VL TOTAL
504
                $wBoxTotal = $w*0.13;
505
                $xBoxTotal = $wBoxVl + $xBoxVl;
506
                $texto = $vProd;
507
                $this->pdf->textBox(
508
                    $xBoxTotal,
509
                    $yBoxProd,
510
                    $wBoxTotal,
511
                    $hMaxLinha,
512
                    $texto,
513
                    $aFontProdutos,
514
                    'C',
515
                    'R',
516
                    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...
517
                    '',
518
                    false
519
                );
520
                
521
                $cont++;
522
            }
523
        }
524
    }
525
    
526
    protected function totalDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
527
    {
528
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna 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...
529
        $maxW = $this->wPrint;
530
        $hLinha = 3;
531
        $wColEsq = ($maxW*0.7);
532
        $wColDir = ($maxW*0.3);
533
        $xValor = $x + $wColEsq;
534
        $qtdItens = $this->det->length;
535
        $vProd = $this->getTagValue($this->ICMSTot, "vProd");
536
        $vNF = $this->getTagValue($this->ICMSTot, "vNF");
537
        $vDesc  = $this->getTagValue($this->ICMSTot, "vDesc");
538
        $vFrete = $this->getTagValue($this->ICMSTot, "vFrete");
539
        $vTotTrib = $this->getTagValue($this->ICMSTot, "vTotTrib");
540
        $texto = "Qtd. Total de Itens";
541
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
542
        $this->pdf->textBox($x, $y, $wColEsq, $hLinha, $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...
543
        $texto = $qtdItens;
544
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
545
        $this->pdf->textBox($xValor, $y, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 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...
546
        $yTotal = $y + ($hLinha);
547
        $texto = "Total de Produtos";
548
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
549
        $this->pdf->textBox($x, $yTotal, $wColEsq, $hLinha, $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...
550
        $texto = "R$ " . number_format($vProd, 2, ",", ".");
551
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
552
        $this->pdf->textBox($xValor, $yTotal, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 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...
553
        $yDesconto = $y + ($hLinha*2);
554
        $texto = "Descontos";
555
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
556
        $this->pdf->textBox($x, $yDesconto, $wColEsq, $hLinha, $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...
557
        $texto = "R$ " . $vDesc;
558
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
559
        $this->pdf->textBox($xValor, $yDesconto, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 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...
560
        $yFrete= $y + ($hLinha*3);
561
        $texto = "Frete";
562
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
563
        $this->pdf->textBox($x, $yFrete, $wColEsq, $hLinha, $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...
564
        $texto = "R$ " . $vFrete;
565
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
566
        $this->pdf->textBox($xValor, $yFrete, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 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...
567
        $yTotalFinal = $y + ($hLinha*4);
568
        $texto = "Total";
569
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
570
        $this->pdf->textBox($x, $yTotalFinal, $wColEsq, $hLinha, $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...
571
        $texto = "R$ " . $vNF;
572
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
573
        $this->pdf->textBox($xValor, $yTotalFinal, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 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...
574
        $yTotalFinal = $y + ($hLinha*5);
575
        $texto = "Informação dos Tributos Totais Incidentes";
576
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>''];
577
        $this->pdf->textBox($x, $yTotalFinal, $wColEsq, $hLinha, $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...
578
        $texto = "R$ " . $vTotTrib;
579
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
580
        $this->pdf->textBox($xValor, $yTotalFinal, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 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...
581
    }
582
    
583
    protected function pagamentosDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
584
    {
585
        $y += 6;
586
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna 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...
587
        $maxW = $this->wPrint;
588
        $qtdPgto = $this->pag->length;
589
        $w = ($maxW*1);
590
        $hLinha = $this->hLinha;
591
        $wColEsq = ($maxW*0.7);
592
        $wColDir = ($maxW*0.3);
0 ignored issues
show
Unused Code introduced by
$wColDir 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...
593
        $xValor = $x + $wColEsq;
0 ignored issues
show
Unused Code introduced by
$xValor 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...
594
        $aFontPgto = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
595
        $wBoxEsq = $w*0.7;
596
        $texto = "FORMA DE PAGAMENTO";
597
        $this->pdf->textBox($x, $y, $wBoxEsq, $hLinha, $texto, $aFontPgto, '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...
598
        $wBoxDir = $w*0.3;
599
        $xBoxDescricao = $x + $wBoxEsq;
600
        $texto = "VALOR PAGO";
601
        $this->pdf->textBox($xBoxDescricao, $y, $wBoxDir, $hLinha, $texto, $aFontPgto, 'T', 'R', 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...
602
        $cont = 0;
603
        if ($qtdPgto > 0) {
604
            foreach ($this->pag as $pagI) {
605
                $tPag = $this->getTagValue($pagI, "tPag");
606
                $tPagNome = $this->tipoPag($tPag);
607
                $tPnome = $tPagNome;
0 ignored issues
show
Unused Code introduced by
$tPnome 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...
608
                $vPag = number_format($this->getTagValue($pagI, "vPag"), 2, ",", ".");
609
                $card = $pagI->getElementsByTagName("card")->item(0);
610
                $cardCNPJ = '';
0 ignored issues
show
Unused Code introduced by
$cardCNPJ 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...
611
                $tBand = '';
0 ignored issues
show
Unused Code introduced by
$tBand 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...
612
                $tBandNome = '';
0 ignored issues
show
Unused Code introduced by
$tBandNome 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...
613
                if (isset($card)) {
614
                    $cardCNPJ = $this->getTagValue($card, "CNPJ");
0 ignored issues
show
Unused Code introduced by
$cardCNPJ 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...
615
                    $tBand    = $this->getTagValue($card, "tBand");
616
                    $cAut = $this->getTagValue($card, "cAut");
0 ignored issues
show
Unused Code introduced by
$cAut 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...
617
                    $tBandNome = self::getCardName($tBand);
0 ignored issues
show
Unused Code introduced by
$tBandNome 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...
618
                }
619
                //COLOCA PRODUTO
620
                $yBoxProd = $y + $hLinha + ($cont*$hLinha);
621
                //COLOCA PRODUTO CÓDIGO
622
                $texto = $tPagNome;
623
                $this->pdf->textBox($x, $yBoxProd, $wBoxEsq, $hLinha, $texto, $aFontPgto, '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...
624
                //COLOCA PRODUTO DESCRIÇÃO
625
                $xBoxDescricao = $wBoxEsq + $x;
626
                $texto = "R$ " . $vPag;
627
                $this->pdf->textBox(
628
                    $xBoxDescricao,
629
                    $yBoxProd,
630
                    $wBoxDir,
631
                    $hLinha,
632
                    $texto,
633
                    $aFontPgto,
634
                    'C',
635
                    'R',
636
                    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...
637
                    '',
638
                    false
639
                );
640
                $cont++;
641
            }
642
            
643
            if (!empty($this->vTroco)) {
644
                $yBoxProd = $y + $hLinha + ($cont*$hLinha);
645
                //COLOCA PRODUTO CÓDIGO
646
                $texto = 'Troco';
647
                $this->pdf->textBox($x, $yBoxProd, $wBoxEsq, $hLinha, $texto, $aFontPgto, '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...
648
                //COLOCA PRODUTO DESCRIÇÃO
649
                $xBoxDescricao = $wBoxEsq + $x;
650
                $texto = "R$ " . number_format($this->vTroco, 2, ",", ".");
651
                $this->pdf->textBox(
652
                    $xBoxDescricao,
653
                    $yBoxProd,
654
                    $wBoxDir,
655
                    $hLinha,
656
                    $texto,
657
                    $aFontPgto,
658
                    'C',
659
                    'R',
660
                    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...
661
                    '',
662
                    false
663
                );
664
            }
665
        }
666
    }
667
    
668
    protected function fiscalDANFE($x = 0, $y = 0, $h = 0)
669
    {
670
        $y += 6;
671
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna 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...
672
        $maxW = $this->wPrint;
673
        $w = ($maxW*1);
674
        $hLinha = $this->hLinha;
675
        $aFontTit = ['font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B'];
676
        $aFontTex = ['font'=>$this->fontePadrao, 'size'=>8, 'style'=>''];
677
        $digVal = $this->getTagValue($this->nfe, "DigestValue");
0 ignored issues
show
Unused Code introduced by
$digVal 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...
678
        $chNFe = str_replace('NFe', '', $this->infNFe->getAttribute("Id"));
679
        $tpAmb = $this->getTagValue($this->ide, 'tpAmb');
0 ignored issues
show
Unused Code introduced by
$tpAmb 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...
680
        
681
        if ($this->checkCancelada()) {
682
            //101 Cancelamento
683
            $this->pdf->setTextColor(255, 0, 0);
684
            $texto = "NFCe CANCELADA";
685
            $this->pdf->textBox($x, $y - 25, $w, $h, $texto, $aFontTit, '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...
686
            $this->pdf->setTextColor(0, 0, 0);
687
        }
688
        
689
        if ($this->checkDenegada()) {
690
            //uso denegado
691
            $this->pdf->setTextColor(255, 0, 0);
692
            $texto = "NFCe CANCELADA";
693
            $this->pdf->textBox($x, $y - 25, $w, $h, $texto, $aFontTit, '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...
694
            $this->pdf->SetTextColor(0, 0, 0);
695
        }
696
        
697
        $cUF = $this->getTagValue($this->ide, 'cUF');
0 ignored issues
show
Unused Code introduced by
$cUF 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...
698
        $nNF = $this->getTagValue($this->ide, 'nNF');
699
        $serieNF = str_pad($this->getTagValue($this->ide, "serie"), 3, "0", STR_PAD_LEFT);
700
        $dhEmi = $this->getTagValue($this->ide, "dhEmi");
701
        $dhEmilocal = new \DateTime($dhEmi);
702
        $dhEmiLocalFormat = $dhEmilocal->format('d/m/Y H:i:s');
703
        $texto = "ÁREA DE MENSAGEM FISCAL";
704
        $this->pdf->textBox($x, $y, $w, $hLinha, $texto, $aFontTit, 'C', 'C', 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...
705
        $yTex1 = $y + ($hLinha*1);
706
        $hTex1 = $hLinha*2;
707
        $texto = "Número " . $nNF . " Série " . $serieNF . " " .$dhEmiLocalFormat . " - Via Consumidor";
708
        $this->pdf->textBox($x, $yTex1, $w, $hTex1, $texto, $aFontTex, 'C', 'C', 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...
709
        $yTex2 = $y + ($hLinha*3);
710
        $hTex2 = $hLinha*2;
711
        
712
        $texto = !empty($this->urlChave) ? "Consulte pela Chave de Acesso em " . $this->urlChave : '';
713
        $this->pdf->textBox($x, $yTex2, $w, $hTex2, $texto, $aFontTex, 'C', 'C', 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...
714
        $texto = "CHAVE DE ACESSO";
715
        $yTit2 = $y + ($hLinha*5);
716
        $this->pdf->textBox($x, $yTit2, $w, $hLinha, $texto, $aFontTit, 'C', 'C', 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...
717
        $yTex3 = $y + ($hLinha*6);
718
        $texto = $chNFe;
719
        $this->pdf->textBox($x, $yTex3, $w, $hLinha, $texto, $aFontTex, 'C', 'C', 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...
720
    }
721
    
722
    protected function consumidorDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
723
    {
724
        $y += 6;
725
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna 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...
726
        $maxW = $this->wPrint;
727
        $w = ($maxW*1);
728
        $hLinha = $this->hLinha;
729
        $aFontTit = ['font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B'];
730
        $aFontTex = ['font'=>$this->fontePadrao, 'size'=>8, 'style'=>''];
731
        $texto = "CONSUMIDOR";
732
        $this->pdf->textBox($x, $y, $w, $hLinha, $texto, $aFontTit, 'C', 'C', 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...
733
        if (isset($this->dest)) {
734
            $considEstrangeiro = !empty($this->dest->getElementsByTagName("idEstrangeiro")->item(0)->nodeValue)
735
                    ? $this->dest->getElementsByTagName("idEstrangeiro")->item(0)->nodeValue
736
                    : '';
737
            $consCPF = !empty($this->dest->getElementsByTagName("CPF")->item(0)->nodeValue)
738
                    ? $this->dest->getElementsByTagName("CPF")->item(0)->nodeValue
739
                    : '';
740
            $consCNPJ = !empty($this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue)
741
                    ? $this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue
742
                    : '';
743
            $cDest = $consCPF.$consCNPJ.$considEstrangeiro; //documentos do consumidor
0 ignored issues
show
Unused Code introduced by
$cDest is not used, you could remove the assignment.

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

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

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

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

Loading history...
744
            $enderDest = $this->dest->getElementsByTagName("enderDest")->item(0);
745
            $consNome = $this->getTagValue($this->dest, "xNome");
746
            $consLgr = $this->getTagValue($enderDest, "xLgr");
747
            $consNro = $this->getTagValue($enderDest, "nro");
748
            $consCpl = $this->getTagValue($enderDest, "xCpl", " - ");
749
            $consBairro = $this->getTagValue($enderDest, "xBairro");
750
            $consCEP = $this->formatField($this->getTagValue($enderDest, "CEP"));
751
            $consMun = $this->getTagValue($enderDest, "xMun");
752
            $consUF = $this->getTagValue($enderDest, "UF");
753
            $considEstrangeiro = $this->getTagValue($this->dest, "idEstrangeiro");
754
            $consCPF = $this->getTagValue($this->dest, "CPF");
755
            $consCNPJ = $this->getTagValue($this->dest, "CNPJ");
756
            $consDoc = "";
757
            if (!empty($consCNPJ)) {
758
                $consDoc = "CNPJ: $consCNPJ";
759
            } elseif (!empty($consCPF)) {
760
                $consDoc = "CPF: $consCPF";
761
            } elseif (!empty($considEstrangeiro)) {
762
                $consDoc = "id: $considEstrangeiro";
763
            }
764
            $consEnd = "";
765
            if (!empty($consLgr)) {
766
                $consEnd = $consLgr
767
                    . ","
768
                    . $consNro
769
                    . " "
770
                    . $consCpl
771
                    . ","
772
                    . $consBairro
773
                    . ". CEP:"
774
                    . $consCEP
775
                    . ". "
776
                    . $consMun
777
                    . "-"
778
                    . $consUF;
779
            }
780
            $yTex1 = $y + $hLinha;
781
            $texto = $consNome;
782
            if (!empty($consDoc)) {
783
                $texto .= " - ". $consDoc . "\n" . $consEnd;
784
                $this->pdf->textBox($x, $yTex1, $w, $hLinha*3, $texto, $aFontTex, 'C', 'C', 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...
785
            }
786
        } else {
787
            $yTex1 = $y + $hLinha;
788
            $texto = "Consumidor não identificado";
789
            $this->pdf->textBox($x, $yTex1, $w, $hLinha, $texto, $aFontTex, 'C', 'C', 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...
790
        }
791
    }
792
    
793
    protected function qrCodeDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
794
    {
795
        $y += 6;
796
        $margemInterna = $this->margemInterna;
797
        $maxW = $this->wPrint;
798
        $w = ($maxW*1)+4;
799
        $hLinha = $this->hLinha;
0 ignored issues
show
Unused Code introduced by
$hLinha 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...
800
        $hBoxLinha = $this->hBoxLinha;
801
        $aFontTit = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B');
0 ignored issues
show
Unused Code introduced by
$aFontTit 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...
802
        $aFontTex = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
803
        $dhRecbto = '';
804
        $nProt = '';
805
        if (isset($this->nfeProc)) {
806
            $nProt = $this->getTagValue($this->nfeProc, "nProt");
807
            $dhRecbto  = $this->getTagValue($this->nfeProc, "dhRecbto");
808
        }
809
        $barcode = new Barcode();
810
        $bobj = $barcode->getBarcodeObj(
811
            'QRCODE,M',
812
            $this->qrCode,
813
            -4,
814
            -4,
815
            'black',
816
            array(-2, -2, -2, -2)
817
        )->setBackgroundColor('white');
818
        $qrcode = $bobj->getPngData();
819
        $wQr = 50;
820
        $hQr = 50;
821
        $yQr = ($y+$margemInterna);
822
        $xQr = ($w/2) - ($wQr/2);
823
        // prepare a base64 encoded "data url"
824
        $pic = 'data://text/plain;base64,' . base64_encode($qrcode);
825
        $info = getimagesize($pic);
0 ignored issues
show
Unused Code introduced by
$info 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...
826
        $this->pdf->image($pic, $xQr, $yQr, $wQr, $hQr, 'PNG');
827
        $dt = new DateTime($dhRecbto);
828
        $yQr = ($yQr+$hQr+$margemInterna);
829
        $this->pdf->textBox($x, $yQr, $w-4, $hBoxLinha, "Protocolo de Autorização: " . $nProt . "\n"
830
            . $dt->format('d/m/Y H:i:s'), $aFontTex, 'C', 'C', 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...
831
    }
832
   
833
    protected function infAdic($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
834
    {
835
        $y += 17;
836
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna 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...
837
        $maxW = $this->wPrint;
838
        $w = ($maxW * 1);
839
        $hLinha = $this->hLinha;
840
        $aFontTit = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'];
841
        $aFontTex = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
842
        // seta o textbox do titulo
843
        $texto = "INFORMAÇÃO ADICIONAL";
844
        if (isset($this->nfeProc) && $this->nfeProc->getElementsByTagName("xMsg")->length) {
845
            $y += 3;
846
            $texto = $texto . ' ' . $this->nfeProc->getElementsByTagName("xMsg")->item(0)->nodeValue;
847
            $heigthText = $this->pdf->textBox($x, $y, $w, $hLinha, $texto, $aFontTit, 'C', 'C', 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...
Unused Code introduced by
$heigthText 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...
848
            $y += 4;
849
        } else {
850
            $heigthText = $this->pdf->textBox($x, $y, $w, $hLinha, $texto, $aFontTit, 'C', 'C', 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...
Unused Code introduced by
$heigthText 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...
851
        }
852
        // seta o textbox do texto adicional
853
        $this->pdf->textBox($x, $y+3, $w-2, $hLinha-3, $this->textoAdic, $aFontTex, '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...
854
    }
855
    
856
    /**
857
     * anfavea
858
     * Função para transformar o campo cdata do padrão ANFAVEA para
859
     * texto imprimível
860
     *
861
     * @param  string $cdata campo CDATA
862
     * @return string conteúdo do campo CDATA como string
863
     */
864
    protected function anfaveaDANFE($cdata = '')
865
    {
866
        if ($cdata == '') {
867
            return '';
868
        }
869
        //remove qualquer texto antes ou depois da tag CDATA
870
        $cdata = str_replace('<![CDATA[', '<CDATA>', $cdata);
871
        $cdata = str_replace(']]>', '</CDATA>', $cdata);
872
        $cdata = preg_replace('/\s\s+/', ' ', $cdata);
873
        $cdata = str_replace("> <", "><", $cdata);
874
        $len = strlen($cdata);
875
        $startPos = strpos($cdata, '<');
876
        if ($startPos === false) {
877
            return $cdata;
878
        }
879
        for ($x=$len; $x>0; $x--) {
880
            if (substr($cdata, $x, 1) == '>') {
881
                $endPos = $x;
882
                break;
883
            }
884
        }
885
        if ($startPos > 0) {
886
            $parte1 = substr($cdata, 0, $startPos);
887
        } else {
888
            $parte1 = '';
889
        }
890
        $parte2 = substr($cdata, $startPos, $endPos-$startPos+1);
0 ignored issues
show
Bug introduced by
The variable $endPos 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...
891
        if ($endPos < $len) {
892
            $parte3 = substr($cdata, $endPos + 1, $len - $endPos - 1);
893
        } else {
894
            $parte3 = '';
895
        }
896
        $texto = trim($parte1).' '.trim($parte3);
897
        if (strpos($parte2, '<CDATA>') === false) {
898
            $cdata = '<CDATA>'.$parte2.'</CDATA>';
899
        } else {
900
            $cdata = $parte2;
901
        }
902
        //carrega o xml CDATA em um objeto DOM
903
        $dom = new Dom();
904
        $dom->loadXML($cdata, LIBXML_NOBLANKS | LIBXML_NOEMPTYTAG);
905
        //$xml = $dom->saveXML();
906
        //grupo CDATA infADprod
907
        $id = $dom->getElementsByTagName('id')->item(0);
908
        $div = $dom->getElementsByTagName('div')->item(0);
909
        $entg = $dom->getElementsByTagName('entg')->item(0);
910
        $dest = $dom->getElementsByTagName('dest')->item(0);
911
        $ctl = $dom->getElementsByTagName('ctl')->item(0);
912
        $ref = $dom->getElementsByTagName('ref')->item(0);
913
        if (isset($id)) {
914
            if ($id->hasAttributes()) {
915
                foreach ($id->attributes as $attr) {
916
                    $name = $attr->nodeName;
917
                    $value = $attr->nodeValue;
918
                    $texto .= " $name : $value";
919
                }
920
            }
921
        }
922
        if (isset($div)) {
923
            if ($div->hasAttributes()) {
924
                foreach ($div->attributes as $attr) {
925
                    $name = $attr->nodeName;
926
                    $value = $attr->nodeValue;
927
                    $texto .= " $name : $value";
928
                }
929
            }
930
        }
931
        if (isset($entg)) {
932
            if ($entg->hasAttributes()) {
933
                foreach ($entg->attributes as $attr) {
934
                    $name = $attr->nodeName;
935
                    $value = $attr->nodeValue;
936
                    $texto .= " $name : $value";
937
                }
938
            }
939
        }
940
        if (isset($dest)) {
941
            if ($dest->hasAttributes()) {
942
                foreach ($dest->attributes as $attr) {
943
                    $name = $attr->nodeName;
944
                    $value = $attr->nodeValue;
945
                    $texto .= " $name : $value";
946
                }
947
            }
948
        }
949
        if (isset($ctl)) {
950
            if ($ctl->hasAttributes()) {
951
                foreach ($ctl->attributes as $attr) {
952
                    $name = $attr->nodeName;
953
                    $value = $attr->nodeValue;
954
                    $texto .= " $name : $value";
955
                }
956
            }
957
        }
958
        if (isset($ref)) {
959
            if ($ref->hasAttributes()) {
960
                foreach ($ref->attributes as $attr) {
961
                    $name = $attr->nodeName;
962
                    $value = $attr->nodeValue;
963
                    $texto .= " $name : $value";
964
                }
965
            }
966
        }
967
        //grupo CADATA infCpl
968
        $t = $dom->getElementsByTagName('transmissor')->item(0);
969
        $r = $dom->getElementsByTagName('receptor')->item(0);
970
        $versao = ! empty($dom->getElementsByTagName('versao')->item(0)->nodeValue) ?
971
        'Versao:'.$dom->getElementsByTagName('versao')->item(0)->nodeValue.' ' : '';
972
        $especieNF = ! empty($dom->getElementsByTagName('especieNF')->item(0)->nodeValue) ?
973
        'Especie:'.$dom->getElementsByTagName('especieNF')->item(0)->nodeValue.' ' : '';
974
        $fabEntrega = ! empty($dom->getElementsByTagName('fabEntrega')->item(0)->nodeValue) ?
975
        'Entrega:'.$dom->getElementsByTagName('fabEntrega')->item(0)->nodeValue.' ' : '';
976
        $dca = ! empty($dom->getElementsByTagName('dca')->item(0)->nodeValue) ?
977
        'dca:'.$dom->getElementsByTagName('dca')->item(0)->nodeValue.' ' : '';
978
        $texto .= "".$versao.$especieNF.$fabEntrega.$dca;
979
        if (isset($t)) {
980
            if ($t->hasAttributes()) {
981
                $texto .= " Transmissor ";
982
                foreach ($t->attributes as $attr) {
983
                    $name = $attr->nodeName;
984
                    $value = $attr->nodeValue;
985
                    $texto .= " $name : $value";
986
                }
987
            }
988
        }
989
        if (isset($r)) {
990
            if ($r->hasAttributes()) {
991
                $texto .= " Receptor ";
992
                foreach ($r->attributes as $attr) {
993
                    $name = $attr->nodeName;
994
                    $value = $attr->nodeValue;
995
                    $texto .= " $name : $value";
996
                }
997
            }
998
        }
999
        return $texto;
1000
    }
1001
    
1002
    protected static function getCardName($tBand)
1003
    {
1004
        switch ($tBand) {
1005
            case '01':
1006
                $tBandNome = 'VISA';
1007
                break;
1008
            case '02':
1009
                $tBandNome = 'MASTERCARD';
1010
                break;
1011
            case '03':
1012
                $tBandNome = 'AMERICAM EXPRESS';
1013
                break;
1014
            case '04':
1015
                $tBandNome = 'SOROCRED';
1016
                break;
1017
            case '99':
1018
                $tBandNome = 'OUTROS';
1019
                break;
1020
            default:
1021
                $tBandNome = '';
1022
        }
1023
        return $tBandNome;
1024
    }
1025
      
1026
    protected function checkCancelada()
1027
    {
1028
        if (!isset($this->nfeProc)) {
1029
            return false;
1030
        }
1031
        $cStat = $this->getTagValue($this->nfeProc, "cStat");
1032
        return $cStat == '101' ||
1033
                $cStat == '151' ||
1034
                $cStat == '135' ||
1035
                $cStat == '155';
1036
    }
1037
1038
    protected function checkDenegada()
1039
    {
1040
        if (!isset($this->nfeProc)) {
1041
            return false;
1042
        }
1043
        //NÃO ERA NECESSÁRIO ESSA FUNÇÃO POIS SÓ SE USA
1044
        //1 VEZ NO ARQUIVO INTEIRO
1045
        $cStat = $this->getTagValue($this->nfeProc, "cStat");
1046
        return $cStat == '110' ||
1047
               $cStat == '301' ||
1048
               $cStat == '302';
1049
    }
1050
}
1051