src/Phug/Formatter/AbstractTwigFormat.php
Method __construct
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function __construct(Formatter $formatter = null)
{
parent::__construct($formatter);
$this->codeBlocks = [];
Avoid too many return
statements within this method. Open
Open
return "{{ $input }}";
Avoid assigning values to variables in if clauses and the like (line '110', column '14'). Open
Open
protected function deduplicatePhpTags($commentPattern, &$content, &$childContent)
{
$content = preg_replace('/\\s\\?>$/', '', $content);
$childContent = preg_replace('/^<\\?(?:php)?\\s/', '', $childContent);
if ($commentPattern &&
- 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
Avoid assigning values to variables in if clauses and the like (line '111', column '18'). Open
Open
protected function deduplicatePhpTags($commentPattern, &$content, &$childContent)
{
$content = preg_replace('/\\s\\?>$/', '', $content);
$childContent = preg_replace('/^<\\?(?:php)?\\s/', '', $childContent);
if ($commentPattern &&
- 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
Parameter $element
has undeclared type \Phug\Formatter\Element\MarkupElement
Open
Open
protected function formatAttributes(MarkupElement $element)
- Exclude checks
Class extends undeclared class \Phug\Formatter\Format\XhtmlFormat
Open
Open
abstract class AbstractTwigFormat extends XhtmlFormat
- Exclude checks
Reference to undeclared class \Phug\Formatter\Format\XhtmlFormat
Open
Open
parent::__construct($formatter);
- Exclude checks
Call to method getAssignments
from undeclared class \Phug\Formatter\Element\MarkupElement
Open
Open
foreach ($element->getAssignments() as $assignment) {
- Exclude checks
Checking instanceof against undeclared class \Phug\Formatter\Element\CodeElement
Open
Open
if ($child instanceof CodeElement &&
- Exclude checks
Call to undeclared method \Phug\Formatter\AbstractTwigFormat::getChildrenIterator
Open
Open
foreach ($this->getChildrenIterator($element) as $child) {
- Exclude checks
Parameter $element
has undeclared type \Phug\Formatter\ElementInterface
Open
Open
protected function formatElementChildren(ElementInterface $element, $indentStep = 1)
- Exclude checks
Parameter $formatter
has undeclared type ?\Phug\Formatter
Open
Open
public function __construct(Formatter $formatter = null)
- Exclude checks
Call to undeclared method \Phug\Formatter\AbstractTwigFormat::setOptionsRecursive
Open
Open
$this
- Exclude checks
Reference to undeclared property \Phug\Formatter\AbstractTwigFormat->formatter
Open
Open
$this->formatter->setLevel($indentLevel + $indentStep);
- Exclude checks
Reference to undeclared property \Phug\Formatter\AbstractTwigFormat->formatter
Open
Open
$this->formatter->setLevel($indentLevel);
- Exclude checks
Reference to undeclared property \Phug\Formatter\AbstractTwigFormat->formatter
Open
Open
$pugModuleName = '$'.$this->formatter->getOption('dependencies_storage');
- Exclude checks
Reference to undeclared property \Phug\Formatter\AbstractTwigFormat->formatter
Open
Open
$indentLevel = $this->formatter->getLevel();
- Exclude checks
Call to method getAttributes
from undeclared class \Phug\Formatter\Element\MarkupElement
Open
Open
foreach ($element->getAttributes() as $attribute) {
- Exclude checks
Checking instanceof against undeclared class \Phug\Formatter\Element\CodeElement
Open
Open
$previous instanceof CodeElement &&
- Exclude checks
Call to undeclared method \Phug\Formatter\AbstractTwigFormat::getOption
Open
Open
$commentPattern = $this->getOption('debug');
- Exclude checks
Checking instanceof against undeclared class \Phug\Formatter\ElementInterface
Open
Open
if ($child instanceof ElementInterface) {
- Exclude checks
Call to undeclared method \Phug\Formatter\AbstractTwigFormat::format
Open
Open
$code .= $this->format($attribute);
- Exclude checks
Call to undeclared method \Phug\Formatter\AbstractTwigFormat::format
Open
Open
$code .= $this->format($assignment);
- Exclude checks
Call to method isCodeBlock
from undeclared class \Phug\Formatter\Element\CodeElement
Open
Open
$previous->isCodeBlock()
- Exclude checks
Reference to undeclared property \Phug\Formatter\AbstractTwigFormat->formatter
Open
Open
$childContent = $this->formatter->format($child);
- Exclude checks
Reference to undeclared property \Phug\Formatter\AbstractTwigFormat->formatter
Open
Open
return $this->mustBeHandleWithPhp($input, '$'.$this->formatter->getOption('dependencies_storage'))
- Exclude checks