code quality: declare strict / inline types#72
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Pull Request Overview
This PR modernizes the codebase by adding PHP strict type declarations and type hints across all core files, improving type safety and code quality.
Key Changes:
- Added
declare(strict_types=1)to all PHP files for strict type checking - Added type declarations to all class properties (string, bool, array, and fully-qualified class types)
- Marked
Feature_RegistryandFeature_Loaderclasses as final to prevent inheritance - Replaced verbose docblock descriptions with
{@inheritDoc}tags in Example_Feature for inherited methods
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| includes/bootstrap.php | Added strict types declaration |
| includes/Features/Example_Feature/Example_Feature.php | Added strict types declaration and updated docblocks to use {@inheritdoc} for inherited methods |
| includes/Feature_Registry.php | Added strict types declaration, marked class as final, and added array type to $features property |
| includes/Feature_Loader.php | Added strict types declaration, marked class as final, and added type declarations to $registry and $initialized properties |
| includes/Exception/Invalid_Feature_Metadata_Exception.php | Added strict types declaration |
| includes/Exception/Invalid_Feature_Exception.php | Added strict types declaration |
| includes/Contracts/Feature.php | Added strict types declaration |
| includes/Abstracts/Abstract_Feature.php | Added strict types declaration and type declarations to all properties ($id, $label, $description, $enabled) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
What?
This PR
declare( strict_types=1 );to plugin filesFeature_LoaderandFeature_RegistryfinalExample_Featureto use{@inheritDoc}Why?
Stricter/native types improve DX by erroring early, saving unnecessary code review and reducing the likelihood of shipping bugs into a release.
How?
See copilot summary.
Testing Instructions
Testing Instructions for Keyboard
N/a
Screenshots or screencast
Test using WordPress Playground
The changes in this pull request can be previewed and tested using this WordPress Playground instance:
Click here to test this pull request.