Skip to content

Make handler parameter nullable in WpClient constructor (#1)#2

Open
jgalea wants to merge 3 commits into
developfrom
agent/wp-http-1
Open

Make handler parameter nullable in WpClient constructor (#1)#2
jgalea wants to merge 3 commits into
developfrom
agent/wp-http-1

Conversation

@jgalea

@jgalea jgalea commented May 28, 2026

Copy link
Copy Markdown

This PR makes the $handler parameter of WpClient::__construct nullable with a null default, allowing php-http/discovery's ClassDiscovery to instantiate WpClient without arguments.

When null is passed (or no argument is given), the constructor falls back to HandlerStack::createDefault(), which is the same default used by the existing WpClient::createDefault() factory method.

Closes #1

jgalea added 3 commits May 28, 2026 21:51
Allows php-http/discovery's ClassDiscovery to instantiate WpClient
without arguments. When null is passed, the constructor falls back to
HandlerStack::createDefault().

Closes #1
composer.json didn't declare allow-plugins, so the non-interactive
composer update in CI aborted on the phpcodesniffer-installer and
package-versions-deprecated plugins. Allow-list both.
WordPress 6.2 moved the bundled Requests library to wp-includes/Requests/src
and renamed the classes to the WpOrg\Requests namespace. The bootstrap hardcoded
the old wp-includes/Requests/Utility paths, so PhpUnit fatally errored on any WP
core that Composer resolved at 6.2+. Load the new autoloader when present, fall
back to the legacy files otherwise, and reference the modern class name in the
WpHandler test.
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.

Constructor parameter prevents usage with php-http/discovery

1 participant