src/Pug/Engine/PugJsEngine.php
Method renderWithJs
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function renderWithJs($input, $filename, $vars = null, $fallback = null)
{
if (is_array($filename)) {
if (!is_null($vars)) {
$fallback = $vars;
Missing class import via use statement (line '70', column '23'). Open
Open
throw new \RuntimeException(
- 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 '\NodejsPhpFallback\NodejsPhpFallback' in method 'renderWithJs'. Open
Open
json_encode(realpath(NodejsPhpFallback::getPrefixPath() . '/require.js')) .
- 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 assigning values to variables in if clauses and the like (line '204', column '13'). Open
Open
public function renderWithJs($input, $filename, $vars = null, $fallback = null)
{
if (is_array($filename)) {
if (!is_null($vars)) {
$fallback = $vars;
- Read upRead up
- Exclude checks
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
Open
unlink($path);
- Exclude checks
Call to undeclared method \Pug\Engine\PugJsEngine::mergeWithSharedVariables
Open
Open
$vars = $this->mergeWithSharedVariables($vars);
- Exclude checks
Argument 1 (input)
is null
but \Pug\Engine\PugJsEngine::renderWithJs()
takes string
defined at /code/src/Pug/Engine/PugJsEngine.php:190
Open
Open
return $this->renderWithJs(null, $path, $vars, $fallback);
- Exclude checks
Argument 1 (path)
is ?string
but \basename()
takes string
Open
Open
$basename = basename($filename);
- Exclude checks
Call to method __construct
from undeclared class \NodejsPhpFallback\NodejsPhpFallback
Open
Open
$this->nodeEngine = new NodejsPhpFallback($this->hasOption('node_path')
- Exclude checks
Argument 1 (path)
is ?string
but \realpath()
takes string
Open
Open
'path' => realpath($filename),
- Exclude checks
Property \Pug\Engine\PugJsEngine->nodeEngine
has undeclared type \NodejsPhpFallback\NodejsPhpFallback
Open
Open
protected $nodeEngine;
- Exclude checks
Return type of getNodeEngine()
is undeclared type \NodejsPhpFallback\NodejsPhpFallback
Open
Open
public function getNodeEngine()
- Exclude checks
Call to method getPrefixPath
from undeclared class \NodejsPhpFallback\NodejsPhpFallback
Open
Open
json_encode(realpath(NodejsPhpFallback::getPrefixPath() . '/require.js')) .
- Exclude checks
Argument 1 (path)
is ?string
but \dirname()
takes string
Open
Open
$directory = dirname($filename);
- Exclude checks
Call to method execModuleScript
from undeclared class \NodejsPhpFallback\NodejsPhpFallback
Open
Open
$result = $node->execModuleScript(
- Exclude checks
Call to undeclared method \Pug\Engine\PugJsEngine::getOption
Open
Open
: $this->getOption('cache_dir');
- Exclude checks
Call to method nodeExec
from undeclared class \NodejsPhpFallback\NodejsPhpFallback
Open
Open
$html = $node->nodeExec($renderFile);
- Exclude checks
Call to undeclared method \Pug\Engine\PugJsEngine::hasOption
Open
Open
$this->nodeEngine = new NodejsPhpFallback($this->hasOption('node_path')
- Exclude checks
Expected 0 spaces before closing bracket; newline found Open
Open
$this->nodeEngine = new NodejsPhpFallback($this->hasOption('node_path')
- Exclude checks
Opening parenthesis of a multi-line function call must be the last content on the line Open
Open
file_put_contents($renderFile,
- Exclude checks
Expected 0 spaces before closing bracket; newline found Open
Open
file_put_contents($optionsFile, 'module.exports = require(' .
- Exclude checks