mirror of
https://github.com/shufflingpixels/php-io.git
synced 2026-08-15 11:48:13 +02:00
Replace PSR-7 StreamInterface with a set of small, composable interfaces (ReaderInterface, WriterInterface, SeekerInterface and their combinations). BinaryReader now depends only on ReaderInterface, BinaryWriter on WriterInterface, making both easy to satisfy with any byte source or sink. Buffer and Resource are simplified — no capability flags, no detach/close lifecycle, no PSR-7 metadata methods. LimitedResource is replaced by LimitedReader, a lightweight reader that enforces a byte count limit. BinaryReader::read() is renamed to readExact() for clarity. Tests updated throughout to match the new APIs.
16 lines
359 B
PHP
16 lines
359 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Shufflingpixels\IO;
|
|
|
|
/** Describes a source of bytes that can be read sequentially. */
|
|
interface ReaderInterface
|
|
{
|
|
/**
|
|
* Reads up to $length bytes, returning fewer at end of stream.
|
|
*
|
|
* Returns false when no more bytes are available.
|
|
*/
|
|
public function read(int $length): string|false;
|
|
}
|