kylekatarnls/jade-php

View on GitHub
src/Pug/Engine/PugJsEngine.php

Summary

Maintainability
A
1 hr
Test Coverage

Method renderWithJs has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function renderWithJs($input, $filename, $vars = null, $fallback = null)
    {
        if (is_array($filename)) {
            if (!is_null($vars)) {
                $fallback = $vars;
Severity: Minor
Found in src/Pug/Engine/PugJsEngine.php - About 1 hr to fix

    Missing class import via use statement (line '70', column '23').
    Open

                throw new \RuntimeException(
    Severity: Minor
    Found in src/Pug/Engine/PugJsEngine.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 '\NodejsPhpFallback\NodejsPhpFallback' in method 'renderWithJs'.
    Open

                    json_encode(realpath(NodejsPhpFallback::getPrefixPath() . '/require.js')) .
    Severity: Minor
    Found in src/Pug/Engine/PugJsEngine.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 assigning values to variables in if clauses and the like (line '204', column '13').
    Open

        public function renderWithJs($input, $filename, $vars = null, $fallback = null)
        {
            if (is_array($filename)) {
                if (!is_null($vars)) {
                    $fallback = $vars;
    Severity: Minor
    Found in src/Pug/Engine/PugJsEngine.php by phpmd

    IfStatementAssignment

    Since: 2.7.0

    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($foo = 'bar') { // possible typo
                // ...
            }
            if ($baz = 0) { // always false
                // ...
            }
        }
    }

    Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

    Argument 1 (filename) is ?string but \unlink() takes string
    Open

                unlink($path);
    Severity: Minor
    Found in src/Pug/Engine/PugJsEngine.php by phan

    Call to undeclared method \Pug\Engine\PugJsEngine::mergeWithSharedVariables
    Open

            $vars = $this->mergeWithSharedVariables($vars);
    Severity: Critical
    Found in src/Pug/Engine/PugJsEngine.php by phan

    Argument 1 (input) is null but \Pug\Engine\PugJsEngine::renderWithJs() takes string defined at /code/src/Pug/Engine/PugJsEngine.php:190
    Open

            return $this->renderWithJs(null, $path, $vars, $fallback);
    Severity: Minor
    Found in src/Pug/Engine/PugJsEngine.php by phan

    Argument 1 (path) is ?string but \basename() takes string
    Open

            $basename = basename($filename);
    Severity: Minor
    Found in src/Pug/Engine/PugJsEngine.php by phan

    Call to method __construct from undeclared class \NodejsPhpFallback\NodejsPhpFallback
    Open

                $this->nodeEngine = new NodejsPhpFallback($this->hasOption('node_path')
    Severity: Critical
    Found in src/Pug/Engine/PugJsEngine.php by phan

    Argument 1 (path) is ?string but \realpath() takes string
    Open

                'path'    => realpath($filename),
    Severity: Minor
    Found in src/Pug/Engine/PugJsEngine.php by phan

    Property \Pug\Engine\PugJsEngine->nodeEngine has undeclared type \NodejsPhpFallback\NodejsPhpFallback
    Open

        protected $nodeEngine;
    Severity: Minor
    Found in src/Pug/Engine/PugJsEngine.php by phan

    Return type of getNodeEngine() is undeclared type \NodejsPhpFallback\NodejsPhpFallback
    Open

        public function getNodeEngine()
    Severity: Minor
    Found in src/Pug/Engine/PugJsEngine.php by phan

    Call to method getPrefixPath from undeclared class \NodejsPhpFallback\NodejsPhpFallback
    Open

                    json_encode(realpath(NodejsPhpFallback::getPrefixPath() . '/require.js')) .
    Severity: Critical
    Found in src/Pug/Engine/PugJsEngine.php by phan

    Argument 1 (path) is ?string but \dirname() takes string
    Open

            $directory = dirname($filename);
    Severity: Minor
    Found in src/Pug/Engine/PugJsEngine.php by phan

    Call to method execModuleScript from undeclared class \NodejsPhpFallback\NodejsPhpFallback
    Open

            $result = $node->execModuleScript(
    Severity: Critical
    Found in src/Pug/Engine/PugJsEngine.php by phan

    Call to undeclared method \Pug\Engine\PugJsEngine::getOption
    Open

                : $this->getOption('cache_dir');
    Severity: Critical
    Found in src/Pug/Engine/PugJsEngine.php by phan

    Call to method nodeExec from undeclared class \NodejsPhpFallback\NodejsPhpFallback
    Open

            $html = $node->nodeExec($renderFile);
    Severity: Critical
    Found in src/Pug/Engine/PugJsEngine.php by phan

    Call to undeclared method \Pug\Engine\PugJsEngine::hasOption
    Open

                $this->nodeEngine = new NodejsPhpFallback($this->hasOption('node_path')
    Severity: Critical
    Found in src/Pug/Engine/PugJsEngine.php by phan

    Expected 0 spaces before closing bracket; newline found
    Open

                $this->nodeEngine = new NodejsPhpFallback($this->hasOption('node_path')

    Opening parenthesis of a multi-line function call must be the last content on the line
    Open

            file_put_contents($renderFile,

    Expected 0 spaces before closing bracket; newline found
    Open

            file_put_contents($optionsFile, 'module.exports = require(' .

    There are no issues that match your filters.

    Category
    Status