Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update architecture to adapt package structure #194

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions bin/readme/installing-body.md

This file was deleted.

27 changes: 0 additions & 27 deletions command.php

This file was deleted.

7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
"dev-main": "2.x-dev"
},
"commands": [
"doctor",
Expand All @@ -57,8 +57,11 @@
}
},
"autoload": {
"psr-4": {
"WP_CLI\\Doctor\\": "src/"
},
"files": [
"command.php"
"doctor-command.php"
]
},
"minimum-stability": "dev",
Expand Down
13 changes: 13 additions & 0 deletions doctor-command.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

if ( ! class_exists( 'WP_CLI' ) ) {
return;
}

$wpcli_doctor_autoloader = __DIR__ . '/vendor/autoload.php';

if ( file_exists( $wpcli_doctor_autoloader ) ) {
require_once $wpcli_doctor_autoloader;
}

WP_CLI::add_command( 'doctor', 'WP_CLI\Doctor\Command' );
2 changes: 1 addition & 1 deletion features/check-autoload-options-size.feature
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Feature: Check the size of autoloaded options
And a custom.yml file:
"""
autoload-options-size:
class: runcommand\Doctor\Checks\Autoload_Options_Size
class: WP_CLI\Doctor\Check\Autoload_Options_Size
options:
threshold_kb: 800
"""
Expand Down
6 changes: 3 additions & 3 deletions features/check-constant-definition.feature
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Feature: Check the values of defined constants
And a config.yml file:
"""
constant-db-host-defined:
class: runcommand\Doctor\Checks\Constant_Definition
class: WP_CLI\Doctor\Check\Constant_Definition
options:
constant: DB_HOST
defined: true
Expand All @@ -87,7 +87,7 @@ Feature: Check the values of defined constants
And a config.yml file:
"""
constant-foobar-true:
class: runcommand\Doctor\Checks\Constant_Definition
class: WP_CLI\Doctor\Check\Constant_Definition
options:
constant: FOOBAR
value: true
Expand All @@ -108,7 +108,7 @@ Feature: Check the values of defined constants
And a config.yml file:
"""
constant-foobar-true:
class: runcommand\Doctor\Checks\Constant_Definition
class: WP_CLI\Doctor\Check\Constant_Definition
options:
constant: FOOBAR
value: true
Expand Down
2 changes: 1 addition & 1 deletion features/check-plugin-active-count.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Feature: Check whether a high number of plugins are activated
And a config.yml file:
"""
plugin-active-count:
class: runcommand\Doctor\Checks\Plugin_Active_Count
class: WP_CLI\Doctor\Check\Plugin_Active_Count
options:
threshold_count: 3
"""
Expand Down
2 changes: 1 addition & 1 deletion features/check-plugin-deactivated.feature
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Feature: Check whether a high percentage of plugins are deactivated
And a custom.yml file:
"""
plugin-deactivated:
class: runcommand\Doctor\Checks\Plugin_Deactivated
class: WP_CLI\Doctor\Check\Plugin_Deactivated
options:
threshold_percentage: 60
"""
Expand Down
8 changes: 4 additions & 4 deletions features/check-plugin-status.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Feature: Check the status of a plugin
And a config.yml file:
"""
plugin-akismet-active:
class: runcommand\Doctor\Checks\Plugin_Status
class: WP_CLI\Doctor\Check\Plugin_Status
options:
name: akismet
status: active
Expand All @@ -21,12 +21,12 @@ Feature: Check the status of a plugin
And a config.yml file:
"""
plugin-akismet-active:
class: runcommand\Doctor\Checks\Plugin_Status
class: WP_CLI\Doctor\Check\Plugin_Status
options:
name: akismet
status: active
plugin-hello-uninstalled:
class: runcommand\Doctor\Checks\Plugin_Status
class: WP_CLI\Doctor\Check\Plugin_Status
options:
name: hello
status: uninstalled
Expand Down Expand Up @@ -71,7 +71,7 @@ Feature: Check the status of a plugin
And a config.yml file:
"""
plugin-akismet-active-network:
class: runcommand\Doctor\Checks\Plugin_Status
class: WP_CLI\Doctor\Check\Plugin_Status
options:
name: akismet
status: active-network
Expand Down
4 changes: 2 additions & 2 deletions features/config.feature
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Feature: Configure the Doctor
And a config.yml file:
"""
check space:
class: runcommand\Doctor\Checks\Constant_Definition
class: WP_CLI\Doctor\Check\Constant_Definition
"""

When I try `wp doctor check --all --config=config.yml`
Expand Down Expand Up @@ -175,7 +175,7 @@ Feature: Configure the Doctor
/**
* Ensures Akismet is activated with the appropriate credentials.
*/
class Akismet_Valid_API_Key extends runcommand\Doctor\Checks\Check {
class Akismet_Valid_API_Key extends WP_CLI\Doctor\Check {

public function run() {
// If the Akismet isn't activated, bail early.
Expand Down
2 changes: 1 addition & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<ruleset name="WP-CLI-entity">
<ruleset name="WP-CLI-doctor">
<description>Custom ruleset for WP-CLI doctor-command</description>

<!--
Expand Down
2 changes: 1 addition & 1 deletion inc/checks/class-check.php → src/Check.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace runcommand\Doctor\Checks;
namespace WP_CLI\Doctor;

use WP_CLI;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace runcommand\Doctor\Checks;
namespace WP_CLI\Doctor\Check;

use WP_CLI;
use WP_CLI\Doctor\Check;

/**
* Warns when autoloaded options size exceeds threshold of %threshold_kb% kb.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php

namespace runcommand\Doctor\Checks;
namespace WP_CLI\Doctor\Check;

use FilesystemIterator;
use WP_CLI;
use WP_CLI\Doctor\Check;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;

Expand All @@ -15,7 +17,7 @@ public function run() {

// Path to wp-content directory.
$wp_content_dir = defined( 'WP_CONTENT_DIR' ) ? WP_CONTENT_DIR : ABSPATH . 'wp-content';
$directory = new RecursiveDirectoryIterator( $wp_content_dir, RecursiveDirectoryIterator::SKIP_DOTS );
$directory = new RecursiveDirectoryIterator( $wp_content_dir, FilesystemIterator::SKIP_DOTS );
$iterator = new RecursiveIteratorIterator( $directory, RecursiveIteratorIterator::CHILD_FIRST );

// Regex to match.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace runcommand\Doctor\Checks;
namespace WP_CLI\Doctor\Check;

use WP_CLI;
use WP_CLI\Doctor\Check;

/**
* Confirms expected state of the %constant% constant.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace runcommand\Doctor\Checks;
namespace WP_CLI\Doctor\Check;

use WP_CLI;
use WP_CLI\Doctor\Check;

/**
* Errors when new WordPress minor release is available; warns for major release.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace runcommand\Doctor\Checks;
namespace WP_CLI\Doctor\Check;

use WP_CLI;
use WP_CLI\Doctor\Check;

/**
* Verifies WordPress files against published checksums; errors on failure.
Expand Down
3 changes: 2 additions & 1 deletion inc/checks/class-cron.php → src/Check/Cron.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace runcommand\Doctor\Checks;
namespace WP_CLI\Doctor\Check;

use WP_CLI;
use WP_CLI\Doctor\Check;

abstract class Cron extends Check {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace runcommand\Doctor\Checks;
namespace WP_CLI\Doctor\Check;

use WP_CLI;
use WP_CLI\Doctor\Check;

/**
* Errors when there's an excess of %threshold_count% total cron jobs registered.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace runcommand\Doctor\Checks;
namespace WP_CLI\Doctor\Check;

use WP_CLI;

Expand Down
4 changes: 3 additions & 1 deletion inc/checks/class-file.php → src/Check/File.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace runcommand\Doctor\Checks;
namespace WP_CLI\Doctor\Check;

use WP_CLI\Doctor\Check;

/**
* Check files on the filesystem.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

namespace runcommand\Doctor\Checks;
namespace WP_CLI\Doctor\Check;

use WP_CLI;
use WP_CLI\Doctor\Check;
use SplFileInfo;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

namespace runcommand\Doctor\Checks;
namespace WP_CLI\Doctor\Check;

use WP_CLI;
use WP_CLI\Doctor\Check;
use SplFileInfo;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace runcommand\Doctor\Checks;
namespace WP_CLI\Doctor\Check;

use WP_CLI;
use WP_CLI\Doctor\Check;

/**
* Warns when there are language updates available.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace runcommand\Doctor\Checks;
namespace WP_CLI\Doctor\Check;

use WP_CLI;
use WP_CLI\Doctor\Check;

/**
* Confirms the expected value of the '%option%' option.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace runcommand\Doctor\Checks;
namespace WP_CLI\Doctor\Check;

use WP_CLI;
use WP_CLI\Doctor\Check;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;

Expand Down
3 changes: 2 additions & 1 deletion inc/checks/class-plugin.php → src/Check/Plugin.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace runcommand\Doctor\Checks;
namespace WP_CLI\Doctor\Check;

use WP_CLI;
use WP_CLI\Doctor\Check;

abstract class Plugin extends Check {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace runcommand\Doctor\Checks;
namespace WP_CLI\Doctor\Check;

use WP_CLI;

Expand All @@ -17,8 +17,6 @@ class Plugin_Active_Count extends Plugin {
protected $threshold_count = 80;

public function run() {
$plugins = self::get_plugins();

$active = 0;
foreach ( self::get_plugins() as $plugin ) {
if ( 'active' === $plugin['status'] || 'active-network' === $plugin['status'] ) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace runcommand\Doctor\Checks;
namespace WP_CLI\Doctor\Check;

use WP_CLI;
use WP_CLI\Doctor\Check;

/**
* Warns when greater than %threshold_percentage%% of plugins are deactivated.
Expand Down
Loading
Loading