Strict typing: Add native PHP 8.2 type declarations from the existing PHPDoc blocks#172
Open
web-dev-passion wants to merge 1 commit into
Open
Strict typing: Add native PHP 8.2 type declarations from the existing PHPDoc blocks#172web-dev-passion wants to merge 1 commit into
web-dev-passion wants to merge 1 commit into
Conversation
Pull @param/@return/@var down to native PHP 8.2 types across src/. Signatures and properties only, no behaviour change. Kept the docblocks where they hold generics native types can't (array<string, int|string>). Left a few loose on purpose where a strict type would break callers: persistIdentity, hasRoles, link/_default. phpstan 8 + cs green, tests unchanged.
Owner
|
I like it, but some of the public API changes here need to wait until the next major. |
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.
Strict typing: Add native PHP 8.2 type declarations from the existing PHPDoc blocks
Preamble
I've been running TinyAuth on a project and noticed most signatures still keep their types in the PHPDoc blocks only. Based on latest effort across CakePHP packages and core, I guess going to improve and leverage PHP's native type system is a welcome change. 😄
What was changed ?
Applies native parameter, return and property type declarations throughout the plugin, derived from the existing
@param/@return/@varPHPDoc and confirmed against actual usage.Left untyped on purpose
A few signatures stay loose, because tightening them would change behaviour. If you take a look into the changes you would see why.
PHP Version matching composer + README
Targets the package's PHP 8.2 minimum. PHPDoc is kept where it carries generics or array (basic) shapes (e.g.
array<string, int|string>) that native types (based on PHP 8.2) cannot express.How it was done
First pass with Rector (type-declaration set pinned to 8.2), the rest by hand.
phpstan level 8 and cs pass, test suite unchanged. Happy to adjust.
And thanks for your great work @dereuromark !