mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Few fixes to make tests pass on windows
* changed / to DIRECTORY_SEPARATOR in expected messages * cahnged most occurences PHP_EOL to "\n" in tests and src * added output buffering in test to avoid marking test as risky
This commit is contained in:
parent
1a97f69d32
commit
15c1a82d8c
@ -567,22 +567,22 @@ class CommentChecker
|
|||||||
*/
|
*/
|
||||||
public static function renderDocComment(array $parsed_doc_comment, $left_padding)
|
public static function renderDocComment(array $parsed_doc_comment, $left_padding)
|
||||||
{
|
{
|
||||||
$doc_comment_text = '/**' . PHP_EOL;
|
$doc_comment_text = '/**' . "\n";
|
||||||
|
|
||||||
$description_lines = null;
|
$description_lines = null;
|
||||||
|
|
||||||
$trimmed_description = trim($parsed_doc_comment['description']);
|
$trimmed_description = trim($parsed_doc_comment['description']);
|
||||||
|
|
||||||
if (!empty($trimmed_description)) {
|
if (!empty($trimmed_description)) {
|
||||||
$description_lines = explode(PHP_EOL, $parsed_doc_comment['description']);
|
$description_lines = explode("\n", $parsed_doc_comment['description']);
|
||||||
|
|
||||||
foreach ($description_lines as $line) {
|
foreach ($description_lines as $line) {
|
||||||
$doc_comment_text .= $left_padding . ' *' . (trim($line) ? ' ' . $line : '') . PHP_EOL;
|
$doc_comment_text .= $left_padding . ' *' . (trim($line) ? ' ' . $line : '') . "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($description_lines && $parsed_doc_comment['specials']) {
|
if ($description_lines && $parsed_doc_comment['specials']) {
|
||||||
$doc_comment_text .= $left_padding . ' *' . PHP_EOL;
|
$doc_comment_text .= $left_padding . ' *' . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($parsed_doc_comment['specials']) {
|
if ($parsed_doc_comment['specials']) {
|
||||||
@ -590,19 +590,19 @@ class CommentChecker
|
|||||||
|
|
||||||
foreach ($parsed_doc_comment['specials'] as $type => $lines) {
|
foreach ($parsed_doc_comment['specials'] as $type => $lines) {
|
||||||
if ($last_type !== null && ($last_type !== 'return' || $last_type !== 'psalm-return')) {
|
if ($last_type !== null && ($last_type !== 'return' || $last_type !== 'psalm-return')) {
|
||||||
$doc_comment_text .= $left_padding . ' *' . PHP_EOL;
|
$doc_comment_text .= $left_padding . ' *' . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($lines as $line) {
|
foreach ($lines as $line) {
|
||||||
$doc_comment_text .= $left_padding . ' * @' . $type . ' '
|
$doc_comment_text .= $left_padding . ' * @' . $type . ' '
|
||||||
. str_replace("\n", "\n" . $left_padding . ' *', $line) . PHP_EOL;
|
. str_replace("\n", "\n" . $left_padding . ' *', $line) . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$last_type = $type;
|
$last_type = $type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$doc_comment_text .= $left_padding . ' */' . PHP_EOL . $left_padding;
|
$doc_comment_text .= $left_padding . ' */' . "\n" . $left_padding;
|
||||||
|
|
||||||
return $doc_comment_text;
|
return $doc_comment_text;
|
||||||
}
|
}
|
||||||
|
@ -271,7 +271,7 @@ class ProjectChecker
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->output_format === self::TYPE_CONSOLE) {
|
if ($this->output_format === self::TYPE_CONSOLE) {
|
||||||
echo 'Scanning files...' . PHP_EOL;
|
echo 'Scanning files...' . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($diff_files === null || $deleted_files === null || count($diff_files) > 200) {
|
if ($diff_files === null || $deleted_files === null || count($diff_files) > 200) {
|
||||||
@ -282,7 +282,7 @@ class ProjectChecker
|
|||||||
$this->codebase->scanFiles();
|
$this->codebase->scanFiles();
|
||||||
} else {
|
} else {
|
||||||
if ($this->debug_output) {
|
if ($this->debug_output) {
|
||||||
echo count($diff_files) . ' changed files' . PHP_EOL;
|
echo count($diff_files) . ' changed files' . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($diff_files) {
|
if ($diff_files) {
|
||||||
@ -298,7 +298,7 @@ class ProjectChecker
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->output_format === self::TYPE_CONSOLE) {
|
if ($this->output_format === self::TYPE_CONSOLE) {
|
||||||
echo 'Analyzing files...' . PHP_EOL;
|
echo 'Analyzing files...' . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->codebase->analyzer->analyzeFiles($this, $this->threads, $this->alter_code);
|
$this->codebase->analyzer->analyzeFiles($this, $this->threads, $this->alter_code);
|
||||||
@ -308,7 +308,7 @@ class ProjectChecker
|
|||||||
);
|
);
|
||||||
|
|
||||||
if ($this->debug_output && $removed_parser_files) {
|
if ($this->debug_output && $removed_parser_files) {
|
||||||
echo 'Removed ' . $removed_parser_files . ' old parser caches' . PHP_EOL;
|
echo 'Removed ' . $removed_parser_files . ' old parser caches' . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($is_diff) {
|
if ($is_diff) {
|
||||||
@ -355,14 +355,14 @@ class ProjectChecker
|
|||||||
$selection_start = $selection_bounds[0] - $snippet_bounds[0];
|
$selection_start = $selection_bounds[0] - $snippet_bounds[0];
|
||||||
$selection_length = $selection_bounds[1] - $selection_bounds[0];
|
$selection_length = $selection_bounds[1] - $selection_bounds[0];
|
||||||
|
|
||||||
echo $location->file_name . ':' . $location->getLineNumber() . PHP_EOL .
|
echo $location->file_name . ':' . $location->getLineNumber() . "\n" .
|
||||||
(
|
(
|
||||||
$this->use_color
|
$this->use_color
|
||||||
? substr($snippet, 0, $selection_start) .
|
? substr($snippet, 0, $selection_start) .
|
||||||
"\e[97;42m" . substr($snippet, $selection_start, $selection_length) .
|
"\e[97;42m" . substr($snippet, $selection_start, $selection_length) .
|
||||||
"\e[0m" . substr($snippet, $selection_length + $selection_start)
|
"\e[0m" . substr($snippet, $selection_length + $selection_start)
|
||||||
: $snippet
|
: $snippet
|
||||||
) . PHP_EOL . PHP_EOL;
|
) . "\n" . "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -379,13 +379,13 @@ class ProjectChecker
|
|||||||
$this->checkDirWithConfig($dir_name, $this->config, true);
|
$this->checkDirWithConfig($dir_name, $this->config, true);
|
||||||
|
|
||||||
if ($this->output_format === self::TYPE_CONSOLE) {
|
if ($this->output_format === self::TYPE_CONSOLE) {
|
||||||
echo 'Scanning files...' . PHP_EOL;
|
echo 'Scanning files...' . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->codebase->scanFiles();
|
$this->codebase->scanFiles();
|
||||||
|
|
||||||
if ($this->output_format === self::TYPE_CONSOLE) {
|
if ($this->output_format === self::TYPE_CONSOLE) {
|
||||||
echo 'Analyzing files...' . PHP_EOL;
|
echo 'Analyzing files...' . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->codebase->analyzer->analyzeFiles($this, $this->threads, $this->alter_code);
|
$this->codebase->analyzer->analyzeFiles($this, $this->threads, $this->alter_code);
|
||||||
@ -510,7 +510,7 @@ class ProjectChecker
|
|||||||
|
|
||||||
if (!$config->isInProjectDirs($file_path)) {
|
if (!$config->isInProjectDirs($file_path)) {
|
||||||
if ($this->debug_output) {
|
if ($this->debug_output) {
|
||||||
echo 'skipping ' . $file_path . PHP_EOL;
|
echo 'skipping ' . $file_path . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
@ -530,7 +530,7 @@ class ProjectChecker
|
|||||||
public function checkFile($file_path)
|
public function checkFile($file_path)
|
||||||
{
|
{
|
||||||
if ($this->debug_output) {
|
if ($this->debug_output) {
|
||||||
echo 'Checking ' . $file_path . PHP_EOL;
|
echo 'Checking ' . $file_path . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->config->hide_external_errors = $this->config->isInProjectDirs($file_path);
|
$this->config->hide_external_errors = $this->config->isInProjectDirs($file_path);
|
||||||
@ -540,13 +540,13 @@ class ProjectChecker
|
|||||||
FileReferenceProvider::loadReferenceCache();
|
FileReferenceProvider::loadReferenceCache();
|
||||||
|
|
||||||
if ($this->output_format === self::TYPE_CONSOLE) {
|
if ($this->output_format === self::TYPE_CONSOLE) {
|
||||||
echo 'Scanning files...' . PHP_EOL;
|
echo 'Scanning files...' . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->codebase->scanFiles();
|
$this->codebase->scanFiles();
|
||||||
|
|
||||||
if ($this->output_format === self::TYPE_CONSOLE) {
|
if ($this->output_format === self::TYPE_CONSOLE) {
|
||||||
echo 'Analyzing files...' . PHP_EOL;
|
echo 'Analyzing files...' . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->codebase->analyzer->analyzeFiles($this, $this->threads, $this->alter_code);
|
$this->codebase->analyzer->analyzeFiles($this, $this->threads, $this->alter_code);
|
||||||
|
@ -138,7 +138,7 @@ class StatementsChecker extends SourceChecker implements StatementsSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($project_checker->debug_lines) {
|
if ($project_checker->debug_lines) {
|
||||||
echo $this->getFilePath() . ':' . $stmt->getLine() . PHP_EOL;
|
echo $this->getFilePath() . ':' . $stmt->getLine() . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -556,7 +556,7 @@ class StatementsChecker extends SourceChecker implements StatementsSource
|
|||||||
$newline_pos = (int)strrpos($file_contents, "\n", $branch_point - strlen($file_contents)) + 1;
|
$newline_pos = (int)strrpos($file_contents, "\n", $branch_point - strlen($file_contents)) + 1;
|
||||||
$indentation = substr($file_contents, $newline_pos, $branch_point - $newline_pos);
|
$indentation = substr($file_contents, $newline_pos, $branch_point - $newline_pos);
|
||||||
FileManipulationBuffer::add($this->getFilePath(), [
|
FileManipulationBuffer::add($this->getFilePath(), [
|
||||||
new FileManipulation($branch_point, $branch_point, $var_id . ' = null;' . PHP_EOL . $indentation),
|
new FileManipulation($branch_point, $branch_point, $var_id . ' = null;' . "\n" . $indentation),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ class Analyzer
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->debug_output) {
|
if ($this->debug_output) {
|
||||||
echo 'Getting ' . $file_path . PHP_EOL;
|
echo 'Getting ' . $file_path . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $file_checker;
|
return $file_checker;
|
||||||
@ -132,7 +132,7 @@ class Analyzer
|
|||||||
$file_checker = $this->getFileChecker($project_checker, $file_path, $filetype_checkers);
|
$file_checker = $this->getFileChecker($project_checker, $file_path, $filetype_checkers);
|
||||||
|
|
||||||
if ($this->debug_output) {
|
if ($this->debug_output) {
|
||||||
echo 'Analyzing ' . $file_checker->getFilePath() . PHP_EOL;
|
echo 'Analyzing ' . $file_checker->getFilePath() . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$file_checker->analyze(null);
|
$file_checker->analyze(null);
|
||||||
@ -288,7 +288,7 @@ class Analyzer
|
|||||||
list($path_mixed_count, $path_nonmixed_count) = $this->mixed_counts[$file_path];
|
list($path_mixed_count, $path_nonmixed_count) = $this->mixed_counts[$file_path];
|
||||||
$stats .= number_format(100 * $path_nonmixed_count / ($path_mixed_count + $path_nonmixed_count), 0)
|
$stats .= number_format(100 * $path_nonmixed_count / ($path_mixed_count + $path_nonmixed_count), 0)
|
||||||
. '% ' . $this->config->shortenFileName($file_path)
|
. '% ' . $this->config->shortenFileName($file_path)
|
||||||
. ' (' . $path_mixed_count . ' mixed)' . PHP_EOL;
|
. ' (' . $path_mixed_count . ' mixed)' . "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,7 +357,7 @@ class Analyzer
|
|||||||
|
|
||||||
if ($docblock_update_count) {
|
if ($docblock_update_count) {
|
||||||
if ($dry_run) {
|
if ($dry_run) {
|
||||||
echo $file_path . ':' . PHP_EOL;
|
echo $file_path . ':' . "\n";
|
||||||
|
|
||||||
$differ = new \PhpCsFixer\Diff\v2_0\Differ(
|
$differ = new \PhpCsFixer\Diff\v2_0\Differ(
|
||||||
new \PhpCsFixer\Diff\GeckoPackages\DiffOutputBuilder\UnifiedDiffOutputBuilder([
|
new \PhpCsFixer\Diff\GeckoPackages\DiffOutputBuilder\UnifiedDiffOutputBuilder([
|
||||||
@ -372,7 +372,7 @@ class Analyzer
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($output_changes) {
|
if ($output_changes) {
|
||||||
echo 'Altering ' . $file_path . PHP_EOL;
|
echo 'Altering ' . $file_path . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->file_provider->setContents($file_path, $existing_contents);
|
$this->file_provider->setContents($file_path, $existing_contents);
|
||||||
|
@ -259,7 +259,7 @@ class ClassLikes
|
|||||||
&& !$this->classlike_storage_provider->has($fq_class_name_lc)
|
&& !$this->classlike_storage_provider->has($fq_class_name_lc)
|
||||||
) {
|
) {
|
||||||
if ($this->debug_output) {
|
if ($this->debug_output) {
|
||||||
echo 'Last-chance attempt to hydrate ' . $fq_class_name . PHP_EOL;
|
echo 'Last-chance attempt to hydrate ' . $fq_class_name . "\n";
|
||||||
}
|
}
|
||||||
// attempt to load in the class
|
// attempt to load in the class
|
||||||
$this->scanner->queueClassLikeForScanning($fq_class_name);
|
$this->scanner->queueClassLikeForScanning($fq_class_name);
|
||||||
@ -308,7 +308,7 @@ class ClassLikes
|
|||||||
&& !$this->classlike_storage_provider->has($fq_class_name_lc)
|
&& !$this->classlike_storage_provider->has($fq_class_name_lc)
|
||||||
) {
|
) {
|
||||||
if ($this->debug_output) {
|
if ($this->debug_output) {
|
||||||
echo 'Last-chance attempt to hydrate ' . $fq_class_name . PHP_EOL;
|
echo 'Last-chance attempt to hydrate ' . $fq_class_name . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// attempt to load in the class
|
// attempt to load in the class
|
||||||
|
@ -67,7 +67,7 @@ class Populator
|
|||||||
public function populateCodebase()
|
public function populateCodebase()
|
||||||
{
|
{
|
||||||
if ($this->debug_output) {
|
if ($this->debug_output) {
|
||||||
echo 'ClassLikeStorage is populating' . PHP_EOL;
|
echo 'ClassLikeStorage is populating' . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->classlike_storage_provider->getAll() as $class_storage) {
|
foreach ($this->classlike_storage_provider->getAll() as $class_storage) {
|
||||||
@ -79,11 +79,11 @@ class Populator
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->debug_output) {
|
if ($this->debug_output) {
|
||||||
echo 'ClassLikeStorage is populated' . PHP_EOL;
|
echo 'ClassLikeStorage is populated' . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->debug_output) {
|
if ($this->debug_output) {
|
||||||
echo 'FileStorage is populating' . PHP_EOL;
|
echo 'FileStorage is populating' . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$all_file_storage = $this->file_storage_provider->getAll();
|
$all_file_storage = $this->file_storage_provider->getAll();
|
||||||
@ -129,7 +129,7 @@ class Populator
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->debug_output) {
|
if ($this->debug_output) {
|
||||||
echo 'FileStorage is populated' . PHP_EOL;
|
echo 'FileStorage is populated' . "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ class Populator
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->debug_output) {
|
if ($this->debug_output) {
|
||||||
echo 'Have populated ' . $storage->name . PHP_EOL;
|
echo 'Have populated ' . $storage->name . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$storage->populated = true;
|
$storage->populated = true;
|
||||||
|
@ -224,7 +224,7 @@ class Scanner
|
|||||||
if (!isset($this->classlike_files[$fq_classlike_name_lc])) {
|
if (!isset($this->classlike_files[$fq_classlike_name_lc])) {
|
||||||
if ($classlikes->doesClassLikeExist($fq_classlike_name_lc)) {
|
if ($classlikes->doesClassLikeExist($fq_classlike_name_lc)) {
|
||||||
if ($this->debug_output) {
|
if ($this->debug_output) {
|
||||||
echo 'Using reflection to get metadata for ' . $fq_classlike_name . PHP_EOL;
|
echo 'Using reflection to get metadata for ' . $fq_classlike_name . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$reflected_class = new \ReflectionClass($fq_classlike_name);
|
$reflected_class = new \ReflectionClass($fq_classlike_name);
|
||||||
@ -385,7 +385,7 @@ class Scanner
|
|||||||
|
|
||||||
if ($composer_file_path && file_exists($composer_file_path)) {
|
if ($composer_file_path && file_exists($composer_file_path)) {
|
||||||
if ($this->debug_output) {
|
if ($this->debug_output) {
|
||||||
echo 'Using composer to locate file for ' . $fq_class_name . PHP_EOL;
|
echo 'Using composer to locate file for ' . $fq_class_name . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$classlikes->addFullyQualifiedClassLikeName(
|
$classlikes->addFullyQualifiedClassLikeName(
|
||||||
@ -404,7 +404,7 @@ class Scanner
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if ($this->debug_output) {
|
if ($this->debug_output) {
|
||||||
echo 'Using reflection to locate file for ' . $fq_class_name . PHP_EOL;
|
echo 'Using reflection to locate file for ' . $fq_class_name . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$reflected_class = new \ReflectionClass($fq_class_name);
|
$reflected_class = new \ReflectionClass($fq_class_name);
|
||||||
|
@ -141,7 +141,7 @@ class FunctionDocblockManipulator
|
|||||||
$char = $chars[$i];
|
$char = $chars[$i];
|
||||||
|
|
||||||
switch ($char) {
|
switch ($char) {
|
||||||
case PHP_EOL:
|
case "\n":
|
||||||
$in_single_line_comment = false;
|
$in_single_line_comment = false;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ class FunctionDocblockManipulator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$preceding_newline_pos = strrpos($file_contents, PHP_EOL, $this->docblock_end - strlen($file_contents));
|
$preceding_newline_pos = strrpos($file_contents, "\n", $this->docblock_end - strlen($file_contents));
|
||||||
|
|
||||||
if ($preceding_newline_pos === false) {
|
if ($preceding_newline_pos === false) {
|
||||||
$this->indentation = '';
|
$this->indentation = '';
|
||||||
|
@ -240,7 +240,7 @@ class IssueBuffer
|
|||||||
}
|
}
|
||||||
|
|
||||||
$issue_string .= ': ' . $issue_data['type'] . ' - ' . $issue_data['file_name'] . ':' .
|
$issue_string .= ': ' . $issue_data['type'] . ' - ' . $issue_data['file_name'] . ':' .
|
||||||
$issue_data['line_from'] . ':' . $issue_data['column_from'] . ' - ' . $issue_data['message'] . PHP_EOL;
|
$issue_data['line_from'] . ':' . $issue_data['column_from'] . ' - ' . $issue_data['message'] . "\n";
|
||||||
|
|
||||||
$snippet = $issue_data['snippet'];
|
$snippet = $issue_data['snippet'];
|
||||||
|
|
||||||
@ -252,7 +252,7 @@ class IssueBuffer
|
|||||||
|
|
||||||
$issue_string .= substr($snippet, 0, $selection_start) .
|
$issue_string .= substr($snippet, 0, $selection_start) .
|
||||||
($is_error ? "\e[97;41m" : "\e[30;47m") . substr($snippet, $selection_start, $selection_length) .
|
($is_error ? "\e[97;41m" : "\e[30;47m") . substr($snippet, $selection_start, $selection_length) .
|
||||||
"\e[0m" . substr($snippet, $selection_length + $selection_start) . PHP_EOL;
|
"\e[0m" . substr($snippet, $selection_length + $selection_start) . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $issue_string;
|
return $issue_string;
|
||||||
@ -297,7 +297,7 @@ class IssueBuffer
|
|||||||
$scanned_files = $project_checker->codebase->scanner->getScannedFiles();
|
$scanned_files = $project_checker->codebase->scanner->getScannedFiles();
|
||||||
Provider\FileReferenceProvider::updateReferenceCache($project_checker, $scanned_files);
|
Provider\FileReferenceProvider::updateReferenceCache($project_checker, $scanned_files);
|
||||||
|
|
||||||
echo PHP_EOL;
|
echo "\n";
|
||||||
|
|
||||||
$error_count = 0;
|
$error_count = 0;
|
||||||
$info_count = 0;
|
$info_count = 0;
|
||||||
@ -341,42 +341,42 @@ class IssueBuffer
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo str_repeat('-', 30) . PHP_EOL;
|
echo str_repeat('-', 30) . "\n";
|
||||||
|
|
||||||
if ($error_count) {
|
if ($error_count) {
|
||||||
echo ($project_checker->use_color
|
echo ($project_checker->use_color
|
||||||
? "\e[0;31m" . $error_count . " errors\e[0m"
|
? "\e[0;31m" . $error_count . " errors\e[0m"
|
||||||
: $error_count . ' errors'
|
: $error_count . ' errors'
|
||||||
) . ' found' . PHP_EOL;
|
) . ' found' . "\n";
|
||||||
} else {
|
} else {
|
||||||
echo 'No errors found!' . PHP_EOL;
|
echo 'No errors found!' . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($info_count) {
|
if ($info_count) {
|
||||||
echo str_repeat('-', 30) . PHP_EOL;
|
echo str_repeat('-', 30) . "\n";
|
||||||
|
|
||||||
echo $info_count . ' other issues found.' . PHP_EOL
|
echo $info_count . ' other issues found.' . "\n"
|
||||||
. 'You can hide them with ' .
|
. 'You can hide them with ' .
|
||||||
($project_checker->use_color ? "\e[30;48;5;195m--show-info=false\e[0m" : '--show-info=false') . PHP_EOL;
|
($project_checker->use_color ? "\e[30;48;5;195m--show-info=false\e[0m" : '--show-info=false') . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
echo str_repeat('-', 30) . PHP_EOL . PHP_EOL;
|
echo str_repeat('-', 30) . "\n" . "\n";
|
||||||
|
|
||||||
if ($start_time) {
|
if ($start_time) {
|
||||||
echo 'Checks took ' . number_format((float)microtime(true) - $start_time, 2) . ' seconds';
|
echo 'Checks took ' . number_format((float)microtime(true) - $start_time, 2) . ' seconds';
|
||||||
echo ' and used ' . number_format(memory_get_peak_usage() / (1024 * 1024), 3) . 'MB of memory' . PHP_EOL;
|
echo ' and used ' . number_format(memory_get_peak_usage() / (1024 * 1024), 3) . 'MB of memory' . "\n";
|
||||||
|
|
||||||
$nonmixed_percentage = $project_checker->codebase->analyzer->getNonMixedPercentage();
|
$nonmixed_percentage = $project_checker->codebase->analyzer->getNonMixedPercentage();
|
||||||
|
|
||||||
if ($is_full) {
|
if ($is_full) {
|
||||||
echo 'Psalm was able to infer types for ' . number_format($nonmixed_percentage, 3) . '%'
|
echo 'Psalm was able to infer types for ' . number_format($nonmixed_percentage, 3) . '%'
|
||||||
. ' of the codebase' . PHP_EOL;
|
. ' of the codebase' . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($add_stats) {
|
if ($add_stats) {
|
||||||
echo '-----------------' . PHP_EOL;
|
echo '-----------------' . "\n";
|
||||||
echo $project_checker->codebase->analyzer->getNonMixedStats();
|
echo $project_checker->codebase->analyzer->getNonMixedStats();
|
||||||
echo PHP_EOL;
|
echo "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,7 +398,7 @@ class IssueBuffer
|
|||||||
public static function getOutput($format, $useColor)
|
public static function getOutput($format, $useColor)
|
||||||
{
|
{
|
||||||
if ($format === ProjectChecker::TYPE_JSON) {
|
if ($format === ProjectChecker::TYPE_JSON) {
|
||||||
return json_encode(self::$issues_data) . PHP_EOL;
|
return json_encode(self::$issues_data) . "\n";
|
||||||
} elseif ($format === ProjectChecker::TYPE_XML) {
|
} elseif ($format === ProjectChecker::TYPE_XML) {
|
||||||
$xml = Array2XML::createXML('report', ['item' => self::$issues_data]);
|
$xml = Array2XML::createXML('report', ['item' => self::$issues_data]);
|
||||||
|
|
||||||
@ -406,14 +406,14 @@ class IssueBuffer
|
|||||||
} elseif ($format === ProjectChecker::TYPE_EMACS) {
|
} elseif ($format === ProjectChecker::TYPE_EMACS) {
|
||||||
$output = '';
|
$output = '';
|
||||||
foreach (self::$issues_data as $issue_data) {
|
foreach (self::$issues_data as $issue_data) {
|
||||||
$output .= self::getEmacsOutput($issue_data) . PHP_EOL;
|
$output .= self::getEmacsOutput($issue_data) . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
} elseif ($format === ProjectChecker::TYPE_PYLINT) {
|
} elseif ($format === ProjectChecker::TYPE_PYLINT) {
|
||||||
$output = '';
|
$output = '';
|
||||||
foreach (self::$issues_data as $issue_data) {
|
foreach (self::$issues_data as $issue_data) {
|
||||||
$output .= self::getPylintOutput($issue_data) . PHP_EOL;
|
$output .= self::getPylintOutput($issue_data) . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
@ -421,7 +421,7 @@ class IssueBuffer
|
|||||||
|
|
||||||
$output = '';
|
$output = '';
|
||||||
foreach (self::$issues_data as $issue_data) {
|
foreach (self::$issues_data as $issue_data) {
|
||||||
$output .= self::getConsoleOutput($issue_data, $useColor) . PHP_EOL . PHP_EOL;
|
$output .= self::getConsoleOutput($issue_data, $useColor) . "\n" . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
|
@ -67,7 +67,7 @@ class StatementsProvider
|
|||||||
|
|
||||||
if ($stmts === null) {
|
if ($stmts === null) {
|
||||||
if ($debug_output) {
|
if ($debug_output) {
|
||||||
echo 'Parsing ' . $file_path . PHP_EOL;
|
echo 'Parsing ' . $file_path . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmts = self::parseStatementsInFile($file_contents);
|
$stmts = self::parseStatementsInFile($file_contents);
|
||||||
|
@ -64,9 +64,9 @@ class FileScanner implements FileSource
|
|||||||
|
|
||||||
if ($debug_output) {
|
if ($debug_output) {
|
||||||
if ($this->will_analyze) {
|
if ($this->will_analyze) {
|
||||||
echo 'Deep scanning ' . $file_storage->file_path . PHP_EOL;
|
echo 'Deep scanning ' . $file_storage->file_path . "\n";
|
||||||
} else {
|
} else {
|
||||||
echo 'Scanning ' . $file_storage->file_path . PHP_EOL;
|
echo 'Scanning ' . $file_storage->file_path . "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -911,7 +911,7 @@ class AnnotationTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
fooBar("hello");',
|
fooBar("hello");',
|
||||||
'error_message' => 'TooManyArguments - src/somefile.php:8 - Too many arguments for method fooBar '
|
'error_message' => 'TooManyArguments - src' . DIRECTORY_SEPARATOR . 'somefile.php:8 - Too many arguments for method fooBar '
|
||||||
. '- expecting 0 but saw 1',
|
. '- expecting 0 but saw 1',
|
||||||
],
|
],
|
||||||
'missingParamVar' => [
|
'missingParamVar' => [
|
||||||
@ -921,7 +921,7 @@ class AnnotationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
function fooBar(): void {
|
function fooBar(): void {
|
||||||
}',
|
}',
|
||||||
'error_message' => 'InvalidDocblock - src/somefile.php:5 - Badly-formatted @param',
|
'error_message' => 'InvalidDocblock - src' . DIRECTORY_SEPARATOR . 'somefile.php:5 - Badly-formatted @param',
|
||||||
],
|
],
|
||||||
'invalidDocblockReturn' => [
|
'invalidDocblockReturn' => [
|
||||||
'<?php
|
'<?php
|
||||||
@ -982,7 +982,7 @@ class AnnotationTest extends TestCase
|
|||||||
|
|
||||||
$a = new A();
|
$a = new A();
|
||||||
$a->foo = new SomeOtherPropertyType();',
|
$a->foo = new SomeOtherPropertyType();',
|
||||||
'error_message' => 'InvalidPropertyAssignmentValue - src/somefile.php:27 - $a->foo with declared type'
|
'error_message' => 'InvalidPropertyAssignmentValue - src' . DIRECTORY_SEPARATOR . 'somefile.php:27 - $a->foo with declared type'
|
||||||
. ' \'Bar\PropertyType\' cannot',
|
. ' \'Bar\PropertyType\' cannot',
|
||||||
],
|
],
|
||||||
'propertyWriteDocblockInvalidAssignment' => [
|
'propertyWriteDocblockInvalidAssignment' => [
|
||||||
@ -1095,7 +1095,7 @@ class AnnotationTest extends TestCase
|
|||||||
function fooFoo($a): void {
|
function fooFoo($a): void {
|
||||||
echo substr($a, 4, 2);
|
echo substr($a, 4, 2);
|
||||||
}',
|
}',
|
||||||
'error_message' => 'MissingParamType - src/somefile.php:2 - Parameter $a has no provided type,'
|
'error_message' => 'MissingParamType - src' . DIRECTORY_SEPARATOR . 'somefile.php:2 - Parameter $a has no provided type,'
|
||||||
. ' should be string',
|
. ' should be string',
|
||||||
'error_levels' => ['MixedArgument'],
|
'error_levels' => ['MixedArgument'],
|
||||||
],
|
],
|
||||||
@ -1104,7 +1104,7 @@ class AnnotationTest extends TestCase
|
|||||||
function fooFoo($a): void {
|
function fooFoo($a): void {
|
||||||
echo $a . "foo";
|
echo $a . "foo";
|
||||||
}',
|
}',
|
||||||
'error_message' => 'MissingParamType - src/somefile.php:2 - Parameter $a has no provided type,'
|
'error_message' => 'MissingParamType - src' . DIRECTORY_SEPARATOR . 'somefile.php:2 - Parameter $a has no provided type,'
|
||||||
. ' should be string',
|
. ' should be string',
|
||||||
'error_levels' => ['MixedOperand'],
|
'error_levels' => ['MixedOperand'],
|
||||||
],
|
],
|
||||||
@ -1113,7 +1113,7 @@ class AnnotationTest extends TestCase
|
|||||||
function fooFoo($a): void {
|
function fooFoo($a): void {
|
||||||
echo $a + 5;
|
echo $a + 5;
|
||||||
}',
|
}',
|
||||||
'error_message' => 'MissingParamType - src/somefile.php:2 - Parameter $a has no provided type,'
|
'error_message' => 'MissingParamType - src' . DIRECTORY_SEPARATOR . 'somefile.php:2 - Parameter $a has no provided type,'
|
||||||
. ' should be int|float',
|
. ' should be int|float',
|
||||||
'error_levels' => ['MixedOperand', 'MixedArgument'],
|
'error_levels' => ['MixedOperand', 'MixedArgument'],
|
||||||
],
|
],
|
||||||
@ -1122,7 +1122,7 @@ class AnnotationTest extends TestCase
|
|||||||
function fooFoo($a): void {
|
function fooFoo($a): void {
|
||||||
echo $a / 5;
|
echo $a / 5;
|
||||||
}',
|
}',
|
||||||
'error_message' => 'MissingParamType - src/somefile.php:2 - Parameter $a has no provided type,'
|
'error_message' => 'MissingParamType - src' . DIRECTORY_SEPARATOR . 'somefile.php:2 - Parameter $a has no provided type,'
|
||||||
. ' should be int|float',
|
. ' should be int|float',
|
||||||
'error_levels' => ['MixedOperand', 'MixedArgument'],
|
'error_levels' => ['MixedOperand', 'MixedArgument'],
|
||||||
],
|
],
|
||||||
@ -1131,7 +1131,7 @@ class AnnotationTest extends TestCase
|
|||||||
function fooFoo($a): void {
|
function fooFoo($a): void {
|
||||||
echo "$a";
|
echo "$a";
|
||||||
}',
|
}',
|
||||||
'error_message' => 'MissingParamType - src/somefile.php:2 - Parameter $a has no provided type,'
|
'error_message' => 'MissingParamType - src' . DIRECTORY_SEPARATOR . 'somefile.php:2 - Parameter $a has no provided type,'
|
||||||
. ' should be string',
|
. ' should be string',
|
||||||
'error_levels' => ['MixedOperand'],
|
'error_levels' => ['MixedOperand'],
|
||||||
],
|
],
|
||||||
@ -1144,7 +1144,7 @@ class AnnotationTest extends TestCase
|
|||||||
echo substr("hello", $a, 2);
|
echo substr("hello", $a, 2);
|
||||||
}
|
}
|
||||||
}',
|
}',
|
||||||
'error_message' => 'MissingParamType - src/somefile.php:2 - Parameter $a has no provided type,'
|
'error_message' => 'MissingParamType - src' . DIRECTORY_SEPARATOR . 'somefile.php:2 - Parameter $a has no provided type,'
|
||||||
. ' should be int|string',
|
. ' should be int|string',
|
||||||
'error_levels' => ['MixedArgument'],
|
'error_levels' => ['MixedArgument'],
|
||||||
],
|
],
|
||||||
@ -1167,7 +1167,7 @@ class AnnotationTest extends TestCase
|
|||||||
function shouldTakeString($s): void {
|
function shouldTakeString($s): void {
|
||||||
if (is_string($s)) takesString($s);
|
if (is_string($s)) takesString($s);
|
||||||
}',
|
}',
|
||||||
'error_message' => 'MissingParamType - src/somefile.php:4 - Parameter $s has no provided type,'
|
'error_message' => 'MissingParamType - src' . DIRECTORY_SEPARATOR . 'somefile.php:4 - Parameter $s has no provided type,'
|
||||||
. ' could not infer',
|
. ' could not infer',
|
||||||
'error_levels' => ['MixedArgument'],
|
'error_levels' => ['MixedArgument'],
|
||||||
],
|
],
|
||||||
@ -1182,7 +1182,7 @@ class AnnotationTest extends TestCase
|
|||||||
$s = returnsMixed();
|
$s = returnsMixed();
|
||||||
takesString($s);
|
takesString($s);
|
||||||
}',
|
}',
|
||||||
'error_message' => 'MissingParamType - src/somefile.php:7 - Parameter $s has no provided type,'
|
'error_message' => 'MissingParamType - src' . DIRECTORY_SEPARATOR . 'somefile.php:7 - Parameter $s has no provided type,'
|
||||||
. ' could not infer',
|
. ' could not infer',
|
||||||
'error_levels' => ['MixedArgument', 'InvalidReturnType', 'MixedAssignment'],
|
'error_levels' => ['MixedArgument', 'InvalidReturnType', 'MixedAssignment'],
|
||||||
],
|
],
|
||||||
|
@ -211,7 +211,7 @@ class ArrayAccessTest extends TestCase
|
|||||||
'<?php
|
'<?php
|
||||||
$params = ["key" => "value"];
|
$params = ["key" => "value"];
|
||||||
echo $params["fieldName"];',
|
echo $params["fieldName"];',
|
||||||
'error_message' => 'InvalidArrayOffset - src/somefile.php:3 - Cannot access '
|
'error_message' => 'InvalidArrayOffset - src' . DIRECTORY_SEPARATOR . 'somefile.php:3 - Cannot access '
|
||||||
. 'value on variable $params using offset value of',
|
. 'value on variable $params using offset value of',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
@ -260,7 +260,7 @@ class ConfigTest extends TestCase
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function ($issue_name) {
|
function ($issue_name) {
|
||||||
return '<' . $issue_name . ' errorLevel="suppress" />' . PHP_EOL;
|
return '<' . $issue_name . ' errorLevel="suppress" />' . "\n";
|
||||||
},
|
},
|
||||||
self::getAllIssues()
|
self::getAllIssues()
|
||||||
)
|
)
|
||||||
|
@ -27,7 +27,7 @@ class DocumentationTest extends TestCase
|
|||||||
throw new \UnexpectedValueException('Docs are empty');
|
throw new \UnexpectedValueException('Docs are empty');
|
||||||
}
|
}
|
||||||
|
|
||||||
$file_lines = explode(PHP_EOL, $file_contents);
|
$file_lines = explode("\n", $file_contents);
|
||||||
|
|
||||||
$issue_code = [];
|
$issue_code = [];
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ class DocumentationTest extends TestCase
|
|||||||
++$i;
|
++$i;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$current_block .= $file_lines[$i] . PHP_EOL;
|
$current_block .= $file_lines[$i] . "\n";
|
||||||
++$i;
|
++$i;
|
||||||
} while (substr($file_lines[$i], 0, 3) !== '```' && $i < $j);
|
} while (substr($file_lines[$i], 0, 3) !== '```' && $i < $j);
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ class DocumentationTest extends TestCase
|
|||||||
$documented_issues = array_keys($code_blocks);
|
$documented_issues = array_keys($code_blocks);
|
||||||
sort($documented_issues);
|
sort($documented_issues);
|
||||||
|
|
||||||
$this->assertSame(implode(PHP_EOL, $all_issues), implode(PHP_EOL, $documented_issues));
|
$this->assertSame(implode("\n", $all_issues), implode("\n", $documented_issues));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -181,7 +181,7 @@ class DocumentationTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
$invalid_code_data[$issue_name] = [
|
$invalid_code_data[$issue_name] = [
|
||||||
'<?php' . PHP_EOL . $blocks[0],
|
'<?php' . "\n" . $blocks[0],
|
||||||
$issue_name,
|
$issue_name,
|
||||||
$ignored_issues,
|
$ignored_issues,
|
||||||
strpos($issue_name, 'Unused') !== false || strpos($issue_name, 'Unevaluated') !== false,
|
strpos($issue_name, 'Unused') !== false || strpos($issue_name, 'Unevaluated') !== false,
|
||||||
|
@ -659,7 +659,7 @@ class FunctionCallTest extends TestCase
|
|||||||
'<?php
|
'<?php
|
||||||
function fooFoo(int $a): void {}
|
function fooFoo(int $a): void {}
|
||||||
fooFoo(5, "dfd");',
|
fooFoo(5, "dfd");',
|
||||||
'error_message' => 'TooManyArguments - src/somefile.php:3 - Too many arguments for method fooFoo '
|
'error_message' => 'TooManyArguments - src' . DIRECTORY_SEPARATOR . 'somefile.php:3 - Too many arguments for method fooFoo '
|
||||||
. '- expecting 1 but saw 2',
|
. '- expecting 1 but saw 2',
|
||||||
],
|
],
|
||||||
'tooManyArgumentsForConstructor' => [
|
'tooManyArgumentsForConstructor' => [
|
||||||
|
@ -69,7 +69,7 @@ class IssueSuppressionTest extends TestCase
|
|||||||
new C();
|
new C();
|
||||||
}
|
}
|
||||||
}',
|
}',
|
||||||
'error_message' => 'UndefinedClass - src/somefile.php:8 - Class or interface C',
|
'error_message' => 'UndefinedClass - src' . DIRECTORY_SEPARATOR . 'somefile.php:8 - Class or interface C',
|
||||||
],
|
],
|
||||||
'undefinedClassOneLineInFileAfter' => [
|
'undefinedClassOneLineInFileAfter' => [
|
||||||
'<?php
|
'<?php
|
||||||
@ -78,7 +78,7 @@ class IssueSuppressionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
new B();
|
new B();
|
||||||
new C();',
|
new C();',
|
||||||
'error_message' => 'UndefinedClass - src/somefile.php:6 - Class or interface C',
|
'error_message' => 'UndefinedClass - src' . DIRECTORY_SEPARATOR . 'somefile.php:6 - Class or interface C',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ class ListTest extends TestCase
|
|||||||
return $this->a;
|
return $this->a;
|
||||||
}
|
}
|
||||||
}',
|
}',
|
||||||
'error_message' => 'InvalidPropertyAssignmentValue - src/somefile.php:11',
|
'error_message' => 'InvalidPropertyAssignmentValue - src' . DIRECTORY_SEPARATOR . 'somefile.php:11',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -1032,7 +1032,7 @@ class LoopScopeTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo $array;',
|
echo $array;',
|
||||||
'error_message' => 'PossiblyUndefinedGlobalVariable - src/somefile.php:3 - Possibly undefined ' .
|
'error_message' => 'PossiblyUndefinedGlobalVariable - src' . DIRECTORY_SEPARATOR . 'somefile.php:3 - Possibly undefined ' .
|
||||||
'global variable $array, first seen on line 3',
|
'global variable $array, first seen on line 3',
|
||||||
],
|
],
|
||||||
'possiblyUndefinedArrayInWhileAndForeach' => [
|
'possiblyUndefinedArrayInWhileAndForeach' => [
|
||||||
@ -1044,7 +1044,7 @@ class LoopScopeTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo $array;',
|
echo $array;',
|
||||||
'error_message' => 'PossiblyUndefinedGlobalVariable - src/somefile.php:4 - Possibly undefined ' .
|
'error_message' => 'PossiblyUndefinedGlobalVariable - src' . DIRECTORY_SEPARATOR . 'somefile.php:4 - Possibly undefined ' .
|
||||||
'global variable $array, first seen on line 4',
|
'global variable $array, first seen on line 4',
|
||||||
],
|
],
|
||||||
'possiblyUndefinedVariableInForeach' => [
|
'possiblyUndefinedVariableInForeach' => [
|
||||||
@ -1054,7 +1054,7 @@ class LoopScopeTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo $car;',
|
echo $car;',
|
||||||
'error_message' => 'PossiblyUndefinedGlobalVariable - src/somefile.php:6 - Possibly undefined ' .
|
'error_message' => 'PossiblyUndefinedGlobalVariable - src' . DIRECTORY_SEPARATOR . 'somefile.php:6 - Possibly undefined ' .
|
||||||
'global variable $car, first seen on line 3',
|
'global variable $car, first seen on line 3',
|
||||||
],
|
],
|
||||||
'possibleUndefinedVariableInForeachAndIfWithBreak' => [
|
'possibleUndefinedVariableInForeachAndIfWithBreak' => [
|
||||||
@ -1067,7 +1067,7 @@ class LoopScopeTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo $a;',
|
echo $a;',
|
||||||
'error_message' => 'PossiblyUndefinedGlobalVariable - src/somefile.php:9 - Possibly undefined ' .
|
'error_message' => 'PossiblyUndefinedGlobalVariable - src' . DIRECTORY_SEPARATOR . 'somefile.php:9 - Possibly undefined ' .
|
||||||
'global variable $a, first seen on line 4',
|
'global variable $a, first seen on line 4',
|
||||||
],
|
],
|
||||||
'possibleUndefinedVariableInForeachAndIf' => [
|
'possibleUndefinedVariableInForeachAndIf' => [
|
||||||
@ -1079,7 +1079,7 @@ class LoopScopeTest extends TestCase
|
|||||||
|
|
||||||
echo $a;
|
echo $a;
|
||||||
}',
|
}',
|
||||||
'error_message' => 'PossiblyUndefinedGlobalVariable - src/somefile.php:7 - Possibly undefined ' .
|
'error_message' => 'PossiblyUndefinedGlobalVariable - src' . DIRECTORY_SEPARATOR . 'somefile.php:7 - Possibly undefined ' .
|
||||||
'global variable $a, first seen on line 4',
|
'global variable $a, first seen on line 4',
|
||||||
],
|
],
|
||||||
'implicitFourthLoopWithBadReturnType' => [
|
'implicitFourthLoopWithBadReturnType' => [
|
||||||
|
@ -267,7 +267,7 @@ class MethodCallTest extends TestCase
|
|||||||
class B extends A {}
|
class B extends A {}
|
||||||
|
|
||||||
$b = new B();',
|
$b = new B();',
|
||||||
'error_message' => 'MissingDependency - src/somefile.php:7',
|
'error_message' => 'MissingDependency - src' . DIRECTORY_SEPARATOR . 'somefile.php:7',
|
||||||
],
|
],
|
||||||
'variableMethodCallOnArray' => [
|
'variableMethodCallOnArray' => [
|
||||||
'<?php
|
'<?php
|
||||||
|
@ -897,7 +897,7 @@ class PropertyTypeTest extends TestCase
|
|||||||
$this->foo = 5;
|
$this->foo = 5;
|
||||||
}
|
}
|
||||||
}',
|
}',
|
||||||
'error_message' => 'MissingPropertyType - src/somefile.php:3 - Property A::$foo does not have a ' .
|
'error_message' => 'MissingPropertyType - src' . DIRECTORY_SEPARATOR . 'somefile.php:3 - Property A::$foo does not have a ' .
|
||||||
'declared type - consider null|int',
|
'declared type - consider null|int',
|
||||||
],
|
],
|
||||||
'missingPropertyTypeWithConstructorInit' => [
|
'missingPropertyTypeWithConstructorInit' => [
|
||||||
@ -909,7 +909,7 @@ class PropertyTypeTest extends TestCase
|
|||||||
$this->foo = 5;
|
$this->foo = 5;
|
||||||
}
|
}
|
||||||
}',
|
}',
|
||||||
'error_message' => 'MissingPropertyType - src/somefile.php:3 - Property A::$foo does not have a ' .
|
'error_message' => 'MissingPropertyType - src' . DIRECTORY_SEPARATOR . 'somefile.php:3 - Property A::$foo does not have a ' .
|
||||||
'declared type - consider int',
|
'declared type - consider int',
|
||||||
],
|
],
|
||||||
'missingPropertyTypeWithConstructorInitAndNull' => [
|
'missingPropertyTypeWithConstructorInitAndNull' => [
|
||||||
@ -925,7 +925,7 @@ class PropertyTypeTest extends TestCase
|
|||||||
$this->foo = null;
|
$this->foo = null;
|
||||||
}
|
}
|
||||||
}',
|
}',
|
||||||
'error_message' => 'MissingPropertyType - src/somefile.php:3 - Property A::$foo does not have a ' .
|
'error_message' => 'MissingPropertyType - src' . DIRECTORY_SEPARATOR . 'somefile.php:3 - Property A::$foo does not have a ' .
|
||||||
'declared type - consider null|int',
|
'declared type - consider null|int',
|
||||||
],
|
],
|
||||||
'missingPropertyTypeWithConstructorInitAndNullDefault' => [
|
'missingPropertyTypeWithConstructorInitAndNullDefault' => [
|
||||||
@ -937,7 +937,7 @@ class PropertyTypeTest extends TestCase
|
|||||||
$this->foo = 5;
|
$this->foo = 5;
|
||||||
}
|
}
|
||||||
}',
|
}',
|
||||||
'error_message' => 'MissingPropertyType - src/somefile.php:3 - Property A::$foo does not have a ' .
|
'error_message' => 'MissingPropertyType - src' . DIRECTORY_SEPARATOR . 'somefile.php:3 - Property A::$foo does not have a ' .
|
||||||
'declared type - consider int|null',
|
'declared type - consider int|null',
|
||||||
],
|
],
|
||||||
'badAssignment' => [
|
'badAssignment' => [
|
||||||
|
@ -505,7 +505,7 @@ class RedundantConditionTest extends TestCase
|
|||||||
/** @psalm-suppress PossiblyNullArgument */
|
/** @psalm-suppress PossiblyNullArgument */
|
||||||
takesA($a);
|
takesA($a);
|
||||||
if ($a instanceof A) {}',
|
if ($a instanceof A) {}',
|
||||||
'error_message' => 'RedundantCondition - src/somefile.php:15',
|
'error_message' => 'RedundantCondition - src' . DIRECTORY_SEPARATOR . 'somefile.php:15',
|
||||||
],
|
],
|
||||||
'replaceFalseType' => [
|
'replaceFalseType' => [
|
||||||
'<?php
|
'<?php
|
||||||
@ -527,7 +527,7 @@ class RedundantConditionTest extends TestCase
|
|||||||
|
|
||||||
if ($b) {}
|
if ($b) {}
|
||||||
}',
|
}',
|
||||||
'error_message' => 'TypeDoesNotContainType - src/somefile.php:7',
|
'error_message' => 'TypeDoesNotContainType - src' . DIRECTORY_SEPARATOR . 'somefile.php:7',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,9 @@ somefile.php:15:6:error - Possibly undefined global variable $a, first seen on l
|
|||||||
IssueBuffer::getOutput(ProjectChecker::TYPE_XML, false)
|
IssueBuffer::getOutput(ProjectChecker::TYPE_XML, false)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
ob_start();
|
||||||
IssueBuffer::finish($this->project_checker, true, 0);
|
IssueBuffer::finish($this->project_checker, true, 0);
|
||||||
|
ob_end_clean();
|
||||||
$this->assertFileExists(__DIR__ . '/test-report.json');
|
$this->assertFileExists(__DIR__ . '/test-report.json');
|
||||||
$this->assertSame('[]
|
$this->assertSame('[]
|
||||||
', file_get_contents(__DIR__ . '/test-report.json'));
|
', file_get_contents(__DIR__ . '/test-report.json'));
|
||||||
|
@ -230,7 +230,7 @@ class ScopeTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo $b;',
|
echo $b;',
|
||||||
'error_message' => 'PossiblyUndefinedGlobalVariable - src/somefile.php:6 - Possibly undefined global '
|
'error_message' => 'PossiblyUndefinedGlobalVariable - src' . DIRECTORY_SEPARATOR . 'somefile.php:6 - Possibly undefined global '
|
||||||
. 'variable $b, first seen on line 3',
|
. 'variable $b, first seen on line 3',
|
||||||
],
|
],
|
||||||
'possiblyUndefinedArrayInIf' => [
|
'possiblyUndefinedArrayInIf' => [
|
||||||
@ -240,7 +240,7 @@ class ScopeTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo $array;',
|
echo $array;',
|
||||||
'error_message' => 'PossiblyUndefinedGlobalVariable - src/somefile.php:3 - Possibly undefined global '
|
'error_message' => 'PossiblyUndefinedGlobalVariable - src' . DIRECTORY_SEPARATOR . 'somefile.php:3 - Possibly undefined global '
|
||||||
. 'variable $array, first seen on line 3',
|
. 'variable $array, first seen on line 3',
|
||||||
],
|
],
|
||||||
'invalidGlobal' => [
|
'invalidGlobal' => [
|
||||||
|
@ -568,7 +568,7 @@ class TraitTest extends TestCase
|
|||||||
$this->foo = 5;
|
$this->foo = 5;
|
||||||
}
|
}
|
||||||
}',
|
}',
|
||||||
'error_message' => 'MissingPropertyType - src/somefile.php:3 - Property T::$foo does not have a ' .
|
'error_message' => 'MissingPropertyType - src' . DIRECTORY_SEPARATOR . 'somefile.php:3 - Property T::$foo does not have a ' .
|
||||||
'declared type - consider null|int',
|
'declared type - consider null|int',
|
||||||
],
|
],
|
||||||
'missingPropertyTypeWithConstructorInit' => [
|
'missingPropertyTypeWithConstructorInit' => [
|
||||||
@ -583,7 +583,7 @@ class TraitTest extends TestCase
|
|||||||
$this->foo = 5;
|
$this->foo = 5;
|
||||||
}
|
}
|
||||||
}',
|
}',
|
||||||
'error_message' => 'MissingPropertyType - src/somefile.php:3 - Property T::$foo does not have a ' .
|
'error_message' => 'MissingPropertyType - src' . DIRECTORY_SEPARATOR . 'somefile.php:3 - Property T::$foo does not have a ' .
|
||||||
'declared type - consider int',
|
'declared type - consider int',
|
||||||
],
|
],
|
||||||
'missingPropertyTypeWithConstructorInitAndNull' => [
|
'missingPropertyTypeWithConstructorInitAndNull' => [
|
||||||
@ -602,7 +602,7 @@ class TraitTest extends TestCase
|
|||||||
$this->foo = null;
|
$this->foo = null;
|
||||||
}
|
}
|
||||||
}',
|
}',
|
||||||
'error_message' => 'MissingPropertyType - src/somefile.php:3 - Property T::$foo does not have a ' .
|
'error_message' => 'MissingPropertyType - src' . DIRECTORY_SEPARATOR . 'somefile.php:3 - Property T::$foo does not have a ' .
|
||||||
'declared type - consider null|int',
|
'declared type - consider null|int',
|
||||||
],
|
],
|
||||||
'missingPropertyTypeWithConstructorInitAndNullDefault' => [
|
'missingPropertyTypeWithConstructorInitAndNullDefault' => [
|
||||||
@ -617,7 +617,7 @@ class TraitTest extends TestCase
|
|||||||
$this->foo = 5;
|
$this->foo = 5;
|
||||||
}
|
}
|
||||||
}',
|
}',
|
||||||
'error_message' => 'MissingPropertyType - src/somefile.php:3 - Property T::$foo does not have a ' .
|
'error_message' => 'MissingPropertyType - src' . DIRECTORY_SEPARATOR . 'somefile.php:3 - Property T::$foo does not have a ' .
|
||||||
'declared type - consider int|null',
|
'declared type - consider int|null',
|
||||||
],
|
],
|
||||||
'redefinedTraitMethodInSubclass' => [
|
'redefinedTraitMethodInSubclass' => [
|
||||||
|
@ -1368,7 +1368,7 @@ class TypeTest extends TestCase
|
|||||||
class C extends A {}
|
class C extends A {}
|
||||||
|
|
||||||
function takesB(B $i): void {}',
|
function takesB(B $i): void {}',
|
||||||
'error_message' => 'TypeCoercion - src/somefile.php:11 - Argument 1 of takesB expects B,'
|
'error_message' => 'TypeCoercion - src' . DIRECTORY_SEPARATOR . 'somefile.php:11 - Argument 1 of takesB expects B,'
|
||||||
. ' parent type A provided',
|
. ' parent type A provided',
|
||||||
],
|
],
|
||||||
'intersectionTypeInterfaceCheckAfterInstanceof' => [
|
'intersectionTypeInterfaceCheckAfterInstanceof' => [
|
||||||
@ -1387,7 +1387,7 @@ class TypeTest extends TestCase
|
|||||||
interface I {}
|
interface I {}
|
||||||
|
|
||||||
function takesI(I $i): void {}',
|
function takesI(I $i): void {}',
|
||||||
'error_message' => 'InvalidArgument - src/somefile.php:9 - Argument 1 of takesI expects I, A provided',
|
'error_message' => 'InvalidArgument - src' . DIRECTORY_SEPARATOR . 'somefile.php:9 - Argument 1 of takesI expects I, A provided',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user