From d3b65f255c59edd9ed7a0887826e701d016e96ad Mon Sep 17 00:00:00 2001 From: Matt Wiebe Date: Wed, 19 Jul 2023 16:49:25 -0500 Subject: [PATCH 1/3] Try dotcom's set of sniffs --- composer.json | 7 ++++++- phpcs.xml | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 68cefb9..16e1add 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,9 @@ "squizlabs/php_codesniffer": "3.*", "wp-coding-standards/wpcs": "*", "yoast/phpunit-polyfills": "^2.0", - "dealerdirect/phpcodesniffer-composer-installer": "^1.0.0" + "dealerdirect/phpcodesniffer-composer-installer": "^1.0.0", + "sirbrillig/phpcs-variable-analysis": "^2.11", + "phpcsstandards/phpcsextra": "^1.1.0" }, "config": { "allow-plugins": true @@ -36,6 +38,9 @@ "composer install", "bin/install-wp-tests.sh activitypub-test root activitypub-test test-db latest true", "vendor/bin/phpunit" + ], + "lint": [ + "vendor/bin/phpcs" ] } } diff --git a/phpcs.xml b/phpcs.xml index 07a9a39..ad12dbd 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -23,4 +23,50 @@ + + + + + error + + + + + + + + + error + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + warning + + + **/*.asset.php + From be96b19781e3cf38d500352359d04ac477b5f953 Mon Sep 17 00:00:00 2001 From: Matt Wiebe Date: Wed, 19 Jul 2023 19:54:07 -0500 Subject: [PATCH 2/3] use latest wp coding standards --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 16e1add..8cf4ec0 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "phpcompatibility/php-compatibility": "*", "phpcompatibility/phpcompatibility-wp": "*", "squizlabs/php_codesniffer": "3.*", - "wp-coding-standards/wpcs": "*", + "wp-coding-standards/wpcs": "dev-develop", "yoast/phpunit-polyfills": "^2.0", "dealerdirect/phpcodesniffer-composer-installer": "^1.0.0", "sirbrillig/phpcs-variable-analysis": "^2.11", From 3512206d4884e89cf7708be8a5b836388517ceeb Mon Sep 17 00:00:00 2001 From: Matt Wiebe Date: Wed, 19 Jul 2023 20:39:58 -0500 Subject: [PATCH 3/3] phpcbf fixes --- activitypub.php | 8 ++++---- composer.json | 2 +- includes/class-mention.php | 1 - includes/class-shortcodes.php | 1 - includes/rest/class-inbox.php | 4 ++-- includes/transformer/class-post.php | 2 +- 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/activitypub.php b/activitypub.php index 0abf189..0de62e3 100644 --- a/activitypub.php +++ b/activitypub.php @@ -64,7 +64,7 @@ function init() { */ spl_autoload_register( function ( $full_class ) { - $base_dir = \dirname( __FILE__ ) . '/includes/'; + $base_dir = __DIR__ . '/includes/'; $base = 'activitypub'; $class = strtolower( $full_class ); @@ -92,14 +92,14 @@ spl_autoload_register( } ); -require_once \dirname( __FILE__ ) . '/includes/functions.php'; +require_once __DIR__ . '/includes/functions.php'; // load NodeInfo endpoints only if blog is public if ( \get_option( 'blog_public', 1 ) ) { Rest\NodeInfo::init(); } -$debug_file = \dirname( __FILE__ ) . '/includes/debug.php'; +$debug_file = __DIR__ . '/includes/debug.php'; if ( \WP_DEBUG && file_exists( $debug_file ) && is_readable( $debug_file ) ) { require_once $debug_file; Debug::init(); @@ -150,7 +150,7 @@ function plugin_settings_link( $actions ) { add_action( 'bp_include', function() { - require_once \dirname( __FILE__ ) . '/integration/class-buddypress.php'; + require_once __DIR__ . '/integration/class-buddypress.php'; Integration\Buddypress::init(); }, 0 diff --git a/composer.json b/composer.json index 8cf4ec0..d34d110 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,7 @@ "vendor/bin/phpunit" ], "lint": [ - "vendor/bin/phpcs" + "vendor/bin/phpcs -n -q" ] } } diff --git a/includes/class-mention.php b/includes/class-mention.php index 63508e8..fda0dd5 100644 --- a/includes/class-mention.php +++ b/includes/class-mention.php @@ -151,6 +151,5 @@ class Mention { } } return $mentions; - } } diff --git a/includes/class-shortcodes.php b/includes/class-shortcodes.php index 2825e80..7877b64 100644 --- a/includes/class-shortcodes.php +++ b/includes/class-shortcodes.php @@ -70,7 +70,6 @@ class Shortcodes { } return \wp_strip_all_tags( \get_the_title( $item->ID ), true ); - } /** diff --git a/includes/rest/class-inbox.php b/includes/rest/class-inbox.php index 98b4e55..e4bef21 100644 --- a/includes/rest/class-inbox.php +++ b/includes/rest/class-inbox.php @@ -237,7 +237,7 @@ class Inbox { //'type' => 'enum', //'enum' => array( 'Create' ), //'sanitize_callback' => function( $param, $request, $key ) { - // return \strtolower( $param ); + // return \strtolower( $param ); //}, ); @@ -282,7 +282,7 @@ class Inbox { //'type' => 'enum', //'enum' => array( 'Create' ), //'sanitize_callback' => function( $param, $request, $key ) { - // return \strtolower( $param ); + // return \strtolower( $param ); //}, ); diff --git a/includes/transformer/class-post.php b/includes/transformer/class-post.php index 568a0e3..69dcf89 100644 --- a/includes/transformer/class-post.php +++ b/includes/transformer/class-post.php @@ -187,7 +187,7 @@ class Post { // list post thumbnail first if this post has one if ( \function_exists( 'has_post_thumbnail' ) && \has_post_thumbnail( $id ) ) { $image_ids[] = \get_post_thumbnail_id( $id ); - $max_images--; + --$max_images; } if ( $max_images > 0 ) {