WordPress.org

Make WordPress Core

Opened 2 months ago

Last modified 7 weeks 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.


2 months ago

#2 @westonruter
2 months 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.

#4 @westonruter
8 weeks ago

There is now an add-on for PHP linting in CodeMirror available: https://github.com/glayzzle/codemirror-linter

Last edited 7 weeks ago by westonruter (previous) (diff)

#5 @westonruter
7 weeks 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 @westonruter
7 weeks 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 I think it should have some more time to bake. So I'm punting this for the future. Maybe WordPress 5.0.

Last edited 7 weeks ago by westonruter (previous) (diff)

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


7 weeks ago

Note: See TracTickets for help on using tickets.