File tree Expand file tree Collapse file tree 4 files changed +14
-9
lines changed
Expand file tree Collapse file tree 4 files changed +14
-9
lines changed Original file line number Diff line number Diff line change 11# LargeArrayBuffer
22
3- [ ![ License] ( http ://poser.pugx.org/nerou/large-array-buffer/license)] ( https://packagist.org/packages/nerou/large-array-buffer )
4- [ ![ PHP Version Require] ( http ://poser.pugx.org/nerou/large-array-buffer/require/php)] ( https://packagist.org/packages/nerou/large-array-buffer )
5- [ ![ Version] ( http ://poser.pugx.org/nerou/large-array-buffer/version)] ( https://packagist.org/packages/nerou/large-array-buffer )
3+ [ ![ License] ( https ://poser.pugx.org/nerou/large-array-buffer/license)] ( https://packagist.org/packages/nerou/large-array-buffer )
4+ [ ![ PHP Version Require] ( https ://poser.pugx.org/nerou/large-array-buffer/require/php)] ( https://packagist.org/packages/nerou/large-array-buffer )
5+ [ ![ Version] ( https ://poser.pugx.org/nerou/large-array-buffer/version)] ( https://packagist.org/packages/nerou/large-array-buffer )
66[ ![ Psalm Type Coverage] ( https://shepherd.dev/github/nerou42/LargeArrayBuffer/coverage.svg )] ( https://packagist.org/packages/nerou/large-array-buffer )
77
88## This is for you, if...
Original file line number Diff line number Diff line change @@ -24,7 +24,8 @@ private function generateMeasurement(int $index): Measurement {
2424 return new Measurement (
2525 (new \DateTimeImmutable ())->sub (new \DateInterval ('PT ' .$ index .'H ' )),
2626 $ index % 500 ,
27- random_int (-1_000_000 , 1_000_000 ) / 1000 );;
27+ random_int (-1_000_000 , 1_000_000 ) / 1000
28+ );
2829 }
2930
3031 public function arrayMeasurementsFill (): array {
Original file line number Diff line number Diff line change 1313 ],
1414 "suggest" : {
1515 "ext-json" : " Requirement of toJSONFile() method" ,
16+ "ext-zlib" : " To enable support for GZIP compression" ,
1617 "ext-lz4" : " To enable support of LZ4 compression" ,
1718 "ext-igbinary" : " To enable support for igbinary serializer" ,
1819 "ext-msgpack" : " To enable support for msgpack serializer"
Original file line number Diff line number Diff line change @@ -114,17 +114,20 @@ public function rewind(): void {
114114 * @throws \RuntimeException if unable to read from php://temp
115115 */
116116 public function next (): void {
117- if (feof ($ this ->stream ) || $ this ->count === 0 ) { // stream is not initialized before first write
117+ if (feof ($ this ->stream ) || $ this ->count === $ this -> index ) { // if nothing to read, no data left
118118 $ this ->current = null ;
119119 return ;
120120 }
121121 $ line = fgets ($ this ->stream );
122122 if ($ line === false ) {
123- throw new \RuntimeException ('could not read line from php://temp ' );
124- }
125- if (strrpos ($ line , "\n" ) === strlen ($ line ) - 1 ){
126- $ line = substr ($ line , 0 , strlen ($ line ) - 1 ); // cut off line break
123+ $ this ->current = null ;
124+ if (feof ($ this ->stream )){
125+ return ;
126+ } else {
127+ throw new \RuntimeException ('could not read line from php://temp at index ' .$ this ->index .' of ' .$ this ->count .' items ' );
128+ }
127129 }
130+ $ line = substr ($ line , 0 , strlen ($ line ) - 1 ); // cut off line break
128131 $ compressed = stripcslashes ($ line );
129132 /** @var string|false $serialized */
130133 $ serialized = match ($ this ->compression ){
You can’t perform that action at this time.
0 commit comments