Enhance Config API and add regression test for issue #34#48
Merged
Conversation
- Add get() and toJson() to Config and ConfigInterface, mirroring Chart. - toJson() hardens output with JSON_THROW_ON_ERROR and HEX flags. - Guard toArray() so it only calls ->toArray() on objects that define it. - Return void from __set() and move fluent chaining into __call(). - Add generic array<string, mixed> PHPDoc types for stricter PHPStan.
Implicitly nullable parameters ($chart = null without a ?-prefixed type) are deprecated as of PHP 8.4. Declare the parameter as ?Chart to silence the deprecation and keep the package forward-compatible.
Guards $data->datasets[] = ...; against regressions. Removing the by-reference return from Config::__get() makes this test fail with the exact #34 symptom, so the magic-array-append fix can no longer be lost silently. No existing test covered this path.
PHP 8.5 is stable and the suite passes on it with no deprecations. Add it to the matrix and move continue-on-error from 8.4 to 8.5, so 8.4 is now an enforced target while the newest release stays non-blocking.
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
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.
This pull request introduces improved type safety, interface consistency, and additional test coverage for the configuration and chart classes. It also updates the PHP test matrix to include PHP 8.5. The most important changes are organized below:
Type Safety and Interface Improvements:
array<string, mixed>) to methods likeget()andtoArray()inChart,Config, and their interfaces, improving static analysis and code clarity. [1] [2] [3] [4] [5]Configclass and related interfaces to includeget()andtoJson()methods, ensuring a consistent API for configuration objects. [1] [2] [3]Configby updating the__setand__callmethods for better type safety and method chaining.toArray()method inConfigto recursively convert objects only if they have atoArray()method, preventing errors with other object types.PHP Compatibility and Workflow:
continue-on-errorfor PHP 8.5, ensuring compatibility with the latest PHP version. [1] [2]Testing Enhancements:
Config::get()andConfig::toJson(), and a regression test for correct behavior when appending to non-existent magic array properties.Other Improvements:
Optionsclass for improved IDE support and documentation.toHtml()inChartto accept a nullableChartparameter, improving flexibility.