Merged
Conversation
* 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Test and merge