php -l and lint-php.sh

Содержание
Install
Simple example
Complex usage
What it fixed in src/

Install

Nothing to install. php -l ships with every PHP interpreter. The wrapper scripts/lint-php.sh needs only the project Docker image, exactly like the other linters:

php -l src/dev/php/array.php ./scripts/lint-php.sh --help

Simple example

Lint one file after editing it:

php -l src/ru/qa/.php/Rblock.php

No syntax errors detected in src/ru/qa/.php/Rblock.php

Whole-tree syntax check from container/:

./scripts/lint-php.sh

Complex usage

Same selection flags as lint-static.sh: explicit paths, staged changes, or the whole tree. Read-only runs never modify code:

./scripts/lint-php.sh --files src/ru/qa/.php/Rblock.php src/dev/php/linters/ ./scripts/lint-php.sh --staged ./scripts/lint-php.sh --all

php -l is also the safety gate of wrap-long-lines.sh --fix: every file the wrapper touches must pass php -l afterwards, otherwise the file is restored byte-for-byte and reported as failed.

What it fixed in src/

Strictly speaking php -l fixes nothing — it only reports. But it certified the two mass cleanups below:

  1. After the PHPCBF safe-sniff pass (1050 errors in 113 files) and the FileHeader pass (1735 errors in 1734 files): linted: 5105, failures: 0.
  2. After renaming 7 snake_case methods in src/ru/qa/.php/Rblock.php (show_rblock to showRblock and friends) plus 12 callers: no syntax errors in any touched file.

php -l prints Deprecated notices it does not fail on, for example optional parameters declared before required ones in Rblock.php and Page.php. Those are left alone: fixing them is a refactor, not a syntax fix.

Article author: Andrei Olegovich

Похожие статьи
Development with PHP
PHP linters we use
php -l and lint-php.sh
PHPCS: PHP CodeSniffer
phpcs.xml ruleset file
PHPCBF: fix style automatically
wrap-long-lines.sh
PHPStan and Psalm
Изображение баннера

Поиск по сайту

Канал @aofeed Чат @aofeedchat

Контакты и сотрудничество:
Рекомендую наш хостинг beget.ru
Пишите на info@urn.su если Вы:
1. Хотите написать статью для нашего сайта или перевести статью на свой родной язык.
2. Хотите разместить на сайте рекламу, подходящую по тематике.
3. Реклама на моём сайте имеет максимальный уровень цензуры. Если Вы увидели рекламный блок недопустимый для просмотра детьми школьного возраста, вызывающий шок или вводящий в заблуждение - пожалуйста свяжитесь с нами по электронной почте
4. Нашли на сайте ошибку, неточности, баг и т.д. ... .......
5. Статьи можно расшарить в соцсетях, нажав на иконку сети: