Skip to content

Commit

Permalink
Remove development artifacts and restore PHP 8.3 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
adamziel committed Mar 19, 2024
1 parent 3506ef4 commit 003e4cc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/WordPress/AsyncHttp/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ function ( $request ) {
}

while ( true ) {
if ( ! $request_info->isFinished() && feof( $stream ) ) {
if ( ! $request_info->is_finished() && feof( $stream ) ) {
$request_info->state = RequestInfo::STATE_FINISHED;
fclose( $stream );
$this->queue_needs_processing = true;
Expand All @@ -271,7 +271,7 @@ function ( $request ) {
$request_info->buffer = substr( $request_info->buffer, $length );

return $buffered;
} elseif ( $request_info->isFinished() ) {
} elseif ( $request_info->is_finished() ) {
unset( $this->requests[ $request ] );

return $request_info->buffer;
Expand Down
5 changes: 2 additions & 3 deletions src/WordPress/AsyncHttp/async_http_streams.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ function streams_http_requests_send( $streams ) {
$remaining_streams = $streams;
while ( count( $remaining_streams ) ) {
$write = $remaining_streams;
sleep( 2 );
// phpcs:disable WordPress.PHP.NoSilencedErrors.Discouraged
$ready = @stream_select( $read, $write, $except, 5, 5000000 );
$ready = @stream_select( $read, $write, $except, 0, 5000000 );
if ( $ready === false ) {
throw new Exception( 'Error: ' . error_get_last()['message'] );
} elseif ( $ready <= 0 ) {
Expand Down Expand Up @@ -133,7 +132,7 @@ function streams_http_requests_send( $streams ) {
* @return array|false An array of chunks read from the streams, or false if no streams are available.
* @throws Exception If an error occurs during the stream_select operation or if the operation times out.
*/
function streams_http_response_await_bytes( $streams, $length, $timeout_microseconds = 5000000 ) {
function streams_http_response_await_bytes( $streams, $length, $timeout_microseconds = 500000 ) {
$read = $streams;
if ( count( $read ) === 0 ) {
return false;
Expand Down
2 changes: 2 additions & 0 deletions src/WordPress/Util/Map.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function offsetGet( $offset ) {
throw new \Exception( 'Stream for resource ' . json_encode( $offset ) . ' not found' );
}

#[\ReturnTypeWillChange]
public function offsetSet( $offset, $value ) {
foreach ( $this->pairs as $k => $pair ) {
if ( $pair[0] === $offset ) {
Expand All @@ -45,6 +46,7 @@ public function offsetSet( $offset, $value ) {
$this->pairs[] = array( $offset, $value );
}

#[\ReturnTypeWillChange]
public function offsetUnset( $offset ) {
foreach ( $this->pairs as $i => $pair ) {
if ( $pair[0] === $offset ) {
Expand Down

0 comments on commit 003e4cc

Please sign in to comment.