Skip to content

Commit

Permalink
Fix-GH-10933-And-GH-10951
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-worman committed May 4, 2024
1 parent 7d6c88e commit 23c7acc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1338,10 +1338,9 @@ private function visitClassConstDeclaration(
);

$type_location = null;
$suppressed_issues = [];
if ($var_comment !== null && $var_comment->type !== null) {
$suppressed_issues = $var_comment ? $var_comment->suppressed_issues : [];
if ($var_comment && $var_comment->type !== null) {
$const_type = $var_comment->type;
$suppressed_issues = $var_comment->suppressed_issues;

if ($var_comment->type_start !== null
&& $var_comment->type_end !== null
Expand Down Expand Up @@ -1421,7 +1420,9 @@ private function visitClassConstDeclaration(
);



if ($this->codebase->analysis_php_version_id >= 8_03_00
&& !$storage->final
&& $stmt->type === null
) {
IssueBuffer::maybeAdd(
Expand Down
23 changes: 23 additions & 0 deletions tests/MissingClassConstTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,29 @@ class A {
'ignored_issues' => [],
'php_version' => '8.3',
],
'no type; >= PHP 8.3; but class is final' => [
'code' => <<<'PHP'
<?php
final class A {
public const B = 0;
}
PHP,
'assertions' => [],
'ignored_issues' => [],
'php_version' => '8.3',
],
'no type; >= PHP 8.3; but psalm-suppressed' => [
'code' => <<<'PHP'
<?php
class A {
/** @psalm-suppress MissingClassConstType */
public const B = 0;
}
PHP,
'assertions' => [],
'ignored_issues' => [],
'php_version' => '8.3',
],
'no type; < PHP 8.3' => [
'code' => <<<'PHP'
<?php
Expand Down

0 comments on commit 23c7acc

Please sign in to comment.