Skip to content

Ci/release flow#2

Merged
justlevine merged 7 commits intotrunkfrom
ci/release-flow
Aug 16, 2025
Merged

Ci/release flow#2
justlevine merged 7 commits intotrunkfrom
ci/release-flow

Conversation

@justlevine
Copy link
Owner

Test and merge

justlevine and others added 7 commits August 13, 2025 15:49
* tools: Implement repo scaffolding (squashed

* ci: clean up workflow smells

* ci: `test:php` is same for coverage/non-coverage

* docs: lint issue with split comment

* tests(phpunit): fix `TESTS_REPO_ROOT_DIR` when bootstrapping
* add: REST API controllers for Abilities API

Implements REST endpoints for listing and executing abilities through
the WordPress REST API, enabling programmatic access to registered abilities.

* fix: Remove non-existent method call in REST controller

Fixed REST controller calling non-existent get_execute_callback() method.
Always show run link for abilities in REST responses.

* fix: Update REST routes for GET/POST method support

- Register run controller before list controller to fix route precedence
- Support both GET (resources) and POST (tools) methods based on ability type
- Add TODO comment explaining load order issue with ALLMETHODS
- Remove result wrapper to match Feature API response format
- Handle query params for GET requests and JSON body for POST

* test: Add comprehensive REST API test coverage with 57 passing tests

* add: Load REST API controllers in main plugin file

* fix: Use trunk's test infrastructure instead of custom setup

* fix: Code quality improvements for REST API controllers

PHPStan fixes:
- Add return type annotations for void methods
- Add array type hints for array parameters and returns
- Cast integer header values to strings (PHPStan stubs expect strings)
- Add ignore rule for WP_REST_Request generic types with explanation

PHPCS compliance:
- Add file documentation headers to all REST API files
- Use fully qualified class names in PHPDoc comments
- Add 'abilities-api' domain to all translation functions
- Fix array alignment and spacing issues
- Fix short ternary operators to explicit conditionals
- Add periods to inline comments
- Simplify elseif logic in run controller

Type hints and modern PHP:
- Add native PHP type hints where compatible with PHP 7.4+
- Add WP_REST_Abilities prefix to allowed prefixes in PHPCS config
- Use native return types (void, array, bool) and parameter types

* refactor: Apply PR #6 feedback - change id to name throughout REST API

* fix: Address PHPStan and PHPCS issues in REST controllers

- Add array<string, mixed> type hint for get_input_from_request return
- Add public visibility to DEFAULT_PER_PAGE constant

* fix: Add type hints to REST API controller methods

* docs: Soften language in PHPStan configuration comment

* test: Add comprehensive REST API test coverage

- Add test coverage for REST API controllers (List, Run, Init)
- Add tests for uncovered lines in run controller (29 lines)
- Add tests for init class route registration
- Add malformed input tests for edge cases
- Remove PHP type hints from REST controllers for WordPress compatibility
- Fix test expectations to match WordPress REST API behavior
- Use PHPUnit data providers for better test organization
- Fix HTTP method validation tests
- Add missing @return documentation tag

Test coverage improvements:
- WPRESTAbilitiesRunControllerTest: Full coverage with input validation, permissions, HTTP methods
- WPRESTAbilitiesListControllerTest: Pagination, special characters, invalid parameters
- WPRESTAbilitiesInitTest: Route registration and controller instantiation

All tests passing (105 tests, 246 assertions)

* fix: Exclude REST controllers from type hint requirements in PHPCS

- WordPress core's WP_REST_Controller doesn't have type hints on methods
- Adding type hints causes fatal errors due to signature mismatch
- Exclude Squiz.Commenting.FunctionComment.TypeHintMissing for REST controllers
- Also exclude Slevomat type hint rules for consistency
- This is a common WordPress compatibility issue
* chore: PHPCS/PHPStan remediations

* Update phpcs.xml.dist

Co-authored-by: Dovid Levine <justlevine@gmail.com>

* Update src/abilities-api.php

* Update class-wp-abilities-registry.php

---------

Co-authored-by: Greg Ziółkowski <grzegorz@gziolo.pl>
* Adjust directory structure to align with WP core
See rules for PHP Tests at https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/.
See best practices for plugins at https://developer.wordpress.org/plugins/plugin-basics/best-practices/.

* Add fixes

* Fix reported coding standard checks

* Fix reported coding standard checks
@justlevine justlevine merged commit 39bcafc into trunk Aug 16, 2025
22 checks passed
@justlevine justlevine deleted the ci/release-flow branch August 16, 2025 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants