Skip to content

Commit

Permalink
Merge pull request #18 from deliciousbrains/ross-update
Browse files Browse the repository at this point in the history
Update dependencies and PHP version
  • Loading branch information
rosswintle authored Aug 10, 2022
2 parents cf6340e + bbb0a40 commit 0392117
Show file tree
Hide file tree
Showing 25 changed files with 169 additions and 103 deletions.
24 changes: 24 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

# WordPress Coding Standards
# https://make.wordpress.org/core/handbook/coding-standards/

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
tab_width = 4
indent_style = tab
insert_final_newline = false
trim_trailing_whitespace = true

[*.txt]
trim_trailing_whitespace = false

[*.{md,json,yml}]
trim_trailing_whitespace = false
indent_style = space
indent_size = 2
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
language: php

php:
- 5.6
- 7.0
- 7.1
- 7.3
- 7.4

install:
- composer install --prefer-dist --no-interaction --no-suggest
Expand All @@ -13,4 +12,4 @@ script:

after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[![Build Status](https://travis-ci.org/A5hleyRich/wp-queue.svg?branch=master)](https://travis-ci.org/A5hleyRich/wp-queue)
[![Code Coverage](https://scrutinizer-ci.com/g/A5hleyRich/wp-queue/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/A5hleyRich/wp-queue/?branch=master)
[![Total Downloads](https://poser.pugx.org/a5hleyrich/wp-queue/downloads)](https://packagist.org/packages/a5hleyrich/wp-queue)
[![Latest Stable Version](https://poser.pugx.org/a5hleyrich/wp-queue/v/stable)](https://packagist.org/packages/a5hleyrich/wp-queue)
[![License](https://poser.pugx.org/a5hleyrich/wp-queue/license)](https://packagist.org/packages/a5hleyrich/wp-queue)
[![Build Status](https://travis-ci.com/deliciousbrains/wp-queue.svg?branch=master)](https://travis-ci.com/deliciousbrains/wp-queue)
[![Code Coverage](https://scrutinizer-ci.com/g/deliciousbrains/wp-queue/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/deliciousbrains/wp-queue/?branch=master)
[![Total Downloads](https://poser.pugx.org/deliciousbrains/wp-queue/downloads)](https://packagist.org/packages/deliciousbrains/wp-queue)
[![Latest Stable Version](https://poser.pugx.org/deliciousbrains/wp-queue/v/stable)](https://packagist.org/packages/deliciousbrains/wp-queue)
[![License](https://poser.pugx.org/deliciousbrains/wp-queue/license)](https://packagist.org/packages/deliciousbrains/wp-queue)

## Prerequisites

WP_Queue requires PHP __5.3+__.
WP_Queue requires PHP __7.3+__.

The following database tables need to be created:

Expand Down Expand Up @@ -62,7 +62,7 @@ class Subscribe_User_Job extends Job {
*/
public function handle() {
$user = get_user_by( 'ID', $this->user_id );
// Process the user...
}
Expand Down Expand Up @@ -109,4 +109,4 @@ add_filter( ‘wp_queue_default_connection’, function() {

## License

WP Queue is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
WP Queue is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
23 changes: 18 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
{
"name": "a5hleyrich/wp-queue",
"name": "deliciousbrains/wp-queue",
"description": "WordPress job queues",
"keywords": ["wordpress","queue","job"],
"license": "MIT",
"authors": [
{
"name": "Ashley Rich",
"email": "hello@ashleyrich.com"
},
{
"name": "Delicious Brains",
"email": "nom@deliciousbrains.com"
}
],
"require": {
"php": ">=5.5.0",
"nesbot/carbon": "^1.22"
"php": ">=7.3.0",
"nesbot/carbon": "^2.0"
},
"autoload": {
"psr-4": {
Expand All @@ -22,7 +26,16 @@
]
},
"require-dev": {
"phpunit/phpunit": "~5.7.0",
"10up/wp_mock": "0.2.0"
"phpunit/phpunit": "^9.0.0",
"10up/wp_mock": "^0.4.2",
"humanmade/coding-standards": "^1.1",
"php-stubs/wp-cli-stubs": "^2.6",
"phpstan/phpstan": "^1.4",
"szepeviktor/phpstan-wordpress": "^1.0"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
29 changes: 29 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<ruleset name="Delicious Brains">
<!-- Files or directories to check -->
<file>.</file>

<!-- Path to strip from the front of file paths inside reports (displays shorter paths) -->
<arg name="basepath" value="." />

<!-- Use HM Coding Standards -->
<rule ref="vendor/humanmade/coding-standards">
<!-- Namespace isn't required for all files. -->
<exclude name="HM.Functions.NamespacedFunctions.MissingNamespace" />
<!-- Ignore rule expecting Namespaced directory. -->
<exclude name="HM.Files.NamespaceDirectoryName.NoIncDirectory" />
<!-- File name and class name match is not necessary. -->
<exclude name="HM.Files.ClassFileName.MismatchedName" />
<!-- Ignore class file name rule -->
<exclude name="WordPress.Files.FileName.InvalidClassFileName" />
<!-- Ignore rule expecting hyphens in file name. -->
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase" />
<!-- Don't require file comment header. -->
<exclude name="Squiz.Commenting.FileComment.Missing" />
</rule>

<!-- Ignore Snake case variables for tests -->
<rule ref="WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase">
<exclude-pattern>/tests/*</exclude-pattern>
</rule>
</ruleset>
10 changes: 10 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
includes:
- vendor/szepeviktor/phpstan-wordpress/extension.neon
parameters:
level: 5
paths:
- src
scanFiles:
- %rootDir%/../../php-stubs/wp-cli-stubs/wp-cli-stubs.php
- %rootDir%/../../php-stubs/wp-cli-stubs/wp-cli-commands-stubs.php
- %rootDir%/../../php-stubs/wp-cli-stubs/wp-cli-i18n-stubs.php
30 changes: 15 additions & 15 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?xml version="1.0"?>
<phpunit colors="true" backupGlobals="false" bootstrap="vendor/autoload.php">
<testsuites>
<testsuite name="wp-queue">
<directory prefix="Test" suffix=".php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
<exclude>
<directory suffix=".php">./vendor</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" backupGlobals="false" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage includeUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
<exclude>
<directory suffix=".php">./vendor</directory>
</exclude>
</coverage>
<testsuites>
<testsuite name="wp-queue">
<directory prefix="Test" suffix=".php">./tests</directory>
</testsuite>
</testsuites>
</phpunit>
2 changes: 1 addition & 1 deletion src/WP_Queue/Connections/ConnectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ public function jobs();
*/
public function failed_jobs();

}
}
32 changes: 16 additions & 16 deletions src/WP_Queue/Connections/DatabaseConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ public function __construct( $wpdb ) {
* @return bool|int
*/
public function push( Job $job, $delay = 0 ) {
$result = $this->database->insert( $this->jobs_table, array(
$result = $this->database->insert( $this->jobs_table, [
'job' => serialize( $job ),
'available_at' => $this->datetime( $delay ),
'created_at' => $this->datetime(),
) );
] );

if ( ! $result ) {
return false;
Expand Down Expand Up @@ -93,9 +93,9 @@ public function pop() {
* @return bool
*/
public function delete( $job ) {
$where = array(
$where = [
'id' => $job->id(),
);
];

if ( $this->database->delete( $this->jobs_table, $where ) ) {
return true;
Expand All @@ -112,14 +112,14 @@ public function delete( $job ) {
* @return bool
*/
public function release( $job ) {
$data = array(
$data = [
'job' => serialize( $job ),
'attempts' => $job->attempts(),
'reserved_at' => null,
);
$where = array(
];
$where = [
'id' => $job->id(),
);
];

if ( $this->database->update( $this->jobs_table, $data, $where ) ) {
return true;
Expand All @@ -137,11 +137,11 @@ public function release( $job ) {
* @return bool
*/
public function failure( $job, Exception $exception ) {
$insert = $this->database->insert( $this->failures_table, array(
$insert = $this->database->insert( $this->failures_table, [
'job' => serialize( $job ),
'error' => $this->format_exception( $exception ),
'failed_at' => $this->datetime(),
) );
] );

if ( $insert ) {
$this->delete( $job );
Expand All @@ -159,7 +159,7 @@ public function failure( $job, Exception $exception ) {
*/
public function jobs() {
$sql = "SELECT COUNT(*) FROM {$this->jobs_table}";

return (int) $this->database->get_var( $sql );
}

Expand All @@ -180,13 +180,13 @@ public function failed_jobs() {
* @param Job $job
*/
protected function reserve( $job ) {
$data = array(
$data = [
'reserved_at' => $this->datetime(),
);
];

$this->database->update( $this->jobs_table, $data, array(
$this->database->update( $this->jobs_table, $data, [
'id' => $job->id(),
) );
] );
}

/**
Expand Down Expand Up @@ -256,4 +256,4 @@ protected function format_exception( Exception $exception ) {
return $string;
}

}
}
9 changes: 1 addition & 8 deletions src/WP_Queue/Connections/RedisConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class RedisConnection implements ConnectionInterface {
* @return bool|int
*/
public function push( Job $job, $delay = 0 ) {
//
}

/**
Expand All @@ -25,7 +24,6 @@ public function push( Job $job, $delay = 0 ) {
* @return bool|Job
*/
public function pop() {
//
}

/**
Expand All @@ -34,7 +32,6 @@ public function pop() {
* @param Job $job
*/
public function delete( $job ) {
//
}

/**
Expand All @@ -43,7 +40,6 @@ public function delete( $job ) {
* @param Job $job
*/
public function release( $job ) {
//
}

/**
Expand All @@ -55,7 +51,6 @@ public function release( $job ) {
* @return bool
*/
public function failure( $job, Exception $exception ) {
//
}

/**
Expand All @@ -64,7 +59,6 @@ public function failure( $job, Exception $exception ) {
* @return int
*/
public function jobs() {
//
}

/**
Expand All @@ -73,7 +67,6 @@ public function jobs() {
* @return int
*/
public function failed_jobs() {
//
}

}
}
8 changes: 4 additions & 4 deletions src/WP_Queue/Connections/SyncConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SyncConnection implements ConnectionInterface {
*
* @return bool|int
*/
public function push(Job $job, $delay = 0) {
public function push( Job $job, $delay = 0 ) {
$job->handle();

return true;
Expand All @@ -36,7 +36,7 @@ public function pop() {
*
* @return bool
*/
public function delete($job) {
public function delete( $job ) {
return false;
}

Expand All @@ -47,7 +47,7 @@ public function delete($job) {
*
* @return bool
*/
public function release($job) {
public function release( $job ) {
return false;
}

Expand All @@ -59,7 +59,7 @@ public function release($job) {
*
* @return bool
*/
public function failure($job, Exception $exception) {
public function failure( $job, Exception $exception ) {
return false;
}

Expand Down
Loading

0 comments on commit 0392117

Please sign in to comment.