pug-php/twig

View on GitHub
src/Phug/Formatter/AbstractTwigFormat.php

Summary

Maintainability
A
1 hr
Test Coverage
A
100%

Method __construct has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function __construct(Formatter $formatter = null)
    {
        parent::__construct($formatter);

        $this->codeBlocks = [];
Severity: Minor
Found in src/Phug/Formatter/AbstractTwigFormat.php - About 1 hr to fix

    Avoid too many return statements within this method.
    Open

                        return "{{ $input }}";
    Severity: Major
    Found in src/Phug/Formatter/AbstractTwigFormat.php - About 30 mins to fix

      Avoid assigning values to variables in if clauses and the like (line '110', column '14').
      Open

          protected function deduplicatePhpTags($commentPattern, &$content, &$childContent)
          {
              $content = preg_replace('/\\s\\?>$/', '', $content);
              $childContent = preg_replace('/^<\\?(?:php)?\\s/', '', $childContent);
              if ($commentPattern &&

      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

          protected function deduplicatePhpTags($commentPattern, &$content, &$childContent)
          {
              $content = preg_replace('/\\s\\?>$/', '', $content);
              $childContent = preg_replace('/^<\\?(?:php)?\\s/', '', $childContent);
              if ($commentPattern &&

      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

          protected function formatAttributes(MarkupElement $element)

      Class extends undeclared class \Phug\Formatter\Format\XhtmlFormat
      Open

      abstract class AbstractTwigFormat extends XhtmlFormat
      Severity: Critical
      Found in src/Phug/Formatter/AbstractTwigFormat.php by phan

      Reference to undeclared class \Phug\Formatter\Format\XhtmlFormat
      Open

              parent::__construct($formatter);
      Severity: Critical
      Found in src/Phug/Formatter/AbstractTwigFormat.php by phan

      Call to method getAssignments from undeclared class \Phug\Formatter\Element\MarkupElement
      Open

              foreach ($element->getAssignments() as $assignment) {
      Severity: Critical
      Found in src/Phug/Formatter/AbstractTwigFormat.php by phan

      Checking instanceof against undeclared class \Phug\Formatter\Element\CodeElement
      Open

              if ($child instanceof CodeElement &&
      Severity: Critical
      Found in src/Phug/Formatter/AbstractTwigFormat.php by phan

      Call to undeclared method \Phug\Formatter\AbstractTwigFormat::getChildrenIterator
      Open

              foreach ($this->getChildrenIterator($element) as $child) {
      Severity: Critical
      Found in src/Phug/Formatter/AbstractTwigFormat.php by phan

      Parameter $element has undeclared type \Phug\Formatter\ElementInterface
      Open

          protected function formatElementChildren(ElementInterface $element, $indentStep = 1)

      Parameter $formatter has undeclared type ?\Phug\Formatter
      Open

          public function __construct(Formatter $formatter = null)

      Call to undeclared method \Phug\Formatter\AbstractTwigFormat::setOptionsRecursive
      Open

              $this
      Severity: Critical
      Found in src/Phug/Formatter/AbstractTwigFormat.php by phan

      Reference to undeclared property \Phug\Formatter\AbstractTwigFormat->formatter
      Open

              $this->formatter->setLevel($indentLevel + $indentStep);

      Reference to undeclared property \Phug\Formatter\AbstractTwigFormat->formatter
      Open

              $this->formatter->setLevel($indentLevel);

      Reference to undeclared property \Phug\Formatter\AbstractTwigFormat->formatter
      Open

                          $pugModuleName = '$'.$this->formatter->getOption('dependencies_storage');

      Reference to undeclared property \Phug\Formatter\AbstractTwigFormat->formatter
      Open

              $indentLevel = $this->formatter->getLevel();

      Call to method getAttributes from undeclared class \Phug\Formatter\Element\MarkupElement
      Open

              foreach ($element->getAttributes() as $attribute) {
      Severity: Critical
      Found in src/Phug/Formatter/AbstractTwigFormat.php by phan

      Checking instanceof against undeclared class \Phug\Formatter\Element\CodeElement
      Open

                  $previous instanceof CodeElement &&
      Severity: Critical
      Found in src/Phug/Formatter/AbstractTwigFormat.php by phan

      Call to undeclared method \Phug\Formatter\AbstractTwigFormat::getOption
      Open

              $commentPattern = $this->getOption('debug');
      Severity: Critical
      Found in src/Phug/Formatter/AbstractTwigFormat.php by phan

      Checking instanceof against undeclared class \Phug\Formatter\ElementInterface
      Open

                  if ($child instanceof ElementInterface) {
      Severity: Critical
      Found in src/Phug/Formatter/AbstractTwigFormat.php by phan

      Call to undeclared method \Phug\Formatter\AbstractTwigFormat::format
      Open

                  $code .= $this->format($attribute);
      Severity: Critical
      Found in src/Phug/Formatter/AbstractTwigFormat.php by phan

      Call to undeclared method \Phug\Formatter\AbstractTwigFormat::format
      Open

                  $code .= $this->format($assignment);
      Severity: Critical
      Found in src/Phug/Formatter/AbstractTwigFormat.php by phan

      Call to method isCodeBlock from undeclared class \Phug\Formatter\Element\CodeElement
      Open

                  $previous->isCodeBlock()
      Severity: Critical
      Found in src/Phug/Formatter/AbstractTwigFormat.php by phan

      Reference to undeclared property \Phug\Formatter\AbstractTwigFormat->formatter
      Open

              $childContent = $this->formatter->format($child);

      Reference to undeclared property \Phug\Formatter\AbstractTwigFormat->formatter
      Open

              return $this->mustBeHandleWithPhp($input, '$'.$this->formatter->getOption('dependencies_storage'))

      There are no issues that match your filters.

      Category
      Status