Skip to content

PHP

Linters

Linter Additional
phpcs
PHP_PHPCS
GitHub stars sarif
phpstan
PHP_PHPSTAN
GitHub stars sarif
psalm
PHP_PSALM
GitHub stars sarif
phplint
PHP_PHPLINT
GitHub stars sarif

Linted files

  • File extensions:
    • .php

Configuration in MegaLinter

Variable Description Default value
PHP_PRE_COMMANDS List of bash commands to run before the linters None
PHP_POST_COMMANDS List of bash commands to run after the linters None
PHP_FILTER_REGEX_INCLUDE Custom regex including filter
PHP_FILTER_REGEX_EXCLUDE Custom regex excluding filter

Behind the scenes

Installation

  • Dockerfile commands :
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="0x6AF725270AB81E04D79442549D8A98B29B2D5D79" \
    && ( gpg --keyserver hkps://keys.openpgp.org --recv-keys "$PHAR_KEY_ID" \
       || gpg --keyserver hkps://keyserver.ubuntu.com --recv-keys "$PHAR_KEY_ID" \
       || gpg --keyserver keyserver.pgp.com --recv-keys "$PHAR_KEY_ID" \
       || gpg --keyserver pgp.mit.edu --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/php83 110

COPY --from=composer/composer:2-bin /composer /usr/bin/composer
ENV PATH="/root/.composer/vendor/bin:${PATH}"