phplint
phplint documentation
- Version in MegaLinter: 9.0.4
- Visit Official Web Site
- If custom
.phplint.yml
config file isn't found, .phplint.yml will be used
- If custom
Configuration in MegaLinter
- Enable phplint by adding
PHP_PHPLINT
in ENABLE_LINTERS variable - Disable phplint by adding
PHP_PHPLINT
in DISABLE_LINTERS variable
Variable | Description | Default value |
---|---|---|
PHP_PHPLINT_ARGUMENTS | User custom arguments to add in linter CLI call Ex: -s --foo "bar" |
|
PHP_PHPLINT_FILTER_REGEX_INCLUDE | Custom regex including filter Ex: (src\|lib) |
Include every file |
PHP_PHPLINT_FILTER_REGEX_EXCLUDE | Custom regex excluding filter Ex: (test\|examples) |
Exclude no file |
PHP_PHPLINT_CLI_LINT_MODE | Override default CLI lint mode - file : Calls the linter for each file- list_of_files : Call the linter with the list of files as argument- project : Call the linter from the root of the project |
list_of_files |
PHP_PHPLINT_FILE_EXTENSIONS | Allowed file extensions. "*" matches any extension, "" matches empty extension. Empty list excludes all filesEx: [".py", ""] |
[".php"] |
PHP_PHPLINT_FILE_NAMES_REGEX | File name regex filters. Regular expression list for filtering files by their base names using regex full match. Empty list includes all files Ex: ["Dockerfile(-.+)?", "Jenkinsfile"] |
Include every file |
PHP_PHPLINT_PRE_COMMANDS | List of bash commands to run before the linter | None |
PHP_PHPLINT_POST_COMMANDS | List of bash commands to run after the linter | None |
PHP_PHPLINT_CONFIG_FILE | phplint configuration file nameUse LINTER_DEFAULT to let the linter find it |
.phplint.yml |
PHP_PHPLINT_RULES_PATH | Path where to find linter configuration file | Workspace folder, then MegaLinter default rules |
PHP_PHPLINT_DISABLE_ERRORS | Run linter but consider errors as warnings | false |
PHP_PHPLINT_DISABLE_ERRORS_IF_LESS_THAN | Maximum number of errors allowed | 0 |
PHP_PHPLINT_CLI_EXECUTABLE | Override CLI executable | ['phplint'] |
MegaLinter Flavours
This linter is available in the following flavours
Flavor | Description | Embedded linters | Info | |
---|---|---|---|---|
all | Default MegaLinter Flavor | 113 | ||
cupcake | MegaLinter for the most commonly used languages | 81 | ||
php | Optimized for PHP based projects | 50 |
Behind the scenes
How are identified applicable files
- File extensions:
.php
How the linting is performed
- phplint is called once with the list of files as arguments (
list_of_files
CLI lint mode)
Example calls
phplint myfile.php
phplint mydir
phplint mydir myfile.php
phplint mydir -vvv
Help content
Description:
Files syntax check only
Usage:
lint [options] [--] [<path>...]
Arguments:
path Path to file or directory to lint (default: working directory)
Options:
--exclude=EXCLUDE Path to file or directory to exclude from linting (multiple values allowed)
--extensions=EXTENSIONS Check only files with selected extensions (multiple values allowed)
-j, --jobs=JOBS Number of paralleled jobs to run
-c, --configuration=CONFIGURATION Read configuration from config file [default: ".phplint.yml"]
--no-configuration Ignore default configuration file (.phplint.yml)
--cache=CACHE Path to the cache directory
--no-cache Ignore cached data
-p, --progress=PROGRESS Show the progress output
--no-progress Hide the progress output
--log-json[=LOG-JSON] Log scan results in JSON format to file (default: standard output)
--log-junit[=LOG-JUNIT] Log scan results in JUnit XML format to file (default: standard output)
-w, --warning Also show warnings
--memory-limit=MEMORY-LIMIT Memory limit for analysis
--ignore-exit-code Ignore exit codes so there are no "failure" exit code even when no files processed
-h, --help Display help for the given command. When no command is given display help for the lint command
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi|--no-ansi Force (or disable --no-ansi) ANSI output
-n, --no-interaction Do not ask any interactive question
--manifest Show which versions of dependencies are bundled
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Installation on mega-linter Docker image
- Dockerfile commands :
# Parent descriptor install
RUN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" \
&& export GITHUB_AUTH_TOKEN \
&& wget --tries=5 -q -O phive.phar https://phar.io/releases/phive.phar \
&& wget --tries=5 -q -O phive.phar.asc https://phar.io/releases/phive.phar.asc \
&& PHAR_KEY_ID="0x9D8A98B29B2D5D79" \
&& ( gpg --keyserver keyserver.pgp.com --recv-keys "$PHAR_KEY_ID" \
|| gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$PHAR_KEY_ID" \
|| gpg --keyserver pgp.mit.edu --recv-keys "$PHAR_KEY_ID" \
|| gpg --keyserver hkps://keyserver.ubuntu.com --recv-keys "$PHAR_KEY_ID" ) \
&& gpg --verify phive.phar.asc phive.phar \
&& chmod +x phive.phar \
&& mv phive.phar /usr/local/bin/phive \
&& rm phive.phar.asc \
&& update-alternatives --install /usr/bin/php php /usr/bin/php81 110
# Linter install
RUN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && phive --no-progress install overtrue/phplint --force-accept-unsigned -g