src/Psalm/Internal/Fork/Pool.php
private function readResultsFromChildren()
    {
        // Create an array of all active streams, indexed by
        // resource id.
        $streams = [];
        foreach ($this->read_streams as $stream) {
            $streams[intval($stream)] = $stream;
        }

        // Create an array for the content received on each stream,
        // indexed by resource id.
        $content = array_fill_keys(array_keys($streams), '');

        // Read the data off of all the stream.
        while (count($streams) > 0) {
            $needs_read = array_values($streams);
            $needs_write = null;
            $needs_except = null;

            // Wait for data on at least one stream.
            $num = stream_select($needs_read, $needs_write, $needs_except, null /* no timeout */);
            if ($num === false) {
                error_log('unable to select on read stream');
                exit(self::EXIT_FAILURE);
            }

            // For each stream that was ready, read the content.
            foreach ($needs_read as $file) {
                $buffer = fread($file, 1024);
                if ($buffer) {
                    $content[intval($file)] .= $buffer;
                }

                // If the stream has closed, stop trying to select on it.
                if (feof($file)) {
                    fclose($file);
                    unset($streams[intval($file)]);
                }
            }
        }

        // Unmarshal the content into its original form.
        return array_values(
            array_map(
                /**
                 * @param string $data
                 *
                 * @return array
                 */
                function ($data) {
                    /** @var array */
                    $result = unserialize($data);
                    /** @psalm-suppress DocblockTypeContradiction */
                    if (!\is_array($result)) {
                        error_log(
                            'Child terminated without returning a serialized array - response type=' . gettype($result)
                        );
                        $this->did_have_error = true;
                    }

                    return $result;
                },
                $content
            )
        );
    }
private function readResultsFromChildren()
    {
        // Create an array of all active streams, indexed by
        // resource id.
        $streams = [];
        foreach ($this->read_streams as $stream) {
            $streams[intval($stream)] = $stream;
        }

        // Create an array for the content received on each stream,
        // indexed by resource id.
        $content = array_fill_keys(array_keys($streams), '');

        // Read the data off of all the stream.
        while (count($streams) > 0) {
            $needs_read = array_values($streams);
            $needs_write = null;
            $needs_except = null;

            // Wait for data on at least one stream.
            $num = stream_select($needs_read, $needs_write, $needs_except, null /* no timeout */);
            if ($num === false) {
                error_log('unable to select on read stream');
                exit(self::EXIT_FAILURE);
            }

            // For each stream that was ready, read the content.
            foreach ($needs_read as $file) {
                $buffer = fread($file, 1024);
                if ($buffer) {
                    $content[intval($file)] .= $buffer;
                }

                // If the stream has closed, stop trying to select on it.
                if (feof($file)) {
                    fclose($file);
                    unset($streams[intval($file)]);
                }
            }
        }

        // Unmarshal the content into its original form.
        return array_values(
            array_map(
                /**
                 * @param string $data
                 *
                 * @return array
                 */
                function ($data) {
                    /** @var array */
                    $result = unserialize($data);
                    /** @psalm-suppress DocblockTypeContradiction */
                    if (!\is_array($result)) {
                        error_log(
                            'Child terminated without returning a serialized array - response type=' . gettype($result)
                        );
                        $this->did_have_error = true;
                    }

                    return $result;
                },
                $content
            )
        );
    }
private function readResultsFromChildren ( ) { // Create an array of all active streams, indexed by // resource id. $ streams = [ ] ; foreach ( $ this -> read_streams as $ stream ) { $ streams [ intval ( $ stream ) ] = $ stream ; } // Create an array for the content received on each stream, // indexed by resource id. $ content = array_fill_keys ( array_keys ( $ streams ) , '' ) ; // Read the data off of all the stream. while ( count ( $ streams ) > 0 ) { $ needs_read = array_values ( $ streams ) ; $ needs_write = null ; $ needs_except = null ; // Wait for data on at least one stream. $ num = stream_select ( $ needs_read , $ needs_write , $ needs_except , null /* no timeout */ ) ; if ( $ num === false ) { error_log ( 'unable to select on read stream' ) ; exit ( self :: EXIT_FAILURE ) ; } // For each stream that was ready, read the content. foreach ( $ needs_read as $ file ) { $ buffer = fread ( $ file , 1024 ) ; if ( $ buffer ) { $ content [ intval ( $ file ) ] .= $ buffer ; } // If the stream has closed, stop trying to select on it. if ( feof ( $ file ) ) { fclose ( $ file ) ; unset ( $ streams [ intval ( $ file ) ] ) ; } } } // Unmarshal the content into its original form. return array_values ( array_map ( /**
                 * @param string $data
                 *
                 * @return array
                 */ function ( $ data ) { /** @var array */ $ result = unserialize ( $ data ) ; /** @psalm-suppress DocblockTypeContradiction */ if ( ! \ is_array ( $ result ) ) { error_log ( 'Child terminated without returning a serialized array - response type=' . gettype ( $ result ) ) ; $ this -> did_have_error = true ; } return $ result ; } , $ content ) ) ; }
Read the results that each child process has serialized on their write streams.
The results are returned in an array, one for each worker. The order of the results
is not maintained.

@return array

@psalm-suppress MixedAssignment
@psalm-suppress MixedOperand
Read the results that each child process has serialized on their write streams . The results are returned in an array one for each worker . The order of the results is not maintained .