Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
59c5b8f
PHPCS: Add new ruleset to the project
thrijith Apr 22, 2019
3dcdde1
PHPCS: Fix up errors in src/WP_CLI/Entity
thrijith Apr 22, 2019
c263125
PHPCS: Update ruleset to exclude calsses from NamingConventions sniff
thrijith Apr 22, 2019
c528826
PHPCS: Update ruleset to exclude classes from MethodDeclaration.Under…
thrijith Apr 22, 2019
1f09a46
PHPCS: Update ruleset to exclude classes from PrefixAllGlobals.NonPre…
thrijith Apr 22, 2019
8595f9f
PHPCS: Update ruleset to exclude classes from PrefixAllGlobals.NonPre…
thrijith Apr 22, 2019
d90e4e3
PHPCS: Update ruleset to exclude classes from PrefixAllGlobals.NonPre…
thrijith Apr 22, 2019
a877b0f
PHPCS: Update ruleset to exclude classes from PrefixAllGlobals.NonPre…
thrijith Apr 22, 2019
f4d37e9
PHPCS: Update ruleset to exclude classes from PrefixAllGlobals.NonPre…
thrijith Apr 22, 2019
47de5f2
PHPCS: Update ruleset to exclude classes from PrefixAllGlobals.NonPre…
thrijith Apr 22, 2019
9150098
PHPCS: Update ruleset to exclude classes from PrefixAllGlobals.NonPre…
thrijith Apr 22, 2019
9676531
PHPCS: Update ruleset to exclude classes from PrefixAllGlobals.NonPre…
thrijith Apr 22, 2019
7087a84
PHPCS: Update ruleset to exclude classes from PrefixAllGlobals.NonPre…
thrijith Apr 22, 2019
f719f69
PHPCS: Fix up errors in entity-command.php and tests directory
thrijith Apr 22, 2019
1787646
Fix up imports and namespaces
schlessera Apr 23, 2019
f323174
Avoid variable abbreviations
schlessera Apr 23, 2019
a504042
Remove old-style PHPCS ignores
schlessera Apr 23, 2019
3d36d83
Automated whitespace fixes
schlessera Apr 23, 2019
5f2d680
Remove unused code
schlessera Apr 23, 2019
3403a53
Avoid PHP-4 comparison functions
schlessera Apr 23, 2019
ef52380
Use shortened ternary
schlessera Apr 23, 2019
e9a2bbd
Improve conditional structures
schlessera Apr 23, 2019
fe2c33b
Make string usage consistent
schlessera Apr 23, 2019
2fc941c
Avoid variable abbreviations
schlessera Apr 23, 2019
c356e0a
Whitelist use of hard-coded SQL query parts
schlessera Apr 23, 2019
ec25ca5
Fix bug in post generation
schlessera Apr 23, 2019
f33cacc
Fix typing bug in site management code
schlessera Apr 23, 2019
b571350
Fix bug in option list command
schlessera Apr 23, 2019
f6d5a67
Add missing import
schlessera Apr 23, 2019
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
2 changes: 2 additions & 0 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
.travis.yml
behat.yml
circle.yml
phpcs.xml.dist
phpunit.xml.dist
bin/
features/
utils/
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ vendor/
*.tar.gz
composer.lock
*.log
phpunit.xml
phpcs.xml
.phpcs.xml
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"wp-cli/db-command": "^1.3 || ^2",
"wp-cli/extension-command": "^1.2 || ^2",
"wp-cli/media-command": "^1.1 || ^2",
"wp-cli/wp-cli-tests": "^2.0.7"
"wp-cli/wp-cli-tests": "^2.1"
},
"config": {
"process-timeout": 7200,
Expand Down
98 changes: 59 additions & 39 deletions entity-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,63 +4,83 @@
return;
}

$autoload = dirname( __FILE__ ) . '/vendor/autoload.php';
if ( file_exists( $autoload ) ) {
require_once $autoload;
$wpcli_entity_autoloader = dirname( __FILE__ ) . '/vendor/autoload.php';
if ( file_exists( $wpcli_entity_autoloader ) ) {
require_once $wpcli_entity_autoloader;
}

WP_CLI::add_command( 'comment', 'Comment_Command' );
WP_CLI::add_command( 'comment meta', 'Comment_Meta_Command' );
WP_CLI::add_command( 'menu', 'Menu_Command' );
WP_CLI::add_command( 'menu item', 'Menu_Item_Command' );
WP_CLI::add_command( 'menu location', 'Menu_Location_Command' );
WP_CLI::add_command( 'network meta', 'Network_Meta_Command', array(
'before_invoke' => function () {
if ( !is_multisite() ) {
WP_CLI::error( 'This is not a multisite installation.' );
}
}
) );
WP_CLI::add_command(
'network meta',
'Network_Meta_Command',
array(
'before_invoke' => function () {
if ( ! is_multisite() ) {
WP_CLI::error( 'This is not a multisite installation.' );
}
},
)
);
WP_CLI::add_command( 'option', 'Option_Command' );
WP_CLI::add_command( 'post', 'Post_Command' );
WP_CLI::add_command( 'post meta', 'Post_Meta_Command' );
WP_CLI::add_command( 'post term', 'Post_Term_Command' );
WP_CLI::add_command( 'post-type', 'Post_Type_Command' );
WP_CLI::add_command( 'site', 'Site_Command' );
WP_CLI::add_command( 'site meta', 'Site_Meta_Command', array(
'before_invoke' => function() {
if ( !is_multisite() ) {
WP_CLI::error( 'This is not a multisite installation.' );
}
if( ! function_exists('is_site_meta_supported') || ! is_site_meta_supported() ){
WP_CLI::error( sprintf( 'The %s table is not installed. Please run the network database upgrade.', $GLOBALS['wpdb']->blogmeta ) );
}
}
) );
WP_CLI::add_command( 'site option', 'Site_Option_Command', array(
'before_invoke' => function() {
if ( !is_multisite() ) {
WP_CLI::error( 'This is not a multisite installation.' );
}
}
) );
WP_CLI::add_command(
'site meta',
'Site_Meta_Command',
array(
'before_invoke' => function() {
if ( ! is_multisite() ) {
WP_CLI::error( 'This is not a multisite installation.' );
}
if ( ! function_exists( 'is_site_meta_supported' ) || ! is_site_meta_supported() ) {
WP_CLI::error( sprintf( 'The %s table is not installed. Please run the network database upgrade.', $GLOBALS['wpdb']->blogmeta ) );
}
},
)
);
WP_CLI::add_command(
'site option',
'Site_Option_Command',
array(
'before_invoke' => function() {
if ( ! is_multisite() ) {
WP_CLI::error( 'This is not a multisite installation.' );
}
},
)
);
WP_CLI::add_command( 'taxonomy', 'Taxonomy_Command' );
WP_CLI::add_command( 'term', 'Term_Command' );
WP_CLI::add_command( 'term meta', 'Term_Meta_Command', array(
'before_invoke' => function() {
if ( \WP_CLI\Utils\wp_version_compare( '4.4', '<' ) ) {
WP_CLI::error( "Requires WordPress 4.4 or greater." );
}
})
WP_CLI::add_command(
'term meta',
'Term_Meta_Command',
array(
'before_invoke' => function() {
if ( \WP_CLI\Utils\wp_version_compare( '4.4', '<' ) ) {
WP_CLI::error( 'Requires WordPress 4.4 or greater.' );
}
},
)
);
WP_CLI::add_command( 'user', 'User_Command' );
WP_CLI::add_command( 'user meta', 'User_Meta_Command' );
WP_CLI::add_command( 'user session', 'User_Session_Command', array(
'before_invoke' => function() {
if ( \WP_CLI\Utils\wp_version_compare( '4.0', '<' ) ) {
WP_CLI::error( "Requires WordPress 4.0 or greater." );
}
})
WP_CLI::add_command(
'user session',
'User_Session_Command',
array(
'before_invoke' => function() {
if ( \WP_CLI\Utils\wp_version_compare( '4.0', '<' ) ) {
WP_CLI::error( 'Requires WordPress 4.0 or greater.' );
}
},
)
);

WP_CLI::add_command( 'user term', 'User_Term_Command' );
Expand Down
78 changes: 78 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0"?>
<ruleset name="WP-CLI-entity">
<description>Custom ruleset for WP-CLI entity-command</description>

<!--
#############################################################################
COMMAND LINE ARGUMENTS
For help understanding this file: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml
For help using PHPCS: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage
#############################################################################
-->

<!-- What to scan. -->
<file>.</file>

<!-- Show progress. -->
<arg value="p"/>

<!-- Strip the filepaths down to the relevant bit. -->
<arg name="basepath" value="./"/>

<!-- Check up to 8 files simultaneously. -->
<arg name="parallel" value="8"/>

<!--
#############################################################################
USE THE WP_CLI_CS RULESET
#############################################################################
-->

<rule ref="WP_CLI_CS"/>

<!--
#############################################################################
PROJECT SPECIFIC CONFIGURATION FOR SNIFFS
#############################################################################
-->

<!-- For help understanding the `testVersion` configuration setting:
https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
<config name="testVersion" value="5.4-"/>

<!-- Verify that everything in the global namespace is either namespaced or prefixed.
See: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#naming-conventions-prefix-everything-in-the-global-namespace -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<property name="prefixes" type="array">
<element value="WP_CLI\Entity"/><!-- Namespaces. -->
<element value="wpcli_entity"/><!-- Global variables and such. -->
</property>
</properties>
</rule>

<!-- Exclude existing classes from the prefix rule as it would break BC to prefix them now. -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedNamespaceFound">
<exclude-pattern>*/src/WP_CLI/Fetchers/(Comment|Post|Site|User)\.php$</exclude-pattern>
<exclude-pattern>*/src/WP_CLI/CommandWith(DBObject|Meta|Terms)\.php$</exclude-pattern>
</rule>

<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound">
<exclude-pattern>*/src/Taxonomy_Command\.php$</exclude-pattern>
<exclude-pattern>*/src/Comment(_Meta)?_Command\.php$</exclude-pattern>
<exclude-pattern>*/src/Menu(_Item|_Location)?_Command\.php$</exclude-pattern>
<exclude-pattern>*/src/Network_Meta_Command\.php$</exclude-pattern>
<exclude-pattern>*/src/Network_Namespace\.php$</exclude-pattern>
<exclude-pattern>*/src/Option_Command\.php$</exclude-pattern>
<exclude-pattern>*/src/Post(_Meta|_Term|_Type)?_Command\.php$</exclude-pattern>
<exclude-pattern>*/src/Site(_Meta|_Option)?_Command\.php$</exclude-pattern>
<exclude-pattern>*/src/Term(_Meta)?_Command\.php$</exclude-pattern>
<exclude-pattern>*/src/User(_Meta|_Session|_Term)?_Command\.php$</exclude-pattern>
</rule>

<!-- Whitelisting to provide backward compatibility to classes possibly extending this class. -->
<rule ref="PSR2.Methods.MethodDeclaration.Underscore">
<exclude-pattern>*/src/WP_CLI/CommandWithDBObject\.php$</exclude-pattern>
</rule>

</ruleset>
Loading