From 31679892c65d1acedd7e354e14e9324254b7d97c Mon Sep 17 00:00:00 2001 From: Ross Wintle Date: Fri, 12 Nov 2021 17:47:55 +0000 Subject: [PATCH 1/4] Add coding standards and configuration --- composer.json | 3 +++ phpcs.xml.dist | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 phpcs.xml.dist diff --git a/composer.json b/composer.json index 5d4dfe2..f54848d 100644 --- a/composer.json +++ b/composer.json @@ -48,5 +48,8 @@ }, "autoload": { "psr-4": {"DeliciousBrains\\SpinupWPComposerSite\\": "app/"} + }, + "require-dev": { + "humanmade/coding-standards": "^1.1" } } diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000..073998d --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,32 @@ + + + + . + + + ^/config/keys.php + + + + + + + + + + + + + + + + + + + + + + + /tests/* + + From 38b7662596c183603eb495474a8894ab7d598910 Mon Sep 17 00:00:00 2001 From: Ross Wintle Date: Fri, 12 Nov 2021 18:14:23 +0000 Subject: [PATCH 2/4] Fix to coding standards as best we can Will have to wait for other #14 and #15 to be merged to do it properly --- app/App.php | 20 ++++++++++----- config/app.php | 41 +++++++++++++++---------------- public/content/mu-plugins/app.php | 7 ++++-- public/index.php | 4 +-- public/wp-config.php | 2 +- 5 files changed, 42 insertions(+), 32 deletions(-) diff --git a/app/App.php b/app/App.php index 60391c2..faf5bc0 100644 --- a/app/App.php +++ b/app/App.php @@ -1,11 +1,17 @@ + * + * @param string $name The name of the magic method + * @param $arguments The arguments to the magic method * * @return bool */ @@ -36,4 +44,4 @@ public static function __callStatic( $name, $arguments ) { return $env === env( 'WP_ENV' ); } } -} \ No newline at end of file +} diff --git a/config/app.php b/config/app.php index 19e8f41..9277cf8 100644 --- a/config/app.php +++ b/config/app.php @@ -1,5 +1,4 @@ load(); $dotenv->required( [ 'DB_NAME', 'DB_USER', 'DB_PASSWORD', 'WP_HOME', 'WP_SITEURL' ] ); @@ -40,36 +39,36 @@ App::define( 'WP_CONTENT_DIR', $webroot_dir . CONTENT_DIR ); App::define( 'WP_CONTENT_URL', WP_HOME . CONTENT_DIR ); -App::define('DB_NAME', env('DB_NAME')); -App::define('DB_USER', env('DB_USER')); -App::define('DB_PASSWORD', env('DB_PASSWORD')); -App::define('DB_HOST', env('DB_HOST') ?: 'localhost'); -App::define('DB_CHARSET', 'utf8mb4'); -App::define('DB_COLLATE', ''); -$table_prefix = env('DB_PREFIX') ?: 'wp_'; +App::define( 'DB_NAME', env( 'DB_NAME' ) ); +App::define( 'DB_USER', env( 'DB_USER' ) ); +App::define( 'DB_PASSWORD', env( 'DB_PASSWORD' ) ); +App::define( 'DB_HOST', env( 'DB_HOST' ) ?: 'localhost' ); +App::define( 'DB_CHARSET', 'utf8mb4' ); +App::define( 'DB_COLLATE', '' ); +$table_prefix = env( 'DB_PREFIX' ) ?: 'wp_'; // Set other constants from env file. -foreach( array_keys($dotenv->load()) as $key ) { - App::define($key, env( $key )); +foreach ( array_keys( $dotenv->load() ) as $key ) { + App::define( $key, env( $key ) ); } -// Environment config +// Environment config. $env_config = __DIR__ . '/environments/' . WP_ENV . '.php'; if ( file_exists( $env_config ) ) { require_once $env_config; } -App::define('AUTOMATIC_UPDATER_DISABLED', true); -App::define('DISABLE_WP_CRON', env('DISABLE_WP_CRON') ?: false); -// Disable the plugin and theme file editor in the admin -App::define('DISALLOW_FILE_EDIT', true); -// Disable plugin and theme updates and installation from the admin -App::define('DISALLOW_FILE_MODS', true); +App::define( 'AUTOMATIC_UPDATER_DISABLED', true ); +App::define( 'DISABLE_WP_CRON', env( 'DISABLE_WP_CRON' ) ?: false ); +// Disable the plugin and theme file editor in the admin. +App::define( 'DISALLOW_FILE_EDIT', true ); +// Disable plugin and theme updates and installation from the admin. +App::define( 'DISALLOW_FILE_MODS', true ); -// Secret keys +// Secret keys. if ( ! file_exists( __DIR__ . '/keys.php' ) ) { $keys = file_get_contents( 'https://api.wordpress.org/secret-key/1.1/salt/' ); - file_put_contents( __DIR__ . '/keys.php', 'register(); \ No newline at end of file +/** + * Bootstrap our site code + */ + +( new DeliciousBrains\SpinupWPComposerSite\App() )->register(); diff --git a/public/index.php b/public/index.php index add0f9f..9e7f348 100644 --- a/public/index.php +++ b/public/index.php @@ -11,7 +11,7 @@ * * @var bool */ -define('WP_USE_THEMES', true); +define( 'WP_USE_THEMES', true ); /** Loads the WordPress Environment and Template */ -require( dirname( __FILE__ ) . '/wp/wp-blog-header.php' ); \ No newline at end of file +require( dirname( __FILE__ ) . '/wp/wp-blog-header.php' ); diff --git a/public/wp-config.php b/public/wp-config.php index 5e4c7ca..ddc003d 100644 --- a/public/wp-config.php +++ b/public/wp-config.php @@ -6,4 +6,4 @@ */ require_once dirname( __DIR__ ) . '/vendor/autoload.php'; require_once dirname( __DIR__ ) . '/config/app.php'; -require_once ABSPATH . 'wp-settings.php'; \ No newline at end of file +require_once ABSPATH . 'wp-settings.php'; From a29f07f4d0e3b797baea7b65d11c7f7b12438130 Mon Sep 17 00:00:00 2001 From: Ross Wintle Date: Fri, 12 Nov 2021 18:20:54 +0000 Subject: [PATCH 3/4] Additional coding standards fix --- app/App.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/App.php b/app/App.php index faf5bc0..cf9007d 100644 --- a/app/App.php +++ b/app/App.php @@ -34,7 +34,7 @@ public static function define( $key, $value ) { * This allows the environment to be queried using magic methods like App::is_env_ * * @param string $name The name of the magic method - * @param $arguments The arguments to the magic method + * @param array $arguments The arguments to the magic method * * @return bool */ From a5e69d7ac0d40a9d983ef08a8ea9f5176f77f33e Mon Sep 17 00:00:00 2001 From: Ross Wintle Date: Mon, 24 Jan 2022 10:51:46 +0000 Subject: [PATCH 4/4] Update coding standards branch for composer v2.2 --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ad4b1d8..9c14af5 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,8 @@ "sort-packages": true, "allow-plugins": { "composer/installers": true, - "johnpbloch/wordpress-core-installer": true + "johnpbloch/wordpress-core-installer": true, + "dealerdirect/phpcodesniffer-composer-installer": true } }, "require": {