Page MenuHomePhabricator

phplint should detect PHP files not having the .php suffix
Closed, DeclinedPublic

Description

I have sent a PHP fatal error in the scap repository (fix: https://gerrit.wikimedia.org/r/#/c/120692 )

EBernhardson wrote:

other repositories run the php linter, could this one too? Since not everything has the .php extension it would probably have to use the magic number(ala /usr/bin/file) to decide or some such.

I guess find / file / xargs php -l would do the job indeed. If you can come up with the shell commands to have it happen I will be more than happy.

We currently use the phplint macro which is:

bin/git-changed-in-head php php5 inc phtml module install  | xargs -n1 -t php -l

http://git.wikimedia.org/blob/integration%2Fjenkins-job-builder-config.git/f630f86f77b4afe1384b4d8bf3d5f0e02cae49ac/macro.yaml#L453

git-changed-in-head comes from integration/jenkins.git which is intended to provides files having changed in HEAD (obviously :D).


Version: wmf-deployment
Severity: normal

Details

Reference
bz63041

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 2:59 AM
bzimport set Reference to bz63041.
bzimport added a subscriber: Unknown Object (MLST).

First stab at a line:

find ./ -type f -print0 | xargs -0 file -k | grep 'PHP script' | cut -d : -f 1 | xargs -n 1 php -l

Will see if it can be a bit cleaner.

hashar set Security to None.
Krinkle renamed this task from phplint should detects PHP files not having the .php suffix to phplint should detect PHP files not having the .php suffix.Mar 2 2015, 3:01 PM
Krinkle removed a subscriber: Unknown Object (MLST).
hashar claimed this task.

The recommended way is now to use composer and the jakub-onderka/php-parallel-lint package. You can then define a list of directories and files to lint:

https://www.mediawiki.org/wiki/Continuous_integration/Entry_points#PHP