From 358b373a7ad1f73bfece3a33c83e4690949c8d5c Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Thu, 16 Nov 2023 16:29:41 -0500 Subject: [PATCH] Upgrading mantle to alley-coding-standards 2.0 --- app/jobs/class-example-job.php | 3 ++- app/models/class-category.php | 2 +- app/models/class-post.php | 2 +- app/models/class-tag.php | 2 +- app/providers/class-asset-service-provider.php | 6 +++--- composer.json | 11 ++--------- mantle.php | 2 +- routes/rest-api.php | 8 ++++---- routes/web.php | 14 +++++++------- 9 files changed, 22 insertions(+), 28 deletions(-) diff --git a/app/jobs/class-example-job.php b/app/jobs/class-example-job.php index 743f5fe..cd3e188 100644 --- a/app/jobs/class-example-job.php +++ b/app/jobs/class-example-job.php @@ -16,7 +16,8 @@ * Example Job that can be queued. */ class Example_Job implements Job, Can_Queue { - use Queueable, Dispatchable; + use Queueable; + use Dispatchable; /** * Handle the job. diff --git a/app/models/class-category.php b/app/models/class-category.php index b9b2064..cf76586 100644 --- a/app/models/class-category.php +++ b/app/models/class-category.php @@ -26,7 +26,7 @@ class Category extends Term { * * @return Has_Many */ - public function posts() : Has_Many { + public function posts(): Has_Many { return $this->has_many( Post::class ); } } diff --git a/app/models/class-post.php b/app/models/class-post.php index b3df29a..75ea691 100644 --- a/app/models/class-post.php +++ b/app/models/class-post.php @@ -35,7 +35,7 @@ public function category() { * * @return Has_Many */ - public function tags() : Has_Many { + public function tags(): Has_Many { return $this->has_many( Tag::class ); } } diff --git a/app/models/class-tag.php b/app/models/class-tag.php index c6b63e2..126e5bf 100644 --- a/app/models/class-tag.php +++ b/app/models/class-tag.php @@ -26,7 +26,7 @@ class Tag extends Term { * * @return Has_Many */ - public function posts() : Has_Many { + public function posts(): Has_Many { return $this->has_many( Post::class ); } } diff --git a/app/providers/class-asset-service-provider.php b/app/providers/class-asset-service-provider.php index e9cbee8..94c8ab7 100644 --- a/app/providers/class-asset-service-provider.php +++ b/app/providers/class-asset-service-provider.php @@ -45,12 +45,12 @@ public function boot() { | | Enqueue a raw asset using the asset() helper: | - | asset()->script( 'example-entry' )->async()->src( asset_loader( '/app.js' ) ); - | asset()->style( 'example-entry' )->condition( 'single' )->src( asset_loader( '/app.css' ) ); + | asset()->script( 'example-entry' )->async()->src( asset_loader( '/app.js' ) ); + | asset()->style( 'example-entry' )->condition( 'single' )->src( asset_loader( '/app.css' ) ); | | Enqueue an asset with dependencies from @wordpress/dependency-extraction-webpack-plugin: | - | asset()->script( 'example-block' )->src( asset_loader( '/example-block.js' ) )->dependencies( asset_loader()->dependencies( '/example-block.js' ) ); + | asset()->script( 'example-block' )->src( asset_loader( '/example-block.js' ) )->dependencies( asset_loader()->dependencies( '/example-block.js' ) ); | | Get cookin'! | diff --git a/composer.json b/composer.json index 1a4b9a8..18c316e 100644 --- a/composer.json +++ b/composer.json @@ -15,12 +15,11 @@ "fakerphp/faker": "^1.23" }, "require-dev": { - "alleyinteractive/alley-coding-standards": "^1.0", + "alleyinteractive/alley-coding-standards": "^2.0", "nunomaduro/collision": "^6.4", "phpstan/phpstan": "1.10.15", "phpunit/phpunit": "^9.6.10", - "szepeviktor/phpstan-wordpress": "^1.3", - "wp-coding-standards/wpcs": "dev-php-8-1 as 2.3.x-dev" + "szepeviktor/phpstan-wordpress": "^1.3" }, "config": { "allow-plugins": { @@ -44,12 +43,6 @@ }, "minimum-stability": "dev", "prefer-stable": true, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/alleyinteractive/WordPress-Coding-Standards" - } - ], "scripts": { "post-autoload-dump": [ "bin/mantle package:discover", diff --git a/mantle.php b/mantle.php index 43d7e99..4f6ad61 100644 --- a/mantle.php +++ b/mantle.php @@ -54,7 +54,7 @@ if ( ! file_exists( __DIR__ . '/vendor/wordpress-autoload.php' ) ) { add_action( 'admin_notices', - function() { + function () { printf( '

%s

', esc_html__( 'Mantle requires a `composer install` to run properly.', 'mantle' ) diff --git a/routes/rest-api.php b/routes/rest-api.php index c255c2b..307a253 100644 --- a/routes/rest-api.php +++ b/routes/rest-api.php @@ -14,12 +14,12 @@ | | Register a closure-based route: | -| Route::get( '/closure-route', function( \WP_REST_Request $request ) { -| dd( $request ); -| } ); +| Route::get( '/closure-route', function( \WP_REST_Request $request ) { +| dd( $request ); +| } ); | */ -Route::rest_api( '/example-namespace', function() { +Route::rest_api( '/example-namespace', function () { // } ); diff --git a/routes/web.php b/routes/web.php index 678d419..da1ff40 100644 --- a/routes/web.php +++ b/routes/web.php @@ -15,18 +15,18 @@ | | Register a controller route: | -| Route::get( '/controller-route', Example_Controller::class . '@method_to_call' ); +| Route::get( '/controller-route', Example_Controller::class . '@method_to_call' ); | | Register a closure-based route: | -| Route::get( '/closure-route', function( \Mantle\Http\Request $request ) { -| dd( $request->all() ); -| } ); +| Route::get( '/closure-route', function( \Mantle\Http\Request $request ) { +| dd( $request->all() ); +| } ); | | Register a route with variables: | -| Route::get( '/hello/{who}', function( $name ) { -| return "Why hello {$name}!"; -| } ); +| Route::get( '/hello/{who}', function( $name ) { +| return "Why hello {$name}!"; +| } ); | */