Skip to content

Commit b4b29e7

Browse files
committed
Deprecate FilteredStream::getReadFilter and FilteredStream::getWriteFilter
1 parent 20ffbdc commit b4b29e7

10 files changed

+58
-36
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Change Log
22

3+
## Unreleased
4+
5+
### Deprecated
6+
7+
- FilteredStream::getReadFilter The read filter is internal and should never be used by consuming code.
8+
- FilteredStream::getWriteFilter 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.
9+
310
## 1.4.0 - 2016-10-20
411

512
### Added

src/Encoding/ChunkStream.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ class ChunkStream extends FilteredStream
1212
/**
1313
* {@inheritdoc}
1414
*/
15-
public function getReadFilter()
15+
protected function readFilter()
1616
{
1717
return 'chunk';
1818
}
1919

2020
/**
2121
* {@inheritdoc}
2222
*/
23-
public function getWriteFilter()
23+
protected function writeFilter()
2424
{
2525
return 'dechunk';
2626
}

src/Encoding/CompressStream.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ public function __construct(StreamInterface $stream, $level = -1)
2727
/**
2828
* {@inheritdoc}
2929
*/
30-
public function getReadFilter()
30+
protected function readFilter()
3131
{
3232
return 'zlib.deflate';
3333
}
3434

3535
/**
3636
* {@inheritdoc}
3737
*/
38-
public function getWriteFilter()
38+
protected function writeFilter()
3939
{
4040
return 'zlib.inflate';
4141
}

src/Encoding/DechunkStream.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ class DechunkStream extends FilteredStream
1414
/**
1515
* {@inheritdoc}
1616
*/
17-
public function getReadFilter()
17+
protected function readFilter()
1818
{
1919
return 'dechunk';
2020
}
2121

2222
/**
2323
* {@inheritdoc}
2424
*/
25-
public function getWriteFilter()
25+
protected function writeFilter()
2626
{
2727
return 'chunk';
2828
}

src/Encoding/DecompressStream.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ public function __construct(StreamInterface $stream, $level = -1)
2727
/**
2828
* {@inheritdoc}
2929
*/
30-
public function getReadFilter()
30+
protected function readFilter()
3131
{
3232
return 'zlib.inflate';
3333
}
3434

3535
/**
3636
* {@inheritdoc}
3737
*/
38-
public function getWriteFilter()
38+
protected function writeFilter()
3939
{
4040
return 'zlib.deflate';
4141
}

src/Encoding/DeflateStream.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ public function __construct(StreamInterface $stream, $level = -1)
2323
/**
2424
* {@inheritdoc}
2525
*/
26-
public function getReadFilter()
26+
protected function readFilter()
2727
{
2828
return 'zlib.deflate';
2929
}
3030

3131
/**
3232
* {@inheritdoc}
3333
*/
34-
public function getWriteFilter()
34+
protected function writeFilter()
3535
{
3636
return 'zlib.inflate';
3737
}

src/Encoding/FilteredStream.php

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,6 @@ abstract class FilteredStream implements StreamInterface
2222
*/
2323
protected $readFilterCallback;
2424

25-
/**
26-
* @var resource
27-
*/
28-
protected $readFilter;
29-
30-
/**
31-
* @var callable
32-
*/
33-
protected $writeFilterCallback;
34-
35-
/**
36-
* @var resource
37-
*/
38-
protected $writeFilter;
39-
4025
/**
4126
* Internal buffer.
4227
*
@@ -47,12 +32,14 @@ abstract class FilteredStream implements StreamInterface
4732
/**
4833
* @param StreamInterface $stream
4934
* @param mixed|null $readFilterOptions
50-
* @param mixed|null $writeFilterOptions
35+
* @param mixed|null $writeFilterOptions deprecated since 1.5, will be removed in 2.0
5136
*/
5237
public function __construct(StreamInterface $stream, $readFilterOptions = null, $writeFilterOptions = null)
5338
{
54-
$this->readFilterCallback = Filter\fun($this->getReadFilter(), $readFilterOptions);
55-
$this->writeFilterCallback = Filter\fun($this->getWriteFilter(), $writeFilterOptions);
39+
$this->readFilterCallback = Filter\fun($this->readFilter(), $readFilterOptions);
40+
if (null !== $writeFilterOptions) {
41+
@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);
42+
}
5643
$this->stream = $stream;
5744
}
5845

@@ -139,13 +126,41 @@ public function __toString()
139126
* Returns the read filter name.
140127
*
141128
* @return string
129+
*
130+
* @deprecated since version 1.5, will be removed in 2.0
142131
*/
143-
abstract public function getReadFilter();
132+
public function getReadFilter()
133+
{
134+
@trigger_error('The '.__CLASS__.'::'.__METHOD__.' method is deprecated since version 1.5 and will be removed in 2.0. Use Http\Message\RequestMatcher\RequestMatcher instead.', E_USER_DEPRECATED);
135+
136+
return $this->readFilter();
137+
}
138+
139+
/**
140+
* Returns the write filter name.
141+
*
142+
* @return string
143+
*/
144+
abstract protected function readFilter();
145+
146+
/**
147+
* Returns the write filter name.
148+
*
149+
* @return string
150+
*
151+
* @deprecated since version 1.5, will be removed in 2.0
152+
*/
153+
public function getWriteFilter()
154+
{
155+
@trigger_error('The '.__CLASS__.'::'.__METHOD__.' method is deprecated since version 1.5 and will be removed in 2.0. Use Http\Message\RequestMatcher\RequestMatcher instead.', E_USER_DEPRECATED);
156+
157+
return $this->writeFilter();
158+
}
144159

145160
/**
146161
* Returns the write filter name.
147162
*
148163
* @return string
149164
*/
150-
abstract public function getWriteFilter();
165+
abstract protected function writeFilter();
151166
}

src/Encoding/GzipDecodeStream.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ public function __construct(StreamInterface $stream, $level = -1)
2727
/**
2828
* {@inheritdoc}
2929
*/
30-
public function getReadFilter()
30+
protected function readFilter()
3131
{
3232
return 'zlib.inflate';
3333
}
3434

3535
/**
3636
* {@inheritdoc}
3737
*/
38-
public function getWriteFilter()
38+
protected function writeFilter()
3939
{
4040
return 'zlib.deflate';
4141
}

src/Encoding/GzipEncodeStream.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ public function __construct(StreamInterface $stream, $level = -1)
2727
/**
2828
* {@inheritdoc}
2929
*/
30-
public function getReadFilter()
30+
protected function readFilter()
3131
{
3232
return 'zlib.deflate';
3333
}
3434

3535
/**
3636
* {@inheritdoc}
3737
*/
38-
public function getWriteFilter()
38+
protected function writeFilter()
3939
{
4040
return 'zlib.inflate';
4141
}

src/Encoding/InflateStream.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ public function __construct(StreamInterface $stream, $level = -1)
2727
/**
2828
* {@inheritdoc}
2929
*/
30-
public function getReadFilter()
30+
protected function readFilter()
3131
{
3232
return 'zlib.inflate';
3333
}
3434

3535
/**
3636
* {@inheritdoc}
3737
*/
38-
public function getWriteFilter()
38+
protected function writeFilter()
3939
{
4040
return 'zlib.deflate';
4141
}

0 commit comments

Comments
 (0)