Skip to content

Commit b9093d9

Browse files
authored
Fix Buffer::discard must be fluent to be compatible with buffer package (#4)
1 parent 49f113a commit b9093d9

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

buffer.cc

+2
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ PHP_METHOD(ByteBuffer, discard)
189189
GUARD_SIZE(objval, size);
190190

191191
objval->data->discard(size);
192+
193+
RETURN_ZVAL(getThis(), 1, 0);
192194
}
193195

194196
PHP_METHOD(ByteBuffer, slice)

tests/012.phpt

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Buffer fluent test
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('buffer')) {
6+
echo 'skip';
7+
}
8+
?>
9+
--FILE--
10+
<?php
11+
$buffer = new PHPinnacle\Buffer\ByteBuffer('abcd');
12+
13+
echo $buffer->append('e')->bytes() . \PHP_EOL;
14+
echo $buffer->discard(1)->bytes() . \PHP_EOL;
15+
?>
16+
--EXPECT--
17+
abcde
18+
bcde

0 commit comments

Comments
 (0)