Use PSR-17 createRequest() instead of deprecated getMessageFactory()#17
Open
mwansinck wants to merge 1 commit into
Open
Use PSR-17 createRequest() instead of deprecated getMessageFactory()#17mwansinck wants to merge 1 commit into
mwansinck wants to merge 1 commit into
Conversation
…ssageFactory() The only call to the deprecated getMessageFactory() was in executeQuery(). getMessageFactory() returns an Http\Message\MessageFactory, an interface that lives solely in the abandoned/archived php-http/message-factory package, which forces that dependency at runtime (fatal "Interface 'Http\Message\MessageFactory' not found" otherwise). See geo6#16. AbstractHttpProvider::createRequest() (from geocoder-php/common-http) already builds the request via PSR-17 factories with an identical argument signature, exactly like every other geocoder-php provider. Switching to it drops the last dependency on php-http/message-factory with no behavioural change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
bpost::executeQuery()is the only place that still calls the deprecatedAbstractHttpProvider::getMessageFactory(). That method returns anHttp\Message\MessageFactory, an interface that exists solely in the archived/abandonedphp-http/message-factorypackage. As a result the provider hard-requires that abandoned package at runtime, and fails with:whenever it isn't present (e.g. when consumers prune abandoned dependencies). See #16.
Fix
Switch the request construction to
AbstractHttpProvider::createRequest()(fromgeocoder-php/common-http), which already builds the request through PSR-17 factories and has an identical argument signature ($method, $uri, array $headers = [], ?string $body = null). This is exactly the approach every othergeocoder-phpprovider uses.This removes the last reference to
Http\Message\MessageFactory, so the provider no longer pulls inphp-http/message-factory. No behavioural change — the produced request is identical.Testing
Verified against a real project: with this change applied and
php-http/message-factoryremoved, the bpost geocoding integration tests (mocked bpost responses) still pass. Without the change they fatal on the missing interface.Fixes #16