Skip to content

Conversation

Copy link

Copilot AI commented Dec 22, 2025

Scaffolded packages now include a phpcs.xml.dist file for WordPress Coding Standards linting, matching the setup used across WP-CLI packages.

Changes

  • templates/phpcs.xml.dist.mustache: Created a new Mustache template for phpcs.xml.dist with customizable prefix based on package name
  • ScaffoldPackageCommand.php: Added logic to generate package_name_slug from package name and use the phpcs.xml.dist template during scaffolding
  • scaffold-package.feature: Added test assertions verifying file creation, WP_CLI_CS ruleset presence, and customized prefix
  • README.md: Updated to reflect new file in scaffolded output

The generated phpcs.xml.dist uses the WP_CLI_CS ruleset, which includes WordPress-Extra standards with WP-CLI-specific exclusions (e.g., allows short array syntax, excludes file naming conventions for PSR-4). The PrefixAllGlobals configuration is customized for each package - for example, wp-cli/foo gets prefix wpcli_foo, and wp-cli/export-command gets prefix wpcli_export_command.

Example

$ wp scaffold package wp-cli/my-command
Success: Created package files in ~/.wp-cli/packages/local/wp-cli/my-command

$ ls ~/.wp-cli/packages/local/wp-cli/my-command/
.gitignore  .editorconfig  .distignore  phpcs.xml.dist  composer.json  ...

$ cat ~/.wp-cli/packages/local/wp-cli/my-command/phpcs.xml.dist
# Shows customized prefix: wpcli_my_command

$ cd ~/.wp-cli/packages/local/wp-cli/my-command/
$ composer phpcs
# Now enforces WordPress Coding Standards via WP_CLI_CS ruleset
Original prompt

This section details on the original issue you should resolve

<issue_title>Add WordPress Coding Standards linting</issue_title>
<issue_description>A la wp-cli/wp-cli#3472</issue_description>

Comments on the Issue (you are @copilot in this section)

@danielbachhuber Related https://github.com/wp-cli/wp-cli/pull/4057

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add WordPress Coding Standards linting Add phpcs.xml.dist to scaffolded packages Dec 22, 2025
Copilot AI requested a review from swissspidy December 22, 2025 16:31
@swissspidy
Copy link
Member

@copilot there should be a dedicated phpcs config file in the templates folder. The PrefixAllGlobals config item needs to be a placeholder that's customized to match the scaffolded project.

Copy link
Author

Copilot AI commented Dec 23, 2025

@copilot there should be a dedicated phpcs config file in the templates folder. The PrefixAllGlobals config item needs to be a placeholder that's customized to match the scaffolded project.

Done in commit 6ea47cf. Created templates/phpcs.xml.dist.mustache with the PrefixAllGlobals prefix customized to wpcli_{{package_name_slug}}. For a package like wp-cli/foo, the prefix becomes wpcli_foo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add WordPress Coding Standards linting

2 participants