Skip to content

fix(lint): add PHP linting to main lint command#2711

Open
faisalahammad wants to merge 1 commit into
Automattic:trunkfrom
faisalahammad:fix/1882-add-php-linting
Open

fix(lint): add PHP linting to main lint command#2711
faisalahammad wants to merge 1 commit into
Automattic:trunkfrom
faisalahammad:fix/1882-add-php-linting

Conversation

@faisalahammad
Copy link
Copy Markdown
Contributor

Summary

Adds PHP linting to the main npm run lint command. The project already has PHPCS configured with WordPress-Extra, WordPress-Docs, WordPressVIPMinimum, and PHPCompatibilityWP (PHP 7.2+), but the lint script only ran SCSS and JS — PHP had to be invoked separately via npm run lint:php.

Fixes #1882

Changes

package.json

Before:

"lint": "npm run lint:scss && npm run lint:js",

After:

"lint": "npm run lint:scss && npm run lint:js && npm run lint:php",

Why: Matches the existing && chain pattern. No new dependencies. PHP linting is now discoverable through the main lint command, consistent with how JS and SCSS linting already work.

Testing

Test 1: PHP linting passes clean

  1. npm run lint:php → exit 0

Test 2: SCSS + PHP chain works

  1. npm run lint:scss && npm run lint:php → exit 0

Test 3: PHPCS catches violations

  1. Created test file with bad PHP → 4 errors detected (exit 2)
  2. npm run fix:php → auto-fixed 2/4 errors

Test 4: Full chain behavior

  1. npm run lint → runs SCSS, JS, then PHP sequentially via &&

All tests pass. Single file, single line change.

Adds `npm run lint:php` to the `lint` script chain so PHP linting runs
alongside SCSS and JS. PHPCS was already configured with WordPress-Extra,
WordPress-Docs, WordPressVIPMinimum, and PHPCompatibilityWP but had to
be invoked separately.

Fixes Automattic#1882
@faisalahammad faisalahammad requested a review from a team as a code owner May 15, 2026 16:32
@laurelfulford laurelfulford added the [Status] Needs Review The issue or pull request needs to be reviewed label May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Status] Needs Review The issue or pull request needs to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add PHP linting

2 participants