Skip to content

Commit

Permalink
Merge pull request #125 from vitaliiivanovspryker/master
Browse files Browse the repository at this point in the history
Fixed issue PHP Fatal error: Call to a member function getImage() on bool in ModuleConstantsFormingConstantValuesRule.php:47
  • Loading branch information
vitaliiivanovspryker committed Jan 2, 2024
2 parents 705f2f2 + 159dd9c commit 22537ee
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Shared/ModuleConstantsFormingConstantValuesRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace ArchitectureSniffer\Shared;

use PDepend\Source\AST\ASTNode;
use PHPMD\AbstractNode;
use PHPMD\AbstractRule;
use PHPMD\Rule\InterfaceAware;
Expand Down Expand Up @@ -44,7 +45,9 @@ public function apply(AbstractNode $node)

foreach ($node->findChildrenOfType('ConstantDeclarator') as $constant) {
/** @var \PDepend\Source\AST\ASTValue|\PHPMD\AbstractNode $constant */
$value = $constant->getValue()->getValue()->getImage();
$constantValue = $constant->getValue()->getValue();

$value = $constantValue instanceof ASTNode ? $constantValue->getImage() : $constantValue;

$expectedConstantValue = sprintf(
"'%s:%s'",
Expand Down

0 comments on commit 22537ee

Please sign in to comment.