autoload.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. $autoloadFile = './vendor/codeception/codeception/autoload.php';
  3. if (file_exists('./vendor/autoload.php') && file_exists($autoloadFile) && __FILE__ != realpath($autoloadFile)) {
  4. //for global installation or phar file
  5. fwrite(
  6. STDERR,
  7. "\n==== Redirecting to Composer-installed version in vendor/codeception ====\n"
  8. );
  9. require $autoloadFile;
  10. //require package/bin instead of codecept to avoid printing hashbang line
  11. require './vendor/codeception/codeception/package/bin';
  12. die;
  13. } elseif (file_exists(__DIR__ . '/vendor/autoload.php')) {
  14. // for phar
  15. require_once __DIR__ . '/vendor/autoload.php';
  16. } elseif (file_exists(__DIR__ . '/../../autoload.php')) {
  17. //for composer
  18. require_once __DIR__ . '/../../autoload.php';
  19. }
  20. unset($autoloadFile);
  21. // @codingStandardsIgnoreStart
  22. include_once __DIR__ . DIRECTORY_SEPARATOR . 'shim.php';
  23. // compat
  24. if (PHP_MAJOR_VERSION < 7) {
  25. if (false === interface_exists('Throwable', false)) {
  26. interface Throwable {};
  27. }
  28. if (false === class_exists('ParseError', false)) {
  29. class ParseError extends \Exception {};
  30. }
  31. }
  32. // @codingStandardsIgnoreEnd
  33. // function not autoloaded in PHP, thus its a good place for them
  34. if (!function_exists('codecept_debug')) {
  35. function codecept_debug($data)
  36. {
  37. \Codeception\Util\Debug::debug($data);
  38. }
  39. }
  40. if (!function_exists('codecept_root_dir')) {
  41. function codecept_root_dir($appendPath = '')
  42. {
  43. return \Codeception\Configuration::projectDir() . $appendPath;
  44. }
  45. }
  46. if (!function_exists('codecept_output_dir')) {
  47. function codecept_output_dir($appendPath = '')
  48. {
  49. return \Codeception\Configuration::outputDir() . $appendPath;
  50. }
  51. }
  52. if (!function_exists('codecept_log_dir')) {
  53. function codecept_log_dir($appendPath = '')
  54. {
  55. return \Codeception\Configuration::outputDir() . $appendPath;
  56. }
  57. }
  58. if (!function_exists('codecept_data_dir')) {
  59. function codecept_data_dir($appendPath = '')
  60. {
  61. return \Codeception\Configuration::dataDir() . $appendPath;
  62. }
  63. }
  64. if (!function_exists('codecept_relative_path')) {
  65. function codecept_relative_path($path)
  66. {
  67. return \Codeception\Util\PathResolver::getRelativeDir(
  68. $path,
  69. \Codeception\Configuration::projectDir(),
  70. DIRECTORY_SEPARATOR
  71. );
  72. }
  73. }
  74. if (!function_exists('codecept_absolute_path')) {
  75. /**
  76. * If $path is absolute, it will be returned without changes.
  77. * If $path is relative, it will be passed to `codecept_root_dir()` function
  78. * to make it absolute.
  79. *
  80. * @param string $path
  81. * @return string the absolute path
  82. */
  83. function codecept_absolute_path($path)
  84. {
  85. return codecept_is_path_absolute($path) ? $path : codecept_root_dir($path);
  86. }
  87. }
  88. if (!function_exists('codecept_is_path_absolute')) {
  89. /**
  90. * Check whether the given $path is absolute.
  91. *
  92. * @param string $path
  93. * @return bool
  94. * @since 2.4.4
  95. */
  96. function codecept_is_path_absolute($path)
  97. {
  98. if (DIRECTORY_SEPARATOR === '/') {
  99. return mb_substr($path, 0, 1) === DIRECTORY_SEPARATOR;
  100. }
  101. return preg_match('#^[A-Z]:(?![^/\\\])#i', $path) === 1;
  102. }
  103. }