Method Generate_PDF
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function Generate_PDF ($content, $doc_title, $doc_keywords) {
global $icmsConfig;
require_once ICMS_PDF_LIB_PATH.'/tcpdf.php';
icms_loadLanguageFile('core', 'pdf');
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
Avoid using undefined variables such as '$l' which will lead to PHP notices. Open
$pdf->setLanguageArray($l); //set language items
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Remove error control operator '@' on line 55. Open
function Generate_PDF ($content, $doc_title, $doc_keywords) {
global $icmsConfig;
require_once ICMS_PDF_LIB_PATH.'/tcpdf.php';
icms_loadLanguageFile('core', 'pdf');
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
- Read upRead up
- Exclude checks
ErrorControlOperator
Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.
Example
function foo($filePath) {
$file = @fopen($filPath); // hides exceptions
$key = @$array[$notExistingKey]; // assigns null to $key
}
Source http://phpmd.org/rules/cleancode.html#errorcontroloperator
Missing class import via use statement (line '30', column '13'). Open
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Avoid using static access to class 'icms_core_DataFilter' in method 'Generate_PDF'. Open
$pdfheader = icms_core_DataFilter::undoHtmlSpecialChars($sitename.' - '.$siteslogan);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid unused local variables such as '$l'. Open
$pdf->setLanguageArray($l); //set language items
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Reference to undeclared constant \PDF_PAGE_FORMAT
Open
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
- Exclude checks
Reference to undeclared constant \PDF_AUTHOR
Open
$pdf->SetAuthor(PDF_AUTHOR);
- Exclude checks
Call to method SetMargins
from undeclared class \TCPDF
Open
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
- Exclude checks
Reference to undeclared constant \PDF_MARGIN_LEFT
Open
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
- Exclude checks
Call to method SetFooterMargin
from undeclared class \TCPDF
Open
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
- Exclude checks
Call to method setLanguageArray
from undeclared class \TCPDF
Open
$pdf->setLanguageArray($l); //set language items
- Exclude checks
Reference to undeclared constant \_PDF_LOCAL_FONT
Open
$TextFont = (@_PDF_LOCAL_FONT && file_exists(ICMS_PDF_LIB_PATH.'/fonts/'._PDF_LOCAL_FONT.'.php')) ? _PDF_LOCAL_FONT : 'dejavusans';
- Exclude checks
Reference to undeclared constant \PDF_CREATOR
Open
$pdf->SetCreator(PDF_CREATOR);
- Exclude checks
Reference to undeclared constant \PDF_FONT_NAME_MAIN
Open
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
- Exclude checks
Reference to undeclared constant \PDF_FONT_SIZE_DATA
Open
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
- Exclude checks
Reference to undeclared constant \PDF_MARGIN_TOP
Open
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
- Exclude checks
Call to method __construct
from undeclared class \TCPDF
Open
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
- Exclude checks
Reference to undeclared constant \PDF_MARGIN_BOTTOM
Open
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
- Exclude checks
Call to method SetHeaderMargin
from undeclared class \TCPDF
Open
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
- Exclude checks
Reference to undeclared constant \PDF_FONT_SIZE_MAIN
Open
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
- Exclude checks
Call to method SetFont
from undeclared class \TCPDF
Open
$pdf -> SetFont($TextFont);
- Exclude checks
Reference to undeclared constant \PDF_MARGIN_HEADER
Open
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
- Exclude checks
Reference to undeclared constant \PDF_UNIT
Open
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
- Exclude checks
Call to method setImageScale
from undeclared class \TCPDF
Open
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set image scale factor
- Exclude checks
Call to method Output
from undeclared class \TCPDF
Open
return $pdf->Output();
- Exclude checks
Call to method writeHTML
from undeclared class \TCPDF
Open
$pdf->writeHTML($content, true, 0);
- Exclude checks
Call to method SetSubject
from undeclared class \TCPDF
Open
$pdf->SetSubject($doc_title);
- Exclude checks
Reference to undeclared constant \PDF_MARGIN_RIGHT
Open
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
- Exclude checks
Call to method SetAutoPageBreak
from undeclared class \TCPDF
Open
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
- Exclude checks
Reference to undeclared constant \PDF_MARGIN_FOOTER
Open
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
- Exclude checks
Call to method setHeaderFont
from undeclared class \TCPDF
Open
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
- Exclude checks
Call to method undoHtmlSpecialChars
from undeclared class \icms_core_DataFilter
Open
$pdfheader = icms_core_DataFilter::undoHtmlSpecialChars($sitename.' - '.$siteslogan);
- Exclude checks
Call to method AliasNbPages
from undeclared class \TCPDF
Open
$pdf->AliasNbPages();
- Exclude checks
Reference to undeclared constant \PDF_PAGE_ORIENTATION
Open
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
- Exclude checks
Call to method SetCreator
from undeclared class \TCPDF
Open
$pdf->SetCreator(PDF_CREATOR);
- Exclude checks
Call to method SetTitle
from undeclared class \TCPDF
Open
$pdf->SetTitle($doc_title);
- Exclude checks
Call to method SetHeaderData
from undeclared class \TCPDF
Open
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, $pdfheader, ICMS_URL);
- Exclude checks
Reference to undeclared constant \PDF_HEADER_LOGO_WIDTH
Open
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, $pdfheader, ICMS_URL);
- Exclude checks
Reference to undeclared constant \PDF_IMAGE_SCALE_RATIO
Open
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set image scale factor
- Exclude checks
Call to method SetAuthor
from undeclared class \TCPDF
Open
$pdf->SetAuthor(PDF_AUTHOR);
- Exclude checks
Call to method SetKeywords
from undeclared class \TCPDF
Open
$pdf->SetKeywords($doc_keywords);
- Exclude checks
Reference to undeclared constant \PDF_HEADER_LOGO
Open
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, $pdfheader, ICMS_URL);
- Exclude checks
Call to method setFooterFont
from undeclared class \TCPDF
Open
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
- Exclude checks
Reference to undeclared constant \PDF_FONT_NAME_DATA
Open
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
- Exclude checks
Call to method AddPage
from undeclared class \TCPDF
Open
$pdf->AddPage();
- Exclude checks
The parameter $doc_keywords is not named in camelCase. Open
function Generate_PDF ($content, $doc_title, $doc_keywords) {
global $icmsConfig;
require_once ICMS_PDF_LIB_PATH.'/tcpdf.php';
icms_loadLanguageFile('core', 'pdf');
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $doc_title is not named in camelCase. Open
function Generate_PDF ($content, $doc_title, $doc_keywords) {
global $icmsConfig;
require_once ICMS_PDF_LIB_PATH.'/tcpdf.php';
icms_loadLanguageFile('core', 'pdf');
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
Expected "function abc(...)"; found "function abc (...)" Open
function Generate_PDF ($content, $doc_title, $doc_keywords) {
- Exclude checks
Expected 0 spaces before opening parenthesis; 1 found Open
function Generate_PDF ($content, $doc_title, $doc_keywords) {
- Exclude checks
PHP keywords must be lowercase; expected "array" but found "Array" Open
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
- Exclude checks
PHP keywords must be lowercase; expected "array" but found "Array" Open
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE" Open
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
- Exclude checks
Expected 1 newline at end of file; 0 found Open
}
- Exclude checks
The variable $doc_keywords is not named in camelCase. Open
function Generate_PDF ($content, $doc_title, $doc_keywords) {
global $icmsConfig;
require_once ICMS_PDF_LIB_PATH.'/tcpdf.php';
icms_loadLanguageFile('core', 'pdf');
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $doc_title is not named in camelCase. Open
function Generate_PDF ($content, $doc_title, $doc_keywords) {
global $icmsConfig;
require_once ICMS_PDF_LIB_PATH.'/tcpdf.php';
icms_loadLanguageFile('core', 'pdf');
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $doc_title is not named in camelCase. Open
function Generate_PDF ($content, $doc_title, $doc_keywords) {
global $icmsConfig;
require_once ICMS_PDF_LIB_PATH.'/tcpdf.php';
icms_loadLanguageFile('core', 'pdf');
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $TextFont is not named in camelCase. Open
function Generate_PDF ($content, $doc_title, $doc_keywords) {
global $icmsConfig;
require_once ICMS_PDF_LIB_PATH.'/tcpdf.php';
icms_loadLanguageFile('core', 'pdf');
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $TextFont is not named in camelCase. Open
function Generate_PDF ($content, $doc_title, $doc_keywords) {
global $icmsConfig;
require_once ICMS_PDF_LIB_PATH.'/tcpdf.php';
icms_loadLanguageFile('core', 'pdf');
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}