How to properly use phpcs for checking all php files on project directory

808 views Asked by At

I want to perform a check for all php files in my project directory to see if they are compatible with PHP 7.

I installed PHPCompatibility as a phpcs standard and I realised that variations such as .class.php, .lib.php .inc.php
were skipped using only --extensions=php or not specifying any --extensions as per the examples bellow

1) No --extensions

phpcs -p -s -v --standard=PHPCompatibility  /Users/natalisilverio/Sites/php7/ --runtime-set testVersion 7.0  --report-file=phpcs-noExtensions.txt

2) --extensions=php

phpcs -p -s -v --standard=PHPCompatibility  /Users/natalisilverio/Sites/php7/ --runtime-set testVersion 7.0 --extensions=php --report-file=phpcs-phpExtensions.txt

3) Multiple --extensions

phpcs -p -s -v --standard=PHPCompatibility  /Users/natalisilverio/Sites/php7/ --runtime-set testVersion 7.0 --extensions=php,inc.php,lib.php,class.php --report-file=phpcs-multipleExtensions.txt

If I target a specific directory that has an .class.php file and set --extensions=.class.php as an extension I get it listed on my report

phpcs -p -s -v --standard=PHPCompatibility  /Users/natalisilverio/Sites/php7/ --runtime-set testVersion 7.0 --extensions=class.php --report-file=phpcs-classExtensions.txt

I have many 3rd party plugins and I cannot tell which variation they would be using, so I would like to know which is the correct way to correctly check my project folder recursively without setting multiple extensions variations for .php files

0

There are 0 answers