Skip to content

Apply typed properties in classes/ via Rector. - #1982

Open
shadyvb wants to merge 2 commits into
ticket/XWPENG-47-rector-configfrom
ticket/XWPENG-47-typed-props-classes
Open

Apply typed properties in classes/ via Rector.#1982
shadyvb wants to merge 2 commits into
ticket/XWPENG-47-rector-configfrom
ticket/XWPENG-47-typed-props-classes

Conversation

@shadyvb

@shadyvb shadyvb commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #000.

Describe your approach and how it fixes the issue.

Checklist

  • Project documentation has been updated to reflect the changes in this pull request, if applicable.
  • I have tested the changes in the local development environment (see contributing.md).
  • I have added phpunit tests.

Release Changelog

  • Fix: Describe a bug fix included in this release.
  • New: Describe a new feature in this release.

Release Checklist

  • This pull request is to the master branch.
  • Release version follows semantic versioning. Does it include breaking changes?
  • Update changelog in readme.txt.
  • Bump version in stream.php.
  • Bump Stable tag in readme.txt.
  • Bump version in classes/class-plugin.php.
  • Draft a release on GitHub.

Change [ ] to [x] to mark the items as done.

@shadyvb
shadyvb marked this pull request as ready for review September 2, 2026 09:56
Register TypedPropertyFromAssignsRector with extension-point base skips; hand-correct
Plugin service holders and Connectors_Unit_Test Admin mock fidelity.
@shadyvb
shadyvb force-pushed the ticket/XWPENG-47-typed-props-classes branch from e3fc25d to 47ed6f8 Compare September 2, 2026 10:12
… contract (XWPENG-47).

Guard the three wp_stream_settings_* filter boundaries in Settings so a
misbehaving callback can never feed null or a non-array into properties
that the typed-property Rector runs assign to directly:

- get_option_key(): fall back to the computed key when the
  wp_stream_settings_option_key filter returns a non-string.
- get_options(): fall back to the unfiltered options array when the
  wp_stream_settings_options filter returns a non-array.
- get_fields(): keep the unfiltered fields when the
  wp_stream_settings_option_fields filter returns a non-array.

These props are untyped today only because Rector skipped them due to
the mixed filter assignments; any consumer with typed properties (or a
future TypedPropertyFromAssigns run) would otherwise throw a TypeError
on every request, since Settings is constructed on init.

Also declare the DB_Driver::setup_storage() return type (Install) on
the interface and the WPDB implementation. Plugin::$install is
nullable-typed in this stack, so a custom wp_stream_db_driver driver
returning anything else previously failed with a cryptic runtime
TypeError; it now fails at class-load time inside the offending driver.

Note: the setup_storage signature is technically breaking for
third-party drivers that omit the return type.
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