Skip to content

Commit

Permalink
Merge pull request #13 from boxuk/refactor-for-1x
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkoian authored Mar 9, 2022
2 parents 8ebf649 + 5d496ef commit 0af09e0
Show file tree
Hide file tree
Showing 38 changed files with 2,516 additions and 2,634 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ composer.phar
/vendor
.DS_Store
composer.lock
.php-cs-fixer.cache
/tools/**/vendor
15 changes: 15 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

$finder = PhpCsFixer\Finder::create()
->exclude(['tools', 'vendor', 'wp'])
->in(__DIR__);

$config = new PhpCsFixer\Config();

return $config->setRules([
'@PSR12' => true,
'array_syntax' => ['syntax' => 'short'],
])
->setFinder($finder);
16 changes: 11 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
language: php

dist: focal

branches:
only:
- master
Expand All @@ -22,26 +24,30 @@ env:
- WP_CLI_TEST_DBHOST=127.0.0.1

install:
- composer install
- composer update
- composer prepare-tests
- composer install-tools

script:
- composer behat || composer behat-rerun

jobs:
allow_failures:
- php: 8.1.0 # PHP 8.1 times out currently.
include:
- stage: lint
script:
- composer lint
- composer phpcs
- composer php-cs-fixer:test
php: 7.4
env: BUILD=lint
- stage: test
php: 5.6
php: 7.4
env:
- WP_VERSION=latest
- stage: test
php: 7.4
php: 8.0
env: WP_VERSION=latest
- stage: test
php: 8.0
php: 8.1.0
env: WP_VERSION=latest
31 changes: 0 additions & 31 deletions autoload.php

This file was deleted.

15 changes: 11 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@
{
"name": "Daniel Bachhuber",
"email": "[email protected]",
"homepage": "http://danielbachhuber.com",
"homepage": "https://danielbachhuber.com",
"role": "Developer"
}
],
"prefer-stable": true,
"minimum-stability": "dev",
"require": {
"php": ">=5.6"
"php": "^7.4 || ^8.0 || ^8.1",
"wp-cli/mustangostang-spyc": "^0.6.3"
},
"autoload": {
"psr-4": {
"BoxUk\\Dictator\\": "src/"
},
"files": [ "dictator.php" ]
},
"require-dev": {
Expand All @@ -32,7 +36,7 @@
"scripts": {
"behat": "run-behat-tests",
"behat-rerun": "rerun-behat-tests",
"lint": "run-linter-tests",
"lint": "run-linter-tests --exclude tools",
"phpcs": "run-phpcs-tests",
"phpunit": "run-php-unit-tests",
"prepare-tests": "install-package-tests",
Expand All @@ -41,7 +45,10 @@
"@phpcs",
"@phpunit",
"@behat"
]
],
"install-tools": "@composer update -W --working-dir=tools/php-cs-fixer",
"php-cs-fixer:test": "tools/php-cs-fixer/vendor/bin/php-cs-fixer fix -v --diff --dry-run",
"php-cs-fixer:fix": "tools/php-cs-fixer/vendor/bin/php-cs-fixer fix -v --diff"
},
"config": {
"allow-plugins": {
Expand Down
35 changes: 19 additions & 16 deletions dictator.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
<?php
/**
* Dictator controls the State of WordPress with WP-CLI
*
* Use wisely.
* Dictator controls the State of WordPress with WP-CLI.
*/

if ( ! defined( 'WP_CLI' ) || ! WP_CLI ) {
return;
declare(strict_types=1);

use BoxUk\Dictator\Command;
use BoxUk\Dictator\Dictator;
use BoxUk\Dictator\State\Network;
use BoxUk\Dictator\State\Site;

if (! defined('WP_CLI') || ! WP_CLI) {
return;
}

if ( ! defined( 'DICTATOR' ) ) {
define( 'DICTATOR', true );
if (! defined('DICTATOR')) {
define('DICTATOR', true);
}

/**
* Some files need to be manually loaded
*/
require_once dirname( __FILE__ ) . '/autoload.php';
require_once dirname( __FILE__ ) . '/php/class-dictator.php';
require_once dirname( __FILE__ ) . '/php/class-dictator-translator.php';
require_once dirname( __FILE__ ) . '/php/class-dictator-cli-command.php';
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
require_once __DIR__ . '/vendor/autoload.php';
}

WP_CLI::add_command('dictator', Command::class);

Dictator::add_state( 'network', '\Dictator\States\Network' );
Dictator::add_state( 'site', '\Dictator\States\Site' );
Dictator::addState('network', Network::class);
Dictator::addState('site', Site::class);
Loading

0 comments on commit 0af09e0

Please sign in to comment.