Skip to content
This repository has been archived by the owner on May 28, 2019. It is now read-only.

Commit

Permalink
Don't use nulls for empty output.
Browse files Browse the repository at this point in the history
  • Loading branch information
ezzatron committed Apr 8, 2014
1 parent 1c63f4b commit efaab70
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/AbstractNativeStreamFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function filter($input, $output, &$consumed, $isEnd)
$this->buffer = substr($this->buffer, $thisConsumed);
}

if (null !== $outputBuffer) {
if ('' !== $outputBuffer) {
$bucket->data = $outputBuffer;
stream_bucket_append($output, $bucket);
$hasOutput = true;
Expand Down
6 changes: 1 addition & 5 deletions src/TransformStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,7 @@ private function transformBuffer()
$this->buffer = substr($this->buffer, $consumed);
}

if ($this->isEnding || null !== $output) {
if (null === $output) {
$output = '';
}

if ($this->isEnding || '' !== $output) {
$this->emit('data', array($output, $this));
}

Expand Down
6 changes: 3 additions & 3 deletions test/src/Base64DecodeTransform.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ public function transform($data, &$context, $isEnd = false)
{
$consume = $this->blocksSize(strlen($data), 4, $isEnd);
if (!$consume) {
return array(null, 0, null);
return array('', 0, null);
}

$consumedData = substr($data, 0, $consume);
if (1 === strlen(rtrim($consumedData, '=')) % 4) {
return array(null, 0, new Exception('Base64 decode failed.'));
return array('', 0, new Exception('Base64 decode failed.'));
}

$outputBuffer = base64_decode($consumedData, true);
if (false === $outputBuffer) {
return array(null, 0, new Exception('Base64 decode failed.'));
return array('', 0, new Exception('Base64 decode failed.'));
}

return array($outputBuffer, $consume, null);
Expand Down
2 changes: 1 addition & 1 deletion test/src/Md5Transform.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function transform($data, &$context, $isEnd = false)
if ($isEnd) {
$output = hash_final($context);
} else {
$output = null;
$output = '';
}

return array($output, strlen($data), null);
Expand Down

0 comments on commit efaab70

Please sign in to comment.