Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing typeerror when get_term() returns WP_Error #22

Merged
merged 10 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

name: CI

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

jobs:
php-tests:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- uses: actions/checkout@v4

- name: Run PHP Tests in src directory
uses: alleyinteractive/action-test-php@develop
with:
skip-services: 'true'
wordpress-version: 'false'
13 changes: 0 additions & 13 deletions .github/workflows/coding-standards.yml

This file was deleted.

13 changes: 0 additions & 13 deletions .github/workflows/unit-test.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ build
vendor
composer.lock
node_modules
.phpunit.cache

# Log files
*.log
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

All notable changes to Cache Collector will be documented in this file.

## 1.1.0 - 2024-07-16

- Fix type error when purging against an unknown term.

## v1.0.1 - 2023-12-07

- Fix to register the post type on `init`.

## v1.0.0 - 2023-12-02

- Initial release.

## 0.1.1 - 2022-12-07

- Fix bug with post type registration being called before `init`.
Expand Down
11 changes: 7 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
],
"homepage": "https://github.com/alleyinteractive/cache-collector",
"require": {
"php": "^8.0"
"php": "^8.1"
},
"require-dev": {
"alleyinteractive/alley-coding-standards": "^1.0",
"alleyinteractive/alley-coding-standards": "^2.0",
"alleyinteractive/composer-wordpress-autoloader": "^1.0",
"mantle-framework/testkit": "^0.9",
"nunomaduro/collision": "^5.0"
"mantle-framework/testkit": "^1.0",
"php-stubs/wp-cli-stubs": "^2.10",
"szepeviktor/phpstan-wordpress": "^1.3"
},
"suggest": {
"psr/log": "For logging messages to when purging the cache"
Expand All @@ -46,9 +47,11 @@
"scripts": {
"phpcbf": "phpcbf .",
"phpcs": "phpcs .",
"phpstan": "phpstan --memory-limit=512M",
"phpunit": "phpunit",
"test": [
"@phpcs",
"@phpstan",
"@phpunit"
]
}
Expand Down
24 changes: 24 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
includes:
- vendor/szepeviktor/phpstan-wordpress/extension.neon

parameters:
# Level 9 is the highest level
level: max

paths:
- src/
- plugin.php

scanFiles:
- %rootDir%/../../php-stubs/wordpress-stubs/wordpress-stubs.php
- %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

# ignoreErrors:
# - '#PHPDoc tag @var#'
#
# excludePaths:
# - ./*/*/FileToBeExcluded.php
#
# checkMissingIterableValueType: false
24 changes: 12 additions & 12 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?xml version="1.0"?>
<phpunit
bootstrap="tests/bootstrap.php"
backupGlobals="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
printerClass="NunoMaduro\Collision\Adapters\Phpunit\Printer"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="tests/bootstrap.php"
backupGlobals="false"
colors="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.2/phpunit.xsd"
cacheDirectory=".phpunit.cache"
>
<testsuites>
<testsuite name="general">
<directory prefix="test-" suffix=".php">tests</directory>
</testsuite>
</testsuites>
<testsuites>
<testsuite name="general">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>
</phpunit>
7 changes: 4 additions & 3 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
* Plugin Name: cache-collector
* Plugin URI: https://github.com/alleyinteractive/cache-collector
* Description: Dynamic cache key collector for easy purging.
* Version: 0.1.0
* Version: 1.1.0
* Author: Sean Fisher
* Author URI: https://github.com/alleyinteractive/cache-collector
* Requires at least: 5.9
* Tested up to: 5.9
* Requires PHP: 8.1
* Tested up to: 6.6
*
* @package cache-collector
*/
Expand All @@ -23,7 +24,7 @@
/**
* Instantiate the plugin.
*/
function cache_collector_setup() {
function cache_collector_setup(): void {
add_action( 'init', [ Cache_Collector::class, 'register_post_type' ] );

// Register the post/term purge actions.
Expand Down
Loading