Skip to content

Commit b9b8f14

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

10 files changed

+67
-21
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: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,22 @@ abstract class FilteredStream implements StreamInterface
2424

2525
/**
2626
* @var resource
27+
*
28+
* @deprecated since version 1.5, will be removed in 2.0
2729
*/
2830
protected $readFilter;
2931

3032
/**
3133
* @var callable
34+
*
35+
* @deprecated since version 1.5, will be removed in 2.0
3236
*/
3337
protected $writeFilterCallback;
3438

3539
/**
3640
* @var resource
41+
*
42+
* @deprecated since version 1.5, will be removed in 2.0
3743
*/
3844
protected $writeFilter;
3945

@@ -47,12 +53,17 @@ abstract class FilteredStream implements StreamInterface
4753
/**
4854
* @param StreamInterface $stream
4955
* @param mixed|null $readFilterOptions
50-
* @param mixed|null $writeFilterOptions
56+
* @param mixed|null $writeFilterOptions deprecated since 1.5, will be removed in 2.0
5157
*/
5258
public function __construct(StreamInterface $stream, $readFilterOptions = null, $writeFilterOptions = null)
5359
{
54-
$this->readFilterCallback = Filter\fun($this->getReadFilter(), $readFilterOptions);
55-
$this->writeFilterCallback = Filter\fun($this->getWriteFilter(), $writeFilterOptions);
60+
$this->readFilterCallback = Filter\fun($this->readFilter(), $readFilterOptions);
61+
$this->writeFilterCallback = Filter\fun($this->writeFilter(), $writeFilterOptions);
62+
63+
if (null !== $writeFilterOptions) {
64+
@trigger_error('The $writeFilterOptions argument is deprecated since version 1.5 and will be removed in 2.0.', E_USER_DEPRECATED);
65+
}
66+
5667
$this->stream = $stream;
5768
}
5869

@@ -139,13 +150,41 @@ public function __toString()
139150
* Returns the read filter name.
140151
*
141152
* @return string
153+
*
154+
* @deprecated since version 1.5, will be removed in 2.0
155+
*/
156+
public function getReadFilter()
157+
{
158+
@trigger_error('The '.__CLASS__.'::'.__METHOD__.' method is deprecated since version 1.5 and will be removed in 2.0.', E_USER_DEPRECATED);
159+
160+
return $this->readFilter();
161+
}
162+
163+
/**
164+
* Returns the write filter name.
165+
*
166+
* @return string
142167
*/
143-
abstract public function getReadFilter();
168+
abstract protected function readFilter();
169+
170+
/**
171+
* Returns the write filter name.
172+
*
173+
* @return string
174+
*
175+
* @deprecated since version 1.5, will be removed in 2.0
176+
*/
177+
public function getWriteFilter()
178+
{
179+
@trigger_error('The '.__CLASS__.'::'.__METHOD__.' method is deprecated since version 1.5 and will be removed in 2.0.', E_USER_DEPRECATED);
180+
181+
return $this->writeFilter();
182+
}
144183

145184
/**
146185
* Returns the write filter name.
147186
*
148187
* @return string
149188
*/
150-
abstract public function getWriteFilter();
189+
abstract protected function writeFilter();
151190
}

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)