mirror of
https://github.com/10h30/wp-strava.git
synced 2026-07-11 18:56:18 +09:00
Merge pull request #88 from cmanon/feature/phpcs-improvements
Feature/phpcs improvements
This commit is contained in:
+6
-1
@@ -10,6 +10,11 @@
|
||||
"require-dev": {
|
||||
"wp-coding-standards/wpcs": "^2",
|
||||
"phpunit/phpunit": "^8",
|
||||
"10up/wp_mock": "^0.4"
|
||||
"10up/wp_mock": "^0.4",
|
||||
"phpcompatibility/php-compatibility": "^9.3",
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "@php ./vendor/bin/phpcs -s"
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+130
-4
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "dac3df251d687a478db972eda4d6d51a",
|
||||
"content-hash": "01b8759acf189fe4bde8c02a661eec75",
|
||||
"packages": [],
|
||||
"packages-dev": [
|
||||
{
|
||||
@@ -92,6 +92,72 @@
|
||||
],
|
||||
"time": "2019-12-22T17:52:09+00:00"
|
||||
},
|
||||
{
|
||||
"name": "dealerdirect/phpcodesniffer-composer-installer",
|
||||
"version": "v0.7.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git",
|
||||
"reference": "fe390591e0241955f22eb9ba327d137e501c771c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/fe390591e0241955f22eb9ba327d137e501c771c",
|
||||
"reference": "fe390591e0241955f22eb9ba327d137e501c771c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"composer-plugin-api": "^1.0 || ^2.0",
|
||||
"php": ">=5.3",
|
||||
"squizlabs/php_codesniffer": "^2.0 || ^3.0 || ^4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"composer/composer": "*",
|
||||
"phpcompatibility/php-compatibility": "^9.0",
|
||||
"sensiolabs/security-checker": "^4.1.0"
|
||||
},
|
||||
"type": "composer-plugin",
|
||||
"extra": {
|
||||
"class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Franck Nijhof",
|
||||
"email": "franck.nijhof@dealerdirect.com",
|
||||
"homepage": "http://www.frenck.nl",
|
||||
"role": "Developer / IT Manager"
|
||||
}
|
||||
],
|
||||
"description": "PHP_CodeSniffer Standards Composer Installer Plugin",
|
||||
"homepage": "http://www.dealerdirect.com",
|
||||
"keywords": [
|
||||
"PHPCodeSniffer",
|
||||
"PHP_CodeSniffer",
|
||||
"code quality",
|
||||
"codesniffer",
|
||||
"composer",
|
||||
"installer",
|
||||
"phpcs",
|
||||
"plugin",
|
||||
"qa",
|
||||
"quality",
|
||||
"standard",
|
||||
"standards",
|
||||
"style guide",
|
||||
"stylecheck",
|
||||
"tests"
|
||||
],
|
||||
"time": "2020-12-07T18:04:37+00:00"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/instantiator",
|
||||
"version": "1.3.0",
|
||||
@@ -411,6 +477,64 @@
|
||||
"description": "Library for handling version information and constraints",
|
||||
"time": "2018-07-08T19:19:57+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpcompatibility/php-compatibility",
|
||||
"version": "9.3.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHPCompatibility/PHPCompatibility.git",
|
||||
"reference": "9fb324479acf6f39452e0655d2429cc0d3914243"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243",
|
||||
"reference": "9fb324479acf6f39452e0655d2429cc0d3914243",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3",
|
||||
"squizlabs/php_codesniffer": "^2.3 || ^3.0.2"
|
||||
},
|
||||
"conflict": {
|
||||
"squizlabs/php_codesniffer": "2.6.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0"
|
||||
},
|
||||
"suggest": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.",
|
||||
"roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues."
|
||||
},
|
||||
"type": "phpcodesniffer-standard",
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"LGPL-3.0-or-later"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Wim Godden",
|
||||
"homepage": "https://github.com/wimg",
|
||||
"role": "lead"
|
||||
},
|
||||
{
|
||||
"name": "Juliette Reinders Folmer",
|
||||
"homepage": "https://github.com/jrfnl",
|
||||
"role": "lead"
|
||||
},
|
||||
{
|
||||
"name": "Contributors",
|
||||
"homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors"
|
||||
}
|
||||
],
|
||||
"description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.",
|
||||
"homepage": "http://techblog.wimgodden.be/tag/codesniffer/",
|
||||
"keywords": [
|
||||
"compatibility",
|
||||
"phpcs",
|
||||
"standards"
|
||||
],
|
||||
"time": "2019-12-27T09:44:58+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpdocumentor/reflection-common",
|
||||
"version": "2.0.0",
|
||||
@@ -875,6 +999,7 @@
|
||||
"keywords": [
|
||||
"tokenizer"
|
||||
],
|
||||
"abandoned": true,
|
||||
"time": "2019-09-17T06:23:10+00:00"
|
||||
},
|
||||
{
|
||||
@@ -1729,12 +1854,12 @@
|
||||
"version": "1.7.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/webmozart/assert.git",
|
||||
"url": "https://github.com/webmozarts/assert.git",
|
||||
"reference": "aed98a490f9a8f78468232db345ab9cf606cf598"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/webmozart/assert/zipball/aed98a490f9a8f78468232db345ab9cf606cf598",
|
||||
"url": "https://api.github.com/repos/webmozarts/assert/zipball/aed98a490f9a8f78468232db345ab9cf606cf598",
|
||||
"reference": "aed98a490f9a8f78468232db345ab9cf606cf598",
|
||||
"shasum": ""
|
||||
},
|
||||
@@ -1826,5 +1951,6 @@
|
||||
"platform": {
|
||||
"php": ">=5.3"
|
||||
},
|
||||
"platform-dev": []
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "1.1.0"
|
||||
}
|
||||
|
||||
@@ -8,10 +8,12 @@
|
||||
<exclude name="WordPress.Files.FileName.InvalidClassFileName" />
|
||||
</rule>
|
||||
|
||||
<file>./includes</file>
|
||||
<rule ref="PHPCompatibility"/>
|
||||
<config name="testVersion" value="5.3-7.4"/>
|
||||
<arg name="extensions" value="php"/>
|
||||
|
||||
<file>./src</file>
|
||||
<file>./wp-strava.php</file>
|
||||
|
||||
<exclude-pattern>*/vendor/*</exclude-pattern>
|
||||
|
||||
<config name="installed_paths" value="../../../vendor/wp-coding-standards/wpcs/" />
|
||||
</ruleset>
|
||||
|
||||
+3
-1
@@ -3,7 +3,7 @@
|
||||
Contributors: cmanon, jrfoell, lancewillett, dlintott, sebastianerb
|
||||
Tags: strava, activity, bicycle, cycling, biking, running, run, swimming, swim, paddle, kayak, gps, shortcode, widget, plugin, block, blocks
|
||||
Requires at least: 4.6
|
||||
Tested up to: 5.6
|
||||
Tested up to: 5.7
|
||||
Stable tag: 2.7.0
|
||||
Requires PHP: 5.3
|
||||
License: GPLv2 or later
|
||||
@@ -121,6 +121,8 @@ On the WP-Strava settings page you cannot currently remove and add another athle
|
||||
|
||||
= Unreleased =
|
||||
Revised `block.json` based on feedback from https://wordpress.org/plugins/developers/block-plugin-validator/
|
||||
Add PHPCompatibility checks to coding standards (and fixes from recommendations)
|
||||
|
||||
|
||||
= 2.7.0 =
|
||||
Add setting to choose API cache interval (1 hour / 15 minutes) https://wordpress.org/support/topic/decrease-update-time-for-group-recent-activities/
|
||||
|
||||
@@ -96,7 +96,7 @@ class WPStrava_API {
|
||||
$data = $this->remote_get( $uri, $args );
|
||||
|
||||
// Default to 1 hour of transient cache unless set otherwise.
|
||||
$settings = WPStrava::get_instance()->settings;
|
||||
$settings = WPStrava::get_instance()->settings;
|
||||
$cache_time = $settings->cache_time ? absint( $settings->cache_time ) : HOUR_IN_SECONDS;
|
||||
|
||||
set_transient( $transient_key, $data, $cache_time );
|
||||
|
||||
@@ -67,7 +67,7 @@ class WPStrava_Blocks_Activity implements WPStrava_Blocks_Interface {
|
||||
|
||||
$this->add_script = true;
|
||||
|
||||
$matches = [];
|
||||
$matches = array();
|
||||
preg_match( '/\/activities\/([0-9].*)$/', $attributes['url'], $matches );
|
||||
if ( $matches[1] ) {
|
||||
// Transform from block attributes to shortcode standard.
|
||||
|
||||
@@ -67,7 +67,7 @@ class WPStrava_Blocks_Route implements WPStrava_Blocks_Interface {
|
||||
|
||||
$this->add_script = true;
|
||||
|
||||
$matches = [];
|
||||
$matches = array();
|
||||
preg_match( '/\/routes\/([0-9].*)$/', $attributes['url'], $matches );
|
||||
if ( $matches[1] ) {
|
||||
// Transform from block attributes to shortcode standard.
|
||||
|
||||
@@ -544,8 +544,8 @@ class WPStrava_Settings {
|
||||
$fifteen_min = 15 * MINUTE_IN_SECONDS;
|
||||
?>
|
||||
<select id="strava_cache_time" name="strava_cache_time">
|
||||
<option value="<?php echo esc_attr( HOUR_IN_SECONDS )?>" <?php selected( $this->cache_time, HOUR_IN_SECONDS ); ?>><?php esc_html_e( '1 Hour', 'wp-strava' ); ?></option>
|
||||
<option value="<?php echo esc_attr( $fifteen_min )?>" <?php selected( $this->cache_time, $fifteen_min ); ?>><?php esc_html_e( '15 Minutes', 'wp-strava' ); ?></option>
|
||||
<option value="<?php echo esc_attr( HOUR_IN_SECONDS ); ?>" <?php selected( $this->cache_time, HOUR_IN_SECONDS ); ?>><?php esc_html_e( '1 Hour', 'wp-strava' ); ?></option>
|
||||
<option value="<?php echo esc_attr( $fifteen_min ); ?>" <?php selected( $this->cache_time, $fifteen_min ); ?>><?php esc_html_e( '15 Minutes', 'wp-strava' ); ?></option>
|
||||
</select>
|
||||
<p class="description"><?php esc_html_e( 'How often to refresh data from the Strava API', 'wp-strava' ); ?></p>
|
||||
<?php
|
||||
@@ -692,7 +692,9 @@ class WPStrava_Settings {
|
||||
public function save_info( $id, $secret, $info ) {
|
||||
$infos = get_option( 'strava_info' );
|
||||
$infos = empty( $infos ) ? array() : $infos;
|
||||
$infos = array_filter( $infos, array( $this, 'filter_by_id' ), ARRAY_FILTER_USE_KEY ); // Remove old IDs.
|
||||
|
||||
array_walk( $infos, array( $this, 'filter_by_id' ) );
|
||||
$infos = array_filter( $infos );
|
||||
|
||||
$info->client_secret = $secret;
|
||||
$infos[ $id ] = $info;
|
||||
@@ -700,19 +702,19 @@ class WPStrava_Settings {
|
||||
}
|
||||
|
||||
/**
|
||||
* array_filter() callback to remove info for IDs we no longer have.
|
||||
* array_walk() callback to clear IDs we no longer want.
|
||||
*
|
||||
* @param int $key Strava Client ID
|
||||
* @return boolean True if Client ID is in $this->ids, false otherwise.
|
||||
* @author Justin Foell <justin@foell.org>
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public function filter_by_id( $key ) {
|
||||
public function filter_by_id( &$value, $key ) {
|
||||
$ids = $this->get_ids();
|
||||
if ( in_array( $key, $ids ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict -- Loose comparison OK.
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
return false;
|
||||
|
||||
$value = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,12 +6,12 @@ class WPStrava_SOMEnglishTest extends TestCase {
|
||||
|
||||
private $som;
|
||||
|
||||
public function setUp() : void {
|
||||
public function setUp() : void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound -- PHPUnit requires PHP7
|
||||
\WP_Mock::setUp();
|
||||
$this->som = new WPStrava_SOMEnglish();
|
||||
}
|
||||
|
||||
public function tearDown() : void {
|
||||
public function tearDown() : void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound -- PHPUnit requires PHP7
|
||||
\WP_Mock::tearDown();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user