diff --git a/composer.json b/composer.json index 0c5e3a4..4c3e814 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "require": { "php": ">=5.3.2", - "utrust/utrust": "1.0.4" + "utrust/utrust": "1.1.0" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 68fbe46..625d75d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c6d4f6f5d15df434fff5fb97f1c24d7b", + "content-hash": "80f108e3720bf3618089d110b3682dc4", "packages": [ { "name": "utrust/utrust", - "version": "v1.0.4", + "version": "v1.1.0", "source": { "type": "git", "url": "https://github.com/utrustdev/utrust-php.git", - "reference": "9303e697b87cabe462b1607e0e5029df96c7637f" + "reference": "8a64390ec1a5486aeee69cd8b3ee2bb691dec3f1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utrustdev/utrust-php/zipball/9303e697b87cabe462b1607e0e5029df96c7637f", - "reference": "9303e697b87cabe462b1607e0e5029df96c7637f", + "url": "https://api.github.com/repos/utrustdev/utrust-php/zipball/8a64390ec1a5486aeee69cd8b3ee2bb691dec3f1", + "reference": "8a64390ec1a5486aeee69cd8b3ee2bb691dec3f1", "shasum": "" }, "require": { @@ -45,7 +45,11 @@ } ], "description": "Utrust API library", - "time": "2020-07-13T15:02:10+00:00" + "support": { + "issues": "https://github.com/utrustdev/utrust-php/issues", + "source": "https://github.com/utrustdev/utrust-php/tree/v1.1.0" + }, + "time": "2023-09-19T09:33:12+00:00" }, { "name": "vlucas/valitron", @@ -106,5 +110,6 @@ "platform": { "php": ">=5.3.2" }, - "platform-dev": [] + "platform-dev": [], + "plugin-api-version": "2.3.0" } diff --git a/vendor/autoload.php b/vendor/autoload.php index fff258e..84020db 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -2,6 +2,24 @@ // autoload.php @generated by Composer +if (PHP_VERSION_ID < 50600) { + if (!headers_sent()) { + header('HTTP/1.1 500 Internal Server Error'); + } + $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL; + if (!ini_get('display_errors')) { + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { + fwrite(STDERR, $err); + } elseif (!headers_sent()) { + echo $err; + } + } + trigger_error( + $err, + E_USER_ERROR + ); +} + require_once __DIR__ . '/composer/autoload_real.php'; return ComposerAutoloaderInit1615abfcb9deb7462fa804a81956eb41::getLoader(); diff --git a/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php index fce8549..a72151c 100644 --- a/vendor/composer/ClassLoader.php +++ b/vendor/composer/ClassLoader.php @@ -37,57 +37,134 @@ * * @author Fabien Potencier * @author Jordi Boggiano - * @see http://www.php-fig.org/psr/psr-0/ - * @see http://www.php-fig.org/psr/psr-4/ + * @see https://www.php-fig.org/psr/psr-0/ + * @see https://www.php-fig.org/psr/psr-4/ */ class ClassLoader { + /** @var \Closure(string):void */ + private static $includeFile; + + /** @var ?string */ + private $vendorDir; + // PSR-4 + /** + * @var array[] + * @psalm-var array> + */ private $prefixLengthsPsr4 = array(); + /** + * @var array[] + * @psalm-var array> + */ private $prefixDirsPsr4 = array(); + /** + * @var array[] + * @psalm-var array + */ private $fallbackDirsPsr4 = array(); // PSR-0 + /** + * @var array[] + * @psalm-var array> + */ private $prefixesPsr0 = array(); + /** + * @var array[] + * @psalm-var array + */ private $fallbackDirsPsr0 = array(); + /** @var bool */ private $useIncludePath = false; + + /** + * @var string[] + * @psalm-var array + */ private $classMap = array(); + + /** @var bool */ private $classMapAuthoritative = false; + + /** + * @var bool[] + * @psalm-var array + */ private $missingClasses = array(); + + /** @var ?string */ private $apcuPrefix; + /** + * @var self[] + */ + private static $registeredLoaders = array(); + + /** + * @param ?string $vendorDir + */ + public function __construct($vendorDir = null) + { + $this->vendorDir = $vendorDir; + self::initializeIncludeClosure(); + } + + /** + * @return string[] + */ public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); } + /** + * @return array[] + * @psalm-return array> + */ public function getPrefixesPsr4() { return $this->prefixDirsPsr4; } + /** + * @return array[] + * @psalm-return array + */ public function getFallbackDirs() { return $this->fallbackDirsPsr0; } + /** + * @return array[] + * @psalm-return array + */ public function getFallbackDirsPsr4() { return $this->fallbackDirsPsr4; } + /** + * @return string[] Array of classname => path + * @psalm-return array + */ public function getClassMap() { return $this->classMap; } /** - * @param array $classMap Class to filename map + * @param string[] $classMap Class to filename map + * @psalm-param array $classMap + * + * @return void */ public function addClassMap(array $classMap) { @@ -102,9 +179,11 @@ public function addClassMap(array $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 array|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories + * @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) { @@ -147,11 +226,13 @@ public function add($prefix, $paths, $prepend = false) * 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 array|string $paths The PSR-4 base directories - * @param bool $prepend Whether to prepend the directories + * @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) { @@ -195,8 +276,10 @@ public function addPsr4($prefix, $paths, $prepend = false) * 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 array|string $paths The PSR-0 base directories + * @param string $prefix The prefix + * @param string[]|string $paths The PSR-0 base directories + * + * @return void */ public function set($prefix, $paths) { @@ -211,10 +294,12 @@ public function set($prefix, $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 array|string $paths The PSR-4 base directories + * @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) { @@ -234,6 +319,8 @@ public function setPsr4($prefix, $paths) * Turns on searching the include path for class files. * * @param bool $useIncludePath + * + * @return void */ public function setUseIncludePath($useIncludePath) { @@ -256,6 +343,8 @@ public function getUseIncludePath() * that have not been registered with the class map. * * @param bool $classMapAuthoritative + * + * @return void */ public function setClassMapAuthoritative($classMapAuthoritative) { @@ -276,6 +365,8 @@ public function isClassMapAuthoritative() * 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) { @@ -296,33 +387,55 @@ public function getApcuPrefix() * 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 bool|null True if loaded, null otherwise + * @return true|null True if loaded, null otherwise */ public function loadClass($class) { if ($file = $this->findFile($class)) { - includeFile($file); + $includeFile = self::$includeFile; + $includeFile($file); return true; } + + return null; } /** @@ -367,6 +480,21 @@ public function findFile($class) 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 @@ -432,14 +560,26 @@ private function findFileWithExtension($class, $ext) return false; } -} -/** - * Scope isolated include. - * - * Prevents access to $this/self from included files. - */ -function includeFile($file) -{ - include $file; + /** + * @return void + */ + private static function initializeIncludeClosure() + { + if (self::$includeFile !== null) { + return; + } + + /** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + * + * @param string $file + * @return void + */ + self::$includeFile = \Closure::bind(static function($file) { + include $file; + }, null, null); + } } diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php new file mode 100644 index 0000000..51e734a --- /dev/null +++ b/vendor/composer/InstalledVersions.php @@ -0,0 +1,359 @@ + + * Jordi Boggiano + * + * 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` + * + * @final + */ +class InstalledVersions +{ + /** + * @var mixed[]|null + * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array}|array{}|null + */ + private static $installed; + + /** + * @var bool|null + */ + private static $canGetVendors; + + /** + * @var array[] + * @psalm-var array}> + */ + 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 + */ + 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 + */ + 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 || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false; + } + } + + 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((string) $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, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool} + */ + 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, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} + */ + 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}> + */ + 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, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $data + */ + public static function reload($data) + { + self::$installed = $data; + self::$installedByVendor = array(); + } + + /** + * @return array[] + * @psalm-return list}> + */ + 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')) { + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require $vendorDir.'/composer/installed.php'; + $installed[] = self::$installedByVendor[$vendorDir] = $required; + 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') { + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require __DIR__ . '/installed.php'; + self::$installed = $required; + } else { + self::$installed = array(); + } + } + + if (self::$installed !== array()) { + $installed[] = self::$installed; + } + + return $installed; + } +} diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 7a91153..0fb0a2c 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -2,8 +2,9 @@ // autoload_classmap.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( + 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', ); diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php index b7fc012..15a2ff3 100644 --- a/vendor/composer/autoload_namespaces.php +++ b/vendor/composer/autoload_namespaces.php @@ -2,7 +2,7 @@ // autoload_namespaces.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index 5ce7200..53a1a53 100644 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -2,7 +2,7 @@ // autoload_psr4.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 78d4841..83d8881 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -13,37 +13,23 @@ public static function loadClassLoader($class) } } + /** + * @return \Composer\Autoload\ClassLoader + */ public static function getLoader() { if (null !== self::$loader) { return self::$loader; } + require __DIR__ . '/platform_check.php'; + spl_autoload_register(array('ComposerAutoloaderInit1615abfcb9deb7462fa804a81956eb41', 'loadClassLoader'), true, true); - self::$loader = $loader = new \Composer\Autoload\ClassLoader(); + self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); spl_autoload_unregister(array('ComposerAutoloaderInit1615abfcb9deb7462fa804a81956eb41', 'loadClassLoader')); - $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); - if ($useStaticLoader) { - require_once __DIR__ . '/autoload_static.php'; - - call_user_func(\Composer\Autoload\ComposerStaticInit1615abfcb9deb7462fa804a81956eb41::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); - } - } + require __DIR__ . '/autoload_static.php'; + call_user_func(\Composer\Autoload\ComposerStaticInit1615abfcb9deb7462fa804a81956eb41::getInitializer($loader)); $loader->register(true); diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 130de56..b5a9305 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -33,11 +33,16 @@ class ComposerStaticInit1615abfcb9deb7462fa804a81956eb41 ), ); + public static $classMap = array ( + 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', + ); + public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { $loader->prefixLengthsPsr4 = ComposerStaticInit1615abfcb9deb7462fa804a81956eb41::$prefixLengthsPsr4; $loader->prefixDirsPsr4 = ComposerStaticInit1615abfcb9deb7462fa804a81956eb41::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit1615abfcb9deb7462fa804a81956eb41::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 4898de5..48f53c8 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -1,96 +1,106 @@ -[ - { - "name": "utrust/utrust", - "version": "v1.0.4", - "version_normalized": "1.0.4.0", - "source": { - "type": "git", - "url": "https://github.com/utrustdev/utrust-php.git", - "reference": "9303e697b87cabe462b1607e0e5029df96c7637f" +{ + "packages": [ + { + "name": "utrust/utrust", + "version": "v1.1.0", + "version_normalized": "1.1.0.0", + "source": { + "type": "git", + "url": "https://github.com/utrustdev/utrust-php.git", + "reference": "8a64390ec1a5486aeee69cd8b3ee2bb691dec3f1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/utrustdev/utrust-php/zipball/8a64390ec1a5486aeee69cd8b3ee2bb691dec3f1", + "reference": "8a64390ec1a5486aeee69cd8b3ee2bb691dec3f1", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "vlucas/valitron": "^1.4.7" + }, + "require-dev": { + "phpunit/phpunit": "^8", + "squizlabs/php_codesniffer": "*" + }, + "time": "2023-09-19T09:33:12+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Utrust\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-3.0-or-later" + ], + "authors": [ + { + "name": "Utrust Team", + "email": "team@utrust.com" + } + ], + "description": "Utrust API library", + "support": { + "issues": "https://github.com/utrustdev/utrust-php/issues", + "source": "https://github.com/utrustdev/utrust-php/tree/v1.1.0" + }, + "install-path": "../utrust/utrust" }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/utrustdev/utrust-php/zipball/9303e697b87cabe462b1607e0e5029df96c7637f", - "reference": "9303e697b87cabe462b1607e0e5029df96c7637f", - "shasum": "" - }, - "require": { - "php": ">=5.3.0", - "vlucas/valitron": "^1.4.7" - }, - "require-dev": { - "phpunit/phpunit": "^8", - "squizlabs/php_codesniffer": "*" - }, - "time": "2020-07-13T15:02:10+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-4": { - "Utrust\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-3.0-or-later" - ], - "authors": [ - { - "name": "Utrust Team", - "email": "team@utrust.com" - } - ], - "description": "Utrust API library" - }, - { - "name": "vlucas/valitron", - "version": "v1.4.7", - "version_normalized": "1.4.7.0", - "source": { - "type": "git", - "url": "https://github.com/vlucas/valitron.git", - "reference": "a03072bed1679660200766d134507a30193eaf6d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/vlucas/valitron/zipball/a03072bed1679660200766d134507a30193eaf6d", - "reference": "a03072bed1679660200766d134507a30193eaf6d", - "shasum": "" - }, - "require": { - "php": ">=5.3.2" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.5 || ^6.5" - }, - "suggest": { - "ext-mbstring": "It can support the multiple bytes string length." - }, - "time": "2019-08-29T19:49:43+00:00", - "type": "library", - "installation-source": "source", - "autoload": { - "psr-4": { - "Valitron\\": "src/Valitron" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Vance Lucas", - "email": "vance@vancelucas.com", - "homepage": "http://www.vancelucas.com" - } - ], - "description": "Simple, elegant, stand-alone validation library with NO dependencies", - "homepage": "http://github.com/vlucas/valitron", - "keywords": [ - "valid", - "validation", - "validator" - ] - } -] + { + "name": "vlucas/valitron", + "version": "v1.4.7", + "version_normalized": "1.4.7.0", + "source": { + "type": "git", + "url": "https://github.com/vlucas/valitron.git", + "reference": "a03072bed1679660200766d134507a30193eaf6d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/vlucas/valitron/zipball/a03072bed1679660200766d134507a30193eaf6d", + "reference": "a03072bed1679660200766d134507a30193eaf6d", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.5 || ^6.5" + }, + "suggest": { + "ext-mbstring": "It can support the multiple bytes string length." + }, + "time": "2019-08-29T19:49:43+00:00", + "type": "library", + "installation-source": "source", + "autoload": { + "psr-4": { + "Valitron\\": "src/Valitron" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Vance Lucas", + "email": "vance@vancelucas.com", + "homepage": "http://www.vancelucas.com" + } + ], + "description": "Simple, elegant, stand-alone validation library with NO dependencies", + "homepage": "http://github.com/vlucas/valitron", + "keywords": [ + "valid", + "validation", + "validator" + ], + "install-path": "../vlucas/valitron" + } + ], + "dev": true, + "dev-package-names": [] +} diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php new file mode 100644 index 0000000..ab0bf44 --- /dev/null +++ b/vendor/composer/installed.php @@ -0,0 +1,41 @@ + array( + 'name' => '__root__', + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'reference' => '7441ac8e4ae99b26ee57212bae660e38209fd231', + 'type' => 'library', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'dev' => true, + ), + 'versions' => array( + '__root__' => array( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'reference' => '7441ac8e4ae99b26ee57212bae660e38209fd231', + 'type' => 'library', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'utrust/utrust' => array( + 'pretty_version' => 'v1.1.0', + 'version' => '1.1.0.0', + 'reference' => '8a64390ec1a5486aeee69cd8b3ee2bb691dec3f1', + 'type' => 'library', + 'install_path' => __DIR__ . '/../utrust/utrust', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'vlucas/valitron' => array( + 'pretty_version' => 'v1.4.7', + 'version' => '1.4.7.0', + 'reference' => 'a03072bed1679660200766d134507a30193eaf6d', + 'type' => 'library', + 'install_path' => __DIR__ . '/../vlucas/valitron', + 'aliases' => array(), + 'dev_requirement' => false, + ), + ), +); diff --git a/vendor/composer/platform_check.php b/vendor/composer/platform_check.php new file mode 100644 index 0000000..60cb1be --- /dev/null +++ b/vendor/composer/platform_check.php @@ -0,0 +1,26 @@ += 50302)) { + $issues[] = 'Your Composer dependencies require a PHP version ">= 5.3.2". 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/utrust/utrust/README.md b/vendor/utrust/utrust/README.md index 3bcac34..4e5b2aa 100644 --- a/vendor/utrust/utrust/README.md +++ b/vendor/utrust/utrust/README.md @@ -24,17 +24,18 @@ Creating a new Order: ```php use Utrust\ApiClient; -use Utrust\Store\Customer; -use Utrust\Store\Order; -$order = new Order([...]); -$customer = new Customer([...]); +$utrustApi = new ApiClient('API_KEY'); -$utrust_api = new ApiClient('API_KEY'); -$response = $utrust_api->createOrder($order, $customer); +$orderData = [...]; +$customerData = [...]; + +$response = $utrustApi->createOrder($orderData, $customerData); echo $response->attributes->redirect_url; ``` +Check the full example [here](https://github.com/utrustdev/utrust-php/blob/master/examples/create_simple_order.php). + ### Validations The `Validator` class can be used to check your data array before passing it to the API Client. @@ -117,4 +118,4 @@ Utrust PHP is maintained with :purple_heart: by the Utrust development team, and is available to the public under the GNU GPLv3 license. Please see [LICENSE](https://github.com/utrustdev/utrust-php/blob/master/LICENSE) for further details. -© Utrust 2019 +© Utrust 2020 diff --git a/vendor/utrust/utrust/examples/create_simple_order.php b/vendor/utrust/utrust/examples/create_simple_order.php index 8a042ea..3bfd086 100644 --- a/vendor/utrust/utrust/examples/create_simple_order.php +++ b/vendor/utrust/utrust/examples/create_simple_order.php @@ -24,15 +24,6 @@ 'cancel_url' => 'http://example.com/order_canceled', 'callback_url' => 'http://example.com/webhook_url', ], - 'line_items' => [ - [ - 'sku' => 'tshirt-1234', - 'name' => 'T-shirt', - 'price' => '10.00', - 'currency' => 'EUR', - 'quantity' => 1, - ], - ], ]; // Build Customer data array diff --git a/vendor/utrust/utrust/src/ApiClient.php b/vendor/utrust/utrust/src/ApiClient.php index d94c987..1bd4bb8 100644 --- a/vendor/utrust/utrust/src/ApiClient.php +++ b/vendor/utrust/utrust/src/ApiClient.php @@ -1,8 +1,8 @@ [ ['amount.details'], @@ -64,6 +59,11 @@ public function order($data) ['amount.details.tax'], ['amount.details.shipping'], ['amount.details.discount'], + ['line_items'], + ['line_items.*.name'], + ['line_items.*.price'], + ['line_items.*.currency'], + ['line_items.*.quantity'], ['line_items.*.sku'], ['return_urls.cancel_url'], ['return_urls.callback_url'], diff --git a/vendor/utrust/utrust/src/Webhook/Event.php b/vendor/utrust/utrust/src/Webhook/Event.php index e0c1be9..01b4260 100644 --- a/vendor/utrust/utrust/src/Webhook/Event.php +++ b/vendor/utrust/utrust/src/Webhook/Event.php @@ -20,6 +20,16 @@ public function __construct($payload) throw new \Exception('Event_type is missing on the payload.' . print_r($this->payload, true)); } + // Make sure it has amount + if (!isset($this->payload->resource->amount)) { + throw new \Exception('Amount is missing on the payload.' . print_r($this->payload, true)); + } + + // Make sure it has currency + if (!isset($this->payload->resource->currency)) { + throw new \Exception('Currency is missing on the payload.' . print_r($this->payload, true)); + } + // Make sure it has reference if (!isset($this->payload->resource->reference)) { throw new \Exception('Reference is missing on the payload.' . print_r($this->payload, true)); @@ -36,6 +46,26 @@ public function getEventType() return $this->payload->event_type; } + /** + * Gets Order amount + * + * @return string Order amount. + */ + public function getOrderAmount() + { + return $this->payload->resource->amount; + } + + /** + * + * Gets Order currency + * @return string Order currency. + */ + public function getOrderCurrency() + { + return $this->payload->resource->currency; + } + /** * Gets Order Reference data * diff --git a/vendor/utrust/utrust/tests/ValidatorTest.php b/vendor/utrust/utrust/tests/ValidatorTest.php index 698b63c..0f47f8d 100644 --- a/vendor/utrust/utrust/tests/ValidatorTest.php +++ b/vendor/utrust/utrust/tests/ValidatorTest.php @@ -51,15 +51,7 @@ public function testValidOrder(): void 'cancel_url' => 'http://example.com/order_canceled', 'callback_url' => 'http://example.com/webhook_url', ], - 'line_items' => [ - [ - 'sku' => 'tshirt-1234', - 'name' => 'T-shirt', - 'price' => '10.00', - 'currency' => 'EUR', - 'quantity' => 1, - ], - ], + ]; $result = Validator::order($validOrderData); @@ -78,30 +70,10 @@ public function testInvalidOrder(): void 'return_url' => 'http://example.com/order_success', 'cancel_url' => 'example.com/this-is-not-a-correct-url', ], - 'line_items' => [ - [ - 'sku' => 'tshirt-1234', - 'quantity' => 'this-is-not-an-integer', - ], - ], ]; $expected_errors_message = print_r([ "reference" => ["Reference is required"], - "line_items.*.name" => [ - "Line Items.*.name is required", - ], - "line_items.*.price" => [ - "Line Items.*.price is required", - ], - "line_items.*.currency" => [ - "Line Items.*.currency is required", - "Line Items.*.currency contains invalid characters", - ], - "line_items.*.quantity" => [ - - "Line Items.*.quantity must be an integer", - ], "amount.currency" => [ "Amount.currency contains invalid characters", ], diff --git a/vendor/utrust/utrust/tests/WebhookTest.php b/vendor/utrust/utrust/tests/WebhookTest.php index a94d31f..0560fca 100644 --- a/vendor/utrust/utrust/tests/WebhookTest.php +++ b/vendor/utrust/utrust/tests/WebhookTest.php @@ -25,6 +25,26 @@ public function testInvalidPayloadMissingEventType(): void $event = new Event($invalidPayload); } + public function testInvalidPayloadMissingAmount(): void + { + $invalidPayload = "{ \"event_type\": \"ORDER.PAYMENT.CANCELLED\", \"resource\": { \"currency\": \"EUR\", \"reference\": \"REF-12345678\" }, \"signature\": \"bb32374545004b5f4a1264a8e8e78e3357e27a35a8a3b334fe1a2a47b60a35ba\", \"state\": \"cancelled\" }"; + + $this->expectException(Exception::class); + $this->expectExceptionMessage('Amount is missing on the payload.'); + + $event = new Event($invalidPayload); + } + + public function testInvalidPayloadMissingCurrency(): void + { + $invalidPayload = "{ \"event_type\": \"ORDER.PAYMENT.CANCELLED\", \"resource\": { \"amount\": \"0.99\", \"reference\": \"REF-12345678\" }, \"signature\": \"bb32374545004b5f4a1264a8e8e78e3357e27a35a8a3b334fe1a2a47b60a35ba\", \"state\": \"cancelled\" }"; + + $this->expectException(Exception::class); + $this->expectExceptionMessage('Currency is missing on the payload.'); + + $event = new Event($invalidPayload); + } + public function testInvalidPayloadMissingReference(): void { $invalidPayload = "{ \"event_type\": \"ORDER.PAYMENT.CANCELLED\", \"resource\": { \"amount\": \"0.99\", \"currency\": \"EUR\" }, \"signature\": \"1234-this-is-an-invalid-signature-1234\", \"state\": \"cancelled\" }";