• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

azjezz / psl / 22519606807

28 Feb 2026 11:11AM UTC coverage: 97.532% (-1.2%) from 98.733%
22519606807

push

github

web-flow
feat(network): rewrite networking stack with TLS, UDP, SOCKS5, CIDR, and IO utilities (#585)

860 of 937 new or added lines in 31 files covered. (91.78%)

15 existing lines in 6 files now uncovered.

7470 of 7659 relevant lines covered (97.53%)

42.83 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.71
/src/Psl/IO/copy_bidirectional.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Psl\IO;
6

7
use Psl\Async;
8
use Psl\DateTime\Duration;
9

10
/**
11
 * Copy data bidirectionally between two handles until both sides reach EOF.
12
 *
13
 * This is useful for building proxies: data flows from $a to $b and from $b to $a
14
 * concurrently until both directions reach EOF.
15
 *
16
 * @return array{int<0, max>, int<0, max>} [bytes_a_to_b, bytes_b_to_a]
17
 *
18
 * @throws Exception\RuntimeException If a read or write error occurs.
19
 * @throws Exception\TimeoutException If the operation times out.
20
 */
21
function copy_bidirectional(
22
    ReadHandleInterface&WriteHandleInterface $a,
23
    ReadHandleInterface&WriteHandleInterface $b,
24
    null|Duration $timeout = null,
25
): array {
26
    $timer = new Async\OptionalIncrementalTimeout($timeout, static function (): never {
1✔
NEW
27
        throw new Exception\TimeoutException('Bidirectional copy operation timed out.');
×
28
    });
1✔
29

30
    /**
31
     * @var array{int<0, max>, int<0, max>}
32
     */
33
    return Async\concurrently([
1✔
34
        static fn(): int => copy($a, $b, $timer->getRemaining()),
1✔
35
        static fn(): int => copy($b, $a, $timer->getRemaining()),
1✔
36
    ]);
1✔
37
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc