Skip to content

phplint GitHub last commit

phplint documentation

phplint - GitHub

Configuration in MegaLinter

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 files
Ex: [".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 name
Use 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

MegaLinter Flavours

This linter is available in the following flavours

Flavor Description Embedded linters Info
all Default MegaLinter Flavor 97 Docker Image Size (tag) Docker Pulls
php Optimized for PHP based projects 46 Docker Image Size (tag) Docker Pulls

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

Example calls

phplint myfile.php
phplint mydir
phplint mydir myfile.php
phplint mydir -vvv

Help content

Description:
  Lint something

Usage:
  phplint [options] [--] [<path>...]

Arguments:
  path                               Path to file or directory to lint.

Options:
      --exclude=EXCLUDE              Path to file or directory to exclude from linting (multiple values allowed)
      --extensions=EXTENSIONS        Check only files with selected extensions (default: php)
  -j, --jobs=JOBS                    Number of parraled jobs to run (default: 5)
  -c, --configuration=CONFIGURATION  Read configuration from config file (default: ./.phplint.yml).
      --no-configuration             Ignore default configuration file (default: ./.phplint.yml).
      --no-cache                     Ignore cached data.
      --cache=CACHE                  Path to the cache file.
      --no-progress                  Hide the progress output.
      --json[=JSON]                  Path to store JSON results.
      --xml[=XML]                    Path to store JUnit XML results.
  -w, --warning                      Also show warnings.
  -q, --quiet                        Do not output any message
  -h, --help                         Display help for the given command. When no command is given display help for the list command
  -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
  -nf, --no-files-exit-code          Throw error if no files processed.
  -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 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/php7 100 \
    && update-alternatives --install /usr/bin/php php /usr/bin/php8 10

# Linter install
RUN composer global require overtrue/phplint ^3.0 \
    && composer global config bin-dir --absolute

ENV PATH="/root/.composer/vendor/bin:$PATH"