Skip to content
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
31 changes: 31 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Normalise line endings on commit and check out LF everywhere, so the tab/LF
# style declared in .editorconfig survives contributors on other platforms.
* text=auto eol=lf

# WordPress ships plugin readmes with CRLF; matches the .editorconfig rule.
*.txt text eol=crlf

# Use git's built-in hunk-header drivers, so diffs name the enclosing
# function/class instead of showing bare line numbers.
*.php diff=php
*.md diff=markdown

# Machine-written files. Collapsed by default in reviews and excluded from
# language stats; composer.lock is also deliberately unowned in CODEOWNERS.
composer.lock linguist-generated=true
languages/*.pot linguist-generated=true

# Development-only files, excluded from `git archive` and from the dist zip
# Composer downloads for a wordpress-plugin package.
/.github/ export-ignore
/.idea/ export-ignore
/tests/ export-ignore
/.editorconfig export-ignore
/.eslintignore export-ignore
/.eslintrc export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.php-cs-fixer.php export-ignore
/phpstan.neon export-ignore
/phpunit.xml.dist export-ignore
/composer.lock export-ignore
5 changes: 5 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# These owners are the default owners for everything in the repo.
* @yardinternet/wordpress-backend

# Listed with no owner so PRs that only touch them don't request a review.
composer.lock
25 changes: 25 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
groups:
actions:
patterns:
- "*"
commit-message:
prefix: "chore"

- package-ecosystem: "composer"
registries: "*"
directory: "/"
schedule:
interval: "weekly"
groups:
composer:
patterns:
- "*"
commit-message:
prefix: "chore"
versioning-strategy: lockfile-only
8 changes: 8 additions & 0 deletions .github/workflows/dependabot-automerge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Dependabot automerge

on: pull_request

jobs:
dependabot-automerge:
uses: yardinternet/workflows/.github/workflows/dependabot-automerge.yml@main
secrets: inherit
13 changes: 13 additions & 0 deletions .github/workflows/format-php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Code Style

on:
pull_request:
paths:
- "**.php"

jobs:
php-cs-fixer:
uses: yardinternet/workflows/.github/workflows/format-php.yml@main
secrets: inherit
with:
php-version: "8.2"
47 changes: 47 additions & 0 deletions .github/workflows/test-php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Tests

on:
pull_request:
paths:
- "**.php"
- "composer.json"
- "composer.lock"
- ".github/workflows/test-php.yml"

jobs:
phpunit:
name: PHPUnit (PHP ${{ matrix.php-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version: ["8.2"]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: none
tools: composer:v2

- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"

- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php-version }}-composer-

- name: Install dependencies
run: composer install --no-interaction --no-progress --prefer-dist

- name: Run PHPUnit
run: composer test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
.php_cs.cache
.php-cs-fixer.cache
.phpunit.result.cache
phpunit.xml

# Folders
vendor
wp-content
tests/logs
10 changes: 1 addition & 9 deletions .idea/openklacht.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 2 additions & 9 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 16 additions & 62 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,20 @@

declare(strict_types=1);

$finder = PhpCsFixer\Finder::create()
->notPath('vendor')
->notPath('node_modules')
->notPath('wp-content')
->in(__DIR__)
->in('./resources')
->in('./config')
->name('*.php')
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true);
use PhpCsFixer\Finder;
use Yard\PhpCsFixerRules\Config;

return (new PhpCsFixer\Config)
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => [
'sort_algorithm' => 'alpha',
],
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
'phpdoc_scalar' => true,
'phpdoc_var_without_name' => true,
'phpdoc_single_line_var_spacing' => true,
'unary_operator_spaces' => true,
'phpdoc_trim' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'align_multiline_comment' => true,
'array_indentation' => true,
'no_superfluous_elseif' => true,
'single_blank_line_before_namespace' => true,
'blank_line_after_opening_tag' => false,
'no_blank_lines_after_phpdoc' => true,
'phpdoc_separation' => true,
'binary_operator_spaces' => [
'default' => 'single_space',
'operators' => [
'=' => 'single_space',
'=>' => 'single_space',
'|' => 'no_space',
],
],
'return_type_declaration' => [
'space_before' => 'none',
],
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
],
'full_opening_tag' => true,
'method_argument_space' => [
'on_multiline' => 'ensure_fully_multiline',
'keep_multiple_spaces_after_comma' => true,
],
'yoda_style' => [
'always_move_variable' => true,
'equal' => true,
'identical' => true,
'less_and_greater' => true,
],
'declare_strict_types' => true,
])
->setRiskyAllowed(true)
->setFinder($finder);
# PHP CS Fixer can be run by using the composer script `composer format`

$finder = Finder::create()
->in(__DIR__)
->name('*.php')
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true)
->exclude('vendor')
->exclude('node_modules')
->exclude('wp-content')
->append(['.php-cs-fixer.php']);

return Config::create($finder);
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# CHANGELOG

## Version 2.0.0

- Breaking: PHP 8.2 is now the minimum supported version.
- Breaking: WordPress 6.5 is now the minimum supported version, required for the `Requires Plugins` header.
- Chore: CMB2 is declared through the `Requires Plugins` plugin header instead of as a Composer runtime dependency, since it is installed as a separate WordPress plugin. It moves to `require-dev` for local development.
- Feature: `okl_date_received` and `okl_judgement_date` are superseded by `okl_date_received_date` and `okl_judgement_date_date`, which render a datepicker and store a fixed `d-m-Y` value instead of a locale-dependent display string.
- Feature: add `okl_judgement_date_sortable` to the Elasticsearch document, alongside the existing `okl_date_received_sortable`.
- Deprecated: `okl_date_received` and `okl_judgement_date` remain registered, exposed via the REST API and indexed, so existing complaints keep their stored value. They are no longer written on form submission, and no longer read as a fallback for the sortable dates. No existing data is modified.
- Breaking: complaints whose date is only in a deprecated field no longer produce `okl_date_received_sortable` or `okl_judgement_date_sortable`, so they drop out of date-sorted results until the date is re-entered in the datepicker field.
- Fix: the Elasticsearch sortable dates are derived from the fixed-format fields alone, so they no longer depend on the site locale at any point.
- Chore: the `intl` extension is no longer required, as nothing parses locale-formatted dates any more.
- Chore: metabox field definitions are passed to CMB2 in full, so field types can carry their own options.
- Chore: add a PHPStan configuration, repair the php-cs-fixer file finder, and modernise the codebase for PHP 8.2.

## Version 1.0.4

- Chore: update deps
Expand Down
35 changes: 17 additions & 18 deletions autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@

class Autoloader
{

/**
* Autoloader constructor.
* PSR autoloader
*/
public function __construct()
{
spl_autoload_register(function ($className) {
$baseDir = __DIR__.'/src/';
$namespace = str_replace('\\', '/', __NAMESPACE__);
$className = str_replace('\\', '/', $className);
$class = $baseDir.(empty($namespace) ? '' : $namespace.'/').$className.'.php';
$class = str_replace('/OWC/OpenKlacht/', '/OpenKlacht/', $class);
if (file_exists($class)) {
require_once($class);
}
});
}
/**
* Autoloader constructor.
* PSR autoloader
*/
public function __construct()
{
spl_autoload_register(function ($className) {
$baseDir = __DIR__.'/src/';
$namespace = str_replace('\\', '/', __NAMESPACE__);
$className = str_replace('\\', '/', $className);
$class = $baseDir.(empty($namespace) ? '' : $namespace.'/').$className.'.php';
$class = str_replace('/OWC/OpenKlacht/', '/OpenKlacht/', $class);
if (file_exists($class)) {
require_once($class);
}
});
}
}
Loading
Loading