Make WordPress Core

Opened 7 days ago

Last modified 108 minutes ago

#41873 new enhancement

Code Editor: Add PHP linter

Reported by: westonruter Owned by:
Milestone: 4.9 Priority: high
Severity: normal Version:
Component: General Keywords: needs-patch
Focuses: Cc:


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 (2)

This ticket was mentioned in Slack in #core by westonruter. View the logs.

4 hours ago

#2 @westonruter
108 minutes ago

  • Priority changed from normal to high

Bumping priority to high for visibility and alignment with 4.9 goals, and given proximity to beta 1 deadline.

Note: See TracTickets for help on using tickets.