Opened 7 years ago
Last modified 7 years ago
#41873 new enhancement
Code Editor: Add PHP linter
Reported by: | westonruter | Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | |
Component: | General | Keywords: | needs-patch |
Focuses: | Cc: |
Description
There is no PHP linter yet when editing PHP in the code editor (powered by CodeMirror, from [41376] for #12423). This would be a good enhancement, PHP syntax errors are the most critical thing to catch prior to saving in order to prevent whitescreening a site. Currently there are linters only for HTML, JS, CSS, and JSON.
See https://github.com/WordPress/better-code-editing/issues/48#issuecomment-327963921:
Props to @rheinardkorf for finding http://glayzzle.com/php-parser/#demo !!
On GitHub: https://github.com/glayzzle/php-parser
I had previously stumbled across the https://github.com/glayzzle/php-linter project but it is empty. I didn't see the other project.
This holds great promise. The only icing on the cake here would be if the parser could be told which PHP version to use, but we could get a list of language features that are added after PHP 5.2 and mark them as errors when the version of PHP on the server is not new enough. Amazing.
See more background on the original GitHub issue: https://github.com/WordPress/better-code-editing/issues/48
Change History (7)
This ticket was mentioned in Slack in #core by westonruter. View the logs.
7 years ago
#3
@
7 years ago
See follow-ups from:
https://twitter.com/ioan_chiriac/status/913498405950943233
https://twitter.com/ioan_chiriac/status/913499955503001600
https://twitter.com/ioan_chiriac/status/913500750403260416
https://twitter.com/ioan_chiriac/status/913501760202985472
https://twitter.com/ioan_chiriac/status/913507662846988288
Last tweet mentions there is a CodeMirror linter using php-linter: https://github.com/glayzzle/codemirror-linter
#4
@
7 years ago
There is now an add-on for PHP linting in CodeMirror available: https://github.com/glayzzle/codemirror-linter
#5
@
7 years ago
See also feature request to add options for targeting allowed PHP language features and functions: https://github.com/glayzzle/codemirror-linter/issues/4
#6
@
7 years ago
- Milestone changed from 4.9 to Future Release
- Priority changed from high to normal
There are some really exciting possibilities for PHP linting now, but we're running up against the beta1 deadline and the php-linter code is still pretty fresh and needs hardening. So I'm punting this for the future. Maybe WordPress 5.0.
Bumping priority to high for visibility and alignment with 4.9 goals, and given proximity to beta 1 deadline.