• 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/Network/socket_pair.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Psl\Network;
6

7
use Psl\Internal;
8
use Psl\OS;
9
use Psl\TCP;
10

11
use function error_get_last;
12
use function stream_socket_pair;
13

14
use const STREAM_IPPROTO_IP;
15
use const STREAM_PF_INET;
16
use const STREAM_PF_UNIX;
17
use const STREAM_SOCK_STREAM;
18

19
/**
20
 * Create a pair of connected bidirectional stream sockets.
21
 *
22
 * Both ends can read and write. Data written to one end can be read from the other.
23
 * Useful for testing, inter-fiber communication, or in-process proxying.
24
 *
25
 * @return array{StreamInterface, StreamInterface}
26
 *
27
 * @throws Exception\RuntimeException If unable to create the socket pair.
28
 */
29
function socket_pair(): array
30
{
31
    $sockets = Internal\suppress(
3✔
32
        /**
33
         * @return array{0: resource, 1: resource}
34
         */
35
        static function (): array {
3✔
36
            $domain = OS\is_windows() ? STREAM_PF_INET : STREAM_PF_UNIX;
3✔
37
            $sockets = stream_socket_pair($domain, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);
3✔
38
            if (false === $sockets) {
3✔
39
                /** @var array{message?: string} $error */
NEW
40
                $error = error_get_last();
×
NEW
41
                throw new Exception\RuntimeException($error['message'] ?? 'Failed to create socket pair.');
×
42
            }
43

44
            return [$sockets[0], $sockets[1]];
3✔
45
        },
3✔
46
    );
3✔
47

48
    return [
3✔
49
        new TCP\Internal\Stream($sockets[0]),
3✔
50
        new TCP\Internal\Stream($sockets[1]),
3✔
51
    ];
3✔
52
}
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