Skip to content

Extract Plugin::boot() from the constructor. - #1991

Open
shadyvb wants to merge 10 commits into
ticket/XWPENG-47-matchfrom
ticket/XWPENG-48-plugin-boot
Open

shadyvb wants to merge 10 commits into
ticket/XWPENG-47-matchfrom
ticket/XWPENG-48-plugin-boot

Conversation

@shadyvb

@shadyvb shadyvb commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Fixes XWPENG-48.

Stacks on #1986 (ticket/XWPENG-47-match).

Extracts Plugin::boot() from Plugin::__construct() so location setup (needed before the autoloader can resolve plugin classes) stays in the constructor while dependency loading, subsystem instantiation, and hook registration move into a dedicated boot() method. Hook names, priorities, and registration order are unchanged — this is a structural refactor only, intended to make the boot sequence easier to test and to prepare for later god-class splits.

Summary

  • Plugin::__construct() — sets $this->locations, then calls $this->boot().
  • Plugin::boot() — new public method containing the former constructor body after location setup: autoloader registration, scheduler selection, DB driver wiring, add_action calls, admin/install bootstrap, and WP-CLI registration.
  • Docblocks — updated references from __construct() to boot() where timing semantics apply (Action Scheduler availability, wp_stream_use_action_scheduler filter).
  • Tests — test_boot_registers_expected_actions() asserts the four add_action registrations; test_boot_applies_expected_filters() asserts db, log, and scheduler are instantiated with expected types.

Test plan

  • CI Lint and Test (PHP 8.2 / 8.3 / 8.4) pass
  • CI E2E (PHP 8.2 / 8.3 / 8.4) pass
  • composer lint and composer lint-tests pass locally
  • Reviewer: confirm no behavioral change — plugin activates, records log, admin screens load

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: N/A (internal refactor; no user-facing behavior change).
  • New: N/A.

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.

…rced end-to-end (XWPENG-46).

Replace shutdown echo with capability-gated admin notices, bump release to 5.0.0, and quiet PHPUnit multisite noise from headers and Yoast indexables.
Config-only: require-dev pin, on-demand composer scripts, cache under artifacts/,
PHPCS exclude for cache dir. No plugin source changes.
Register TypedPropertyFromAssignsRector with extension-point base skips; hand-correct
Plugin service holders and Connectors_Unit_Test Admin mock fidelity.
… 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.
Rector plus hand invariance alignment so parent and child property types match.
Connector::$name is string (non-nullable) on the base and every child.
Rector plus hand invariance alignment; remove typed-property skip list from rector.php.
Seventeen constructors across connectors, alerts, and exporters; hand-correct
Connectors_Unit_Test Admin mock fidelity.
Rector plus hand review in class-alerts.php and class-connectors.php.
Move side-effecting bootstrap into boot() after locations are set; the
constructor still calls boot() so hook timing is unchanged. Add Plugin_Test
coverage for actions registered in boot() and filter side effects.
@shadyvb shadyvb changed the title ticket/XWPENG 48 plugin boot Extract Plugin::boot() from the constructor. Sep 5, 2026
@shadyvb
shadyvb marked this pull request as ready for review September 6, 2026 20:27
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