Skip to content

Enhance Config API and add regression test for issue #34#48

Merged
bbsnly merged 4 commits into
mainfrom
chore/config-api-and-ci-hardening
Jun 24, 2026
Merged

Enhance Config API and add regression test for issue #34#48
bbsnly merged 4 commits into
mainfrom
chore/config-api-and-ci-hardening

Conversation

@bbsnly

@bbsnly bbsnly commented Jun 24, 2026

Copy link
Copy Markdown
Owner

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:

  • Added precise return type annotations (array<string, mixed>) to methods like get() and toArray() in Chart, Config, and their interfaces, improving static analysis and code clarity. [1] [2] [3] [4] [5]
  • Updated Config class and related interfaces to include get() and toJson() methods, ensuring a consistent API for configuration objects. [1] [2] [3]
  • Improved handling of dynamic property setting in Config by updating the __set and __call methods for better type safety and method chaining.
  • Enhanced the toArray() method in Config to recursively convert objects only if they have a toArray() method, preventing errors with other object types.

PHP Compatibility and Workflow:

  • Added PHP 8.5 to the GitHub Actions test matrix and set continue-on-error for PHP 8.5, ensuring compatibility with the latest PHP version. [1] [2]

Testing Enhancements:

  • Added new tests for Config::get() and Config::toJson(), and a regression test for correct behavior when appending to non-existent magic array properties.

Other Improvements:

  • Added a docblock to Options class for improved IDE support and documentation.
  • Allowed toHtml() in Chart to accept a nullable Chart parameter, improving flexibility.

bbsnly added 4 commits June 24, 2026 22:14
- 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.
@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

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 ☂️

@bbsnly bbsnly merged commit 725ef14 into main Jun 24, 2026
7 checks passed
@bbsnly bbsnly deleted the chore/config-api-and-ci-hardening branch June 24, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant