1.2.0
Robustness fixes for the stream handling, opt-in delimiter-based response framing, and modernized tooling.
Added
Client::setDelimiter()— optional end-of-response marker (e.g."\n"for line-based protocols such as JSON-RPC over TCP). With a delimiter set, a response is complete as soon as it ends with the delimiter instead of after a silent interval on the stream: reads return sooner and truncated responses are detected (RequestExceptionon timeout,ConnectionExceptionwhen the connection closes before the response is completed) rather than silently accepted.Client::setPollInterval()andClient::DEFAULT_POLL_INTERVAL— renamed from "connection lag": the value is the pause between data availability checks.- CI: GitHub Actions matrix testing PHP 7.4, 8.0, 8.1, 8.2, 8.3, 8.4 and 8.5.
Fixed
- Infinite loop on a broken stream:
read()looped onfread() !== '', butfread()returnsfalseon error, so a broken stream spun forever. It now throws aConnectionException. - A connection closed by the peer looked like a timeout: neither read loop checked
feof(), so a closed connection kept polling for the full request timeout (30 s by default) and then reported a timeout. It now fails fast withConnectionException. - Unchecked and partial writes:
request()ignored thefwrite()result, so large request bodies could be partially written with no error surfaced. Writes now continue until the whole body is sent; a zero-byte write (full send buffer in non-blocking mode) is retried until the request timeout.
Changed
- Default chunk size raised from 1024 to 8192 bytes to match the size of PHP's internal stream read buffer.
psr/logv1, v2 and v3 are now accepted (Client::setLogger()returnsvoidper the v3 interface).- Minimum PHP version raised from 7.1 to 7.4.
- Test suite migrated from PHPUnit 7 to PHPUnit 9.6; README rewritten.
Deprecated
Client::setConnectionLag()— usesetPollInterval()instead.Client::DEFAULT_CONNECTION_LAG— useDEFAULT_POLL_INTERVALinstead.
Removed
- Unused
ext-jsonrequirement fromcomposer.json.
Backward-compatibility notes
- Wire behaviour without a delimiter is unchanged.
- A peer-closed connection now throws
ConnectionExceptionpromptly instead ofRequestExceptionafter the full timeout — code that caught onlyRequestExceptionfor that case should also catchConnectionException.
Full Changelog: 1.1...1.2.0