Skip to content

Fix test lint-comment#4986

Merged
staabm merged 8 commits intophpstan:2.1.xfrom
staabm:fix-reg
Feb 18, 2026
Merged

Fix test lint-comment#4986
staabm merged 8 commits intophpstan:2.1.xfrom
staabm:fix-reg

Conversation

@staabm
Copy link
Copy Markdown
Contributor

@staabm staabm commented Feb 18, 2026

fix existing tests and claude instructions.

added a exception when the first line contains the lint-substring but at the wrong position

@@ -467,6 +473,8 @@ private static function isFileLintSkipped(string $file): bool

if (preg_match('~<?php\\s*\\/\\/\s*lint\s*([^\d\s]+)\s*([^\s]+)\s*~i', $firstLine, $m) === 1) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here we can see that for TypeInferenceTestCase to work properly, we expect <?php // lint at the very start

Comment on lines +3 to +16
exec('php vendor/bin/phpunit --group levels --list-tests-xml test-list.xml', $output, $return);
if ($return !== 0) {
throw new RuntimeException(implode("\n", $output));
}

libxml_use_internal_errors(true);
$simpleXml = simplexml_load_file('test-list.xml');
if ($simpleXml === false) {
throw new RuntimeException('Error loading test-list.xml');
$errors = [];
foreach (libxml_get_errors() as $error) {
$errors[] = $error->message;
}

throw new RuntimeException('Error loading test-list.xml: ' . implode(', ', $errors));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure when a underlying error occurs we see a meaningful error with hints for the root-cause

Comment on lines +476 to +477
} elseif (str_contains($firstLine, 'lint')) {
throw new LogicException(sprintf('// lint comment must immediately follow the php starting tag in %s', $file));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the new error which will be triggered

@staabm staabm marked this pull request as ready for review February 18, 2026 10:59
@phpstan-bot
Copy link
Copy Markdown
Collaborator

This pull request has been marked as ready for review.

@staabm staabm merged commit 4557edd into phpstan:2.1.x Feb 18, 2026
640 of 645 checks passed
@staabm staabm deleted the fix-reg branch February 18, 2026 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants