Skip to content

Commit

Permalink
Merge pull request #3 from inpsyde/modernize
Browse files Browse the repository at this point in the history
Modernize codebase and QA
  • Loading branch information
gmazzap authored May 20, 2024
2 parents 3521f5d + 49e9df1 commit 782b914
Show file tree
Hide file tree
Showing 40 changed files with 2,919 additions and 1,817 deletions.
9 changes: 6 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
* text eol=lf

/.github/ export-ignore
/tests/ export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/phpcs.xml.dist export-ignore
/phpunit.xml.dist export-ignore
/README.md export-ignore
/tests/ export-ignore
/psalm.xml export-ignore
/CHANGELOG.md export-ignore
/README.md export-ignore
58 changes: 58 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Static Analysis

on:
push:
paths:
- '**workflows/static-analysis.yml'
- '**.php'
- '**phpcs.xml.dist'
- '**psalm.xml'
pull_request:
paths:
- '**workflows/static-analysis.yml'
- '**.php'
- '**phpcs.xml.dist'
- '**psalm.xml'
workflow_dispatch:
inputs:
jobs:
required: true
type: choice
default: 'Run all'
description: 'Choose jobs to run'
options:
- 'Run all'
- 'Run PHPCS only'
- 'Run Psalm only'
- 'Run lint only'

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true

jobs:
lint:
if: ${{ (github.event_name != 'workflow_dispatch') || ((github.event.inputs.jobs == 'Run all') || (github.event.inputs.jobs == 'Run lint only')) }}
uses: inpsyde/reusable-workflows/.github/workflows/lint-php.yml@main
strategy:
matrix:
php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]
with:
PHP_VERSION: ${{ matrix.php }}
LINT_ARGS: '-e php --colors --show-deprecated ./inc ./src'

coding-standards-analysis:
if: ${{ (github.event_name != 'workflow_dispatch') || ((github.event.inputs.jobs == 'Run all') || (github.event.inputs.jobs == 'Run PHPCS only')) }}
uses: inpsyde/reusable-workflows/.github/workflows/coding-standards-php.yml@main
with:
PHP_VERSION: '8.3'

static-code-analysis:
if: ${{ (github.event_name != 'workflow_dispatch') || ((github.event.inputs.jobs == 'Run all') || (github.event.inputs.jobs == 'Run Psalm only')) }}
uses: inpsyde/reusable-workflows/.github/workflows/static-analysis-php.yml@main
strategy:
matrix:
php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]
with:
PHP_VERSION: ${{ matrix.php }}
PSALM_ARGS: --output-format=github --no-suggestions --no-cache --no-diff
63 changes: 63 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Unit Tests

on:
push:
paths:
- '**workflows/unit-tests.yml'
- '**.php'
- '**phpunit.xml.dist'
pull_request:
paths:
- '**workflows/unit-tests.yml'
- '**.php'
- '**phpcs.xml.dist'
workflow_dispatch:

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true

jobs:
unit-tests-php:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-ver: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]
wp-ver: [ '5.9', '6.0', '6.1', '6.2', '6.3', '6.4', '6' ]
exclude:
- php-ver: '8.2'
wp-ver: '5.9'
- php-ver: '8.3'
wp-ver: '5.9'
- php-ver: '8.2'
wp-ver: '6.0'
- php-ver: '8.3'
wp-ver: '6.0'
- php-ver: '8.3'
wp-ver: '6.1'
- php-ver: '8.3'
wp-ver: '6.2'
- php-ver: '8.3'
wp-ver: '6.3'
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-ver }}
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
coverage: none

- name: Adjust dependencies in 'composer.json'
run: |
composer remove roots/wordpress-no-content inpsyde/php-coding-standards vimeo/psalm --dev --no-update
composer require "roots/wordpress-no-content:~${{ matrix.wp-ver }}.0" --dev --no-update
- name: Install dependencies
uses: ramsey/composer-install@v3

- name: Run unit tests
run: ./vendor/bin/phpunit --no-coverage
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/coverage/
composer.lock
vendor/
/phpunit.xml
/phpunit.xml
/.phpunit.result.cache
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
# Object Hooks Remover

## Next

- Modernize codebase to support recent PHP versions and up-to-date Syde coding standards.
- Move logic from `utils.php` file to an internal `Functions` class (all-static, only for encapsulation and autoload).
- Modernize QA:
- Move out from Travis to GitHub actions.
- Rewrite tests, update PHPUnit version, tests now include the real WordPress functions instead of stubs.
- Added static analysis.
- Introduced `remove_all_object_hooks()`.
- Introduced `remove_static_method_hook()` to replace the now deprecated `remove_class_hook()` (which is converted to an alias).
- In `remove_closure_hook()` is now possible to use `"mixed"` as target parameter type when the closure param declare no type.
- License change from MIT to GPL due to usage of WordPress functions.
- README refresh.

---

## v0.1.1 (2017-12-19)

### Fixed

- Fix PHP 7 compatibility when removing hook with closures declaring param types.

---

## v0.1.0 (2017-12-03)

First release.
Loading

0 comments on commit 782b914

Please sign in to comment.