2.x Make Timber\Request not implement Timber\CoreInterface#2631
Merged
Conversation
Member
I would personally remove that class:
IMHO, 2.0 would be a good occasion to get rid of it :) Further more, as long as the class isn't used inside Timber, I don't see any valid argument to keep it, especially now we're composer only. If a user wants a request object, let's add a quick how to in the docs: // composer require nyholm/psr7-server
add_filter('timber/context', function($context) {
$psr17Factory = new \Nyholm\Psr7\Factory\Psr17Factory();
$creator = new \Nyholm\Psr7Server\ServerRequestCreator(
$psr17Factory, // ServerRequestFactory
$psr17Factory, // UriFactory
$psr17Factory, // UploadedFileFactory
$psr17Factory // StreamFactory
);
$context['request'] = $creator->fromGlobals();
return $context;
});☝️Now you have a really complete ServerRequest object to play with. And the Timber Team doesn't have to worry about this class anymore. Now, if we have to keep it, I'll all for leaving |
nlemoine
approved these changes
Nov 23, 2022
Member
Author
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.
Issue
While working on fixing some PHPStan issues, I found that the
Timber\Requestclass extendsTimber\Coreand implementsTimber\CoreInterface.In the current state of Timber, I don’t see any reason why it should do so. Even when it was introduced in #853, it wasn’t clearly stated why it should extend
Timber\Core.The method required by
Timber\CoreInterfaceare added as empty functions and they look like they were added only to serve the interface. But this request helper class doesn’t have anything to do with a Timber core object that usually matches core functionality in WordPress.Solution
Make
Timber\Requestnot implementTimber\CoreInterface.Impact
This might break backwards compatibility with any class that extends
Timber\Request. We will have to add a note to the Upgrade Guide.Usage Changes
None.
Considerations
We could move this to a future release and not release this breaking change in 2.x. In that case, we would have to add a return to
__isset()to fix the PHPStan issue.I’d really like to get a second opinion on this one.
Testing
No.