From e7516378af6876f1e3af995f81550d55711b824f Mon Sep 17 00:00:00 2001 From: James Amner Date: Mon, 17 Mar 2025 14:03:10 +0000 Subject: [PATCH] [BWP-125] Update to use Box-Core WordPress Standards --- .gitignore | 1 + composer.json | 7 +- composer.lock | 104 +++++++++++++++------ phpcs.xml.dist | 119 ++++-------------------- wp-content/mu-plugins/mu-require.php | 6 +- wp-content/mu-plugins/sample/sample.php | 4 +- 6 files changed, 104 insertions(+), 137 deletions(-) diff --git a/.gitignore b/.gitignore index 6ed0ef69..d46c5039 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,7 @@ debug.log !/tests/tmp/.gitkeep .phpunit.result.cache .phpunit.cache/ +.phpcs.cache !docker/database/init.sql auth.json diff --git a/composer.json b/composer.json index 4d91090c..c3bd4746 100644 --- a/composer.json +++ b/composer.json @@ -8,6 +8,10 @@ "type": "composer", "url": "https://wpackagist.org" }, + { + "type": "git", + "url": "https://github.com/boxuk/coding-standards.git" + }, { "options": { "symlink": false @@ -56,7 +60,8 @@ "require-dev": { "10up/wp_mock": "^1.0", "automattic/vipwpcs": "^3.0", - "phpcompatibility/phpcompatibility-wp": "*", + "boxuk/coding-standards": "dev-wordpress", + "phpcompatibility/phpcompatibility-wp": "^2.1", "phpstan/phpstan": "^1.10", "phpunit/phpunit": "^9", "szepeviktor/phpstan-wordpress": "^1.3", diff --git a/composer.lock b/composer.lock index 120b52e9..be39b4c8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b78e293565f96caa58dc47fcedc7d3c2", + "content-hash": "1e7f139120cf5489eae83504c755ca1a", "packages": [ { "name": "boxuk/wp-editor-tools", @@ -1122,16 +1122,16 @@ }, { "name": "symfony/validator", - "version": "v7.2.3", + "version": "v7.2.4", "source": { "type": "git", "url": "https://github.com/symfony/validator.git", - "reference": "6faf9f671d522b76ce87e46a1d2d7740b4385c6f" + "reference": "00936b34ef29d0e0e9a5340bbce6e7562092da56" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/validator/zipball/6faf9f671d522b76ce87e46a1d2d7740b4385c6f", - "reference": "6faf9f671d522b76ce87e46a1d2d7740b4385c6f", + "url": "https://api.github.com/repos/symfony/validator/zipball/00936b34ef29d0e0e9a5340bbce6e7562092da56", + "reference": "00936b34ef29d0e0e9a5340bbce6e7562092da56", "shasum": "" }, "require": { @@ -1199,7 +1199,7 @@ "description": "Provides tools to validate values", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/validator/tree/v7.2.3" + "source": "https://github.com/symfony/validator/tree/v7.2.4" }, "funding": [ { @@ -1215,7 +1215,7 @@ "type": "tidelift" } ], - "time": "2025-01-28T15:51:35+00:00" + "time": "2025-02-21T09:47:16+00:00" }, { "name": "wp-cli/mustangostang-spyc", @@ -1489,16 +1489,16 @@ "packages-dev": [ { "name": "10up/wp_mock", - "version": "1.0.1", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/10up/wp_mock.git", - "reference": "48b7f22934a4351e45e336f09263ee27fc9ddcbe" + "reference": "f25b5895ed31bf5e7036fe0c666664364ae011c2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/10up/wp_mock/zipball/48b7f22934a4351e45e336f09263ee27fc9ddcbe", - "reference": "48b7f22934a4351e45e336f09263ee27fc9ddcbe", + "url": "https://api.github.com/repos/10up/wp_mock/zipball/f25b5895ed31bf5e7036fe0c666664364ae011c2", + "reference": "f25b5895ed31bf5e7036fe0c666664364ae011c2", "shasum": "" }, "require": { @@ -1537,9 +1537,9 @@ "description": "A mocking library to take the pain out of unit testing for WordPress", "support": { "issues": "https://github.com/10up/wp_mock/issues", - "source": "https://github.com/10up/wp_mock/tree/1.0.1" + "source": "https://github.com/10up/wp_mock/tree/1.1.0" }, - "time": "2024-01-22T02:22:57+00:00" + "time": "2025-03-12T00:36:13+00:00" }, { "name": "antecedent/patchwork", @@ -1643,6 +1643,42 @@ }, "time": "2024-05-10T20:31:09+00:00" }, + { + "name": "boxuk/coding-standards", + "version": "dev-wordpress", + "source": { + "type": "git", + "url": "https://github.com/boxuk/coding-standards.git", + "reference": "fb1e17ffaaf2b946d2a38932ea3466d92fb9fe30" + }, + "require": { + "php": ">=8.0" + }, + "suggest": { + "automattic/vipwpcs": "WP - For WordPress Coding Standards.", + "phpcompatibility/phpcompatibility-wp": "WP - For PHP version compatibility checks.", + "symplify/easy-coding-standard": "ECS - These configs work with ECS currently so you probably want to install this" + }, + "type": "phpcodesniffer-standard", + "autoload": { + "psr-4": { + "BoxUK\\CodingStandards\\": [ + "src" + ] + } + }, + "license": [ + "MIT" + ], + "description": "Provides a sane set of defaults for coding standard, mainly easy-coding-standards", + "keywords": [ + "automation", + "code style", + "fixer", + "static analysis" + ], + "time": "2025-03-17T12:54:22+00:00" + }, { "name": "dealerdirect/phpcodesniffer-composer-installer", "version": "v1.0.0", @@ -2163,16 +2199,16 @@ }, { "name": "php-stubs/wordpress-stubs", - "version": "v6.7.1", + "version": "v6.7.2", "source": { "type": "git", "url": "https://github.com/php-stubs/wordpress-stubs.git", - "reference": "83448e918bf06d1ed3d67ceb6a985fc266a02fd1" + "reference": "c04f96cb232fab12a3cbcccf5a47767f0665c3f4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/83448e918bf06d1ed3d67ceb6a985fc266a02fd1", - "reference": "83448e918bf06d1ed3d67ceb6a985fc266a02fd1", + "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/c04f96cb232fab12a3cbcccf5a47767f0665c3f4", + "reference": "c04f96cb232fab12a3cbcccf5a47767f0665c3f4", "shasum": "" }, "require-dev": { @@ -2205,9 +2241,9 @@ ], "support": { "issues": "https://github.com/php-stubs/wordpress-stubs/issues", - "source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.7.1" + "source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.7.2" }, - "time": "2024-11-24T03:57:09+00:00" + "time": "2025-02-12T04:51:58+00:00" }, { "name": "phpcompatibility/php-compatibility", @@ -2581,16 +2617,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.15", + "version": "1.12.21", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "c91d4e8bc056f46cf653656e6f71004b254574d1" + "reference": "14276fdef70575106a3392a4ed553c06a984df28" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/c91d4e8bc056f46cf653656e6f71004b254574d1", - "reference": "c91d4e8bc056f46cf653656e6f71004b254574d1", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/14276fdef70575106a3392a4ed553c06a984df28", + "reference": "14276fdef70575106a3392a4ed553c06a984df28", "shasum": "" }, "require": { @@ -2635,7 +2671,7 @@ "type": "github" } ], - "time": "2025-01-05T16:40:22+00:00" + "time": "2025-03-09T09:24:50+00:00" }, { "name": "phpunit/php-code-coverage", @@ -4081,16 +4117,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.11.2", + "version": "3.11.3", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "1368f4a58c3c52114b86b1abe8f4098869cb0079" + "reference": "ba05f990e79cbe69b9f35c8c1ac8dca7eecc3a10" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/1368f4a58c3c52114b86b1abe8f4098869cb0079", - "reference": "1368f4a58c3c52114b86b1abe8f4098869cb0079", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/ba05f990e79cbe69b9f35c8c1ac8dca7eecc3a10", + "reference": "ba05f990e79cbe69b9f35c8c1ac8dca7eecc3a10", "shasum": "" }, "require": { @@ -4155,9 +4191,13 @@ { "url": "https://opencollective.com/php_codesniffer", "type": "open_collective" + }, + { + "url": "https://thanks.dev/phpcsstandards", + "type": "thanks_dev" } ], - "time": "2024-12-11T16:04:26+00:00" + "time": "2025-01-23T17:04:15+00:00" }, { "name": "symfony/polyfill-php73", @@ -4528,7 +4568,9 @@ ], "aliases": [], "minimum-stability": "dev", - "stability-flags": [], + "stability-flags": { + "boxuk/coding-standards": 20 + }, "prefer-stable": true, "prefer-lowest": false, "platform": [], @@ -4537,5 +4579,5 @@ "ext-mbstring": "1", "ext-intl": "1" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 7f9d4749..8369b8fc 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -1,12 +1,23 @@ - - A custom set of rules to check for a Box UK WordPress project - ./wp-content/ + - + - + + + + + + + wp-content + + + */mu-plugins/wp-feature-flags* + */mu-plugins/wp-editor-tools* + wp-content/plugins* @@ -17,100 +28,6 @@ - - - - - - */wp/ - - */upgrade/* - - */plugins/* - */premium-plugins/* - */patched-plugins/* - */mu-plugins/wp-feature-flags* - */mu-plugins/wp-editor-tools* - - *.asset.php - - */uploads/* - - */tests/* - - */cache/* - - - */node_modules/* - - - */vendor/* - - - */styleguide/* - */assets/* - - - *\.min\.* - - - object-cache\.php - advanced-cache\.php - mu-require\.php - db\.php - - - - - - - - - - */mu-plugins/flagpole/* - */mu-plugins/wp-hook-attributes/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + diff --git a/wp-content/mu-plugins/mu-require.php b/wp-content/mu-plugins/mu-require.php index 448acc39..17427168 100644 --- a/wp-content/mu-plugins/mu-require.php +++ b/wp-content/mu-plugins/mu-require.php @@ -6,6 +6,8 @@ * Author: Roots * Author URI: https://roots.io/ * License: MIT License + * + * @package Roots\Bedrock */ namespace Roots\Bedrock; @@ -15,12 +17,12 @@ */ $vendor = WP_CONTENT_DIR . '/vendor/autoload.php'; if ( file_exists( $vendor ) ) { - require_once $vendor; + require_once $vendor; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingVariable -- Including via variable is better here. } /** * Autoload mu-plugins */ if ( is_blog_installed() && class_exists( Autoloader::class ) ) { - new Autoloader(); + new Autoloader(); } diff --git a/wp-content/mu-plugins/sample/sample.php b/wp-content/mu-plugins/sample/sample.php index 9888a4ef..cce1a0bf 100644 --- a/wp-content/mu-plugins/sample/sample.php +++ b/wp-content/mu-plugins/sample/sample.php @@ -31,10 +31,10 @@ static function () { 'init', function () { $flag_register = FlagRegister::instance(); - $flag = $flag_register->get_flag( 'sample-flag' ); + $flag = $flag_register->get_flag( 'sample-flag' ); if ( $flag && $flag->is_enabled() ) { - $sample = new SampleClass(); + $sample = new SampleClass(); $sample_text = $sample->get_sample(); do_action( 'qm/info', $sample_text . ' if feature enabled.' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores }