File: phar-autoload.php.in

package info (click to toggle)
phpcpd 7.0.0~git20230110-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 504 kB
  • sloc: php: 2,284; xml: 132; makefile: 21
file content (55 lines) | stat: -rw-r--r-- 1,290 bytes parent folder | download
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
#!/usr/bin/env php
<?php declare(strict_types=1);
if (version_compare('8.1.0', PHP_VERSION, '>')) {
    fwrite(
        STDERR,
        sprintf(
            'This version of PHPCPD requires PHP 8.1 (or later).' . PHP_EOL .
            'You are using PHP %s%s.' . PHP_EOL,
            PHP_VERSION,
            defined('PHP_BINARY') ? ' (' . PHP_BINARY . ')' : ''
        )
    );

    die(1);
}

if ($_SERVER['SCRIPT_NAME'] != '-') {
    $phar = realpath($_SERVER['SCRIPT_NAME']);
} else {
    $files = get_included_files();
    $phar = $files[0];
}

define('__PHPCPD_PHAR__', str_replace(DIRECTORY_SEPARATOR, '/', $phar));
define('__PHPCPD_PHAR_ROOT__', 'phar://___PHAR___');

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

      if ($classes === NULL) {
          $classes = array(
            ___CLASSLIST___
          );
      }

      $class = strtolower($class);

      if (isset($classes[$class])) {
          require 'phar://___PHAR___' . $classes[$class];
      }
  }
);

Phar::mapPhar('___PHAR___');

if (isset($_SERVER['argv'][1]) && $_SERVER['argv'][1] == '--manifest') {
    print file_get_contents(__PHPCPD_PHAR_ROOT__ . '/manifest.txt');
    exit;
}

exit((new \SebastianBergmann\PHPCPD\Application)->run($_SERVER['argv']));

__HALT_COMPILER();