diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e244eda0bc4b3c391c07ec27c6f78e3b5b9ba3cf --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/vendor/ +/.idea/ \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b81b018ad684f3a35fee301741b2734c8f4..0000000000000000000000000000000000000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/grifart-not-serializable.iml b/.idea/grifart-not-serializable.iml deleted file mode 100644 index c53daa6c5746327ffe57328769ef70e1365a54b9..0000000000000000000000000000000000000000 --- a/.idea/grifart-not-serializable.iml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<module type="WEB_MODULE" version="4"> - <component name="NewModuleRootManager"> - <content url="file://$MODULE_DIR$"> - <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="Grifart\NotSerializable" /> - </content> - <orderEntry type="inheritedJdk" /> - <orderEntry type="sourceFolder" forTests="false" /> - </component> -</module> \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 903d2049c8715307390e50a268082f1ce34537a9..0000000000000000000000000000000000000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="ProjectModuleManager"> - <modules> - <module fileurl="file://$PROJECT_DIR$/.idea/grifart-not-serializable.iml" filepath="$PROJECT_DIR$/.idea/grifart-not-serializable.iml" /> - </modules> - </component> -</project> \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml deleted file mode 100644 index 7e5d55ab5b05437405982d5ba02e4af4fb3afd3f..0000000000000000000000000000000000000000 --- a/.idea/php.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="PhpProjectSharedConfiguration" php_language_level="8.1" /> -</project> \ No newline at end of file diff --git a/vendor/autoload.php b/vendor/autoload.php deleted file mode 100644 index d9aed1ffaf19824aeae7c7160f99fbc94e0e534e..0000000000000000000000000000000000000000 --- a/vendor/autoload.php +++ /dev/null @@ -1,7 +0,0 @@ -<?php - -// autoload.php @generated by Composer - -require_once __DIR__ . '/composer/autoload_real.php'; - -return ComposerAutoloaderInit98521d725cda1ff93233be2b41b76c6c::getLoader(); diff --git a/vendor/bin/phpstan b/vendor/bin/phpstan deleted file mode 100755 index 8a0d5a7e33c4a5f470f10c23c9f92184cb3b53eb..0000000000000000000000000000000000000000 --- a/vendor/bin/phpstan +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/env php -<?php - -/** - * Proxy PHP file generated by Composer - * - * This file includes the referenced bin path (../phpstan/phpstan/phpstan) - * using a stream wrapper to prevent the shebang from being output on PHP<8 - * - * @generated - */ - -namespace Composer; - -$GLOBALS['_composer_bin_dir'] = __DIR__; -$GLOBALS['_composer_autoload_path'] = __DIR__ . '/..'.'/autoload.php'; - -if (PHP_VERSION_ID < 80000) { - if (!class_exists('Composer\BinProxyWrapper')) { - /** - * @internal - */ - final class BinProxyWrapper - { - private $handle; - private $position; - private $realpath; - - public function stream_open($path, $mode, $options, &$opened_path) - { - // get rid of phpvfscomposer:// prefix for __FILE__ & __DIR__ resolution - $opened_path = substr($path, 17); - $this->realpath = realpath($opened_path) ?: $opened_path; - $opened_path = $this->realpath; - $this->handle = fopen($this->realpath, $mode); - $this->position = 0; - - return (bool) $this->handle; - } - - public function stream_read($count) - { - $data = fread($this->handle, $count); - - if ($this->position === 0) { - $data = preg_replace('{^#!.*\r?\n}', '', $data); - } - - $this->position += strlen($data); - - return $data; - } - - public function stream_cast($castAs) - { - return $this->handle; - } - - public function stream_close() - { - fclose($this->handle); - } - - public function stream_lock($operation) - { - return $operation ? flock($this->handle, $operation) : true; - } - - public function stream_seek($offset, $whence) - { - if (0 === fseek($this->handle, $offset, $whence)) { - $this->position = ftell($this->handle); - return true; - } - - return false; - } - - public function stream_tell() - { - return $this->position; - } - - public function stream_eof() - { - return feof($this->handle); - } - - public function stream_stat() - { - return array(); - } - - public function stream_set_option($option, $arg1, $arg2) - { - return true; - } - - public function url_stat($path, $flags) - { - $path = substr($path, 17); - if (file_exists($path)) { - return stat($path); - } - - return false; - } - } - } - - if (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper')) { - include("phpvfscomposer://" . __DIR__ . '/..'.'/phpstan/phpstan/phpstan'); - exit(0); - } -} - -include __DIR__ . '/..'.'/phpstan/phpstan/phpstan'; diff --git a/vendor/bin/phpstan.phar b/vendor/bin/phpstan.phar deleted file mode 100755 index 9694c2faed92f53321d4e838d16a8277d6e639a0..0000000000000000000000000000000000000000 --- a/vendor/bin/phpstan.phar +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/env php -<?php - -/** - * Proxy PHP file generated by Composer - * - * This file includes the referenced bin path (../phpstan/phpstan/phpstan.phar) - * using a stream wrapper to prevent the shebang from being output on PHP<8 - * - * @generated - */ - -namespace Composer; - -$GLOBALS['_composer_bin_dir'] = __DIR__; -$GLOBALS['_composer_autoload_path'] = __DIR__ . '/..'.'/autoload.php'; - -if (PHP_VERSION_ID < 80000) { - if (!class_exists('Composer\BinProxyWrapper')) { - /** - * @internal - */ - final class BinProxyWrapper - { - private $handle; - private $position; - private $realpath; - - public function stream_open($path, $mode, $options, &$opened_path) - { - // get rid of phpvfscomposer:// prefix for __FILE__ & __DIR__ resolution - $opened_path = substr($path, 17); - $this->realpath = realpath($opened_path) ?: $opened_path; - $opened_path = $this->realpath; - $this->handle = fopen($this->realpath, $mode); - $this->position = 0; - - return (bool) $this->handle; - } - - public function stream_read($count) - { - $data = fread($this->handle, $count); - - if ($this->position === 0) { - $data = preg_replace('{^#!.*\r?\n}', '', $data); - } - - $this->position += strlen($data); - - return $data; - } - - public function stream_cast($castAs) - { - return $this->handle; - } - - public function stream_close() - { - fclose($this->handle); - } - - public function stream_lock($operation) - { - return $operation ? flock($this->handle, $operation) : true; - } - - public function stream_seek($offset, $whence) - { - if (0 === fseek($this->handle, $offset, $whence)) { - $this->position = ftell($this->handle); - return true; - } - - return false; - } - - public function stream_tell() - { - return $this->position; - } - - public function stream_eof() - { - return feof($this->handle); - } - - public function stream_stat() - { - return array(); - } - - public function stream_set_option($option, $arg1, $arg2) - { - return true; - } - - public function url_stat($path, $flags) - { - $path = substr($path, 17); - if (file_exists($path)) { - return stat($path); - } - - return false; - } - } - } - - if (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper')) { - include("phpvfscomposer://" . __DIR__ . '/..'.'/phpstan/phpstan/phpstan.phar'); - exit(0); - } -} - -include __DIR__ . '/..'.'/phpstan/phpstan/phpstan.phar'; diff --git a/vendor/bin/tester b/vendor/bin/tester deleted file mode 100755 index f914009bff2b0f89945529e5ccec31a54f907174..0000000000000000000000000000000000000000 --- a/vendor/bin/tester +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/env php -<?php - -/** - * Proxy PHP file generated by Composer - * - * This file includes the referenced bin path (../nette/tester/src/tester) - * using a stream wrapper to prevent the shebang from being output on PHP<8 - * - * @generated - */ - -namespace Composer; - -$GLOBALS['_composer_bin_dir'] = __DIR__; -$GLOBALS['_composer_autoload_path'] = __DIR__ . '/..'.'/autoload.php'; - -if (PHP_VERSION_ID < 80000) { - if (!class_exists('Composer\BinProxyWrapper')) { - /** - * @internal - */ - final class BinProxyWrapper - { - private $handle; - private $position; - private $realpath; - - public function stream_open($path, $mode, $options, &$opened_path) - { - // get rid of phpvfscomposer:// prefix for __FILE__ & __DIR__ resolution - $opened_path = substr($path, 17); - $this->realpath = realpath($opened_path) ?: $opened_path; - $opened_path = $this->realpath; - $this->handle = fopen($this->realpath, $mode); - $this->position = 0; - - return (bool) $this->handle; - } - - public function stream_read($count) - { - $data = fread($this->handle, $count); - - if ($this->position === 0) { - $data = preg_replace('{^#!.*\r?\n}', '', $data); - } - - $this->position += strlen($data); - - return $data; - } - - public function stream_cast($castAs) - { - return $this->handle; - } - - public function stream_close() - { - fclose($this->handle); - } - - public function stream_lock($operation) - { - return $operation ? flock($this->handle, $operation) : true; - } - - public function stream_seek($offset, $whence) - { - if (0 === fseek($this->handle, $offset, $whence)) { - $this->position = ftell($this->handle); - return true; - } - - return false; - } - - public function stream_tell() - { - return $this->position; - } - - public function stream_eof() - { - return feof($this->handle); - } - - public function stream_stat() - { - return array(); - } - - public function stream_set_option($option, $arg1, $arg2) - { - return true; - } - - public function url_stat($path, $flags) - { - $path = substr($path, 17); - if (file_exists($path)) { - return stat($path); - } - - return false; - } - } - } - - if (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper')) { - include("phpvfscomposer://" . __DIR__ . '/..'.'/nette/tester/src/tester'); - exit(0); - } -} - -include __DIR__ . '/..'.'/nette/tester/src/tester'; diff --git a/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php deleted file mode 100644 index afef3fa2ad83f114c8de5487e869f9c9b8a459bf..0000000000000000000000000000000000000000 --- a/vendor/composer/ClassLoader.php +++ /dev/null @@ -1,572 +0,0 @@ -<?php - -/* - * This file is part of Composer. - * - * (c) Nils Adermann <naderman@naderman.de> - * Jordi Boggiano <j.boggiano@seld.be> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Autoload; - -/** - * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. - * - * $loader = new \Composer\Autoload\ClassLoader(); - * - * // register classes with namespaces - * $loader->add('Symfony\Component', __DIR__.'/component'); - * $loader->add('Symfony', __DIR__.'/framework'); - * - * // activate the autoloader - * $loader->register(); - * - * // to enable searching the include path (eg. for PEAR packages) - * $loader->setUseIncludePath(true); - * - * In this example, if you try to use a class in the Symfony\Component - * namespace or one of its children (Symfony\Component\Console for instance), - * the autoloader will first look for the class under the component/ - * directory, and it will then fallback to the framework/ directory if not - * found before giving up. - * - * This class is loosely based on the Symfony UniversalClassLoader. - * - * @author Fabien Potencier <fabien@symfony.com> - * @author Jordi Boggiano <j.boggiano@seld.be> - * @see https://www.php-fig.org/psr/psr-0/ - * @see https://www.php-fig.org/psr/psr-4/ - */ -class ClassLoader -{ - /** @var ?string */ - private $vendorDir; - - // PSR-4 - /** - * @var array[] - * @psalm-var array<string, array<string, int>> - */ - private $prefixLengthsPsr4 = array(); - /** - * @var array[] - * @psalm-var array<string, array<int, string>> - */ - private $prefixDirsPsr4 = array(); - /** - * @var array[] - * @psalm-var array<string, string> - */ - private $fallbackDirsPsr4 = array(); - - // PSR-0 - /** - * @var array[] - * @psalm-var array<string, array<string, string[]>> - */ - private $prefixesPsr0 = array(); - /** - * @var array[] - * @psalm-var array<string, string> - */ - private $fallbackDirsPsr0 = array(); - - /** @var bool */ - private $useIncludePath = false; - - /** - * @var string[] - * @psalm-var array<string, string> - */ - private $classMap = array(); - - /** @var bool */ - private $classMapAuthoritative = false; - - /** - * @var bool[] - * @psalm-var array<string, bool> - */ - private $missingClasses = array(); - - /** @var ?string */ - private $apcuPrefix; - - /** - * @var self[] - */ - private static $registeredLoaders = array(); - - /** - * @param ?string $vendorDir - */ - public function __construct($vendorDir = null) - { - $this->vendorDir = $vendorDir; - } - - /** - * @return string[] - */ - public function getPrefixes() - { - if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); - } - - return array(); - } - - /** - * @return array[] - * @psalm-return array<string, array<int, string>> - */ - public function getPrefixesPsr4() - { - return $this->prefixDirsPsr4; - } - - /** - * @return array[] - * @psalm-return array<string, string> - */ - public function getFallbackDirs() - { - return $this->fallbackDirsPsr0; - } - - /** - * @return array[] - * @psalm-return array<string, string> - */ - public function getFallbackDirsPsr4() - { - return $this->fallbackDirsPsr4; - } - - /** - * @return string[] Array of classname => path - * @psalm-return array<string, string> - */ - public function getClassMap() - { - return $this->classMap; - } - - /** - * @param string[] $classMap Class to filename map - * @psalm-param array<string, string> $classMap - * - * @return void - */ - public function addClassMap(array $classMap) - { - if ($this->classMap) { - $this->classMap = array_merge($this->classMap, $classMap); - } else { - $this->classMap = $classMap; - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, either - * appending or prepending to the ones previously set for this prefix. - * - * @param string $prefix The prefix - * @param string[]|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories - * - * @return void - */ - public function add($prefix, $paths, $prepend = false) - { - if (!$prefix) { - if ($prepend) { - $this->fallbackDirsPsr0 = array_merge( - (array) $paths, - $this->fallbackDirsPsr0 - ); - } else { - $this->fallbackDirsPsr0 = array_merge( - $this->fallbackDirsPsr0, - (array) $paths - ); - } - - return; - } - - $first = $prefix[0]; - if (!isset($this->prefixesPsr0[$first][$prefix])) { - $this->prefixesPsr0[$first][$prefix] = (array) $paths; - - return; - } - if ($prepend) { - $this->prefixesPsr0[$first][$prefix] = array_merge( - (array) $paths, - $this->prefixesPsr0[$first][$prefix] - ); - } else { - $this->prefixesPsr0[$first][$prefix] = array_merge( - $this->prefixesPsr0[$first][$prefix], - (array) $paths - ); - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, either - * appending or prepending to the ones previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param string[]|string $paths The PSR-4 base directories - * @param bool $prepend Whether to prepend the directories - * - * @throws \InvalidArgumentException - * - * @return void - */ - public function addPsr4($prefix, $paths, $prepend = false) - { - if (!$prefix) { - // Register directories for the root namespace. - if ($prepend) { - $this->fallbackDirsPsr4 = array_merge( - (array) $paths, - $this->fallbackDirsPsr4 - ); - } else { - $this->fallbackDirsPsr4 = array_merge( - $this->fallbackDirsPsr4, - (array) $paths - ); - } - } elseif (!isset($this->prefixDirsPsr4[$prefix])) { - // Register directories for a new namespace. - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; - } elseif ($prepend) { - // Prepend directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - (array) $paths, - $this->prefixDirsPsr4[$prefix] - ); - } else { - // Append directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - $this->prefixDirsPsr4[$prefix], - (array) $paths - ); - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, - * replacing any others previously set for this prefix. - * - * @param string $prefix The prefix - * @param string[]|string $paths The PSR-0 base directories - * - * @return void - */ - public function set($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr0 = (array) $paths; - } else { - $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, - * replacing any others previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param string[]|string $paths The PSR-4 base directories - * - * @throws \InvalidArgumentException - * - * @return void - */ - public function setPsr4($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr4 = (array) $paths; - } else { - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; - } - } - - /** - * Turns on searching the include path for class files. - * - * @param bool $useIncludePath - * - * @return void - */ - public function setUseIncludePath($useIncludePath) - { - $this->useIncludePath = $useIncludePath; - } - - /** - * Can be used to check if the autoloader uses the include path to check - * for classes. - * - * @return bool - */ - public function getUseIncludePath() - { - return $this->useIncludePath; - } - - /** - * Turns off searching the prefix and fallback directories for classes - * that have not been registered with the class map. - * - * @param bool $classMapAuthoritative - * - * @return void - */ - public function setClassMapAuthoritative($classMapAuthoritative) - { - $this->classMapAuthoritative = $classMapAuthoritative; - } - - /** - * Should class lookup fail if not found in the current class map? - * - * @return bool - */ - public function isClassMapAuthoritative() - { - return $this->classMapAuthoritative; - } - - /** - * APCu prefix to use to cache found/not-found classes, if the extension is enabled. - * - * @param string|null $apcuPrefix - * - * @return void - */ - public function setApcuPrefix($apcuPrefix) - { - $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; - } - - /** - * The APCu prefix in use, or null if APCu caching is not enabled. - * - * @return string|null - */ - public function getApcuPrefix() - { - return $this->apcuPrefix; - } - - /** - * Registers this instance as an autoloader. - * - * @param bool $prepend Whether to prepend the autoloader or not - * - * @return void - */ - public function register($prepend = false) - { - spl_autoload_register(array($this, 'loadClass'), true, $prepend); - - if (null === $this->vendorDir) { - return; - } - - if ($prepend) { - self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; - } else { - unset(self::$registeredLoaders[$this->vendorDir]); - self::$registeredLoaders[$this->vendorDir] = $this; - } - } - - /** - * Unregisters this instance as an autoloader. - * - * @return void - */ - public function unregister() - { - spl_autoload_unregister(array($this, 'loadClass')); - - if (null !== $this->vendorDir) { - unset(self::$registeredLoaders[$this->vendorDir]); - } - } - - /** - * Loads the given class or interface. - * - * @param string $class The name of the class - * @return true|null True if loaded, null otherwise - */ - public function loadClass($class) - { - if ($file = $this->findFile($class)) { - includeFile($file); - - return true; - } - - return null; - } - - /** - * Finds the path to the file where the class is defined. - * - * @param string $class The name of the class - * - * @return string|false The path if found, false otherwise - */ - public function findFile($class) - { - // class map lookup - if (isset($this->classMap[$class])) { - return $this->classMap[$class]; - } - if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { - return false; - } - if (null !== $this->apcuPrefix) { - $file = apcu_fetch($this->apcuPrefix.$class, $hit); - if ($hit) { - return $file; - } - } - - $file = $this->findFileWithExtension($class, '.php'); - - // Search for Hack files if we are running on HHVM - if (false === $file && defined('HHVM_VERSION')) { - $file = $this->findFileWithExtension($class, '.hh'); - } - - if (null !== $this->apcuPrefix) { - apcu_add($this->apcuPrefix.$class, $file); - } - - if (false === $file) { - // Remember that this class does not exist. - $this->missingClasses[$class] = true; - } - - return $file; - } - - /** - * Returns the currently registered loaders indexed by their corresponding vendor directories. - * - * @return self[] - */ - public static function getRegisteredLoaders() - { - return self::$registeredLoaders; - } - - /** - * @param string $class - * @param string $ext - * @return string|false - */ - private function findFileWithExtension($class, $ext) - { - // PSR-4 lookup - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; - - $first = $class[0]; - if (isset($this->prefixLengthsPsr4[$first])) { - $subPath = $class; - while (false !== $lastPos = strrpos($subPath, '\\')) { - $subPath = substr($subPath, 0, $lastPos); - $search = $subPath . '\\'; - if (isset($this->prefixDirsPsr4[$search])) { - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); - foreach ($this->prefixDirsPsr4[$search] as $dir) { - if (file_exists($file = $dir . $pathEnd)) { - return $file; - } - } - } - } - } - - // PSR-4 fallback dirs - foreach ($this->fallbackDirsPsr4 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { - return $file; - } - } - - // PSR-0 lookup - if (false !== $pos = strrpos($class, '\\')) { - // namespaced class name - $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) - . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); - } else { - // PEAR-like class name - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; - } - - if (isset($this->prefixesPsr0[$first])) { - foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { - if (0 === strpos($class, $prefix)) { - foreach ($dirs as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - } - } - } - - // PSR-0 fallback dirs - foreach ($this->fallbackDirsPsr0 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - - // PSR-0 include paths. - if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { - return $file; - } - - return false; - } -} - -/** - * Scope isolated include. - * - * Prevents access to $this/self from included files. - * - * @param string $file - * @return void - * @private - */ -function includeFile($file) -{ - include $file; -} diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php deleted file mode 100644 index d50e0c9fcc47df4f65268ae1a0b4074990160486..0000000000000000000000000000000000000000 --- a/vendor/composer/InstalledVersions.php +++ /dev/null @@ -1,350 +0,0 @@ -<?php - -/* - * This file is part of Composer. - * - * (c) Nils Adermann <naderman@naderman.de> - * Jordi Boggiano <j.boggiano@seld.be> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer; - -use Composer\Autoload\ClassLoader; -use Composer\Semver\VersionParser; - -/** - * This class is copied in every Composer installed project and available to all - * - * See also https://getcomposer.org/doc/07-runtime.md#installed-versions - * - * To require its presence, you can require `composer-runtime-api ^2.0` - */ -class InstalledVersions -{ - /** - * @var mixed[]|null - * @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}|array{}|null - */ - private static $installed; - - /** - * @var bool|null - */ - private static $canGetVendors; - - /** - * @var array[] - * @psalm-var array<string, array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}> - */ - private static $installedByVendor = array(); - - /** - * Returns a list of all package names which are present, either by being installed, replaced or provided - * - * @return string[] - * @psalm-return list<string> - */ - public static function getInstalledPackages() - { - $packages = array(); - foreach (self::getInstalled() as $installed) { - $packages[] = array_keys($installed['versions']); - } - - if (1 === \count($packages)) { - return $packages[0]; - } - - return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); - } - - /** - * Returns a list of all package names with a specific type e.g. 'library' - * - * @param string $type - * @return string[] - * @psalm-return list<string> - */ - public static function getInstalledPackagesByType($type) - { - $packagesByType = array(); - - foreach (self::getInstalled() as $installed) { - foreach ($installed['versions'] as $name => $package) { - if (isset($package['type']) && $package['type'] === $type) { - $packagesByType[] = $name; - } - } - } - - return $packagesByType; - } - - /** - * Checks whether the given package is installed - * - * This also returns true if the package name is provided or replaced by another package - * - * @param string $packageName - * @param bool $includeDevRequirements - * @return bool - */ - public static function isInstalled($packageName, $includeDevRequirements = true) - { - foreach (self::getInstalled() as $installed) { - if (isset($installed['versions'][$packageName])) { - return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']); - } - } - - return false; - } - - /** - * Checks whether the given package satisfies a version constraint - * - * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call: - * - * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3') - * - * @param VersionParser $parser Install composer/semver to have access to this class and functionality - * @param string $packageName - * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package - * @return bool - */ - public static function satisfies(VersionParser $parser, $packageName, $constraint) - { - $constraint = $parser->parseConstraints($constraint); - $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); - - return $provided->matches($constraint); - } - - /** - * Returns a version constraint representing all the range(s) which are installed for a given package - * - * It is easier to use this via isInstalled() with the $constraint argument if you need to check - * whether a given version of a package is installed, and not just whether it exists - * - * @param string $packageName - * @return string Version constraint usable with composer/semver - */ - public static function getVersionRanges($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - $ranges = array(); - if (isset($installed['versions'][$packageName]['pretty_version'])) { - $ranges[] = $installed['versions'][$packageName]['pretty_version']; - } - if (array_key_exists('aliases', $installed['versions'][$packageName])) { - $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); - } - if (array_key_exists('replaced', $installed['versions'][$packageName])) { - $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); - } - if (array_key_exists('provided', $installed['versions'][$packageName])) { - $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); - } - - return implode(' || ', $ranges); - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @param string $packageName - * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present - */ - public static function getVersion($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - if (!isset($installed['versions'][$packageName]['version'])) { - return null; - } - - return $installed['versions'][$packageName]['version']; - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @param string $packageName - * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present - */ - public static function getPrettyVersion($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - if (!isset($installed['versions'][$packageName]['pretty_version'])) { - return null; - } - - return $installed['versions'][$packageName]['pretty_version']; - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @param string $packageName - * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference - */ - public static function getReference($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - if (!isset($installed['versions'][$packageName]['reference'])) { - return null; - } - - return $installed['versions'][$packageName]['reference']; - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @param string $packageName - * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path. - */ - public static function getInstallPath($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @return array - * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string} - */ - public static function getRootPackage() - { - $installed = self::getInstalled(); - - return $installed[0]['root']; - } - - /** - * Returns the raw installed.php data for custom implementations - * - * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. - * @return array[] - * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} - */ - public static function getRawData() - { - @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED); - - if (null === self::$installed) { - // only require the installed.php file if this file is loaded from its dumped location, - // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 - if (substr(__DIR__, -8, 1) !== 'C') { - self::$installed = include __DIR__ . '/installed.php'; - } else { - self::$installed = array(); - } - } - - return self::$installed; - } - - /** - * Returns the raw data of all installed.php which are currently loaded for custom implementations - * - * @return array[] - * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}> - */ - public static function getAllRawData() - { - return self::getInstalled(); - } - - /** - * Lets you reload the static array from another file - * - * This is only useful for complex integrations in which a project needs to use - * this class but then also needs to execute another project's autoloader in process, - * and wants to ensure both projects have access to their version of installed.php. - * - * A typical case would be PHPUnit, where it would need to make sure it reads all - * the data it needs from this class, then call reload() with - * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure - * the project in which it runs can then also use this class safely, without - * interference between PHPUnit's dependencies and the project's dependencies. - * - * @param array[] $data A vendor/composer/installed.php data set - * @return void - * - * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} $data - */ - public static function reload($data) - { - self::$installed = $data; - self::$installedByVendor = array(); - } - - /** - * @return array[] - * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}> - */ - private static function getInstalled() - { - if (null === self::$canGetVendors) { - self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); - } - - $installed = array(); - - if (self::$canGetVendors) { - foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { - if (isset(self::$installedByVendor[$vendorDir])) { - $installed[] = self::$installedByVendor[$vendorDir]; - } elseif (is_file($vendorDir.'/composer/installed.php')) { - $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; - if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { - self::$installed = $installed[count($installed) - 1]; - } - } - } - } - - if (null === self::$installed) { - // only require the installed.php file if this file is loaded from its dumped location, - // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 - if (substr(__DIR__, -8, 1) !== 'C') { - self::$installed = require __DIR__ . '/installed.php'; - } else { - self::$installed = array(); - } - } - $installed[] = self::$installed; - - return $installed; - } -} diff --git a/vendor/composer/LICENSE b/vendor/composer/LICENSE deleted file mode 100644 index f27399a042d95c4708af3a8c74d35d338763cf8f..0000000000000000000000000000000000000000 --- a/vendor/composer/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ - -Copyright (c) Nils Adermann, Jordi Boggiano - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php deleted file mode 100644 index a69290ef6957bd4f38735c55b7107d47b83a25bc..0000000000000000000000000000000000000000 --- a/vendor/composer/autoload_classmap.php +++ /dev/null @@ -1,40 +0,0 @@ -<?php - -// autoload_classmap.php @generated by Composer - -$vendorDir = dirname(dirname(__FILE__)); -$baseDir = dirname($vendorDir); - -return array( - 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', - 'Tester\\Assert' => $vendorDir . '/nette/tester/src/Framework/Assert.php', - 'Tester\\AssertException' => $vendorDir . '/nette/tester/src/Framework/AssertException.php', - 'Tester\\CodeCoverage\\Collector' => $vendorDir . '/nette/tester/src/CodeCoverage/Collector.php', - 'Tester\\CodeCoverage\\Generators\\AbstractGenerator' => $vendorDir . '/nette/tester/src/CodeCoverage/Generators/AbstractGenerator.php', - 'Tester\\CodeCoverage\\Generators\\CloverXMLGenerator' => $vendorDir . '/nette/tester/src/CodeCoverage/Generators/CloverXMLGenerator.php', - 'Tester\\CodeCoverage\\Generators\\HtmlGenerator' => $vendorDir . '/nette/tester/src/CodeCoverage/Generators/HtmlGenerator.php', - 'Tester\\CodeCoverage\\PhpParser' => $vendorDir . '/nette/tester/src/CodeCoverage/PhpParser.php', - 'Tester\\DataProvider' => $vendorDir . '/nette/tester/src/Framework/DataProvider.php', - 'Tester\\DomQuery' => $vendorDir . '/nette/tester/src/Framework/DomQuery.php', - 'Tester\\Dumper' => $vendorDir . '/nette/tester/src/Framework/Dumper.php', - 'Tester\\Environment' => $vendorDir . '/nette/tester/src/Framework/Environment.php', - 'Tester\\Expect' => $vendorDir . '/nette/tester/src/Framework/Expect.php', - 'Tester\\FileMock' => $vendorDir . '/nette/tester/src/Framework/FileMock.php', - 'Tester\\FileMutator' => $vendorDir . '/nette/tester/src/Framework/FileMutator.php', - 'Tester\\Helpers' => $vendorDir . '/nette/tester/src/Framework/Helpers.php', - 'Tester\\Runner\\CliTester' => $vendorDir . '/nette/tester/src/Runner/CliTester.php', - 'Tester\\Runner\\CommandLine' => $vendorDir . '/nette/tester/src/Runner/CommandLine.php', - 'Tester\\Runner\\Job' => $vendorDir . '/nette/tester/src/Runner/Job.php', - 'Tester\\Runner\\OutputHandler' => $vendorDir . '/nette/tester/src/Runner/OutputHandler.php', - 'Tester\\Runner\\Output\\ConsolePrinter' => $vendorDir . '/nette/tester/src/Runner/Output/ConsolePrinter.php', - 'Tester\\Runner\\Output\\JUnitPrinter' => $vendorDir . '/nette/tester/src/Runner/Output/JUnitPrinter.php', - 'Tester\\Runner\\Output\\Logger' => $vendorDir . '/nette/tester/src/Runner/Output/Logger.php', - 'Tester\\Runner\\Output\\TapPrinter' => $vendorDir . '/nette/tester/src/Runner/Output/TapPrinter.php', - 'Tester\\Runner\\PhpInterpreter' => $vendorDir . '/nette/tester/src/Runner/PhpInterpreter.php', - 'Tester\\Runner\\Runner' => $vendorDir . '/nette/tester/src/Runner/Runner.php', - 'Tester\\Runner\\Test' => $vendorDir . '/nette/tester/src/Runner/Test.php', - 'Tester\\Runner\\TestHandler' => $vendorDir . '/nette/tester/src/Runner/TestHandler.php', - 'Tester\\TestCase' => $vendorDir . '/nette/tester/src/Framework/TestCase.php', - 'Tester\\TestCaseException' => $vendorDir . '/nette/tester/src/Framework/TestCase.php', - 'Tester\\TestCaseSkippedException' => $vendorDir . '/nette/tester/src/Framework/TestCase.php', -); diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php deleted file mode 100644 index 989a5e543de5165bd81bfabc92cf39c2aa48fb19..0000000000000000000000000000000000000000 --- a/vendor/composer/autoload_files.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php - -// autoload_files.php @generated by Composer - -$vendorDir = dirname(dirname(__FILE__)); -$baseDir = dirname($vendorDir); - -return array( - '9b38cf48e83f5d8f60375221cd213eee' => $vendorDir . '/phpstan/phpstan/bootstrap.php', -); diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php deleted file mode 100644 index b7fc0125dbca56fd7565ad62097672a59473e64e..0000000000000000000000000000000000000000 --- a/vendor/composer/autoload_namespaces.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -// autoload_namespaces.php @generated by Composer - -$vendorDir = dirname(dirname(__FILE__)); -$baseDir = dirname($vendorDir); - -return array( -); diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php deleted file mode 100644 index 4166e7e7389225a3cc7bba4698ce39a3ad89c08d..0000000000000000000000000000000000000000 --- a/vendor/composer/autoload_psr4.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php - -// autoload_psr4.php @generated by Composer - -$vendorDir = dirname(dirname(__FILE__)); -$baseDir = dirname($vendorDir); - -return array( - 'Grifart\\NotSerializable\\' => array($baseDir . '/src'), -); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php deleted file mode 100644 index 27a7b3ed6a98d0104c618ffb8ed2be43b1136ce5..0000000000000000000000000000000000000000 --- a/vendor/composer/autoload_real.php +++ /dev/null @@ -1,80 +0,0 @@ -<?php - -// autoload_real.php @generated by Composer - -class ComposerAutoloaderInit98521d725cda1ff93233be2b41b76c6c -{ - private static $loader; - - public static function loadClassLoader($class) - { - if ('Composer\Autoload\ClassLoader' === $class) { - require __DIR__ . '/ClassLoader.php'; - } - } - - /** - * @return \Composer\Autoload\ClassLoader - */ - public static function getLoader() - { - if (null !== self::$loader) { - return self::$loader; - } - - require __DIR__ . '/platform_check.php'; - - spl_autoload_register(array('ComposerAutoloaderInit98521d725cda1ff93233be2b41b76c6c', 'loadClassLoader'), true, true); - self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); - spl_autoload_unregister(array('ComposerAutoloaderInit98521d725cda1ff93233be2b41b76c6c', 'loadClassLoader')); - - $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); - if ($useStaticLoader) { - require __DIR__ . '/autoload_static.php'; - - call_user_func(\Composer\Autoload\ComposerStaticInit98521d725cda1ff93233be2b41b76c6c::getInitializer($loader)); - } else { - $map = require __DIR__ . '/autoload_namespaces.php'; - foreach ($map as $namespace => $path) { - $loader->set($namespace, $path); - } - - $map = require __DIR__ . '/autoload_psr4.php'; - foreach ($map as $namespace => $path) { - $loader->setPsr4($namespace, $path); - } - - $classMap = require __DIR__ . '/autoload_classmap.php'; - if ($classMap) { - $loader->addClassMap($classMap); - } - } - - $loader->register(true); - - if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInit98521d725cda1ff93233be2b41b76c6c::$files; - } else { - $includeFiles = require __DIR__ . '/autoload_files.php'; - } - foreach ($includeFiles as $fileIdentifier => $file) { - composerRequire98521d725cda1ff93233be2b41b76c6c($fileIdentifier, $file); - } - - return $loader; - } -} - -/** - * @param string $fileIdentifier - * @param string $file - * @return void - */ -function composerRequire98521d725cda1ff93233be2b41b76c6c($fileIdentifier, $file) -{ - if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { - $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; - - require $file; - } -} diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php deleted file mode 100644 index 989281b6f4f45b5618e668942f2f12d2f8d909ea..0000000000000000000000000000000000000000 --- a/vendor/composer/autoload_static.php +++ /dev/null @@ -1,70 +0,0 @@ -<?php - -// autoload_static.php @generated by Composer - -namespace Composer\Autoload; - -class ComposerStaticInit98521d725cda1ff93233be2b41b76c6c -{ - public static $files = array ( - '9b38cf48e83f5d8f60375221cd213eee' => __DIR__ . '/..' . '/phpstan/phpstan/bootstrap.php', - ); - - public static $prefixLengthsPsr4 = array ( - 'G' => - array ( - 'Grifart\\NotSerializable\\' => 24, - ), - ); - - public static $prefixDirsPsr4 = array ( - 'Grifart\\NotSerializable\\' => - array ( - 0 => __DIR__ . '/../..' . '/src', - ), - ); - - public static $classMap = array ( - 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', - 'Tester\\Assert' => __DIR__ . '/..' . '/nette/tester/src/Framework/Assert.php', - 'Tester\\AssertException' => __DIR__ . '/..' . '/nette/tester/src/Framework/AssertException.php', - 'Tester\\CodeCoverage\\Collector' => __DIR__ . '/..' . '/nette/tester/src/CodeCoverage/Collector.php', - 'Tester\\CodeCoverage\\Generators\\AbstractGenerator' => __DIR__ . '/..' . '/nette/tester/src/CodeCoverage/Generators/AbstractGenerator.php', - 'Tester\\CodeCoverage\\Generators\\CloverXMLGenerator' => __DIR__ . '/..' . '/nette/tester/src/CodeCoverage/Generators/CloverXMLGenerator.php', - 'Tester\\CodeCoverage\\Generators\\HtmlGenerator' => __DIR__ . '/..' . '/nette/tester/src/CodeCoverage/Generators/HtmlGenerator.php', - 'Tester\\CodeCoverage\\PhpParser' => __DIR__ . '/..' . '/nette/tester/src/CodeCoverage/PhpParser.php', - 'Tester\\DataProvider' => __DIR__ . '/..' . '/nette/tester/src/Framework/DataProvider.php', - 'Tester\\DomQuery' => __DIR__ . '/..' . '/nette/tester/src/Framework/DomQuery.php', - 'Tester\\Dumper' => __DIR__ . '/..' . '/nette/tester/src/Framework/Dumper.php', - 'Tester\\Environment' => __DIR__ . '/..' . '/nette/tester/src/Framework/Environment.php', - 'Tester\\Expect' => __DIR__ . '/..' . '/nette/tester/src/Framework/Expect.php', - 'Tester\\FileMock' => __DIR__ . '/..' . '/nette/tester/src/Framework/FileMock.php', - 'Tester\\FileMutator' => __DIR__ . '/..' . '/nette/tester/src/Framework/FileMutator.php', - 'Tester\\Helpers' => __DIR__ . '/..' . '/nette/tester/src/Framework/Helpers.php', - 'Tester\\Runner\\CliTester' => __DIR__ . '/..' . '/nette/tester/src/Runner/CliTester.php', - 'Tester\\Runner\\CommandLine' => __DIR__ . '/..' . '/nette/tester/src/Runner/CommandLine.php', - 'Tester\\Runner\\Job' => __DIR__ . '/..' . '/nette/tester/src/Runner/Job.php', - 'Tester\\Runner\\OutputHandler' => __DIR__ . '/..' . '/nette/tester/src/Runner/OutputHandler.php', - 'Tester\\Runner\\Output\\ConsolePrinter' => __DIR__ . '/..' . '/nette/tester/src/Runner/Output/ConsolePrinter.php', - 'Tester\\Runner\\Output\\JUnitPrinter' => __DIR__ . '/..' . '/nette/tester/src/Runner/Output/JUnitPrinter.php', - 'Tester\\Runner\\Output\\Logger' => __DIR__ . '/..' . '/nette/tester/src/Runner/Output/Logger.php', - 'Tester\\Runner\\Output\\TapPrinter' => __DIR__ . '/..' . '/nette/tester/src/Runner/Output/TapPrinter.php', - 'Tester\\Runner\\PhpInterpreter' => __DIR__ . '/..' . '/nette/tester/src/Runner/PhpInterpreter.php', - 'Tester\\Runner\\Runner' => __DIR__ . '/..' . '/nette/tester/src/Runner/Runner.php', - 'Tester\\Runner\\Test' => __DIR__ . '/..' . '/nette/tester/src/Runner/Test.php', - 'Tester\\Runner\\TestHandler' => __DIR__ . '/..' . '/nette/tester/src/Runner/TestHandler.php', - 'Tester\\TestCase' => __DIR__ . '/..' . '/nette/tester/src/Framework/TestCase.php', - 'Tester\\TestCaseException' => __DIR__ . '/..' . '/nette/tester/src/Framework/TestCase.php', - 'Tester\\TestCaseSkippedException' => __DIR__ . '/..' . '/nette/tester/src/Framework/TestCase.php', - ); - - public static function getInitializer(ClassLoader $loader) - { - return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit98521d725cda1ff93233be2b41b76c6c::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit98521d725cda1ff93233be2b41b76c6c::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit98521d725cda1ff93233be2b41b76c6c::$classMap; - - }, null, ClassLoader::class); - } -} diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json deleted file mode 100644 index 13466a57053938fc94da2380eed3c78408ad7708..0000000000000000000000000000000000000000 --- a/vendor/composer/installed.json +++ /dev/null @@ -1,149 +0,0 @@ -{ - "packages": [ - { - "name": "nette/tester", - "version": "v2.4.1", - "version_normalized": "2.4.1.0", - "source": { - "type": "git", - "url": "https://github.com/nette/tester.git", - "reference": "b54326b3c1a2c6c76d2662a06b5ad5a10d822e98" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/nette/tester/zipball/b54326b3c1a2c6c76d2662a06b5ad5a10d822e98", - "reference": "b54326b3c1a2c6c76d2662a06b5ad5a10d822e98", - "shasum": "" - }, - "require": { - "php": ">=7.2 <8.2" - }, - "require-dev": { - "ext-simplexml": "*", - "phpstan/phpstan": "^0.12" - }, - "time": "2021-08-24T14:13:00+00:00", - "bin": [ - "src/tester" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.4-dev" - } - }, - "installation-source": "dist", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause", - "GPL-2.0-only", - "GPL-3.0-only" - ], - "authors": [ - { - "name": "David Grudl", - "homepage": "https://davidgrudl.com" - }, - { - "name": "Miloslav HΕ―la", - "homepage": "https://github.com/milo" - }, - { - "name": "Nette Community", - "homepage": "https://nette.org/contributors" - } - ], - "description": "Nette Tester: enjoyable unit testing in PHP with code coverage reporter. ππππ", - "homepage": "https://tester.nette.org", - "keywords": [ - "Xdebug", - "assertions", - "clover", - "code coverage", - "nette", - "pcov", - "phpdbg", - "phpunit", - "testing", - "unit" - ], - "support": { - "issues": "https://github.com/nette/tester/issues", - "source": "https://github.com/nette/tester/tree/v2.4.1" - }, - "install-path": "../nette/tester" - }, - { - "name": "phpstan/phpstan", - "version": "1.4.10", - "version_normalized": "1.4.10.0", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpstan.git", - "reference": "898c479c39caa727bedf4311dd294a8f4e250e72" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/898c479c39caa727bedf4311dd294a8f4e250e72", - "reference": "898c479c39caa727bedf4311dd294a8f4e250e72", - "shasum": "" - }, - "require": { - "php": "^7.1|^8.0" - }, - "conflict": { - "phpstan/phpstan-shim": "*" - }, - "time": "2022-03-14T10:25:45+00:00", - "bin": [ - "phpstan", - "phpstan.phar" - ], - "type": "library", - "installation-source": "dist", - "autoload": { - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PHPStan - PHP Static Analysis Tool", - "support": { - "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/1.4.10" - }, - "funding": [ - { - "url": "https://github.com/ondrejmirtes", - "type": "github" - }, - { - "url": "https://github.com/phpstan", - "type": "github" - }, - { - "url": "https://www.patreon.com/phpstan", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", - "type": "tidelift" - } - ], - "install-path": "../phpstan/phpstan" - } - ], - "dev": true, - "dev-package-names": [ - "nette/tester", - "phpstan/phpstan" - ] -} diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php deleted file mode 100644 index 3e6332b51a3f457334d6dfe4afc174e54a963779..0000000000000000000000000000000000000000 --- a/vendor/composer/installed.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php return array( - 'root' => array( - 'pretty_version' => '1.0.0+no-version-set', - 'version' => '1.0.0.0', - 'type' => 'library', - 'install_path' => __DIR__ . '/../../', - 'aliases' => array(), - 'reference' => NULL, - 'name' => 'grifart/not-serializable', - 'dev' => true, - ), - 'versions' => array( - 'grifart/not-serializable' => array( - 'pretty_version' => '1.0.0+no-version-set', - 'version' => '1.0.0.0', - 'type' => 'library', - 'install_path' => __DIR__ . '/../../', - 'aliases' => array(), - 'reference' => NULL, - 'dev_requirement' => false, - ), - 'nette/tester' => array( - 'pretty_version' => 'v2.4.1', - 'version' => '2.4.1.0', - 'type' => 'library', - 'install_path' => __DIR__ . '/../nette/tester', - 'aliases' => array(), - 'reference' => 'b54326b3c1a2c6c76d2662a06b5ad5a10d822e98', - 'dev_requirement' => true, - ), - 'phpstan/phpstan' => array( - 'pretty_version' => '1.4.10', - 'version' => '1.4.10.0', - 'type' => 'library', - 'install_path' => __DIR__ . '/../phpstan/phpstan', - 'aliases' => array(), - 'reference' => '898c479c39caa727bedf4311dd294a8f4e250e72', - 'dev_requirement' => true, - ), - ), -); diff --git a/vendor/composer/platform_check.php b/vendor/composer/platform_check.php deleted file mode 100644 index 580fa9609554b6be9fc475f7e0dc71c59d47138e..0000000000000000000000000000000000000000 --- a/vendor/composer/platform_check.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php - -// platform_check.php @generated by Composer - -$issues = array(); - -if (!(PHP_VERSION_ID >= 70400)) { - $issues[] = 'Your Composer dependencies require a PHP version ">= 7.4.0". You are running ' . PHP_VERSION . '.'; -} - -if ($issues) { - if (!headers_sent()) { - header('HTTP/1.1 500 Internal Server Error'); - } - if (!ini_get('display_errors')) { - if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { - fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); - } elseif (!headers_sent()) { - echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; - } - } - trigger_error( - 'Composer detected issues in your platform: ' . implode(' ', $issues), - E_USER_ERROR - ); -} diff --git a/vendor/nette/tester/appveyor.yml b/vendor/nette/tester/appveyor.yml deleted file mode 100644 index 85d7c1c0f9f21b41e1d4305373cdba0491b14f7e..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/appveyor.yml +++ /dev/null @@ -1,28 +0,0 @@ -build: off -cache: - - c:\php -> appveyor.yml - -clone_folder: c:\projects\tester - -init: - - SET ANSICON=121x90 (121x90) - -install: - # Install PHP 7.2 - - IF EXIST c:\php\72 (SET PHP=0) ELSE (SET PHP=1) - - IF %PHP%==1 mkdir c:\php\72 - - IF %PHP%==1 cd c:\php\72 - - IF %PHP%==1 curl https://windows.php.net/downloads/releases/archives/php-7.2.2-Win32-VC15-x64.zip --output php.zip - - IF %PHP%==1 7z x php.zip >nul - - IF %PHP%==1 del /Q *.zip - - - cd c:\projects\tester - -test_script: - - c:\php\72\php src\tester tests -s -p c:\php\72\php - - c:\php\72\php src\tester tests -s -p c:\php\72\php-cgi - - c:\php\72\php src\tester tests -s -p c:\php\72\phpdbg - -on_failure: - # Print *.actual content - - for /r %%x in (*.actual) do ( type "%%x" ) diff --git a/vendor/nette/tester/composer.json b/vendor/nette/tester/composer.json deleted file mode 100644 index d9cc1cc85eba9cf9918b1ad3e227c86b77db5c60..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/composer.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "name": "nette/tester", - "description": "Nette Tester: enjoyable unit testing in PHP with code coverage reporter. ππππ", - "homepage": "https://tester.nette.org", - "keywords": ["testing", "unit", "nette", "phpunit", "code coverage", "xdebug", "phpdbg", "pcov", "clover", "assertions"], - "license": ["BSD-3-Clause", "GPL-2.0-only", "GPL-3.0-only"], - "authors": [ - { - "name": "David Grudl", - "homepage": "https://davidgrudl.com" - }, - { - "name": "Miloslav HΕ―la", - "homepage": "https://github.com/milo" - }, - { - "name": "Nette Community", - "homepage": "https://nette.org/contributors" - } - ], - "require": { - "php": ">=7.2 <8.2" - }, - "require-dev": { - "ext-simplexml": "*", - "phpstan/phpstan": "^0.12" - }, - "autoload": { - "classmap": ["src/"] - }, - "bin": ["src/tester"], - "scripts": { - "phpstan": "phpstan analyse", - "tester": "tester tests -s" - }, - "extra": { - "branch-alias": { "dev-master": "2.4-dev" } - } -} diff --git a/vendor/nette/tester/license.md b/vendor/nette/tester/license.md deleted file mode 100644 index 03bf49fee434518f0c88ad168bdf2f848b0a36f7..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/license.md +++ /dev/null @@ -1,49 +0,0 @@ -Licenses -======== - -Good news! You may use Nette Tester under the terms of either -the New BSD License or the GNU General Public License (GPL) version 2 or 3. - - - -New BSD License ---------------- - -Copyright (c) 2004, 2013 David Grudl (https://davidgrudl.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - * Neither the name of "Nette Tester" nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - -This software is provided by the copyright holders and contributors "as is" and -any express or implied warranties, including, but not limited to, the implied -warranties of merchantability and fitness for a particular purpose are -disclaimed. In no event shall the copyright owner or contributors be liable for -any direct, indirect, incidental, special, exemplary, or consequential damages -(including, but not limited to, procurement of substitute goods or services; -loss of use, data, or profits; or business interruption) however caused and on -any theory of liability, whether in contract, strict liability, or tort -(including negligence or otherwise) arising in any way out of the use of this -software, even if advised of the possibility of such damage. - - - -GNU General Public License --------------------------- - -GPL licenses are very very long, so instead of including them here we offer -you URLs with full text: - -- [GPL version 2](http://www.gnu.org/licenses/gpl-2.0.html) -- [GPL version 3](http://www.gnu.org/licenses/gpl-3.0.html) diff --git a/vendor/nette/tester/readme.md b/vendor/nette/tester/readme.md deleted file mode 100644 index 58843595f71adb52e8d56443fb8bb15b49babc04..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/readme.md +++ /dev/null @@ -1,235 +0,0 @@ -[Nette Tester](https://tester.nette.org): enjoyable unit testing -================================================================ - -[](https://packagist.org/packages/nette/tester) -[](https://github.com/nette/tester/actions) -[](https://ci.appveyor.com/project/dg/tester/branch/master) -[](https://github.com/nette/tester/releases) -[](https://github.com/nette/tester/blob/master/license.md) - - -Introduction ------------- - -Nette Tester is a productive and enjoyable unit testing framework. It's used by -the [Nette Framework](https://nette.org) and is capable of testing any PHP code. - -Documentation is available on the [Nette Tester website](https://tester.nette.org). -Read the [blog](https://blog.nette.org/category/tester/) for new information. - - -[Support Tester](https://github.com/sponsors/dg) --------------------------------------------- - -Do you like Nette Tester? Are you looking forward to the new features? - -[](https://github.com/sponsors/dg) - -Thank you! - - -Installation ------------- - -The recommended way to install Nette Tester is through Composer: - -``` -composer require nette/tester --dev -``` - -Alternatively, you can download the [tester.phar](https://github.com/nette/tester/releases) file. - -- Nette Tester 2.4 is compatible with PHP 7.2 to 8.1 -- Nette Tester 2.3 is compatible with PHP 7.1 to 8.0 -- Nette Tester 2.1 & 2.2 is compatible with PHP 7.1 to 7.3 -- Nette Tester 2.0 is compatible with PHP 5.6 to 7.3 - -Collecting and processing code coverage information depends on Xdebug or PCOV extension, or PHPDBG SAPI. - - -Writing Tests -------------- - -Imagine that we are testing this simple class: - -```php -class Greeting -{ - function say($name) - { - if (!$name) { - throw new InvalidArgumentException('Invalid name.'); - } - return "Hello $name"; - } -} -``` - -So we create test file named `greeting.test.phpt`: - -```php -require 'src/bootstrap.php'; - -use Tester\Assert; - -$h = new Greeting; - -// use an assertion function to test say() -Assert::same('Hello John', $h->say('John')); -``` - -Thats' all! - -Now we run tests from command-line using the `tester` command: - -``` -> tester - _____ ___ ___ _____ ___ ___ -|_ _/ __)( __/_ _/ __)| _ ) - |_| \___ /___) |_| \___ |_|_\ v2.4.1 - -PHP 7.3.3 | php -n | 8 threads -. -OK (1 tests, 0 skipped, 0.0 seconds) -``` - -Nette Tester prints dot for successful test, F for failed test -and S when the test has been skipped. - - -Assertions ----------- - -This table shows all assertions (class `Assert` means `Tester\Assert`): - -- `Assert::same($expected, $actual)` - Reports an error if $expected and $actual are not the same. -- `Assert::notSame($expected, $actual)` - Reports an error if $expected and $actual are the same. -- `Assert::equal($expected, $actual)` - Like same(), but identity of objects and the order of keys in the arrays are ignored. -- `Assert::notEqual($expected, $actual)` - Like notSame(), but identity of objects and arrays order are ignored. -- `Assert::contains($needle, array $haystack)` - Reports an error if $needle is not an element of $haystack. -- `Assert::contains($needle, string $haystack)` - Reports an error if $needle is not a substring of $haystack. -- `Assert::notContains($needle, array $haystack)` - Reports an error if $needle is an element of $haystack. -- `Assert::notContains($needle, string $haystack)` - Reports an error if $needle is a substring of $haystack. -- `Assert::true($value)` - Reports an error if $value is not true. -- `Assert::false($value)` - Reports an error if $value is not false. -- `Assert::truthy($value)` - Reports an error if $value is not truthy. -- `Assert::falsey($value)` - Reports an error if $value is not falsey. -- `Assert::null($value)` - Reports an error if $value is not null. -- `Assert::nan($value)` - Reports an error if $value is not NAN. -- `Assert::type($type, $value)` - Reports an error if the variable $value is not of PHP or class type $type. -- `Assert::exception($closure, $class, $message = null, $code = null)` - Checks if the function throws exception. -- `Assert::error($closure, $level, $message = null)` - Checks if the function $closure throws PHP warning/notice/error. -- `Assert::noError($closure)` - Checks that the function $closure does not throw PHP warning/notice/error or exception. -- `Assert::match($pattern, $value)` - Compares result using regular expression or mask. -- `Assert::matchFile($file, $value)` - Compares result using regular expression or mask sorted in file. -- `Assert::count($count, $value)` - Reports an error if number of items in $value is not $count. -- `Assert::with($objectOrClass, $closure)` - Executes function that can access private and protected members of given object via $this. - -Testing exceptions: - -```php -Assert::exception(function () { - $h = new Greeting; - $h->say(null); -}, InvalidArgumentException::class, 'Invalid name.'); -``` - -Testing PHP errors, warnings or notices: - -```php -Assert::error(function () { - $h = new Greeting; - echo $h->abc; -}, E_NOTICE, 'Undefined property: Greeting::$abc'); -``` - -Testing private access methods: - -```php -$h = new Greeting; -Assert::with($h, function () { - // normalize() is internal private method. - Assert::same('Hello David', $this->normalize('Hello david')); // $this is Greeting -}); -``` - -Tips and features ------------------ - -Running unit tests manually is annoying, so let Nette Tester to watch your folder -with code and automatically re-run tests whenever code is changed: - -``` -tester -w /my/source/codes -``` - -Running tests in parallel is very much faster and Nette Tester uses 8 threads as default. -If you wish to run the tests in series use: - -``` -tester -j 1 -``` - -How do you find code that is not yet tested? Use Code-Coverage Analysis. This feature -requires you have installed [Xdebug](https://xdebug.org/) or [PCOV](https://github.com/krakjoe/pcov) -extension, or you are using PHPDBG SAPI. This will generate nice HTML report in `coverage.html`. - -``` -tester . -c php.ini --coverage coverage.html --coverage-src /my/source/codes -``` - -We can load Nette Tester using Composer's autoloader. In this case -it is important to setup Nette Tester environment: - -```php -require 'vendor/autoload.php'; - -Tester\Environment::setup(); -``` - -We can also test HTML pages. Let the [template engine](https://latte.nette.org) generate -HTML code or download existing page to `$html` variable. We will check whether -the page contains form fields for username and password. The syntax is the -same as the CSS selectors: - -```php -$dom = Tester\DomQuery::fromHtml($html); - -Assert::true($dom->has('input[name="username"]')); -Assert::true($dom->has('input[name="password"]')); -``` - -For more inspiration see how [Nette Tester tests itself](https://github.com/nette/tester/tree/master/tests). - - -Running tests -------------- - -The command-line test runner can be invoked through the `tester` command (or `php tester.php`). Take a look -at the command-line options: - -``` -> tester - -Usage: - tester [options] [<test file> | <directory>]... - -Options: - -p <path> Specify PHP interpreter to run (default: php). - -c <path> Look for php.ini file (or look in directory) <path>. - -C Use system-wide php.ini. - -l | --log <path> Write log to file <path>. - -d <key=value>... Define INI entry 'key' with value 'val'. - -s Show information about skipped tests. - --stop-on-fail Stop execution upon the first failure. - -j <num> Run <num> jobs in parallel (default: 8). - -o <console|tap|junit|none> Specify output format. - -w | --watch <path> Watch directory. - -i | --info Show tests environment info and exit. - --setup <path> Script for runner setup. - --temp <path> Path to temporary directory. Default by sys_get_temp_dir(). - --colors [1|0] Enable or disable colors. - --coverage <path> Generate code coverage report to file. - --coverage-src <path> Path to source code. - -h | --help This help. -``` diff --git a/vendor/nette/tester/src/CodeCoverage/Collector.php b/vendor/nette/tester/src/CodeCoverage/Collector.php deleted file mode 100644 index 585b6b52964ef06aafcfdaf2b4cd068b49528e60..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/CodeCoverage/Collector.php +++ /dev/null @@ -1,198 +0,0 @@ -<?php - -/** - * This file is part of the Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -namespace Tester\CodeCoverage; - - -/** - * Code coverage collector. - */ -class Collector -{ - public const - ENGINE_PCOV = 'PCOV', - ENGINE_PHPDBG = 'PHPDBG', - ENGINE_XDEBUG = 'Xdebug'; - - /** @var resource */ - private static $file; - - /** @var string */ - private static $engine; - - - public static function detectEngines(): array - { - return array_filter([ - extension_loaded('pcov') ? [self::ENGINE_PCOV, phpversion('pcov')] : null, - defined('PHPDBG_VERSION') ? [self::ENGINE_PHPDBG, PHPDBG_VERSION] : null, - extension_loaded('xdebug') ? [self::ENGINE_XDEBUG, phpversion('xdebug')] : null, - ]); - } - - - public static function isStarted(): bool - { - return self::$file !== null; - } - - - /** - * Starts gathering the information for code coverage. - * @throws \LogicException - */ - public static function start(string $file, string $engine): void - { - if (self::isStarted()) { - throw new \LogicException('Code coverage collector has been already started.'); - - } elseif (!in_array( - $engine, - array_map(function (array $engineInfo) { return $engineInfo[0]; }, self::detectEngines()), - true - )) { - throw new \LogicException("Code coverage engine '$engine' is not supported."); - } - - self::$file = fopen($file, 'c+'); - self::$engine = $engine; - self::{'start' . $engine}(); - - register_shutdown_function(function (): void { - register_shutdown_function([self::class, 'save']); - }); - } - - - /** - * Flushes all gathered information. Effective only with PHPDBG collector. - */ - public static function flush(): void - { - if (self::isStarted() && self::$engine === self::ENGINE_PHPDBG) { - self::save(); - } - } - - - /** - * Saves information about code coverage. Can be called repeatedly to free memory. - * @throws \LogicException - */ - public static function save(): void - { - if (!self::isStarted()) { - throw new \LogicException('Code coverage collector has not been started.'); - } - - [$positive, $negative] = self::{'collect' . self::$engine}(); - - flock(self::$file, LOCK_EX); - fseek(self::$file, 0); - $rawContent = stream_get_contents(self::$file); - $original = $rawContent ? unserialize($rawContent) : []; - $coverage = array_replace_recursive($negative, $original, $positive); - - fseek(self::$file, 0); - ftruncate(self::$file, 0); - fwrite(self::$file, serialize($coverage)); - flock(self::$file, LOCK_UN); - } - - - private static function startPCOV(): void - { - \pcov\start(); - } - - - /** - * Collects information about code coverage. - */ - private static function collectPCOV(): array - { - $positive = $negative = []; - - \pcov\stop(); - - foreach (\pcov\collect() as $file => $lines) { - if (!file_exists($file)) { - continue; - } - - foreach ($lines as $num => $val) { - if ($val > 0) { - $positive[$file][$num] = $val; - } else { - $negative[$file][$num] = $val; - } - } - } - - return [$positive, $negative]; - } - - - private static function startXdebug(): void - { - xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE); - } - - - /** - * Collects information about code coverage. - */ - private static function collectXdebug(): array - { - $positive = $negative = []; - - foreach (xdebug_get_code_coverage() as $file => $lines) { - if (!file_exists($file)) { - continue; - } - - foreach ($lines as $num => $val) { - if ($val > 0) { - $positive[$file][$num] = $val; - } else { - $negative[$file][$num] = $val; - } - } - } - - return [$positive, $negative]; - } - - - private static function startPhpDbg(): void - { - phpdbg_start_oplog(); - } - - - /** - * Collects information about code coverage. - */ - private static function collectPhpDbg(): array - { - $positive = phpdbg_end_oplog(); - $negative = phpdbg_get_executable(); - - foreach ($positive as $file => &$lines) { - $lines = array_fill_keys(array_keys($lines), 1); - } - - foreach ($negative as $file => &$lines) { - $lines = array_fill_keys(array_keys($lines), -1); - } - - phpdbg_start_oplog(); - return [$positive, $negative]; - } -} diff --git a/vendor/nette/tester/src/CodeCoverage/Generators/AbstractGenerator.php b/vendor/nette/tester/src/CodeCoverage/Generators/AbstractGenerator.php deleted file mode 100644 index 1fab066357221fd5a0185728acb9e919745ba818..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/CodeCoverage/Generators/AbstractGenerator.php +++ /dev/null @@ -1,131 +0,0 @@ -<?php - -/** - * This file is part of the Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -namespace Tester\CodeCoverage\Generators; - -use Tester\Helpers; - - -/** - * Code coverage report generator. - */ -abstract class AbstractGenerator -{ - protected const - CODE_DEAD = -2, - CODE_UNTESTED = -1, - CODE_TESTED = 1; - - /** @var array */ - public $acceptFiles = ['php', 'phpt', 'phtml']; - - /** @var array */ - protected $data; - - /** @var array */ - protected $sources; - - /** @var int */ - protected $totalSum = 0; - - /** @var int */ - protected $coveredSum = 0; - - - /** - * @param string $file path to coverage.dat file - * @param array $sources paths to covered source files or directories - */ - public function __construct(string $file, array $sources = []) - { - if (!is_file($file)) { - throw new \Exception("File '$file' is missing."); - } - - $this->data = @unserialize(file_get_contents($file)); // @ is escalated to exception - if (!is_array($this->data)) { - throw new \Exception("Content of file '$file' is invalid."); - } - - $this->data = array_filter($this->data, function (string $path): bool { - return @is_file($path); // @ some files or wrappers may not exist, i.e. mock:// - }, ARRAY_FILTER_USE_KEY); - - if (!$sources) { - $sources = [Helpers::findCommonDirectory(array_keys($this->data))]; - - } else { - foreach ($sources as $source) { - if (!file_exists($source)) { - throw new \Exception("File or directory '$source' is missing."); - } - } - } - - $this->sources = array_map('realpath', $sources); - } - - - public function render(string $file = null): void - { - $handle = $file ? @fopen($file, 'w') : STDOUT; // @ is escalated to exception - if (!$handle) { - throw new \Exception("Unable to write to file '$file'."); - } - - ob_start(function (string $buffer) use ($handle) { fwrite($handle, $buffer); }, 4096); - try { - $this->renderSelf(); - } catch (\Exception $e) { - } - ob_end_flush(); - fclose($handle); - - if (isset($e)) { - if ($file) { - unlink($file); - } - throw $e; - } - } - - - public function getCoveredPercent(): float - { - return $this->totalSum ? $this->coveredSum * 100 / $this->totalSum : 0; - } - - - protected function getSourceIterator(): \Iterator - { - $iterator = new \AppendIterator; - foreach ($this->sources as $source) { - $iterator->append( - is_dir($source) - ? new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source)) - : new \ArrayIterator([new \SplFileInfo($source)]) - ); - } - - return new \CallbackFilterIterator($iterator, function (\SplFileInfo $file): bool { - return $file->getBasename()[0] !== '.' // . or .. or .gitignore - && in_array($file->getExtension(), $this->acceptFiles, true); - }); - } - - - /** @deprecated */ - protected static function getCommonFilesPath(array $files): string - { - return Helpers::findCommonDirectory($files); - } - - - abstract protected function renderSelf(): void; -} diff --git a/vendor/nette/tester/src/CodeCoverage/Generators/CloverXMLGenerator.php b/vendor/nette/tester/src/CodeCoverage/Generators/CloverXMLGenerator.php deleted file mode 100644 index 6ec4190098e56013460c3a0ca737cacb973f214a..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/CodeCoverage/Generators/CloverXMLGenerator.php +++ /dev/null @@ -1,219 +0,0 @@ -<?php - -/** - * This file is part of the Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -namespace Tester\CodeCoverage\Generators; - -use DOMDocument; -use DOMElement; -use Tester\CodeCoverage\PhpParser; - - -class CloverXMLGenerator extends AbstractGenerator -{ - private static $metricAttributesMap = [ - 'packageCount' => 'packages', - 'fileCount' => 'files', - 'linesOfCode' => 'loc', - 'linesOfNonCommentedCode' => 'ncloc', - 'classCount' => 'classes', - 'methodCount' => 'methods', - 'coveredMethodCount' => 'coveredmethods', - 'statementCount' => 'statements', - 'coveredStatementCount' => 'coveredstatements', - 'elementCount' => 'elements', - 'coveredElementCount' => 'coveredelements', - 'conditionalCount' => 'conditionals', - 'coveredConditionalCount' => 'coveredconditionals', - ]; - - - public function __construct(string $file, array $sources = []) - { - if (!extension_loaded('dom') || !extension_loaded('tokenizer')) { - throw new \LogicException('CloverXML generator requires DOM and Tokenizer extensions to be loaded.'); - } - parent::__construct($file, $sources); - } - - - protected function renderSelf(): void - { - $time = (string) time(); - $parser = new PhpParser; - - $doc = new DOMDocument; - $doc->formatOutput = true; - - $elCoverage = $doc->appendChild($doc->createElement('coverage')); - $elCoverage->setAttribute('generated', $time); - - // TODO: @name - $elProject = $elCoverage->appendChild($doc->createElement('project')); - $elProject->setAttribute('timestamp', $time); - $elProjectMetrics = $elProject->appendChild($doc->createElement('metrics')); - - $projectMetrics = (object) [ - 'packageCount' => 0, - 'fileCount' => 0, - 'linesOfCode' => 0, - 'linesOfNonCommentedCode' => 0, - 'classCount' => 0, - 'methodCount' => 0, - 'coveredMethodCount' => 0, - 'statementCount' => 0, - 'coveredStatementCount' => 0, - 'elementCount' => 0, - 'coveredElementCount' => 0, - 'conditionalCount' => 0, - 'coveredConditionalCount' => 0, - ]; - - foreach ($this->getSourceIterator() as $file) { - $file = (string) $file; - - $projectMetrics->fileCount++; - - if (empty($this->data[$file])) { - $coverageData = null; - $this->totalSum += count(file($file, FILE_SKIP_EMPTY_LINES)); - } else { - $coverageData = $this->data[$file]; - } - - // TODO: split to <package> by namespace? - $elFile = $elProject->appendChild($doc->createElement('file')); - $elFile->setAttribute('name', $file); - $elFileMetrics = $elFile->appendChild($doc->createElement('metrics')); - - $code = $parser->parse(file_get_contents($file)); - - $fileMetrics = (object) [ - 'linesOfCode' => $code->linesOfCode, - 'linesOfNonCommentedCode' => $code->linesOfCode - $code->linesOfComments, - 'classCount' => count($code->classes) + count($code->traits), - 'methodCount' => 0, - 'coveredMethodCount' => 0, - 'statementCount' => 0, - 'coveredStatementCount' => 0, - 'elementCount' => 0, - 'coveredElementCount' => 0, - 'conditionalCount' => 0, - 'coveredConditionalCount' => 0, - ]; - - foreach (array_merge($code->classes, $code->traits) as $name => $info) { // TODO: interfaces? - $elClass = $elFile->appendChild($doc->createElement('class')); - if (($tmp = strrpos($name, '\\')) === false) { - $elClass->setAttribute('name', $name); - } else { - $elClass->setAttribute('namespace', substr($name, 0, $tmp)); - $elClass->setAttribute('name', substr($name, $tmp + 1)); - } - - $elClassMetrics = $elClass->appendChild($doc->createElement('metrics')); - $classMetrics = $this->calculateClassMetrics($info, $coverageData); - self::setMetricAttributes($elClassMetrics, $classMetrics); - self::appendMetrics($fileMetrics, $classMetrics); - } - self::setMetricAttributes($elFileMetrics, $fileMetrics); - - - foreach ((array) $coverageData as $line => $count) { - if ($count === self::CODE_DEAD) { - continue; - } - - // Line type can be 'method' but Xdebug does not report such lines as executed. - $elLine = $elFile->appendChild($doc->createElement('line')); - $elLine->setAttribute('num', (string) $line); - $elLine->setAttribute('type', 'stmt'); - $elLine->setAttribute('count', (string) max(0, $count)); - - $this->totalSum++; - $this->coveredSum += $count > 0 ? 1 : 0; - } - - self::appendMetrics($projectMetrics, $fileMetrics); - } - - // TODO: What about reported (covered) lines outside of class/trait definition? - self::setMetricAttributes($elProjectMetrics, $projectMetrics); - - echo $doc->saveXML(); - } - - - private function calculateClassMetrics(\stdClass $info, array $coverageData = null): \stdClass - { - $stats = (object) [ - 'methodCount' => count($info->methods), - 'coveredMethodCount' => 0, - 'statementCount' => 0, - 'coveredStatementCount' => 0, - 'conditionalCount' => 0, - 'coveredConditionalCount' => 0, - 'elementCount' => null, - 'coveredElementCount' => null, - ]; - - foreach ($info->methods as $name => $methodInfo) { - [$lineCount, $coveredLineCount] = $this->analyzeMethod($methodInfo, $coverageData); - - $stats->statementCount += $lineCount; - - if ($coverageData !== null) { - $stats->coveredMethodCount += $lineCount === $coveredLineCount ? 1 : 0; - $stats->coveredStatementCount += $coveredLineCount; - } - } - - $stats->elementCount = $stats->methodCount + $stats->statementCount; - $stats->coveredElementCount = $stats->coveredMethodCount + $stats->coveredStatementCount; - - return $stats; - } - - - private static function analyzeMethod(\stdClass $info, array $coverageData = null): array - { - $count = 0; - $coveredCount = 0; - - if ($coverageData === null) { // Never loaded file - $count = max(1, $info->end - $info->start - 2); - } else { - for ($i = $info->start; $i <= $info->end; $i++) { - if (isset($coverageData[$i]) && $coverageData[$i] !== self::CODE_DEAD) { - $count++; - if ($coverageData[$i] > 0) { - $coveredCount++; - } - } - } - } - - return [$count, $coveredCount]; - } - - - private static function appendMetrics(\stdClass $summary, \stdClass $add): void - { - foreach ($add as $name => $value) { - $summary->{$name} += $value; - } - } - - - private static function setMetricAttributes(DOMElement $element, \stdClass $metrics): void - { - foreach ($metrics as $name => $value) { - $element->setAttribute(self::$metricAttributesMap[$name], (string) $value); - } - } -} diff --git a/vendor/nette/tester/src/CodeCoverage/Generators/HtmlGenerator.php b/vendor/nette/tester/src/CodeCoverage/Generators/HtmlGenerator.php deleted file mode 100644 index e9117efd6cbe024d0bc413d9a213d5f26cf5aa75..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/CodeCoverage/Generators/HtmlGenerator.php +++ /dev/null @@ -1,110 +0,0 @@ -<?php - -/** - * This file is part of the Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -namespace Tester\CodeCoverage\Generators; - -use Tester\Helpers; - - -/** - * Code coverage report generator. - */ -class HtmlGenerator extends AbstractGenerator -{ - private const CLASSES = [ - self::CODE_TESTED => 't', // tested - self::CODE_UNTESTED => 'u', // untested - self::CODE_DEAD => 'dead', // dead code - ]; - - /** @var string */ - private $title; - - /** @var array */ - private $files = []; - - - /** - * @param string $file path to coverage.dat file - * @param array $sources files/directories - */ - public function __construct(string $file, array $sources = [], string $title = null) - { - parent::__construct($file, $sources); - $this->title = $title; - } - - - protected function renderSelf(): void - { - $this->setupHighlight(); - $this->parse(); - - $title = $this->title; - $classes = self::CLASSES; - $files = $this->files; - $coveredPercent = $this->getCoveredPercent(); - - include __DIR__ . '/template.phtml'; - } - - - private function setupHighlight(): void - { - ini_set('highlight.comment', 'hc'); - ini_set('highlight.default', 'hd'); - ini_set('highlight.html', 'hh'); - ini_set('highlight.keyword', 'hk'); - ini_set('highlight.string', 'hs'); - } - - - private function parse(): void - { - if (count($this->files) > 0) { - return; - } - - $this->files = []; - $commonSourcesPath = Helpers::findCommonDirectory($this->sources) . DIRECTORY_SEPARATOR; - foreach ($this->getSourceIterator() as $entry) { - $entry = (string) $entry; - - $coverage = $covered = $total = 0; - $loaded = !empty($this->data[$entry]); - $lines = []; - if ($loaded) { - $lines = $this->data[$entry]; - foreach ($lines as $flag) { - if ($flag >= self::CODE_UNTESTED) { - $total++; - } - if ($flag >= self::CODE_TESTED) { - $covered++; - } - } - $coverage = round($covered * 100 / $total); - $this->totalSum += $total; - $this->coveredSum += $covered; - } else { - $this->totalSum += count(file($entry, FILE_SKIP_EMPTY_LINES)); - } - - $light = $total ? $total < 5 : count(file($entry)) < 50; - $this->files[] = (object) [ - 'name' => str_replace($commonSourcesPath, '', $entry), - 'file' => $entry, - 'lines' => $lines, - 'coverage' => $coverage, - 'total' => $total, - 'class' => $light ? 'light' : ($loaded ? null : 'not-loaded'), - ]; - } - } -} diff --git a/vendor/nette/tester/src/CodeCoverage/Generators/template.phtml b/vendor/nette/tester/src/CodeCoverage/Generators/template.phtml deleted file mode 100644 index 128ff08cc822df580934e5acb8a73bb50aa94919..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/CodeCoverage/Generators/template.phtml +++ /dev/null @@ -1,568 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <meta charset="utf-8"> - <meta name="robots" content="noindex,noarchive"> - <meta name="generator" content="Nette Tester"> - - <title><?= $title ? htmlspecialchars("$title - ") : ''; ?>Code coverage</title> - - <style type="text/css"> - html { - font: 14px/1.5 Verdana,"Geneva CE",lucida,sans-serif; - border-top: 7.7em solid #f4ebdb; - } - - body { - max-width: 990px; - margin: -7.7em auto 0; - background: #fcfaf5; - color: #333; - } - - footer { - margin-left: .5em; - } - - h1 { - font-family: "Trebuchet MS","Geneva CE",lucida,sans-serif; - font-size: 1.9em; - margin: .5em; - color: #7a7772; - text-shadow: 1px 1px 0 white; - } - - h1 small { - font-size: 60%; - } - - div.code { - background: white; - border: 1px dotted silver; - padding: .4em 0; - display: none; - color: #333; - overflow: auto; - } - - code, - div.code { - font: 13px/1.3 monospace; - } - - div.code > div { - float: left; - min-width: 100%; - position: relative; - } - - aside { - min-width: 100%; - position: absolute; - } - - aside div { - white-space: pre; - padding-left: .7em; - } - - aside a { - color: #c0c0c0; - display: block; - } - - aside a:hover { - color: inherit; - font-weight: bold; - text-decoration: none; - } - - code { - display: block; - white-space: nowrap; - position: relative; - } - - i { - font-style: normal; - } - - a { - color: #006aeb; - text-decoration: none; - } - - a:active, - a:hover { - text-decoration: underline; - } - - td { - vertical-align: middle; - } - - small { - color: gray; - } - - .number { - text-align: right; - width: 50px; - } - - .bar { - border: 1px solid #acacac; - background: #e50400; - width: 35px; - height: 1em; - } - - .bar-empty { - border: 1px solid transparent; - background: transparent; - width: 35px; - height: 1em; - } - - .bar div { - background: #1a7e1e; - height: 1em; - } - - .light td { - opacity: .5; - } - - .light td * { - color: gray; - } - - .not-loaded td * { - color: red; - } - - .t { background-color: #e0ffe0; } - .u { background-color: #ffe0e0; } - - code .hc { color: #929292; } - code .hd { color: #333; } - code .hh { color: #06B; } - code .hk { color: #e71818; } - code .hs { color: #008000; } - - .tabs { - margin-bottom: 1.5em; - } - - .tabs a { - padding: .5em 1.5em; - display: inline-block; - font-size: 17px; - } - - .tabs a.active, - .tabs a:focus, - .tabs a:hover { - background-color: #fcfaf5; - text-decoration: none; - } - - .directory { - display: none; - margin-left: 1.5rem; - } - - .directory.opened { - display: block; - } - - .toggle-dir { - color: brown; - } - - .toggle-dir:before { - content: 'βΌ '; - } - - .toggle-dir.opened:before { - content: 'β² '; - } - - .sort .up, .sort .no-sort, .sort .down { - display: inline-block; - padding-left: 5px; - color: #c9302c - } - - .sort .no-sort { - color: #ccc - } - - .sort .up, .sort .down, .sort .no-sort, - .sort.desc:hover .up, .sort.desc:hover .down, - .sort.asc .no-sort, .sort.down .no-sort, .sort.asc:hover .up, .sort:hover .no-sort { - display: none - } - - .sort:hover .up, .sort.asc .up, - .sort.desc:hover .no-sort, - .sort.asc:hover .down, .sort.desc .down { - display: inline-block - } - </style> -</head> - -<body> - -<?php - -function assignArrayByPath(&$arr, $info, $value) { - $keys = explode(DIRECTORY_SEPARATOR, $info->name); - - $currentFile = ''; - foreach ($keys as $key) { - $currentFile = $currentFile . ($currentFile !== '' ? DIRECTORY_SEPARATOR : '') . $key; - $arr = &$arr['files'][$key]; - - if (!isset($arr['name'])) { - $arr['name'] = $currentFile; - } - $arr['count'] = isset($arr['count']) ? $arr['count'] + 1 : 1; - $arr['coverage'] = isset($arr['coverage']) ? $arr['coverage'] + $info->coverage : $info->coverage; - } - $arr = $value; -} - -$jsonData = []; -$directories = []; -$allLinesCount = 0; -foreach ($files as $id => $info) { - $code = file_get_contents($info->file); - $lineCount = substr_count($code, "\n") + 1; - $digits = ceil(log10($lineCount)) + 1; - - $allLinesCount += $lineCount; - - $currentId = "F{$id}"; - assignArrayByPath($directories, $info, $currentId); - - $data = (array) $info; - $data['digits'] = $digits; - $data['lineCount'] = $lineCount; - $data['content'] = strtr(highlight_string($code, true), [ - '<code>' => "<code style='margin-left: {$digits}em'>", - '<span style="color: ' => '<i class="', - '</span>' => '</i>', - '<br />' => '<br>', - ]); - $jsonData[$currentId] = $data; -} ?> - -<h1> - <?= $title ? htmlspecialchars("$title - ") : ''; ?>Code coverage <?= round($coveredPercent) ?> % - <small>sources have <?= number_format($allLinesCount) ?> lines of code in <?= number_format(count($files)) ?> files</small> -</h1> - -<nav class="tabs"> - <a href="#list" class="tab-item active">List</a> - <a href="#tree" class="tab-item">Tree</a> -</nav> - -<div class="tabs-content"> - <div id="list" class="tab-content"> - <table> - <tbody> - <tr> - <td class="number"> - <a href="#" class="sort desc" data-sort="coverage"><span class="up">β</span><span class="down">β</span><span class="no-sort"> </span>%</a> - </td> - <td> - <div class="bar-empty"></div> - </td> - <td> - <a href="#" class="sort" data-sort="path">path<span class="up">β</span><span class="down">β</span><span class="no-sort"> </span></a> - </td> - </tr> - </tbody> - </table> - <div id="files-content"></div> - </div> - <div id="tree" class="tab-content" style="display: none"></div> -</div> - -<footer> - <p>Generated by <a href="https://tester.nette.org">Nette Tester</a> at <?= @date('Y/m/d H:i:s') // @ timezone may not be set ?></p> -</footer> - -<script> - (function() { - let _files = <?= json_encode($jsonData) ?>; - let _directories = <?= json_encode($directories) ?>; - let isFilesInitialized = false; - let isDirectoriesInitialized = false; - - let sort = 'coverage'; - let desc = true; - let classes = { - '1': 't', // tested - '-1': 'u', // untested - '-2': 'dead', // dead code - }; - - function getSortedKeys() { - switch (sort) { - case 'coverage': - let sortedFiles = []; - for (let i in _files) { - sortedFiles.push([i, _files[i].coverage]); - } - - sortedFiles.sort(function(a, b) { - return desc ? (b[1] - a[1]) : (a[1] - b[1]); - }); - - let filesByCoverage = []; - for (let i = 0; i < sortedFiles.length; i++) { - filesByCoverage.push(sortedFiles[i][0]); - } - return filesByCoverage; - - case 'path': - return sortAlphabetically(_files, desc); - - default: - return Object.keys(_files).sort((a, b) => desc ? (b-a) : (a-b)); - } - } - - function sortAlphabetically(obj, isDesc) { - let sorted = []; - for (let i in obj) { - sorted.push([i, obj[i].name]); - } - - sorted.sort(function(a, b) { - let compared = a[1].localeCompare(b[1]); - return compared === -1 ? (isDesc ? 1 : -1) : (compared === 1 ? (isDesc ? -1 : 1) : 0); - }); - - let out = []; - for (let i = 0; i < sorted.length; i++) { - out.push(sorted[i][0]); - } - return out; - } - - function initDirectories() { - if (isDirectoriesInitialized) { - return; - } - let el = document.getElementById('tree'); - el.innerHTML = createDirectory(_directories.files); - isDirectoriesInitialized = true; - } - - function createDirectory(directory) { - let out = ''; - Object.keys(directory).sort(function(a, b) { - let aIsFile = a.endsWith('.php'); - let bIsFile = b.endsWith('.php'); - if ((aIsFile || bIsFile) && !(aIsFile && bIsFile)) { - return aIsFile ? 1 : -1; - } - let compared = a.localeCompare(b); - return compared === -1 ? -1 : (compared === 1 ? 1 : 0); - }).forEach(function(i) { - let dir = directory[i]; - let id, coverage; - let isFile = typeof dir === 'string'; - if (isFile) { - id = dir; - dir = _files[dir]; - coverage = dir.coverage; - } else { - id = null; - coverage = dir.count === 0 ? 0 : Math.round(dir.coverage / dir.count); - } - - let html = createFileInfo(isFile ? ('D' + id) : dir.name, { - coverage: coverage, - name: isFile ? i : (i + ' <small>(' + dir.count + ')</small>'), - class: isFile ? dir.class : 'dir', - }, isFile ? 'toggle' : 'toggle-dir'); - - if (isFile) { - html += '<div class="code" id="D' + id + '"></div>'; - } else { - html += '<div class="directory" id="' + dir.name + '">' + createDirectory(dir.files) + '</div>'; - } - - out += '<div>' + html + '</div>'; - }); - return out; - } - - function initFiles(force) { - if (!force && isFilesInitialized) { - return; - } - let filesEl = document.getElementById('files-content'); - filesEl.innerHTML = ''; - - getSortedKeys().forEach(function(i) { - let file = _files[i]; - let html = createFileInfo(i, file); - - html += '<div class="code" id="' + i + '"></div>'; - - let wrapper = document.createElement('div'); - wrapper.innerHTML = html; - filesEl.appendChild(wrapper); - }); - isFilesInitialized = true; - } - - function createFileInfo(id, file, toggleClass) { - toggleClass = toggleClass || 'toggle'; - return '<table>' + - '<tbody><tr' + (file.class ? (' class="' + file.class + '"') : '') + '>' + - '<td class="number"><small>' + file.coverage + ' %</small></td>' + - '<td><div class="bar"><div style="width: ' + file.coverage + '%"></div></div></td>' + - '<td><a href="#' + id + '" class="' + toggleClass + '">' + file.name + '</a></td>' + - '</tr>' + - '</tbody></table>'; - } - - function initFileContent(el) { - if (el.hasAttribute('data-initialized')) { - return; - } - - let id = el.getAttribute('id'); - id = id.startsWith('D') ? id.split('D')[1] : id; - let file = _files[id]; - if (!file) { - return; - } - - let aside = ''; - let prevClass = null; - let closeTag = '', buffer = ''; - for (let i = 1; i < file.lineCount; i++) { - let currentClass = file.lines[i] && classes[file.lines[i]] ? classes[file.lines[i]] : ''; - if (currentClass !== prevClass) { - aside += (buffer + closeTag); - buffer = ''; - closeTag = '</div>'; - aside += '<div' + (currentClass ? (' class="' + currentClass + '"') : '') + '>'; - } - - let currentId = id + 'L' + i; - buffer += '<a href="#' + currentId + '" id="' + currentId + '">' + ' '.repeat(file.digits - String(i).length) + i + "</a>"; - prevClass = currentClass; - } - aside += buffer + closeTag; - - el.innerHTML = '<div><aside>' + aside + '</aside>' + (file ? file.content : 'ERROR: Not available') + '</div>'; - - el.setAttribute('data-initialized', 'true'); - } - - function addClickListener(className, callback) { - document.body.addEventListener('click', function (e) { - let isParent = e.target.parentNode && e.target.parentNode.classList.contains(className); - if (isParent || e.target.classList.contains(className)) { - callback.apply(isParent ? e.target.parentNode : e.target, [e]); - } - }); - } - - addClickListener('sort', function(e) { - e.preventDefault(); - sort = this.getAttribute('data-sort'); - - let sortItems = document.getElementsByClassName('sort'); - for (let i = 0; i < sortItems.length; i++) { - if (sortItems[i] === this) { - continue; - } - sortItems[i].classList.remove('asc'); - sortItems[i].classList.remove('desc'); - } - - desc = false; - if (this.classList.contains('asc')) { - desc = true; - this.classList.remove('asc'); - this.classList.add('desc'); - } else { - this.classList.remove('desc'); - this.classList.add('asc'); - } - - initFiles(true); - }); - - addClickListener('toggle', function(e) { - e.preventDefault(); - let el = document.getElementById(this.href.split('#')[1]); - if (el.style.display === 'block') { - el.style.display = 'none'; - } else { - initFileContent(el); - el.style.display = 'block'; - } - }); - - addClickListener('toggle-dir', function(e) { - e.preventDefault(); - let el = document.getElementById(this.href.split('#')[1]); - if (el.classList.contains('opened')) { - this.classList.remove('opened'); - el.classList.remove('opened'); - } else { - this.classList.add('opened'); - el.classList.add('opened'); - } - }); - - addClickListener('tab-item', function(e) { - e.preventDefault(); - let tabs = document.getElementsByClassName('tab-content'); - for (let i = 0; i < tabs.length; i++) { - tabs[i].style.display = 'none'; - } - let tabItems = document.getElementsByClassName('tab-item'); - for (let i = 0; i < tabItems.length; i++) { - tabItems[i].classList.remove('active'); - } - this.classList.add('active'); - - let id = this.href.split('#')[1]; - if (id === 'files') { - initFiles(); - } else { - initDirectories(); - } - - let el = document.getElementById(id); - if (el.style.display === 'block') { - el.style.display = 'none'; - } else { - el.style.display = 'block'; - } - }); - - document.addEventListener("DOMContentLoaded", function(event) { - initFiles(true); - - let el = document.getElementById(window.location.hash.replace(/^#|L\d+$/g, '')); - if (el) { - initFileContent(el); - el.style.display = 'block'; - } - }); - })(); -</script> -</body> -</html> diff --git a/vendor/nette/tester/src/CodeCoverage/PhpParser.php b/vendor/nette/tester/src/CodeCoverage/PhpParser.php deleted file mode 100644 index c1e2a9e8e56c38785140335c32ba914330597914..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/CodeCoverage/PhpParser.php +++ /dev/null @@ -1,184 +0,0 @@ -<?php - -/** - * This file is part of the Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -namespace Tester\CodeCoverage; - - -/** - * Parses PHP source code and returns: - * - the start/end line information about functions, classes, interfaces, traits and their methods - * - the count of code lines - * - the count of commented code lines - * - * @internal - */ -class PhpParser -{ - /** - * Returned structure is: - * stdClass { - * linesOfCode: int, - * linesOfComments: int, - * functions: [functionName => $functionInfo], - * classes: [className => $info], - * traits: [traitName => $info], - * interfaces: [interfaceName => $info], - * } - * - * where $functionInfo is: - * stdClass { - * start: int, - * end: int - * } - * - * and $info is: - * stdClass { - * start: int, - * end: int, - * methods: [methodName => $methodInfo] - * } - * - * where $methodInfo is: - * stdClass { - * start: int, - * end: int, - * visibility: public|protected|private - * } - */ - public function parse(string $code): \stdClass - { - $tokens = token_get_all($code, TOKEN_PARSE); - - $level = $classLevel = $functionLevel = null; - $namespace = ''; - $line = 1; - - $result = (object) [ - 'linesOfCode' => max(1, substr_count($code, "\n")), - 'linesOfComments' => 0, - 'functions' => [], - 'classes' => [], - 'traits' => [], - 'interfaces' => [], - ]; - - while ($token = current($tokens)) { - next($tokens); - if (is_array($token)) { - $line = $token[2]; - } - - switch (is_array($token) ? $token[0] : $token) { - case T_NAMESPACE: - $namespace = self::fetch($tokens, [T_STRING, PHP_VERSION_ID < 80000 ? T_NS_SEPARATOR : T_NAME_QUALIFIED]); - $namespace = ltrim($namespace . '\\', '\\'); - break; - - case T_CLASS: - case T_INTERFACE: - case T_TRAIT: - if ($name = self::fetch($tokens, T_STRING)) { - if ($token[0] === T_CLASS) { - $class = &$result->classes[$namespace . $name]; - } elseif ($token[0] === T_INTERFACE) { - $class = &$result->interfaces[$namespace . $name]; - } else { - $class = &$result->traits[$namespace . $name]; - } - - $classLevel = $level + 1; - $class = (object) [ - 'start' => $line, - 'end' => null, - 'methods' => [], - ]; - } - break; - - case T_PUBLIC: - case T_PROTECTED: - case T_PRIVATE: - $visibility = $token[1]; - break; - - case T_ABSTRACT: - $isAbstract = true; - break; - - case T_FUNCTION: - if (($name = self::fetch($tokens, T_STRING)) && !isset($isAbstract)) { - if (isset($class) && $level === $classLevel) { - $function = &$class->methods[$name]; - $function = (object) [ - 'start' => $line, - 'end' => null, - 'visibility' => $visibility ?? 'public', - ]; - - } else { - $function = &$result->functions[$namespace . $name]; - $function = (object) [ - 'start' => $line, - 'end' => null, - ]; - } - $functionLevel = $level + 1; - } - unset($visibility, $isAbstract); - break; - - case T_CURLY_OPEN: - case T_DOLLAR_OPEN_CURLY_BRACES: - case '{': - $level++; - break; - - case '}': - if (isset($function) && $level === $functionLevel) { - $function->end = $line; - unset($function); - - } elseif (isset($class) && $level === $classLevel) { - $class->end = $line; - unset($class); - } - $level--; - break; - - case T_COMMENT: - case T_DOC_COMMENT: - $result->linesOfComments += substr_count(trim($token[1]), "\n") + 1; - // break omitted - - case T_WHITESPACE: - case T_CONSTANT_ENCAPSED_STRING: - $line += substr_count($token[1], "\n"); - break; - } - } - - return $result; - } - - - private static function fetch(array &$tokens, $take): ?string - { - $res = null; - while ($token = current($tokens)) { - [$token, $s] = is_array($token) ? $token : [$token, $token]; - if (in_array($token, (array) $take, true)) { - $res .= $s; - } elseif (!in_array($token, [T_DOC_COMMENT, T_WHITESPACE, T_COMMENT], true)) { - break; - } - next($tokens); - } - return $res; - } -} diff --git a/vendor/nette/tester/src/Framework/Assert.php b/vendor/nette/tester/src/Framework/Assert.php deleted file mode 100644 index 17b30e7b6d8d6779f4f6a2e05f8b8293ad2255a2..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/Framework/Assert.php +++ /dev/null @@ -1,683 +0,0 @@ -<?php - -/** - * This file is part of the Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -namespace Tester; - - -/** - * Assertion test helpers. - */ -class Assert -{ - /** used by equal() for comparing floats */ - private const EPSILON = 1e-10; - - /** used by match(); in values, each $ followed by number is backreference */ - public static $patterns = [ - '%%' => '%', // one % character - '%a%' => '[^\r\n]+', // one or more of anything except the end of line characters - '%a\?%' => '[^\r\n]*', // zero or more of anything except the end of line characters - '%A%' => '.+', // one or more of anything including the end of line characters - '%A\?%' => '.*', // zero or more of anything including the end of line characters - '%s%' => '[\t ]+', // one or more white space characters except the end of line characters - '%s\?%' => '[\t ]*', // zero or more white space characters except the end of line characters - '%S%' => '\S+', // one or more of characters except the white space - '%S\?%' => '\S*', // zero or more of characters except the white space - '%c%' => '[^\r\n]', // a single character of any sort (except the end of line) - '%d%' => '[0-9]+', // one or more digits - '%d\?%' => '[0-9]*', // zero or more digits - '%i%' => '[+-]?[0-9]+', // signed integer value - '%f%' => '[+-]?\.?\d+\.?\d*(?:[Ee][+-]?\d+)?', // floating point number - '%h%' => '[0-9a-fA-F]+', // one or more HEX digits - '%w%' => '[0-9a-zA-Z_]+', //one or more alphanumeric characters - '%ds%' => '[\\\\/]', // directory separator - '%(\[.+\][+*?{},\d]*)%' => '$1', // range - ]; - - /** @var bool expand patterns in match() and matchFile() */ - public static $expandPatterns = true; - - /** @var callable function (AssertException $exception): void */ - public static $onFailure; - - /** @var int the count of assertions */ - public static $counter = 0; - - - /** - * Asserts that two values are equal and have the same type and identity of objects. - */ - public static function same($expected, $actual, string $description = null): void - { - self::$counter++; - if ($actual !== $expected) { - self::fail(self::describe('%1 should be %2', $description), $actual, $expected); - } - } - - - /** - * Asserts that two values are not equal or do not have the same type and identity of objects. - */ - public static function notSame($expected, $actual, string $description = null): void - { - self::$counter++; - if ($actual === $expected) { - self::fail(self::describe('%1 should not be %2', $description), $actual, $expected); - } - } - - - /** - * Asserts that two values are equal and checks expectations. The identity of objects, - * the order of keys in the arrays and marginally different floats are ignored. - */ - public static function equal($expected, $actual, string $description = null): void - { - self::$counter++; - if (!self::isEqual($expected, $actual)) { - self::fail(self::describe('%1 should be equal to %2', $description), $actual, $expected); - } - } - - - /** - * Asserts that two values are not equal and checks expectations. The identity of objects, - * the order of keys in the arrays and marginally different floats are ignored. - */ - public static function notEqual($expected, $actual, string $description = null): void - { - self::$counter++; - try { - $res = self::isEqual($expected, $actual); - } catch (AssertException $e) { - } - if (empty($e) && $res) { - self::fail(self::describe('%1 should not be equal to %2', $description), $actual, $expected); - } - } - - - /** - * Asserts that a haystack (string or array) contains an expected needle. - * @param mixed $needle - * @param array|string $actual - */ - public static function contains($needle, $actual, string $description = null): void - { - self::$counter++; - if (is_array($actual)) { - if (!in_array($needle, $actual, true)) { - self::fail(self::describe('%1 should contain %2', $description), $actual, $needle); - } - } elseif (is_string($actual)) { - if (!is_string($needle)) { - self::fail(self::describe('Needle %1 should be string'), $needle); - - } elseif ($needle !== '' && strpos($actual, $needle) === false) { - self::fail(self::describe('%1 should contain %2', $description), $actual, $needle); - } - } else { - self::fail(self::describe('%1 should be string or array', $description), $actual); - } - } - - - /** - * Asserts that a haystack (string or array) does not contain an expected needle. - * @param mixed $needle - * @param array|string $actual - */ - public static function notContains($needle, $actual, string $description = null): void - { - self::$counter++; - if (is_array($actual)) { - if (in_array($needle, $actual, true)) { - self::fail(self::describe('%1 should not contain %2', $description), $actual, $needle); - } - } elseif (is_string($actual)) { - if (!is_string($needle)) { - self::fail(self::describe('Needle %1 should be string'), $needle); - - } elseif ($needle === '' || strpos($actual, $needle) !== false) { - self::fail(self::describe('%1 should not contain %2', $description), $actual, $needle); - } - } else { - self::fail(self::describe('%1 should be string or array', $description), $actual); - } - } - - - /** - * Asserts that a haystack has an expected key. - * @param string|int $key - */ - public static function hasKey($key, array $actual, string $description = null): void - { - self::$counter++; - if (!is_int($key) && !is_string($key)) { - self::fail(self::describe('Key %1 should be string or integer'), $key); - - } elseif (!array_key_exists($key, $actual)) { - self::fail(self::describe('%1 should contain key %2', $description), $actual, $key); - } - } - - - /** - * Asserts that a haystack doesn't have an expected key. - * @param string|int $key - */ - public static function hasNotKey($key, array $actual, string $description = null): void - { - self::$counter++; - if (!is_int($key) && !is_string($key)) { - self::fail(self::describe('Key %1 should be string or integer'), $key); - - } elseif (array_key_exists($key, $actual)) { - self::fail(self::describe('%1 should not contain key %2', $description), $actual, $key); - } - } - - - /** - * Asserts that a value is true. - * @param mixed $actual - */ - public static function true($actual, string $description = null): void - { - self::$counter++; - if ($actual !== true) { - self::fail(self::describe('%1 should be TRUE', $description), $actual); - } - } - - - /** - * Asserts that a value is false. - * @param mixed $actual - */ - public static function false($actual, string $description = null): void - { - self::$counter++; - if ($actual !== false) { - self::fail(self::describe('%1 should be FALSE', $description), $actual); - } - } - - - /** - * Asserts that a value is null. - * @param mixed $actual - */ - public static function null($actual, string $description = null): void - { - self::$counter++; - if ($actual !== null) { - self::fail(self::describe('%1 should be NULL', $description), $actual); - } - } - - - /** - * Asserts that a value is not null. - * @param mixed $actual - */ - public static function notNull($actual, string $description = null): void - { - self::$counter++; - if ($actual === null) { - self::fail(self::describe('Value should not be NULL', $description)); - } - } - - - /** - * Asserts that a value is Not a Number. - * @param mixed $actual - */ - public static function nan($actual, string $description = null): void - { - self::$counter++; - if (!is_float($actual) || !is_nan($actual)) { - self::fail(self::describe('%1 should be NAN', $description), $actual); - } - } - - - /** - * Asserts that a value is truthy. - * @param mixed $actual - */ - public static function truthy($actual, string $description = null): void - { - self::$counter++; - if (!$actual) { - self::fail(self::describe('%1 should be truthy', $description), $actual); - } - } - - - /** - * Asserts that a value is falsey. - * @param mixed $actual - */ - public static function falsey($actual, string $description = null): void - { - self::$counter++; - if ($actual) { - self::fail(self::describe('%1 should be falsey', $description), $actual); - } - } - - - /** - * Asserts the number of items in an array or Countable. - * @param array|\Countable $value - */ - public static function count(int $count, $value, string $description = null): void - { - self::$counter++; - if (!$value instanceof \Countable && !is_array($value)) { - self::fail(self::describe('%1 should be array or countable object', $description), $value); - - } elseif (count($value) !== $count) { - self::fail(self::describe('Count %1 should be %2', $description), count($value), $count); - } - } - - - /** - * Asserts that a value is of given class, interface or built-in type. - * @param string|object $type - * @param mixed $value - */ - public static function type($type, $value, string $description = null): void - { - self::$counter++; - if (!is_object($type) && !is_string($type)) { - throw new \Exception('Type must be a object or a string.'); - - } elseif ($type === 'list') { - if (!is_array($value) || ($value && array_keys($value) !== range(0, count($value) - 1))) { - self::fail(self::describe("%1 should be $type", $description), $value); - } - - } elseif (in_array($type, ['array', 'bool', 'callable', 'float', - 'int', 'integer', 'null', 'object', 'resource', 'scalar', 'string', ], true) - ) { - if (!("is_$type")($value)) { - self::fail(self::describe(gettype($value) . " should be $type", $description)); - } - - } elseif (!$value instanceof $type) { - $actual = is_object($value) ? get_class($value) : gettype($value); - $type = is_object($type) ? get_class($type) : $type; - self::fail(self::describe("$actual should be instance of $type", $description)); - } - } - - - /** - * Asserts that a function throws exception of given type and its message matches given pattern. - */ - public static function exception( - callable $function, - string $class, - string $message = null, - $code = null - ): ?\Throwable { - self::$counter++; - $e = null; - try { - $function(); - } catch (\Throwable $e) { - } - if ($e === null) { - self::fail("$class was expected, but none was thrown"); - - } elseif (!$e instanceof $class) { - self::fail("$class was expected but got " . get_class($e) . ($e->getMessage() ? " ({$e->getMessage()})" : ''), null, null, $e); - - } elseif ($message && !self::isMatching($message, $e->getMessage())) { - self::fail("$class with a message matching %2 was expected but got %1", $e->getMessage(), $message); - - } elseif ($code !== null && $e->getCode() !== $code) { - self::fail("$class with a code %2 was expected but got %1", $e->getCode(), $code); - } - return $e; - } - - - /** - * Asserts that a function throws exception of given type and its message matches given pattern. Alias for exception(). - */ - public static function throws(callable $function, string $class, string $message = null, $code = null): ?\Throwable - { - return self::exception($function, $class, $message, $code); - } - - - /** - * Asserts that a function generates one or more PHP errors or throws exceptions. - * @param int|string|array $expectedType - * @param string $expectedMessage message - * @throws \Exception - * @throws \Exception - */ - public static function error(callable $function, $expectedType, string $expectedMessage = null): ?\Throwable - { - if (is_string($expectedType) && !preg_match('#^E_[A-Z_]+$#D', $expectedType)) { - return static::exception($function, $expectedType, $expectedMessage); - } - - self::$counter++; - $expected = is_array($expectedType) ? $expectedType : [[$expectedType, $expectedMessage]]; - foreach ($expected as &$item) { - $item = ((array) $item) + [null, null]; - $expectedType = $item[0]; - if (is_int($expectedType)) { - $item[2] = Helpers::errorTypeToString($expectedType); - } elseif (is_string($expectedType)) { - $item[0] = constant($item[2] = $expectedType); - } else { - throw new \Exception('Error type must be E_* constant.'); - } - } - - set_error_handler(function (int $severity, string $message, string $file, int $line) use (&$expected) { - if (($severity & error_reporting()) !== $severity) { - return; - } - - $errorStr = Helpers::errorTypeToString($severity) . ($message ? " ($message)" : ''); - [$expectedType, $expectedMessage, $expectedTypeStr] = array_shift($expected); - if ($expectedType === null) { - self::fail("Generated more errors than expected: $errorStr was generated in file $file on line $line"); - - } elseif ($severity !== $expectedType) { - self::fail("$expectedTypeStr was expected, but $errorStr was generated in file $file on line $line"); - - } elseif ($expectedMessage && !self::isMatching($expectedMessage, $message)) { - self::fail("$expectedTypeStr with a message matching %2 was expected but got %1", $message, $expectedMessage); - } - }); - - reset($expected); - try { - $function(); - restore_error_handler(); - } catch (\Exception $e) { - restore_error_handler(); - throw $e; - } - - if ($expected) { - self::fail('Error was expected, but was not generated'); - } - return null; - } - - - /** - * Asserts that a function does not generate PHP errors and does not throw exceptions. - */ - public static function noError(callable $function): void - { - if (($count = func_num_args()) > 1) { - throw new \Exception(__METHOD__ . "() expects 1 parameter, $count given."); - } - self::error($function, []); - } - - - /** - * Asserts that a string matches a given pattern. - * %a% one or more of anything except the end of line characters - * %a?% zero or more of anything except the end of line characters - * %A% one or more of anything including the end of line characters - * %A?% zero or more of anything including the end of line characters - * %s% one or more white space characters except the end of line characters - * %s?% zero or more white space characters except the end of line characters - * %S% one or more of characters except the white space - * %S?% zero or more of characters except the white space - * %c% a single character of any sort (except the end of line) - * %d% one or more digits - * %d?% zero or more digits - * %i% signed integer value - * %f% floating point number - * %h% one or more HEX digits - * @param string $pattern mask|regexp; only delimiters ~ and # are supported for regexp - */ - public static function match(string $pattern, $actual, string $description = null): void - { - self::$counter++; - if (!is_scalar($actual)) { - self::fail(self::describe('%1 should match %2', $description), $actual, $pattern); - - } elseif (!self::isMatching($pattern, $actual)) { - if (self::$expandPatterns) { - [$pattern, $actual] = self::expandMatchingPatterns($pattern, $actual); - } - self::fail(self::describe('%1 should match %2', $description), $actual, $pattern); - } - } - - - /** - * Asserts that a string matches a given pattern stored in file. - */ - public static function matchFile(string $file, $actual, string $description = null): void - { - self::$counter++; - $pattern = @file_get_contents($file); // @ is escalated to exception - if ($pattern === false) { - throw new \Exception("Unable to read file '$file'."); - - } elseif (!is_scalar($actual)) { - self::fail(self::describe('%1 should match %2', $description), $actual, $pattern); - - } elseif (!self::isMatching($pattern, $actual)) { - if (self::$expandPatterns) { - [$pattern, $actual] = self::expandMatchingPatterns($pattern, $actual); - } - self::fail(self::describe('%1 should match %2', $description), $actual, $pattern); - } - } - - - /** - * Assertion that fails. - */ - public static function fail(string $message, $actual = null, $expected = null, \Throwable $previous = null): void - { - $e = new AssertException($message, $expected, $actual, $previous); - if (self::$onFailure) { - (self::$onFailure)($e); - } else { - throw $e; - } - } - - - private static function describe(string $reason, string $description = null): string - { - return ($description ? $description . ': ' : '') . $reason; - } - - - /** - * Executes function that can access private and protected members of given object via $this. - * @param object|string $obj - */ - public static function with($objectOrClass, \Closure $closure) - { - return $closure->bindTo(is_object($objectOrClass) ? $objectOrClass : null, $objectOrClass)(); - } - - - /********************* helpers ****************d*g**/ - - - /** - * Compares using mask. - * @internal - */ - public static function isMatching(string $pattern, $actual, bool $strict = false): bool - { - if (!is_scalar($actual)) { - throw new \Exception('Value must be strings.'); - } - - $old = ini_set('pcre.backtrack_limit', '10000000'); - - if (!self::isPcre($pattern)) { - $utf8 = preg_match('#\x80-\x{10FFFF}]#u', $pattern) ? 'u' : ''; - $suffix = ($strict ? '$#DsU' : '\s*$#sU') . $utf8; - $patterns = static::$patterns + [ - '[.\\\\+*?[^$(){|\#]' => '\$0', // preg quoting - '\x00' => '\x00', - '[\t ]*\r?\n' => '[\t ]*\r?\n', // right trim - ]; - $pattern = '#^' . preg_replace_callback('#' . implode('|', array_keys($patterns)) . '#U' . $utf8, function ($m) use ($patterns) { - foreach ($patterns as $re => $replacement) { - $s = preg_replace("#^$re$#D", str_replace('\\', '\\\\', $replacement), $m[0], 1, $count); - if ($count) { - return $s; - } - } - }, rtrim($pattern, " \t\n\r")) . $suffix; - } - - $res = preg_match($pattern, (string) $actual); - ini_set('pcre.backtrack_limit', $old); - if ($res === false || preg_last_error()) { - throw new \Exception('Error while executing regular expression. (PREG Error Code ' . preg_last_error() . ')'); - } - return (bool) $res; - } - - - /** - * @internal - */ - public static function expandMatchingPatterns(string $pattern, $actual): array - { - if (self::isPcre($pattern)) { - return [$pattern, $actual]; - } - - $parts = preg_split('#(%)#', $pattern, -1, PREG_SPLIT_DELIM_CAPTURE); - for ($i = count($parts); $i >= 0; $i--) { - $patternX = implode(array_slice($parts, 0, $i)); - $patternY = "$patternX%A?%"; - if (self::isMatching($patternY, $actual)) { - $patternZ = implode(array_slice($parts, $i)); - break; - } - } - - foreach (['%A%', '%A?%'] as $greedyPattern) { - if (substr($patternX, -strlen($greedyPattern)) === $greedyPattern) { - $patternX = substr($patternX, 0, -strlen($greedyPattern)); - $patternY = "$patternX%A?%"; - $patternZ = $greedyPattern . $patternZ; - break; - } - } - - $low = 0; - $high = strlen($actual); - while ($low <= $high) { - $mid = ($low + $high) >> 1; - if (self::isMatching($patternY, substr($actual, 0, $mid))) { - $high = $mid - 1; - } else { - $low = $mid + 1; - } - } - - $low = $high + 2; - $high = strlen($actual); - while ($low <= $high) { - $mid = ($low + $high) >> 1; - if (!self::isMatching($patternX, substr($actual, 0, $mid), true)) { - $high = $mid - 1; - } else { - $low = $mid + 1; - } - } - - $actualX = substr($actual, 0, $high); - $actualZ = substr($actual, $high); - - return [ - $actualX . rtrim(preg_replace('#[\t ]*\r?\n#', "\n", $patternZ)), - $actualX . rtrim(preg_replace('#[\t ]*\r?\n#', "\n", $actualZ)), - ]; - } - - - /** - * Compares two structures and checks expectations. The identity of objects, the order of keys - * in the arrays and marginally different floats are ignored. - */ - private static function isEqual($expected, $actual, int $level = 0, $objects = null): bool - { - switch (true) { - case $level > 10: - throw new \Exception('Nesting level too deep or recursive dependency.'); - - case $expected instanceof Expect: - $expected($actual); - return true; - - case is_float($expected) && is_float($actual) && is_finite($expected) && is_finite($actual): - $diff = abs($expected - $actual); - return ($diff < self::EPSILON) || ($diff / max(abs($expected), abs($actual)) < self::EPSILON); - - case is_object($expected) && is_object($actual) && get_class($expected) === get_class($actual): - $objects = $objects ? clone $objects : new \SplObjectStorage; - if (isset($objects[$expected])) { - return $objects[$expected] === $actual; - } elseif ($expected === $actual) { - return true; - } - $objects[$expected] = $actual; - $objects[$actual] = $expected; - $expected = (array) $expected; - $actual = (array) $actual; - // break omitted - - case is_array($expected) && is_array($actual): - ksort($expected, SORT_STRING); - ksort($actual, SORT_STRING); - if (array_keys($expected) !== array_keys($actual)) { - return false; - } - - foreach ($expected as $value) { - if (!self::isEqual($value, current($actual), $level + 1, $objects)) { - return false; - } - next($actual); - } - return true; - - default: - return $expected === $actual; - } - } - - - private static function isPcre(string $pattern): bool - { - return (bool) preg_match('/^([~#]).+(\1)[imsxUu]*$/Ds', $pattern); - } -} diff --git a/vendor/nette/tester/src/Framework/AssertException.php b/vendor/nette/tester/src/Framework/AssertException.php deleted file mode 100644 index 8bb7b4118f97f6071951769fe9fc578144f7adce..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/Framework/AssertException.php +++ /dev/null @@ -1,43 +0,0 @@ -<?php - -/** - * This file is part of the Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -namespace Tester; - - -/** - * Assertion exception. - */ -class AssertException extends \Exception -{ - public $origMessage; - - public $actual; - - public $expected; - - - public function __construct(string $message, $expected, $actual, \Throwable $previous = null) - { - parent::__construct('', 0, $previous); - $this->expected = $expected; - $this->actual = $actual; - $this->setMessage($message); - } - - - public function setMessage(string $message): self - { - $this->origMessage = $message; - $this->message = strtr($message, [ - '%1' => Dumper::toLine($this->actual), - '%2' => Dumper::toLine($this->expected), - ]); - return $this; - } -} diff --git a/vendor/nette/tester/src/Framework/DataProvider.php b/vendor/nette/tester/src/Framework/DataProvider.php deleted file mode 100644 index d5ab1383d16c34714f01fdbd01b6c65dbc35eb4f..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/Framework/DataProvider.php +++ /dev/null @@ -1,110 +0,0 @@ -<?php - -/** - * This file is part of the Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -namespace Tester; - - -/** - * Data provider helpers. - * @internal - */ -class DataProvider -{ - /** - * @throws \Exception - */ - public static function load(string $file, string $query = ''): array - { - if (!is_file($file)) { - throw new \Exception("Missing data provider file '$file'."); - } - - if (pathinfo($file, PATHINFO_EXTENSION) === 'php') { - $data = (function () { - return require func_get_arg(0); - })(realpath($file)); - - if ($data instanceof \Traversable) { - $data = iterator_to_array($data); - } elseif (!is_array($data)) { - throw new \Exception("Data provider '$file' did not return array or Traversable."); - } - - } else { - $data = @parse_ini_file($file, true); // @ is escalated to exception - if ($data === false) { - throw new \Exception("Cannot parse data provider file '$file'."); - } - } - - foreach ($data as $key => $value) { - if (!self::testQuery((string) $key, $query)) { - unset($data[$key]); - } - } - - return $data; - } - - - public static function testQuery(string $input, string $query): bool - { - static $replaces = ['' => '=', '=>' => '>=', '=<' => '<=']; - $tokens = preg_split('#\s+#', $input); - preg_match_all('#\s*,?\s*(<=|=<|<|==|=|!=|<>|>=|=>|>)?\s*([^\s,]+)#A', $query, $queryParts, PREG_SET_ORDER); - foreach ($queryParts as [, $operator, $operand]) { - $operator = $replaces[$operator] ?? $operator; - $token = (string) array_shift($tokens); - $res = preg_match('#^[0-9.]+$#D', $token) - ? version_compare($token, $operand, $operator) - : self::compare($token, $operator, $operand); - if (!$res) { - return false; - } - } - return true; - } - - - private static function compare($l, string $operator, $r): bool - { - switch ($operator) { - case '>': - return $l > $r; - case '=>': - case '>=': - return $l >= $r; - case '<': - return $l < $r; - case '=<': - case '<=': - return $l <= $r; - case '=': - case '==': - return $l == $r; - case '!': - case '!=': - case '<>': - return $l != $r; - } - throw new \InvalidArgumentException("Unknown operator $operator."); - } - - - /** - * @throws \Exception - */ - public static function parseAnnotation(string $annotation, string $file): array - { - if (!preg_match('#^(\??)\s*([^,\s]+)\s*,?\s*(\S.*)?()#', $annotation, $m)) { - throw new \Exception("Invalid @dataProvider value '$annotation'."); - } - return [dirname($file) . DIRECTORY_SEPARATOR . $m[2], $m[3], (bool) $m[1]]; - } -} diff --git a/vendor/nette/tester/src/Framework/DomQuery.php b/vendor/nette/tester/src/Framework/DomQuery.php deleted file mode 100644 index ae7ae8fca51dfd17226a51a00d164f543a67b52b..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/Framework/DomQuery.php +++ /dev/null @@ -1,136 +0,0 @@ -<?php - -/** - * This file is part of the Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -namespace Tester; - - -/** - * DomQuery simplifies querying (X)HTML documents. - */ -class DomQuery extends \SimpleXMLElement -{ - public static function fromHtml(string $html): self - { - if (strpos($html, '<') === false) { - $html = '<body>' . $html; - } - - // parse these elements as void - $html = preg_replace('#<(keygen|source|track|wbr)(?=\s|>)((?:"[^"]*"|\'[^\']*\'|[^"\'>])*+)(?<!/)>#', '<$1$2 />', $html); - - // fix parsing of </ inside scripts - $html = preg_replace_callback('#(<script(?=\s|>)(?:"[^"]*"|\'[^\']*\'|[^"\'>])*+>)(.*?)(</script>)#s', function (array $m): string { - return $m[1] . str_replace('</', '<\/', $m[2]) . $m[3]; - }, $html); - - $dom = new \DOMDocument; - $old = libxml_use_internal_errors(true); - libxml_clear_errors(); - $dom->loadHTML($html); - $errors = libxml_get_errors(); - libxml_use_internal_errors($old); - - foreach ($errors as $error) { - if (!preg_match('#Tag \S+ invalid#', $error->message)) { - trigger_error(__METHOD__ . ": $error->message on line $error->line.", E_USER_WARNING); - } - } - return simplexml_import_dom($dom, self::class); - } - - - public static function fromXml(string $xml): self - { - return simplexml_load_string($xml, self::class); - } - - - /** - * Returns array of descendants filtered by a selector. - * @return DomQuery[] - */ - public function find(string $selector): array - { - return $this->xpath(self::css2xpath($selector)); - } - - - /** - * Check the current document against a selector. - */ - public function has(string $selector): bool - { - return (bool) $this->find($selector); - } - - - /** - * Transforms CSS expression to XPath. - */ - public static function css2xpath(string $css): string - { - $xpath = '//*'; - preg_match_all('/ - ([#.:]?)([a-z][a-z0-9_-]*)| # id, class, pseudoclass (1,2) - \[ - ([a-z0-9_-]+) - (?: - ([~*^$]?)=( - "[^"]*"| - \'[^\']*\'| - [^\]]+ - ) - )? - \]| # [attr=val] (3,4,5) - \s*([>,+~])\s*| # > , + ~ (6) - (\s+)| # whitespace (7) - (\*) # * (8) - /ix', trim($css), $matches, PREG_SET_ORDER); - foreach ($matches as $m) { - if ($m[1] === '#') { // #ID - $xpath .= "[@id='$m[2]']"; - } elseif ($m[1] === '.') { // .class - $xpath .= "[contains(concat(' ', normalize-space(@class), ' '), ' $m[2] ')]"; - } elseif ($m[1] === ':') { // :pseudo-class - throw new \InvalidArgumentException('Not implemented.'); - } elseif ($m[2]) { // tag - $xpath = rtrim($xpath, '*') . $m[2]; - } elseif ($m[3]) { // [attribute] - $attr = '@' . strtolower($m[3]); - if (!isset($m[5])) { - $xpath .= "[$attr]"; - continue; - } - $val = trim($m[5], '"\''); - if ($m[4] === '') { - $xpath .= "[$attr='$val']"; - } elseif ($m[4] === '~') { - $xpath .= "[contains(concat(' ', normalize-space($attr), ' '), ' $val ')]"; - } elseif ($m[4] === '*') { - $xpath .= "[contains($attr, '$val')]"; - } elseif ($m[4] === '^') { - $xpath .= "[starts-with($attr, '$val')]"; - } elseif ($m[4] === '$') { - $xpath .= "[substring($attr, string-length($attr)-0)='$val']"; - } - } elseif ($m[6] === '>') { - $xpath .= '/*'; - } elseif ($m[6] === ',') { - $xpath .= '|//*'; - } elseif ($m[6] === '~') { - $xpath .= '/following-sibling::*'; - } elseif ($m[6] === '+') { - throw new \InvalidArgumentException('Not implemented.'); - } elseif ($m[7]) { - $xpath .= '//*'; - } - } - return $xpath; - } -} diff --git a/vendor/nette/tester/src/Framework/Dumper.php b/vendor/nette/tester/src/Framework/Dumper.php deleted file mode 100644 index abd17349af78a59c0e7336345630a1363f51925b..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/Framework/Dumper.php +++ /dev/null @@ -1,384 +0,0 @@ -<?php - -/** - * This file is part of the Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -namespace Tester; - - -/** - * Dumps PHP variables. - * @internal - */ -class Dumper -{ - public static $maxLength = 70; - - public static $maxDepth = 10; - - public static $dumpDir = 'output'; - - public static $maxPathSegments = 3; - - public static $pathSeparator; - - - /** - * Dumps information about a variable in readable format. - * @param mixed $var variable to dump - */ - public static function toLine($var): string - { - static $table; - if ($table === null) { - foreach (array_merge(range("\x00", "\x1F"), range("\x7F", "\xFF")) as $ch) { - $table[$ch] = '\x' . str_pad(dechex(ord($ch)), 2, '0', STR_PAD_LEFT); - } - $table['\\'] = '\\\\'; - $table["\r"] = '\r'; - $table["\n"] = '\n'; - $table["\t"] = '\t'; - } - - if (is_bool($var)) { - return $var ? 'TRUE' : 'FALSE'; - - } elseif ($var === null) { - return 'NULL'; - - } elseif (is_int($var)) { - return "$var"; - - } elseif (is_float($var)) { - return var_export($var, true); - - } elseif (is_string($var)) { - if (preg_match('#^(.{' . self::$maxLength . '}).#su', $var, $m)) { - $var = "$m[1]..."; - } elseif (strlen($var) > self::$maxLength) { - $var = substr($var, 0, self::$maxLength) . '...'; - } - return preg_match('#[^\x09\x0A\x0D\x20-\x7E\xA0-\x{10FFFF}]#u', $var) || preg_last_error() - ? '"' . strtr($var, $table) . '"' - : "'$var'"; - - } elseif (is_array($var)) { - $out = ''; - $counter = 0; - foreach ($var as $k => &$v) { - $out .= ($out === '' ? '' : ', '); - if (strlen($out) > self::$maxLength) { - $out .= '...'; - break; - } - $out .= ($k === $counter ? '' : self::toLine($k) . ' => ') - . (is_array($v) && $v ? '[...]' : self::toLine($v)); - $counter = is_int($k) ? max($k + 1, $counter) : $counter; - } - return "[$out]"; - - } elseif ($var instanceof \Throwable) { - return 'Exception ' . get_class($var) . ': ' . ($var->getCode() ? '#' . $var->getCode() . ' ' : '') . $var->getMessage(); - - } elseif ($var instanceof Expect) { - return $var->dump(); - - } elseif (is_object($var)) { - return self::objectToLine($var); - - } elseif (is_resource($var)) { - return 'resource(' . get_resource_type($var) . ')'; - - } else { - return 'unknown type'; - } - } - - - /** - * Formats object to line. - * @param object $object - */ - private static function objectToLine($object): string - { - $line = get_class($object); - if ($object instanceof \DateTime || $object instanceof \DateTimeInterface) { - $line .= '(' . $object->format('Y-m-d H:i:s O') . ')'; - } - - return $line . '(' . self::hash($object) . ')'; - } - - - /** - * Dumps variable in PHP format. - * @param mixed $var variable to dump - */ - public static function toPhp($var): string - { - return self::_toPhp($var); - } - - - /** - * Returns object's stripped hash. - * @param object $object - */ - private static function hash($object): string - { - return '#' . substr(md5(spl_object_hash($object)), 0, 4); - } - - - private static function _toPhp(&$var, array &$list = [], int $level = 0, int &$line = 1): string - { - if (is_float($var)) { - $var = str_replace(',', '.', "$var"); - return strpos($var, '.') === false ? $var . '.0' : $var; - - } elseif (is_bool($var)) { - return $var ? 'true' : 'false'; - - } elseif ($var === null) { - return 'null'; - - } elseif (is_string($var) && (preg_match('#[^\x09\x20-\x7E\xA0-\x{10FFFF}]#u', $var) || preg_last_error())) { - static $table; - if ($table === null) { - foreach (array_merge(range("\x00", "\x1F"), range("\x7F", "\xFF")) as $ch) { - $table[$ch] = '\x' . str_pad(dechex(ord($ch)), 2, '0', STR_PAD_LEFT); - } - $table['\\'] = '\\\\'; - $table["\r"] = '\r'; - $table["\n"] = '\n'; - $table["\t"] = '\t'; - $table['$'] = '\$'; - $table['"'] = '\"'; - } - return '"' . strtr($var, $table) . '"'; - - } elseif (is_array($var)) { - $space = str_repeat("\t", $level); - - static $marker; - if ($marker === null) { - $marker = uniqid("\x00", true); - } - if (empty($var)) { - $out = ''; - - } elseif ($level > self::$maxDepth || isset($var[$marker])) { - return '/* Nesting level too deep or recursive dependency */'; - - } else { - $out = "\n$space"; - $outShort = ''; - $var[$marker] = true; - $oldLine = $line; - $line++; - $counter = 0; - foreach ($var as $k => &$v) { - if ($k !== $marker) { - $item = ($k === $counter ? '' : self::_toPhp($k, $list, $level + 1, $line) . ' => ') . self::_toPhp($v, $list, $level + 1, $line); - $counter = is_int($k) ? max($k + 1, $counter) : $counter; - $outShort .= ($outShort === '' ? '' : ', ') . $item; - $out .= "\t$item,\n$space"; - $line++; - } - } - unset($var[$marker]); - if (strpos($outShort, "\n") === false && strlen($outShort) < self::$maxLength) { - $line = $oldLine; - $out = $outShort; - } - } - return '[' . $out . ']'; - - } elseif ($var instanceof \Closure) { - $rc = new \ReflectionFunction($var); - return "/* Closure defined in file {$rc->getFileName()} on line {$rc->getStartLine()} */"; - - } elseif (is_object($var)) { - if (($rc = new \ReflectionObject($var))->isAnonymous()) { - return "/* Anonymous class defined in file {$rc->getFileName()} on line {$rc->getStartLine()} */"; - } - $arr = (array) $var; - $space = str_repeat("\t", $level); - $class = get_class($var); - $used = &$list[spl_object_hash($var)]; - - if (empty($arr)) { - $out = ''; - - } elseif ($used) { - return "/* $class dumped on line $used */"; - - } elseif ($level > self::$maxDepth) { - return '/* Nesting level too deep */'; - - } else { - $out = "\n"; - $used = $line; - $line++; - foreach ($arr as $k => &$v) { - if (isset($k[0]) && $k[0] === "\x00") { - $k = substr($k, strrpos($k, "\x00") + 1); - } - $out .= "$space\t" . self::_toPhp($k, $list, $level + 1, $line) . ' => ' . self::_toPhp($v, $list, $level + 1, $line) . ",\n"; - $line++; - } - $out .= $space; - } - $hash = self::hash($var); - return $class === 'stdClass' - ? "(object) /* $hash */ [$out]" - : "$class::__set_state(/* $hash */ [$out])"; - - } elseif (is_resource($var)) { - return '/* resource ' . get_resource_type($var) . ' */'; - - } else { - $res = var_export($var, true); - $line += substr_count($res, "\n"); - return $res; - } - } - - - public static function dumpException(\Throwable $e): string - { - $trace = $e->getTrace(); - array_splice($trace, 0, $e instanceof \ErrorException ? 1 : 0, [['file' => $e->getFile(), 'line' => $e->getLine()]]); - - $testFile = null; - foreach (array_reverse($trace) as $item) { - if (isset($item['file'])) { // in case of shutdown handler, we want to skip inner-code blocks and debugging calls - $testFile = $item['file']; - break; - } - } - - if ($e instanceof AssertException) { - $expected = $e->expected; - $actual = $e->actual; - - if (is_object($expected) || is_array($expected) || (is_string($expected) && strlen($expected) > self::$maxLength) - || is_object($actual) || is_array($actual) || (is_string($actual) && (strlen($actual) > self::$maxLength || preg_match('#[\x00-\x1F]#', $actual))) - ) { - $args = isset($_SERVER['argv'][1]) - ? '.[' . implode(' ', preg_replace(['#^-*([^|]+).*#i', '#[^=a-z0-9. -]+#i'], ['$1', '-'], array_slice($_SERVER['argv'], 1))) . ']' - : ''; - $stored[] = self::saveOutput($testFile, $expected, $args . '.expected'); - $stored[] = self::saveOutput($testFile, $actual, $args . '.actual'); - } - - if ((is_string($actual) && is_string($expected))) { - for ($i = 0; $i < strlen($actual) && isset($expected[$i]) && $actual[$i] === $expected[$i]; $i++); - for (; $i && $i < strlen($actual) && $actual[$i - 1] >= "\x80" && $actual[$i] >= "\x80" && $actual[$i] < "\xC0"; $i--); - $i = max(0, min( - $i - (int) (self::$maxLength / 3), // try to display 1/3 of shorter string - max(strlen($actual), strlen($expected)) - self::$maxLength + 3 // 3 = length of ... - )); - if ($i) { - $expected = substr_replace($expected, '...', 0, $i); - $actual = substr_replace($actual, '...', 0, $i); - } - } - - $message = 'Failed: ' . $e->origMessage; - if (((is_string($actual) && is_string($expected)) || (is_array($actual) && is_array($expected))) - && preg_match('#^(.*)(%\d)(.*)(%\d.*)$#Ds', $message, $m) - ) { - $message = ($delta = strlen($m[1]) - strlen($m[3])) >= 3 - ? "$m[1]$m[2]\n" . str_repeat(' ', $delta - 3) . "...$m[3]$m[4]" - : "$m[1]$m[2]$m[3]\n" . str_repeat(' ', strlen($m[1]) - 4) . "... $m[4]"; - } - $message = strtr($message, [ - '%1' => self::color('yellow') . self::toLine($actual) . self::color('white'), - '%2' => self::color('yellow') . self::toLine($expected) . self::color('white'), - ]); - } else { - $message = ($e instanceof \ErrorException ? Helpers::errorTypeToString($e->getSeverity()) : get_class($e)) - . ': ' . preg_replace('#[\x00-\x09\x0B-\x1F]+#', ' ', $e->getMessage()); - } - - $s = self::color('white', $message) . "\n\n" - . (isset($stored) ? 'diff ' . Helpers::escapeArg($stored[0]) . ' ' . Helpers::escapeArg($stored[1]) . "\n\n" : ''); - - foreach ($trace as $item) { - $item += ['file' => null, 'class' => null, 'type' => null, 'function' => null]; - if ($e instanceof AssertException && $item['file'] === __DIR__ . DIRECTORY_SEPARATOR . 'Assert.php') { - continue; - } - $line = $item['class'] === Assert::class && method_exists($item['class'], $item['function']) - && strpos($tmp = file($item['file'])[$item['line'] - 1], "::$item[function](") ? $tmp : null; - - $s .= 'in ' - . ($item['file'] - ? ( - ($item['file'] === $testFile ? self::color('white') : '') - . implode( - self::$pathSeparator ?? DIRECTORY_SEPARATOR, - array_slice(explode(DIRECTORY_SEPARATOR, $item['file']), -self::$maxPathSegments) - ) - . "($item[line])" . self::color('gray') . ' ' - ) - : '[internal function]' - ) - . ($line - ? trim($line) - : $item['class'] . $item['type'] . $item['function'] . ($item['function'] ? '()' : '') - ) - . self::color() . "\n"; - } - - if ($e->getPrevious()) { - $s .= "\n(previous) " . static::dumpException($e->getPrevious()); - } - return $s; - } - - - /** - * Dumps data to folder 'output'. - */ - public static function saveOutput(string $testFile, $content, string $suffix = ''): string - { - $path = self::$dumpDir . DIRECTORY_SEPARATOR . pathinfo($testFile, PATHINFO_FILENAME) . $suffix; - if (!preg_match('#/|\w:#A', self::$dumpDir)) { - $path = dirname($testFile) . DIRECTORY_SEPARATOR . $path; - } - @mkdir(dirname($path)); // @ - directory may already exist - file_put_contents($path, is_string($content) ? $content : (self::toPhp($content) . "\n")); - return $path; - } - - - /** - * Applies color to string. - */ - public static function color(string $color = '', string $s = null): string - { - static $colors = [ - 'black' => '0;30', 'gray' => '1;30', 'silver' => '0;37', 'white' => '1;37', - 'navy' => '0;34', 'blue' => '1;34', 'green' => '0;32', 'lime' => '1;32', - 'teal' => '0;36', 'aqua' => '1;36', 'maroon' => '0;31', 'red' => '1;31', - 'purple' => '0;35', 'fuchsia' => '1;35', 'olive' => '0;33', 'yellow' => '1;33', - null => '0', - ]; - $c = explode('/', $color); - return "\e[" - . str_replace(';', "m\e[", $colors[$c[0]] . (empty($c[1]) ? '' : ';4' . substr($colors[$c[1]], -1))) - . 'm' . $s . ($s === null ? '' : "\e[0m"); - } - - - public static function removeColors(string $s): string - { - return preg_replace('#\e\[[\d;]+m#', '', $s); - } -} diff --git a/vendor/nette/tester/src/Framework/Environment.php b/vendor/nette/tester/src/Framework/Environment.php deleted file mode 100644 index 3315d28e4ae75208279c808847cf762fa00c8b0c..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/Framework/Environment.php +++ /dev/null @@ -1,251 +0,0 @@ -<?php - -/** - * This file is part of the Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -namespace Tester; - - -/** - * Testing environment. - */ -class Environment -{ - /** Should Test use console colors? */ - public const COLORS = 'NETTE_TESTER_COLORS'; - - /** Test is run by Runner */ - public const RUNNER = 'NETTE_TESTER_RUNNER'; - - /** Code coverage engine */ - public const COVERAGE_ENGINE = 'NETTE_TESTER_COVERAGE_ENGINE'; - - /** Code coverage file */ - public const COVERAGE = 'NETTE_TESTER_COVERAGE'; - - /** Thread number when run tests in multi threads */ - public const THREAD = 'NETTE_TESTER_THREAD'; - - /** @var bool */ - public static $checkAssertions = false; - - /** @var bool */ - public static $useColors; - - /** @var int initial output buffer level */ - private static $obLevel; - - /** @var int */ - private static $exitCode = 0; - - - /** - * Configures testing environment. - */ - public static function setup(): void - { - self::setupErrors(); - self::setupColors(); - self::$obLevel = ob_get_level(); - - class_exists(Runner\Job::class); - class_exists(Dumper::class); - class_exists(Assert::class); - - $annotations = self::getTestAnnotations(); - self::$checkAssertions = !isset($annotations['outputmatch']) && !isset($annotations['outputmatchfile']); - - if (getenv(self::COVERAGE) && getenv(self::COVERAGE_ENGINE)) { - CodeCoverage\Collector::start(getenv(self::COVERAGE), getenv(self::COVERAGE_ENGINE)); - } - - if (getenv('TERMINAL_EMULATOR') === 'JetBrains-JediTerm') { - Dumper::$maxPathSegments = -1; - Dumper::$pathSeparator = '/'; - } - } - - - /** - * Configures colored output. - */ - public static function setupColors(): void - { - self::$useColors = getenv(self::COLORS) !== false - ? (bool) getenv(self::COLORS) - : (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') - && (!function_exists('stream_isatty') || stream_isatty(STDOUT)) // PHP >= 7.2 - && getenv('NO_COLOR') === false - && (defined('PHP_WINDOWS_VERSION_BUILD') - ? (function_exists('sapi_windows_vt100_support') && sapi_windows_vt100_support(STDOUT)) - || getenv('ConEmuANSI') === 'ON' // ConEmu - || getenv('ANSICON') !== false // ANSICON - || getenv('term') === 'xterm' // MSYS - || getenv('term') === 'xterm-256color' // MSYS - : (!function_exists('posix_isatty') || posix_isatty(STDOUT))); // PHP < 7.2 - - ob_start(function (string $s): string { - return self::$useColors ? $s : Dumper::removeColors($s); - }, 1, PHP_OUTPUT_HANDLER_FLUSHABLE); - } - - - /** - * Configures PHP error handling. - */ - public static function setupErrors(): void - { - error_reporting(E_ALL); - ini_set('display_errors', '1'); - ini_set('html_errors', '0'); - ini_set('log_errors', '0'); - - set_exception_handler([self::class, 'handleException']); - - set_error_handler(function (int $severity, string $message, string $file, int $line): ?bool { - if ( - in_array($severity, [E_RECOVERABLE_ERROR, E_USER_ERROR], true) - || ($severity & error_reporting()) === $severity - ) { - self::handleException(new \ErrorException($message, 0, $severity, $file, $line)); - } - return false; - }); - - register_shutdown_function(function (): void { - Assert::$onFailure = [self::class, 'handleException']; - - $error = error_get_last(); - register_shutdown_function(function () use ($error): void { - if (in_array($error['type'] ?? null, [E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE], true)) { - if (($error['type'] & error_reporting()) !== $error['type']) { // show fatal errors hidden by @shutup - self::removeOutputBuffers(); - echo "\n", Dumper::color('white/red', "Fatal error: $error[message] in $error[file] on line $error[line]"), "\n"; - } - } elseif (self::$checkAssertions && !Assert::$counter) { - self::removeOutputBuffers(); - echo "\n", Dumper::color('white/red', 'Error: This test forgets to execute an assertion.'), "\n"; - self::exit(Runner\Job::CODE_FAIL); - } elseif (!getenv(self::RUNNER) && self::$exitCode !== Runner\Job::CODE_SKIP) { - echo "\n", (self::$exitCode ? Dumper::color('white/red', 'FAILURE') : Dumper::color('white/green', 'OK')), "\n"; - } - }); - }); - } - - - /** - * @internal - */ - public static function handleException(\Throwable $e): void - { - self::removeOutputBuffers(); - self::$checkAssertions = false; - echo Dumper::dumpException($e); - self::exit($e instanceof AssertException ? Runner\Job::CODE_FAIL : Runner\Job::CODE_ERROR); - } - - - /** - * Skips this test. - */ - public static function skip(string $message = ''): void - { - self::$checkAssertions = false; - echo "\nSkipped:\n$message\n"; - self::exit(Runner\Job::CODE_SKIP); - } - - - /** - * Locks the parallel tests. - * @param string $path lock store directory - */ - public static function lock(string $name = '', string $path = ''): void - { - static $locks; - $file = "$path/lock-" . md5($name); - if (!isset($locks[$file])) { - flock($locks[$file] = fopen($file, 'w'), LOCK_EX); - } - } - - - /** - * Returns current test annotations. - */ - public static function getTestAnnotations(): array - { - $trace = debug_backtrace(); - return ($file = $trace[count($trace) - 1]['file'] ?? null) - ? Helpers::parseDocComment(file_get_contents($file)) + ['file' => $file] - : []; - } - - - /** - * Removes keyword final from source codes. - */ - public static function bypassFinals(): void - { - FileMutator::addMutator(function (string $code): string { - if (strpos($code, 'final') !== false) { - $tokens = token_get_all($code, TOKEN_PARSE); - $code = ''; - foreach ($tokens as $token) { - $code .= is_array($token) - ? ($token[0] === T_FINAL ? '' : $token[1]) - : $token; - } - } - return $code; - }); - } - - - /** - * Loads data according to the file annotation or specified by Tester\Runner\TestHandler::initiateDataProvider() - */ - public static function loadData(): array - { - if (isset($_SERVER['argv']) && ($tmp = preg_filter('#--dataprovider=(.*)#Ai', '$1', $_SERVER['argv']))) { - [$key, $file] = explode('|', reset($tmp), 2); - $data = DataProvider::load($file); - if (!array_key_exists($key, $data)) { - throw new \Exception("Missing dataset '$key' from data provider '$file'."); - } - return $data[$key]; - } - - $annotations = self::getTestAnnotations(); - if (!isset($annotations['dataprovider'])) { - throw new \Exception('Missing annotation @dataProvider.'); - } - $provider = (array) $annotations['dataprovider']; - [$file, $query] = DataProvider::parseAnnotation($provider[0], $annotations['file']); - - $data = DataProvider::load($file, $query); - if (!$data) { - throw new \Exception("No datasets from data provider '$file'" . ($query ? " for query '$query'" : '') . '.'); - } - - return reset($data); - } - - - private static function removeOutputBuffers(): void - { - while (ob_get_level() > self::$obLevel && @ob_end_flush()); // @ may be not removable - } - - - public static function exit(int $code = 0): void - { - self::$exitCode = $code; - exit($code); - } -} diff --git a/vendor/nette/tester/src/Framework/Expect.php b/vendor/nette/tester/src/Framework/Expect.php deleted file mode 100644 index bc9f7e69e99708b026cfc4ea57b2541df96e0aa2..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/Framework/Expect.php +++ /dev/null @@ -1,124 +0,0 @@ -<?php - -/** - * This file is part of the Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -namespace Tester; - - -/** - * Expectations for more complex assertions formulation. - * - * @method static self same($expected) - * @method static self notSame($expected) - * @method static self equal($expected) - * @method static self notEqual($expected) - * @method static self contains($needle) - * @method static self notContains($needle) - * @method static self true() - * @method static self false() - * @method static self null() - * @method static self nan() - * @method static self truthy() - * @method static self falsey() - * @method static self count(int $count) - * @method static self type(string|object $type) - * @method static self match(string $pattern) - * @method static self matchFile(string $file) - * - * @method self andSame($expected) - * @method self andNotSame($expected) - * @method self andEqual($expected) - * @method self andNotEqual($expected) - * @method self andContains($needle) - * @method self andNotContains($needle) - * @method self andTrue() - * @method self andFalse() - * @method self andNull() - * @method self andNan() - * @method self andTruthy() - * @method self andFalsey() - * @method self andCount(int $count) - * @method self andType(string|object $type) - * @method self andMatch(string $pattern) - * @method self andMatchFile(string $file) - */ -class Expect -{ - /** @var array of self|\Closure|\stdClass */ - private $constraints = []; - - - public static function __callStatic(string $method, array $args): self - { - $me = new self; - $me->constraints[] = (object) ['method' => $method, 'args' => $args]; - return $me; - } - - - public static function that(callable $constraint): self - { - return (new self)->and($constraint); - } - - - public function __call(string $method, array $args): self - { - if (preg_match('#^and([A-Z]\w+)#', $method, $m)) { - $this->constraints[] = (object) ['method' => lcfirst($m[1]), 'args' => $args]; - return $this; - } - throw new \Error('Call to undefined method ' . self::class . '::' . $method . '()'); - } - - - public function and(callable $constraint): self - { - $this->constraints[] = $constraint; - return $this; - } - - - /** - * Checks the expectations. - */ - public function __invoke($actual): void - { - foreach ($this->constraints as $cstr) { - if ($cstr instanceof \stdClass) { - $args = $cstr->args; - $args[] = $actual; - Assert::{$cstr->method}(...$args); - - } elseif ($cstr($actual) === false) { - Assert::fail('%1 is expected to be %2', $actual, is_string($cstr) ? $cstr : 'user-expectation'); - } - } - } - - - public function dump(): string - { - $res = []; - foreach ($this->constraints as $cstr) { - if ($cstr instanceof \stdClass) { - $args = isset($cstr->args[0]) - ? Dumper::toLine($cstr->args[0]) - : ''; - $res[] = "$cstr->method($args)"; - - } elseif ($cstr instanceof self) { - $res[] = $cstr->dump(); - - } else { - $res[] = is_string($cstr) ? $cstr : 'user-expectation'; - } - } - return implode(',', $res); - } -} diff --git a/vendor/nette/tester/src/Framework/FileMock.php b/vendor/nette/tester/src/Framework/FileMock.php deleted file mode 100644 index a32b272c12faae9c99f9498fdf6af3499de1d0aa..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/Framework/FileMock.php +++ /dev/null @@ -1,222 +0,0 @@ -<?php - -/** - * This file is part of the Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -namespace Tester; - - -/** - * Mock files. - */ -class FileMock -{ - private const PROTOCOL = 'mock'; - - /** @var string[] */ - public static $files = []; - - /** @var string */ - private $content; - - /** @var int */ - private $readingPos; - - /** @var int */ - private $writingPos; - - /** @var bool */ - private $appendMode; - - /** @var bool */ - private $isReadable; - - /** @var bool */ - private $isWritable; - - - /** - * @return string file name - */ - public static function create(string $content = '', string $extension = null): string - { - self::register(); - - static $id; - $name = self::PROTOCOL . '://' . (++$id) . '.' . $extension; - self::$files[$name] = $content; - return $name; - } - - - public static function register(): void - { - if (!in_array(self::PROTOCOL, stream_get_wrappers(), true)) { - stream_wrapper_register(self::PROTOCOL, self::class); - } - } - - - public function stream_open(string $path, string $mode): bool - { - if (!preg_match('#^([rwaxc]).*?(\+)?#', $mode, $m)) { - // Windows: failed to open stream: Bad file descriptor - // Linux: failed to open stream: Illegal seek - $this->warning("failed to open stream: Invalid mode '$mode'"); - return false; - - } elseif ($m[1] === 'x' && isset(self::$files[$path])) { - $this->warning('failed to open stream: File exists'); - return false; - - } elseif ($m[1] === 'r' && !isset(self::$files[$path])) { - $this->warning('failed to open stream: No such file or directory'); - return false; - - } elseif ($m[1] === 'w' || $m[1] === 'x') { - self::$files[$path] = ''; - } - - $this->content = &self::$files[$path]; - $this->content = (string) $this->content; - $this->appendMode = $m[1] === 'a'; - $this->readingPos = 0; - $this->writingPos = $this->appendMode ? strlen($this->content) : 0; - $this->isReadable = isset($m[2]) || $m[1] === 'r'; - $this->isWritable = isset($m[2]) || $m[1] !== 'r'; - - return true; - } - - - public function stream_read(int $length) - { - if (!$this->isReadable) { - return false; - } - - $result = substr($this->content, $this->readingPos, $length); - $this->readingPos += strlen($result); - $this->writingPos += $this->appendMode ? 0 : strlen($result); - return $result; - } - - - public function stream_write(string $data) - { - if (!$this->isWritable) { - return false; - } - - $length = strlen($data); - $this->content = str_pad($this->content, $this->writingPos, "\x00"); - $this->content = substr_replace($this->content, $data, $this->writingPos, $length); - $this->readingPos += $length; - $this->writingPos += $length; - return $length; - } - - - public function stream_tell(): int - { - return $this->readingPos; - } - - - public function stream_eof(): bool - { - return $this->readingPos >= strlen($this->content); - } - - - public function stream_seek(int $offset, int $whence): bool - { - if ($whence === SEEK_CUR) { - $offset += $this->readingPos; - } elseif ($whence === SEEK_END) { - $offset += strlen($this->content); - } - if ($offset >= 0) { - $this->readingPos = $offset; - $this->writingPos = $this->appendMode ? $this->writingPos : $offset; - return true; - } else { - return false; - } - } - - - public function stream_truncate(int $size): bool - { - if (!$this->isWritable) { - return false; - } - - $this->content = substr(str_pad($this->content, $size, "\x00"), 0, $size); - $this->writingPos = $this->appendMode ? $size : $this->writingPos; - return true; - } - - - public function stream_set_option(int $option, int $arg1, int $arg2): bool - { - return false; - } - - - public function stream_stat(): array - { - return ['mode' => 0100666, 'size' => strlen($this->content)]; - } - - - public function url_stat(string $path, int $flags) - { - return isset(self::$files[$path]) - ? ['mode' => 0100666, 'size' => strlen(self::$files[$path])] - : false; - } - - - public function stream_lock(int $operation): bool - { - return false; - } - - - public function stream_metadata(string $path, int $option, $value): bool - { - switch ($option) { - case STREAM_META_TOUCH: - return true; - } - return false; - } - - - public function unlink(string $path): bool - { - if (isset(self::$files[$path])) { - unset(self::$files[$path]); - return true; - } - - $this->warning('No such file'); - return false; - } - - - private function warning(string $message): void - { - $bt = debug_backtrace(0, 3); - if (isset($bt[2]['function'])) { - $message = $bt[2]['function'] . '(' . @$bt[2]['args'][0] . '): ' . $message; - } - - trigger_error($message, E_USER_WARNING); - } -} diff --git a/vendor/nette/tester/src/Framework/FileMutator.php b/vendor/nette/tester/src/Framework/FileMutator.php deleted file mode 100644 index 8f9634a0476798137c5707c799b471f7f5284568..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/Framework/FileMutator.php +++ /dev/null @@ -1,233 +0,0 @@ -<?php - -/** - * This file is part of the Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -namespace Tester; - - -/** - * PHP file mutator. - * @internal - */ -class FileMutator -{ - private const PROTOCOL = 'file'; - - /** @var resource|null */ - public $context; - - /** @var resource|null */ - private $handle; - - /** @var callable[] */ - private static $mutators = []; - - - public static function addMutator(callable $mutator): void - { - self::$mutators[] = $mutator; - stream_wrapper_unregister(self::PROTOCOL); - stream_wrapper_register(self::PROTOCOL, self::class); - } - - - public function dir_closedir(): void - { - closedir($this->handle); - } - - - public function dir_opendir(string $path, int $options): bool - { - $this->handle = $this->context - ? $this->native('opendir', $path, $this->context) - : $this->native('opendir', $path); - return (bool) $this->handle; - } - - - public function dir_readdir() - { - return readdir($this->handle); - } - - - public function dir_rewinddir(): bool - { - return (bool) rewinddir($this->handle); - } - - - public function mkdir(string $path, int $mode, int $options): bool - { - $recursive = (bool) ($options & STREAM_MKDIR_RECURSIVE); - return $this->context - ? $this->native('mkdir', $path, $mode, $recursive, $this->context) - : $this->native('mkdir', $path, $mode, $recursive); - } - - - public function rename(string $pathFrom, string $pathTo): bool - { - return $this->context - ? $this->native('rename', $pathFrom, $pathTo, $this->context) - : $this->native('rename', $pathFrom, $pathTo); - } - - - public function rmdir(string $path, int $options): bool - { - return $this->context - ? $this->native('rmdir', $path, $this->context) - : $this->native('rmdir', $path); - } - - - public function stream_cast(int $castAs) - { - return $this->handle; - } - - - public function stream_close(): void - { - fclose($this->handle); - } - - - public function stream_eof(): bool - { - return feof($this->handle); - } - - - public function stream_flush(): bool - { - return fflush($this->handle); - } - - - public function stream_lock(int $operation): bool - { - return $operation - ? flock($this->handle, $operation) - : true; - } - - - public function stream_metadata(string $path, int $option, $value): bool - { - switch ($option) { - case STREAM_META_TOUCH: - return $this->native('touch', $path, $value[0] ?? time(), $value[1] ?? time()); - case STREAM_META_OWNER_NAME: - case STREAM_META_OWNER: - return $this->native('chown', $path, $value); - case STREAM_META_GROUP_NAME: - case STREAM_META_GROUP: - return $this->native('chgrp', $path, $value); - case STREAM_META_ACCESS: - return $this->native('chmod', $path, $value); - } - return false; - } - - - public function stream_open(string $path, string $mode, int $options, ?string &$openedPath): bool - { - $usePath = (bool) ($options & STREAM_USE_PATH); - if ($mode === 'rb' && pathinfo($path, PATHINFO_EXTENSION) === 'php') { - $content = $this->native('file_get_contents', $path, $usePath, $this->context); - if ($content === false) { - return false; - } else { - foreach (self::$mutators as $mutator) { - $content = $mutator($content); - } - $this->handle = tmpfile(); - $this->native('fwrite', $this->handle, $content); - $this->native('fseek', $this->handle, 0); - return true; - } - } else { - $this->handle = $this->context - ? $this->native('fopen', $path, $mode, $usePath, $this->context) - : $this->native('fopen', $path, $mode, $usePath); - return (bool) $this->handle; - } - } - - - public function stream_read(int $count) - { - return fread($this->handle, $count); - } - - - public function stream_seek(int $offset, int $whence = SEEK_SET): bool - { - return fseek($this->handle, $offset, $whence) === 0; - } - - - public function stream_set_option(int $option, int $arg1, int $arg2): bool - { - return false; - } - - - public function stream_stat() - { - return fstat($this->handle); - } - - - public function stream_tell(): int - { - return ftell($this->handle); - } - - - public function stream_truncate(int $newSize): bool - { - return ftruncate($this->handle, $newSize); - } - - - public function stream_write(string $data) - { - return fwrite($this->handle, $data); - } - - - public function unlink(string $path): bool - { - return $this->native('unlink', $path); - } - - - public function url_stat(string $path, int $flags) - { - $func = $flags & STREAM_URL_STAT_LINK ? 'lstat' : 'stat'; - return $flags & STREAM_URL_STAT_QUIET - ? @$this->native($func, $path) - : $this->native($func, $path); - } - - - private function native(string $func) - { - stream_wrapper_restore(self::PROTOCOL); - try { - return $func(...array_slice(func_get_args(), 1)); - } finally { - stream_wrapper_unregister(self::PROTOCOL); - stream_wrapper_register(self::PROTOCOL, self::class); - } - } -} diff --git a/vendor/nette/tester/src/Framework/Helpers.php b/vendor/nette/tester/src/Framework/Helpers.php deleted file mode 100644 index fd0964c803abd6c1908c614f97e4dca06ce5b963..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/Framework/Helpers.php +++ /dev/null @@ -1,124 +0,0 @@ -<?php - -/** - * This file is part of the Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -namespace Tester; - - -/** - * Test helpers. - */ -class Helpers -{ - /** - * Purges directory. - */ - public static function purge(string $dir): void - { - if (preg_match('#^(\w:)?[/\\\\]?$#', $dir)) { - throw new \InvalidArgumentException('Directory must not be an empty string or root path.'); - } - if (!is_dir($dir)) { - mkdir($dir); - } - foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST) as $entry) { - if ($entry->isDir()) { - rmdir((string) $entry); - } else { - unlink((string) $entry); - } - } - } - - - /** - * Find common directory for given paths. All files or directories must exist. - * @return string Empty when not found. Slash and back slash chars normalized to DIRECTORY_SEPARATOR. - * @internal - */ - public static function findCommonDirectory(array $paths): string - { - $splitPaths = array_map(function ($s) { - $real = realpath($s); - if ($s === '') { - throw new \RuntimeException('Path must not be empty.'); - } elseif ($real === false) { - throw new \RuntimeException("File or directory '$s' does not exist."); - } - return explode(DIRECTORY_SEPARATOR, $real); - }, $paths); - - $first = (array) array_shift($splitPaths); - for ($i = 0; $i < count($first); $i++) { - foreach ($splitPaths as $s) { - if ($first[$i] !== ($s[$i] ?? null)) { - break 2; - } - } - } - $common = implode(DIRECTORY_SEPARATOR, array_slice($first, 0, $i)); - return is_dir($common) ? $common : dirname($common); - } - - - /** - * Parse phpDoc comment. - * @internal - */ - public static function parseDocComment(string $s): array - { - $options = []; - if (!preg_match('#^/\*\*(.*?)\*/#ms', $s, $content)) { - return []; - } - if (preg_match('#^[ \t\*]*+([^\s@].*)#mi', $content[1], $matches)) { - $options[0] = trim($matches[1]); - } - preg_match_all('#^[ \t\*]*@(\w+)([^\w\r\n].*)?#mi', $content[1], $matches, PREG_SET_ORDER); - foreach ($matches as $match) { - $ref = &$options[strtolower($match[1])]; - if (isset($ref)) { - $ref = (array) $ref; - $ref = &$ref[]; - } - $ref = isset($match[2]) ? trim($match[2]) : ''; - } - return $options; - } - - - /** - * @internal - */ - public static function errorTypeToString(int $type): string - { - $consts = get_defined_constants(true); - foreach ($consts['Core'] as $name => $val) { - if ($type === $val && substr($name, 0, 2) === 'E_') { - return $name; - } - } - return 'Unknown error'; - } - - - /** - * Escape a string to be used as a shell argument. - * @internal - */ - public static function escapeArg(string $s): string - { - if (preg_match('#^[a-z0-9._=/:-]+$#Di', $s)) { - return $s; - } - - return defined('PHP_WINDOWS_VERSION_BUILD') - ? '"' . str_replace('"', '""', $s) . '"' - : escapeshellarg($s); - } -} diff --git a/vendor/nette/tester/src/Framework/TestCase.php b/vendor/nette/tester/src/Framework/TestCase.php deleted file mode 100644 index 1ffaddd7128264934877f5e88ce3084036a15293..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/Framework/TestCase.php +++ /dev/null @@ -1,277 +0,0 @@ -<?php - -/** - * This file is part of the Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -namespace Tester; - - -/** - * Single test case. - */ -class TestCase -{ - /** @internal */ - public const - LIST_METHODS = 'nette-tester-list-methods', - METHOD_PATTERN = '#^test[A-Z0-9_]#'; - - /** @var bool */ - private $handleErrors = false; - - /** @var callable|false|null */ - private $prevErrorHandler = false; - - - /** - * Runs the test case. - */ - public function run(): void - { - if (func_num_args()) { - throw new \LogicException('Calling TestCase::run($method) is deprecated. Use TestCase::runTest($method) instead.'); - } - - $methods = array_values(preg_grep(self::METHOD_PATTERN, array_map(function (\ReflectionMethod $rm): string { - return $rm->getName(); - }, (new \ReflectionObject($this))->getMethods()))); - - if (isset($_SERVER['argv']) && ($tmp = preg_filter('#--method=([\w-]+)$#Ai', '$1', $_SERVER['argv']))) { - $method = reset($tmp); - if ($method === self::LIST_METHODS) { - $this->sendMethodList($methods); - return; - } - - try { - $this->runTest($method); - } catch (TestCaseSkippedException $e) { - Environment::skip($e->getMessage()); - } - - } else { - foreach ($methods as $method) { - try { - $this->runTest($method); - } catch (TestCaseSkippedException $e) { - echo "\nSkipped:\n{$e->getMessage()}\n"; - } - } - } - } - - - /** - * Runs the test method. - * @param array $args test method parameters (dataprovider bypass) - */ - public function runTest(string $method, array $args = null): void - { - if (!method_exists($this, $method)) { - throw new TestCaseException("Method '$method' does not exist."); - } elseif (!preg_match(self::METHOD_PATTERN, $method)) { - throw new TestCaseException("Method '$method' is not a testing method."); - } - - $method = new \ReflectionMethod($this, $method); - if (!$method->isPublic()) { - throw new TestCaseException("Method {$method->getName()} is not public. Make it public or rename it."); - } - - $info = Helpers::parseDocComment((string) $method->getDocComment()) + ['throws' => null]; - - if ($info['throws'] === '') { - throw new TestCaseException("Missing class name in @throws annotation for {$method->getName()}()."); - } elseif (is_array($info['throws'])) { - throw new TestCaseException("Annotation @throws for {$method->getName()}() can be specified only once."); - } else { - $throws = is_string($info['throws']) ? preg_split('#\s+#', $info['throws'], 2) : []; - } - - $data = $args === null - ? $this->prepareTestData($method, (array) ($info['dataprovider'] ?? [])) - : [$args]; - - if ($this->prevErrorHandler === false) { - $this->prevErrorHandler = set_error_handler(function (int $severity): ?bool { - if ($this->handleErrors && ($severity & error_reporting()) === $severity) { - $this->handleErrors = false; - $this->silentTearDown(); - } - - return $this->prevErrorHandler - ? ($this->prevErrorHandler)(...func_get_args()) - : false; - }); - } - - - foreach ($data as $k => $params) { - try { - $this->setUp(); - - $this->handleErrors = true; - $params = array_values($params); - try { - if ($info['throws']) { - $e = Assert::error(function () use ($method, $params): void { - [$this, $method->getName()](...$params); - }, ...$throws); - if ($e instanceof AssertException) { - throw $e; - } - } else { - [$this, $method->getName()](...$params); - } - } catch (\Exception $e) { - $this->handleErrors = false; - $this->silentTearDown(); - throw $e; - } - $this->handleErrors = false; - - $this->tearDown(); - - } catch (AssertException $e) { - throw $e->setMessage(sprintf( - '%s in %s(%s)%s', - $e->origMessage, - $method->getName(), - substr(Dumper::toLine($params), 1, -1), - is_string($k) ? (" (data set '" . explode('-', $k, 2)[1] . "')") : '' - )); - } - } - } - - - /** - * @return mixed - */ - protected function getData(string $provider) - { - if (strpos($provider, '.') === false) { - return $this->$provider(); - } else { - $rc = new \ReflectionClass($this); - [$file, $query] = DataProvider::parseAnnotation($provider, $rc->getFileName()); - return DataProvider::load($file, $query); - } - } - - - /** - * This method is called before a test is executed. - * @return void - */ - protected function setUp() - { - } - - - /** - * This method is called after a test is executed. - * @return void - */ - protected function tearDown() - { - } - - - private function silentTearDown(): void - { - set_error_handler(function () {}); - try { - $this->tearDown(); - } catch (\Exception $e) { - } - restore_error_handler(); - } - - - /** - * Skips the test. - */ - protected function skip(string $message = ''): void - { - throw new TestCaseSkippedException($message); - } - - - private function sendMethodList(array $methods): void - { - Environment::$checkAssertions = false; - header('Content-Type: text/plain'); - echo "\n"; - echo 'TestCase:' . static::class . "\n"; - echo 'Method:' . implode("\nMethod:", $methods) . "\n"; - - $dependentFiles = []; - $reflections = [new \ReflectionObject($this)]; - while (count($reflections)) { - $rc = array_shift($reflections); - $dependentFiles[$rc->getFileName()] = 1; - - if ($rpc = $rc->getParentClass()) { - $reflections[] = $rpc; - } - - foreach ($rc->getTraits() as $rt) { - $reflections[] = $rt; - } - } - echo 'Dependency:' . implode("\nDependency:", array_keys($dependentFiles)) . "\n"; - } - - - private function prepareTestData(\ReflectionMethod $method, array $dataprovider): array - { - $data = $defaultParams = []; - - foreach ($method->getParameters() as $param) { - $defaultParams[$param->getName()] = $param->isDefaultValueAvailable() - ? $param->getDefaultValue() - : null; - } - - foreach ($dataprovider as $i => $provider) { - $res = $this->getData($provider); - if (!is_array($res) && !$res instanceof \Traversable) { - throw new TestCaseException("Data provider $provider() doesn't return array or Traversable."); - } - - foreach ($res as $k => $set) { - if (!is_array($set)) { - $type = is_object($set) ? get_class($set) : gettype($set); - throw new TestCaseException("Data provider $provider() item '$k' must be an array, $type given."); - } - - $data["$i-$k"] = is_string(key($set)) - ? array_merge($defaultParams, $set) - : $set; - } - } - - if (!$dataprovider) { - if ($method->getNumberOfRequiredParameters()) { - throw new TestCaseException("Method {$method->getName()}() has arguments, but @dataProvider is missing."); - } - $data[] = []; - } - return $data; - } -} - - -class TestCaseException extends \Exception -{ -} - - -class TestCaseSkippedException extends \Exception -{ -} diff --git a/vendor/nette/tester/src/Runner/CliTester.php b/vendor/nette/tester/src/Runner/CliTester.php deleted file mode 100644 index 558d21dbc3239acefa8071dc5d5ff2d0eaab3197..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/Runner/CliTester.php +++ /dev/null @@ -1,377 +0,0 @@ -<?php - -/** - * This file is part of the Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -namespace Tester\Runner; - -use Tester\CodeCoverage; -use Tester\Dumper; -use Tester\Environment; -use Tester\Helpers; - - -/** - * CLI Tester. - */ -class CliTester -{ - /** @var array */ - private $options; - - /** @var PhpInterpreter */ - private $interpreter; - - /** @var bool */ - private $debugMode = true; - - /** @var string|null */ - private $stdoutFormat; - - - public function run(): ?int - { - Environment::setupColors(); - $this->setupErrors(); - - ob_start(); - $cmd = $this->loadOptions(); - - $this->debugMode = (bool) $this->options['--debug']; - if (isset($this->options['--colors'])) { - Environment::$useColors = (bool) $this->options['--colors']; - } elseif (in_array($this->stdoutFormat, ['tap', 'junit'], true)) { - Environment::$useColors = false; - } - - if ($cmd->isEmpty() || $this->options['--help']) { - $cmd->help(); - return null; - } - - $this->createPhpInterpreter(); - - if ($this->options['--info']) { - $job = new Job(new Test(__DIR__ . '/info.php'), $this->interpreter); - $job->run(); - echo $job->getTest()->stdout; - return null; - } - - $runner = $this->createRunner(); - $runner->setEnvironmentVariable(Environment::RUNNER, '1'); - $runner->setEnvironmentVariable(Environment::COLORS, (string) (int) Environment::$useColors); - - if ($this->options['--coverage']) { - $coverageFile = $this->prepareCodeCoverage($runner); - } - - if ($this->stdoutFormat !== null) { - ob_clean(); - } - ob_end_flush(); - - if ($this->options['--watch']) { - $this->watch($runner); - return null; - } - - $result = $runner->run(); - - if (isset($coverageFile) && preg_match('#\.(?:html?|xml)$#D', $coverageFile)) { - $this->finishCodeCoverage($coverageFile); - } - - return $result ? 0 : 1; - } - - - private function loadOptions(): CommandLine - { - $outputFiles = []; - - echo <<<'XX' - _____ ___ ___ _____ ___ ___ -|_ _/ __)( __/_ _/ __)| _ ) - |_| \___ /___) |_| \___ |_|_\ v2.4.1 - - -XX; - - $cmd = new CommandLine(<<<'XX' -Usage: - tester [options] [<test file> | <directory>]... - -Options: - -p <path> Specify PHP interpreter to run (default: php). - -c <path> Look for php.ini file (or look in directory) <path>. - -C Use system-wide php.ini. - -d <key=value>... Define INI entry 'key' with value 'value'. - -s Show information about skipped tests. - --stop-on-fail Stop execution upon the first failure. - -j <num> Run <num> jobs in parallel (default: 8). - -o <console|tap|junit|log|none> (e.g. -o junit:output.xml) - Specify one or more output formats with optional file name. - -w | --watch <path> Watch directory. - -i | --info Show tests environment info and exit. - --setup <path> Script for runner setup. - --temp <path> Path to temporary directory. Default by sys_get_temp_dir(). - --colors [1|0] Enable or disable colors. - --coverage <path> Generate code coverage report to file. - --coverage-src <path> Path to source code. - -h | --help This help. - -XX - , [ - '-c' => [CommandLine::REALPATH => true], - '--watch' => [CommandLine::REPEATABLE => true, CommandLine::REALPATH => true], - '--setup' => [CommandLine::REALPATH => true], - '--temp' => [CommandLine::REALPATH => true], - 'paths' => [CommandLine::REPEATABLE => true, CommandLine::VALUE => getcwd()], - '--debug' => [], - '--cider' => [], - '--coverage-src' => [CommandLine::REALPATH => true, CommandLine::REPEATABLE => true], - '-o' => [CommandLine::REPEATABLE => true, CommandLine::NORMALIZER => function ($arg) use (&$outputFiles) { - [$format, $file] = explode(':', $arg, 2) + [1 => null]; - - if (isset($outputFiles[$file])) { - throw new \Exception( - $file === null - ? 'Option -o <format> without file name parameter can be used only once.' - : "Cannot specify output by -o into file '$file' more then once." - ); - } elseif ($file === null) { - $this->stdoutFormat = $format; - } - $outputFiles[$file] = true; - - return [$format, $file]; - }], - ]); - - if (isset($_SERVER['argv'])) { - if (($tmp = array_search('-l', $_SERVER['argv'], true)) - || ($tmp = array_search('-log', $_SERVER['argv'], true)) - || ($tmp = array_search('--log', $_SERVER['argv'], true)) - ) { - $_SERVER['argv'][$tmp] = '-o'; - $_SERVER['argv'][$tmp + 1] = 'log:' . $_SERVER['argv'][$tmp + 1]; - } - - if ($tmp = array_search('--tap', $_SERVER['argv'], true)) { - unset($_SERVER['argv'][$tmp]); - $_SERVER['argv'] = array_merge($_SERVER['argv'], ['-o', 'tap']); - } - } - - $this->options = $cmd->parse(); - if ($this->options['--temp'] === null) { - if (($temp = sys_get_temp_dir()) === '') { - echo "Note: System temporary directory is not set.\n"; - } elseif (($real = realpath($temp)) === false) { - echo "Note: System temporary directory '$temp' does not exist.\n"; - } else { - $this->options['--temp'] = rtrim($real, DIRECTORY_SEPARATOR); - } - } - - return $cmd; - } - - - private function createPhpInterpreter(): void - { - $args = $this->options['-C'] ? [] : ['-n']; - if ($this->options['-c']) { - array_push($args, '-c', $this->options['-c']); - } elseif (!$this->options['--info'] && !$this->options['-C']) { - echo "Note: No php.ini is used.\n"; - } - - if (in_array($this->stdoutFormat, ['tap', 'junit'], true)) { - array_push($args, '-d', 'html_errors=off'); - } - - foreach ($this->options['-d'] as $item) { - array_push($args, '-d', $item); - } - - $this->interpreter = new PhpInterpreter($this->options['-p'], $args); - - if ($error = $this->interpreter->getStartupError()) { - echo Dumper::color('red', "PHP startup error: $error") . "\n"; - } - } - - - private function createRunner(): Runner - { - $runner = new Runner($this->interpreter); - $runner->paths = $this->options['paths']; - $runner->threadCount = max(1, (int) $this->options['-j']); - $runner->stopOnFail = $this->options['--stop-on-fail']; - - if ($this->options['--temp'] !== null) { - $runner->setTempDirectory($this->options['--temp']); - } - - if ($this->stdoutFormat === null) { - $runner->outputHandlers[] = new Output\ConsolePrinter( - $runner, - (bool) $this->options['-s'], - 'php://output', - (bool) $this->options['--cider'] - ); - } - - foreach ($this->options['-o'] as $output) { - [$format, $file] = $output; - switch ($format) { - case 'console': - $runner->outputHandlers[] = new Output\ConsolePrinter($runner, (bool) $this->options['-s'], $file, (bool) $this->options['--cider']); - break; - - case 'tap': - $runner->outputHandlers[] = new Output\TapPrinter($file); - break; - - case 'junit': - $runner->outputHandlers[] = new Output\JUnitPrinter($file); - break; - - case 'log': - $runner->outputHandlers[] = new Output\Logger($runner, $file); - break; - - case 'none': - break; - - default: - throw new \LogicException("Undefined output printer '$format'.'"); - } - } - - if ($this->options['--setup']) { - (function () use ($runner): void { - require func_get_arg(0); - })($this->options['--setup']); - } - return $runner; - } - - - private function prepareCodeCoverage(Runner $runner): string - { - $engines = $this->interpreter->getCodeCoverageEngines(); - if (count($engines) < 1) { - throw new \Exception("Code coverage functionality requires Xdebug or PCOV extension or PHPDBG SAPI (used {$this->interpreter->getCommandLine()})"); - } - - file_put_contents($this->options['--coverage'], ''); - $file = realpath($this->options['--coverage']); - - [$engine, $version] = reset($engines); - - $runner->setEnvironmentVariable(Environment::COVERAGE, $file); - $runner->setEnvironmentVariable(Environment::COVERAGE_ENGINE, $engine); - - if ($engine === CodeCoverage\Collector::ENGINE_XDEBUG && version_compare($version, '3.0.0', '>=')) { - $runner->addPhpIniOption('xdebug.mode', ltrim(ini_get('xdebug.mode') . ',coverage', ',')); - } - - if ($engine === CodeCoverage\Collector::ENGINE_PCOV && count($this->options['--coverage-src'])) { - $runner->addPhpIniOption('pcov.directory', Helpers::findCommonDirectory($this->options['--coverage-src'])); - } - - echo "Code coverage by $engine: $file\n"; - return $file; - } - - - private function finishCodeCoverage(string $file): void - { - if (!in_array($this->stdoutFormat, ['none', 'tap', 'junit'], true)) { - echo 'Generating code coverage report... '; - } - if (filesize($file) === 0) { - echo 'failed. Coverage file is empty. Do you call Tester\Environment::setup() in tests?' . "\n"; - return; - } - $generator = pathinfo($file, PATHINFO_EXTENSION) === 'xml' - ? new CodeCoverage\Generators\CloverXMLGenerator($file, $this->options['--coverage-src']) - : new CodeCoverage\Generators\HtmlGenerator($file, $this->options['--coverage-src']); - $generator->render($file); - echo round($generator->getCoveredPercent()) . "% covered\n"; - } - - - private function watch(Runner $runner): void - { - $prev = []; - $counter = 0; - while (true) { - $state = []; - foreach ($this->options['--watch'] as $directory) { - foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory)) as $file) { - if (substr($file->getExtension(), 0, 3) === 'php' && substr($file->getBasename(), 0, 1) !== '.') { - $state[(string) $file] = @filemtime((string) $file); // @ file could be deleted in the meantime - } - } - } - if ($state !== $prev) { - $prev = $state; - try { - $runner->run(); - } catch (\ErrorException $e) { - $this->displayException($e); - } - echo "\n"; - $time = time(); - } - - $idle = time() - $time; - if ($idle >= 60 * 60) { - $idle = 'long time'; - } elseif ($idle >= 60) { - $idle = round($idle / 60) . ' min'; - } else { - $idle .= ' sec'; - } - echo 'Watching ' . implode(', ', $this->options['--watch']) . " (idle for $idle) " . str_repeat('.', ++$counter % 5) . " \r"; - sleep(2); - } - } - - - private function setupErrors(): void - { - error_reporting(E_ALL); - ini_set('html_errors', '0'); - - set_error_handler(function (int $severity, string $message, string $file, int $line) { - if (($severity & error_reporting()) === $severity) { - throw new \ErrorException($message, 0, $severity, $file, $line); - } - return false; - }); - - set_exception_handler(function (\Throwable $e) { - $this->displayException($e); - exit(2); - }); - } - - - private function displayException(\Throwable $e): void - { - echo "\n"; - echo $this->debugMode - ? Dumper::dumpException($e) - : Dumper::color('white/red', 'Error: ' . $e->getMessage()); - echo "\n"; - } -} diff --git a/vendor/nette/tester/src/Runner/CommandLine.php b/vendor/nette/tester/src/Runner/CommandLine.php deleted file mode 100644 index ef89dc8509ba19a23afcf1141b65dc4e64dd1d16..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/Runner/CommandLine.php +++ /dev/null @@ -1,185 +0,0 @@ -<?php - -/** - * This file is part of the Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -namespace Tester\Runner; - - -/** - * Stupid command line arguments parser. - */ -class CommandLine -{ - public const - ARGUMENT = 'argument', - OPTIONAL = 'optional', - REPEATABLE = 'repeatable', - ENUM = 'enum', - REALPATH = 'realpath', - NORMALIZER = 'normalizer', - VALUE = 'default'; - - /** @var array[] */ - private $options = []; - - /** @var string[] */ - private $aliases = []; - - /** @var string[] */ - private $positional = []; - - /** @var string */ - private $help; - - - public function __construct(string $help, array $defaults = []) - { - $this->help = $help; - $this->options = $defaults; - - preg_match_all('#^[ \t]+(--?\w.*?)(?: .*\(default: (.*)\)| |\r|$)#m', $help, $lines, PREG_SET_ORDER); - foreach ($lines as $line) { - preg_match_all('#(--?\w[\w-]*)(?:[= ](<.*?>|\[.*?]|\w+)(\.{0,3}))?[ ,|]*#A', $line[1], $m); - if (!count($m[0]) || count($m[0]) > 2 || implode('', $m[0]) !== $line[1]) { - throw new \InvalidArgumentException("Unable to parse '$line[1]'."); - } - - $name = end($m[1]); - $opts = $this->options[$name] ?? []; - $this->options[$name] = $opts + [ - self::ARGUMENT => (bool) end($m[2]), - self::OPTIONAL => isset($line[2]) || (substr(end($m[2]), 0, 1) === '[') || isset($opts[self::VALUE]), - self::REPEATABLE => (bool) end($m[3]), - self::ENUM => count($enums = explode('|', trim(end($m[2]), '<[]>'))) > 1 ? $enums : null, - self::VALUE => $line[2] ?? null, - ]; - if ($name !== $m[1][0]) { - $this->aliases[$m[1][0]] = $name; - } - } - - foreach ($this->options as $name => $foo) { - if ($name[0] !== '-') { - $this->positional[] = $name; - } - } - } - - - public function parse(array $args = null): array - { - if ($args === null) { - $args = isset($_SERVER['argv']) ? array_slice($_SERVER['argv'], 1) : []; - } - $params = []; - reset($this->positional); - $i = 0; - while ($i < count($args)) { - $arg = $args[$i++]; - if ($arg[0] !== '-') { - if (!current($this->positional)) { - throw new \Exception("Unexpected parameter $arg."); - } - $name = current($this->positional); - $this->checkArg($this->options[$name], $arg); - if (empty($this->options[$name][self::REPEATABLE])) { - $params[$name] = $arg; - next($this->positional); - } else { - $params[$name][] = $arg; - } - continue; - } - - [$name, $arg] = strpos($arg, '=') ? explode('=', $arg, 2) : [$arg, true]; - - if (isset($this->aliases[$name])) { - $name = $this->aliases[$name]; - - } elseif (!isset($this->options[$name])) { - throw new \Exception("Unknown option $name."); - } - - $opt = $this->options[$name]; - - if ($arg !== true && empty($opt[self::ARGUMENT])) { - throw new \Exception("Option $name has not argument."); - - } elseif ($arg === true && !empty($opt[self::ARGUMENT])) { - if (isset($args[$i]) && $args[$i][0] !== '-') { - $arg = $args[$i++]; - } elseif (empty($opt[self::OPTIONAL])) { - throw new \Exception("Option $name requires argument."); - } - } - - $this->checkArg($opt, $arg); - - if ( - !empty($opt[self::ENUM]) - && !in_array(is_array($arg) ? reset($arg) : $arg, $opt[self::ENUM], true) - && !( - $opt[self::OPTIONAL] - && $arg === true - ) - ) { - throw new \Exception("Value of option $name must be " . implode(', or ', $opt[self::ENUM]) . '.'); - } - - if (empty($opt[self::REPEATABLE])) { - $params[$name] = $arg; - } else { - $params[$name][] = $arg; - } - } - - foreach ($this->options as $name => $opt) { - if (isset($params[$name])) { - continue; - } elseif (isset($opt[self::VALUE])) { - $params[$name] = $opt[self::VALUE]; - } elseif ($name[0] !== '-' && empty($opt[self::OPTIONAL])) { - throw new \Exception("Missing required argument <$name>."); - } else { - $params[$name] = null; - } - if (!empty($opt[self::REPEATABLE])) { - $params[$name] = (array) $params[$name]; - } - } - return $params; - } - - - public function help(): void - { - echo $this->help; - } - - - public function checkArg(array $opt, &$arg): void - { - if (!empty($opt[self::NORMALIZER])) { - $arg = call_user_func($opt[self::NORMALIZER], $arg); - } - - if (!empty($opt[self::REALPATH])) { - $path = realpath($arg); - if ($path === false) { - throw new \Exception("File path '$arg' not found."); - } - $arg = $path; - } - } - - - public function isEmpty(): bool - { - return !isset($_SERVER['argv']) || count($_SERVER['argv']) < 2; - } -} diff --git a/vendor/nette/tester/src/Runner/Job.php b/vendor/nette/tester/src/Runner/Job.php deleted file mode 100644 index d8b8c1ae437b8d990da4328da97207944911fb00..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/Runner/Job.php +++ /dev/null @@ -1,221 +0,0 @@ -<?php - -/** - * This file is part of the Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -namespace Tester\Runner; - -use Tester\Helpers; - - -/** - * Single test job. - */ -class Job -{ - public const - CODE_NONE = -1, - CODE_OK = 0, - CODE_SKIP = 177, - CODE_FAIL = 178, - CODE_ERROR = 255; - - /** waiting time between process activity check in microseconds */ - public const RUN_USLEEP = 10000; - - public const - RUN_ASYNC = 1, - RUN_COLLECT_ERRORS = 2; - - /** @var Test */ - private $test; - - /** @var PhpInterpreter */ - private $interpreter; - - /** @var string[] environment variables for test */ - private $envVars; - - /** @var resource|null */ - private $proc; - - /** @var resource|null */ - private $stdout; - - /** @var resource|null */ - private $stderr; - - /** @var int */ - private $exitCode = self::CODE_NONE; - - /** @var string[] output headers */ - private $headers = []; - - /** @var float|null */ - private $duration; - - - public function __construct(Test $test, PhpInterpreter $interpreter, array $envVars = null) - { - if ($test->getResult() !== Test::PREPARED) { - throw new \LogicException("Test '{$test->getSignature()}' already has result '{$test->getResult()}'."); - } - - $test->stdout = ''; - $test->stderr = ''; - - $this->test = $test; - $this->interpreter = $interpreter; - $this->envVars = (array) $envVars; - } - - - public function setEnvironmentVariable(string $name, string $value): void - { - $this->envVars[$name] = $value; - } - - - public function getEnvironmentVariable(string $name): string - { - return $this->envVars[$name]; - } - - - /** - * Runs single test. - * @param int $flags self::RUN_ASYNC | self::RUN_COLLECT_ERRORS - */ - public function run(int $flags = 0): void - { - foreach ($this->envVars as $name => $value) { - putenv("$name=$value"); - } - - $args = []; - foreach ($this->test->getArguments() as $value) { - $args[] = is_array($value) - ? Helpers::escapeArg("--$value[0]=$value[1]") - : Helpers::escapeArg($value); - } - - $this->duration = -microtime(true); - $this->proc = proc_open( - $this->interpreter->getCommandLine() - . ' -d register_argc_argv=on ' . Helpers::escapeArg($this->test->getFile()) . ' ' . implode(' ', $args), - [ - ['pipe', 'r'], - ['pipe', 'w'], - ['pipe', 'w'], - ], - $pipes, - dirname($this->test->getFile()), - null, - ['bypass_shell' => true] - ); - - foreach (array_keys($this->envVars) as $name) { - putenv($name); - } - - [$stdin, $this->stdout, $stderr] = $pipes; - fclose($stdin); - if ($flags & self::RUN_COLLECT_ERRORS) { - $this->stderr = $stderr; - } else { - fclose($stderr); - } - - if ($flags & self::RUN_ASYNC) { - stream_set_blocking($this->stdout, false); // on Windows does not work with proc_open() - if ($this->stderr) { - stream_set_blocking($this->stderr, false); - } - } else { - while ($this->isRunning()) { - usleep(self::RUN_USLEEP); // stream_select() doesn't work with proc_open() - } - } - } - - - /** - * Checks if the test is still running. - */ - public function isRunning(): bool - { - if (!is_resource($this->stdout)) { - return false; - } - $this->test->stdout .= stream_get_contents($this->stdout); - if ($this->stderr) { - $this->test->stderr .= stream_get_contents($this->stderr); - } - - $status = proc_get_status($this->proc); - if ($status['running']) { - return true; - } - $this->duration += microtime(true); - - fclose($this->stdout); - if ($this->stderr) { - fclose($this->stderr); - } - $code = proc_close($this->proc); - $this->exitCode = $code === self::CODE_NONE - ? $status['exitcode'] - : $code; - - if ($this->interpreter->isCgi() && count($tmp = explode("\r\n\r\n", $this->test->stdout, 2)) >= 2) { - [$headers, $this->test->stdout] = $tmp; - foreach (explode("\r\n", $headers) as $header) { - $pos = strpos($header, ':'); - if ($pos !== false) { - $this->headers[trim(substr($header, 0, $pos))] = trim(substr($header, $pos + 1)); - } - } - } - return false; - } - - - public function getTest(): Test - { - return $this->test; - } - - - /** - * Returns exit code. - */ - public function getExitCode(): int - { - return $this->exitCode; - } - - - /** - * Returns output headers. - * @return string[] - */ - public function getHeaders(): array - { - return $this->headers; - } - - - /** - * Returns process duration in seconds. - */ - public function getDuration(): ?float - { - return $this->duration > 0 - ? $this->duration - : null; - } -} diff --git a/vendor/nette/tester/src/Runner/Output/ConsolePrinter.php b/vendor/nette/tester/src/Runner/Output/ConsolePrinter.php deleted file mode 100644 index c7f1122e8dbd590f455b455c2ec7540392eab92d..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/Runner/Output/ConsolePrinter.php +++ /dev/null @@ -1,136 +0,0 @@ -<?php - -/** - * This file is part of the Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -namespace Tester\Runner\Output; - -use Tester; -use Tester\Dumper; -use Tester\Runner\Runner; -use Tester\Runner\Test; - - -/** - * Console printer. - */ -class ConsolePrinter implements Tester\Runner\OutputHandler -{ - /** @var Runner */ - private $runner; - - /** @var bool display skipped tests information? */ - private $displaySkipped = false; - - /** @var resource */ - private $file; - - /** @var string */ - private $buffer; - - /** @var float */ - private $time; - - /** @var int */ - private $count; - - /** @var array */ - private $results; - - /** @var string */ - private $baseDir; - - /** @var array */ - private $symbols; - - - public function __construct( - Runner $runner, - bool $displaySkipped = false, - string $file = null, - bool $ciderMode = false - ) { - $this->runner = $runner; - $this->displaySkipped = $displaySkipped; - $this->file = fopen($file ?: 'php://output', 'w'); - $this->symbols = [ - Test::PASSED => $ciderMode ? Dumper::color('green', 'π') : '.', - Test::SKIPPED => 's', - Test::FAILED => $ciderMode ? Dumper::color('red', 'π') : Dumper::color('white/red', 'F'), - ]; - } - - - public function begin(): void - { - $this->count = 0; - $this->baseDir = null; - $this->results = [ - Test::PASSED => 0, - Test::SKIPPED => 0, - Test::FAILED => 0, - ]; - $this->time = -microtime(true); - fwrite($this->file, $this->runner->getInterpreter()->getShortInfo() - . ' | ' . $this->runner->getInterpreter()->getCommandLine() - . " | {$this->runner->threadCount} thread" . ($this->runner->threadCount > 1 ? 's' : '') . "\n\n"); - } - - - public function prepare(Test $test): void - { - if ($this->baseDir === null) { - $this->baseDir = dirname($test->getFile()) . DIRECTORY_SEPARATOR; - } elseif (strpos($test->getFile(), $this->baseDir) !== 0) { - $common = array_intersect_assoc( - explode(DIRECTORY_SEPARATOR, $this->baseDir), - explode(DIRECTORY_SEPARATOR, $test->getFile()) - ); - $this->baseDir = ''; - $prev = 0; - foreach ($common as $i => $part) { - if ($i !== $prev++) { - break; - } - $this->baseDir .= $part . DIRECTORY_SEPARATOR; - } - } - - $this->count++; - } - - - public function finish(Test $test): void - { - $this->results[$test->getResult()]++; - fwrite($this->file, $this->symbols[$test->getResult()]); - - $title = ($test->title ? "$test->title | " : '') . substr($test->getSignature(), strlen($this->baseDir)); - $message = ' ' . str_replace("\n", "\n ", trim((string) $test->message)) . "\n\n"; - if ($test->getResult() === Test::FAILED) { - $this->buffer .= Dumper::color('red', "-- FAILED: $title") . "\n$message"; - } elseif ($test->getResult() === Test::SKIPPED && $this->displaySkipped) { - $this->buffer .= "-- Skipped: $title\n$message"; - } - } - - - public function end(): void - { - $run = array_sum($this->results); - fwrite($this->file, !$this->count ? "No tests found\n" : - "\n\n" . $this->buffer . "\n" - . ($this->results[Test::FAILED] ? Dumper::color('white/red') . 'FAILURES!' : Dumper::color('white/green') . 'OK') - . " ($this->count test" . ($this->count > 1 ? 's' : '') . ', ' - . ($this->results[Test::FAILED] ? $this->results[Test::FAILED] . ' failure' . ($this->results[Test::FAILED] > 1 ? 's' : '') . ', ' : '') - . ($this->results[Test::SKIPPED] ? $this->results[Test::SKIPPED] . ' skipped, ' : '') - . ($this->count !== $run ? ($this->count - $run) . ' not run, ' : '') - . sprintf('%0.1f', $this->time + microtime(true)) . ' seconds)' . Dumper::color() . "\n"); - - $this->buffer = null; - } -} diff --git a/vendor/nette/tester/src/Runner/Output/JUnitPrinter.php b/vendor/nette/tester/src/Runner/Output/JUnitPrinter.php deleted file mode 100644 index 453a5a03bda00493afe0bc94a4ce136faca17839..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/Runner/Output/JUnitPrinter.php +++ /dev/null @@ -1,86 +0,0 @@ -<?php - -/** - * This file is part of the Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -namespace Tester\Runner\Output; - -use Tester; -use Tester\Runner\Test; - - -/** - * JUnit xml format printer. - */ -class JUnitPrinter implements Tester\Runner\OutputHandler -{ - /** @var resource */ - private $file; - - /** @var string */ - private $buffer; - - /** @var float */ - private $startTime; - - /** @var array */ - private $results; - - - public function __construct(string $file = null) - { - $this->file = fopen($file ?: 'php://output', 'w'); - } - - - public function begin(): void - { - $this->results = [ - Test::PASSED => 0, - Test::SKIPPED => 0, - Test::FAILED => 0, - ]; - $this->startTime = microtime(true); - fwrite($this->file, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<testsuites>\n"); - } - - - public function prepare(Test $test): void - { - } - - - public function finish(Test $test): void - { - $this->results[$test->getResult()]++; - $this->buffer .= "\t\t<testcase classname=\"" . htmlspecialchars($test->getSignature()) . '" name="' . htmlspecialchars($test->getSignature()) . '"'; - - switch ($test->getResult()) { - case Test::FAILED: - $this->buffer .= ">\n\t\t\t<failure message=\"" . htmlspecialchars($test->message, ENT_COMPAT | ENT_HTML5) . "\"/>\n\t\t</testcase>\n"; - break; - case Test::SKIPPED: - $this->buffer .= ">\n\t\t\t<skipped/>\n\t\t</testcase>\n"; - break; - case Test::PASSED: - $this->buffer .= "/>\n"; - break; - } - } - - - public function end(): void - { - $time = sprintf('%0.1f', microtime(true) - $this->startTime); - $output = $this->buffer; - $this->buffer = "\t<testsuite errors=\"{$this->results[Test::FAILED]}\" skipped=\"{$this->results[Test::SKIPPED]}\" tests=\"" . array_sum($this->results) . "\" time=\"$time\" timestamp=\"" . @date('Y-m-d\TH:i:s') . "\">\n"; - $this->buffer .= $output; - $this->buffer .= "\t</testsuite>"; - - fwrite($this->file, $this->buffer . "\n</testsuites>\n"); - } -} diff --git a/vendor/nette/tester/src/Runner/Output/Logger.php b/vendor/nette/tester/src/Runner/Output/Logger.php deleted file mode 100644 index a7c29226b04cbdafdee5aed88e092183386777af..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/Runner/Output/Logger.php +++ /dev/null @@ -1,88 +0,0 @@ -<?php - -/** - * This file is part of the Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -namespace Tester\Runner\Output; - -use Tester; -use Tester\Runner\Runner; -use Tester\Runner\Test; - - -/** - * Verbose logger. - */ -class Logger implements Tester\Runner\OutputHandler -{ - /** @var Runner */ - private $runner; - - /** @var resource */ - private $file; - - /** @var int */ - private $count; - - /** @var array */ - private $results; - - - public function __construct(Runner $runner, string $file = null) - { - $this->runner = $runner; - $this->file = fopen($file ?: 'php://output', 'w'); - } - - - public function begin(): void - { - $this->count = 0; - $this->results = [ - Test::PASSED => 0, - Test::SKIPPED => 0, - Test::FAILED => 0, - ]; - fwrite($this->file, 'PHP ' . $this->runner->getInterpreter()->getVersion() - . ' | ' . $this->runner->getInterpreter()->getCommandLine() - . " | {$this->runner->threadCount} threads\n\n"); - } - - - public function prepare(Test $test): void - { - $this->count++; - } - - - public function finish(Test $test): void - { - $this->results[$test->getResult()]++; - $message = ' ' . str_replace("\n", "\n ", Tester\Dumper::removeColors(trim((string) $test->message))); - $outputs = [ - Test::PASSED => "-- OK: {$test->getSignature()}", - Test::SKIPPED => "-- Skipped: {$test->getSignature()}\n$message", - Test::FAILED => "-- FAILED: {$test->getSignature()}\n$message", - ]; - fwrite($this->file, $outputs[$test->getResult()] . "\n\n"); - } - - - public function end(): void - { - $run = array_sum($this->results); - fwrite( - $this->file, - ($this->results[Test::FAILED] ? 'FAILURES!' : 'OK') - . " ($this->count tests" - . ($this->results[Test::FAILED] ? ", {$this->results[Test::FAILED]} failures" : '') - . ($this->results[Test::SKIPPED] ? ", {$this->results[Test::SKIPPED]} skipped" : '') - . ($this->count !== $run ? ', ' . ($this->count - $run) . ' not run' : '') - . ')' - ); - } -} diff --git a/vendor/nette/tester/src/Runner/Output/TapPrinter.php b/vendor/nette/tester/src/Runner/Output/TapPrinter.php deleted file mode 100644 index b03e11057ea9aff261a8a80523589f9b56f4ad13..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/Runner/Output/TapPrinter.php +++ /dev/null @@ -1,67 +0,0 @@ -<?php - -/** - * This file is part of the Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -namespace Tester\Runner\Output; - -use Tester; -use Tester\Runner\Test; - - -/** - * Test Anything Protocol, http://testanything.org - */ -class TapPrinter implements Tester\Runner\OutputHandler -{ - /** @var resource */ - private $file; - - /** @var array */ - private $results; - - - public function __construct(string $file = null) - { - $this->file = fopen($file ?: 'php://output', 'w'); - } - - - public function begin(): void - { - $this->results = [ - Test::PASSED => 0, - Test::SKIPPED => 0, - Test::FAILED => 0, - ]; - fwrite($this->file, "TAP version 13\n"); - } - - - public function prepare(Test $test): void - { - } - - - public function finish(Test $test): void - { - $this->results[$test->getResult()]++; - $message = str_replace("\n", "\n# ", trim((string) $test->message)); - $outputs = [ - Test::PASSED => "ok {$test->getSignature()}", - Test::SKIPPED => "ok {$test->getSignature()} #skip $message", - Test::FAILED => "not ok {$test->getSignature()}\n# $message", - ]; - fwrite($this->file, $outputs[$test->getResult()] . "\n"); - } - - - public function end(): void - { - fwrite($this->file, '1..' . array_sum($this->results)); - } -} diff --git a/vendor/nette/tester/src/Runner/OutputHandler.php b/vendor/nette/tester/src/Runner/OutputHandler.php deleted file mode 100644 index 3aef8365e2a25516b353b14b1f79ebb65dffd933..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/Runner/OutputHandler.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php - -/** - * This file is part of the Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -namespace Tester\Runner; - - -/** - * Runner output. - */ -interface OutputHandler -{ - function begin(): void; - - function prepare(Test $test): void; - - function finish(Test $test): void; - - function end(): void; -} diff --git a/vendor/nette/tester/src/Runner/PhpInterpreter.php b/vendor/nette/tester/src/Runner/PhpInterpreter.php deleted file mode 100644 index 4a8a143880eb57059468dc46376b20190629564a..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/Runner/PhpInterpreter.php +++ /dev/null @@ -1,139 +0,0 @@ -<?php - -/** - * This file is part of the Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -namespace Tester\Runner; - -use Tester\Helpers; - - -/** - * PHP command-line executable. - */ -class PhpInterpreter -{ - /** @var string */ - private $commandLine; - - /** @var bool is CGI? */ - private $cgi; - - /** @var \stdClass created by info.php */ - private $info; - - /** @var string */ - private $error; - - - public function __construct(string $path, array $args = []) - { - $this->commandLine = Helpers::escapeArg($path); - $proc = @proc_open( // @ is escalated to exception - $this->commandLine . ' --version', - [['pipe', 'r'], ['pipe', 'w'], ['pipe', 'w']], - $pipes, - null, - null, - ['bypass_shell' => true] - ); - if ($proc === false) { - throw new \Exception("Cannot run PHP interpreter $path. Use -p option."); - } - fclose($pipes[0]); - $output = stream_get_contents($pipes[1]); - proc_close($proc); - - $args = ' ' . implode(' ', array_map([Helpers::class, 'escapeArg'], $args)); - if (strpos($output, 'phpdbg') !== false) { - $args = ' -qrrb -S cli' . $args; - } - $this->commandLine .= rtrim($args); - - $proc = proc_open( - $this->commandLine . ' -d register_argc_argv=on ' . Helpers::escapeArg(__DIR__ . '/info.php') . ' serialized', - [['pipe', 'r'], ['pipe', 'w'], ['pipe', 'w']], - $pipes, - null, - null, - ['bypass_shell' => true] - ); - $output = stream_get_contents($pipes[1]); - $this->error = trim(stream_get_contents($pipes[2])); - if (proc_close($proc)) { - throw new \Exception("Unable to run $path: " . preg_replace('#[\r\n ]+#', ' ', $this->error)); - } - - $parts = explode("\r\n\r\n", $output, 2); - $this->cgi = count($parts) === 2; - $this->info = @unserialize((string) strstr($parts[$this->cgi], 'O:8:"stdClass"')); - $this->error .= strstr($parts[$this->cgi], 'O:8:"stdClass"', true); - if (!$this->info) { - throw new \Exception("Unable to detect PHP version (output: $output)."); - - } elseif ($this->info->phpDbgVersion && version_compare($this->info->version, '7.0.0', '<')) { - throw new \Exception('Unable to use phpdbg on PHP < 7.0.0.'); - - } elseif ($this->cgi && $this->error) { - $this->error .= "\n(note that PHP CLI generates better error messages)"; - } - } - - - /** - * @return static - */ - public function withPhpIniOption(string $name, string $value = null): self - { - $me = clone $this; - $me->commandLine .= ' -d ' . Helpers::escapeArg($name . ($value === null ? '' : "=$value")); - return $me; - } - - - public function getCommandLine(): string - { - return $this->commandLine; - } - - - public function getVersion(): string - { - return $this->info->version; - } - - - public function getCodeCoverageEngines(): array - { - return $this->info->codeCoverageEngines; - } - - - public function isCgi(): bool - { - return $this->cgi; - } - - - public function getStartupError(): string - { - return $this->error; - } - - - public function getShortInfo(): string - { - return "PHP {$this->info->version} ({$this->info->sapi})" - . ($this->info->phpDbgVersion ? "; PHPDBG {$this->info->phpDbgVersion}" : ''); - } - - - public function hasExtension(string $name): bool - { - return in_array(strtolower($name), array_map('strtolower', $this->info->extensions), true); - } -} diff --git a/vendor/nette/tester/src/Runner/Runner.php b/vendor/nette/tester/src/Runner/Runner.php deleted file mode 100644 index 77575ed6a07e0b11d48e376a9cdc2037c7a5ba10..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/Runner/Runner.php +++ /dev/null @@ -1,298 +0,0 @@ -<?php - -/** - * This file is part of the Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -namespace Tester\Runner; - -use Tester\Environment; - - -/** - * Test runner. - */ -class Runner -{ - /** @var string[] paths to test files/directories */ - public $paths = []; - - /** @var string[] */ - public $ignoreDirs = ['vendor']; - - /** @var int run in parallel threads */ - public $threadCount = 1; - - /** @var TestHandler */ - public $testHandler; - - /** @var OutputHandler[] */ - public $outputHandlers = []; - - /** @var bool */ - public $stopOnFail = false; - - /** @var PhpInterpreter */ - private $interpreter; - - /** @var array */ - private $envVars = []; - - /** @var Job[] */ - private $jobs; - - /** @var bool */ - private $interrupted = false; - - /** @var string|null */ - private $tempDir; - - /** @var bool */ - private $result; - - /** @var array */ - private $lastResults = []; - - - public function __construct(PhpInterpreter $interpreter) - { - $this->interpreter = $interpreter; - $this->testHandler = new TestHandler($this); - } - - - public function setEnvironmentVariable(string $name, string $value): void - { - $this->envVars[$name] = $value; - } - - - public function getEnvironmentVariables(): array - { - return $this->envVars; - } - - - public function addPhpIniOption(string $name, string $value = null): void - { - $this->interpreter = $this->interpreter->withPhpIniOption($name, $value); - } - - - public function setTempDirectory(?string $path): void - { - if ($path !== null) { - if (!is_dir($path) || !is_writable($path)) { - throw new \RuntimeException("Path '$path' is not a writable directory."); - } - - $path = realpath($path) . DIRECTORY_SEPARATOR . 'Tester'; - if (!is_dir($path) && @mkdir($path) === false && !is_dir($path)) { // @ - directory may exist - throw new \RuntimeException("Cannot create '$path' directory."); - } - } - - $this->tempDir = $path; - $this->testHandler->setTempDirectory($path); - } - - - /** - * Runs all tests. - */ - public function run(): bool - { - $this->result = true; - $this->interrupted = false; - - foreach ($this->outputHandlers as $handler) { - $handler->begin(); - } - - $this->jobs = $running = []; - foreach ($this->paths as $path) { - $this->findTests($path); - } - - if ($this->tempDir) { - usort($this->jobs, function (Job $a, Job $b): int { - return $this->getLastResult($a->getTest()) - $this->getLastResult($b->getTest()); - }); - } - - $threads = range(1, $this->threadCount); - - $this->installInterruptHandler(); - $async = $this->threadCount > 1 && count($this->jobs) > 1; - - while (($this->jobs || $running) && !$this->isInterrupted()) { - while ($threads && $this->jobs) { - $running[] = $job = array_shift($this->jobs); - $job->setEnvironmentVariable(Environment::THREAD, (string) array_shift($threads)); - $job->run($async ? $job::RUN_ASYNC : 0); - } - - if ($async) { - usleep(Job::RUN_USLEEP); // stream_select() doesn't work with proc_open() - } - - foreach ($running as $key => $job) { - if ($this->isInterrupted()) { - break 2; - } - - if (!$job->isRunning()) { - $threads[] = $job->getEnvironmentVariable(Environment::THREAD); - $this->testHandler->assess($job); - unset($running[$key]); - } - } - } - $this->removeInterruptHandler(); - - foreach ($this->outputHandlers as $handler) { - $handler->end(); - } - - return $this->result; - } - - - private function findTests(string $path): void - { - if (strpbrk($path, '*?') === false && !file_exists($path)) { - throw new \InvalidArgumentException("File or directory '$path' not found."); - } - - if (is_dir($path)) { - foreach (glob(str_replace('[', '[[]', $path) . '/*', GLOB_ONLYDIR) ?: [] as $dir) { - if (in_array(basename($dir), $this->ignoreDirs, true)) { - continue; - } - $this->findTests($dir); - } - - $this->findTests($path . '/*.phpt'); - $this->findTests($path . '/*Test.php'); - - } else { - foreach (glob(str_replace('[', '[[]', $path)) ?: [] as $file) { - if (is_file($file)) { - $this->testHandler->initiate(realpath($file)); - } - } - } - } - - - /** - * Appends new job to queue. - */ - public function addJob(Job $job): void - { - $this->jobs[] = $job; - } - - - public function prepareTest(Test $test): void - { - foreach ($this->outputHandlers as $handler) { - $handler->prepare($test); - } - } - - - /** - * Writes to output handlers. - */ - public function finishTest(Test $test): void - { - $this->result = $this->result && ($test->getResult() !== Test::FAILED); - - foreach ($this->outputHandlers as $handler) { - $handler->finish($test); - } - - if ($this->tempDir) { - $lastResult = &$this->lastResults[$test->getSignature()]; - if ($lastResult !== $test->getResult()) { - file_put_contents($this->getLastResultFilename($test), $lastResult = $test->getResult()); - } - } - - if ($this->stopOnFail && $test->getResult() === Test::FAILED) { - $this->interrupted = true; - } - } - - - public function getInterpreter(): PhpInterpreter - { - return $this->interpreter; - } - - - private function installInterruptHandler(): void - { - if (function_exists('pcntl_signal')) { - pcntl_signal(SIGINT, function (): void { - pcntl_signal(SIGINT, SIG_DFL); - $this->interrupted = true; - }); - } elseif (function_exists('sapi_windows_set_ctrl_handler') && PHP_SAPI === 'cli') { - sapi_windows_set_ctrl_handler(function () { - $this->interrupted = true; - }); - } - } - - - private function removeInterruptHandler(): void - { - if (function_exists('pcntl_signal')) { - pcntl_signal(SIGINT, SIG_DFL); - } elseif (function_exists('sapi_windows_set_ctrl_handler') && PHP_SAPI === 'cli') { - sapi_windows_set_ctrl_handler(null); - } - } - - - private function isInterrupted(): bool - { - if (function_exists('pcntl_signal_dispatch')) { - pcntl_signal_dispatch(); - } - - return $this->interrupted; - } - - - private function getLastResult(Test $test): int - { - $signature = $test->getSignature(); - if (isset($this->lastResults[$signature])) { - return $this->lastResults[$signature]; - } - - $file = $this->getLastResultFilename($test); - if (is_file($file)) { - return $this->lastResults[$signature] = (int) file_get_contents($file); - } - - return $this->lastResults[$signature] = Test::PREPARED; - } - - - private function getLastResultFilename(Test $test): string - { - return $this->tempDir - . DIRECTORY_SEPARATOR - . pathinfo($test->getFile(), PATHINFO_FILENAME) - . '.' - . substr(md5($test->getSignature()), 0, 5) - . '.result'; - } -} diff --git a/vendor/nette/tester/src/Runner/Test.php b/vendor/nette/tester/src/Runner/Test.php deleted file mode 100644 index 530a0ed00560d5357a68b546833596005fea5c21..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/Runner/Test.php +++ /dev/null @@ -1,138 +0,0 @@ -<?php - -/** - * This file is part of the Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -namespace Tester\Runner; - - -/** - * Test represents one result. - */ -class Test -{ - public const - PREPARED = 0, - FAILED = 1, - PASSED = 2, - SKIPPED = 3; - - /** @var string|null */ - public $title; - - /** @var string|null */ - public $message; - - /** @var string */ - public $stdout = ''; - - /** @var string */ - public $stderr = ''; - - /** @var string */ - private $file; - - /** @var int */ - private $result = self::PREPARED; - - /** @var float|null */ - private $duration; - - /** @var string[]|string[][] */ - private $args = []; - - - public function __construct(string $file, string $title = null) - { - $this->file = $file; - $this->title = $title; - } - - - public function getFile(): string - { - return $this->file; - } - - - /** - * @return string[]|string[][] - */ - public function getArguments(): array - { - return $this->args; - } - - - public function getSignature(): string - { - $args = implode(' ', array_map(function ($arg): string { - return is_array($arg) ? "$arg[0]=$arg[1]" : $arg; - }, $this->args)); - - return $this->file . ($args ? " $args" : ''); - } - - - public function getResult(): int - { - return $this->result; - } - - - public function hasResult(): bool - { - return $this->result !== self::PREPARED; - } - - - /** - * Duration in seconds. - */ - public function getDuration(): ?float - { - return $this->duration; - } - - - /** - * @return static - */ - public function withArguments(array $args): self - { - if ($this->hasResult()) { - throw new \LogicException('Cannot change arguments of test which already has a result.'); - } - - $me = clone $this; - foreach ($args as $name => $values) { - foreach ((array) $values as $value) { - $me->args[] = is_int($name) - ? "$value" - : [$name, "$value"]; - } - } - return $me; - } - - - /** - * @return static - */ - public function withResult(int $result, ?string $message, float $duration = null): self - { - if ($this->hasResult()) { - throw new \LogicException("Result of test is already set to $this->result with message '$this->message'."); - } - - $me = clone $this; - $me->result = $result; - $me->message = $message; - $me->duration = $duration; - return $me; - } -} diff --git a/vendor/nette/tester/src/Runner/TestHandler.php b/vendor/nette/tester/src/Runner/TestHandler.php deleted file mode 100644 index bb344578bd05ece3578101cf3c2d01e636da7643..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/Runner/TestHandler.php +++ /dev/null @@ -1,293 +0,0 @@ -<?php - -/** - * This file is part of the Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -namespace Tester\Runner; - -use Tester; -use Tester\Dumper; -use Tester\Helpers; -use Tester\TestCase; - - -/** - * Default test behavior. - */ -class TestHandler -{ - private const HTTP_OK = 200; - - /** @var Runner */ - private $runner; - - /** @var string|null */ - private $tempDir; - - - public function __construct(Runner $runner) - { - $this->runner = $runner; - } - - - public function setTempDirectory(?string $path): void - { - $this->tempDir = $path; - } - - - public function initiate(string $file): void - { - [$annotations, $title] = $this->getAnnotations($file); - $php = $this->runner->getInterpreter(); - - $tests = [new Test($file, $title)]; - foreach (get_class_methods($this) as $method) { - if (!preg_match('#^initiate(.+)#', strtolower($method), $m) || !isset($annotations[$m[1]])) { - continue; - } - - foreach ((array) $annotations[$m[1]] as $value) { - /** @var Test[] $prepared */ - $prepared = []; - foreach ($tests as $test) { - $res = $this->$method($test, $value, $php); - if ($res === null) { - $prepared[] = $test; - } else { - foreach (is_array($res) ? $res : [$res] as $testVariety) { - /** @var Test $testVariety */ - if ($testVariety->hasResult()) { - $this->runner->prepareTest($testVariety); - $this->runner->finishTest($testVariety); - } else { - $prepared[] = $testVariety; - } - } - } - } - $tests = $prepared; - } - } - - foreach ($tests as $test) { - $this->runner->prepareTest($test); - $this->runner->addJob(new Job($test, $php, $this->runner->getEnvironmentVariables())); - } - } - - - public function assess(Job $job): void - { - $test = $job->getTest(); - $annotations = $this->getAnnotations($test->getFile())[0] += [ - 'exitcode' => Job::CODE_OK, - 'httpcode' => self::HTTP_OK, - ]; - - foreach (get_class_methods($this) as $method) { - if (!preg_match('#^assess(.+)#', strtolower($method), $m) || !isset($annotations[$m[1]])) { - continue; - } - - foreach ((array) $annotations[$m[1]] as $arg) { - /** @var Test|null $res */ - if ($res = $this->$method($job, $arg)) { - $this->runner->finishTest($res); - return; - } - } - } - $this->runner->finishTest($test->withResult(Test::PASSED, $test->message, $job->getDuration())); - } - - - private function initiateSkip(Test $test, string $message): Test - { - return $test->withResult(Test::SKIPPED, $message); - } - - - private function initiatePhpVersion(Test $test, string $version, PhpInterpreter $interpreter): ?Test - { - if (preg_match('#^(<=|<|==|=|!=|<>|>=|>)?\s*(.+)#', $version, $matches) - && version_compare($matches[2], $interpreter->getVersion(), $matches[1] ?: '>=')) { - return $test->withResult(Test::SKIPPED, "Requires PHP $version."); - } - return null; - } - - - private function initiatePhpExtension(Test $test, string $value, PhpInterpreter $interpreter): ?Test - { - foreach (preg_split('#[\s,]+#', $value) as $extension) { - if (!$interpreter->hasExtension($extension)) { - return $test->withResult(Test::SKIPPED, "Requires PHP extension $extension."); - } - } - return null; - } - - - private function initiatePhpIni(Test $test, string $pair, PhpInterpreter &$interpreter): void - { - [$name, $value] = explode('=', $pair, 2) + [1 => null]; - $interpreter = $interpreter->withPhpIniOption($name, $value); - } - - - private function initiateDataProvider(Test $test, string $provider) - { - try { - [$dataFile, $query, $optional] = Tester\DataProvider::parseAnnotation($provider, $test->getFile()); - $data = Tester\DataProvider::load($dataFile, $query); - if (count($data) < 1) { - throw new \Exception("No records in data provider file '{$test->getFile()}'" . ($query ? " for query '$query'" : '') . '.'); - } - - } catch (\Exception $e) { - return $test->withResult(empty($optional) ? Test::FAILED : Test::SKIPPED, $e->getMessage()); - } - - return array_map(function (string $item) use ($test, $dataFile): Test { - return $test->withArguments(['dataprovider' => "$item|$dataFile"]); - }, array_keys($data)); - } - - - private function initiateMultiple(Test $test, $count): array - { - return array_map(function (int $i) use ($test): Test { - return $test->withArguments(['multiple' => $i]); - }, range(0, (int) $count - 1)); - } - - - private function initiateTestCase(Test $test, $foo, PhpInterpreter $interpreter) - { - $methods = null; - - if ($this->tempDir) { - $cacheFile = $this->tempDir . DIRECTORY_SEPARATOR . 'TestHandler.testCase.' . substr(md5($test->getSignature()), 0, 5) . '.list'; - if (is_file($cacheFile)) { - $cache = unserialize(file_get_contents($cacheFile)); - - $valid = true; - foreach ($cache['files'] as $path => $mTime) { - if (!is_file($path) || filemtime($path) !== $mTime) { - $valid = false; - break; - } - } - if ($valid) { - $methods = $cache['methods']; - } - } - } - - if ($methods === null) { - $job = new Job($test->withArguments(['method' => TestCase::LIST_METHODS]), $interpreter, $this->runner->getEnvironmentVariables()); - $job->run(); - - if (in_array($job->getExitCode(), [Job::CODE_ERROR, Job::CODE_FAIL, Job::CODE_SKIP], true)) { - return $test->withResult($job->getExitCode() === Job::CODE_SKIP ? Test::SKIPPED : Test::FAILED, $job->getTest()->stdout); - } - - $stdout = $job->getTest()->stdout; - - if (!preg_match('#^TestCase:([^\n]+)$#m', $stdout, $m)) { - return $test->withResult(Test::FAILED, "Cannot list TestCase methods in file '{$test->getFile()}'. Do you call TestCase::run() in it?"); - } - $testCaseClass = $m[1]; - - preg_match_all('#^Method:([^\n]+)$#m', $stdout, $m); - if (count($m[1]) < 1) { - return $test->withResult(Test::SKIPPED, "Class $testCaseClass in file '{$test->getFile()}' does not contain test methods."); - } - $methods = $m[1]; - - if ($this->tempDir) { - preg_match_all('#^Dependency:([^\n]+)$#m', $stdout, $m); - file_put_contents($cacheFile, serialize([ - 'methods' => $methods, - 'files' => array_combine($m[1], array_map('filemtime', $m[1])), - ])); - } - } - - return array_map(function (string $method) use ($test): Test { - return $test->withArguments(['method' => $method]); - }, $methods); - } - - - private function assessExitCode(Job $job, $code): ?Test - { - $code = (int) $code; - if ($job->getExitCode() === Job::CODE_SKIP) { - $message = preg_match('#.*Skipped:\n(.*?)$#Ds', $output = $job->getTest()->stdout, $m) - ? $m[1] - : $output; - return $job->getTest()->withResult(Test::SKIPPED, trim($message)); - - } elseif ($job->getExitCode() !== $code) { - $message = $job->getExitCode() !== Job::CODE_FAIL - ? "Exited with error code {$job->getExitCode()} (expected $code)" - : ''; - return $job->getTest()->withResult(Test::FAILED, trim($message . "\n" . $job->getTest()->stdout)); - } - return null; - } - - - private function assessHttpCode(Job $job, $code): ?Test - { - if (!$this->runner->getInterpreter()->isCgi()) { - return null; - } - $headers = $job->getHeaders(); - $actual = (int) ($headers['Status'] ?? self::HTTP_OK); - $code = (int) $code; - return $code && $code !== $actual - ? $job->getTest()->withResult(Test::FAILED, "Exited with HTTP code $actual (expected $code)") - : null; - } - - - private function assessOutputMatchFile(Job $job, string $file): ?Test - { - $file = dirname($job->getTest()->getFile()) . DIRECTORY_SEPARATOR . $file; - if (!is_file($file)) { - return $job->getTest()->withResult(Test::FAILED, "Missing matching file '$file'."); - } - return $this->assessOutputMatch($job, file_get_contents($file)); - } - - - private function assessOutputMatch(Job $job, string $content): ?Test - { - $actual = $job->getTest()->stdout; - if (!Tester\Assert::isMatching($content, $actual)) { - [$content, $actual] = Tester\Assert::expandMatchingPatterns($content, $actual); - Dumper::saveOutput($job->getTest()->getFile(), $actual, '.actual'); - Dumper::saveOutput($job->getTest()->getFile(), $content, '.expected'); - return $job->getTest()->withResult(Test::FAILED, 'Failed: output should match ' . Dumper::toLine($content)); - } - return null; - } - - - private function getAnnotations(string $file): array - { - $annotations = Helpers::parseDocComment(file_get_contents($file)); - $testTitle = isset($annotations[0]) - ? preg_replace('#^TEST:\s*#i', '', $annotations[0]) - : null; - return [$annotations, $testTitle]; - } -} diff --git a/vendor/nette/tester/src/Runner/info.php b/vendor/nette/tester/src/Runner/info.php deleted file mode 100644 index a2c2b01270bee101ea75837f78f36ca467640eb6..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/Runner/info.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php - -/** - * @internal - */ - -declare(strict_types=1); - -require __DIR__ . '/../CodeCoverage/Collector.php'; - -$isPhpDbg = defined('PHPDBG_VERSION'); -$extensions = get_loaded_extensions(); -natcasesort($extensions); - -$info = (object) [ - 'binary' => defined('PHP_BINARY') ? PHP_BINARY : null, - 'version' => PHP_VERSION, - 'phpDbgVersion' => $isPhpDbg ? PHPDBG_VERSION : null, - 'sapi' => PHP_SAPI, - 'iniFiles' => array_merge( - ($tmp = php_ini_loaded_file()) === false ? [] : [$tmp], - (function_exists('php_ini_scanned_files') && strlen($tmp = (string) php_ini_scanned_files())) ? explode(",\n", trim($tmp)) : [] - ), - 'extensions' => $extensions, - 'tempDir' => sys_get_temp_dir(), - 'codeCoverageEngines' => Tester\CodeCoverage\Collector::detectEngines(), -]; - -if (isset($_SERVER['argv'][1])) { - echo serialize($info); - die(); -} - -foreach ([ - 'PHP binary' => $info->binary ?: '(not available)', - 'PHP version' . ($isPhpDbg ? '; PHPDBG version' : '') - => "$info->version ($info->sapi)" . ($isPhpDbg ? "; $info->phpDbgVersion" : ''), - 'Loaded php.ini files' => count($info->iniFiles) ? implode(', ', $info->iniFiles) : '(none)', - 'Code coverage engines' => count($info->codeCoverageEngines) - ? implode(', ', array_map(function (array $engineInfo) { return sprintf('%s (%s)', ...$engineInfo); }, $info->codeCoverageEngines)) - : '(not available)', - 'PHP temporary directory' => $info->tempDir == '' ? '(empty)' : $info->tempDir, - 'Loaded extensions' => count($info->extensions) ? implode(', ', $info->extensions) : '(none)', -] as $title => $value) { - echo "\e[1;32m$title\e[0m:\n$value\n\n"; -} diff --git a/vendor/nette/tester/src/bootstrap.php b/vendor/nette/tester/src/bootstrap.php deleted file mode 100644 index 065a4c7e94f75adcaa0b2a44040a61e186434c4f..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/bootstrap.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php - -/** - * Test environment initialization. - */ - -declare(strict_types=1); - -require __DIR__ . '/Framework/Helpers.php'; -require __DIR__ . '/Framework/Environment.php'; -require __DIR__ . '/Framework/DataProvider.php'; -require __DIR__ . '/Framework/Assert.php'; -require __DIR__ . '/Framework/AssertException.php'; -require __DIR__ . '/Framework/Dumper.php'; -require __DIR__ . '/Framework/FileMock.php'; -require __DIR__ . '/Framework/TestCase.php'; -require __DIR__ . '/Framework/FileMutator.php'; -require __DIR__ . '/Framework/Expect.php'; -require __DIR__ . '/CodeCoverage/Collector.php'; -require __DIR__ . '/Runner/Job.php'; - -if (extension_loaded('libxml') && extension_loaded('SimpleXML')) { - require __DIR__ . '/Framework/DomQuery.php'; -} else { - spl_autoload_register(function (string $class): void { - if ($class === Tester\DomQuery::class) { - throw new LogicException('Tester\DomQuery requires libxml and SimpleXML extensions to be loaded.'); - } - }); -} - -Tester\Environment::setup(); diff --git a/vendor/nette/tester/src/tester b/vendor/nette/tester/src/tester deleted file mode 100755 index df82f19d5f77bb4e035375ac11b255d324281584..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/tester +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env php -<?php - -declare(strict_types=1); - -require __DIR__ . '/tester.php'; \ No newline at end of file diff --git a/vendor/nette/tester/src/tester.php b/vendor/nette/tester/src/tester.php deleted file mode 100644 index abc43105308da7c987eb634bb7260aec35c73400..0000000000000000000000000000000000000000 --- a/vendor/nette/tester/src/tester.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -/** - * Nette Tester. - * Copyright (c) 2009 David Grudl (https://davidgrudl.com) - */ - -declare(strict_types=1); - -require __DIR__ . '/Runner/Test.php'; -require __DIR__ . '/Runner/PhpInterpreter.php'; -require __DIR__ . '/Runner/Runner.php'; -require __DIR__ . '/Runner/CliTester.php'; -require __DIR__ . '/Runner/Job.php'; -require __DIR__ . '/Runner/CommandLine.php'; -require __DIR__ . '/Runner/TestHandler.php'; -require __DIR__ . '/Runner/OutputHandler.php'; -require __DIR__ . '/Runner/Output/Logger.php'; -require __DIR__ . '/Runner/Output/TapPrinter.php'; -require __DIR__ . '/Runner/Output/ConsolePrinter.php'; -require __DIR__ . '/Runner/Output/JUnitPrinter.php'; -require __DIR__ . '/Framework/Helpers.php'; -require __DIR__ . '/Framework/Environment.php'; -require __DIR__ . '/Framework/Assert.php'; -require __DIR__ . '/Framework/AssertException.php'; -require __DIR__ . '/Framework/Dumper.php'; -require __DIR__ . '/Framework/DataProvider.php'; -require __DIR__ . '/Framework/TestCase.php'; -require __DIR__ . '/CodeCoverage/Collector.php'; -require __DIR__ . '/CodeCoverage/PhpParser.php'; -require __DIR__ . '/CodeCoverage/Generators/AbstractGenerator.php'; -require __DIR__ . '/CodeCoverage/Generators/HtmlGenerator.php'; -require __DIR__ . '/CodeCoverage/Generators/CloverXMLGenerator.php'; - - -die((new Tester\Runner\CliTester)->run()); diff --git a/vendor/phpstan/phpstan/LICENSE b/vendor/phpstan/phpstan/LICENSE deleted file mode 100644 index 7c0f2b7b69aca1efda6b984195c267a65f8a3d4b..0000000000000000000000000000000000000000 --- a/vendor/phpstan/phpstan/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2016 OndΕej Mirtes - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/phpstan/phpstan/README.md b/vendor/phpstan/phpstan/README.md deleted file mode 100644 index d25e48edf6a54c4dd2217f18f6774d47ffe4c79a..0000000000000000000000000000000000000000 --- a/vendor/phpstan/phpstan/README.md +++ /dev/null @@ -1,95 +0,0 @@ -<h1 align="center">PHPStan - PHP Static Analysis Tool</h1> - -<p align="center"> - <img src="https://i.imgur.com/WaRKPlC.png" alt="PHPStan" width="300" height="300"> -</p> - -<p align="center"> - <a href="https://github.com/phpstan/phpstan/actions"><img src="https://github.com/phpstan/phpstan/workflows/Tests/badge.svg" alt="Build Status"></a> - <a href="https://packagist.org/packages/phpstan/phpstan"><img src="https://poser.pugx.org/phpstan/phpstan/v/stable" alt="Latest Stable Version"></a> - <a href="https://packagist.org/packages/phpstan/phpstan/stats"><img src="https://poser.pugx.org/phpstan/phpstan/downloads" alt="Total Downloads"></a> - <a href="https://choosealicense.com/licenses/mit/"><img src="https://poser.pugx.org/phpstan/phpstan/license" alt="License"></a> - <a href="https://phpstan.org/"><img src="https://img.shields.io/badge/PHPStan-enabled-brightgreen.svg?style=flat" alt="PHPStan Enabled"></a> -</p> - ------- - -PHPStan focuses on finding errors in your code without actually running it. It catches whole classes of bugs -even before you write tests for the code. It moves PHP closer to compiled languages in the sense that the correctness of each line of the code -can be checked before you run the actual line. - -**[Read more about PHPStan in an introductory article Β»](https://phpstan.org/blog/find-bugs-in-your-code-without-writing-tests)** - -**[Try out PHPStan on the on-line playground! Β»](https://phpstan.org/)** - -## Sponsors - -<a href="https://coders.thecodingmachine.com/phpstan"><img src="https://i.imgur.com/kQhNOTP.png" alt="TheCodingMachine" width="247" height="64"></a> - -<a href="https://packagist.com/?utm_source=phpstan&utm_medium=readme&utm_campaign=sponsorlogo"><img src="https://i.imgur.com/PmMC45f.png" alt="Private Packagist" width="326" height="64"></a> -<br> -<a href="https://careers.tuigroup.com/jobs/"><img src="https://i.imgur.com/uw5rAlR.png" alt="Musement" width="247" height="49"></a> - -<a href="https://blackfire.io/docs/introduction?utm_source=phpstan&utm_medium=github_readme&utm_campaign=logo"><img src="https://i.imgur.com/zR8rsqk.png" alt="Blackfire.io" width="254" height="64"></a> -<br> -<a href="https://www.iodigital.com/"><img src="https://i.imgur.com/fJlw1n9.png" alt="iO" width="254" height="65"></a> - -<a href="https://jobs.ticketswap.com/"><img src="https://i.imgur.com/lhzcutK.png" alt="TicketSwap" width="269" height="64"></a> -<br> -<a href="https://www.startupjobs.cz/startup/shipmonk"><img src="https://i.imgur.com/bAC47za.jpg" alt="ShipMonk" width="290" height="64"></a> - -<a href="https://togetter.com/"><img src="https://i.imgur.com/x9n5cj3.png" alt="Togetter" width="283" height="64"></a> -<br> -<a href="https://join.rightcapital.com/?utm_source=phpstan&utm_medium=github&utm_campaign=sponsorship"><img src="https://i.imgur.com/1AhB5tW.png" alt="RightCapital" width="283" height="64"></a> - -<a href="https://www.contentkingapp.com/?ref=php-developer&utm_source=phpstan&utm_medium=referral&utm_campaign=sponsorship"><img src="https://i.imgur.com/0blm7ki.png" alt="ContentKing" width="283" height="64"></a> -<br> -<a href="https://zol.fr?utm_source=phpstan"><img src="https://i.imgur.com/dzDgd4s.png" alt="ZOL" width="283" height="64"></a> - -<a href="https://kocourek.uk/"><img src="https://i.imgur.com/EX29z98.png" alt="Stepan Kocourek" width="294" height="64"></a> -<br> -<a href="https://www.shopware.com/en/"><img src="https://i.imgur.com/L4X5w9s.png" alt="Shopware" width="284" height="64"></a> - -<a href="https://craftcms.com/"><img src="https://i.imgur.com/xJWThke.png" alt="Craft CMS" width="283" height="64"></a> -<br> -<a href="https://www.worksome.com/"><img src="https://i.imgur.com/TQKSwOl.png" alt="Worksome" width="283" height="64"></a> - -<a href="https://www.campoint.net/"><img src="https://i.imgur.com/fR6eMUm.png" alt="campoint AG" width="283" height="64"></a> - -[**You can now sponsor my open-source work on PHPStan through GitHub Sponsors.**](https://github.com/sponsors/ondrejmirtes) - -Does GitHub already have your π³? Do you use PHPStan to find π before they reach production? [Send a couple of πΈ a month my way too.](https://github.com/sponsors/ondrejmirtes) Thank you! - -One-time donations [through PayPal](https://paypal.me/phpstan) are also accepted. To request an invoice, [contact me](mailto:ondrej@mirtes.cz) through e-mail. - -## Documentation - -All the documentation lives on the [phpstan.org website](https://phpstan.org/): - -* [Getting Started & User Guide](https://phpstan.org/user-guide/getting-started) -* [Config Reference](https://phpstan.org/config-reference) -* [PHPDocs Basics](https://phpstan.org/writing-php-code/phpdocs-basics) & [PHPDoc Types](https://phpstan.org/writing-php-code/phpdoc-types) -* [Extension Library](https://phpstan.org/user-guide/extension-library) -* [Developing Extensions](https://phpstan.org/developing-extensions/extension-types) - -## PHPStan Pro - -PHPStan Pro is a paid add-on on top of open-source PHPStan Static Analysis Tool with these premium features: - -* Web UI for browsing found errors, you can click and open your editor of choice on the offending line. -* Continuous analysis (watch mode): scans changed files in the background, refreshes the UI automatically. -* Interactive fixer: lets you choose the right fix for found errors :blush: - -Try it on PHPStan 0.12.45 or later by running it with the `--pro` option. You can create an account either by following the on-screen instructions, or by visiting [account.phpstan.com](https://account.phpstan.com/). - -After 30-day free trial period it costs 7 EUR for individuals monthly, 70 EUR for teams (up to 25 members). By paying for PHPStan Pro, you're supporting the development of open-source PHPStan. - -You can read more about it on [PHPStan's website](https://phpstan.org/blog/introducing-phpstan-pro). - -## Code of Conduct - -This project adheres to a [Contributor Code of Conduct](https://github.com/phpstan/phpstan/blob/master/CODE_OF_CONDUCT.md). By participating in this project and its community, you are expected to uphold this code. - -## Contributing - -Any contributions are welcome. PHPStan's source code open to pull requests lives at [`phpstan/phpstan-src`](https://github.com/phpstan/phpstan-src). diff --git a/vendor/phpstan/phpstan/bootstrap.php b/vendor/phpstan/phpstan/bootstrap.php deleted file mode 100644 index e8b94316740a152077d20e0a32f3be0aef196cec..0000000000000000000000000000000000000000 --- a/vendor/phpstan/phpstan/bootstrap.php +++ /dev/null @@ -1,60 +0,0 @@ -<?php declare(strict_types = 1); - -namespace PHPStan; - -use Composer\Autoload\ClassLoader; - -final class PharAutoloader -{ - /** @var ClassLoader */ - private static $composerAutoloader; - - final public static function loadClass(string $class): void { - if (!extension_loaded('phar') || defined('__PHPSTAN_RUNNING__')) { - return; - } - - if (strpos($class, '_PHPStan_') === 0) { - if (!in_array('phar', stream_get_wrappers(), true)) { - throw new \Exception('Phar wrapper is not registered. Please review your php.ini settings.'); - } - - if (self::$composerAutoloader === null) { - self::$composerAutoloader = require 'phar://' . __DIR__ . '/phpstan.phar/vendor/autoload.php'; - require_once 'phar://' . __DIR__ . '/phpstan.phar/vendor/clue/block-react/src/functions_include.php'; - require_once 'phar://' . __DIR__ . '/phpstan.phar/vendor/jetbrains/phpstorm-stubs/PhpStormStubsMap.php'; - require_once 'phar://' . __DIR__ . '/phpstan.phar/vendor/react/promise-stream/src/functions_include.php'; - require_once 'phar://' . __DIR__ . '/phpstan.phar/vendor/react/promise-timer/src/functions_include.php'; - require_once 'phar://' . __DIR__ . '/phpstan.phar/vendor/react/promise/src/functions_include.php'; - require_once 'phar://' . __DIR__ . '/phpstan.phar/vendor/ringcentral/psr7/src/functions_include.php'; - } - self::$composerAutoloader->loadClass($class); - - return; - } - if (strpos($class, 'PHPStan\\') !== 0 || strpos($class, 'PHPStan\\PhpDocParser\\') === 0) { - return; - } - - if (!in_array('phar', stream_get_wrappers(), true)) { - throw new \Exception('Phar wrapper is not registered. Please review your php.ini settings.'); - } - - $filename = str_replace('\\', DIRECTORY_SEPARATOR, $class); - if (strpos($class, 'PHPStan\\BetterReflection\\') === 0) { - $filename = substr($filename, strlen('PHPStan\\BetterReflection\\')); - $filepath = 'phar://' . __DIR__ . '/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/' . $filename . '.php'; - } else { - $filename = substr($filename, strlen('PHPStan\\')); - $filepath = 'phar://' . __DIR__ . '/phpstan.phar/src/' . $filename . '.php'; - } - - if (!file_exists($filepath)) { - return; - } - - require $filepath; - } -} - -spl_autoload_register([PharAutoloader::class, 'loadClass']); diff --git a/vendor/phpstan/phpstan/composer.json b/vendor/phpstan/phpstan/composer.json deleted file mode 100644 index 6197ce2efb8905d0c3387acde988da8b948fc703..0000000000000000000000000000000000000000 --- a/vendor/phpstan/phpstan/composer.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "phpstan/phpstan", - "description": "PHPStan - PHP Static Analysis Tool", - "license": ["MIT"], - "require": { - "php": "^7.1|^8.0" - }, - "conflict": { - "phpstan/phpstan-shim": "*" - }, - "bin": [ - "phpstan", - "phpstan.phar" - ], - "autoload": { - "files": ["bootstrap.php"] - } -} diff --git a/vendor/phpstan/phpstan/conf/bleedingEdge.neon b/vendor/phpstan/phpstan/conf/bleedingEdge.neon deleted file mode 100644 index 01fee972d8275f95fd38b96584bbba21e828bb5a..0000000000000000000000000000000000000000 --- a/vendor/phpstan/phpstan/conf/bleedingEdge.neon +++ /dev/null @@ -1,2 +0,0 @@ -includes: - - phar://phpstan.phar/conf/bleedingEdge.neon diff --git a/vendor/phpstan/phpstan/phpstan b/vendor/phpstan/phpstan/phpstan deleted file mode 100755 index 7a08ef4850ba9d4649f4ff7430c4e35f1cb9e455..0000000000000000000000000000000000000000 --- a/vendor/phpstan/phpstan/phpstan +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env php -<?php - -declare (strict_types=1); - -Phar::loadPhar(__DIR__ . '/phpstan.phar', 'phpstan.phar'); - -require 'phar://phpstan.phar/bin/phpstan'; diff --git a/vendor/phpstan/phpstan/phpstan.phar b/vendor/phpstan/phpstan/phpstan.phar deleted file mode 100755 index ad0c68992a0147a7aafdc2c407764a387b179f89..0000000000000000000000000000000000000000 Binary files a/vendor/phpstan/phpstan/phpstan.phar and /dev/null differ diff --git a/vendor/phpstan/phpstan/phpstan.phar.asc b/vendor/phpstan/phpstan/phpstan.phar.asc deleted file mode 100644 index 5e11d15f8c2d347f6be974eccb253229f9a26507..0000000000000000000000000000000000000000 --- a/vendor/phpstan/phpstan/phpstan.phar.asc +++ /dev/null @@ -1,16 +0,0 @@ ------BEGIN PGP SIGNATURE----- - -iQIzBAABCgAdFiEE0yaA1ZV9xxFr4pwUzxoQjQ565yAFAmIvGCgACgkQzxoQjQ56 -5yBvhQ//UNjM/7FsVH251YxVvGT4EV+mK+mOz0ZT2hPpHinamTTCeeYnRg/tU8QF -zlX7+OuIC+2wrPBKU0lKqfz6EzE0Q56uVjewvMZk02RvGCw1Op4/f0SMMr1aHB73 -wSP6YQjyocLlIKRwMdRNGKWb9UFedfw6WGMQaQlQD4luKmHHYWPsmXQGFo8LVEdz -P7wiby67MDWmP5FEVEahUM/emMH8vkoyrvL2BRkVsAQ6+TAfGUOA55McyH7ntMGM -FpTzIp73FDZMSeXCTX4vQKGkKvI3UJWtbWKpf2fAQUBN/C5B2guTNAYR1NropzDQ -Fv96i5hdH3qaHxB9IsVBsX78dp0mqpA8HXn9fQ4UY8VUroDuU+Bc8gylq8TJ5X8C -gprKpfcvmJaDe3F0Jj4Z/BIk4Qot18c/InlOyY8iG79nCjyYoRzDPrChu3i4o5fl -3FqhRuBUPrJN6oNlTOxHcMNNn4+J4fl6P7H8DJ8Ei19m8HnGhyfJXpB7VFhrYgSQ -rYWf3cPtDcIgf6EteTbj0iLdNsq86ilSD4Pex5kQMjNNyGo3uScRIuFLVAWUd8nT -KUTJRczchud5bRRUpTta8jnCPlcqHQT/lgN4+twVzwLQ1+NFeaA8uFslM+b64p/Q -7b7jUZNJZmVo4R4IcnYBoUDND7CvZd0iIuTcCJpU7dFFLY+o5ZE= -=j9X5 ------END PGP SIGNATURE-----