ImpressCMS/impresscms

View on GitHub
htdocs/include/pdf.php

Summary

Maintainability
A
1 hr
Test Coverage

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);
Severity: Minor
Found in htdocs/include/pdf.php - About 1 hr to fix

    Avoid using undefined variables such as '$l' which will lead to PHP notices.
    Open

        $pdf->setLanguageArray($l); //set language items
    Severity: Minor
    Found in htdocs/include/pdf.php by phpmd

    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);
    Severity: Minor
    Found in htdocs/include/pdf.php by phpmd

    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);
    Severity: Minor
    Found in htdocs/include/pdf.php by phpmd

    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);
    Severity: Minor
    Found in htdocs/include/pdf.php by phpmd

    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
    Severity: Minor
    Found in htdocs/include/pdf.php by phpmd

    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);
    Severity: Minor
    Found in htdocs/include/pdf.php by phan

    Reference to undeclared constant \PDF_AUTHOR
    Open

        $pdf->SetAuthor(PDF_AUTHOR);
    Severity: Minor
    Found in htdocs/include/pdf.php by phan

    Call to method SetMargins from undeclared class \TCPDF
    Open

        $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    Severity: Critical
    Found in htdocs/include/pdf.php by phan

    Reference to undeclared constant \PDF_MARGIN_LEFT
    Open

        $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    Severity: Minor
    Found in htdocs/include/pdf.php by phan

    Call to method SetFooterMargin from undeclared class \TCPDF
    Open

        $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
    Severity: Critical
    Found in htdocs/include/pdf.php by phan

    Call to method setLanguageArray from undeclared class \TCPDF
    Open

        $pdf->setLanguageArray($l); //set language items
    Severity: Critical
    Found in htdocs/include/pdf.php by phan

    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';
    Severity: Minor
    Found in htdocs/include/pdf.php by phan

    Reference to undeclared constant \PDF_CREATOR
    Open

        $pdf->SetCreator(PDF_CREATOR);
    Severity: Minor
    Found in htdocs/include/pdf.php by phan

    Reference to undeclared constant \PDF_FONT_NAME_MAIN
    Open

        $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
    Severity: Minor
    Found in htdocs/include/pdf.php by phan

    Reference to undeclared constant \PDF_FONT_SIZE_DATA
    Open

        $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
    Severity: Minor
    Found in htdocs/include/pdf.php by phan

    Reference to undeclared constant \PDF_MARGIN_TOP
    Open

        $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    Severity: Minor
    Found in htdocs/include/pdf.php by phan

    Call to method __construct from undeclared class \TCPDF
    Open

        $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
    Severity: Critical
    Found in htdocs/include/pdf.php by phan

    Reference to undeclared constant \PDF_MARGIN_BOTTOM
    Open

        $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
    Severity: Minor
    Found in htdocs/include/pdf.php by phan

    Call to method SetHeaderMargin from undeclared class \TCPDF
    Open

        $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
    Severity: Critical
    Found in htdocs/include/pdf.php by phan

    Reference to undeclared constant \PDF_FONT_SIZE_MAIN
    Open

        $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
    Severity: Minor
    Found in htdocs/include/pdf.php by phan

    Call to method SetFont from undeclared class \TCPDF
    Open

        $pdf -> SetFont($TextFont);
    Severity: Critical
    Found in htdocs/include/pdf.php by phan

    Reference to undeclared constant \PDF_MARGIN_HEADER
    Open

        $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
    Severity: Minor
    Found in htdocs/include/pdf.php by phan

    Reference to undeclared constant \PDF_UNIT
    Open

        $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
    Severity: Minor
    Found in htdocs/include/pdf.php by phan

    Call to method setImageScale from undeclared class \TCPDF
    Open

        $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set image scale factor
    Severity: Critical
    Found in htdocs/include/pdf.php by phan

    Call to method Output from undeclared class \TCPDF
    Open

        return $pdf->Output();
    Severity: Critical
    Found in htdocs/include/pdf.php by phan

    Call to method writeHTML from undeclared class \TCPDF
    Open

        $pdf->writeHTML($content, true, 0);
    Severity: Critical
    Found in htdocs/include/pdf.php by phan

    Call to method SetSubject from undeclared class \TCPDF
    Open

        $pdf->SetSubject($doc_title);
    Severity: Critical
    Found in htdocs/include/pdf.php by phan

    Reference to undeclared constant \PDF_MARGIN_RIGHT
    Open

        $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    Severity: Minor
    Found in htdocs/include/pdf.php by phan

    Call to method SetAutoPageBreak from undeclared class \TCPDF
    Open

        $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
    Severity: Critical
    Found in htdocs/include/pdf.php by phan

    Reference to undeclared constant \PDF_MARGIN_FOOTER
    Open

        $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
    Severity: Minor
    Found in htdocs/include/pdf.php by phan

    Call to method setHeaderFont from undeclared class \TCPDF
    Open

        $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
    Severity: Critical
    Found in htdocs/include/pdf.php by phan

    Call to method undoHtmlSpecialChars from undeclared class \icms_core_DataFilter
    Open

        $pdfheader = icms_core_DataFilter::undoHtmlSpecialChars($sitename.' - '.$siteslogan);
    Severity: Critical
    Found in htdocs/include/pdf.php by phan

    Call to method AliasNbPages from undeclared class \TCPDF
    Open

        $pdf->AliasNbPages();
    Severity: Critical
    Found in htdocs/include/pdf.php by phan

    Reference to undeclared constant \PDF_PAGE_ORIENTATION
    Open

        $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
    Severity: Minor
    Found in htdocs/include/pdf.php by phan

    Call to method SetCreator from undeclared class \TCPDF
    Open

        $pdf->SetCreator(PDF_CREATOR);
    Severity: Critical
    Found in htdocs/include/pdf.php by phan

    Call to method SetTitle from undeclared class \TCPDF
    Open

        $pdf->SetTitle($doc_title);
    Severity: Critical
    Found in htdocs/include/pdf.php by phan

    Call to method SetHeaderData from undeclared class \TCPDF
    Open

        $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, $pdfheader, ICMS_URL);
    Severity: Critical
    Found in htdocs/include/pdf.php by phan

    Reference to undeclared constant \PDF_HEADER_LOGO_WIDTH
    Open

        $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, $pdfheader, ICMS_URL);
    Severity: Minor
    Found in htdocs/include/pdf.php by phan

    Reference to undeclared constant \PDF_IMAGE_SCALE_RATIO
    Open

        $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set image scale factor
    Severity: Minor
    Found in htdocs/include/pdf.php by phan

    Call to method SetAuthor from undeclared class \TCPDF
    Open

        $pdf->SetAuthor(PDF_AUTHOR);
    Severity: Critical
    Found in htdocs/include/pdf.php by phan

    Call to method SetKeywords from undeclared class \TCPDF
    Open

        $pdf->SetKeywords($doc_keywords);
    Severity: Critical
    Found in htdocs/include/pdf.php by phan

    Reference to undeclared constant \PDF_HEADER_LOGO
    Open

        $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, $pdfheader, ICMS_URL);
    Severity: Minor
    Found in htdocs/include/pdf.php by phan

    Call to method setFooterFont from undeclared class \TCPDF
    Open

        $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
    Severity: Critical
    Found in htdocs/include/pdf.php by phan

    Reference to undeclared constant \PDF_FONT_NAME_DATA
    Open

        $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
    Severity: Minor
    Found in htdocs/include/pdf.php by phan

    Call to method AddPage from undeclared class \TCPDF
    Open

        $pdf->AddPage();
    Severity: Critical
    Found in htdocs/include/pdf.php by phan

    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);
    Severity: Minor
    Found in htdocs/include/pdf.php by phpmd

    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);
    Severity: Minor
    Found in htdocs/include/pdf.php by phpmd

    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) {
    Severity: Minor
    Found in htdocs/include/pdf.php by phpcodesniffer

    Expected 0 spaces before opening parenthesis; 1 found
    Open

    function Generate_PDF ($content, $doc_title, $doc_keywords) {
    Severity: Minor
    Found in htdocs/include/pdf.php by phpcodesniffer

    PHP keywords must be lowercase; expected "array" but found "Array"
    Open

        $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
    Severity: Minor
    Found in htdocs/include/pdf.php by phpcodesniffer

    PHP keywords must be lowercase; expected "array" but found "Array"
    Open

        $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
    Severity: Minor
    Found in htdocs/include/pdf.php by phpcodesniffer

    TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE"
    Open

        $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
    Severity: Minor
    Found in htdocs/include/pdf.php by phpcodesniffer

    Expected 1 newline at end of file; 0 found
    Open

    }
    Severity: Minor
    Found in htdocs/include/pdf.php by phpcodesniffer

    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);
    Severity: Minor
    Found in htdocs/include/pdf.php by phpmd

    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);
    Severity: Minor
    Found in htdocs/include/pdf.php by phpmd

    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);
    Severity: Minor
    Found in htdocs/include/pdf.php by phpmd

    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);
    Severity: Minor
    Found in htdocs/include/pdf.php by phpmd

    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);
    Severity: Minor
    Found in htdocs/include/pdf.php by phpmd

    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

    There are no issues that match your filters.

    Category
    Status