• 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

0.0
/src/Psl/Shell/Internal/escape_argument.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Psl\Shell\Internal;
6

7
use Psl\Regex;
8
use Psl\Str\Byte;
9

10
use const DIRECTORY_SEPARATOR;
11

12
/**
13
 * Escape a string to be used as a shell argument.
14
 *
15
 * @psalm-taint-escape shell
16
 *
17
 * @internal
18
 */
19
function escape_argument(string $argument): string
20
{
21
    /**
22
     * The following code was copied ( with modification ) from the Symfony Process Component (v5.2.3 - 2021-02-22).
23
     *
24
     * https://github.com/symfony/process/blob/b8d6eff26e48187fed15970799f4b605fa7242e4/Process.php#L1623-L1643
25
     *
26
     * @license MIT
27
     *
28
     * @see https://github.com/symfony/process/blob/b8d6eff26e48187fed15970799f4b605fa7242e4/LICENSE
29
     *
30
     * @copyright (c) 2004-2021 Fabien Potencier <fabien@symfony.com>
31
     */
UNCOV
32
    if ('' === $argument) {
×
33
        return '""';
×
34
    }
35

UNCOV
36
    if ('\\' !== DIRECTORY_SEPARATOR) {
×
UNCOV
37
        $argument = Byte\replace($argument, "'", "'\\''");
×
38

UNCOV
39
        return "'" . $argument . "'";
×
40
    }
41

42
    // @codeCoverageIgnoreStart
43
    if (Byte\contains($argument, "\0")) {
44
        $argument = Byte\replace($argument, "\0", '?');
45
    }
46

47
    if (!Regex\matches($argument, '/[\/()%!^"<>&|\s]/')) {
48
        return $argument;
49
    }
50

51
    $argument = Regex\replace($argument, '/(\\\\+)$/', '$1$1');
52
    $argument = Byte\replace_every($argument, [
53
        '"' => '""',
54
        '^' => '"^^"',
55
        '%' => '"^%"',
56
        '!' => '"^!"',
57
        "\n" => '!LF!',
58
    ]);
59

60
    return '"' . $argument . '"';
61
    // @codeCoverageIgnoreEnd
62
}
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