File tree Expand file tree Collapse file tree 9 files changed +54
-22
lines changed Expand file tree Collapse file tree 9 files changed +54
-22
lines changed Original file line number Diff line number Diff line change 23
23
php-version : ${{ matrix.php-versions }}
24
24
coverage : none
25
25
tools : phpunit
26
+ ini-values : error_reporting=E_ALL
26
27
- name : Setup Composer
27
28
uses : ./.github/actions/setup-composer
28
29
- name : Run PHPUnit
Original file line number Diff line number Diff line change
1
+ .phpunit.cache /
1
2
build /
2
3
vendor /
3
4
.php-cs-fixer.cache
4
- .phpunit.result.cache
5
5
composer.lock
Original file line number Diff line number Diff line change 1
1
# Changelog #
2
2
3
+ ## v1.1.4 (2022-01-02) ##
4
+
5
+ * Improve Github action workflow
6
+ * Fix additional PHP 8.1 deprecations
7
+ * Fix issue with ` JsonStream::getContents() ` no returning buffer contents
8
+
3
9
## v1.1.3 (2021-12-27) ##
4
10
5
11
* Add support for PHP 8.1
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " violet/streaming-json-encoder" ,
3
- "type" : " library" ,
4
3
"description" : " Library for iteratively encoding large JSON documents piece by piece" ,
5
- "homepage" : " http://violet.riimu.net" ,
4
+ "license" : " MIT" ,
5
+ "type" : " library" ,
6
6
"keywords" : [
7
7
" streaming" ,
8
8
" json" ,
9
9
" encoder" ,
10
10
" psr-7"
11
11
],
12
- "license" : " MIT" ,
13
12
"authors" : [
14
13
{
15
14
"name" : " Riikka Kalliomäki" ,
16
15
17
16
"homepage" : " http://riimu.net"
18
17
}
19
18
],
19
+ "homepage" : " http://violet.riimu.net" ,
20
20
"require" : {
21
21
"php" : " >=5.6.0" ,
22
22
"psr/http-message" : " ^1.0"
Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" encoding =" UTF-8" ?>
2
- <phpunit bootstrap =" tests/bootstrap.php" >
3
- <testsuites >
4
- <testsuite name =" Default" >
5
- <directory suffix =" Test.php" >tests/tests/</directory >
6
- </testsuite >
7
- </testsuites >
8
- <filter >
9
- <whitelist processUncoveredFilesFromWhitelist =" true" >
10
- <directory suffix =" .php" >src/</directory >
11
- <exclude >
12
- <file >src/autoload.php</file >
13
- </exclude >
14
- </whitelist >
15
- </filter >
2
+ <phpunit xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
3
+ xsi : noNamespaceSchemaLocation =" https://schema.phpunit.de/9.5/phpunit.xsd"
4
+ bootstrap =" vendor/autoload.php"
5
+ cacheResultFile =" .phpunit.cache/test-results"
6
+ executionOrder =" depends,defects"
7
+ beStrictAboutCoversAnnotation =" true"
8
+ beStrictAboutOutputDuringTests =" true"
9
+ beStrictAboutTodoAnnotatedTests =" true"
10
+ convertDeprecationsToExceptions =" true"
11
+ failOnRisky =" true"
12
+ failOnWarning =" true"
13
+ verbose =" true" >
14
+ <testsuites >
15
+ <testsuite name =" default" >
16
+ <directory >tests</directory >
17
+ </testsuite >
18
+ </testsuites >
19
+
20
+ <coverage cacheDirectory =" .phpunit.cache/code-coverage"
21
+ processUncoveredFiles =" true" >
22
+ <include >
23
+ <directory suffix =" .php" >src</directory >
24
+ </include >
25
+ </coverage >
16
26
</phpunit >
Original file line number Diff line number Diff line change @@ -261,6 +261,10 @@ public function isReadable()
261
261
*/
262
262
public function read ($ length )
263
263
{
264
+ if ($ this ->eof ()) {
265
+ return '' ;
266
+ }
267
+
264
268
$ length = max (0 , (int ) $ length );
265
269
$ encoder = $ this ->getEncoder ();
266
270
@@ -288,8 +292,12 @@ public function read($length)
288
292
*/
289
293
public function getContents ()
290
294
{
295
+ if ($ this ->eof ()) {
296
+ return '' ;
297
+ }
298
+
291
299
$ encoder = $ this ->getEncoder ();
292
- $ output = '' ;
300
+ $ output = $ this -> buffer ;
293
301
294
302
while ($ encoder ->valid ()) {
295
303
$ output .= $ encoder ->current ();
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ public function __construct($data)
23
23
$ this ->data = $ data ;
24
24
}
25
25
26
+ #[\ReturnTypeWillChange]
26
27
public function jsonSerialize ()
27
28
{
28
29
return $ this ->data ;
Original file line number Diff line number Diff line change @@ -139,4 +139,13 @@ public function testPrettyPrintStream()
139
139
$ stream = new JsonStream ($ encoder );
140
140
$ this ->assertSame ("[ \n \"value \"\n] " , $ stream ->getContents ());
141
141
}
142
+
143
+ public function testGetRemainingContents ()
144
+ {
145
+ $ encoder = (new BufferJsonEncoder (['value ' ]));
146
+ $ stream = new JsonStream ($ encoder );
147
+
148
+ $ this ->assertSame ('["val ' , $ stream ->read (5 ));
149
+ $ this ->assertSame ('ue"] ' , $ stream ->getContents ());
150
+ }
142
151
}
You can’t perform that action at this time.
0 commit comments