for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace NFePHP\DA\NFe\Traits;
use Com\Tecnick\Barcode\Barcode;
/**
* Bloco QRCode
*/
trait TraitBlocoVIII
{
protected function blocoVIII($y)
$this->bloco8H = 50;
bloco8H
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;
$y += 1;
/*
$aFont = ['font'=> $this->fontePadrao, 'size' => 7, 'style' => ''];
$this->pdf->textBox($this->margem, $y, $this->wPrint, $this->bloco8H, '', $aFont, 'T', 'C', true, '', false);
$maxW = $this->wPrint;
wPrint
$w = ($maxW*1)+4;
$barcode = new Barcode();
$bobj = $barcode->getBarcodeObj(
'QRCODE,M',
$this->qrCode,
qrCode
-4,
'black',
array(-2, -2, -2, -2)
)->setBackgroundColor('white');
$qrcode = $bobj->getPngData();
$wQr = 50;
$hQr = 50;
$yQr = ($y);
$xQr = ($w/2) - ($wQr/2);
$pic = 'data://text/plain;base64,' . base64_encode($qrcode);
$info = getimagesize($pic);
$info
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.
$myVar
$higher
$this->pdf->image($pic, $xQr, $yQr, $wQr, $hQr, 'PNG');
pdf
return $this->bloco8H+$y;
}
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: