Repository navigation
Add native types for PHP 8.3 - #1549
Merged
olivervogel merged 1 commit intoOct 5, 2026
Merged
Conversation
Type the remaining untyped class constants (a PHP 8.3 feature) in DominantPaletteAnalyzer and the VibrantMuted theme definition, and add parameter and return types to closures and arrow functions in src and tests that were still missing them. Stream resources keep their docblock-only types since PHP has no native resource type.
Member
|
Thanks. |
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.
Now that
developrequires PHP ^8.3, the remaining untyped class constants inDominantPaletteAnalyzerandColors\Themes\VibrantMuted\Definitionare typed (private const float MIN_VIBRANT_SATURATION = 0.35), matching the rest of the codebase which already used typed constants.Closures and arrow functions in
srcandteststhat were missing parameter or return types now have them (e.g.drawRectangle(function (RectangleFactory $rectangle): void { ... })).A few things worth noting:
Collection::filter()andPalette::filter()wrappers returnmixed, notbool: withstrict_types=1aboolreturn would throw aTypeErrorfor user callbacks returning a truthy non-bool value, whicharray_filter()accepts today.Colorspace::colorFromNormalized()methods are left untyped. Typing themColorChannelInterface(whatfromNormalized()returns) makes PHPStan report that the spread arguments don't match the specific channel types theColorconstructors expect. Fixing that properly is a refactor rather than typing.File::$stream,FileInterface::toStream(),CanBuildStream::buildStreamOrFail(), the GDResolutionAnalyzerhandles and encoder callbacks) keep their docblock types, since PHP has no nativeresourcetype andmixedwould add nothing.No behaviour change. PHPStan and PHPCS pass.