-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove encoding writing stuff #59
Remove encoding writing stuff #59
Conversation
As far as I can see it's being called here: https://github.com/php-http/message/blob/master/src/Encoding/FilteredStream.php#L55 |
Yes, but the |
That's true, but technically the methods you removed are still called. |
Ping @joelwurtz |
My intent was to propose a method to write into a filtered stream which is the reverse filter of the reading action. This can be useful on server side or library manipulating stream (like transfering data from a FilteredStream to another FilteredStream should result in the same data, which is not the case actually as it would only decode multiple times but never reencode) However i nerver implemented the method as ATM there was no need for that, removing this is not a problem as like you said it's never used (and it's not a BC break). But there should be more to that, the filtered stream should only be readable and not writable (so isWritable should return false, and write method should throw an exception) and also it should not be seekable (but not the purpose of this PR, can be reported as a separate Issue or write as a separate PR) |
Well, the fact that we don't use it is enough for removal? Also, IMO it's a BC break, no matter if it's used by US or not, it's a public API change. |
this is a massive BC break in our public API. if we decide we don't need this we should deprecate the methods and remove them in version 2 only. if they are useful as is, we should instead write some tests that make sure they work as intended. |
Ah yes didn't see the public visibility, i think it's a mistake in the original code as a user never need to get the encoding or decoding filter it's only an implementation detail, they should be deprecated then and removed in 2.0. |
9d72e58
to
ee44e05
Compare
so we can keep this PR open but mark it to be version 2 only, and do
another one to deprecate the methods? should we also trigger a
deprecation warning like symfony does?
|
@dbu I've already modified the PR to deprecate the methods. |
### Deprecated | ||
|
||
- FilteredStream::getReadFilter will be removed in 2.0 | ||
- FilteredStream::getWriteFilter will be removed in 2.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'd like to add an explanation to the changelog why we deprecate them. "The read filter is internal and should never be used by consuming code.", "We did not implement writing to the streams at all. And if we do, the filter is an internal information and should not be used by consuming code."
738954a
to
b4b29e7
Compare
$this->readFilterCallback = Filter\fun($this->getReadFilter(), $readFilterOptions); | ||
$this->writeFilterCallback = Filter\fun($this->getWriteFilter(), $writeFilterOptions); | ||
$this->readFilterCallback = Filter\fun($this->readFilter(), $readFilterOptions); | ||
if (null !== $writeFilterOptions) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add some spacing before and after?
$this->writeFilterCallback = Filter\fun($this->getWriteFilter(), $writeFilterOptions); | ||
$this->readFilterCallback = Filter\fun($this->readFilter(), $readFilterOptions); | ||
if (null !== $writeFilterOptions) { | ||
@trigger_error('The $writeFilterOptions argument is deprecated since version 1.5 and will be removed in 2.0. Use Http\Message\RequestMatcher\RequestMatcher instead.', E_USER_DEPRECATED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean Http\Message\RequestMatcher? (interface).
$this->writeFilterCallback = Filter\fun($this->getWriteFilter(), $writeFilterOptions); | ||
$this->readFilterCallback = Filter\fun($this->readFilter(), $readFilterOptions); | ||
if (null !== $writeFilterOptions) { | ||
@trigger_error('The $writeFilterOptions argument is deprecated since version 1.5 and will be removed in 2.0. Use Http\Message\RequestMatcher\RequestMatcher instead.', E_USER_DEPRECATED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, maybe use sprintf and ::class constant for code brevity?
/** | ||
* @var callable | ||
*/ | ||
protected $writeFilterCallback; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is an abstract class: isn't this a BC break too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing a non-private function in a non-final class is always a BC break.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, the $readFilter
and $writeFilter
properties should remain and should be marked as deprecated too.
d5949f6
to
2477b70
Compare
@sagikazarmark ready for review |
LGTM |
2477b70
to
b9b8f14
Compare
*/ | ||
protected $writeFilterCallback; | ||
|
||
/** | ||
* @var resource | ||
* | ||
* @deprecated since version 1.5, will be removed in 2.0 | ||
*/ | ||
protected $writeFilter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be safely removed as it was always null and never used, even if it's BC i assume nobody use this (otherwise i really don't understand why xD)
@dbu @sagikazarmark ok to remove this even if it's somehow BC (never used, always null value in a protected scope so ...) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i tend to agree, but lets maybe leave as is, there is stuff to remove when we go 2.0 anyways so we can play it safe. does not add cost to leave those in
@@ -24,16 +24,22 @@ | |||
|
|||
/** | |||
* @var resource | |||
* | |||
* @deprecated since version 1.5, will be removed in 2.0 | |||
*/ | |||
protected $readFilter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be removed as well as the writeFilter
What's in this PR?
This PR removes all stuff related with write filters in the
Http\Message\Encoding
namespace.Why?
The abstract class
Http\Message\Encoding\FilteredStream
defines an abstract method namedgetWriteFilter
that is not called anywhere and produces dead code not being tested. IMO this code must be removed or at least deprecated.Example Usage
You can run the tests to see that this code is not being used nor tested.
Checklist
To Do