#7926 closed enhancement (fixed)
Automated linting for PHP versions
Reported by: | boonebgorges | Owned by: | netweb |
---|---|---|---|
Milestone: | 4.0 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Build/Test Tools | Keywords: | has-patch commit |
Cc: |
Description
On a handful of occasions over the last few releases, we've included syntax that is incompatible with a version of PHP that we claim to support. See eg #7925. We could help to avoid this by adding some linting to our Travis CI framework.
Here's one possible approach: https://hakre.wordpress.com/2015/11/10/linting-php-files-in-parallel-on-travis/
Another is a PHP script that I cobbled together for a client: https://github.com/livinglab/openlab/blob/master/developer/lint-php.php. This approach is nice because we can easily define a blacklist.
Attachments (3)
Change History (10)
#1
@
6 years ago
- Keywords has-patch added; needs-patch removed
- Milestone changed from Awaiting Contributions to 4.0
#2
follow-up:
↓ 3
@
6 years ago
7926.grunt.diff is maybe smarter - it uses a grunt task for linting, so everything's centralized. This approach could use the eyes of @netweb, as it does things to my local npm-shrinkwrap that I don't understand.
#3
in reply to:
↑ 2
@
6 years ago
- Keywords commit added; 2nd-opinion removed
Replying to boonebgorges:
7926.grunt.diff is maybe smarter - it uses a grunt task for linting, so everything's centralized.
Works for me +1
This approach could use the eyes of @netweb, as it does things to my local npm-shrinkwrap that I don't understand.
I've added a .npmrc
file to 7926.grunt.2.diff that will now use ~
(tilde) as the default semver prefix instead of the default ^
(caret) and also updated the npm-shrinkwrap.json
file with all the required changes in this ticket. WordPress itself has also made this switch, or if it hasn't its just because it hasn't been committed to trunk.
Not a blocker for this ticket but I'm wondering if the grunt phplint
ask should also operate on Travis CI accross multiple PHP versions? 💥
#5
@
6 years ago
- Milestone 4.0 deleted
- Resolution set to invalid
- Status changed from new to closed
Thanks, @netweb !
Not a blocker for this ticket but I'm wondering if the grunt phplint ask should also operate on Travis CI accross multiple PHP versions? 💥
Ah yes, when I added it to grunt commit
, I forgot it'd need to be handled separately for Travis. As part of travis:phpunit
, it ought to be run across the whole matrix.
Let's put this in and see what happens.
7926.diff is a first pass at a linting script. It doesn't currently have any exclusions, but the infrastructure is there for it. It runs across all PHP files, including tests.
Note that this kind of fix doesn't actually catch the kind of incompatibility discussed in #7925. PHP's linter doesn't execute files to test for failures, it only scans for improper syntax. Something like #7925 could perhaps be caught with a PHPUnit test, or with static code analysis.
That being said, I think this kind of linting still have value. Any thoughts?