Skip to content

Commit c3314bf

Browse files
committed
Spring cleaning
1 parent b5daceb commit c3314bf

7 files changed

Lines changed: 75 additions & 134 deletions

File tree

.travis.yml

Lines changed: 0 additions & 73 deletions
This file was deleted.

behat.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
default:
2+
suites:
3+
default:
4+
contexts:
5+
- WP_CLI\Tests\Context\FeatureContext
6+
paths:
7+
- features

composer.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,20 @@
1717
}
1818
],
1919
"require": {
20-
"php": ">=5.4",
20+
"php": ">=7.2",
2121
"wp-cli/wp-cli": "^2"
2222
},
2323
"require-dev": {
2424
"wp-cli/extension-command": "^2",
25-
"wp-cli/wp-cli-tests": "^2.0.7"
25+
"wp-cli/wp-cli-tests": "^5"
2626
},
2727
"config": {
28-
"platform": {
29-
"php": "5.4"
30-
},
28+
"lock": false,
3129
"process-timeout": 7200,
3230
"sort-packages": true,
3331
"allow-plugins": {
34-
"dealerdirect/phpcodesniffer-composer-installer": true
32+
"dealerdirect/phpcodesniffer-composer-installer": true,
33+
"phpstan/extension-installer": true
3534
}
3635
},
3736
"autoload": {
@@ -46,13 +45,17 @@
4645
"prefer-stable": true,
4746
"scripts": {
4847
"behat": "run-behat-tests",
48+
"behat-rerun": "rerun-behat-tests",
4949
"lint": "run-linter-tests",
5050
"phpcs": "run-phpcs-tests",
51+
"phpstan": "run-phpstan-tests",
52+
"phpcbf": "run-phpcbf-cleanup",
5153
"phpunit": "run-php-unit-tests",
5254
"prepare-tests": "install-package-tests",
5355
"test": [
5456
"@lint",
5557
"@phpcs",
58+
"@phpstan",
5659
"@phpunit",
5760
"@behat"
5861
]

phpcs.xml.dist

Lines changed: 42 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,53 @@
11
<?xml version="1.0"?>
2-
<ruleset name="WP-CLI">
3-
<description>Custom ruleset for WP-CLI</description>
2+
<ruleset name="WP-CLI-core">
3+
<description>Custom ruleset for WP-CLI core-command</description>
4+
5+
<!--
6+
#############################################################################
7+
COMMAND LINE ARGUMENTS
8+
For help understanding this file: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml
9+
For help using PHPCS: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage
10+
#############################################################################
11+
-->
12+
13+
<!-- What to scan. -->
14+
<file>.</file>
415

5-
<!-- For help in understanding this file: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
6-
<!-- For help in using PHPCS: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage -->
16+
<!-- Show progress. -->
17+
<arg value="p"/>
718

8-
<!-- What to scan -->
9-
<file>.</file>
10-
<!-- Ignoring Files and Folders:
11-
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-files-and-folders -->
12-
<exclude-pattern>*/.git/*</exclude-pattern>
13-
<exclude-pattern>*/ci/*</exclude-pattern>
14-
<exclude-pattern>*/features/*</exclude-pattern>
15-
<exclude-pattern>*/packages/*</exclude-pattern>
16-
<exclude-pattern>*/tests/*</exclude-pattern>
17-
<exclude-pattern>*/utils/*</exclude-pattern>
18-
<exclude-pattern>*/vendor/*</exclude-pattern>
19-
20-
<!-- How to scan -->
21-
<arg value="sp"/> <!-- Show sniff and progress -->
22-
<arg name="colors"/> <!-- Show results with colors -->
23-
<arg name="extensions" value="php"/> <!-- Limit to PHP files -->
24-
25-
<!-- Rules: Check PHP version compatibility - see
26-
https://github.com/PHPCompatibility/PHPCompatibilityWP -->
27-
<rule ref="PHPCompatibilityWP">
28-
<!-- Polyfill package is used so array_column() is available for PHP 5.4- -->
29-
<exclude name="PHPCompatibility.PHP.NewFunctions.array_columnFound"/>
30-
<!-- Both magic quotes directives set in wp-settings-cli.php to provide consistent starting point. -->
31-
<exclude name="PHPCompatibility.PHP.DeprecatedIniDirectives.magic_quotes_runtimeDeprecatedRemoved"/>
32-
<exclude name="PHPCompatibility.PHP.DeprecatedIniDirectives.magic_quotes_sybaseDeprecatedRemoved"/>
33-
</rule>
19+
<!-- Strip the filepaths down to the relevant bit. -->
20+
<arg name="basepath" value="./"/>
3421

35-
<!-- For help in understanding this testVersion:
36-
https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
37-
<config name="testVersion" value="5.4-"/>
22+
<!-- Check up to 8 files simultaneously. -->
23+
<arg name="parallel" value="8"/>
3824

39-
<!-- Ignore php_uname mode issue, we're conditionally providing a callback -->
40-
<rule ref="PHPCompatibility.PHP.NewFunctionParameters.php_uname_modeFound">
41-
<exclude-pattern>*/php/commands/src/CLI_Command.php</exclude-pattern>
42-
</rule>
25+
<!--
26+
#############################################################################
27+
USE THE WP_CLI_CS RULESET
28+
#############################################################################
29+
-->
4330

44-
<!-- Rules: WordPress Coding Standards - see
45-
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards -->
46-
<rule ref="WordPress-Core">
47-
<exclude name="Squiz.PHP.DisallowMultipleAssignments.Found" />
48-
<exclude name="WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar" />
49-
<exclude name="WordPress.NamingConventions.ValidVariableName.MemberNotSnakeCase" />
50-
<exclude name="WordPress.NamingConventions.ValidVariableName.NotSnakeCase" />
51-
</rule>
31+
<rule ref="WP_CLI_CS"/>
32+
33+
<!--
34+
#############################################################################
35+
PROJECT SPECIFIC CONFIGURATION FOR SNIFFS
36+
#############################################################################
37+
-->
38+
39+
<!-- For help understanding the `testVersion` configuration setting:
40+
https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
41+
<config name="testVersion" value="7.2-"/>
5242

53-
<!-- For help in understanding these custom sniff properties:
54-
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties -->
55-
<rule ref="WordPress.Files.FileName">
43+
<!-- Verify that everything in the global namespace is either namespaced or prefixed.
44+
See: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#naming-conventions-prefix-everything-in-the-global-namespace -->
45+
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
5646
<properties>
57-
<property name="strict_class_file_names" value="false"/>
47+
<property name="prefixes" type="array">
48+
<element value="WP_Super_Cache"/>
49+
<element value="wpsc"/>
50+
</property>
5851
</properties>
59-
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase" />
6052
</rule>
6153
</ruleset>

src/WP_Super_Cache_CLI_Loader.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ private function register_hooks() {
7575
* @return void
7676
*/
7777
public function init_cache_base() {
78+
// phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
7879
global $WPSC_HTTP_HOST;
7980

8081
if ( ! defined( 'WPCACHEHOME' ) ) {
@@ -89,6 +90,7 @@ public function init_cache_base() {
8990
$_SERVER['HTTP_HOST'] = $this->parse_home_url( PHP_URL_HOST );
9091
}
9192

93+
// phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
9294
if ( empty( $WPSC_HTTP_HOST ) ) {
9395
$this->maybe_include_file( 'include', 'wp-cache-base.php' );
9496
}
@@ -120,6 +122,7 @@ private function maybe_load_config() {
120122
WP_CLI::warning( 'Default cache config file loaded - ' . str_replace( ABSPATH, '', $wp_cache_config_file_sample ) );
121123
}
122124

125+
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
123126
$wp_cache_home_path = trailingslashit( $this->parse_home_url( PHP_URL_PATH ) );
124127
}
125128

@@ -186,14 +189,17 @@ private function multisite_override_settings() {
186189
if ( ! is_multisite() ) {
187190
// Prevents PHP notices for single site installation.
188191
if ( ! isset( $blog_cache_dir ) ) {
192+
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
189193
$blog_cache_dir = $cache_path;
190194
}
191195

192196
return;
193197
}
194198

195199
if ( is_object( $current_site ) ) {
196-
$blogcacheid = trim( is_subdomain_install() ? $current_site->domain : $current_site->path, '/' );
200+
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
201+
$blogcacheid = trim( is_subdomain_install() ? $current_site->domain : $current_site->path, '/' );
202+
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
197203
$blog_cache_dir = $cache_path . 'blogs/' . $blogcacheid . '/';
198204
}
199205
}
@@ -241,6 +247,7 @@ private function maybe_include_file( $func, $filename, $run = '' ) {
241247
global $wp_cache_mobile, $wp_cache_mobile_enabled, $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes;
242248
// Globals from other files.
243249
global $wp_cache_config_file, $wp_cache_config_file_sample, $cache_domain_mapping;
250+
// phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
244251
global $WPSC_HTTP_HOST, $blogcacheid, $blog_cache_dir;
245252

246253
$file = $this->get_wpsc_filename( $filename );
@@ -338,6 +345,7 @@ private function is_wpsc_plugin_active() {
338345
private function parse_home_url( $component ) {
339346
return function_exists( 'wp_parse_url' )
340347
? (string) wp_parse_url( get_option( 'home' ), $component )
348+
// phpcs:ignore WordPress.WP.AlternativeFunctions.parse_url_parse_url
341349
: (string) parse_url( get_option( 'home' ), $component );
342350
}
343351
}

src/WP_Super_Cache_Command.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public function status( $args = array(), $assoc_args = array() ) {
9292
$cache_stats = get_option( 'supercache_stats' );
9393
if ( ! empty( $cache_stats ) ) {
9494
if ( $cache_stats['generated'] > time() - 3600 * 24 ) {
95+
// phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
9596
WP_CLI::line( 'Cache content on ' . date( 'r', $cache_stats['generated'] ) . ': ' );
9697
WP_CLI::line();
9798
WP_CLI::line( ' WordPress cache:' );
@@ -176,7 +177,10 @@ public function preload( $args = array(), $assoc_args = array() ) {
176177
WP_CLI::error( 'The WP Super Cache is not enabled.' );
177178
}
178179

179-
if ( defined( 'DISABLESUPERCACHEPRELOADING' ) && true == DISABLESUPERCACHEPRELOADING ) {
180+
if (
181+
defined( 'DISABLESUPERCACHEPRELOADING' ) &&
182+
( true === DISABLESUPERCACHEPRELOADING || 'true' === DISABLESUPERCACHEPRELOADING )
183+
) {
180184
WP_CLI::error( 'Cache preloading is not enabled.' );
181185
}
182186

wp-super-cache-cli.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22

3-
$autoload = dirname( __FILE__ ) . '/vendor/autoload.php';
3+
$wpsc_autoload = __DIR__ . '/vendor/autoload.php';
44

5-
if ( file_exists( $autoload ) ) {
6-
require_once $autoload;
5+
if ( file_exists( $wpsc_autoload ) ) {
6+
require_once $wpsc_autoload;
77
}
88

99
if ( ! class_exists( 'WP_CLI' ) ) {

0 commit comments

Comments
 (0)