Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved getPsalmHelpText() to Cli\Psalm #7280

Merged
merged 1 commit into from Jan 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
167 changes: 166 additions & 1 deletion src/Psalm/Internal/Cli/Psalm.php
Expand Up @@ -192,7 +192,7 @@ public static function run(array $argv): void


if (array_key_exists('h', $options)) {
echo CliUtils::getPsalmHelpText();
echo self::getHelpText();
/*
--shepherd[=host]
Send data to Shepherd, Psalm's GitHub integration tool.
Expand Down Expand Up @@ -1173,4 +1173,169 @@ private static function generateStubs(
);
}
}

/**
* @psalm-pure
*/
private static function getHelpText(): string
{
return <<<HELP
Usage:
psalm [options] [file...]

Basic configuration:
-c, --config=psalm.xml
Path to a psalm.xml configuration file. Run psalm --init to create one.

--use-ini-defaults
Use PHP-provided ini defaults for memory and error display

--memory-limit=LIMIT
Use a specific memory limit. Cannot be combined with --use-ini-defaults

--disable-extension=[extension]
Used to disable certain extensions while Psalm is running.

--threads=INT
If greater than one, Psalm will run analysis on multiple threads, speeding things up.

--no-diff
Turns off Psalm’s diff mode, checks all files regardless of whether they’ve changed.

--php-version=PHP_VERSION
Explicitly set PHP version to analyse code against.

Surfacing issues:
--show-info[=BOOLEAN]
Show non-exception parser findings (defaults to false).

--show-snippet[=true]
Show code snippets with errors. Options are 'true' or 'false'

--find-dead-code[=auto]
--find-unused-code[=auto]
Look for unused code. Options are 'auto' or 'always'. If no value is specified, default is 'auto'

--find-unused-psalm-suppress
Finds all @psalm-suppress annotations that aren’t used

--find-references-to=[class|method|property]
Searches the codebase for references to the given fully-qualified class or method,
where method is in the format class::methodName

--no-suggestions
Hide suggestions

--taint-analysis
Run Psalm in taint analysis mode – see https://psalm.dev/docs/security_analysis for more info

--dump-taint-graph=OUTPUT_PATH
Output the taint graph using the DOT language – requires --taint-analysis

Issue baselines:
--set-baseline=PATH
Save all current error level issues to a file, to mark them as info in subsequent runs

Add --include-php-versions to also include a list of PHP extension versions

--use-baseline=PATH
Allows you to use a baseline other than the default baseline provided in your config

--ignore-baseline
Ignore the error baseline

--update-baseline
Update the baseline by removing fixed issues. This will not add new issues to the baseline

Add --include-php-versions to also include a list of PHP extension versions

Plugins:
--plugin=PATH
Executes a plugin, an alternative to using the Psalm config

Output:
-m, --monochrome
Enable monochrome output

--output-format=console
Changes the output format.
Available formats: compact, console, text, emacs, json, pylint, xml, checkstyle, junit, sonarqube, github,
phpstorm, codeclimate

--no-progress
Disable the progress indicator

--long-progress
Use a progress indicator suitable for Continuous Integration logs

--stats
Shows a breakdown of Psalm’s ability to infer types in the codebase

Reports:
--report=PATH
The path where to output report file. The output format is based on the file extension.
(Currently supported formats: ".json", ".xml", ".txt", ".emacs", ".pylint", ".console",
".sarif", "checkstyle.xml", "sonarqube.json", "codeclimate.json", "summary.json", "junit.xml")

--report-show-info[=BOOLEAN]
Whether the report should include non-errors in its output (defaults to true)

Caching:
--clear-cache
Clears all cache files that Psalm uses for this specific project

--clear-global-cache
Clears all cache files that Psalm uses for all projects

--no-cache
Runs Psalm without using cache

--no-reflection-cache
Runs Psalm without using cached representations of unchanged classes and files.
Useful if you want the afterClassLikeVisit plugin hook to run every time you visit a file.

--no-file-cache
Runs Psalm without using caching every single file for later diffing.
This reduces the space Psalm uses on disk and file I/O.

Miscellaneous:
-h, --help
Display this help message

-v, --version
Display the Psalm version

-i, --init [source_dir=src] [level=3]
Create a psalm config file in the current directory that points to [source_dir]
at the required level, from 1, most strict, to 8, most permissive.

--debug
Debug information

--debug-by-line
Debug information on a line-by-line level

--debug-emitted-issues
Print a php backtrace to stderr when emitting issues.

-r, --root
If running Psalm globally you’ll need to specify a project root. Defaults to cwd

--generate-json-map=PATH
Generate a map of node references and types in JSON format, saved to the given path.

--generate-stubs=PATH
Generate stubs for the project and dump the file in the given path

--shepherd[=host]
Send data to Shepherd, Psalm’s GitHub integration tool.

--alter
Run Psalter

--language-server
Run Psalm Language Server

HELP;
}
}
165 changes: 0 additions & 165 deletions src/Psalm/Internal/CliUtils.php
Expand Up @@ -322,171 +322,6 @@ public static function getPathsToCheck($f_paths): ?array
return $paths_to_check;
}

/**
* @psalm-pure
* @todo move to Psalm\Internal\Cli\Psalm once \Psalm\getPsalmHelpText() is removed in Psalm 5
*/
public static function getPsalmHelpText(): string
{
return <<<HELP
Usage:
psalm [options] [file...]

Basic configuration:
-c, --config=psalm.xml
Path to a psalm.xml configuration file. Run psalm --init to create one.

--use-ini-defaults
Use PHP-provided ini defaults for memory and error display

--memory-limit=LIMIT
Use a specific memory limit. Cannot be combined with --use-ini-defaults

--disable-extension=[extension]
Used to disable certain extensions while Psalm is running.

--threads=INT
If greater than one, Psalm will run analysis on multiple threads, speeding things up.

--no-diff
Turns off Psalm’s diff mode, checks all files regardless of whether they’ve changed.

--php-version=PHP_VERSION
Explicitly set PHP version to analyse code against.

Surfacing issues:
--show-info[=BOOLEAN]
Show non-exception parser findings (defaults to false).

--show-snippet[=true]
Show code snippets with errors. Options are 'true' or 'false'

--find-dead-code[=auto]
--find-unused-code[=auto]
Look for unused code. Options are 'auto' or 'always'. If no value is specified, default is 'auto'

--find-unused-psalm-suppress
Finds all @psalm-suppress annotations that aren’t used

--find-references-to=[class|method|property]
Searches the codebase for references to the given fully-qualified class or method,
where method is in the format class::methodName

--no-suggestions
Hide suggestions

--taint-analysis
Run Psalm in taint analysis mode – see https://psalm.dev/docs/security_analysis for more info

--dump-taint-graph=OUTPUT_PATH
Output the taint graph using the DOT language – requires --taint-analysis

Issue baselines:
--set-baseline=PATH
Save all current error level issues to a file, to mark them as info in subsequent runs

Add --include-php-versions to also include a list of PHP extension versions

--use-baseline=PATH
Allows you to use a baseline other than the default baseline provided in your config

--ignore-baseline
Ignore the error baseline

--update-baseline
Update the baseline by removing fixed issues. This will not add new issues to the baseline

Add --include-php-versions to also include a list of PHP extension versions

Plugins:
--plugin=PATH
Executes a plugin, an alternative to using the Psalm config

Output:
-m, --monochrome
Enable monochrome output

--output-format=console
Changes the output format.
Available formats: compact, console, text, emacs, json, pylint, xml, checkstyle, junit, sonarqube, github,
phpstorm, codeclimate

--no-progress
Disable the progress indicator

--long-progress
Use a progress indicator suitable for Continuous Integration logs

--stats
Shows a breakdown of Psalm’s ability to infer types in the codebase

Reports:
--report=PATH
The path where to output report file. The output format is based on the file extension.
(Currently supported formats: ".json", ".xml", ".txt", ".emacs", ".pylint", ".console",
".sarif", "checkstyle.xml", "sonarqube.json", "codeclimate.json", "summary.json", "junit.xml")

--report-show-info[=BOOLEAN]
Whether the report should include non-errors in its output (defaults to true)

Caching:
--clear-cache
Clears all cache files that Psalm uses for this specific project

--clear-global-cache
Clears all cache files that Psalm uses for all projects

--no-cache
Runs Psalm without using cache

--no-reflection-cache
Runs Psalm without using cached representations of unchanged classes and files.
Useful if you want the afterClassLikeVisit plugin hook to run every time you visit a file.

--no-file-cache
Runs Psalm without using caching every single file for later diffing.
This reduces the space Psalm uses on disk and file I/O.

Miscellaneous:
-h, --help
Display this help message

-v, --version
Display the Psalm version

-i, --init [source_dir=src] [level=3]
Create a psalm config file in the current directory that points to [source_dir]
at the required level, from 1, most strict, to 8, most permissive.

--debug
Debug information

--debug-by-line
Debug information on a line-by-line level

--debug-emitted-issues
Print a php backtrace to stderr when emitting issues.

-r, --root
If running Psalm globally you’ll need to specify a project root. Defaults to cwd

--generate-json-map=PATH
Generate a map of node references and types in JSON format, saved to the given path.

--generate-stubs=PATH
Generate stubs for the project and dump the file in the given path

--shepherd[=host]
Send data to Shepherd, Psalm’s GitHub integration tool.

--alter
Run Psalter

--language-server
Run Psalm Language Server

HELP;
}

public static function initializeConfig(
?string $path_to_config,
Expand Down