Skip to content

Remove encoding writing stuff #59

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

Merged
merged 1 commit into from
Oct 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## Unreleased

### Deprecated

- FilteredStream::getReadFilter The read filter is internal and should never be used by consuming code.
- 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.

## 1.4.0 - 2016-10-20

### Added
Expand Down
4 changes: 2 additions & 2 deletions src/Encoding/ChunkStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ class ChunkStream extends FilteredStream
/**
* {@inheritdoc}
*/
public function getReadFilter()
protected function readFilter()
{
return 'chunk';
}

/**
* {@inheritdoc}
*/
public function getWriteFilter()
protected function writeFilter()
{
return 'dechunk';
}
Expand Down
4 changes: 2 additions & 2 deletions src/Encoding/CompressStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ public function __construct(StreamInterface $stream, $level = -1)
/**
* {@inheritdoc}
*/
public function getReadFilter()
protected function readFilter()
{
return 'zlib.deflate';
}

/**
* {@inheritdoc}
*/
public function getWriteFilter()
protected function writeFilter()
{
return 'zlib.inflate';
}
Expand Down
4 changes: 2 additions & 2 deletions src/Encoding/DechunkStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ class DechunkStream extends FilteredStream
/**
* {@inheritdoc}
*/
public function getReadFilter()
protected function readFilter()
{
return 'dechunk';
}

/**
* {@inheritdoc}
*/
public function getWriteFilter()
protected function writeFilter()
{
return 'chunk';
}
Expand Down
4 changes: 2 additions & 2 deletions src/Encoding/DecompressStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ public function __construct(StreamInterface $stream, $level = -1)
/**
* {@inheritdoc}
*/
public function getReadFilter()
protected function readFilter()
{
return 'zlib.inflate';
}

/**
* {@inheritdoc}
*/
public function getWriteFilter()
protected function writeFilter()
{
return 'zlib.deflate';
}
Expand Down
4 changes: 2 additions & 2 deletions src/Encoding/DeflateStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ public function __construct(StreamInterface $stream, $level = -1)
/**
* {@inheritdoc}
*/
public function getReadFilter()
protected function readFilter()
{
return 'zlib.deflate';
}

/**
* {@inheritdoc}
*/
public function getWriteFilter()
protected function writeFilter()
{
return 'zlib.inflate';
}
Expand Down
49 changes: 44 additions & 5 deletions src/Encoding/FilteredStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,22 @@ abstract class FilteredStream implements StreamInterface

/**
* @var resource
*
* @deprecated since version 1.5, will be removed in 2.0
*/
protected $readFilter;
Copy link
Member

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


/**
* @var callable
Copy link
Member

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?

Copy link
Member

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.

Copy link
Contributor Author

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.

*
* @deprecated since version 1.5, will be removed in 2.0
*/
protected $writeFilterCallback;

/**
* @var resource
*
* @deprecated since version 1.5, will be removed in 2.0
*/
protected $writeFilter;
Copy link
Member

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 ...) ?

Copy link
Contributor

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


Expand All @@ -47,12 +53,17 @@ abstract class FilteredStream implements StreamInterface
/**
* @param StreamInterface $stream
* @param mixed|null $readFilterOptions
* @param mixed|null $writeFilterOptions
* @param mixed|null $writeFilterOptions deprecated since 1.5, will be removed in 2.0
*/
public function __construct(StreamInterface $stream, $readFilterOptions = null, $writeFilterOptions = null)
{
$this->readFilterCallback = Filter\fun($this->getReadFilter(), $readFilterOptions);
$this->writeFilterCallback = Filter\fun($this->getWriteFilter(), $writeFilterOptions);
$this->readFilterCallback = Filter\fun($this->readFilter(), $readFilterOptions);
$this->writeFilterCallback = Filter\fun($this->writeFilter(), $writeFilterOptions);

if (null !== $writeFilterOptions) {
Copy link
Member

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?

@trigger_error('The $writeFilterOptions argument is deprecated since version 1.5 and will be removed in 2.0.', E_USER_DEPRECATED);
}

$this->stream = $stream;
}

Expand Down Expand Up @@ -139,13 +150,41 @@ public function __toString()
* Returns the read filter name.
*
* @return string
*
* @deprecated since version 1.5, will be removed in 2.0
*/
public function getReadFilter()
{
@trigger_error('The '.__CLASS__.'::'.__METHOD__.' method is deprecated since version 1.5 and will be removed in 2.0.', E_USER_DEPRECATED);

return $this->readFilter();
}

/**
* Returns the write filter name.
*
* @return string
*/
abstract public function getReadFilter();
abstract protected function readFilter();

/**
* Returns the write filter name.
*
* @return string
*
* @deprecated since version 1.5, will be removed in 2.0
*/
public function getWriteFilter()
{
@trigger_error('The '.__CLASS__.'::'.__METHOD__.' method is deprecated since version 1.5 and will be removed in 2.0.', E_USER_DEPRECATED);

return $this->writeFilter();
}

/**
* Returns the write filter name.
*
* @return string
*/
abstract public function getWriteFilter();
abstract protected function writeFilter();
}
4 changes: 2 additions & 2 deletions src/Encoding/GzipDecodeStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ public function __construct(StreamInterface $stream, $level = -1)
/**
* {@inheritdoc}
*/
public function getReadFilter()
protected function readFilter()
{
return 'zlib.inflate';
}

/**
* {@inheritdoc}
*/
public function getWriteFilter()
protected function writeFilter()
{
return 'zlib.deflate';
}
Expand Down
4 changes: 2 additions & 2 deletions src/Encoding/GzipEncodeStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ public function __construct(StreamInterface $stream, $level = -1)
/**
* {@inheritdoc}
*/
public function getReadFilter()
protected function readFilter()
{
return 'zlib.deflate';
}

/**
* {@inheritdoc}
*/
public function getWriteFilter()
protected function writeFilter()
{
return 'zlib.inflate';
}
Expand Down
4 changes: 2 additions & 2 deletions src/Encoding/InflateStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ public function __construct(StreamInterface $stream, $level = -1)
/**
* {@inheritdoc}
*/
public function getReadFilter()
protected function readFilter()
{
return 'zlib.inflate';
}

/**
* {@inheritdoc}
*/
public function getWriteFilter()
protected function writeFilter()
{
return 'zlib.deflate';
}
Expand Down