@@ -86,19 +86,19 @@ class AvroDataIO
86
86
private static $ metadata_schema ;
87
87
88
88
/**
89
- * @returns the initial "magic" segment of an Avro container file header.
89
+ * @return string the initial "magic" segment of an Avro container file header.
90
90
*/
91
91
public static function magic () { return ('Obj ' . pack ('c ' , self ::VERSION )); }
92
92
93
93
/**
94
- * @returns int count of bytes in the initial "magic" segment of the
94
+ * @return int count of bytes in the initial "magic" segment of the
95
95
* Avro container file header
96
96
*/
97
97
public static function magic_size () { return strlen (self ::magic ()); }
98
98
99
99
100
100
/**
101
- * @returns AvroSchema object of Avro container file metadata.
101
+ * @return AvroSchema object of Avro container file metadata.
102
102
*/
103
103
public static function metadata_schema ()
104
104
{
@@ -111,7 +111,7 @@ public static function metadata_schema()
111
111
* @param string $file_path file_path of file to open
112
112
* @param string $mode one of AvroFile::READ_MODE or AvroFile::WRITE_MODE
113
113
* @param string $schema_json JSON of writer's schema
114
- * @returns AvroDataIOWriter instance of AvroDataIOWriter
114
+ * @return AvroDataIOWriter instance of AvroDataIOWriter
115
115
*
116
116
* @throws AvroDataIOException if $writers_schema is not provided
117
117
* or if an invalid $mode is given.
@@ -122,7 +122,6 @@ public static function open_file($file_path, $mode=AvroFile::READ_MODE,
122
122
$ schema = !is_null ($ schema_json )
123
123
? AvroSchema::parse ($ schema_json ) : null ;
124
124
125
- $ io = false ;
126
125
switch ($ mode )
127
126
{
128
127
case AvroFile::WRITE_MODE :
@@ -144,7 +143,7 @@ public static function open_file($file_path, $mode=AvroFile::READ_MODE,
144
143
}
145
144
146
145
/**
147
- * @returns array array of valid codecs
146
+ * @return array array of valid codecs
148
147
*/
149
148
private static function valid_codecs ()
150
149
{
@@ -153,7 +152,7 @@ private static function valid_codecs()
153
152
154
153
/**
155
154
* @param string $codec
156
- * @returns boolean true if $codec is a valid codec value and false otherwise
155
+ * @return boolean true if $codec is a valid codec value and false otherwise
157
156
*/
158
157
public static function is_valid_codec ($ codec )
159
158
{
@@ -163,7 +162,7 @@ public static function is_valid_codec($codec)
163
162
/**
164
163
* @param AvroIO $io
165
164
* @param AvroSchema $schema
166
- * @returns AvroDataIOWriter
165
+ * @return AvroDataIOWriter
167
166
*/
168
167
protected static function open_writer ($ io , $ schema )
169
168
{
@@ -174,7 +173,7 @@ protected static function open_writer($io, $schema)
174
173
/**
175
174
* @param AvroIO $io
176
175
* @param AvroSchema $schema
177
- * @returns AvroDataIOReader
176
+ * @return AvroDataIOReader
178
177
*/
179
178
protected static function open_reader ($ io , $ schema )
180
179
{
@@ -209,12 +208,12 @@ class AvroDataIOReader
209
208
/**
210
209
* @var string
211
210
*/
212
- private $ sync_marker ;
211
+ public $ sync_marker ;
213
212
214
213
/**
215
214
* @var array object container metadata
216
215
*/
217
- private $ metadata ;
216
+ public $ metadata ;
218
217
219
218
/**
220
219
* @var int count of items in block
@@ -278,30 +277,28 @@ private function read_header()
278
277
279
278
/**
280
279
* @internal Would be nice to implement data() as an iterator, I think
281
- * @returns \Generator
280
+ * @return array of data from object container.
282
281
*/
283
282
public function data ()
284
283
{
284
+ $ data = array ();
285
285
while (true )
286
286
{
287
287
if (0 == $ this ->block_count )
288
288
{
289
- if ($ this ->is_eof ()) {
289
+ if ($ this ->is_eof ())
290
290
break ;
291
- }
292
291
293
- if ($ this ->skip_sync ()) {
294
- if ($ this ->is_eof ()) {
292
+ if ($ this ->skip_sync ())
293
+ if ($ this ->is_eof ())
295
294
break ;
296
- }
297
- }
298
295
299
296
$ this ->read_block_header ();
300
297
}
301
- $ data = $ this ->datum_reader ->read ($ this ->decoder );
298
+ $ data [] = $ this ->datum_reader ->read ($ this ->decoder );
302
299
$ this ->block_count -= 1 ;
303
- yield $ data ;
304
300
}
301
+ return $ data ;
305
302
}
306
303
307
304
/**
@@ -312,6 +309,10 @@ public function close() { return $this->io->close(); }
312
309
313
310
/**
314
311
* @uses AvroIO::seek()
312
+ * @param $offset
313
+ * @param $whence
314
+ * @return bool
315
+ * @throws AvroNotImplementedException
315
316
*/
316
317
private function seek ($ offset , $ whence )
317
318
{
@@ -320,6 +321,9 @@ private function seek($offset, $whence)
320
321
321
322
/**
322
323
* @uses AvroIO::read()
324
+ * @param $len
325
+ * @return string
326
+ * @throws AvroNotImplementedException
323
327
*/
324
328
private function read ($ len ) { return $ this ->io ->read ($ len ); }
325
329
@@ -328,6 +332,9 @@ private function read($len) { return $this->io->read($len); }
328
332
*/
329
333
private function is_eof () { return $ this ->io ->is_eof (); }
330
334
335
+ /**
336
+ * @return bool
337
+ */
331
338
private function skip_sync ()
332
339
{
333
340
$ proposed_sync_marker = $ this ->read (AvroDataIO::SYNC_SIZE );
@@ -342,7 +349,7 @@ private function skip_sync()
342
349
/**
343
350
* Reads the block header (which includes the count of items in the block
344
351
* and the length in bytes of the block)
345
- * @returns int length in bytes of the block.
352
+ * @return int length in bytes of the block.
346
353
*/
347
354
private function read_block_header ()
348
355
{
@@ -359,7 +366,7 @@ private function read_block_header()
359
366
class AvroDataIOWriter
360
367
{
361
368
/**
362
- * @returns string a new, unique sync marker.
369
+ * @return string a new, unique sync marker.
363
370
*/
364
371
private static function generate_sync_marker ()
365
372
{
@@ -411,6 +418,7 @@ private static function generate_sync_marker()
411
418
* @param AvroIO $io
412
419
* @param AvroIODatumWriter $datum_writer
413
420
* @param AvroSchema $writers_schema
421
+ * @throws AvroDataIOException
414
422
*/
415
423
public function __construct ($ io , $ datum_writer , $ writers_schema =null )
416
424
{
@@ -470,7 +478,7 @@ public function close()
470
478
471
479
/**
472
480
* Flushes biffer to AvroIO object container.
473
- * @returns mixed value of $io->flush()
481
+ * @return mixed value of $io->flush()
474
482
* @see AvroIO::flush()
475
483
*/
476
484
private function flush ()
@@ -522,13 +530,15 @@ private function write_header()
522
530
/**
523
531
* @param string $bytes
524
532
* @uses AvroIO::write()
533
+ * @return int
525
534
*/
526
535
private function write ($ bytes ) { return $ this ->io ->write ($ bytes ); }
527
536
528
537
/**
529
538
* @param int $offset
530
539
* @param int $whence
531
540
* @uses AvroIO::seek()
541
+ * @return bool
532
542
*/
533
543
private function seek ($ offset , $ whence )
534
544
{
0 commit comments