Skip to content

Commit

Permalink
Add error identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed May 26, 2023
1 parent ea07b96 commit 6ec9016
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Rule/Nette/DoNotExtendNetteObjectRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function processNode(Node $node, Scope $scope): array
$classReflection->getDisplayName(),
'Nette\Object',
'Nette\SmartObject'
))->build(),
))->identifier('class.extendsNetteObject')->build(),
];
}

Expand Down
4 changes: 3 additions & 1 deletion src/Rule/Nette/RegularExpressionPatternRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ public function processNode(Node $node, Scope $scope): array
continue;
}

$errors[] = RuleErrorBuilder::message(sprintf('Regex pattern is invalid: %s', $errorMessage))->build();
$errors[] = RuleErrorBuilder::message(sprintf('Regex pattern is invalid: %s', $errorMessage))
->identifier('regexp.pattern')
->build();
}

return $errors;
Expand Down
3 changes: 2 additions & 1 deletion src/Rule/Nette/RethrowExceptionRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use PhpParser\Node\Stmt\TryCatch;
use PHPStan\Analyser\Scope;
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleErrorBuilder;
use PHPStan\Type\ObjectType;
use PHPStan\Type\TypeCombinator;
use Throwable;
Expand Down Expand Up @@ -86,7 +87,7 @@ public function processNode(Node $node, Scope $scope): array
}
}

$messages[] = sprintf('Exception %s needs to be rethrown.', $exceptionName);
$messages[] = RuleErrorBuilder::message(sprintf('Exception %s needs to be rethrown.', $exceptionName))->identifier('nette.rethrowException')->build();
}

return $messages;
Expand Down

0 comments on commit 6ec9016

Please sign in to comment.