File: binary-phar-autoload.php.in

package info (click to toggle)
phpunit 12.3.5-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 50,160 kB
  • sloc: php: 101,772; xml: 2,084; makefile: 124; sh: 99
file content (127 lines) | stat: -rw-r--r-- 3,071 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/usr/bin/env php
<?php
if (!version_compare(PHP_VERSION, PHP_VERSION, '=')) {
    fwrite(
        STDERR,
        sprintf(
            '%s declares an invalid value for PHP_VERSION.' . PHP_EOL .
            'This breaks fundamental functionality such as version_compare().' . PHP_EOL .
            'Please use a different PHP interpreter.' . PHP_EOL,

            PHP_BINARY
        )
    );

    die(1);
}

if (version_compare('8.3.0', PHP_VERSION, '>')) {
    fwrite(
        STDERR,
        sprintf(
            'PHPUnit X.Y.Z by Sebastian Bergmann and contributors.' . PHP_EOL . PHP_EOL .
            'This version of PHPUnit requires PHP >= 8.3.' . PHP_EOL .
            'You are using PHP %s (%s).' . PHP_EOL,
            PHP_VERSION,
            PHP_BINARY
        )
    );

    die(1);
}

$requiredExtensions = ['ctype', 'dom', 'json', 'libxml', 'mbstring', 'tokenizer', 'xml', 'xmlwriter'];

$unavailableExtensions = array_filter(
    $requiredExtensions,
    static function ($extension) {
        return !extension_loaded($extension);
    }
);

if ([] !== $unavailableExtensions) {
    fwrite(
        STDERR,
        sprintf(
            'PHPUnit requires the "%s" extensions, but the "%s" %s not available.' . PHP_EOL,
            implode('", "', $requiredExtensions),
            implode('", "', $unavailableExtensions),
            count($unavailableExtensions) === 1 ? 'extension is' : 'extensions are'
        )
    );

    die(1);
}

unset($requiredExtensions, $unavailableExtensions);

if (__FILE__ === realpath($_SERVER['SCRIPT_NAME'])) {
    $execute = true;
} else {
    $execute = false;
}

$options = getopt('', array('composer-lock', 'manifest', 'sbom'));

if (isset($options['composer-lock'])) {
    $printComposerLock = true;
} elseif (isset($options['manifest'])) {
    $printManifest = true;
} elseif (isset($options['sbom'])) {
    $printSbom = true;
}

unset($options);

define('__PHPUNIT_PHAR__', str_replace(DIRECTORY_SEPARATOR, '/', __FILE__));
define('__PHPUNIT_PHAR_ROOT__', 'phar://___PHAR___');

Phar::mapPhar('___PHAR___');

spl_autoload_register(
    function ($class) {
        static $classes = null;

        if ($classes === null) {
            $classes = [___CLASSLIST___];
        }

        if (isset($classes[$class])) {
            require_once 'phar://___PHAR___' . $classes[$class];
        }
    },
    ___EXCEPTION___,
    ___PREPEND___
);

foreach ([___CLASSLIST___] as $file) {
    require_once 'phar://___PHAR___' . $file;
}

require __PHPUNIT_PHAR_ROOT__ . '/phpunit/Framework/Assert/Functions.php';

if ($execute) {
    if (isset($printComposerLock)) {
        print file_get_contents(__PHPUNIT_PHAR_ROOT__ . '/composer.lock');

        exit;
    }

    if (isset($printManifest)) {
        print file_get_contents(__PHPUNIT_PHAR_ROOT__ . '/manifest.txt');

        exit;
    }

    if (isset($printSbom)) {
        print file_get_contents(__PHPUNIT_PHAR_ROOT__ . '/sbom.xml');

        exit;
    }

    unset($execute);

    exit((new PHPUnit\TextUI\Application)->run($_SERVER['argv']));
}

__HALT_COMPILER();