primo commit

This commit is contained in:
2024-12-17 17:34:10 +01:00
commit e650f8df99
16435 changed files with 2451012 additions and 0 deletions

View File

@ -0,0 +1,25 @@
<?php
// 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 ComposerAutoloaderInit8353287fecf50ac51479a9e39297831c::getLoader();

View File

@ -0,0 +1,579 @@
<?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 \Closure(string):void */
private static $includeFile;
/** @var string|null */
private $vendorDir;
// PSR-4
/**
* @var array<string, array<string, int>>
*/
private $prefixLengthsPsr4 = array();
/**
* @var array<string, list<string>>
*/
private $prefixDirsPsr4 = array();
/**
* @var list<string>
*/
private $fallbackDirsPsr4 = array();
// PSR-0
/**
* List of PSR-0 prefixes
*
* Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
*
* @var array<string, array<string, list<string>>>
*/
private $prefixesPsr0 = array();
/**
* @var list<string>
*/
private $fallbackDirsPsr0 = array();
/** @var bool */
private $useIncludePath = false;
/**
* @var array<string, string>
*/
private $classMap = array();
/** @var bool */
private $classMapAuthoritative = false;
/**
* @var array<string, bool>
*/
private $missingClasses = array();
/** @var string|null */
private $apcuPrefix;
/**
* @var array<string, self>
*/
private static $registeredLoaders = array();
/**
* @param string|null $vendorDir
*/
public function __construct($vendorDir = null)
{
$this->vendorDir = $vendorDir;
self::initializeIncludeClosure();
}
/**
* @return array<string, list<string>>
*/
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
}
return array();
}
/**
* @return array<string, list<string>>
*/
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
/**
* @return list<string>
*/
public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}
/**
* @return list<string>
*/
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
/**
* @return array<string, string> Array of classname => path
*/
public function getClassMap()
{
return $this->classMap;
}
/**
* @param array<string, string> $classMap Class to filename map
*
* @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 list<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)
{
$paths = (array) $paths;
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
$paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
$paths
);
}
return;
}
$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = $paths;
return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
$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 list<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)
{
$paths = (array) $paths;
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
$paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
$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] = $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
$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 list<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 list<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 = self::$includeFile;
$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 keyed by their corresponding vendor directories.
*
* @return array<string, 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;
}
/**
* @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);
}
}

View File

@ -0,0 +1,313 @@
<?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 RegularLabs\Scoped\Composer;
use RegularLabs\Scoped\Composer\Autoload\ClassLoader;
use RegularLabs\Scoped\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<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
*/
private static $installed;
/**
* @var bool|null
*/
private static $canGetVendors;
/**
* @var array[]
* @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: 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 || !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<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: 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, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: 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, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data
*/
public static function reload($data)
{
self::$installed = $data;
self::$installedByVendor = array();
}
/**
* @return array[]
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
*/
private static function getInstalled()
{
if (null === self::$canGetVendors) {
self::$canGetVendors = method_exists('RegularLabs\Scoped\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<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $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<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
$required = require __DIR__ . '/installed.php';
self::$installed = $required;
} else {
self::$installed = array();
}
}
if (self::$installed !== array()) {
$installed[] = self::$installed;
}
return $installed;
}
}

View File

@ -0,0 +1,21 @@
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.

View File

@ -0,0 +1,213 @@
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
'RegularLabs\\Scoped\\DeepCopy\\DeepCopy' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/DeepCopy.php',
'RegularLabs\\Scoped\\DeepCopy\\Exception\\CloneException' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/Exception/CloneException.php',
'RegularLabs\\Scoped\\DeepCopy\\Exception\\PropertyException' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/Exception/PropertyException.php',
'RegularLabs\\Scoped\\DeepCopy\\Filter\\ChainableFilter' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/Filter/ChainableFilter.php',
'RegularLabs\\Scoped\\DeepCopy\\Filter\\Doctrine\\DoctrineCollectionFilter' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/Filter/Doctrine/DoctrineCollectionFilter.php',
'RegularLabs\\Scoped\\DeepCopy\\Filter\\Doctrine\\DoctrineEmptyCollectionFilter' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/Filter/Doctrine/DoctrineEmptyCollectionFilter.php',
'RegularLabs\\Scoped\\DeepCopy\\Filter\\Doctrine\\DoctrineProxyFilter' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/Filter/Doctrine/DoctrineProxyFilter.php',
'RegularLabs\\Scoped\\DeepCopy\\Filter\\Filter' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/Filter/Filter.php',
'RegularLabs\\Scoped\\DeepCopy\\Filter\\KeepFilter' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/Filter/KeepFilter.php',
'RegularLabs\\Scoped\\DeepCopy\\Filter\\ReplaceFilter' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/Filter/ReplaceFilter.php',
'RegularLabs\\Scoped\\DeepCopy\\Filter\\SetNullFilter' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/Filter/SetNullFilter.php',
'RegularLabs\\Scoped\\DeepCopy\\Matcher\\Doctrine\\DoctrineProxyMatcher' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/Matcher/Doctrine/DoctrineProxyMatcher.php',
'RegularLabs\\Scoped\\DeepCopy\\Matcher\\Matcher' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/Matcher/Matcher.php',
'RegularLabs\\Scoped\\DeepCopy\\Matcher\\PropertyMatcher' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/Matcher/PropertyMatcher.php',
'RegularLabs\\Scoped\\DeepCopy\\Matcher\\PropertyNameMatcher' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/Matcher/PropertyNameMatcher.php',
'RegularLabs\\Scoped\\DeepCopy\\Matcher\\PropertyTypeMatcher' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/Matcher/PropertyTypeMatcher.php',
'RegularLabs\\Scoped\\DeepCopy\\Reflection\\ReflectionHelper' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/Reflection/ReflectionHelper.php',
'RegularLabs\\Scoped\\DeepCopy\\TypeFilter\\Date\\DateIntervalFilter' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/TypeFilter/Date/DateIntervalFilter.php',
'RegularLabs\\Scoped\\DeepCopy\\TypeFilter\\ReplaceFilter' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/TypeFilter/ReplaceFilter.php',
'RegularLabs\\Scoped\\DeepCopy\\TypeFilter\\ShallowCopyFilter' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/TypeFilter/ShallowCopyFilter.php',
'RegularLabs\\Scoped\\DeepCopy\\TypeFilter\\Spl\\ArrayObjectFilter' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/TypeFilter/Spl/ArrayObjectFilter.php',
'RegularLabs\\Scoped\\DeepCopy\\TypeFilter\\Spl\\SplDoublyLinkedList' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/TypeFilter/Spl/SplDoublyLinkedList.php',
'RegularLabs\\Scoped\\DeepCopy\\TypeFilter\\Spl\\SplDoublyLinkedListFilter' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/TypeFilter/Spl/SplDoublyLinkedListFilter.php',
'RegularLabs\\Scoped\\DeepCopy\\TypeFilter\\TypeFilter' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/TypeFilter/TypeFilter.php',
'RegularLabs\\Scoped\\DeepCopy\\TypeMatcher\\TypeMatcher' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/TypeMatcher/TypeMatcher.php',
'RegularLabs\\Scoped\\Detection\\Cache\\Cache' => $vendorDir . '/mobiledetect/mobiledetectlib/src/Cache/Cache.php',
'RegularLabs\\Scoped\\Detection\\Cache\\CacheException' => $vendorDir . '/mobiledetect/mobiledetectlib/src/Cache/CacheException.php',
'RegularLabs\\Scoped\\Detection\\Cache\\CacheItem' => $vendorDir . '/mobiledetect/mobiledetectlib/src/Cache/CacheItem.php',
'RegularLabs\\Scoped\\Detection\\Exception\\MobileDetectException' => $vendorDir . '/mobiledetect/mobiledetectlib/src/Exception/MobileDetectException.php',
'RegularLabs\\Scoped\\Detection\\MobileDetect' => $vendorDir . '/mobiledetect/mobiledetectlib/src/MobileDetect.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\AppendStream' => $vendorDir . '/guzzlehttp/psr7/src/AppendStream.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\BufferStream' => $vendorDir . '/guzzlehttp/psr7/src/BufferStream.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\CachingStream' => $vendorDir . '/guzzlehttp/psr7/src/CachingStream.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\DroppingStream' => $vendorDir . '/guzzlehttp/psr7/src/DroppingStream.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\Exception\\MalformedUriException' => $vendorDir . '/guzzlehttp/psr7/src/Exception/MalformedUriException.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\FnStream' => $vendorDir . '/guzzlehttp/psr7/src/FnStream.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\Header' => $vendorDir . '/guzzlehttp/psr7/src/Header.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\HttpFactory' => $vendorDir . '/guzzlehttp/psr7/src/HttpFactory.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\InflateStream' => $vendorDir . '/guzzlehttp/psr7/src/InflateStream.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\LazyOpenStream' => $vendorDir . '/guzzlehttp/psr7/src/LazyOpenStream.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\LimitStream' => $vendorDir . '/guzzlehttp/psr7/src/LimitStream.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\Message' => $vendorDir . '/guzzlehttp/psr7/src/Message.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\MessageTrait' => $vendorDir . '/guzzlehttp/psr7/src/MessageTrait.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\MimeType' => $vendorDir . '/guzzlehttp/psr7/src/MimeType.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\MultipartStream' => $vendorDir . '/guzzlehttp/psr7/src/MultipartStream.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\NoSeekStream' => $vendorDir . '/guzzlehttp/psr7/src/NoSeekStream.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\PumpStream' => $vendorDir . '/guzzlehttp/psr7/src/PumpStream.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\Query' => $vendorDir . '/guzzlehttp/psr7/src/Query.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\Request' => $vendorDir . '/guzzlehttp/psr7/src/Request.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\Response' => $vendorDir . '/guzzlehttp/psr7/src/Response.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\Rfc7230' => $vendorDir . '/guzzlehttp/psr7/src/Rfc7230.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\ServerRequest' => $vendorDir . '/guzzlehttp/psr7/src/ServerRequest.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\Stream' => $vendorDir . '/guzzlehttp/psr7/src/Stream.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\StreamDecoratorTrait' => $vendorDir . '/guzzlehttp/psr7/src/StreamDecoratorTrait.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\StreamWrapper' => $vendorDir . '/guzzlehttp/psr7/src/StreamWrapper.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\UploadedFile' => $vendorDir . '/guzzlehttp/psr7/src/UploadedFile.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\Uri' => $vendorDir . '/guzzlehttp/psr7/src/Uri.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\UriComparator' => $vendorDir . '/guzzlehttp/psr7/src/UriComparator.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\UriNormalizer' => $vendorDir . '/guzzlehttp/psr7/src/UriNormalizer.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\UriResolver' => $vendorDir . '/guzzlehttp/psr7/src/UriResolver.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\Utils' => $vendorDir . '/guzzlehttp/psr7/src/Utils.php',
'RegularLabs\\Scoped\\Intervention\\Image\\AbstractColor' => $vendorDir . '/intervention/image/src/Intervention/Image/AbstractColor.php',
'RegularLabs\\Scoped\\Intervention\\Image\\AbstractDecoder' => $vendorDir . '/intervention/image/src/Intervention/Image/AbstractDecoder.php',
'RegularLabs\\Scoped\\Intervention\\Image\\AbstractDriver' => $vendorDir . '/intervention/image/src/Intervention/Image/AbstractDriver.php',
'RegularLabs\\Scoped\\Intervention\\Image\\AbstractEncoder' => $vendorDir . '/intervention/image/src/Intervention/Image/AbstractEncoder.php',
'RegularLabs\\Scoped\\Intervention\\Image\\AbstractFont' => $vendorDir . '/intervention/image/src/Intervention/Image/AbstractFont.php',
'RegularLabs\\Scoped\\Intervention\\Image\\AbstractShape' => $vendorDir . '/intervention/image/src/Intervention/Image/AbstractShape.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\AbstractCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Commands/AbstractCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\Argument' => $vendorDir . '/intervention/image/src/Intervention/Image/Commands/Argument.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\ChecksumCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Commands/ChecksumCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\CircleCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Commands/CircleCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\EllipseCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Commands/EllipseCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\ExifCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Commands/ExifCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\IptcCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Commands/IptcCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\LineCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Commands/LineCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\OrientateCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Commands/OrientateCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\PolygonCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Commands/PolygonCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\PsrResponseCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Commands/PsrResponseCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\RectangleCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Commands/RectangleCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\ResponseCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Commands/ResponseCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\StreamCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Commands/StreamCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\TextCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Commands/TextCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Constraint' => $vendorDir . '/intervention/image/src/Intervention/Image/Constraint.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Exception\\ImageException' => $vendorDir . '/intervention/image/src/Intervention/Image/Exception/ImageException.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Exception\\InvalidArgumentException' => $vendorDir . '/intervention/image/src/Intervention/Image/Exception/InvalidArgumentException.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Exception\\MissingDependencyException' => $vendorDir . '/intervention/image/src/Intervention/Image/Exception/MissingDependencyException.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Exception\\NotFoundException' => $vendorDir . '/intervention/image/src/Intervention/Image/Exception/NotFoundException.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Exception\\NotReadableException' => $vendorDir . '/intervention/image/src/Intervention/Image/Exception/NotReadableException.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Exception\\NotSupportedException' => $vendorDir . '/intervention/image/src/Intervention/Image/Exception/NotSupportedException.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Exception\\NotWritableException' => $vendorDir . '/intervention/image/src/Intervention/Image/Exception/NotWritableException.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Exception\\RuntimeException' => $vendorDir . '/intervention/image/src/Intervention/Image/Exception/RuntimeException.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Facades\\Image' => $vendorDir . '/intervention/image/src/Intervention/Image/Facades/Image.php',
'RegularLabs\\Scoped\\Intervention\\Image\\File' => $vendorDir . '/intervention/image/src/Intervention/Image/File.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Filters\\DemoFilter' => $vendorDir . '/intervention/image/src/Intervention/Image/Filters/DemoFilter.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Filters\\FilterInterface' => $vendorDir . '/intervention/image/src/Intervention/Image/Filters/FilterInterface.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Color' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Color.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\BackupCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/BackupCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\BlurCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/BlurCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\BrightnessCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/BrightnessCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\ColorizeCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/ColorizeCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\ContrastCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/ContrastCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\CropCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/CropCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\DestroyCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/DestroyCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\FillCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/FillCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\FitCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/FitCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\FlipCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/FlipCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\GammaCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/GammaCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\GetSizeCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/GetSizeCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\GreyscaleCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/GreyscaleCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\HeightenCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/HeightenCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\InsertCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/InsertCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\InterlaceCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/InterlaceCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\InvertCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/InvertCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\LimitColorsCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/LimitColorsCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\MaskCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/MaskCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\OpacityCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/OpacityCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\PickColorCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/PickColorCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\PixelCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/PixelCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\PixelateCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/PixelateCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\ResetCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/ResetCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\ResizeCanvasCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/ResizeCanvasCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\ResizeCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/ResizeCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\RotateCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/RotateCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\SharpenCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/SharpenCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\TrimCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/TrimCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\WidenCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Commands/WidenCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Decoder' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Decoder.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Driver' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Driver.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Encoder' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Encoder.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Font' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Font.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Shapes\\CircleShape' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Shapes/CircleShape.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Shapes\\EllipseShape' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Shapes/EllipseShape.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Shapes\\LineShape' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Shapes/LineShape.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Shapes\\PolygonShape' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Shapes/PolygonShape.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Shapes\\RectangleShape' => $vendorDir . '/intervention/image/src/Intervention/Image/Gd/Shapes/RectangleShape.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Image' => $vendorDir . '/intervention/image/src/Intervention/Image/Image.php',
'RegularLabs\\Scoped\\Intervention\\Image\\ImageManager' => $vendorDir . '/intervention/image/src/Intervention/Image/ImageManager.php',
'RegularLabs\\Scoped\\Intervention\\Image\\ImageManagerStatic' => $vendorDir . '/intervention/image/src/Intervention/Image/ImageManagerStatic.php',
'RegularLabs\\Scoped\\Intervention\\Image\\ImageServiceProvider' => $vendorDir . '/intervention/image/src/Intervention/Image/ImageServiceProvider.php',
'RegularLabs\\Scoped\\Intervention\\Image\\ImageServiceProviderLaravel4' => $vendorDir . '/intervention/image/src/Intervention/Image/ImageServiceProviderLaravel4.php',
'RegularLabs\\Scoped\\Intervention\\Image\\ImageServiceProviderLaravelRecent' => $vendorDir . '/intervention/image/src/Intervention/Image/ImageServiceProviderLaravelRecent.php',
'RegularLabs\\Scoped\\Intervention\\Image\\ImageServiceProviderLeague' => $vendorDir . '/intervention/image/src/Intervention/Image/ImageServiceProviderLeague.php',
'RegularLabs\\Scoped\\Intervention\\Image\\ImageServiceProviderLumen' => $vendorDir . '/intervention/image/src/Intervention/Image/ImageServiceProviderLumen.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Color' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Color.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\BackupCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/BackupCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\BlurCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/BlurCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\BrightnessCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/BrightnessCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\ColorizeCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/ColorizeCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\ContrastCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/ContrastCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\CropCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/CropCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\DestroyCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/DestroyCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\ExifCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/ExifCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\FillCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/FillCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\FitCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/FitCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\FlipCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/FlipCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\GammaCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/GammaCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\GetSizeCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/GetSizeCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\GreyscaleCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/GreyscaleCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\HeightenCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/HeightenCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\InsertCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/InsertCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\InterlaceCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/InterlaceCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\InvertCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/InvertCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\LimitColorsCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/LimitColorsCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\MaskCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/MaskCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\OpacityCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/OpacityCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\PickColorCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/PickColorCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\PixelCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/PixelCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\PixelateCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/PixelateCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\ResetCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/ResetCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\ResizeCanvasCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/ResizeCanvasCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\ResizeCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/ResizeCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\RotateCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/RotateCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\SharpenCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/SharpenCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\TrimCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/TrimCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\WidenCommand' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Commands/WidenCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Decoder' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Decoder.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Driver' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Driver.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Encoder' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Encoder.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Font' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Font.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Shapes\\CircleShape' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Shapes/CircleShape.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Shapes\\EllipseShape' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Shapes/EllipseShape.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Shapes\\LineShape' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Shapes/LineShape.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Shapes\\PolygonShape' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Shapes/PolygonShape.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Shapes\\RectangleShape' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Shapes/RectangleShape.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Point' => $vendorDir . '/intervention/image/src/Intervention/Image/Point.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Response' => $vendorDir . '/intervention/image/src/Intervention/Image/Response.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Size' => $vendorDir . '/intervention/image/src/Intervention/Image/Size.php',
'RegularLabs\\Scoped\\Psr\\Http\\Message\\MessageInterface' => $vendorDir . '/psr/http-message/src/MessageInterface.php',
'RegularLabs\\Scoped\\Psr\\Http\\Message\\RequestFactoryInterface' => $vendorDir . '/psr/http-factory/src/RequestFactoryInterface.php',
'RegularLabs\\Scoped\\Psr\\Http\\Message\\RequestInterface' => $vendorDir . '/psr/http-message/src/RequestInterface.php',
'RegularLabs\\Scoped\\Psr\\Http\\Message\\ResponseFactoryInterface' => $vendorDir . '/psr/http-factory/src/ResponseFactoryInterface.php',
'RegularLabs\\Scoped\\Psr\\Http\\Message\\ResponseInterface' => $vendorDir . '/psr/http-message/src/ResponseInterface.php',
'RegularLabs\\Scoped\\Psr\\Http\\Message\\ServerRequestFactoryInterface' => $vendorDir . '/psr/http-factory/src/ServerRequestFactoryInterface.php',
'RegularLabs\\Scoped\\Psr\\Http\\Message\\ServerRequestInterface' => $vendorDir . '/psr/http-message/src/ServerRequestInterface.php',
'RegularLabs\\Scoped\\Psr\\Http\\Message\\StreamFactoryInterface' => $vendorDir . '/psr/http-factory/src/StreamFactoryInterface.php',
'RegularLabs\\Scoped\\Psr\\Http\\Message\\StreamInterface' => $vendorDir . '/psr/http-message/src/StreamInterface.php',
'RegularLabs\\Scoped\\Psr\\Http\\Message\\UploadedFileFactoryInterface' => $vendorDir . '/psr/http-factory/src/UploadedFileFactoryInterface.php',
'RegularLabs\\Scoped\\Psr\\Http\\Message\\UploadedFileInterface' => $vendorDir . '/psr/http-message/src/UploadedFileInterface.php',
'RegularLabs\\Scoped\\Psr\\Http\\Message\\UriFactoryInterface' => $vendorDir . '/psr/http-factory/src/UriFactoryInterface.php',
'RegularLabs\\Scoped\\Psr\\Http\\Message\\UriInterface' => $vendorDir . '/psr/http-message/src/UriInterface.php',
'RegularLabs\\Scoped\\Psr\\SimpleCache\\CacheException' => $vendorDir . '/psr/simple-cache/src/CacheException.php',
'RegularLabs\\Scoped\\Psr\\SimpleCache\\CacheInterface' => $vendorDir . '/psr/simple-cache/src/CacheInterface.php',
'RegularLabs\\Scoped\\Psr\\SimpleCache\\InvalidArgumentException' => $vendorDir . '/psr/simple-cache/src/InvalidArgumentException.php',
);

View File

@ -0,0 +1,11 @@
<?php
// autoload_files.php @generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
'7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
'6124b4c8570aa390c21fafd04a26c69f' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php',
);

View File

@ -0,0 +1,9 @@
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
);

View File

@ -0,0 +1,15 @@
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
'RegularLabs\\Scoped\\Psr\\SimpleCache\\' => array($vendorDir . '/psr/simple-cache/src'),
'RegularLabs\\Scoped\\Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-factory/src', $vendorDir . '/psr/http-message/src'),
'RegularLabs\\Scoped\\Intervention\\Image\\' => array($vendorDir . '/intervention/image/src/Intervention/Image'),
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'),
'RegularLabs\\Scoped\\Detection\\' => array($vendorDir . '/mobiledetect/mobiledetectlib/src'),
'RegularLabs\\Scoped\\DeepCopy\\' => array($vendorDir . '/myclabs/deep-copy/src/DeepCopy'),
);

View File

@ -0,0 +1,51 @@
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit8353287fecf50ac51479a9e39297831c
{
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('ComposerAutoloaderInit8353287fecf50ac51479a9e39297831c', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit8353287fecf50ac51479a9e39297831c', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit8353287fecf50ac51479a9e39297831c::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInit8353287fecf50ac51479a9e39297831c::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
require $file;
}
}, null, null);
foreach ($filesToLoad as $fileIdentifier => $file) {
$requireFile($fileIdentifier, $file);
}
return $loader;
}
}

View File

@ -0,0 +1,270 @@
<?php
// autoload_static.php @generated by Composer
namespace Composer\Autoload;
class ComposerStaticInit8353287fecf50ac51479a9e39297831c
{
public static $files = array (
'7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
'6124b4c8570aa390c21fafd04a26c69f' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php',
);
public static $prefixLengthsPsr4 = array (
'R' =>
array (
'RegularLabs\\Scoped\\Psr\\SimpleCache\\' => 35,
'RegularLabs\\Scoped\\Psr\\Http\\Message\\' => 36,
'RegularLabs\\Scoped\\Intervention\\Image\\' => 38,
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\' => 35,
'RegularLabs\\Scoped\\Detection\\' => 29,
'RegularLabs\\Scoped\\DeepCopy\\' => 28,
),
);
public static $prefixDirsPsr4 = array (
'RegularLabs\\Scoped\\Psr\\SimpleCache\\' =>
array (
0 => __DIR__ . '/..' . '/psr/simple-cache/src',
),
'RegularLabs\\Scoped\\Psr\\Http\\Message\\' =>
array (
0 => __DIR__ . '/..' . '/psr/http-factory/src',
1 => __DIR__ . '/..' . '/psr/http-message/src',
),
'RegularLabs\\Scoped\\Intervention\\Image\\' =>
array (
0 => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image',
),
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\' =>
array (
0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src',
),
'RegularLabs\\Scoped\\Detection\\' =>
array (
0 => __DIR__ . '/..' . '/mobiledetect/mobiledetectlib/src',
),
'RegularLabs\\Scoped\\DeepCopy\\' =>
array (
0 => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy',
),
);
public static $classMap = array (
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
'RegularLabs\\Scoped\\DeepCopy\\DeepCopy' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/DeepCopy.php',
'RegularLabs\\Scoped\\DeepCopy\\Exception\\CloneException' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/Exception/CloneException.php',
'RegularLabs\\Scoped\\DeepCopy\\Exception\\PropertyException' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/Exception/PropertyException.php',
'RegularLabs\\Scoped\\DeepCopy\\Filter\\ChainableFilter' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/Filter/ChainableFilter.php',
'RegularLabs\\Scoped\\DeepCopy\\Filter\\Doctrine\\DoctrineCollectionFilter' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/Filter/Doctrine/DoctrineCollectionFilter.php',
'RegularLabs\\Scoped\\DeepCopy\\Filter\\Doctrine\\DoctrineEmptyCollectionFilter' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/Filter/Doctrine/DoctrineEmptyCollectionFilter.php',
'RegularLabs\\Scoped\\DeepCopy\\Filter\\Doctrine\\DoctrineProxyFilter' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/Filter/Doctrine/DoctrineProxyFilter.php',
'RegularLabs\\Scoped\\DeepCopy\\Filter\\Filter' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/Filter/Filter.php',
'RegularLabs\\Scoped\\DeepCopy\\Filter\\KeepFilter' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/Filter/KeepFilter.php',
'RegularLabs\\Scoped\\DeepCopy\\Filter\\ReplaceFilter' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/Filter/ReplaceFilter.php',
'RegularLabs\\Scoped\\DeepCopy\\Filter\\SetNullFilter' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/Filter/SetNullFilter.php',
'RegularLabs\\Scoped\\DeepCopy\\Matcher\\Doctrine\\DoctrineProxyMatcher' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/Matcher/Doctrine/DoctrineProxyMatcher.php',
'RegularLabs\\Scoped\\DeepCopy\\Matcher\\Matcher' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/Matcher/Matcher.php',
'RegularLabs\\Scoped\\DeepCopy\\Matcher\\PropertyMatcher' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/Matcher/PropertyMatcher.php',
'RegularLabs\\Scoped\\DeepCopy\\Matcher\\PropertyNameMatcher' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/Matcher/PropertyNameMatcher.php',
'RegularLabs\\Scoped\\DeepCopy\\Matcher\\PropertyTypeMatcher' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/Matcher/PropertyTypeMatcher.php',
'RegularLabs\\Scoped\\DeepCopy\\Reflection\\ReflectionHelper' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/Reflection/ReflectionHelper.php',
'RegularLabs\\Scoped\\DeepCopy\\TypeFilter\\Date\\DateIntervalFilter' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/TypeFilter/Date/DateIntervalFilter.php',
'RegularLabs\\Scoped\\DeepCopy\\TypeFilter\\ReplaceFilter' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/TypeFilter/ReplaceFilter.php',
'RegularLabs\\Scoped\\DeepCopy\\TypeFilter\\ShallowCopyFilter' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/TypeFilter/ShallowCopyFilter.php',
'RegularLabs\\Scoped\\DeepCopy\\TypeFilter\\Spl\\ArrayObjectFilter' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/TypeFilter/Spl/ArrayObjectFilter.php',
'RegularLabs\\Scoped\\DeepCopy\\TypeFilter\\Spl\\SplDoublyLinkedList' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/TypeFilter/Spl/SplDoublyLinkedList.php',
'RegularLabs\\Scoped\\DeepCopy\\TypeFilter\\Spl\\SplDoublyLinkedListFilter' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/TypeFilter/Spl/SplDoublyLinkedListFilter.php',
'RegularLabs\\Scoped\\DeepCopy\\TypeFilter\\TypeFilter' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/TypeFilter/TypeFilter.php',
'RegularLabs\\Scoped\\DeepCopy\\TypeMatcher\\TypeMatcher' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/TypeMatcher/TypeMatcher.php',
'RegularLabs\\Scoped\\Detection\\Cache\\Cache' => __DIR__ . '/..' . '/mobiledetect/mobiledetectlib/src/Cache/Cache.php',
'RegularLabs\\Scoped\\Detection\\Cache\\CacheException' => __DIR__ . '/..' . '/mobiledetect/mobiledetectlib/src/Cache/CacheException.php',
'RegularLabs\\Scoped\\Detection\\Cache\\CacheItem' => __DIR__ . '/..' . '/mobiledetect/mobiledetectlib/src/Cache/CacheItem.php',
'RegularLabs\\Scoped\\Detection\\Exception\\MobileDetectException' => __DIR__ . '/..' . '/mobiledetect/mobiledetectlib/src/Exception/MobileDetectException.php',
'RegularLabs\\Scoped\\Detection\\MobileDetect' => __DIR__ . '/..' . '/mobiledetect/mobiledetectlib/src/MobileDetect.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\AppendStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/AppendStream.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\BufferStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/BufferStream.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\CachingStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/CachingStream.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\DroppingStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/DroppingStream.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\Exception\\MalformedUriException' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Exception/MalformedUriException.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\FnStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/FnStream.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\Header' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Header.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\HttpFactory' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/HttpFactory.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\InflateStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/InflateStream.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\LazyOpenStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/LazyOpenStream.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\LimitStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/LimitStream.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\Message' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Message.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\MessageTrait' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/MessageTrait.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\MimeType' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/MimeType.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\MultipartStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/MultipartStream.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\NoSeekStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/NoSeekStream.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\PumpStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/PumpStream.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\Query' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Query.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\Request' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Request.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\Response' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Response.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\Rfc7230' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Rfc7230.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\ServerRequest' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/ServerRequest.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\Stream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Stream.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\StreamDecoratorTrait' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/StreamDecoratorTrait.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\StreamWrapper' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/StreamWrapper.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\UploadedFile' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/UploadedFile.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\Uri' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Uri.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\UriComparator' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/UriComparator.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\UriNormalizer' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/UriNormalizer.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\UriResolver' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/UriResolver.php',
'RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\Utils' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Utils.php',
'RegularLabs\\Scoped\\Intervention\\Image\\AbstractColor' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/AbstractColor.php',
'RegularLabs\\Scoped\\Intervention\\Image\\AbstractDecoder' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/AbstractDecoder.php',
'RegularLabs\\Scoped\\Intervention\\Image\\AbstractDriver' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/AbstractDriver.php',
'RegularLabs\\Scoped\\Intervention\\Image\\AbstractEncoder' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/AbstractEncoder.php',
'RegularLabs\\Scoped\\Intervention\\Image\\AbstractFont' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/AbstractFont.php',
'RegularLabs\\Scoped\\Intervention\\Image\\AbstractShape' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/AbstractShape.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\AbstractCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Commands/AbstractCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\Argument' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Commands/Argument.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\ChecksumCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Commands/ChecksumCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\CircleCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Commands/CircleCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\EllipseCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Commands/EllipseCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\ExifCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Commands/ExifCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\IptcCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Commands/IptcCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\LineCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Commands/LineCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\OrientateCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Commands/OrientateCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\PolygonCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Commands/PolygonCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\PsrResponseCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Commands/PsrResponseCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\RectangleCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Commands/RectangleCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\ResponseCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Commands/ResponseCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\StreamCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Commands/StreamCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Commands\\TextCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Commands/TextCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Constraint' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Constraint.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Exception\\ImageException' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Exception/ImageException.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Exception\\InvalidArgumentException' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Exception/InvalidArgumentException.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Exception\\MissingDependencyException' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Exception/MissingDependencyException.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Exception\\NotFoundException' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Exception/NotFoundException.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Exception\\NotReadableException' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Exception/NotReadableException.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Exception\\NotSupportedException' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Exception/NotSupportedException.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Exception\\NotWritableException' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Exception/NotWritableException.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Exception\\RuntimeException' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Exception/RuntimeException.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Facades\\Image' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Facades/Image.php',
'RegularLabs\\Scoped\\Intervention\\Image\\File' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/File.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Filters\\DemoFilter' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Filters/DemoFilter.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Filters\\FilterInterface' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Filters/FilterInterface.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Color' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Color.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\BackupCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/BackupCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\BlurCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/BlurCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\BrightnessCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/BrightnessCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\ColorizeCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/ColorizeCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\ContrastCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/ContrastCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\CropCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/CropCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\DestroyCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/DestroyCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\FillCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/FillCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\FitCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/FitCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\FlipCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/FlipCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\GammaCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/GammaCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\GetSizeCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/GetSizeCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\GreyscaleCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/GreyscaleCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\HeightenCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/HeightenCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\InsertCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/InsertCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\InterlaceCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/InterlaceCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\InvertCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/InvertCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\LimitColorsCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/LimitColorsCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\MaskCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/MaskCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\OpacityCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/OpacityCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\PickColorCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/PickColorCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\PixelCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/PixelCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\PixelateCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/PixelateCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\ResetCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/ResetCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\ResizeCanvasCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/ResizeCanvasCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\ResizeCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/ResizeCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\RotateCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/RotateCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\SharpenCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/SharpenCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\TrimCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/TrimCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Commands\\WidenCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Commands/WidenCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Decoder' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Decoder.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Driver' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Driver.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Encoder' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Encoder.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Font' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Font.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Shapes\\CircleShape' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Shapes/CircleShape.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Shapes\\EllipseShape' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Shapes/EllipseShape.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Shapes\\LineShape' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Shapes/LineShape.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Shapes\\PolygonShape' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Shapes/PolygonShape.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Gd\\Shapes\\RectangleShape' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Gd/Shapes/RectangleShape.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Image' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Image.php',
'RegularLabs\\Scoped\\Intervention\\Image\\ImageManager' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/ImageManager.php',
'RegularLabs\\Scoped\\Intervention\\Image\\ImageManagerStatic' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/ImageManagerStatic.php',
'RegularLabs\\Scoped\\Intervention\\Image\\ImageServiceProvider' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/ImageServiceProvider.php',
'RegularLabs\\Scoped\\Intervention\\Image\\ImageServiceProviderLaravel4' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/ImageServiceProviderLaravel4.php',
'RegularLabs\\Scoped\\Intervention\\Image\\ImageServiceProviderLaravelRecent' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/ImageServiceProviderLaravelRecent.php',
'RegularLabs\\Scoped\\Intervention\\Image\\ImageServiceProviderLeague' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/ImageServiceProviderLeague.php',
'RegularLabs\\Scoped\\Intervention\\Image\\ImageServiceProviderLumen' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/ImageServiceProviderLumen.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Color' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Color.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\BackupCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/BackupCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\BlurCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/BlurCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\BrightnessCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/BrightnessCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\ColorizeCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/ColorizeCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\ContrastCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/ContrastCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\CropCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/CropCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\DestroyCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/DestroyCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\ExifCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/ExifCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\FillCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/FillCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\FitCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/FitCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\FlipCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/FlipCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\GammaCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/GammaCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\GetSizeCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/GetSizeCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\GreyscaleCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/GreyscaleCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\HeightenCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/HeightenCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\InsertCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/InsertCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\InterlaceCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/InterlaceCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\InvertCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/InvertCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\LimitColorsCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/LimitColorsCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\MaskCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/MaskCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\OpacityCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/OpacityCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\PickColorCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/PickColorCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\PixelCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/PixelCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\PixelateCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/PixelateCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\ResetCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/ResetCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\ResizeCanvasCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/ResizeCanvasCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\ResizeCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/ResizeCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\RotateCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/RotateCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\SharpenCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/SharpenCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\TrimCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/TrimCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Commands\\WidenCommand' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Commands/WidenCommand.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Decoder' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Decoder.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Driver' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Driver.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Encoder' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Encoder.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Font' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Font.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Shapes\\CircleShape' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Shapes/CircleShape.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Shapes\\EllipseShape' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Shapes/EllipseShape.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Shapes\\LineShape' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Shapes/LineShape.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Shapes\\PolygonShape' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Shapes/PolygonShape.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Imagick\\Shapes\\RectangleShape' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Shapes/RectangleShape.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Point' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Point.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Response' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Response.php',
'RegularLabs\\Scoped\\Intervention\\Image\\Size' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Size.php',
'RegularLabs\\Scoped\\Psr\\Http\\Message\\MessageInterface' => __DIR__ . '/..' . '/psr/http-message/src/MessageInterface.php',
'RegularLabs\\Scoped\\Psr\\Http\\Message\\RequestFactoryInterface' => __DIR__ . '/..' . '/psr/http-factory/src/RequestFactoryInterface.php',
'RegularLabs\\Scoped\\Psr\\Http\\Message\\RequestInterface' => __DIR__ . '/..' . '/psr/http-message/src/RequestInterface.php',
'RegularLabs\\Scoped\\Psr\\Http\\Message\\ResponseFactoryInterface' => __DIR__ . '/..' . '/psr/http-factory/src/ResponseFactoryInterface.php',
'RegularLabs\\Scoped\\Psr\\Http\\Message\\ResponseInterface' => __DIR__ . '/..' . '/psr/http-message/src/ResponseInterface.php',
'RegularLabs\\Scoped\\Psr\\Http\\Message\\ServerRequestFactoryInterface' => __DIR__ . '/..' . '/psr/http-factory/src/ServerRequestFactoryInterface.php',
'RegularLabs\\Scoped\\Psr\\Http\\Message\\ServerRequestInterface' => __DIR__ . '/..' . '/psr/http-message/src/ServerRequestInterface.php',
'RegularLabs\\Scoped\\Psr\\Http\\Message\\StreamFactoryInterface' => __DIR__ . '/..' . '/psr/http-factory/src/StreamFactoryInterface.php',
'RegularLabs\\Scoped\\Psr\\Http\\Message\\StreamInterface' => __DIR__ . '/..' . '/psr/http-message/src/StreamInterface.php',
'RegularLabs\\Scoped\\Psr\\Http\\Message\\UploadedFileFactoryInterface' => __DIR__ . '/..' . '/psr/http-factory/src/UploadedFileFactoryInterface.php',
'RegularLabs\\Scoped\\Psr\\Http\\Message\\UploadedFileInterface' => __DIR__ . '/..' . '/psr/http-message/src/UploadedFileInterface.php',
'RegularLabs\\Scoped\\Psr\\Http\\Message\\UriFactoryInterface' => __DIR__ . '/..' . '/psr/http-factory/src/UriFactoryInterface.php',
'RegularLabs\\Scoped\\Psr\\Http\\Message\\UriInterface' => __DIR__ . '/..' . '/psr/http-message/src/UriInterface.php',
'RegularLabs\\Scoped\\Psr\\SimpleCache\\CacheException' => __DIR__ . '/..' . '/psr/simple-cache/src/CacheException.php',
'RegularLabs\\Scoped\\Psr\\SimpleCache\\CacheInterface' => __DIR__ . '/..' . '/psr/simple-cache/src/CacheInterface.php',
'RegularLabs\\Scoped\\Psr\\SimpleCache\\InvalidArgumentException' => __DIR__ . '/..' . '/psr/simple-cache/src/InvalidArgumentException.php',
);
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit8353287fecf50ac51479a9e39297831c::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit8353287fecf50ac51479a9e39297831c::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit8353287fecf50ac51479a9e39297831c::$classMap;
}, null, ClassLoader::class);
}
}

View File

@ -0,0 +1,557 @@
{
"packages": [
{
"name": "guzzlehttp\/psr7",
"version": "2.7.0",
"version_normalized": "2.7.0.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/guzzle\/psr7.git",
"reference": "a70f5c95fb43bc83f07c9c948baa0dc1829bf201"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/guzzle\/psr7\/zipball\/a70f5c95fb43bc83f07c9c948baa0dc1829bf201",
"reference": "a70f5c95fb43bc83f07c9c948baa0dc1829bf201",
"shasum": ""
},
"require": {
"php": "^7.2.5 || ^8.0",
"psr\/http-factory": "^1.0",
"psr\/http-message": "^1.1 || ^2.0",
"ralouphie\/getallheaders": "^3.0"
},
"provide": {
"psr\/http-factory-implementation": "1.0",
"psr\/http-message-implementation": "1.0"
},
"require-dev": {
"bamarni\/composer-bin-plugin": "^1.8.2",
"http-interop\/http-factory-tests": "0.9.0",
"phpunit\/phpunit": "^8.5.39 || ^9.6.20"
},
"suggest": {
"laminas\/laminas-httphandlerrunner": "Emit PSR-7 responses"
},
"time": "2024-07-18T11:15:46+00:00",
"type": "library",
"extra": {
"bamarni-bin": {
"bin-links": true,
"forward-command": false
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\": "src\/"
}
},
"notification-url": "https:\/\/packagist.org\/downloads\/",
"license": [
"MIT"
],
"authors": [
{
"name": "Graham Campbell",
"email": "hello@gjcampbell.co.uk",
"homepage": "https:\/\/github.com\/GrahamCampbell"
},
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https:\/\/github.com\/mtdowling"
},
{
"name": "George Mponos",
"email": "gmponos@gmail.com",
"homepage": "https:\/\/github.com\/gmponos"
},
{
"name": "Tobias Nyholm",
"email": "tobias.nyholm@gmail.com",
"homepage": "https:\/\/github.com\/Nyholm"
},
{
"name": "M\u00e1rk S\u00e1gi-Kaz\u00e1r",
"email": "mark.sagikazar@gmail.com",
"homepage": "https:\/\/github.com\/sagikazarmark"
},
{
"name": "Tobias Schultze",
"email": "webmaster@tubo-world.de",
"homepage": "https:\/\/github.com\/Tobion"
},
{
"name": "M\u00e1rk S\u00e1gi-Kaz\u00e1r",
"email": "mark.sagikazar@gmail.com",
"homepage": "https:\/\/sagikazarmark.hu"
}
],
"description": "PSR-7 message implementation that also provides common utility methods",
"keywords": [
"http",
"message",
"psr-7",
"request",
"response",
"stream",
"uri",
"url"
],
"support": {
"issues": "https:\/\/github.com\/guzzle\/psr7\/issues",
"source": "https:\/\/github.com\/guzzle\/psr7\/tree\/2.7.0"
},
"funding": [
{
"url": "https:\/\/github.com\/GrahamCampbell",
"type": "github"
},
{
"url": "https:\/\/github.com\/Nyholm",
"type": "github"
},
{
"url": "https:\/\/tidelift.com\/funding\/github\/packagist\/guzzlehttp\/psr7",
"type": "tidelift"
}
],
"install-path": "..\/guzzlehttp\/psr7"
},
{
"name": "intervention\/image",
"version": "2.7.2",
"version_normalized": "2.7.2.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/Intervention\/image.git",
"reference": "04be355f8d6734c826045d02a1079ad658322dad"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/Intervention\/image\/zipball\/04be355f8d6734c826045d02a1079ad658322dad",
"reference": "04be355f8d6734c826045d02a1079ad658322dad",
"shasum": ""
},
"require": {
"ext-fileinfo": "*",
"guzzlehttp\/psr7": "~1.1 || ^2.0",
"php": ">=5.4.0"
},
"require-dev": {
"mockery\/mockery": "~0.9.2",
"phpunit\/phpunit": "^4.8 || ^5.7 || ^7.5.15"
},
"suggest": {
"ext-gd": "to use GD library based image processing.",
"ext-imagick": "to use Imagick based image processing.",
"intervention\/imagecache": "Caching extension for the Intervention Image library"
},
"time": "2022-05-21T17:30:32+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
},
"laravel": {
"providers": [
"RegularLabs\\Scoped\\Intervention\\Image\\ImageServiceProvider"
],
"aliases": {
"Image": "Intervention\\Image\\Facades\\Image"
}
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"RegularLabs\\Scoped\\Intervention\\Image\\": "src\/Intervention\/Image"
}
},
"notification-url": "https:\/\/packagist.org\/downloads\/",
"license": [
"MIT"
],
"authors": [
{
"name": "Oliver Vogel",
"email": "oliver@intervention.io",
"homepage": "https:\/\/intervention.io\/"
}
],
"description": "Image handling and manipulation library with support for Laravel integration",
"homepage": "http:\/\/image.intervention.io\/",
"keywords": [
"gd",
"image",
"imagick",
"laravel",
"thumbnail",
"watermark"
],
"support": {
"issues": "https:\/\/github.com\/Intervention\/image\/issues",
"source": "https:\/\/github.com\/Intervention\/image\/tree\/2.7.2"
},
"funding": [
{
"url": "https:\/\/paypal.me\/interventionio",
"type": "custom"
},
{
"url": "https:\/\/github.com\/Intervention",
"type": "github"
}
],
"install-path": "..\/intervention\/image"
},
{
"name": "mobiledetect\/mobiledetectlib",
"version": "4.8.06",
"version_normalized": "4.8.06.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/serbanghita\/Mobile-Detect.git",
"reference": "af088b54cecc13b3264edca7da93a89ba7aa2d9e"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/serbanghita\/Mobile-Detect\/zipball\/af088b54cecc13b3264edca7da93a89ba7aa2d9e",
"reference": "af088b54cecc13b3264edca7da93a89ba7aa2d9e",
"shasum": ""
},
"require": {
"php": ">=8.0",
"psr\/simple-cache": "^2 || ^3"
},
"require-dev": {
"friendsofphp\/php-cs-fixer": "^v3.35.1",
"phpbench\/phpbench": "^1.2",
"phpstan\/phpstan": "^1.10",
"phpunit\/phpunit": "^9.6",
"squizlabs\/php_codesniffer": "^3.7"
},
"time": "2024-03-01T22:28:42+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"RegularLabs\\Scoped\\Detection\\": "src\/"
}
},
"notification-url": "https:\/\/packagist.org\/downloads\/",
"license": [
"MIT"
],
"authors": [
{
"name": "Serban Ghita",
"email": "serbanghita@gmail.com",
"homepage": "http:\/\/mobiledetect.net",
"role": "Developer"
}
],
"description": "Mobile_Detect is a lightweight PHP class for detecting mobile devices. It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.",
"homepage": "https:\/\/github.com\/serbanghita\/Mobile-Detect",
"keywords": [
"detect mobile devices",
"mobile",
"mobile detect",
"mobile detector",
"php mobile detect"
],
"support": {
"issues": "https:\/\/github.com\/serbanghita\/Mobile-Detect\/issues",
"source": "https:\/\/github.com\/serbanghita\/Mobile-Detect\/tree\/4.8.06"
},
"funding": [
{
"url": "https:\/\/github.com\/serbanghita",
"type": "github"
}
],
"install-path": "..\/mobiledetect\/mobiledetectlib"
},
{
"name": "myclabs\/deep-copy",
"version": "1.12.0",
"version_normalized": "1.12.0.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/myclabs\/DeepCopy.git",
"reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/myclabs\/DeepCopy\/zipball\/3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c",
"reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"conflict": {
"doctrine\/collections": "<1.6.8",
"doctrine\/common": "<2.13.3 || >=3 <3.2.2"
},
"require-dev": {
"doctrine\/collections": "^1.6.8",
"doctrine\/common": "^2.13.3 || ^3.2.2",
"phpspec\/prophecy": "^1.10",
"phpunit\/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13"
},
"time": "2024-06-12T14:39:25+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"files": [
"src\/DeepCopy\/deep_copy.php"
],
"psr-4": {
"RegularLabs\\Scoped\\DeepCopy\\": "src\/DeepCopy\/"
}
},
"notification-url": "https:\/\/packagist.org\/downloads\/",
"license": [
"MIT"
],
"description": "Create deep copies (clones) of your objects",
"keywords": [
"clone",
"copy",
"duplicate",
"object",
"object graph"
],
"support": {
"issues": "https:\/\/github.com\/myclabs\/DeepCopy\/issues",
"source": "https:\/\/github.com\/myclabs\/DeepCopy\/tree\/1.12.0"
},
"funding": [
{
"url": "https:\/\/tidelift.com\/funding\/github\/packagist\/myclabs\/deep-copy",
"type": "tidelift"
}
],
"install-path": "..\/myclabs\/deep-copy"
},
{
"name": "psr\/http-factory",
"version": "1.1.0",
"version_normalized": "1.1.0.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/php-fig\/http-factory.git",
"reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/php-fig\/http-factory\/zipball\/2b4765fddfe3b508ac62f829e852b1501d3f6e8a",
"reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a",
"shasum": ""
},
"require": {
"php": ">=7.1",
"psr\/http-message": "^1.0 || ^2.0"
},
"time": "2024-04-15T12:06:14+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"RegularLabs\\Scoped\\Psr\\Http\\Message\\": "src\/"
}
},
"notification-url": "https:\/\/packagist.org\/downloads\/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https:\/\/www.php-fig.org\/"
}
],
"description": "PSR-17: Common interfaces for PSR-7 HTTP message factories",
"keywords": [
"factory",
"http",
"message",
"psr",
"psr-17",
"psr-7",
"request",
"response"
],
"support": {
"source": "https:\/\/github.com\/php-fig\/http-factory"
},
"install-path": "..\/psr\/http-factory"
},
{
"name": "psr\/http-message",
"version": "2.0",
"version_normalized": "2.0.0.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/php-fig\/http-message.git",
"reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/php-fig\/http-message\/zipball\/402d35bcb92c70c026d1a6a9883f06b2ead23d71",
"reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
"time": "2023-04-04T09:54:51+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"RegularLabs\\Scoped\\Psr\\Http\\Message\\": "src\/"
}
},
"notification-url": "https:\/\/packagist.org\/downloads\/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https:\/\/www.php-fig.org\/"
}
],
"description": "Common interface for HTTP messages",
"homepage": "https:\/\/github.com\/php-fig\/http-message",
"keywords": [
"http",
"http-message",
"psr",
"psr-7",
"request",
"response"
],
"support": {
"source": "https:\/\/github.com\/php-fig\/http-message\/tree\/2.0"
},
"install-path": "..\/psr\/http-message"
},
{
"name": "psr\/simple-cache",
"version": "3.0.0",
"version_normalized": "3.0.0.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/php-fig\/simple-cache.git",
"reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/php-fig\/simple-cache\/zipball\/764e0b3939f5ca87cb904f570ef9be2d78a07865",
"reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865",
"shasum": ""
},
"require": {
"php": ">=8.0.0"
},
"time": "2021-10-29T13:26:27+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"RegularLabs\\Scoped\\Psr\\SimpleCache\\": "src\/"
}
},
"notification-url": "https:\/\/packagist.org\/downloads\/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https:\/\/www.php-fig.org\/"
}
],
"description": "Common interfaces for simple caching",
"keywords": [
"cache",
"caching",
"psr",
"psr-16",
"simple-cache"
],
"support": {
"source": "https:\/\/github.com\/php-fig\/simple-cache\/tree\/3.0.0"
},
"install-path": "..\/psr\/simple-cache"
},
{
"name": "ralouphie\/getallheaders",
"version": "3.0.3",
"version_normalized": "3.0.3.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/ralouphie\/getallheaders.git",
"reference": "120b605dfeb996808c31b6477290a714d356e822"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/ralouphie\/getallheaders\/zipball\/120b605dfeb996808c31b6477290a714d356e822",
"reference": "120b605dfeb996808c31b6477290a714d356e822",
"shasum": ""
},
"require": {
"php": ">=5.6"
},
"require-dev": {
"php-coveralls\/php-coveralls": "^2.1",
"phpunit\/phpunit": "^5 || ^6.5"
},
"time": "2019-03-08T08:55:37+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"files": [
"src\/getallheaders.php"
]
},
"notification-url": "https:\/\/packagist.org\/downloads\/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ralph Khattar",
"email": "ralph.khattar@gmail.com"
}
],
"description": "A polyfill for getallheaders.",
"support": {
"issues": "https:\/\/github.com\/ralouphie\/getallheaders\/issues",
"source": "https:\/\/github.com\/ralouphie\/getallheaders\/tree\/develop"
},
"install-path": "..\/ralouphie\/getallheaders"
}
],
"dev": true,
"dev-package-names": []
}

View File

@ -0,0 +1,5 @@
<?php
namespace RegularLabs\Scoped;
return array('root' => array('name' => '__root__', 'pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '4abda64d939b414c0f9dfc4b8e8e3ae5448ca92a', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev' => \true), 'versions' => array('__root__' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '4abda64d939b414c0f9dfc4b8e8e3ae5448ca92a', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev_requirement' => \false), 'guzzlehttp/psr7' => array('pretty_version' => '2.7.0', 'version' => '2.7.0.0', 'reference' => 'a70f5c95fb43bc83f07c9c948baa0dc1829bf201', 'type' => 'library', 'install_path' => __DIR__ . '/../guzzlehttp/psr7', 'aliases' => array(), 'dev_requirement' => \false), 'intervention/image' => array('pretty_version' => '2.7.2', 'version' => '2.7.2.0', 'reference' => '04be355f8d6734c826045d02a1079ad658322dad', 'type' => 'library', 'install_path' => __DIR__ . '/../intervention/image', 'aliases' => array(), 'dev_requirement' => \false), 'mobiledetect/mobiledetectlib' => array('pretty_version' => '4.8.06', 'version' => '4.8.06.0', 'reference' => 'af088b54cecc13b3264edca7da93a89ba7aa2d9e', 'type' => 'library', 'install_path' => __DIR__ . '/../mobiledetect/mobiledetectlib', 'aliases' => array(), 'dev_requirement' => \false), 'myclabs/deep-copy' => array('pretty_version' => '1.12.0', 'version' => '1.12.0.0', 'reference' => '3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c', 'type' => 'library', 'install_path' => __DIR__ . '/../myclabs/deep-copy', 'aliases' => array(), 'dev_requirement' => \false), 'psr/http-factory' => array('pretty_version' => '1.1.0', 'version' => '1.1.0.0', 'reference' => '2b4765fddfe3b508ac62f829e852b1501d3f6e8a', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/http-factory', 'aliases' => array(), 'dev_requirement' => \false), 'psr/http-factory-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0')), 'psr/http-message' => array('pretty_version' => '2.0', 'version' => '2.0.0.0', 'reference' => '402d35bcb92c70c026d1a6a9883f06b2ead23d71', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/http-message', 'aliases' => array(), 'dev_requirement' => \false), 'psr/http-message-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0')), 'psr/simple-cache' => array('pretty_version' => '3.0.0', 'version' => '3.0.0.0', 'reference' => '764e0b3939f5ca87cb904f570ef9be2d78a07865', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/simple-cache', 'aliases' => array(), 'dev_requirement' => \false), 'ralouphie/getallheaders' => array('pretty_version' => '3.0.3', 'version' => '3.0.3.0', 'reference' => '120b605dfeb996808c31b6477290a714d356e822', 'type' => 'library', 'install_path' => __DIR__ . '/../ralouphie/getallheaders', 'aliases' => array(), 'dev_requirement' => \false)));

View File

@ -0,0 +1,26 @@
<?php
// platform_check.php @generated by Composer
$issues = array();
if (!(PHP_VERSION_ID >= 80000)) {
$issues[] = 'Your Composer dependencies require a PHP version ">= 8.0.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
);
}

View File

@ -0,0 +1,465 @@
# Change Log
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## 2.7.0 - 2024-07-18
### Added
- Add `Utils::redactUserInfo()` method
- Add ability to encode bools as ints in `Query::build`
## 2.6.3 - 2024-07-18
### Fixed
- Make `StreamWrapper::stream_stat()` return `false` if inner stream's size is `null`
### Changed
- PHP 8.4 support
## 2.6.2 - 2023-12-03
### Fixed
- Fixed another issue with the fact that PHP transforms numeric strings in array keys to ints
### Changed
- Updated links in docs to their canonical versions
- Replaced `call_user_func*` with native calls
## 2.6.1 - 2023-08-27
### Fixed
- Properly handle the fact that PHP transforms numeric strings in array keys to ints
## 2.6.0 - 2023-08-03
### Changed
- Updated the mime type map to add some new entries, fix a couple of invalid entries, and remove an invalid entry
- Fallback to `application/octet-stream` if we are unable to guess the content type for a multipart file upload
## 2.5.1 - 2023-08-03
### Fixed
- Corrected mime type for `.acc` files to `audio/aac`
### Changed
- PHP 8.3 support
## 2.5.0 - 2023-04-17
### Changed
- Adjusted `psr/http-message` version constraint to `^1.1 || ^2.0`
## 2.4.5 - 2023-04-17
### Fixed
- Prevent possible warnings on unset variables in `ServerRequest::normalizeNestedFileSpec`
- Fixed `Message::bodySummary` when `preg_match` fails
- Fixed header validation issue
## 2.4.4 - 2023-03-09
### Changed
- Removed the need for `AllowDynamicProperties` in `LazyOpenStream`
## 2.4.3 - 2022-10-26
### Changed
- Replaced `sha1(uniqid())` by `bin2hex(random_bytes(20))`
## 2.4.2 - 2022-10-25
### Fixed
- Fixed erroneous behaviour when combining host and relative path
## 2.4.1 - 2022-08-28
### Fixed
- Rewind body before reading in `Message::bodySummary`
## 2.4.0 - 2022-06-20
### Added
- Added provisional PHP 8.2 support
- Added `UriComparator::isCrossOrigin` method
## 2.3.0 - 2022-06-09
### Fixed
- Added `Header::splitList` method
- Added `Utils::tryGetContents` method
- Improved `Stream::getContents` method
- Updated mimetype mappings
## 2.2.2 - 2022-06-08
### Fixed
- Fix `Message::parseRequestUri` for numeric headers
- Re-wrap exceptions thrown in `fread` into runtime exceptions
- Throw an exception when multipart options is misformatted
## 2.2.1 - 2022-03-20
### Fixed
- Correct header value validation
## 2.2.0 - 2022-03-20
### Added
- A more compressive list of mime types
- Add JsonSerializable to Uri
- Missing return types
### Fixed
- Bug MultipartStream no `uri` metadata
- Bug MultipartStream with filename for `data://` streams
- Fixed new line handling in MultipartStream
- Reduced RAM usage when copying streams
- Updated parsing in `Header::normalize()`
## 2.1.1 - 2022-03-20
### Fixed
- Validate header values properly
## 2.1.0 - 2021-10-06
### Changed
- Attempting to create a `Uri` object from a malformed URI will no longer throw a generic
`InvalidArgumentException`, but rather a `MalformedUriException`, which inherits from the former
for backwards compatibility. Callers relying on the exception being thrown to detect invalid
URIs should catch the new exception.
### Fixed
- Return `null` in caching stream size if remote size is `null`
## 2.0.0 - 2021-06-30
Identical to the RC release.
## 2.0.0@RC-1 - 2021-04-29
### Fixed
- Handle possibly unset `url` in `stream_get_meta_data`
## 2.0.0@beta-1 - 2021-03-21
### Added
- PSR-17 factories
- Made classes final
- PHP7 type hints
### Changed
- When building a query string, booleans are represented as 1 and 0.
### Removed
- PHP < 7.2 support
- All functions in the `GuzzleHttp\Psr7` namespace
## 1.8.1 - 2021-03-21
### Fixed
- Issue parsing IPv6 URLs
- Issue modifying ServerRequest lost all its attributes
## 1.8.0 - 2021-03-21
### Added
- Locale independent URL parsing
- Most classes got a `@final` annotation to prepare for 2.0
### Fixed
- Issue when creating stream from `php://input` and curl-ext is not installed
- Broken `Utils::tryFopen()` on PHP 8
## 1.7.0 - 2020-09-30
### Added
- Replaced functions by static methods
### Fixed
- Converting a non-seekable stream to a string
- Handle multiple Set-Cookie correctly
- Ignore array keys in header values when merging
- Allow multibyte characters to be parsed in `Message:bodySummary()`
### Changed
- Restored partial HHVM 3 support
## [1.6.1] - 2019-07-02
### Fixed
- Accept null and bool header values again
## [1.6.0] - 2019-06-30
### Added
- Allowed version `^3.0` of `ralouphie/getallheaders` dependency (#244)
- Added MIME type for WEBP image format (#246)
- Added more validation of values according to PSR-7 and RFC standards, e.g. status code range (#250, #272)
### Changed
- Tests don't pass with HHVM 4.0, so HHVM support got dropped. Other libraries like composer have done the same. (#262)
- Accept port number 0 to be valid (#270)
### Fixed
- Fixed subsequent reads from `php://input` in ServerRequest (#247)
- Fixed readable/writable detection for certain stream modes (#248)
- Fixed encoding of special characters in the `userInfo` component of an URI (#253)
## [1.5.2] - 2018-12-04
### Fixed
- Check body size when getting the message summary
## [1.5.1] - 2018-12-04
### Fixed
- Get the summary of a body only if it is readable
## [1.5.0] - 2018-12-03
### Added
- Response first-line to response string exception (fixes #145)
- A test for #129 behavior
- `get_message_body_summary` function in order to get the message summary
- `3gp` and `mkv` mime types
### Changed
- Clarify exception message when stream is detached
### Deprecated
- Deprecated parsing folded header lines as per RFC 7230
### Fixed
- Fix `AppendStream::detach` to not close streams
- `InflateStream` preserves `isSeekable` attribute of the underlying stream
- `ServerRequest::getUriFromGlobals` to support URLs in query parameters
Several other fixes and improvements.
## [1.4.2] - 2017-03-20
### Fixed
- Reverted BC break to `Uri::resolve` and `Uri::removeDotSegments` by removing
calls to `trigger_error` when deprecated methods are invoked.
## [1.4.1] - 2017-02-27
### Added
- Rriggering of silenced deprecation warnings.
### Fixed
- Reverted BC break by reintroducing behavior to automagically fix a URI with a
relative path and an authority by adding a leading slash to the path. It's only
deprecated now.
## [1.4.0] - 2017-02-21
### Added
- Added common URI utility methods based on RFC 3986 (see documentation in the readme):
- `Uri::isDefaultPort`
- `Uri::isAbsolute`
- `Uri::isNetworkPathReference`
- `Uri::isAbsolutePathReference`
- `Uri::isRelativePathReference`
- `Uri::isSameDocumentReference`
- `Uri::composeComponents`
- `UriNormalizer::normalize`
- `UriNormalizer::isEquivalent`
- `UriResolver::relativize`
### Changed
- Ensure `ServerRequest::getUriFromGlobals` returns a URI in absolute form.
- Allow `parse_response` to parse a response without delimiting space and reason.
- Ensure each URI modification results in a valid URI according to PSR-7 discussions.
Invalid modifications will throw an exception instead of returning a wrong URI or
doing some magic.
- `(new Uri)->withPath('foo')->withHost('example.com')` will throw an exception
because the path of a URI with an authority must start with a slash "/" or be empty
- `(new Uri())->withScheme('http')` will return `'http://localhost'`
### Deprecated
- `Uri::resolve` in favor of `UriResolver::resolve`
- `Uri::removeDotSegments` in favor of `UriResolver::removeDotSegments`
### Fixed
- `Stream::read` when length parameter <= 0.
- `copy_to_stream` reads bytes in chunks instead of `maxLen` into memory.
- `ServerRequest::getUriFromGlobals` when `Host` header contains port.
- Compatibility of URIs with `file` scheme and empty host.
## [1.3.1] - 2016-06-25
### Fixed
- `Uri::__toString` for network path references, e.g. `//example.org`.
- Missing lowercase normalization for host.
- Handling of URI components in case they are `'0'` in a lot of places,
e.g. as a user info password.
- `Uri::withAddedHeader` to correctly merge headers with different case.
- Trimming of header values in `Uri::withAddedHeader`. Header values may
be surrounded by whitespace which should be ignored according to RFC 7230
Section 3.2.4. This does not apply to header names.
- `Uri::withAddedHeader` with an array of header values.
- `Uri::resolve` when base path has no slash and handling of fragment.
- Handling of encoding in `Uri::with(out)QueryValue` so one can pass the
key/value both in encoded as well as decoded form to those methods. This is
consistent with withPath, withQuery etc.
- `ServerRequest::withoutAttribute` when attribute value is null.
## [1.3.0] - 2016-04-13
### Added
- Remaining interfaces needed for full PSR7 compatibility
(ServerRequestInterface, UploadedFileInterface, etc.).
- Support for stream_for from scalars.
### Changed
- Can now extend Uri.
### Fixed
- A bug in validating request methods by making it more permissive.
## [1.2.3] - 2016-02-18
### Fixed
- Support in `GuzzleHttp\Psr7\CachingStream` for seeking forward on remote
streams, which can sometimes return fewer bytes than requested with `fread`.
- Handling of gzipped responses with FNAME headers.
## [1.2.2] - 2016-01-22
### Added
- Support for URIs without any authority.
- Support for HTTP 451 'Unavailable For Legal Reasons.'
- Support for using '0' as a filename.
- Support for including non-standard ports in Host headers.
## [1.2.1] - 2015-11-02
### Changes
- Now supporting negative offsets when seeking to SEEK_END.
## [1.2.0] - 2015-08-15
### Changed
- Body as `"0"` is now properly added to a response.
- Now allowing forward seeking in CachingStream.
- Now properly parsing HTTP requests that contain proxy targets in
`parse_request`.
- functions.php is now conditionally required.
- user-info is no longer dropped when resolving URIs.
## [1.1.0] - 2015-06-24
### Changed
- URIs can now be relative.
- `multipart/form-data` headers are now overridden case-insensitively.
- URI paths no longer encode the following characters because they are allowed
in URIs: "(", ")", "*", "!", "'"
- A port is no longer added to a URI when the scheme is missing and no port is
present.
## 1.0.0 - 2015-05-19
Initial release.
Currently unsupported:
- `Psr\Http\Message\ServerRequestInterface`
- `Psr\Http\Message\UploadedFileInterface`
[1.6.0]: https://github.com/guzzle/psr7/compare/1.5.2...1.6.0
[1.5.2]: https://github.com/guzzle/psr7/compare/1.5.1...1.5.2
[1.5.1]: https://github.com/guzzle/psr7/compare/1.5.0...1.5.1
[1.5.0]: https://github.com/guzzle/psr7/compare/1.4.2...1.5.0
[1.4.2]: https://github.com/guzzle/psr7/compare/1.4.1...1.4.2
[1.4.1]: https://github.com/guzzle/psr7/compare/1.4.0...1.4.1
[1.4.0]: https://github.com/guzzle/psr7/compare/1.3.1...1.4.0
[1.3.1]: https://github.com/guzzle/psr7/compare/1.3.0...1.3.1
[1.3.0]: https://github.com/guzzle/psr7/compare/1.2.3...1.3.0
[1.2.3]: https://github.com/guzzle/psr7/compare/1.2.2...1.2.3
[1.2.2]: https://github.com/guzzle/psr7/compare/1.2.1...1.2.2
[1.2.1]: https://github.com/guzzle/psr7/compare/1.2.0...1.2.1
[1.2.0]: https://github.com/guzzle/psr7/compare/1.1.0...1.2.0
[1.1.0]: https://github.com/guzzle/psr7/compare/1.0.0...1.1.0

View File

@ -0,0 +1,26 @@
The MIT License (MIT)
Copyright (c) 2015 Michael Dowling <mtdowling@gmail.com>
Copyright (c) 2015 Márk Sági-Kazár <mark.sagikazar@gmail.com>
Copyright (c) 2015 Graham Campbell <hello@gjcampbell.co.uk>
Copyright (c) 2016 Tobias Schultze <webmaster@tubo-world.de>
Copyright (c) 2016 George Mponos <gmponos@gmail.com>
Copyright (c) 2018 Tobias Nyholm <tobias.nyholm@gmail.com>
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.

View File

@ -0,0 +1,887 @@
# PSR-7 Message Implementation
This repository contains a full [PSR-7](https://www.php-fig.org/psr/psr-7/)
message implementation, several stream decorators, and some helpful
functionality like query string parsing.
![CI](https://github.com/guzzle/psr7/workflows/CI/badge.svg)
![Static analysis](https://github.com/guzzle/psr7/workflows/Static%20analysis/badge.svg)
## Features
This package comes with a number of stream implementations and stream
decorators.
## Installation
```shell
composer require guzzlehttp/psr7
```
## Version Guidance
| Version | Status | PHP Version |
|---------|---------------------|--------------|
| 1.x | EOL (2024-06-30) | >=5.4,<8.2 |
| 2.x | Latest | >=7.2.5,<8.5 |
## AppendStream
`GuzzleHttp\Psr7\AppendStream`
Reads from multiple streams, one after the other.
```php
use GuzzleHttp\Psr7;
$a = Psr7\Utils::streamFor('abc, ');
$b = Psr7\Utils::streamFor('123.');
$composed = new Psr7\AppendStream([$a, $b]);
$composed->addStream(Psr7\Utils::streamFor(' Above all listen to me'));
echo $composed; // abc, 123. Above all listen to me.
```
## BufferStream
`GuzzleHttp\Psr7\BufferStream`
Provides a buffer stream that can be written to fill a buffer, and read
from to remove bytes from the buffer.
This stream returns a "hwm" metadata value that tells upstream consumers
what the configured high water mark of the stream is, or the maximum
preferred size of the buffer.
```php
use GuzzleHttp\Psr7;
// When more than 1024 bytes are in the buffer, it will begin returning
// false to writes. This is an indication that writers should slow down.
$buffer = new Psr7\BufferStream(1024);
```
## CachingStream
The CachingStream is used to allow seeking over previously read bytes on
non-seekable streams. This can be useful when transferring a non-seekable
entity body fails due to needing to rewind the stream (for example, resulting
from a redirect). Data that is read from the remote stream will be buffered in
a PHP temp stream so that previously read bytes are cached first in memory,
then on disk.
```php
use GuzzleHttp\Psr7;
$original = Psr7\Utils::streamFor(fopen('http://www.google.com', 'r'));
$stream = new Psr7\CachingStream($original);
$stream->read(1024);
echo $stream->tell();
// 1024
$stream->seek(0);
echo $stream->tell();
// 0
```
## DroppingStream
`GuzzleHttp\Psr7\DroppingStream`
Stream decorator that begins dropping data once the size of the underlying
stream becomes too full.
```php
use GuzzleHttp\Psr7;
// Create an empty stream
$stream = Psr7\Utils::streamFor();
// Start dropping data when the stream has more than 10 bytes
$dropping = new Psr7\DroppingStream($stream, 10);
$dropping->write('01234567890123456789');
echo $stream; // 0123456789
```
## FnStream
`GuzzleHttp\Psr7\FnStream`
Compose stream implementations based on a hash of functions.
Allows for easy testing and extension of a provided stream without needing
to create a concrete class for a simple extension point.
```php
use GuzzleHttp\Psr7;
$stream = Psr7\Utils::streamFor('hi');
$fnStream = Psr7\FnStream::decorate($stream, [
'rewind' => function () use ($stream) {
echo 'About to rewind - ';
$stream->rewind();
echo 'rewound!';
}
]);
$fnStream->rewind();
// Outputs: About to rewind - rewound!
```
## InflateStream
`GuzzleHttp\Psr7\InflateStream`
Uses PHP's zlib.inflate filter to inflate zlib (HTTP deflate, RFC1950) or gzipped (RFC1952) content.
This stream decorator converts the provided stream to a PHP stream resource,
then appends the zlib.inflate filter. The stream is then converted back
to a Guzzle stream resource to be used as a Guzzle stream.
## LazyOpenStream
`GuzzleHttp\Psr7\LazyOpenStream`
Lazily reads or writes to a file that is opened only after an IO operation
take place on the stream.
```php
use GuzzleHttp\Psr7;
$stream = new Psr7\LazyOpenStream('/path/to/file', 'r');
// The file has not yet been opened...
echo $stream->read(10);
// The file is opened and read from only when needed.
```
## LimitStream
`GuzzleHttp\Psr7\LimitStream`
LimitStream can be used to read a subset or slice of an existing stream object.
This can be useful for breaking a large file into smaller pieces to be sent in
chunks (e.g. Amazon S3's multipart upload API).
```php
use GuzzleHttp\Psr7;
$original = Psr7\Utils::streamFor(fopen('/tmp/test.txt', 'r+'));
echo $original->getSize();
// >>> 1048576
// Limit the size of the body to 1024 bytes and start reading from byte 2048
$stream = new Psr7\LimitStream($original, 1024, 2048);
echo $stream->getSize();
// >>> 1024
echo $stream->tell();
// >>> 0
```
## MultipartStream
`GuzzleHttp\Psr7\MultipartStream`
Stream that when read returns bytes for a streaming multipart or
multipart/form-data stream.
## NoSeekStream
`GuzzleHttp\Psr7\NoSeekStream`
NoSeekStream wraps a stream and does not allow seeking.
```php
use GuzzleHttp\Psr7;
$original = Psr7\Utils::streamFor('foo');
$noSeek = new Psr7\NoSeekStream($original);
echo $noSeek->read(3);
// foo
var_export($noSeek->isSeekable());
// false
$noSeek->seek(0);
var_export($noSeek->read(3));
// NULL
```
## PumpStream
`GuzzleHttp\Psr7\PumpStream`
Provides a read only stream that pumps data from a PHP callable.
When invoking the provided callable, the PumpStream will pass the amount of
data requested to read to the callable. The callable can choose to ignore
this value and return fewer or more bytes than requested. Any extra data
returned by the provided callable is buffered internally until drained using
the read() function of the PumpStream. The provided callable MUST return
false when there is no more data to read.
## Implementing stream decorators
Creating a stream decorator is very easy thanks to the
`GuzzleHttp\Psr7\StreamDecoratorTrait`. This trait provides methods that
implement `Psr\Http\Message\StreamInterface` by proxying to an underlying
stream. Just `use` the `StreamDecoratorTrait` and implement your custom
methods.
For example, let's say we wanted to call a specific function each time the last
byte is read from a stream. This could be implemented by overriding the
`read()` method.
```php
use Psr\Http\Message\StreamInterface;
use GuzzleHttp\Psr7\StreamDecoratorTrait;
class EofCallbackStream implements StreamInterface
{
use StreamDecoratorTrait;
private $callback;
private $stream;
public function __construct(StreamInterface $stream, callable $cb)
{
$this->stream = $stream;
$this->callback = $cb;
}
public function read($length)
{
$result = $this->stream->read($length);
// Invoke the callback when EOF is hit.
if ($this->eof()) {
($this->callback)();
}
return $result;
}
}
```
This decorator could be added to any existing stream and used like so:
```php
use GuzzleHttp\Psr7;
$original = Psr7\Utils::streamFor('foo');
$eofStream = new EofCallbackStream($original, function () {
echo 'EOF!';
});
$eofStream->read(2);
$eofStream->read(1);
// echoes "EOF!"
$eofStream->seek(0);
$eofStream->read(3);
// echoes "EOF!"
```
## PHP StreamWrapper
You can use the `GuzzleHttp\Psr7\StreamWrapper` class if you need to use a
PSR-7 stream as a PHP stream resource.
Use the `GuzzleHttp\Psr7\StreamWrapper::getResource()` method to create a PHP
stream from a PSR-7 stream.
```php
use GuzzleHttp\Psr7\StreamWrapper;
$stream = GuzzleHttp\Psr7\Utils::streamFor('hello!');
$resource = StreamWrapper::getResource($stream);
echo fread($resource, 6); // outputs hello!
```
# Static API
There are various static methods available under the `GuzzleHttp\Psr7` namespace.
## `GuzzleHttp\Psr7\Message::toString`
`public static function toString(MessageInterface $message): string`
Returns the string representation of an HTTP message.
```php
$request = new GuzzleHttp\Psr7\Request('GET', 'http://example.com');
echo GuzzleHttp\Psr7\Message::toString($request);
```
## `GuzzleHttp\Psr7\Message::bodySummary`
`public static function bodySummary(MessageInterface $message, int $truncateAt = 120): string|null`
Get a short summary of the message body.
Will return `null` if the response is not printable.
## `GuzzleHttp\Psr7\Message::rewindBody`
`public static function rewindBody(MessageInterface $message): void`
Attempts to rewind a message body and throws an exception on failure.
The body of the message will only be rewound if a call to `tell()`
returns a value other than `0`.
## `GuzzleHttp\Psr7\Message::parseMessage`
`public static function parseMessage(string $message): array`
Parses an HTTP message into an associative array.
The array contains the "start-line" key containing the start line of
the message, "headers" key containing an associative array of header
array values, and a "body" key containing the body of the message.
## `GuzzleHttp\Psr7\Message::parseRequestUri`
`public static function parseRequestUri(string $path, array $headers): string`
Constructs a URI for an HTTP request message.
## `GuzzleHttp\Psr7\Message::parseRequest`
`public static function parseRequest(string $message): Request`
Parses a request message string into a request object.
## `GuzzleHttp\Psr7\Message::parseResponse`
`public static function parseResponse(string $message): Response`
Parses a response message string into a response object.
## `GuzzleHttp\Psr7\Header::parse`
`public static function parse(string|array $header): array`
Parse an array of header values containing ";" separated data into an
array of associative arrays representing the header key value pair data
of the header. When a parameter does not contain a value, but just
contains a key, this function will inject a key with a '' string value.
## `GuzzleHttp\Psr7\Header::splitList`
`public static function splitList(string|string[] $header): string[]`
Splits a HTTP header defined to contain a comma-separated list into
each individual value:
```
$knownEtags = Header::splitList($request->getHeader('if-none-match'));
```
Example headers include `accept`, `cache-control` and `if-none-match`.
## `GuzzleHttp\Psr7\Header::normalize` (deprecated)
`public static function normalize(string|array $header): array`
`Header::normalize()` is deprecated in favor of [`Header::splitList()`](README.md#guzzlehttppsr7headersplitlist)
which performs the same operation with a cleaned up API and improved
documentation.
Converts an array of header values that may contain comma separated
headers into an array of headers with no comma separated values.
## `GuzzleHttp\Psr7\Query::parse`
`public static function parse(string $str, int|bool $urlEncoding = true): array`
Parse a query string into an associative array.
If multiple values are found for the same key, the value of that key
value pair will become an array. This function does not parse nested
PHP style arrays into an associative array (e.g., `foo[a]=1&foo[b]=2`
will be parsed into `['foo[a]' => '1', 'foo[b]' => '2'])`.
## `GuzzleHttp\Psr7\Query::build`
`public static function build(array $params, int|false $encoding = PHP_QUERY_RFC3986, bool $treatBoolsAsInts = true): string`
Build a query string from an array of key value pairs.
This function can use the return value of `parse()` to build a query
string. This function does not modify the provided keys when an array is
encountered (like `http_build_query()` would).
## `GuzzleHttp\Psr7\Utils::caselessRemove`
`public static function caselessRemove(iterable<string> $keys, $keys, array $data): array`
Remove the items given by the keys, case insensitively from the data.
## `GuzzleHttp\Psr7\Utils::copyToStream`
`public static function copyToStream(StreamInterface $source, StreamInterface $dest, int $maxLen = -1): void`
Copy the contents of a stream into another stream until the given number
of bytes have been read.
## `GuzzleHttp\Psr7\Utils::copyToString`
`public static function copyToString(StreamInterface $stream, int $maxLen = -1): string`
Copy the contents of a stream into a string until the given number of
bytes have been read.
## `GuzzleHttp\Psr7\Utils::hash`
`public static function hash(StreamInterface $stream, string $algo, bool $rawOutput = false): string`
Calculate a hash of a stream.
This method reads the entire stream to calculate a rolling hash, based on
PHP's `hash_init` functions.
## `GuzzleHttp\Psr7\Utils::modifyRequest`
`public static function modifyRequest(RequestInterface $request, array $changes): RequestInterface`
Clone and modify a request with the given changes.
This method is useful for reducing the number of clones needed to mutate
a message.
- method: (string) Changes the HTTP method.
- set_headers: (array) Sets the given headers.
- remove_headers: (array) Remove the given headers.
- body: (mixed) Sets the given body.
- uri: (UriInterface) Set the URI.
- query: (string) Set the query string value of the URI.
- version: (string) Set the protocol version.
## `GuzzleHttp\Psr7\Utils::readLine`
`public static function readLine(StreamInterface $stream, ?int $maxLength = null): string`
Read a line from the stream up to the maximum allowed buffer length.
## `GuzzleHttp\Psr7\Utils::redactUserInfo`
`public static function redactUserInfo(UriInterface $uri): UriInterface`
Redact the password in the user info part of a URI.
## `GuzzleHttp\Psr7\Utils::streamFor`
`public static function streamFor(resource|string|null|int|float|bool|StreamInterface|callable|\Iterator $resource = '', array $options = []): StreamInterface`
Create a new stream based on the input type.
Options is an associative array that can contain the following keys:
- metadata: Array of custom metadata.
- size: Size of the stream.
This method accepts the following `$resource` types:
- `Psr\Http\Message\StreamInterface`: Returns the value as-is.
- `string`: Creates a stream object that uses the given string as the contents.
- `resource`: Creates a stream object that wraps the given PHP stream resource.
- `Iterator`: If the provided value implements `Iterator`, then a read-only
stream object will be created that wraps the given iterable. Each time the
stream is read from, data from the iterator will fill a buffer and will be
continuously called until the buffer is equal to the requested read size.
Subsequent read calls will first read from the buffer and then call `next`
on the underlying iterator until it is exhausted.
- `object` with `__toString()`: If the object has the `__toString()` method,
the object will be cast to a string and then a stream will be returned that
uses the string value.
- `NULL`: When `null` is passed, an empty stream object is returned.
- `callable` When a callable is passed, a read-only stream object will be
created that invokes the given callable. The callable is invoked with the
number of suggested bytes to read. The callable can return any number of
bytes, but MUST return `false` when there is no more data to return. The
stream object that wraps the callable will invoke the callable until the
number of requested bytes are available. Any additional bytes will be
buffered and used in subsequent reads.
```php
$stream = GuzzleHttp\Psr7\Utils::streamFor('foo');
$stream = GuzzleHttp\Psr7\Utils::streamFor(fopen('/path/to/file', 'r'));
$generator = function ($bytes) {
for ($i = 0; $i < $bytes; $i++) {
yield ' ';
}
}
$stream = GuzzleHttp\Psr7\Utils::streamFor($generator(100));
```
## `GuzzleHttp\Psr7\Utils::tryFopen`
`public static function tryFopen(string $filename, string $mode): resource`
Safely opens a PHP stream resource using a filename.
When fopen fails, PHP normally raises a warning. This function adds an
error handler that checks for errors and throws an exception instead.
## `GuzzleHttp\Psr7\Utils::tryGetContents`
`public static function tryGetContents(resource $stream): string`
Safely gets the contents of a given stream.
When stream_get_contents fails, PHP normally raises a warning. This
function adds an error handler that checks for errors and throws an
exception instead.
## `GuzzleHttp\Psr7\Utils::uriFor`
`public static function uriFor(string|UriInterface $uri): UriInterface`
Returns a UriInterface for the given value.
This function accepts a string or UriInterface and returns a
UriInterface for the given value. If the value is already a
UriInterface, it is returned as-is.
## `GuzzleHttp\Psr7\MimeType::fromFilename`
`public static function fromFilename(string $filename): string|null`
Determines the mimetype of a file by looking at its extension.
## `GuzzleHttp\Psr7\MimeType::fromExtension`
`public static function fromExtension(string $extension): string|null`
Maps a file extensions to a mimetype.
## Upgrading from Function API
The static API was first introduced in 1.7.0, in order to mitigate problems with functions conflicting between global and local copies of the package. The function API was removed in 2.0.0. A migration table has been provided here for your convenience:
| Original Function | Replacement Method |
|----------------|----------------|
| `str` | `Message::toString` |
| `uri_for` | `Utils::uriFor` |
| `stream_for` | `Utils::streamFor` |
| `parse_header` | `Header::parse` |
| `normalize_header` | `Header::normalize` |
| `modify_request` | `Utils::modifyRequest` |
| `rewind_body` | `Message::rewindBody` |
| `try_fopen` | `Utils::tryFopen` |
| `copy_to_string` | `Utils::copyToString` |
| `copy_to_stream` | `Utils::copyToStream` |
| `hash` | `Utils::hash` |
| `readline` | `Utils::readLine` |
| `parse_request` | `Message::parseRequest` |
| `parse_response` | `Message::parseResponse` |
| `parse_query` | `Query::parse` |
| `build_query` | `Query::build` |
| `mimetype_from_filename` | `MimeType::fromFilename` |
| `mimetype_from_extension` | `MimeType::fromExtension` |
| `_parse_message` | `Message::parseMessage` |
| `_parse_request_uri` | `Message::parseRequestUri` |
| `get_message_body_summary` | `Message::bodySummary` |
| `_caseless_remove` | `Utils::caselessRemove` |
# Additional URI Methods
Aside from the standard `Psr\Http\Message\UriInterface` implementation in form of the `GuzzleHttp\Psr7\Uri` class,
this library also provides additional functionality when working with URIs as static methods.
## URI Types
An instance of `Psr\Http\Message\UriInterface` can either be an absolute URI or a relative reference.
An absolute URI has a scheme. A relative reference is used to express a URI relative to another URI,
the base URI. Relative references can be divided into several forms according to
[RFC 3986 Section 4.2](https://datatracker.ietf.org/doc/html/rfc3986#section-4.2):
- network-path references, e.g. `//example.com/path`
- absolute-path references, e.g. `/path`
- relative-path references, e.g. `subpath`
The following methods can be used to identify the type of the URI.
### `GuzzleHttp\Psr7\Uri::isAbsolute`
`public static function isAbsolute(UriInterface $uri): bool`
Whether the URI is absolute, i.e. it has a scheme.
### `GuzzleHttp\Psr7\Uri::isNetworkPathReference`
`public static function isNetworkPathReference(UriInterface $uri): bool`
Whether the URI is a network-path reference. A relative reference that begins with two slash characters is
termed an network-path reference.
### `GuzzleHttp\Psr7\Uri::isAbsolutePathReference`
`public static function isAbsolutePathReference(UriInterface $uri): bool`
Whether the URI is a absolute-path reference. A relative reference that begins with a single slash character is
termed an absolute-path reference.
### `GuzzleHttp\Psr7\Uri::isRelativePathReference`
`public static function isRelativePathReference(UriInterface $uri): bool`
Whether the URI is a relative-path reference. A relative reference that does not begin with a slash character is
termed a relative-path reference.
### `GuzzleHttp\Psr7\Uri::isSameDocumentReference`
`public static function isSameDocumentReference(UriInterface $uri, ?UriInterface $base = null): bool`
Whether the URI is a same-document reference. A same-document reference refers to a URI that is, aside from its
fragment component, identical to the base URI. When no base URI is given, only an empty URI reference
(apart from its fragment) is considered a same-document reference.
## URI Components
Additional methods to work with URI components.
### `GuzzleHttp\Psr7\Uri::isDefaultPort`
`public static function isDefaultPort(UriInterface $uri): bool`
Whether the URI has the default port of the current scheme. `Psr\Http\Message\UriInterface::getPort` may return null
or the standard port. This method can be used independently of the implementation.
### `GuzzleHttp\Psr7\Uri::composeComponents`
`public static function composeComponents($scheme, $authority, $path, $query, $fragment): string`
Composes a URI reference string from its various components according to
[RFC 3986 Section 5.3](https://datatracker.ietf.org/doc/html/rfc3986#section-5.3). Usually this method does not need
to be called manually but instead is used indirectly via `Psr\Http\Message\UriInterface::__toString`.
### `GuzzleHttp\Psr7\Uri::fromParts`
`public static function fromParts(array $parts): UriInterface`
Creates a URI from a hash of [`parse_url`](https://www.php.net/manual/en/function.parse-url.php) components.
### `GuzzleHttp\Psr7\Uri::withQueryValue`
`public static function withQueryValue(UriInterface $uri, $key, $value): UriInterface`
Creates a new URI with a specific query string value. Any existing query string values that exactly match the
provided key are removed and replaced with the given key value pair. A value of null will set the query string
key without a value, e.g. "key" instead of "key=value".
### `GuzzleHttp\Psr7\Uri::withQueryValues`
`public static function withQueryValues(UriInterface $uri, array $keyValueArray): UriInterface`
Creates a new URI with multiple query string values. It has the same behavior as `withQueryValue()` but for an
associative array of key => value.
### `GuzzleHttp\Psr7\Uri::withoutQueryValue`
`public static function withoutQueryValue(UriInterface $uri, $key): UriInterface`
Creates a new URI with a specific query string value removed. Any existing query string values that exactly match the
provided key are removed.
## Cross-Origin Detection
`GuzzleHttp\Psr7\UriComparator` provides methods to determine if a modified URL should be considered cross-origin.
### `GuzzleHttp\Psr7\UriComparator::isCrossOrigin`
`public static function isCrossOrigin(UriInterface $original, UriInterface $modified): bool`
Determines if a modified URL should be considered cross-origin with respect to an original URL.
## Reference Resolution
`GuzzleHttp\Psr7\UriResolver` provides methods to resolve a URI reference in the context of a base URI according
to [RFC 3986 Section 5](https://datatracker.ietf.org/doc/html/rfc3986#section-5). This is for example also what web
browsers do when resolving a link in a website based on the current request URI.
### `GuzzleHttp\Psr7\UriResolver::resolve`
`public static function resolve(UriInterface $base, UriInterface $rel): UriInterface`
Converts the relative URI into a new URI that is resolved against the base URI.
### `GuzzleHttp\Psr7\UriResolver::removeDotSegments`
`public static function removeDotSegments(string $path): string`
Removes dot segments from a path and returns the new path according to
[RFC 3986 Section 5.2.4](https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.4).
### `GuzzleHttp\Psr7\UriResolver::relativize`
`public static function relativize(UriInterface $base, UriInterface $target): UriInterface`
Returns the target URI as a relative reference from the base URI. This method is the counterpart to resolve():
```php
(string) $target === (string) UriResolver::resolve($base, UriResolver::relativize($base, $target))
```
One use-case is to use the current request URI as base URI and then generate relative links in your documents
to reduce the document size or offer self-contained downloadable document archives.
```php
$base = new Uri('http://example.com/a/b/');
echo UriResolver::relativize($base, new Uri('http://example.com/a/b/c')); // prints 'c'.
echo UriResolver::relativize($base, new Uri('http://example.com/a/x/y')); // prints '../x/y'.
echo UriResolver::relativize($base, new Uri('http://example.com/a/b/?q')); // prints '?q'.
echo UriResolver::relativize($base, new Uri('http://example.org/a/b/')); // prints '//example.org/a/b/'.
```
## Normalization and Comparison
`GuzzleHttp\Psr7\UriNormalizer` provides methods to normalize and compare URIs according to
[RFC 3986 Section 6](https://datatracker.ietf.org/doc/html/rfc3986#section-6).
### `GuzzleHttp\Psr7\UriNormalizer::normalize`
`public static function normalize(UriInterface $uri, $flags = self::PRESERVING_NORMALIZATIONS): UriInterface`
Returns a normalized URI. The scheme and host component are already normalized to lowercase per PSR-7 UriInterface.
This methods adds additional normalizations that can be configured with the `$flags` parameter which is a bitmask
of normalizations to apply. The following normalizations are available:
- `UriNormalizer::PRESERVING_NORMALIZATIONS`
Default normalizations which only include the ones that preserve semantics.
- `UriNormalizer::CAPITALIZE_PERCENT_ENCODING`
All letters within a percent-encoding triplet (e.g., "%3A") are case-insensitive, and should be capitalized.
Example: `http://example.org/a%c2%b1b` `http://example.org/a%C2%B1b`
- `UriNormalizer::DECODE_UNRESERVED_CHARACTERS`
Decodes percent-encoded octets of unreserved characters. For consistency, percent-encoded octets in the ranges of
ALPHA (%41%5A and %61%7A), DIGIT (%30%39), hyphen (%2D), period (%2E), underscore (%5F), or tilde (%7E) should
not be created by URI producers and, when found in a URI, should be decoded to their corresponding unreserved
characters by URI normalizers.
Example: `http://example.org/%7Eusern%61me/` `http://example.org/~username/`
- `UriNormalizer::CONVERT_EMPTY_PATH`
Converts the empty path to "/" for http and https URIs.
Example: `http://example.org` `http://example.org/`
- `UriNormalizer::REMOVE_DEFAULT_HOST`
Removes the default host of the given URI scheme from the URI. Only the "file" scheme defines the default host
"localhost". All of `file:/myfile`, `file:///myfile`, and `file://localhost/myfile` are equivalent according to
RFC 3986.
Example: `file://localhost/myfile` `file:///myfile`
- `UriNormalizer::REMOVE_DEFAULT_PORT`
Removes the default port of the given URI scheme from the URI.
Example: `http://example.org:80/` `http://example.org/`
- `UriNormalizer::REMOVE_DOT_SEGMENTS`
Removes unnecessary dot-segments. Dot-segments in relative-path references are not removed as it would
change the semantics of the URI reference.
Example: `http://example.org/../a/b/../c/./d.html` `http://example.org/a/c/d.html`
- `UriNormalizer::REMOVE_DUPLICATE_SLASHES`
Paths which include two or more adjacent slashes are converted to one. Webservers usually ignore duplicate slashes
and treat those URIs equivalent. But in theory those URIs do not need to be equivalent. So this normalization
may change the semantics. Encoded slashes (%2F) are not removed.
Example: `http://example.org//foo///bar.html` `http://example.org/foo/bar.html`
- `UriNormalizer::SORT_QUERY_PARAMETERS`
Sort query parameters with their values in alphabetical order. However, the order of parameters in a URI may be
significant (this is not defined by the standard). So this normalization is not safe and may change the semantics
of the URI.
Example: `?lang=en&article=fred` `?article=fred&lang=en`
### `GuzzleHttp\Psr7\UriNormalizer::isEquivalent`
`public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, $normalizations = self::PRESERVING_NORMALIZATIONS): bool`
Whether two URIs can be considered equivalent. Both URIs are normalized automatically before comparison with the given
`$normalizations` bitmask. The method also accepts relative URI references and returns true when they are equivalent.
This of course assumes they will be resolved against the same base URI. If this is not the case, determination of
equivalence or difference of relative references does not mean anything.
## Security
If you discover a security vulnerability within this package, please send an email to security@tidelift.com. All security vulnerabilities will be promptly addressed. Please do not disclose security-related issues publicly until a fix has been announced. Please see [Security Policy](https://github.com/guzzle/psr7/security/policy) for more information.
## License
Guzzle is made available under the MIT License (MIT). Please see [License File](LICENSE) for more information.
## For Enterprise
Available as part of the Tidelift Subscription
The maintainers of Guzzle and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/packagist-guzzlehttp-psr7?utm_source=packagist-guzzlehttp-psr7&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)

View File

@ -0,0 +1,93 @@
{
"name": "guzzlehttp\/psr7",
"description": "PSR-7 message implementation that also provides common utility methods",
"keywords": [
"request",
"response",
"message",
"stream",
"http",
"uri",
"url",
"psr-7"
],
"license": "MIT",
"authors": [
{
"name": "Graham Campbell",
"email": "hello@gjcampbell.co.uk",
"homepage": "https:\/\/github.com\/GrahamCampbell"
},
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https:\/\/github.com\/mtdowling"
},
{
"name": "George Mponos",
"email": "gmponos@gmail.com",
"homepage": "https:\/\/github.com\/gmponos"
},
{
"name": "Tobias Nyholm",
"email": "tobias.nyholm@gmail.com",
"homepage": "https:\/\/github.com\/Nyholm"
},
{
"name": "M\u00e1rk S\u00e1gi-Kaz\u00e1r",
"email": "mark.sagikazar@gmail.com",
"homepage": "https:\/\/github.com\/sagikazarmark"
},
{
"name": "Tobias Schultze",
"email": "webmaster@tubo-world.de",
"homepage": "https:\/\/github.com\/Tobion"
},
{
"name": "M\u00e1rk S\u00e1gi-Kaz\u00e1r",
"email": "mark.sagikazar@gmail.com",
"homepage": "https:\/\/sagikazarmark.hu"
}
],
"require": {
"php": "^7.2.5 || ^8.0",
"psr\/http-factory": "^1.0",
"psr\/http-message": "^1.1 || ^2.0",
"ralouphie\/getallheaders": "^3.0"
},
"provide": {
"psr\/http-factory-implementation": "1.0",
"psr\/http-message-implementation": "1.0"
},
"require-dev": {
"bamarni\/composer-bin-plugin": "^1.8.2",
"http-interop\/http-factory-tests": "0.9.0",
"phpunit\/phpunit": "^8.5.39 || ^9.6.20"
},
"suggest": {
"laminas\/laminas-httphandlerrunner": "Emit PSR-7 responses"
},
"autoload": {
"psr-4": {
"RegularLabs\\Scoped\\GuzzleHttp\\Psr7\\": "src\/"
}
},
"autoload-dev": {
"psr-4": {
"RegularLabs\\Scoped\\GuzzleHttp\\Tests\\Psr7\\": "tests\/"
}
},
"extra": {
"bamarni-bin": {
"bin-links": true,
"forward-command": false
}
},
"config": {
"allow-plugins": {
"bamarni\/composer-bin-plugin": true
},
"preferred-install": "dist",
"sort-packages": true
}
}

View File

@ -0,0 +1,203 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
use RegularLabs\Scoped\Psr\Http\Message\StreamInterface;
/**
* Reads from multiple streams, one after the other.
*
* This is a read-only stream decorator.
*/
final class AppendStream implements StreamInterface
{
/** @var StreamInterface[] Streams being decorated */
private $streams = [];
/** @var bool */
private $seekable = \true;
/** @var int */
private $current = 0;
/** @var int */
private $pos = 0;
/**
* @param StreamInterface[] $streams Streams to decorate. Each stream must
* be readable.
*/
public function __construct(array $streams = [])
{
foreach ($streams as $stream) {
$this->addStream($stream);
}
}
public function __toString(): string
{
try {
$this->rewind();
return $this->getContents();
} catch (\Throwable $e) {
if (\PHP_VERSION_ID >= 70400) {
throw $e;
}
trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), \E_USER_ERROR);
return '';
}
}
/**
* Add a stream to the AppendStream
*
* @param StreamInterface $stream Stream to append. Must be readable.
*
* @throws \InvalidArgumentException if the stream is not readable
*/
public function addStream(StreamInterface $stream): void
{
if (!$stream->isReadable()) {
throw new \InvalidArgumentException('Each stream must be readable');
}
// The stream is only seekable if all streams are seekable
if (!$stream->isSeekable()) {
$this->seekable = \false;
}
$this->streams[] = $stream;
}
public function getContents(): string
{
return Utils::copyToString($this);
}
/**
* Closes each attached stream.
*/
public function close(): void
{
$this->pos = $this->current = 0;
$this->seekable = \true;
foreach ($this->streams as $stream) {
$stream->close();
}
$this->streams = [];
}
/**
* Detaches each attached stream.
*
* Returns null as it's not clear which underlying stream resource to return.
*/
public function detach()
{
$this->pos = $this->current = 0;
$this->seekable = \true;
foreach ($this->streams as $stream) {
$stream->detach();
}
$this->streams = [];
return null;
}
public function tell(): int
{
return $this->pos;
}
/**
* Tries to calculate the size by adding the size of each stream.
*
* If any of the streams do not return a valid number, then the size of the
* append stream cannot be determined and null is returned.
*/
public function getSize(): ?int
{
$size = 0;
foreach ($this->streams as $stream) {
$s = $stream->getSize();
if ($s === null) {
return null;
}
$size += $s;
}
return $size;
}
public function eof(): bool
{
return !$this->streams || $this->current >= count($this->streams) - 1 && $this->streams[$this->current]->eof();
}
public function rewind(): void
{
$this->seek(0);
}
/**
* Attempts to seek to the given position. Only supports SEEK_SET.
*/
public function seek($offset, $whence = \SEEK_SET): void
{
if (!$this->seekable) {
throw new \RuntimeException('This AppendStream is not seekable');
} elseif ($whence !== \SEEK_SET) {
throw new \RuntimeException('The AppendStream can only seek with SEEK_SET');
}
$this->pos = $this->current = 0;
// Rewind each stream
foreach ($this->streams as $i => $stream) {
try {
$stream->rewind();
} catch (\Exception $e) {
throw new \RuntimeException('Unable to seek stream ' . $i . ' of the AppendStream', 0, $e);
}
}
// Seek to the actual position by reading from each stream
while ($this->pos < $offset && !$this->eof()) {
$result = $this->read(min(8096, $offset - $this->pos));
if ($result === '') {
break;
}
}
}
/**
* Reads from all of the appended streams until the length is met or EOF.
*/
public function read($length): string
{
$buffer = '';
$total = count($this->streams) - 1;
$remaining = $length;
$progressToNext = \false;
while ($remaining > 0) {
// Progress to the next stream if needed.
if ($progressToNext || $this->streams[$this->current]->eof()) {
$progressToNext = \false;
if ($this->current === $total) {
break;
}
++$this->current;
}
$result = $this->streams[$this->current]->read($remaining);
if ($result === '') {
$progressToNext = \true;
continue;
}
$buffer .= $result;
$remaining = $length - strlen($buffer);
}
$this->pos += strlen($buffer);
return $buffer;
}
public function isReadable(): bool
{
return \true;
}
public function isWritable(): bool
{
return \false;
}
public function isSeekable(): bool
{
return $this->seekable;
}
public function write($string): int
{
throw new \RuntimeException('Cannot write to an AppendStream');
}
/**
* @return mixed
*/
public function getMetadata($key = null)
{
return $key ? null : [];
}
}

View File

@ -0,0 +1,121 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
use RegularLabs\Scoped\Psr\Http\Message\StreamInterface;
/**
* Provides a buffer stream that can be written to to fill a buffer, and read
* from to remove bytes from the buffer.
*
* This stream returns a "hwm" metadata value that tells upstream consumers
* what the configured high water mark of the stream is, or the maximum
* preferred size of the buffer.
*/
final class BufferStream implements StreamInterface
{
/** @var int */
private $hwm;
/** @var string */
private $buffer = '';
/**
* @param int $hwm High water mark, representing the preferred maximum
* buffer size. If the size of the buffer exceeds the high
* water mark, then calls to write will continue to succeed
* but will return 0 to inform writers to slow down
* until the buffer has been drained by reading from it.
*/
public function __construct(int $hwm = 16384)
{
$this->hwm = $hwm;
}
public function __toString(): string
{
return $this->getContents();
}
public function getContents(): string
{
$buffer = $this->buffer;
$this->buffer = '';
return $buffer;
}
public function close(): void
{
$this->buffer = '';
}
public function detach()
{
$this->close();
return null;
}
public function getSize(): ?int
{
return strlen($this->buffer);
}
public function isReadable(): bool
{
return \true;
}
public function isWritable(): bool
{
return \true;
}
public function isSeekable(): bool
{
return \false;
}
public function rewind(): void
{
$this->seek(0);
}
public function seek($offset, $whence = \SEEK_SET): void
{
throw new \RuntimeException('Cannot seek a BufferStream');
}
public function eof(): bool
{
return strlen($this->buffer) === 0;
}
public function tell(): int
{
throw new \RuntimeException('Cannot determine the position of a BufferStream');
}
/**
* Reads data from the buffer.
*/
public function read($length): string
{
$currentLength = strlen($this->buffer);
if ($length >= $currentLength) {
// No need to slice the buffer because we don't have enough data.
$result = $this->buffer;
$this->buffer = '';
} else {
// Slice up the result to provide a subset of the buffer.
$result = substr($this->buffer, 0, $length);
$this->buffer = substr($this->buffer, $length);
}
return $result;
}
/**
* Writes data to the buffer.
*/
public function write($string): int
{
$this->buffer .= $string;
if (strlen($this->buffer) >= $this->hwm) {
return 0;
}
return strlen($string);
}
/**
* @return mixed
*/
public function getMetadata($key = null)
{
if ($key === 'hwm') {
return $this->hwm;
}
return $key ? null : [];
}
}

View File

@ -0,0 +1,125 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
use RegularLabs\Scoped\Psr\Http\Message\StreamInterface;
/**
* Stream decorator that can cache previously read bytes from a sequentially
* read stream.
*/
final class CachingStream implements StreamInterface
{
use StreamDecoratorTrait;
/** @var StreamInterface Stream being wrapped */
private $remoteStream;
/** @var int Number of bytes to skip reading due to a write on the buffer */
private $skipReadBytes = 0;
/**
* @var StreamInterface
*/
private $stream;
/**
* We will treat the buffer object as the body of the stream
*
* @param StreamInterface $stream Stream to cache. The cursor is assumed to be at the beginning of the stream.
* @param StreamInterface $target Optionally specify where data is cached
*/
public function __construct(StreamInterface $stream, ?StreamInterface $target = null)
{
$this->remoteStream = $stream;
$this->stream = $target ?: new Stream(Utils::tryFopen('php://temp', 'r+'));
}
public function getSize(): ?int
{
$remoteSize = $this->remoteStream->getSize();
if (null === $remoteSize) {
return null;
}
return max($this->stream->getSize(), $remoteSize);
}
public function rewind(): void
{
$this->seek(0);
}
public function seek($offset, $whence = \SEEK_SET): void
{
if ($whence === \SEEK_SET) {
$byte = $offset;
} elseif ($whence === \SEEK_CUR) {
$byte = $offset + $this->tell();
} elseif ($whence === \SEEK_END) {
$size = $this->remoteStream->getSize();
if ($size === null) {
$size = $this->cacheEntireStream();
}
$byte = $size + $offset;
} else {
throw new \InvalidArgumentException('Invalid whence');
}
$diff = $byte - $this->stream->getSize();
if ($diff > 0) {
// Read the remoteStream until we have read in at least the amount
// of bytes requested, or we reach the end of the file.
while ($diff > 0 && !$this->remoteStream->eof()) {
$this->read($diff);
$diff = $byte - $this->stream->getSize();
}
} else {
// We can just do a normal seek since we've already seen this byte.
$this->stream->seek($byte);
}
}
public function read($length): string
{
// Perform a regular read on any previously read data from the buffer
$data = $this->stream->read($length);
$remaining = $length - strlen($data);
// More data was requested so read from the remote stream
if ($remaining) {
// If data was written to the buffer in a position that would have
// been filled from the remote stream, then we must skip bytes on
// the remote stream to emulate overwriting bytes from that
// position. This mimics the behavior of other PHP stream wrappers.
$remoteData = $this->remoteStream->read($remaining + $this->skipReadBytes);
if ($this->skipReadBytes) {
$len = strlen($remoteData);
$remoteData = substr($remoteData, $this->skipReadBytes);
$this->skipReadBytes = max(0, $this->skipReadBytes - $len);
}
$data .= $remoteData;
$this->stream->write($remoteData);
}
return $data;
}
public function write($string): int
{
// When appending to the end of the currently read stream, you'll want
// to skip bytes from being read from the remote stream to emulate
// other stream wrappers. Basically replacing bytes of data of a fixed
// length.
$overflow = strlen($string) + $this->tell() - $this->remoteStream->tell();
if ($overflow > 0) {
$this->skipReadBytes += $overflow;
}
return $this->stream->write($string);
}
public function eof(): bool
{
return $this->stream->eof() && $this->remoteStream->eof();
}
/**
* Close both the remote stream and buffer stream
*/
public function close(): void
{
$this->remoteStream->close();
$this->stream->close();
}
private function cacheEntireStream(): int
{
$target = new FnStream(['write' => 'strlen']);
Utils::copyToStream($this, $target);
return $this->tell();
}
}

View File

@ -0,0 +1,40 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
use RegularLabs\Scoped\Psr\Http\Message\StreamInterface;
/**
* Stream decorator that begins dropping data once the size of the underlying
* stream becomes too full.
*/
final class DroppingStream implements StreamInterface
{
use StreamDecoratorTrait;
/** @var int */
private $maxLength;
/** @var StreamInterface */
private $stream;
/**
* @param StreamInterface $stream Underlying stream to decorate.
* @param int $maxLength Maximum size before dropping data.
*/
public function __construct(StreamInterface $stream, int $maxLength)
{
$this->stream = $stream;
$this->maxLength = $maxLength;
}
public function write($string): int
{
$diff = $this->maxLength - $this->stream->getSize();
// Begin returning 0 when the underlying stream is too large.
if ($diff <= 0) {
return 0;
}
// Write the stream or a subset of the stream if needed.
if (strlen($string) < $diff) {
return $this->stream->write($string);
}
return $this->stream->write(substr($string, 0, $diff));
}
}

View File

@ -0,0 +1,12 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7\Exception;
use InvalidArgumentException;
/**
* Exception thrown if a URI cannot be parsed because it's malformed.
*/
class MalformedUriException extends InvalidArgumentException
{
}

View File

@ -0,0 +1,149 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
use RegularLabs\Scoped\Psr\Http\Message\StreamInterface;
/**
* Compose stream implementations based on a hash of functions.
*
* Allows for easy testing and extension of a provided stream without needing
* to create a concrete class for a simple extension point.
*/
#[\AllowDynamicProperties]
final class FnStream implements StreamInterface
{
private const SLOTS = ['__toString', 'close', 'detach', 'rewind', 'getSize', 'tell', 'eof', 'isSeekable', 'seek', 'isWritable', 'write', 'isReadable', 'read', 'getContents', 'getMetadata'];
/** @var array<string, callable> */
private $methods;
/**
* @param array<string, callable> $methods Hash of method name to a callable.
*/
public function __construct(array $methods)
{
$this->methods = $methods;
// Create the functions on the class
foreach ($methods as $name => $fn) {
$this->{'_fn_' . $name} = $fn;
}
}
/**
* Lazily determine which methods are not implemented.
*
* @throws \BadMethodCallException
*/
public function __get(string $name): void
{
throw new \BadMethodCallException(str_replace('_fn_', '', $name) . '() is not implemented in the FnStream');
}
/**
* The close method is called on the underlying stream only if possible.
*/
public function __destruct()
{
if (isset($this->_fn_close)) {
($this->_fn_close)();
}
}
/**
* An unserialize would allow the __destruct to run when the unserialized value goes out of scope.
*
* @throws \LogicException
*/
public function __wakeup(): void
{
throw new \LogicException('FnStream should never be unserialized');
}
/**
* Adds custom functionality to an underlying stream by intercepting
* specific method calls.
*
* @param StreamInterface $stream Stream to decorate
* @param array<string, callable> $methods Hash of method name to a closure
*
* @return FnStream
*/
public static function decorate(StreamInterface $stream, array $methods)
{
// If any of the required methods were not provided, then simply
// proxy to the decorated stream.
foreach (array_diff(self::SLOTS, array_keys($methods)) as $diff) {
/** @var callable $callable */
$callable = [$stream, $diff];
$methods[$diff] = $callable;
}
return new self($methods);
}
public function __toString(): string
{
try {
/** @var string */
return ($this->_fn___toString)();
} catch (\Throwable $e) {
if (\PHP_VERSION_ID >= 70400) {
throw $e;
}
trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), \E_USER_ERROR);
return '';
}
}
public function close(): void
{
($this->_fn_close)();
}
public function detach()
{
return ($this->_fn_detach)();
}
public function getSize(): ?int
{
return ($this->_fn_getSize)();
}
public function tell(): int
{
return ($this->_fn_tell)();
}
public function eof(): bool
{
return ($this->_fn_eof)();
}
public function isSeekable(): bool
{
return ($this->_fn_isSeekable)();
}
public function rewind(): void
{
($this->_fn_rewind)();
}
public function seek($offset, $whence = \SEEK_SET): void
{
($this->_fn_seek)($offset, $whence);
}
public function isWritable(): bool
{
return ($this->_fn_isWritable)();
}
public function write($string): int
{
return ($this->_fn_write)($string);
}
public function isReadable(): bool
{
return ($this->_fn_isReadable)();
}
public function read($length): string
{
return ($this->_fn_read)($length);
}
public function getContents(): string
{
return ($this->_fn_getContents)();
}
/**
* @return mixed
*/
public function getMetadata($key = null)
{
return ($this->_fn_getMetadata)($key);
}
}

View File

@ -0,0 +1,117 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
final class Header
{
/**
* Parse an array of header values containing ";" separated data into an
* array of associative arrays representing the header key value pair data
* of the header. When a parameter does not contain a value, but just
* contains a key, this function will inject a key with a '' string value.
*
* @param string|array $header Header to parse into components.
*/
public static function parse($header): array
{
static $trimmed = "\"' \n\t\r";
$params = $matches = [];
foreach ((array) $header as $value) {
foreach (self::splitList($value) as $val) {
$part = [];
foreach (preg_split('/;(?=([^"]*"[^"]*")*[^"]*$)/', $val) ?: [] as $kvp) {
if (preg_match_all('/<[^>]+>|[^=]+/', $kvp, $matches)) {
$m = $matches[0];
if (isset($m[1])) {
$part[trim($m[0], $trimmed)] = trim($m[1], $trimmed);
} else {
$part[] = trim($m[0], $trimmed);
}
}
}
if ($part) {
$params[] = $part;
}
}
}
return $params;
}
/**
* Converts an array of header values that may contain comma separated
* headers into an array of headers with no comma separated values.
*
* @param string|array $header Header to normalize.
*
* @deprecated Use self::splitList() instead.
*/
public static function normalize($header): array
{
$result = [];
foreach ((array) $header as $value) {
foreach (self::splitList($value) as $parsed) {
$result[] = $parsed;
}
}
return $result;
}
/**
* Splits a HTTP header defined to contain a comma-separated list into
* each individual value. Empty values will be removed.
*
* Example headers include 'accept', 'cache-control' and 'if-none-match'.
*
* This method must not be used to parse headers that are not defined as
* a list, such as 'user-agent' or 'set-cookie'.
*
* @param string|string[] $values Header value as returned by MessageInterface::getHeader()
*
* @return string[]
*/
public static function splitList($values): array
{
if (!\is_array($values)) {
$values = [$values];
}
$result = [];
foreach ($values as $value) {
if (!\is_string($value)) {
throw new \TypeError('$header must either be a string or an array containing strings.');
}
$v = '';
$isQuoted = \false;
$isEscaped = \false;
for ($i = 0, $max = \strlen($value); $i < $max; ++$i) {
if ($isEscaped) {
$v .= $value[$i];
$isEscaped = \false;
continue;
}
if (!$isQuoted && $value[$i] === ',') {
$v = \trim($v);
if ($v !== '') {
$result[] = $v;
}
$v = '';
continue;
}
if ($isQuoted && $value[$i] === '\\') {
$isEscaped = \true;
$v .= $value[$i];
continue;
}
if ($value[$i] === '"') {
$isQuoted = !$isQuoted;
$v .= $value[$i];
continue;
}
$v .= $value[$i];
}
$v = \trim($v);
if ($v !== '') {
$result[] = $v;
}
}
return $result;
}
}

View File

@ -0,0 +1,76 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
use RegularLabs\Scoped\Psr\Http\Message\RequestFactoryInterface;
use RegularLabs\Scoped\Psr\Http\Message\RequestInterface;
use RegularLabs\Scoped\Psr\Http\Message\ResponseFactoryInterface;
use RegularLabs\Scoped\Psr\Http\Message\ResponseInterface;
use RegularLabs\Scoped\Psr\Http\Message\ServerRequestFactoryInterface;
use RegularLabs\Scoped\Psr\Http\Message\ServerRequestInterface;
use RegularLabs\Scoped\Psr\Http\Message\StreamFactoryInterface;
use RegularLabs\Scoped\Psr\Http\Message\StreamInterface;
use RegularLabs\Scoped\Psr\Http\Message\UploadedFileFactoryInterface;
use RegularLabs\Scoped\Psr\Http\Message\UploadedFileInterface;
use RegularLabs\Scoped\Psr\Http\Message\UriFactoryInterface;
use RegularLabs\Scoped\Psr\Http\Message\UriInterface;
/**
* Implements all of the PSR-17 interfaces.
*
* Note: in consuming code it is recommended to require the implemented interfaces
* and inject the instance of this class multiple times.
*/
final class HttpFactory implements RequestFactoryInterface, ResponseFactoryInterface, ServerRequestFactoryInterface, StreamFactoryInterface, UploadedFileFactoryInterface, UriFactoryInterface
{
public function createUploadedFile(StreamInterface $stream, ?int $size = null, int $error = \UPLOAD_ERR_OK, ?string $clientFilename = null, ?string $clientMediaType = null): UploadedFileInterface
{
if ($size === null) {
$size = $stream->getSize();
}
return new UploadedFile($stream, $size, $error, $clientFilename, $clientMediaType);
}
public function createStream(string $content = ''): StreamInterface
{
return Utils::streamFor($content);
}
public function createStreamFromFile(string $file, string $mode = 'r'): StreamInterface
{
try {
$resource = Utils::tryFopen($file, $mode);
} catch (\RuntimeException $e) {
if ('' === $mode || \false === \in_array($mode[0], ['r', 'w', 'a', 'x', 'c'], \true)) {
throw new \InvalidArgumentException(sprintf('Invalid file opening mode "%s"', $mode), 0, $e);
}
throw $e;
}
return Utils::streamFor($resource);
}
public function createStreamFromResource($resource): StreamInterface
{
return Utils::streamFor($resource);
}
public function createServerRequest(string $method, $uri, array $serverParams = []): ServerRequestInterface
{
if (empty($method)) {
if (!empty($serverParams['REQUEST_METHOD'])) {
$method = $serverParams['REQUEST_METHOD'];
} else {
throw new \InvalidArgumentException('Cannot determine HTTP method');
}
}
return new ServerRequest($method, $uri, [], null, '1.1', $serverParams);
}
public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface
{
return new Response($code, [], null, '1.1', $reasonPhrase);
}
public function createRequest(string $method, $uri): RequestInterface
{
return new Request($method, $uri);
}
public function createUri(string $uri = ''): UriInterface
{
return new Uri($uri);
}
}

View File

@ -0,0 +1,33 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
use RegularLabs\Scoped\Psr\Http\Message\StreamInterface;
/**
* Uses PHP's zlib.inflate filter to inflate zlib (HTTP deflate, RFC1950) or gzipped (RFC1952) content.
*
* This stream decorator converts the provided stream to a PHP stream resource,
* then appends the zlib.inflate filter. The stream is then converted back
* to a Guzzle stream resource to be used as a Guzzle stream.
*
* @see https://datatracker.ietf.org/doc/html/rfc1950
* @see https://datatracker.ietf.org/doc/html/rfc1952
* @see https://www.php.net/manual/en/filters.compression.php
*/
final class InflateStream implements StreamInterface
{
use StreamDecoratorTrait;
/** @var StreamInterface */
private $stream;
public function __construct(StreamInterface $stream)
{
$resource = StreamWrapper::getResource($stream);
// Specify window=15+32, so zlib will use header detection to both gzip (with header) and zlib data
// See https://www.zlib.net/manual.html#Advanced definition of inflateInit2
// "Add 32 to windowBits to enable zlib and gzip decoding with automatic header detection"
// Default window size is 15.
stream_filter_append($resource, 'zlib.inflate', \STREAM_FILTER_READ, ['window' => 15 + 32]);
$this->stream = $stream->isSeekable() ? new Stream($resource) : new NoSeekStream(new Stream($resource));
}
}

View File

@ -0,0 +1,41 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
use RegularLabs\Scoped\Psr\Http\Message\StreamInterface;
/**
* Lazily reads or writes to a file that is opened only after an IO operation
* take place on the stream.
*/
final class LazyOpenStream implements StreamInterface
{
use StreamDecoratorTrait;
/** @var string */
private $filename;
/** @var string */
private $mode;
/**
* @var StreamInterface
*/
private $stream;
/**
* @param string $filename File to lazily open
* @param string $mode fopen mode to use when opening the stream
*/
public function __construct(string $filename, string $mode)
{
$this->filename = $filename;
$this->mode = $mode;
// unsetting the property forces the first access to go through
// __get().
unset($this->stream);
}
/**
* Creates the underlying stream lazily when required.
*/
protected function createStream(): StreamInterface
{
return Utils::streamFor(Utils::tryFopen($this->filename, $this->mode));
}
}

View File

@ -0,0 +1,128 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
use RegularLabs\Scoped\Psr\Http\Message\StreamInterface;
/**
* Decorator used to return only a subset of a stream.
*/
final class LimitStream implements StreamInterface
{
use StreamDecoratorTrait;
/** @var int Offset to start reading from */
private $offset;
/** @var int Limit the number of bytes that can be read */
private $limit;
/** @var StreamInterface */
private $stream;
/**
* @param StreamInterface $stream Stream to wrap
* @param int $limit Total number of bytes to allow to be read
* from the stream. Pass -1 for no limit.
* @param int $offset Position to seek to before reading (only
* works on seekable streams).
*/
public function __construct(StreamInterface $stream, int $limit = -1, int $offset = 0)
{
$this->stream = $stream;
$this->setLimit($limit);
$this->setOffset($offset);
}
public function eof(): bool
{
// Always return true if the underlying stream is EOF
if ($this->stream->eof()) {
return \true;
}
// No limit and the underlying stream is not at EOF
if ($this->limit === -1) {
return \false;
}
return $this->stream->tell() >= $this->offset + $this->limit;
}
/**
* Returns the size of the limited subset of data
*/
public function getSize(): ?int
{
if (null === $length = $this->stream->getSize()) {
return null;
} elseif ($this->limit === -1) {
return $length - $this->offset;
} else {
return min($this->limit, $length - $this->offset);
}
}
/**
* Allow for a bounded seek on the read limited stream
*/
public function seek($offset, $whence = \SEEK_SET): void
{
if ($whence !== \SEEK_SET || $offset < 0) {
throw new \RuntimeException(sprintf('Cannot seek to offset %s with whence %s', $offset, $whence));
}
$offset += $this->offset;
if ($this->limit !== -1) {
if ($offset > $this->offset + $this->limit) {
$offset = $this->offset + $this->limit;
}
}
$this->stream->seek($offset);
}
/**
* Give a relative tell()
*/
public function tell(): int
{
return $this->stream->tell() - $this->offset;
}
/**
* Set the offset to start limiting from
*
* @param int $offset Offset to seek to and begin byte limiting from
*
* @throws \RuntimeException if the stream cannot be seeked.
*/
public function setOffset(int $offset): void
{
$current = $this->stream->tell();
if ($current !== $offset) {
// If the stream cannot seek to the offset position, then read to it
if ($this->stream->isSeekable()) {
$this->stream->seek($offset);
} elseif ($current > $offset) {
throw new \RuntimeException("Could not seek to stream offset {$offset}");
} else {
$this->stream->read($offset - $current);
}
}
$this->offset = $offset;
}
/**
* Set the limit of bytes that the decorator allows to be read from the
* stream.
*
* @param int $limit Number of bytes to allow to be read from the stream.
* Use -1 for no limit.
*/
public function setLimit(int $limit): void
{
$this->limit = $limit;
}
public function read($length): string
{
if ($this->limit === -1) {
return $this->stream->read($length);
}
// Check if the current position is less than the total allowed
// bytes + original offset
$remaining = $this->offset + $this->limit - $this->stream->tell();
if ($remaining > 0) {
// Only return the amount of requested data, ensuring that the byte
// limit is not exceeded
return $this->stream->read(min($remaining, $length));
}
return '';
}
}

View File

@ -0,0 +1,189 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
use RegularLabs\Scoped\Psr\Http\Message\MessageInterface;
use RegularLabs\Scoped\Psr\Http\Message\RequestInterface;
use RegularLabs\Scoped\Psr\Http\Message\ResponseInterface;
final class Message
{
/**
* Returns the string representation of an HTTP message.
*
* @param MessageInterface $message Message to convert to a string.
*/
public static function toString(MessageInterface $message): string
{
if ($message instanceof RequestInterface) {
$msg = trim($message->getMethod() . ' ' . $message->getRequestTarget()) . ' HTTP/' . $message->getProtocolVersion();
if (!$message->hasHeader('host')) {
$msg .= "\r\nHost: " . $message->getUri()->getHost();
}
} elseif ($message instanceof ResponseInterface) {
$msg = 'HTTP/' . $message->getProtocolVersion() . ' ' . $message->getStatusCode() . ' ' . $message->getReasonPhrase();
} else {
throw new \InvalidArgumentException('Unknown message type');
}
foreach ($message->getHeaders() as $name => $values) {
if (is_string($name) && strtolower($name) === 'set-cookie') {
foreach ($values as $value) {
$msg .= "\r\n{$name}: " . $value;
}
} else {
$msg .= "\r\n{$name}: " . implode(', ', $values);
}
}
return "{$msg}\r\n\r\n" . $message->getBody();
}
/**
* Get a short summary of the message body.
*
* Will return `null` if the response is not printable.
*
* @param MessageInterface $message The message to get the body summary
* @param int $truncateAt The maximum allowed size of the summary
*/
public static function bodySummary(MessageInterface $message, int $truncateAt = 120): ?string
{
$body = $message->getBody();
if (!$body->isSeekable() || !$body->isReadable()) {
return null;
}
$size = $body->getSize();
if ($size === 0) {
return null;
}
$body->rewind();
$summary = $body->read($truncateAt);
$body->rewind();
if ($size > $truncateAt) {
$summary .= ' (truncated...)';
}
// Matches any printable character, including unicode characters:
// letters, marks, numbers, punctuation, spacing, and separators.
if (preg_match('/[^\pL\pM\pN\pP\pS\pZ\n\r\t]/u', $summary) !== 0) {
return null;
}
return $summary;
}
/**
* Attempts to rewind a message body and throws an exception on failure.
*
* The body of the message will only be rewound if a call to `tell()`
* returns a value other than `0`.
*
* @param MessageInterface $message Message to rewind
*
* @throws \RuntimeException
*/
public static function rewindBody(MessageInterface $message): void
{
$body = $message->getBody();
if ($body->tell()) {
$body->rewind();
}
}
/**
* Parses an HTTP message into an associative array.
*
* The array contains the "start-line" key containing the start line of
* the message, "headers" key containing an associative array of header
* array values, and a "body" key containing the body of the message.
*
* @param string $message HTTP request or response to parse.
*/
public static function parseMessage(string $message): array
{
if (!$message) {
throw new \InvalidArgumentException('Invalid message');
}
$message = ltrim($message, "\r\n");
$messageParts = preg_split("/\r?\n\r?\n/", $message, 2);
if ($messageParts === \false || count($messageParts) !== 2) {
throw new \InvalidArgumentException('Invalid message: Missing header delimiter');
}
[$rawHeaders, $body] = $messageParts;
$rawHeaders .= "\r\n";
// Put back the delimiter we split previously
$headerParts = preg_split("/\r?\n/", $rawHeaders, 2);
if ($headerParts === \false || count($headerParts) !== 2) {
throw new \InvalidArgumentException('Invalid message: Missing status line');
}
[$startLine, $rawHeaders] = $headerParts;
if (preg_match("/(?:^HTTP\\/|^[A-Z]+ \\S+ HTTP\\/)(\\d+(?:\\.\\d+)?)/i", $startLine, $matches) && $matches[1] === '1.0') {
// Header folding is deprecated for HTTP/1.1, but allowed in HTTP/1.0
$rawHeaders = preg_replace(Rfc7230::HEADER_FOLD_REGEX, ' ', $rawHeaders);
}
/** @var array[] $headerLines */
$count = preg_match_all(Rfc7230::HEADER_REGEX, $rawHeaders, $headerLines, \PREG_SET_ORDER);
// If these aren't the same, then one line didn't match and there's an invalid header.
if ($count !== substr_count($rawHeaders, "\n")) {
// Folding is deprecated, see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4
if (preg_match(Rfc7230::HEADER_FOLD_REGEX, $rawHeaders)) {
throw new \InvalidArgumentException('Invalid header syntax: Obsolete line folding');
}
throw new \InvalidArgumentException('Invalid header syntax');
}
$headers = [];
foreach ($headerLines as $headerLine) {
$headers[$headerLine[1]][] = $headerLine[2];
}
return ['start-line' => $startLine, 'headers' => $headers, 'body' => $body];
}
/**
* Constructs a URI for an HTTP request message.
*
* @param string $path Path from the start-line
* @param array $headers Array of headers (each value an array).
*/
public static function parseRequestUri(string $path, array $headers): string
{
$hostKey = array_filter(array_keys($headers), function ($k) {
// Numeric array keys are converted to int by PHP.
$k = (string) $k;
return strtolower($k) === 'host';
});
// If no host is found, then a full URI cannot be constructed.
if (!$hostKey) {
return $path;
}
$host = $headers[reset($hostKey)][0];
$scheme = substr($host, -4) === ':443' ? 'https' : 'http';
return $scheme . '://' . $host . '/' . ltrim($path, '/');
}
/**
* Parses a request message string into a request object.
*
* @param string $message Request message string.
*/
public static function parseRequest(string $message): RequestInterface
{
$data = self::parseMessage($message);
$matches = [];
if (!preg_match('/^[\S]+\s+([a-zA-Z]+:\/\/|\/).*/', $data['start-line'], $matches)) {
throw new \InvalidArgumentException('Invalid request string');
}
$parts = explode(' ', $data['start-line'], 3);
$version = isset($parts[2]) ? explode('/', $parts[2])[1] : '1.1';
$request = new Request($parts[0], $matches[1] === '/' ? self::parseRequestUri($parts[1], $data['headers']) : $parts[1], $data['headers'], $data['body'], $version);
return $matches[1] === '/' ? $request : $request->withRequestTarget($parts[1]);
}
/**
* Parses a response message string into a response object.
*
* @param string $message Response message string.
*/
public static function parseResponse(string $message): ResponseInterface
{
$data = self::parseMessage($message);
// According to https://datatracker.ietf.org/doc/html/rfc7230#section-3.1.2
// the space between status-code and reason-phrase is required. But
// browsers accept responses without space and reason as well.
if (!preg_match('/^HTTP\/.* [0-9]{3}( .*|$)/', $data['start-line'])) {
throw new \InvalidArgumentException('Invalid response string: ' . $data['start-line']);
}
$parts = explode(' ', $data['start-line'], 3);
return new Response((int) $parts[1], $data['headers'], $data['body'], explode('/', $parts[0])[1], $parts[2] ?? null);
}
}

View File

@ -0,0 +1,212 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
use RegularLabs\Scoped\Psr\Http\Message\MessageInterface;
use RegularLabs\Scoped\Psr\Http\Message\StreamInterface;
/**
* Trait implementing functionality common to requests and responses.
*/
trait MessageTrait
{
/** @var string[][] Map of all registered headers, as original name => array of values */
private $headers = [];
/** @var string[] Map of lowercase header name => original name at registration */
private $headerNames = [];
/** @var string */
private $protocol = '1.1';
/** @var StreamInterface|null */
private $stream;
public function getProtocolVersion(): string
{
return $this->protocol;
}
public function withProtocolVersion($version): MessageInterface
{
if ($this->protocol === $version) {
return $this;
}
$new = clone $this;
$new->protocol = $version;
return $new;
}
public function getHeaders(): array
{
return $this->headers;
}
public function hasHeader($header): bool
{
return isset($this->headerNames[strtolower($header)]);
}
public function getHeader($header): array
{
$header = strtolower($header);
if (!isset($this->headerNames[$header])) {
return [];
}
$header = $this->headerNames[$header];
return $this->headers[$header];
}
public function getHeaderLine($header): string
{
return implode(', ', $this->getHeader($header));
}
public function withHeader($header, $value): MessageInterface
{
$this->assertHeader($header);
$value = $this->normalizeHeaderValue($value);
$normalized = strtolower($header);
$new = clone $this;
if (isset($new->headerNames[$normalized])) {
unset($new->headers[$new->headerNames[$normalized]]);
}
$new->headerNames[$normalized] = $header;
$new->headers[$header] = $value;
return $new;
}
public function withAddedHeader($header, $value): MessageInterface
{
$this->assertHeader($header);
$value = $this->normalizeHeaderValue($value);
$normalized = strtolower($header);
$new = clone $this;
if (isset($new->headerNames[$normalized])) {
$header = $this->headerNames[$normalized];
$new->headers[$header] = array_merge($this->headers[$header], $value);
} else {
$new->headerNames[$normalized] = $header;
$new->headers[$header] = $value;
}
return $new;
}
public function withoutHeader($header): MessageInterface
{
$normalized = strtolower($header);
if (!isset($this->headerNames[$normalized])) {
return $this;
}
$header = $this->headerNames[$normalized];
$new = clone $this;
unset($new->headers[$header], $new->headerNames[$normalized]);
return $new;
}
public function getBody(): StreamInterface
{
if (!$this->stream) {
$this->stream = Utils::streamFor('');
}
return $this->stream;
}
public function withBody(StreamInterface $body): MessageInterface
{
if ($body === $this->stream) {
return $this;
}
$new = clone $this;
$new->stream = $body;
return $new;
}
/**
* @param (string|string[])[] $headers
*/
private function setHeaders(array $headers): void
{
$this->headerNames = $this->headers = [];
foreach ($headers as $header => $value) {
// Numeric array keys are converted to int by PHP.
$header = (string) $header;
$this->assertHeader($header);
$value = $this->normalizeHeaderValue($value);
$normalized = strtolower($header);
if (isset($this->headerNames[$normalized])) {
$header = $this->headerNames[$normalized];
$this->headers[$header] = array_merge($this->headers[$header], $value);
} else {
$this->headerNames[$normalized] = $header;
$this->headers[$header] = $value;
}
}
}
/**
* @param mixed $value
*
* @return string[]
*/
private function normalizeHeaderValue($value): array
{
if (!is_array($value)) {
return $this->trimAndValidateHeaderValues([$value]);
}
if (count($value) === 0) {
throw new \InvalidArgumentException('Header value can not be an empty array.');
}
return $this->trimAndValidateHeaderValues($value);
}
/**
* Trims whitespace from the header values.
*
* Spaces and tabs ought to be excluded by parsers when extracting the field value from a header field.
*
* header-field = field-name ":" OWS field-value OWS
* OWS = *( SP / HTAB )
*
* @param mixed[] $values Header values
*
* @return string[] Trimmed header values
*
* @see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4
*/
private function trimAndValidateHeaderValues(array $values): array
{
return array_map(function ($value) {
if (!is_scalar($value) && null !== $value) {
throw new \InvalidArgumentException(sprintf('Header value must be scalar or null but %s provided.', is_object($value) ? get_class($value) : gettype($value)));
}
$trimmed = trim((string) $value, " \t");
$this->assertValue($trimmed);
return $trimmed;
}, array_values($values));
}
/**
* @see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2
*
* @param mixed $header
*/
private function assertHeader($header): void
{
if (!is_string($header)) {
throw new \InvalidArgumentException(sprintf('Header name must be a string but %s provided.', is_object($header) ? get_class($header) : gettype($header)));
}
if (!preg_match('/^[a-zA-Z0-9\'`#$%&*+.^_|~!-]+$/D', $header)) {
throw new \InvalidArgumentException(sprintf('"%s" is not valid header name.', $header));
}
}
/**
* @see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2
*
* field-value = *( field-content / obs-fold )
* field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
* field-vchar = VCHAR / obs-text
* VCHAR = %x21-7E
* obs-text = %x80-FF
* obs-fold = CRLF 1*( SP / HTAB )
*/
private function assertValue(string $value): void
{
// The regular expression intentionally does not support the obs-fold production, because as
// per RFC 7230#3.2.4:
//
// A sender MUST NOT generate a message that includes
// line folding (i.e., that has any field-value that contains a match to
// the obs-fold rule) unless the message is intended for packaging
// within the message/http media type.
//
// Clients must not send a request with line folding and a server sending folded headers is
// likely very rare. Line folding is a fairly obscure feature of HTTP/1.1 and thus not accepting
// folding is not likely to break any legitimate use case.
if (!preg_match('/^[\x20\x09\x21-\x7E\x80-\xFF]*$/D', $value)) {
throw new \InvalidArgumentException(sprintf('"%s" is not valid header value.', $value));
}
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,130 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
use RegularLabs\Scoped\Psr\Http\Message\StreamInterface;
/**
* Stream that when read returns bytes for a streaming multipart or
* multipart/form-data stream.
*/
final class MultipartStream implements StreamInterface
{
use StreamDecoratorTrait;
/** @var string */
private $boundary;
/** @var StreamInterface */
private $stream;
/**
* @param array $elements Array of associative arrays, each containing a
* required "name" key mapping to the form field,
* name, a required "contents" key mapping to a
* StreamInterface/resource/string, an optional
* "headers" associative array of custom headers,
* and an optional "filename" key mapping to a
* string to send as the filename in the part.
* @param string $boundary You can optionally provide a specific boundary
*
* @throws \InvalidArgumentException
*/
public function __construct(array $elements = [], ?string $boundary = null)
{
$this->boundary = $boundary ?: bin2hex(random_bytes(20));
$this->stream = $this->createStream($elements);
}
public function getBoundary(): string
{
return $this->boundary;
}
public function isWritable(): bool
{
return \false;
}
/**
* Get the headers needed before transferring the content of a POST file
*
* @param string[] $headers
*/
private function getHeaders(array $headers): string
{
$str = '';
foreach ($headers as $key => $value) {
$str .= "{$key}: {$value}\r\n";
}
return "--{$this->boundary}\r\n" . trim($str) . "\r\n\r\n";
}
/**
* Create the aggregate stream that will be used to upload the POST data
*/
protected function createStream(array $elements = []): StreamInterface
{
$stream = new AppendStream();
foreach ($elements as $element) {
if (!is_array($element)) {
throw new \UnexpectedValueException('An array is expected');
}
$this->addElement($stream, $element);
}
// Add the trailing boundary with CRLF
$stream->addStream(Utils::streamFor("--{$this->boundary}--\r\n"));
return $stream;
}
private function addElement(AppendStream $stream, array $element): void
{
foreach (['contents', 'name'] as $key) {
if (!array_key_exists($key, $element)) {
throw new \InvalidArgumentException("A '{$key}' key is required");
}
}
$element['contents'] = Utils::streamFor($element['contents']);
if (empty($element['filename'])) {
$uri = $element['contents']->getMetadata('uri');
if ($uri && \is_string($uri) && \substr($uri, 0, 6) !== 'php://' && \substr($uri, 0, 7) !== 'data://') {
$element['filename'] = $uri;
}
}
[$body, $headers] = $this->createElement($element['name'], $element['contents'], $element['filename'] ?? null, $element['headers'] ?? []);
$stream->addStream(Utils::streamFor($this->getHeaders($headers)));
$stream->addStream($body);
$stream->addStream(Utils::streamFor("\r\n"));
}
/**
* @param string[] $headers
*
* @return array{0: StreamInterface, 1: string[]}
*/
private function createElement(string $name, StreamInterface $stream, ?string $filename, array $headers): array
{
// Set a default content-disposition header if one was no provided
$disposition = self::getHeader($headers, 'content-disposition');
if (!$disposition) {
$headers['Content-Disposition'] = $filename === '0' || $filename ? sprintf('form-data; name="%s"; filename="%s"', $name, basename($filename)) : "form-data; name=\"{$name}\"";
}
// Set a default content-length header if one was no provided
$length = self::getHeader($headers, 'content-length');
if (!$length) {
if ($length = $stream->getSize()) {
$headers['Content-Length'] = (string) $length;
}
}
// Set a default Content-Type if one was not supplied
$type = self::getHeader($headers, 'content-type');
if (!$type && ($filename === '0' || $filename)) {
$headers['Content-Type'] = MimeType::fromFilename($filename) ?? 'application/octet-stream';
}
return [$stream, $headers];
}
/**
* @param string[] $headers
*/
private static function getHeader(array $headers, string $key): ?string
{
$lowercaseHeader = strtolower($key);
foreach ($headers as $k => $v) {
if (strtolower((string) $k) === $lowercaseHeader) {
return $v;
}
}
return null;
}
}

View File

@ -0,0 +1,23 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
use RegularLabs\Scoped\Psr\Http\Message\StreamInterface;
/**
* Stream decorator that prevents a stream from being seeked.
*/
final class NoSeekStream implements StreamInterface
{
use StreamDecoratorTrait;
/** @var StreamInterface */
private $stream;
public function seek($offset, $whence = \SEEK_SET): void
{
throw new \RuntimeException('Cannot seek a NoSeekStream');
}
public function isSeekable(): bool
{
return \false;
}
}

View File

@ -0,0 +1,149 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
use RegularLabs\Scoped\Psr\Http\Message\StreamInterface;
/**
* Provides a read only stream that pumps data from a PHP callable.
*
* When invoking the provided callable, the PumpStream will pass the amount of
* data requested to read to the callable. The callable can choose to ignore
* this value and return fewer or more bytes than requested. Any extra data
* returned by the provided callable is buffered internally until drained using
* the read() function of the PumpStream. The provided callable MUST return
* false when there is no more data to read.
*/
final class PumpStream implements StreamInterface
{
/** @var callable(int): (string|false|null)|null */
private $source;
/** @var int|null */
private $size;
/** @var int */
private $tellPos = 0;
/** @var array */
private $metadata;
/** @var BufferStream */
private $buffer;
/**
* @param callable(int): (string|false|null) $source Source of the stream data. The callable MAY
* accept an integer argument used to control the
* amount of data to return. The callable MUST
* return a string when called, or false|null on error
* or EOF.
* @param array{size?: int, metadata?: array} $options Stream options:
* - metadata: Hash of metadata to use with stream.
* - size: Size of the stream, if known.
*/
public function __construct(callable $source, array $options = [])
{
$this->source = $source;
$this->size = $options['size'] ?? null;
$this->metadata = $options['metadata'] ?? [];
$this->buffer = new BufferStream();
}
public function __toString(): string
{
try {
return Utils::copyToString($this);
} catch (\Throwable $e) {
if (\PHP_VERSION_ID >= 70400) {
throw $e;
}
trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), \E_USER_ERROR);
return '';
}
}
public function close(): void
{
$this->detach();
}
public function detach()
{
$this->tellPos = 0;
$this->source = null;
return null;
}
public function getSize(): ?int
{
return $this->size;
}
public function tell(): int
{
return $this->tellPos;
}
public function eof(): bool
{
return $this->source === null;
}
public function isSeekable(): bool
{
return \false;
}
public function rewind(): void
{
$this->seek(0);
}
public function seek($offset, $whence = \SEEK_SET): void
{
throw new \RuntimeException('Cannot seek a PumpStream');
}
public function isWritable(): bool
{
return \false;
}
public function write($string): int
{
throw new \RuntimeException('Cannot write to a PumpStream');
}
public function isReadable(): bool
{
return \true;
}
public function read($length): string
{
$data = $this->buffer->read($length);
$readLen = strlen($data);
$this->tellPos += $readLen;
$remaining = $length - $readLen;
if ($remaining) {
$this->pump($remaining);
$data .= $this->buffer->read($remaining);
$this->tellPos += strlen($data) - $readLen;
}
return $data;
}
public function getContents(): string
{
$result = '';
while (!$this->eof()) {
$result .= $this->read(1000000);
}
return $result;
}
/**
* @return mixed
*/
public function getMetadata($key = null)
{
if (!$key) {
return $this->metadata;
}
return $this->metadata[$key] ?? null;
}
private function pump(int $length): void
{
if ($this->source !== null) {
do {
$data = ($this->source)($length);
if ($data === \false || $data === null) {
$this->source = null;
return;
}
$this->buffer->write($data);
$length -= strlen($data);
} while ($length > 0);
}
}
}

View File

@ -0,0 +1,112 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
final class Query
{
/**
* Parse a query string into an associative array.
*
* If multiple values are found for the same key, the value of that key
* value pair will become an array. This function does not parse nested
* PHP style arrays into an associative array (e.g., `foo[a]=1&foo[b]=2`
* will be parsed into `['foo[a]' => '1', 'foo[b]' => '2'])`.
*
* @param string $str Query string to parse
* @param int|bool $urlEncoding How the query string is encoded
*/
public static function parse(string $str, $urlEncoding = \true): array
{
$result = [];
if ($str === '') {
return $result;
}
if ($urlEncoding === \true) {
$decoder = function ($value) {
return rawurldecode(str_replace('+', ' ', (string) $value));
};
} elseif ($urlEncoding === \PHP_QUERY_RFC3986) {
$decoder = 'rawurldecode';
} elseif ($urlEncoding === \PHP_QUERY_RFC1738) {
$decoder = 'urldecode';
} else {
$decoder = function ($str) {
return $str;
};
}
foreach (explode('&', $str) as $kvp) {
$parts = explode('=', $kvp, 2);
$key = $decoder($parts[0]);
$value = isset($parts[1]) ? $decoder($parts[1]) : null;
if (!array_key_exists($key, $result)) {
$result[$key] = $value;
} else {
if (!is_array($result[$key])) {
$result[$key] = [$result[$key]];
}
$result[$key][] = $value;
}
}
return $result;
}
/**
* Build a query string from an array of key value pairs.
*
* This function can use the return value of `parse()` to build a query
* string. This function does not modify the provided keys when an array is
* encountered (like `http_build_query()` would).
*
* @param array $params Query string parameters.
* @param int|false $encoding Set to false to not encode,
* PHP_QUERY_RFC3986 to encode using
* RFC3986, or PHP_QUERY_RFC1738 to
* encode using RFC1738.
* @param bool $treatBoolsAsInts Set to true to encode as 0/1, and
* false as false/true.
*/
public static function build(array $params, $encoding = \PHP_QUERY_RFC3986, bool $treatBoolsAsInts = \true): string
{
if (!$params) {
return '';
}
if ($encoding === \false) {
$encoder = function (string $str): string {
return $str;
};
} elseif ($encoding === \PHP_QUERY_RFC3986) {
$encoder = 'rawurlencode';
} elseif ($encoding === \PHP_QUERY_RFC1738) {
$encoder = 'urlencode';
} else {
throw new \InvalidArgumentException('Invalid type');
}
$castBool = $treatBoolsAsInts ? static function ($v) {
return (int) $v;
} : static function ($v) {
return $v ? 'true' : 'false';
};
$qs = '';
foreach ($params as $k => $v) {
$k = $encoder((string) $k);
if (!is_array($v)) {
$qs .= $k;
$v = is_bool($v) ? $castBool($v) : $v;
if ($v !== null) {
$qs .= '=' . $encoder((string) $v);
}
$qs .= '&';
} else {
foreach ($v as $vv) {
$qs .= $k;
$vv = is_bool($vv) ? $castBool($vv) : $vv;
if ($vv !== null) {
$qs .= '=' . $encoder((string) $vv);
}
$qs .= '&';
}
}
}
return $qs ? (string) substr($qs, 0, -1) : '';
}
}

View File

@ -0,0 +1,124 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
use InvalidArgumentException;
use RegularLabs\Scoped\Psr\Http\Message\RequestInterface;
use RegularLabs\Scoped\Psr\Http\Message\StreamInterface;
use RegularLabs\Scoped\Psr\Http\Message\UriInterface;
/**
* PSR-7 request implementation.
*/
class Request implements RequestInterface
{
use MessageTrait;
/** @var string */
private $method;
/** @var string|null */
private $requestTarget;
/** @var UriInterface */
private $uri;
/**
* @param string $method HTTP method
* @param string|UriInterface $uri URI
* @param (string|string[])[] $headers Request headers
* @param string|resource|StreamInterface|null $body Request body
* @param string $version Protocol version
*/
public function __construct(string $method, $uri, array $headers = [], $body = null, string $version = '1.1')
{
$this->assertMethod($method);
if (!$uri instanceof UriInterface) {
$uri = new Uri($uri);
}
$this->method = strtoupper($method);
$this->uri = $uri;
$this->setHeaders($headers);
$this->protocol = $version;
if (!isset($this->headerNames['host'])) {
$this->updateHostFromUri();
}
if ($body !== '' && $body !== null) {
$this->stream = Utils::streamFor($body);
}
}
public function getRequestTarget(): string
{
if ($this->requestTarget !== null) {
return $this->requestTarget;
}
$target = $this->uri->getPath();
if ($target === '') {
$target = '/';
}
if ($this->uri->getQuery() != '') {
$target .= '?' . $this->uri->getQuery();
}
return $target;
}
public function withRequestTarget($requestTarget): RequestInterface
{
if (preg_match('#\s#', $requestTarget)) {
throw new InvalidArgumentException('Invalid request target provided; cannot contain whitespace');
}
$new = clone $this;
$new->requestTarget = $requestTarget;
return $new;
}
public function getMethod(): string
{
return $this->method;
}
public function withMethod($method): RequestInterface
{
$this->assertMethod($method);
$new = clone $this;
$new->method = strtoupper($method);
return $new;
}
public function getUri(): UriInterface
{
return $this->uri;
}
public function withUri(UriInterface $uri, $preserveHost = \false): RequestInterface
{
if ($uri === $this->uri) {
return $this;
}
$new = clone $this;
$new->uri = $uri;
if (!$preserveHost || !isset($this->headerNames['host'])) {
$new->updateHostFromUri();
}
return $new;
}
private function updateHostFromUri(): void
{
$host = $this->uri->getHost();
if ($host == '') {
return;
}
if (($port = $this->uri->getPort()) !== null) {
$host .= ':' . $port;
}
if (isset($this->headerNames['host'])) {
$header = $this->headerNames['host'];
} else {
$header = 'Host';
$this->headerNames['host'] = 'Host';
}
// Ensure Host is the first header.
// See: https://datatracker.ietf.org/doc/html/rfc7230#section-5.4
$this->headers = [$header => [$host]] + $this->headers;
}
/**
* @param mixed $method
*/
private function assertMethod($method): void
{
if (!is_string($method) || $method === '') {
throw new InvalidArgumentException('Method must be a non-empty string.');
}
}
}

View File

@ -0,0 +1,78 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
use RegularLabs\Scoped\Psr\Http\Message\ResponseInterface;
use RegularLabs\Scoped\Psr\Http\Message\StreamInterface;
/**
* PSR-7 response implementation.
*/
class Response implements ResponseInterface
{
use MessageTrait;
/** Map of standard HTTP status code/reason phrases */
private const PHRASES = [100 => 'Continue', 101 => 'Switching Protocols', 102 => 'Processing', 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 207 => 'Multi-status', 208 => 'Already Reported', 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 306 => 'Switch Proxy', 307 => 'Temporary Redirect', 308 => 'Permanent Redirect', 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Time-out', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Large', 415 => 'Unsupported Media Type', 416 => 'Requested range not satisfiable', 417 => 'Expectation Failed', 418 => 'I\'m a teapot', 422 => 'Unprocessable Entity', 423 => 'Locked', 424 => 'Failed Dependency', 425 => 'Unordered Collection', 426 => 'Upgrade Required', 428 => 'Precondition Required', 429 => 'Too Many Requests', 431 => 'Request Header Fields Too Large', 451 => 'Unavailable For Legal Reasons', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Time-out', 505 => 'HTTP Version not supported', 506 => 'Variant Also Negotiates', 507 => 'Insufficient Storage', 508 => 'Loop Detected', 510 => 'Not Extended', 511 => 'Network Authentication Required'];
/** @var string */
private $reasonPhrase;
/** @var int */
private $statusCode;
/**
* @param int $status Status code
* @param (string|string[])[] $headers Response headers
* @param string|resource|StreamInterface|null $body Response body
* @param string $version Protocol version
* @param string|null $reason Reason phrase (when empty a default will be used based on the status code)
*/
public function __construct(int $status = 200, array $headers = [], $body = null, string $version = '1.1', ?string $reason = null)
{
$this->assertStatusCodeRange($status);
$this->statusCode = $status;
if ($body !== '' && $body !== null) {
$this->stream = Utils::streamFor($body);
}
$this->setHeaders($headers);
if ($reason == '' && isset(self::PHRASES[$this->statusCode])) {
$this->reasonPhrase = self::PHRASES[$this->statusCode];
} else {
$this->reasonPhrase = (string) $reason;
}
$this->protocol = $version;
}
public function getStatusCode(): int
{
return $this->statusCode;
}
public function getReasonPhrase(): string
{
return $this->reasonPhrase;
}
public function withStatus($code, $reasonPhrase = ''): ResponseInterface
{
$this->assertStatusCodeIsInteger($code);
$code = (int) $code;
$this->assertStatusCodeRange($code);
$new = clone $this;
$new->statusCode = $code;
if ($reasonPhrase == '' && isset(self::PHRASES[$new->statusCode])) {
$reasonPhrase = self::PHRASES[$new->statusCode];
}
$new->reasonPhrase = (string) $reasonPhrase;
return $new;
}
/**
* @param mixed $statusCode
*/
private function assertStatusCodeIsInteger($statusCode): void
{
if (filter_var($statusCode, \FILTER_VALIDATE_INT) === \false) {
throw new \InvalidArgumentException('Status code must be an integer value.');
}
}
private function assertStatusCodeRange(int $statusCode): void
{
if ($statusCode < 100 || $statusCode >= 600) {
throw new \InvalidArgumentException('Status code must be an integer value between 1xx and 5xx.');
}
}
}

View File

@ -0,0 +1,22 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
/**
* @internal
*/
final class Rfc7230
{
/**
* Header related regular expressions (based on amphp/http package)
*
* Note: header delimiter (\r\n) is modified to \r?\n to accept line feed only delimiters for BC reasons.
*
* @see https://github.com/amphp/http/blob/v1.0.1/src/Rfc7230.php#L12-L15
*
* @license https://github.com/amphp/http/blob/v1.0.1/LICENSE
*/
public const HEADER_REGEX = "(^([^()<>@,;:\\\"/[\\]?={}\x01- ]++):[ \t]*+((?:[ \t]*+[!-~\x80-\xff]++)*+)[ \t]*+\r?\n)m";
public const HEADER_FOLD_REGEX = "(\r?\n[ \t]++)";
}

View File

@ -0,0 +1,266 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
use InvalidArgumentException;
use RegularLabs\Scoped\Psr\Http\Message\ServerRequestInterface;
use RegularLabs\Scoped\Psr\Http\Message\StreamInterface;
use RegularLabs\Scoped\Psr\Http\Message\UploadedFileInterface;
use RegularLabs\Scoped\Psr\Http\Message\UriInterface;
/**
* Server-side HTTP request
*
* Extends the Request definition to add methods for accessing incoming data,
* specifically server parameters, cookies, matched path parameters, query
* string arguments, body parameters, and upload file information.
*
* "Attributes" are discovered via decomposing the request (and usually
* specifically the URI path), and typically will be injected by the application.
*
* Requests are considered immutable; all methods that might change state are
* implemented such that they retain the internal state of the current
* message and return a new instance that contains the changed state.
*/
class ServerRequest extends Request implements ServerRequestInterface
{
/**
* @var array
*/
private $attributes = [];
/**
* @var array
*/
private $cookieParams = [];
/**
* @var array|object|null
*/
private $parsedBody;
/**
* @var array
*/
private $queryParams = [];
/**
* @var array
*/
private $serverParams;
/**
* @var array
*/
private $uploadedFiles = [];
/**
* @param string $method HTTP method
* @param string|UriInterface $uri URI
* @param (string|string[])[] $headers Request headers
* @param string|resource|StreamInterface|null $body Request body
* @param string $version Protocol version
* @param array $serverParams Typically the $_SERVER superglobal
*/
public function __construct(string $method, $uri, array $headers = [], $body = null, string $version = '1.1', array $serverParams = [])
{
$this->serverParams = $serverParams;
parent::__construct($method, $uri, $headers, $body, $version);
}
/**
* Return an UploadedFile instance array.
*
* @param array $files An array which respect $_FILES structure
*
* @throws InvalidArgumentException for unrecognized values
*/
public static function normalizeFiles(array $files): array
{
$normalized = [];
foreach ($files as $key => $value) {
if ($value instanceof UploadedFileInterface) {
$normalized[$key] = $value;
} elseif (is_array($value) && isset($value['tmp_name'])) {
$normalized[$key] = self::createUploadedFileFromSpec($value);
} elseif (is_array($value)) {
$normalized[$key] = self::normalizeFiles($value);
continue;
} else {
throw new InvalidArgumentException('Invalid value in files specification');
}
}
return $normalized;
}
/**
* Create and return an UploadedFile instance from a $_FILES specification.
*
* If the specification represents an array of values, this method will
* delegate to normalizeNestedFileSpec() and return that return value.
*
* @param array $value $_FILES struct
*
* @return UploadedFileInterface|UploadedFileInterface[]
*/
private static function createUploadedFileFromSpec(array $value)
{
if (is_array($value['tmp_name'])) {
return self::normalizeNestedFileSpec($value);
}
return new UploadedFile($value['tmp_name'], (int) $value['size'], (int) $value['error'], $value['name'], $value['type']);
}
/**
* Normalize an array of file specifications.
*
* Loops through all nested files and returns a normalized array of
* UploadedFileInterface instances.
*
* @return UploadedFileInterface[]
*/
private static function normalizeNestedFileSpec(array $files = []): array
{
$normalizedFiles = [];
foreach (array_keys($files['tmp_name']) as $key) {
$spec = ['tmp_name' => $files['tmp_name'][$key], 'size' => $files['size'][$key] ?? null, 'error' => $files['error'][$key] ?? null, 'name' => $files['name'][$key] ?? null, 'type' => $files['type'][$key] ?? null];
$normalizedFiles[$key] = self::createUploadedFileFromSpec($spec);
}
return $normalizedFiles;
}
/**
* Return a ServerRequest populated with superglobals:
* $_GET
* $_POST
* $_COOKIE
* $_FILES
* $_SERVER
*/
public static function fromGlobals(): ServerRequestInterface
{
$method = $_SERVER['REQUEST_METHOD'] ?? 'GET';
$headers = getallheaders();
$uri = self::getUriFromGlobals();
$body = new CachingStream(new LazyOpenStream('php://input', 'r+'));
$protocol = isset($_SERVER['SERVER_PROTOCOL']) ? str_replace('HTTP/', '', $_SERVER['SERVER_PROTOCOL']) : '1.1';
$serverRequest = new ServerRequest($method, $uri, $headers, $body, $protocol, $_SERVER);
return $serverRequest->withCookieParams($_COOKIE)->withQueryParams($_GET)->withParsedBody($_POST)->withUploadedFiles(self::normalizeFiles($_FILES));
}
private static function extractHostAndPortFromAuthority(string $authority): array
{
$uri = 'http://' . $authority;
$parts = parse_url($uri);
if (\false === $parts) {
return [null, null];
}
$host = $parts['host'] ?? null;
$port = $parts['port'] ?? null;
return [$host, $port];
}
/**
* Get a Uri populated with values from $_SERVER.
*/
public static function getUriFromGlobals(): UriInterface
{
$uri = new Uri('');
$uri = $uri->withScheme(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http');
$hasPort = \false;
if (isset($_SERVER['HTTP_HOST'])) {
[$host, $port] = self::extractHostAndPortFromAuthority($_SERVER['HTTP_HOST']);
if ($host !== null) {
$uri = $uri->withHost($host);
}
if ($port !== null) {
$hasPort = \true;
$uri = $uri->withPort($port);
}
} elseif (isset($_SERVER['SERVER_NAME'])) {
$uri = $uri->withHost($_SERVER['SERVER_NAME']);
} elseif (isset($_SERVER['SERVER_ADDR'])) {
$uri = $uri->withHost($_SERVER['SERVER_ADDR']);
}
if (!$hasPort && isset($_SERVER['SERVER_PORT'])) {
$uri = $uri->withPort($_SERVER['SERVER_PORT']);
}
$hasQuery = \false;
if (isset($_SERVER['REQUEST_URI'])) {
$requestUriParts = explode('?', $_SERVER['REQUEST_URI'], 2);
$uri = $uri->withPath($requestUriParts[0]);
if (isset($requestUriParts[1])) {
$hasQuery = \true;
$uri = $uri->withQuery($requestUriParts[1]);
}
}
if (!$hasQuery && isset($_SERVER['QUERY_STRING'])) {
$uri = $uri->withQuery($_SERVER['QUERY_STRING']);
}
return $uri;
}
public function getServerParams(): array
{
return $this->serverParams;
}
public function getUploadedFiles(): array
{
return $this->uploadedFiles;
}
public function withUploadedFiles(array $uploadedFiles): ServerRequestInterface
{
$new = clone $this;
$new->uploadedFiles = $uploadedFiles;
return $new;
}
public function getCookieParams(): array
{
return $this->cookieParams;
}
public function withCookieParams(array $cookies): ServerRequestInterface
{
$new = clone $this;
$new->cookieParams = $cookies;
return $new;
}
public function getQueryParams(): array
{
return $this->queryParams;
}
public function withQueryParams(array $query): ServerRequestInterface
{
$new = clone $this;
$new->queryParams = $query;
return $new;
}
/**
* @return array|object|null
*/
public function getParsedBody()
{
return $this->parsedBody;
}
public function withParsedBody($data): ServerRequestInterface
{
$new = clone $this;
$new->parsedBody = $data;
return $new;
}
public function getAttributes(): array
{
return $this->attributes;
}
/**
* @return mixed
*/
public function getAttribute($attribute, $default = null)
{
if (\false === array_key_exists($attribute, $this->attributes)) {
return $default;
}
return $this->attributes[$attribute];
}
public function withAttribute($attribute, $value): ServerRequestInterface
{
$new = clone $this;
$new->attributes[$attribute] = $value;
return $new;
}
public function withoutAttribute($attribute): ServerRequestInterface
{
if (\false === array_key_exists($attribute, $this->attributes)) {
return $this;
}
$new = clone $this;
unset($new->attributes[$attribute]);
return $new;
}
}

View File

@ -0,0 +1,235 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
use RegularLabs\Scoped\Psr\Http\Message\StreamInterface;
/**
* PHP stream implementation.
*/
class Stream implements StreamInterface
{
/**
* @see https://www.php.net/manual/en/function.fopen.php
* @see https://www.php.net/manual/en/function.gzopen.php
*/
private const READABLE_MODES = '/r|a\+|ab\+|w\+|wb\+|x\+|xb\+|c\+|cb\+/';
private const WRITABLE_MODES = '/a|w|r\+|rb\+|rw|x|c/';
/** @var resource */
private $stream;
/** @var int|null */
private $size;
/** @var bool */
private $seekable;
/** @var bool */
private $readable;
/** @var bool */
private $writable;
/** @var string|null */
private $uri;
/** @var mixed[] */
private $customMetadata;
/**
* This constructor accepts an associative array of options.
*
* - size: (int) If a read stream would otherwise have an indeterminate
* size, but the size is known due to foreknowledge, then you can
* provide that size, in bytes.
* - metadata: (array) Any additional metadata to return when the metadata
* of the stream is accessed.
*
* @param resource $stream Stream resource to wrap.
* @param array{size?: int, metadata?: array} $options Associative array of options.
*
* @throws \InvalidArgumentException if the stream is not a stream resource
*/
public function __construct($stream, array $options = [])
{
if (!is_resource($stream)) {
throw new \InvalidArgumentException('Stream must be a resource');
}
if (isset($options['size'])) {
$this->size = $options['size'];
}
$this->customMetadata = $options['metadata'] ?? [];
$this->stream = $stream;
$meta = stream_get_meta_data($this->stream);
$this->seekable = $meta['seekable'];
$this->readable = (bool) preg_match(self::READABLE_MODES, $meta['mode']);
$this->writable = (bool) preg_match(self::WRITABLE_MODES, $meta['mode']);
$this->uri = $this->getMetadata('uri');
}
/**
* Closes the stream when the destructed
*/
public function __destruct()
{
$this->close();
}
public function __toString(): string
{
try {
if ($this->isSeekable()) {
$this->seek(0);
}
return $this->getContents();
} catch (\Throwable $e) {
if (\PHP_VERSION_ID >= 70400) {
throw $e;
}
trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), \E_USER_ERROR);
return '';
}
}
public function getContents(): string
{
if (!isset($this->stream)) {
throw new \RuntimeException('Stream is detached');
}
if (!$this->readable) {
throw new \RuntimeException('Cannot read from non-readable stream');
}
return Utils::tryGetContents($this->stream);
}
public function close(): void
{
if (isset($this->stream)) {
if (is_resource($this->stream)) {
fclose($this->stream);
}
$this->detach();
}
}
public function detach()
{
if (!isset($this->stream)) {
return null;
}
$result = $this->stream;
unset($this->stream);
$this->size = $this->uri = null;
$this->readable = $this->writable = $this->seekable = \false;
return $result;
}
public function getSize(): ?int
{
if ($this->size !== null) {
return $this->size;
}
if (!isset($this->stream)) {
return null;
}
// Clear the stat cache if the stream has a URI
if ($this->uri) {
clearstatcache(\true, $this->uri);
}
$stats = fstat($this->stream);
if (is_array($stats) && isset($stats['size'])) {
$this->size = $stats['size'];
return $this->size;
}
return null;
}
public function isReadable(): bool
{
return $this->readable;
}
public function isWritable(): bool
{
return $this->writable;
}
public function isSeekable(): bool
{
return $this->seekable;
}
public function eof(): bool
{
if (!isset($this->stream)) {
throw new \RuntimeException('Stream is detached');
}
return feof($this->stream);
}
public function tell(): int
{
if (!isset($this->stream)) {
throw new \RuntimeException('Stream is detached');
}
$result = ftell($this->stream);
if ($result === \false) {
throw new \RuntimeException('Unable to determine stream position');
}
return $result;
}
public function rewind(): void
{
$this->seek(0);
}
public function seek($offset, $whence = \SEEK_SET): void
{
$whence = (int) $whence;
if (!isset($this->stream)) {
throw new \RuntimeException('Stream is detached');
}
if (!$this->seekable) {
throw new \RuntimeException('Stream is not seekable');
}
if (fseek($this->stream, $offset, $whence) === -1) {
throw new \RuntimeException('Unable to seek to stream position ' . $offset . ' with whence ' . var_export($whence, \true));
}
}
public function read($length): string
{
if (!isset($this->stream)) {
throw new \RuntimeException('Stream is detached');
}
if (!$this->readable) {
throw new \RuntimeException('Cannot read from non-readable stream');
}
if ($length < 0) {
throw new \RuntimeException('Length parameter cannot be negative');
}
if (0 === $length) {
return '';
}
try {
$string = fread($this->stream, $length);
} catch (\Exception $e) {
throw new \RuntimeException('Unable to read from stream', 0, $e);
}
if (\false === $string) {
throw new \RuntimeException('Unable to read from stream');
}
return $string;
}
public function write($string): int
{
if (!isset($this->stream)) {
throw new \RuntimeException('Stream is detached');
}
if (!$this->writable) {
throw new \RuntimeException('Cannot write to a non-writable stream');
}
// We can't know the size after writing anything
$this->size = null;
$result = fwrite($this->stream, $string);
if ($result === \false) {
throw new \RuntimeException('Unable to write to stream');
}
return $result;
}
/**
* @return mixed
*/
public function getMetadata($key = null)
{
if (!isset($this->stream)) {
return $key ? null : [];
} elseif (!$key) {
return $this->customMetadata + stream_get_meta_data($this->stream);
} elseif (isset($this->customMetadata[$key])) {
return $this->customMetadata[$key];
}
$meta = stream_get_meta_data($this->stream);
return $meta[$key] ?? null;
}
}

View File

@ -0,0 +1,131 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
use RegularLabs\Scoped\Psr\Http\Message\StreamInterface;
/**
* Stream decorator trait
*
* @property StreamInterface $stream
*/
trait StreamDecoratorTrait
{
/**
* @param StreamInterface $stream Stream to decorate
*/
public function __construct(StreamInterface $stream)
{
$this->stream = $stream;
}
/**
* Magic method used to create a new stream if streams are not added in
* the constructor of a decorator (e.g., LazyOpenStream).
*
* @return StreamInterface
*/
public function __get(string $name)
{
if ($name === 'stream') {
$this->stream = $this->createStream();
return $this->stream;
}
throw new \UnexpectedValueException("{$name} not found on class");
}
public function __toString(): string
{
try {
if ($this->isSeekable()) {
$this->seek(0);
}
return $this->getContents();
} catch (\Throwable $e) {
if (\PHP_VERSION_ID >= 70400) {
throw $e;
}
trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), \E_USER_ERROR);
return '';
}
}
public function getContents(): string
{
return Utils::copyToString($this);
}
/**
* Allow decorators to implement custom methods
*
* @return mixed
*/
public function __call(string $method, array $args)
{
/** @var callable $callable */
$callable = [$this->stream, $method];
$result = $callable(...$args);
// Always return the wrapped object if the result is a return $this
return $result === $this->stream ? $this : $result;
}
public function close(): void
{
$this->stream->close();
}
/**
* @return mixed
*/
public function getMetadata($key = null)
{
return $this->stream->getMetadata($key);
}
public function detach()
{
return $this->stream->detach();
}
public function getSize(): ?int
{
return $this->stream->getSize();
}
public function eof(): bool
{
return $this->stream->eof();
}
public function tell(): int
{
return $this->stream->tell();
}
public function isReadable(): bool
{
return $this->stream->isReadable();
}
public function isWritable(): bool
{
return $this->stream->isWritable();
}
public function isSeekable(): bool
{
return $this->stream->isSeekable();
}
public function rewind(): void
{
$this->seek(0);
}
public function seek($offset, $whence = \SEEK_SET): void
{
$this->stream->seek($offset, $whence);
}
public function read($length): string
{
return $this->stream->read($length);
}
public function write($string): int
{
return $this->stream->write($string);
}
/**
* Implement in subclasses to dynamically create streams when requested.
*
* @throws \BadMethodCallException
*/
protected function createStream(): StreamInterface
{
throw new \BadMethodCallException('Not implemented');
}
}

View File

@ -0,0 +1,145 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
use RegularLabs\Scoped\Psr\Http\Message\StreamInterface;
/**
* Converts Guzzle streams into PHP stream resources.
*
* @see https://www.php.net/streamwrapper
*/
final class StreamWrapper
{
/** @var resource */
public $context;
/** @var StreamInterface */
private $stream;
/** @var string r, r+, or w */
private $mode;
/**
* Returns a resource representing the stream.
*
* @param StreamInterface $stream The stream to get a resource for
*
* @return resource
*
* @throws \InvalidArgumentException if stream is not readable or writable
*/
public static function getResource(StreamInterface $stream)
{
self::register();
if ($stream->isReadable()) {
$mode = $stream->isWritable() ? 'r+' : 'r';
} elseif ($stream->isWritable()) {
$mode = 'w';
} else {
throw new \InvalidArgumentException('The stream must be readable, ' . 'writable, or both.');
}
return fopen('guzzle://stream', $mode, \false, self::createStreamContext($stream));
}
/**
* Creates a stream context that can be used to open a stream as a php stream resource.
*
* @return resource
*/
public static function createStreamContext(StreamInterface $stream)
{
return stream_context_create(['guzzle' => ['stream' => $stream]]);
}
/**
* Registers the stream wrapper if needed
*/
public static function register(): void
{
if (!in_array('guzzle', stream_get_wrappers())) {
stream_wrapper_register('guzzle', __CLASS__);
}
}
public function stream_open(string $path, string $mode, int $options, ?string &$opened_path = null): bool
{
$options = stream_context_get_options($this->context);
if (!isset($options['guzzle']['stream'])) {
return \false;
}
$this->mode = $mode;
$this->stream = $options['guzzle']['stream'];
return \true;
}
public function stream_read(int $count): string
{
return $this->stream->read($count);
}
public function stream_write(string $data): int
{
return $this->stream->write($data);
}
public function stream_tell(): int
{
return $this->stream->tell();
}
public function stream_eof(): bool
{
return $this->stream->eof();
}
public function stream_seek(int $offset, int $whence): bool
{
$this->stream->seek($offset, $whence);
return \true;
}
/**
* @return resource|false
*/
public function stream_cast(int $cast_as)
{
$stream = clone $this->stream;
$resource = $stream->detach();
return $resource ?? \false;
}
/**
* @return array{
* dev: int,
* ino: int,
* mode: int,
* nlink: int,
* uid: int,
* gid: int,
* rdev: int,
* size: int,
* atime: int,
* mtime: int,
* ctime: int,
* blksize: int,
* blocks: int
* }|false
*/
public function stream_stat()
{
if ($this->stream->getSize() === null) {
return \false;
}
static $modeMap = ['r' => 33060, 'rb' => 33060, 'r+' => 33206, 'w' => 33188, 'wb' => 33188];
return ['dev' => 0, 'ino' => 0, 'mode' => $modeMap[$this->mode], 'nlink' => 0, 'uid' => 0, 'gid' => 0, 'rdev' => 0, 'size' => $this->stream->getSize() ?: 0, 'atime' => 0, 'mtime' => 0, 'ctime' => 0, 'blksize' => 0, 'blocks' => 0];
}
/**
* @return array{
* dev: int,
* ino: int,
* mode: int,
* nlink: int,
* uid: int,
* gid: int,
* rdev: int,
* size: int,
* atime: int,
* mtime: int,
* ctime: int,
* blksize: int,
* blocks: int
* }
*/
public function url_stat(string $path, int $flags): array
{
return ['dev' => 0, 'ino' => 0, 'mode' => 0, 'nlink' => 0, 'uid' => 0, 'gid' => 0, 'rdev' => 0, 'size' => 0, 'atime' => 0, 'mtime' => 0, 'ctime' => 0, 'blksize' => 0, 'blocks' => 0];
}
}

View File

@ -0,0 +1,152 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
use InvalidArgumentException;
use RegularLabs\Scoped\Psr\Http\Message\StreamInterface;
use RegularLabs\Scoped\Psr\Http\Message\UploadedFileInterface;
use RuntimeException;
class UploadedFile implements UploadedFileInterface
{
private const ERRORS = [\UPLOAD_ERR_OK, \UPLOAD_ERR_INI_SIZE, \UPLOAD_ERR_FORM_SIZE, \UPLOAD_ERR_PARTIAL, \UPLOAD_ERR_NO_FILE, \UPLOAD_ERR_NO_TMP_DIR, \UPLOAD_ERR_CANT_WRITE, \UPLOAD_ERR_EXTENSION];
/**
* @var string|null
*/
private $clientFilename;
/**
* @var string|null
*/
private $clientMediaType;
/**
* @var int
*/
private $error;
/**
* @var string|null
*/
private $file;
/**
* @var bool
*/
private $moved = \false;
/**
* @var int|null
*/
private $size;
/**
* @var StreamInterface|null
*/
private $stream;
/**
* @param StreamInterface|string|resource $streamOrFile
*/
public function __construct($streamOrFile, ?int $size, int $errorStatus, ?string $clientFilename = null, ?string $clientMediaType = null)
{
$this->setError($errorStatus);
$this->size = $size;
$this->clientFilename = $clientFilename;
$this->clientMediaType = $clientMediaType;
if ($this->isOk()) {
$this->setStreamOrFile($streamOrFile);
}
}
/**
* Depending on the value set file or stream variable
*
* @param StreamInterface|string|resource $streamOrFile
*
* @throws InvalidArgumentException
*/
private function setStreamOrFile($streamOrFile): void
{
if (is_string($streamOrFile)) {
$this->file = $streamOrFile;
} elseif (is_resource($streamOrFile)) {
$this->stream = new Stream($streamOrFile);
} elseif ($streamOrFile instanceof StreamInterface) {
$this->stream = $streamOrFile;
} else {
throw new InvalidArgumentException('Invalid stream or file provided for UploadedFile');
}
}
/**
* @throws InvalidArgumentException
*/
private function setError(int $error): void
{
if (\false === in_array($error, UploadedFile::ERRORS, \true)) {
throw new InvalidArgumentException('Invalid error status for UploadedFile');
}
$this->error = $error;
}
private static function isStringNotEmpty($param): bool
{
return is_string($param) && \false === empty($param);
}
/**
* Return true if there is no upload error
*/
private function isOk(): bool
{
return $this->error === \UPLOAD_ERR_OK;
}
public function isMoved(): bool
{
return $this->moved;
}
/**
* @throws RuntimeException if is moved or not ok
*/
private function validateActive(): void
{
if (\false === $this->isOk()) {
throw new RuntimeException('Cannot retrieve stream due to upload error');
}
if ($this->isMoved()) {
throw new RuntimeException('Cannot retrieve stream after it has already been moved');
}
}
public function getStream(): StreamInterface
{
$this->validateActive();
if ($this->stream instanceof StreamInterface) {
return $this->stream;
}
/** @var string $file */
$file = $this->file;
return new LazyOpenStream($file, 'r+');
}
public function moveTo($targetPath): void
{
$this->validateActive();
if (\false === self::isStringNotEmpty($targetPath)) {
throw new InvalidArgumentException('Invalid path provided for move operation; must be a non-empty string');
}
if ($this->file) {
$this->moved = \PHP_SAPI === 'cli' ? rename($this->file, $targetPath) : move_uploaded_file($this->file, $targetPath);
} else {
Utils::copyToStream($this->getStream(), new LazyOpenStream($targetPath, 'w'));
$this->moved = \true;
}
if (\false === $this->moved) {
throw new RuntimeException(sprintf('Uploaded file could not be moved to %s', $targetPath));
}
}
public function getSize(): ?int
{
return $this->size;
}
public function getError(): int
{
return $this->error;
}
public function getClientFilename(): ?string
{
return $this->clientFilename;
}
public function getClientMediaType(): ?string
{
return $this->clientMediaType;
}
}

View File

@ -0,0 +1,572 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
use RegularLabs\Scoped\GuzzleHttp\Psr7\Exception\MalformedUriException;
use RegularLabs\Scoped\Psr\Http\Message\UriInterface;
/**
* PSR-7 URI implementation.
*
* @author Michael Dowling
* @author Tobias Schultze
* @author Matthew Weier O'Phinney
*/
class Uri implements UriInterface, \JsonSerializable
{
/**
* Absolute http and https URIs require a host per RFC 7230 Section 2.7
* but in generic URIs the host can be empty. So for http(s) URIs
* we apply this default host when no host is given yet to form a
* valid URI.
*/
private const HTTP_DEFAULT_HOST = 'localhost';
private const DEFAULT_PORTS = ['http' => 80, 'https' => 443, 'ftp' => 21, 'gopher' => 70, 'nntp' => 119, 'news' => 119, 'telnet' => 23, 'tn3270' => 23, 'imap' => 143, 'pop' => 110, 'ldap' => 389];
/**
* Unreserved characters for use in a regex.
*
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-2.3
*/
private const CHAR_UNRESERVED = 'a-zA-Z0-9_\-\.~';
/**
* Sub-delims for use in a regex.
*
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-2.2
*/
private const CHAR_SUB_DELIMS = '!\$&\'\(\)\*\+,;=';
private const QUERY_SEPARATORS_REPLACEMENT = ['=' => '%3D', '&' => '%26'];
/** @var string Uri scheme. */
private $scheme = '';
/** @var string Uri user info. */
private $userInfo = '';
/** @var string Uri host. */
private $host = '';
/** @var int|null Uri port. */
private $port;
/** @var string Uri path. */
private $path = '';
/** @var string Uri query string. */
private $query = '';
/** @var string Uri fragment. */
private $fragment = '';
/** @var string|null String representation */
private $composedComponents;
public function __construct(string $uri = '')
{
if ($uri !== '') {
$parts = self::parse($uri);
if ($parts === \false) {
throw new MalformedUriException("Unable to parse URI: {$uri}");
}
$this->applyParts($parts);
}
}
/**
* UTF-8 aware \parse_url() replacement.
*
* The internal function produces broken output for non ASCII domain names
* (IDN) when used with locales other than "C".
*
* On the other hand, cURL understands IDN correctly only when UTF-8 locale
* is configured ("C.UTF-8", "en_US.UTF-8", etc.).
*
* @see https://bugs.php.net/bug.php?id=52923
* @see https://www.php.net/manual/en/function.parse-url.php#114817
* @see https://curl.haxx.se/libcurl/c/CURLOPT_URL.html#ENCODING
*
* @return array|false
*/
private static function parse(string $url)
{
// If IPv6
$prefix = '';
if (preg_match('%^(.*://\[[0-9:a-f]+\])(.*?)$%', $url, $matches)) {
/** @var array{0:string, 1:string, 2:string} $matches */
$prefix = $matches[1];
$url = $matches[2];
}
/** @var string */
$encodedUrl = preg_replace_callback('%[^:/@?&=#]+%usD', static function ($matches) {
return urlencode($matches[0]);
}, $url);
$result = parse_url($prefix . $encodedUrl);
if ($result === \false) {
return \false;
}
return array_map('urldecode', $result);
}
public function __toString(): string
{
if ($this->composedComponents === null) {
$this->composedComponents = self::composeComponents($this->scheme, $this->getAuthority(), $this->path, $this->query, $this->fragment);
}
return $this->composedComponents;
}
/**
* Composes a URI reference string from its various components.
*
* Usually this method does not need to be called manually but instead is used indirectly via
* `Psr\Http\Message\UriInterface::__toString`.
*
* PSR-7 UriInterface treats an empty component the same as a missing component as
* getQuery(), getFragment() etc. always return a string. This explains the slight
* difference to RFC 3986 Section 5.3.
*
* Another adjustment is that the authority separator is added even when the authority is missing/empty
* for the "file" scheme. This is because PHP stream functions like `file_get_contents` only work with
* `file:///myfile` but not with `file:/myfile` although they are equivalent according to RFC 3986. But
* `file:///` is the more common syntax for the file scheme anyway (Chrome for example redirects to
* that format).
*
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.3
*/
public static function composeComponents(?string $scheme, ?string $authority, string $path, ?string $query, ?string $fragment): string
{
$uri = '';
// weak type checks to also accept null until we can add scalar type hints
if ($scheme != '') {
$uri .= $scheme . ':';
}
if ($authority != '' || $scheme === 'file') {
$uri .= '//' . $authority;
}
if ($authority != '' && $path != '' && $path[0] != '/') {
$path = '/' . $path;
}
$uri .= $path;
if ($query != '') {
$uri .= '?' . $query;
}
if ($fragment != '') {
$uri .= '#' . $fragment;
}
return $uri;
}
/**
* Whether the URI has the default port of the current scheme.
*
* `Psr\Http\Message\UriInterface::getPort` may return null or the standard port. This method can be used
* independently of the implementation.
*/
public static function isDefaultPort(UriInterface $uri): bool
{
return $uri->getPort() === null || isset(self::DEFAULT_PORTS[$uri->getScheme()]) && $uri->getPort() === self::DEFAULT_PORTS[$uri->getScheme()];
}
/**
* Whether the URI is absolute, i.e. it has a scheme.
*
* An instance of UriInterface can either be an absolute URI or a relative reference. This method returns true
* if it is the former. An absolute URI has a scheme. A relative reference is used to express a URI relative
* to another URI, the base URI. Relative references can be divided into several forms:
* - network-path references, e.g. '//example.com/path'
* - absolute-path references, e.g. '/path'
* - relative-path references, e.g. 'subpath'
*
* @see Uri::isNetworkPathReference
* @see Uri::isAbsolutePathReference
* @see Uri::isRelativePathReference
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-4
*/
public static function isAbsolute(UriInterface $uri): bool
{
return $uri->getScheme() !== '';
}
/**
* Whether the URI is a network-path reference.
*
* A relative reference that begins with two slash characters is termed an network-path reference.
*
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.2
*/
public static function isNetworkPathReference(UriInterface $uri): bool
{
return $uri->getScheme() === '' && $uri->getAuthority() !== '';
}
/**
* Whether the URI is a absolute-path reference.
*
* A relative reference that begins with a single slash character is termed an absolute-path reference.
*
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.2
*/
public static function isAbsolutePathReference(UriInterface $uri): bool
{
return $uri->getScheme() === '' && $uri->getAuthority() === '' && isset($uri->getPath()[0]) && $uri->getPath()[0] === '/';
}
/**
* Whether the URI is a relative-path reference.
*
* A relative reference that does not begin with a slash character is termed a relative-path reference.
*
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.2
*/
public static function isRelativePathReference(UriInterface $uri): bool
{
return $uri->getScheme() === '' && $uri->getAuthority() === '' && (!isset($uri->getPath()[0]) || $uri->getPath()[0] !== '/');
}
/**
* Whether the URI is a same-document reference.
*
* A same-document reference refers to a URI that is, aside from its fragment
* component, identical to the base URI. When no base URI is given, only an empty
* URI reference (apart from its fragment) is considered a same-document reference.
*
* @param UriInterface $uri The URI to check
* @param UriInterface|null $base An optional base URI to compare against
*
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.4
*/
public static function isSameDocumentReference(UriInterface $uri, ?UriInterface $base = null): bool
{
if ($base !== null) {
$uri = UriResolver::resolve($base, $uri);
return $uri->getScheme() === $base->getScheme() && $uri->getAuthority() === $base->getAuthority() && $uri->getPath() === $base->getPath() && $uri->getQuery() === $base->getQuery();
}
return $uri->getScheme() === '' && $uri->getAuthority() === '' && $uri->getPath() === '' && $uri->getQuery() === '';
}
/**
* Creates a new URI with a specific query string value removed.
*
* Any existing query string values that exactly match the provided key are
* removed.
*
* @param UriInterface $uri URI to use as a base.
* @param string $key Query string key to remove.
*/
public static function withoutQueryValue(UriInterface $uri, string $key): UriInterface
{
$result = self::getFilteredQueryString($uri, [$key]);
return $uri->withQuery(implode('&', $result));
}
/**
* Creates a new URI with a specific query string value.
*
* Any existing query string values that exactly match the provided key are
* removed and replaced with the given key value pair.
*
* A value of null will set the query string key without a value, e.g. "key"
* instead of "key=value".
*
* @param UriInterface $uri URI to use as a base.
* @param string $key Key to set.
* @param string|null $value Value to set
*/
public static function withQueryValue(UriInterface $uri, string $key, ?string $value): UriInterface
{
$result = self::getFilteredQueryString($uri, [$key]);
$result[] = self::generateQueryString($key, $value);
return $uri->withQuery(implode('&', $result));
}
/**
* Creates a new URI with multiple specific query string values.
*
* It has the same behavior as withQueryValue() but for an associative array of key => value.
*
* @param UriInterface $uri URI to use as a base.
* @param (string|null)[] $keyValueArray Associative array of key and values
*/
public static function withQueryValues(UriInterface $uri, array $keyValueArray): UriInterface
{
$result = self::getFilteredQueryString($uri, array_keys($keyValueArray));
foreach ($keyValueArray as $key => $value) {
$result[] = self::generateQueryString((string) $key, $value !== null ? (string) $value : null);
}
return $uri->withQuery(implode('&', $result));
}
/**
* Creates a URI from a hash of `parse_url` components.
*
* @see https://www.php.net/manual/en/function.parse-url.php
*
* @throws MalformedUriException If the components do not form a valid URI.
*/
public static function fromParts(array $parts): UriInterface
{
$uri = new self();
$uri->applyParts($parts);
$uri->validateState();
return $uri;
}
public function getScheme(): string
{
return $this->scheme;
}
public function getAuthority(): string
{
$authority = $this->host;
if ($this->userInfo !== '') {
$authority = $this->userInfo . '@' . $authority;
}
if ($this->port !== null) {
$authority .= ':' . $this->port;
}
return $authority;
}
public function getUserInfo(): string
{
return $this->userInfo;
}
public function getHost(): string
{
return $this->host;
}
public function getPort(): ?int
{
return $this->port;
}
public function getPath(): string
{
return $this->path;
}
public function getQuery(): string
{
return $this->query;
}
public function getFragment(): string
{
return $this->fragment;
}
public function withScheme($scheme): UriInterface
{
$scheme = $this->filterScheme($scheme);
if ($this->scheme === $scheme) {
return $this;
}
$new = clone $this;
$new->scheme = $scheme;
$new->composedComponents = null;
$new->removeDefaultPort();
$new->validateState();
return $new;
}
public function withUserInfo($user, $password = null): UriInterface
{
$info = $this->filterUserInfoComponent($user);
if ($password !== null) {
$info .= ':' . $this->filterUserInfoComponent($password);
}
if ($this->userInfo === $info) {
return $this;
}
$new = clone $this;
$new->userInfo = $info;
$new->composedComponents = null;
$new->validateState();
return $new;
}
public function withHost($host): UriInterface
{
$host = $this->filterHost($host);
if ($this->host === $host) {
return $this;
}
$new = clone $this;
$new->host = $host;
$new->composedComponents = null;
$new->validateState();
return $new;
}
public function withPort($port): UriInterface
{
$port = $this->filterPort($port);
if ($this->port === $port) {
return $this;
}
$new = clone $this;
$new->port = $port;
$new->composedComponents = null;
$new->removeDefaultPort();
$new->validateState();
return $new;
}
public function withPath($path): UriInterface
{
$path = $this->filterPath($path);
if ($this->path === $path) {
return $this;
}
$new = clone $this;
$new->path = $path;
$new->composedComponents = null;
$new->validateState();
return $new;
}
public function withQuery($query): UriInterface
{
$query = $this->filterQueryAndFragment($query);
if ($this->query === $query) {
return $this;
}
$new = clone $this;
$new->query = $query;
$new->composedComponents = null;
return $new;
}
public function withFragment($fragment): UriInterface
{
$fragment = $this->filterQueryAndFragment($fragment);
if ($this->fragment === $fragment) {
return $this;
}
$new = clone $this;
$new->fragment = $fragment;
$new->composedComponents = null;
return $new;
}
public function jsonSerialize(): string
{
return $this->__toString();
}
/**
* Apply parse_url parts to a URI.
*
* @param array $parts Array of parse_url parts to apply.
*/
private function applyParts(array $parts): void
{
$this->scheme = isset($parts['scheme']) ? $this->filterScheme($parts['scheme']) : '';
$this->userInfo = isset($parts['user']) ? $this->filterUserInfoComponent($parts['user']) : '';
$this->host = isset($parts['host']) ? $this->filterHost($parts['host']) : '';
$this->port = isset($parts['port']) ? $this->filterPort($parts['port']) : null;
$this->path = isset($parts['path']) ? $this->filterPath($parts['path']) : '';
$this->query = isset($parts['query']) ? $this->filterQueryAndFragment($parts['query']) : '';
$this->fragment = isset($parts['fragment']) ? $this->filterQueryAndFragment($parts['fragment']) : '';
if (isset($parts['pass'])) {
$this->userInfo .= ':' . $this->filterUserInfoComponent($parts['pass']);
}
$this->removeDefaultPort();
}
/**
* @param mixed $scheme
*
* @throws \InvalidArgumentException If the scheme is invalid.
*/
private function filterScheme($scheme): string
{
if (!is_string($scheme)) {
throw new \InvalidArgumentException('Scheme must be a string');
}
return \strtr($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
}
/**
* @param mixed $component
*
* @throws \InvalidArgumentException If the user info is invalid.
*/
private function filterUserInfoComponent($component): string
{
if (!is_string($component)) {
throw new \InvalidArgumentException('User info must be a string');
}
return preg_replace_callback('/(?:[^%' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . ']+|%(?![A-Fa-f0-9]{2}))/', [$this, 'rawurlencodeMatchZero'], $component);
}
/**
* @param mixed $host
*
* @throws \InvalidArgumentException If the host is invalid.
*/
private function filterHost($host): string
{
if (!is_string($host)) {
throw new \InvalidArgumentException('Host must be a string');
}
return \strtr($host, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
}
/**
* @param mixed $port
*
* @throws \InvalidArgumentException If the port is invalid.
*/
private function filterPort($port): ?int
{
if ($port === null) {
return null;
}
$port = (int) $port;
if (0 > $port || 0xffff < $port) {
throw new \InvalidArgumentException(sprintf('Invalid port: %d. Must be between 0 and 65535', $port));
}
return $port;
}
/**
* @param (string|int)[] $keys
*
* @return string[]
*/
private static function getFilteredQueryString(UriInterface $uri, array $keys): array
{
$current = $uri->getQuery();
if ($current === '') {
return [];
}
$decodedKeys = array_map(function ($k): string {
return rawurldecode((string) $k);
}, $keys);
return array_filter(explode('&', $current), function ($part) use ($decodedKeys) {
return !in_array(rawurldecode(explode('=', $part)[0]), $decodedKeys, \true);
});
}
private static function generateQueryString(string $key, ?string $value): string
{
// Query string separators ("=", "&") within the key or value need to be encoded
// (while preventing double-encoding) before setting the query string. All other
// chars that need percent-encoding will be encoded by withQuery().
$queryString = strtr($key, self::QUERY_SEPARATORS_REPLACEMENT);
if ($value !== null) {
$queryString .= '=' . strtr($value, self::QUERY_SEPARATORS_REPLACEMENT);
}
return $queryString;
}
private function removeDefaultPort(): void
{
if ($this->port !== null && self::isDefaultPort($this)) {
$this->port = null;
}
}
/**
* Filters the path of a URI
*
* @param mixed $path
*
* @throws \InvalidArgumentException If the path is invalid.
*/
private function filterPath($path): string
{
if (!is_string($path)) {
throw new \InvalidArgumentException('Path must be a string');
}
return preg_replace_callback('/(?:[^' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . '%:@\/]++|%(?![A-Fa-f0-9]{2}))/', [$this, 'rawurlencodeMatchZero'], $path);
}
/**
* Filters the query string or fragment of a URI.
*
* @param mixed $str
*
* @throws \InvalidArgumentException If the query or fragment is invalid.
*/
private function filterQueryAndFragment($str): string
{
if (!is_string($str)) {
throw new \InvalidArgumentException('Query and fragment must be a string');
}
return preg_replace_callback('/(?:[^' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . '%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/', [$this, 'rawurlencodeMatchZero'], $str);
}
private function rawurlencodeMatchZero(array $match): string
{
return rawurlencode($match[0]);
}
private function validateState(): void
{
if ($this->host === '' && ($this->scheme === 'http' || $this->scheme === 'https')) {
$this->host = self::HTTP_DEFAULT_HOST;
}
if ($this->getAuthority() === '') {
if (0 === strpos($this->path, '//')) {
throw new MalformedUriException('The path of a URI without an authority must not start with two slashes "//"');
}
if ($this->scheme === '' && \false !== strpos(explode('/', $this->path, 2)[0], ':')) {
throw new MalformedUriException('A relative URI must not have a path beginning with a segment containing a colon');
}
}
}
}

View File

@ -0,0 +1,43 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
use RegularLabs\Scoped\Psr\Http\Message\UriInterface;
/**
* Provides methods to determine if a modified URL should be considered cross-origin.
*
* @author Graham Campbell
*/
final class UriComparator
{
/**
* Determines if a modified URL should be considered cross-origin with
* respect to an original URL.
*/
public static function isCrossOrigin(UriInterface $original, UriInterface $modified): bool
{
if (\strcasecmp($original->getHost(), $modified->getHost()) !== 0) {
return \true;
}
if ($original->getScheme() !== $modified->getScheme()) {
return \true;
}
if (self::computePort($original) !== self::computePort($modified)) {
return \true;
}
return \false;
}
private static function computePort(UriInterface $uri): int
{
$port = $uri->getPort();
if (null !== $port) {
return $port;
}
return 'https' === $uri->getScheme() ? 443 : 80;
}
private function __construct()
{
// cannot be instantiated
}
}

View File

@ -0,0 +1,175 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
use RegularLabs\Scoped\Psr\Http\Message\UriInterface;
/**
* Provides methods to normalize and compare URIs.
*
* @author Tobias Schultze
*
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-6
*/
final class UriNormalizer
{
/**
* Default normalizations which only include the ones that preserve semantics.
*/
public const PRESERVING_NORMALIZATIONS = self::CAPITALIZE_PERCENT_ENCODING | self::DECODE_UNRESERVED_CHARACTERS | self::CONVERT_EMPTY_PATH | self::REMOVE_DEFAULT_HOST | self::REMOVE_DEFAULT_PORT | self::REMOVE_DOT_SEGMENTS;
/**
* All letters within a percent-encoding triplet (e.g., "%3A") are case-insensitive, and should be capitalized.
*
* Example: http://example.org/a%c2%b1b → http://example.org/a%C2%B1b
*/
public const CAPITALIZE_PERCENT_ENCODING = 1;
/**
* Decodes percent-encoded octets of unreserved characters.
*
* For consistency, percent-encoded octets in the ranges of ALPHA (%41%5A and %61%7A), DIGIT (%30%39),
* hyphen (%2D), period (%2E), underscore (%5F), or tilde (%7E) should not be created by URI producers and,
* when found in a URI, should be decoded to their corresponding unreserved characters by URI normalizers.
*
* Example: http://example.org/%7Eusern%61me/ → http://example.org/~username/
*/
public const DECODE_UNRESERVED_CHARACTERS = 2;
/**
* Converts the empty path to "/" for http and https URIs.
*
* Example: http://example.org → http://example.org/
*/
public const CONVERT_EMPTY_PATH = 4;
/**
* Removes the default host of the given URI scheme from the URI.
*
* Only the "file" scheme defines the default host "localhost".
* All of `file:/myfile`, `file:///myfile`, and `file://localhost/myfile`
* are equivalent according to RFC 3986. The first format is not accepted
* by PHPs stream functions and thus already normalized implicitly to the
* second format in the Uri class. See `GuzzleHttp\Psr7\Uri::composeComponents`.
*
* Example: file://localhost/myfile → file:///myfile
*/
public const REMOVE_DEFAULT_HOST = 8;
/**
* Removes the default port of the given URI scheme from the URI.
*
* Example: http://example.org:80/ → http://example.org/
*/
public const REMOVE_DEFAULT_PORT = 16;
/**
* Removes unnecessary dot-segments.
*
* Dot-segments in relative-path references are not removed as it would
* change the semantics of the URI reference.
*
* Example: http://example.org/../a/b/../c/./d.html → http://example.org/a/c/d.html
*/
public const REMOVE_DOT_SEGMENTS = 32;
/**
* Paths which include two or more adjacent slashes are converted to one.
*
* Webservers usually ignore duplicate slashes and treat those URIs equivalent.
* But in theory those URIs do not need to be equivalent. So this normalization
* may change the semantics. Encoded slashes (%2F) are not removed.
*
* Example: http://example.org//foo///bar.html → http://example.org/foo/bar.html
*/
public const REMOVE_DUPLICATE_SLASHES = 64;
/**
* Sort query parameters with their values in alphabetical order.
*
* However, the order of parameters in a URI may be significant (this is not defined by the standard).
* So this normalization is not safe and may change the semantics of the URI.
*
* Example: ?lang=en&article=fred → ?article=fred&lang=en
*
* Note: The sorting is neither locale nor Unicode aware (the URI query does not get decoded at all) as the
* purpose is to be able to compare URIs in a reproducible way, not to have the params sorted perfectly.
*/
public const SORT_QUERY_PARAMETERS = 128;
/**
* Returns a normalized URI.
*
* The scheme and host component are already normalized to lowercase per PSR-7 UriInterface.
* This methods adds additional normalizations that can be configured with the $flags parameter.
*
* PSR-7 UriInterface cannot distinguish between an empty component and a missing component as
* getQuery(), getFragment() etc. always return a string. This means the URIs "/?#" and "/" are
* treated equivalent which is not necessarily true according to RFC 3986. But that difference
* is highly uncommon in reality. So this potential normalization is implied in PSR-7 as well.
*
* @param UriInterface $uri The URI to normalize
* @param int $flags A bitmask of normalizations to apply, see constants
*
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-6.2
*/
public static function normalize(UriInterface $uri, int $flags = self::PRESERVING_NORMALIZATIONS): UriInterface
{
if ($flags & self::CAPITALIZE_PERCENT_ENCODING) {
$uri = self::capitalizePercentEncoding($uri);
}
if ($flags & self::DECODE_UNRESERVED_CHARACTERS) {
$uri = self::decodeUnreservedCharacters($uri);
}
if ($flags & self::CONVERT_EMPTY_PATH && $uri->getPath() === '' && ($uri->getScheme() === 'http' || $uri->getScheme() === 'https')) {
$uri = $uri->withPath('/');
}
if ($flags & self::REMOVE_DEFAULT_HOST && $uri->getScheme() === 'file' && $uri->getHost() === 'localhost') {
$uri = $uri->withHost('');
}
if ($flags & self::REMOVE_DEFAULT_PORT && $uri->getPort() !== null && Uri::isDefaultPort($uri)) {
$uri = $uri->withPort(null);
}
if ($flags & self::REMOVE_DOT_SEGMENTS && !Uri::isRelativePathReference($uri)) {
$uri = $uri->withPath(UriResolver::removeDotSegments($uri->getPath()));
}
if ($flags & self::REMOVE_DUPLICATE_SLASHES) {
$uri = $uri->withPath(preg_replace('#//++#', '/', $uri->getPath()));
}
if ($flags & self::SORT_QUERY_PARAMETERS && $uri->getQuery() !== '') {
$queryKeyValues = explode('&', $uri->getQuery());
sort($queryKeyValues);
$uri = $uri->withQuery(implode('&', $queryKeyValues));
}
return $uri;
}
/**
* Whether two URIs can be considered equivalent.
*
* Both URIs are normalized automatically before comparison with the given $normalizations bitmask. The method also
* accepts relative URI references and returns true when they are equivalent. This of course assumes they will be
* resolved against the same base URI. If this is not the case, determination of equivalence or difference of
* relative references does not mean anything.
*
* @param UriInterface $uri1 An URI to compare
* @param UriInterface $uri2 An URI to compare
* @param int $normalizations A bitmask of normalizations to apply, see constants
*
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-6.1
*/
public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, int $normalizations = self::PRESERVING_NORMALIZATIONS): bool
{
return (string) self::normalize($uri1, $normalizations) === (string) self::normalize($uri2, $normalizations);
}
private static function capitalizePercentEncoding(UriInterface $uri): UriInterface
{
$regex = '/(?:%[A-Fa-f0-9]{2})++/';
$callback = function (array $match): string {
return strtoupper($match[0]);
};
return $uri->withPath(preg_replace_callback($regex, $callback, $uri->getPath()))->withQuery(preg_replace_callback($regex, $callback, $uri->getQuery()));
}
private static function decodeUnreservedCharacters(UriInterface $uri): UriInterface
{
$regex = '/%(?:2D|2E|5F|7E|3[0-9]|[46][1-9A-F]|[57][0-9A])/i';
$callback = function (array $match): string {
return rawurldecode($match[0]);
};
return $uri->withPath(preg_replace_callback($regex, $callback, $uri->getPath()))->withQuery(preg_replace_callback($regex, $callback, $uri->getQuery()));
}
private function __construct()
{
// cannot be instantiated
}
}

View File

@ -0,0 +1,178 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
use RegularLabs\Scoped\Psr\Http\Message\UriInterface;
/**
* Resolves a URI reference in the context of a base URI and the opposite way.
*
* @author Tobias Schultze
*
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-5
*/
final class UriResolver
{
/**
* Removes dot segments from a path and returns the new path.
*
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.4
*/
public static function removeDotSegments(string $path): string
{
if ($path === '' || $path === '/') {
return $path;
}
$results = [];
$segments = explode('/', $path);
foreach ($segments as $segment) {
if ($segment === '..') {
array_pop($results);
} elseif ($segment !== '.') {
$results[] = $segment;
}
}
$newPath = implode('/', $results);
if ($path[0] === '/' && (!isset($newPath[0]) || $newPath[0] !== '/')) {
// Re-add the leading slash if necessary for cases like "/.."
$newPath = '/' . $newPath;
} elseif ($newPath !== '' && ($segment === '.' || $segment === '..')) {
// Add the trailing slash if necessary
// If newPath is not empty, then $segment must be set and is the last segment from the foreach
$newPath .= '/';
}
return $newPath;
}
/**
* Converts the relative URI into a new URI that is resolved against the base URI.
*
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.2
*/
public static function resolve(UriInterface $base, UriInterface $rel): UriInterface
{
if ((string) $rel === '') {
// we can simply return the same base URI instance for this same-document reference
return $base;
}
if ($rel->getScheme() != '') {
return $rel->withPath(self::removeDotSegments($rel->getPath()));
}
if ($rel->getAuthority() != '') {
$targetAuthority = $rel->getAuthority();
$targetPath = self::removeDotSegments($rel->getPath());
$targetQuery = $rel->getQuery();
} else {
$targetAuthority = $base->getAuthority();
if ($rel->getPath() === '') {
$targetPath = $base->getPath();
$targetQuery = $rel->getQuery() != '' ? $rel->getQuery() : $base->getQuery();
} else {
if ($rel->getPath()[0] === '/') {
$targetPath = $rel->getPath();
} else if ($targetAuthority != '' && $base->getPath() === '') {
$targetPath = '/' . $rel->getPath();
} else {
$lastSlashPos = strrpos($base->getPath(), '/');
if ($lastSlashPos === \false) {
$targetPath = $rel->getPath();
} else {
$targetPath = substr($base->getPath(), 0, $lastSlashPos + 1) . $rel->getPath();
}
}
$targetPath = self::removeDotSegments($targetPath);
$targetQuery = $rel->getQuery();
}
}
return new Uri(Uri::composeComponents($base->getScheme(), $targetAuthority, $targetPath, $targetQuery, $rel->getFragment()));
}
/**
* Returns the target URI as a relative reference from the base URI.
*
* This method is the counterpart to resolve():
*
* (string) $target === (string) UriResolver::resolve($base, UriResolver::relativize($base, $target))
*
* One use-case is to use the current request URI as base URI and then generate relative links in your documents
* to reduce the document size or offer self-contained downloadable document archives.
*
* $base = new Uri('http://example.com/a/b/');
* echo UriResolver::relativize($base, new Uri('http://example.com/a/b/c')); // prints 'c'.
* echo UriResolver::relativize($base, new Uri('http://example.com/a/x/y')); // prints '../x/y'.
* echo UriResolver::relativize($base, new Uri('http://example.com/a/b/?q')); // prints '?q'.
* echo UriResolver::relativize($base, new Uri('http://example.org/a/b/')); // prints '//example.org/a/b/'.
*
* This method also accepts a target that is already relative and will try to relativize it further. Only a
* relative-path reference will be returned as-is.
*
* echo UriResolver::relativize($base, new Uri('/a/b/c')); // prints 'c' as well
*/
public static function relativize(UriInterface $base, UriInterface $target): UriInterface
{
if ($target->getScheme() !== '' && ($base->getScheme() !== $target->getScheme() || $target->getAuthority() === '' && $base->getAuthority() !== '')) {
return $target;
}
if (Uri::isRelativePathReference($target)) {
// As the target is already highly relative we return it as-is. It would be possible to resolve
// the target with `$target = self::resolve($base, $target);` and then try make it more relative
// by removing a duplicate query. But let's not do that automatically.
return $target;
}
if ($target->getAuthority() !== '' && $base->getAuthority() !== $target->getAuthority()) {
return $target->withScheme('');
}
// We must remove the path before removing the authority because if the path starts with two slashes, the URI
// would turn invalid. And we also cannot set a relative path before removing the authority, as that is also
// invalid.
$emptyPathUri = $target->withScheme('')->withPath('')->withUserInfo('')->withPort(null)->withHost('');
if ($base->getPath() !== $target->getPath()) {
return $emptyPathUri->withPath(self::getRelativePath($base, $target));
}
if ($base->getQuery() === $target->getQuery()) {
// Only the target fragment is left. And it must be returned even if base and target fragment are the same.
return $emptyPathUri->withQuery('');
}
// If the base URI has a query but the target has none, we cannot return an empty path reference as it would
// inherit the base query component when resolving.
if ($target->getQuery() === '') {
$segments = explode('/', $target->getPath());
/** @var string $lastSegment */
$lastSegment = end($segments);
return $emptyPathUri->withPath($lastSegment === '' ? './' : $lastSegment);
}
return $emptyPathUri;
}
private static function getRelativePath(UriInterface $base, UriInterface $target): string
{
$sourceSegments = explode('/', $base->getPath());
$targetSegments = explode('/', $target->getPath());
array_pop($sourceSegments);
$targetLastSegment = array_pop($targetSegments);
foreach ($sourceSegments as $i => $segment) {
if (isset($targetSegments[$i]) && $segment === $targetSegments[$i]) {
unset($sourceSegments[$i], $targetSegments[$i]);
} else {
break;
}
}
$targetSegments[] = $targetLastSegment;
$relativePath = str_repeat('../', count($sourceSegments)) . implode('/', $targetSegments);
// A reference to am empty last segment or an empty first sub-segment must be prefixed with "./".
// This also applies to a segment with a colon character (e.g., "file:colon") that cannot be used
// as the first segment of a relative-path reference, as it would be mistaken for a scheme name.
if ('' === $relativePath || \false !== strpos(explode('/', $relativePath, 2)[0], ':')) {
$relativePath = "./{$relativePath}";
} elseif ('/' === $relativePath[0]) {
if ($base->getAuthority() != '' && $base->getPath() === '') {
// In this case an extra slash is added by resolve() automatically. So we must not add one here.
$relativePath = ".{$relativePath}";
} else {
$relativePath = "./{$relativePath}";
}
}
return $relativePath;
}
private function __construct()
{
// cannot be instantiated
}
}

View File

@ -0,0 +1,386 @@
<?php
declare (strict_types=1);
namespace RegularLabs\Scoped\GuzzleHttp\Psr7;
use RegularLabs\Scoped\Psr\Http\Message\RequestInterface;
use RegularLabs\Scoped\Psr\Http\Message\ServerRequestInterface;
use RegularLabs\Scoped\Psr\Http\Message\StreamInterface;
use RegularLabs\Scoped\Psr\Http\Message\UriInterface;
final class Utils
{
/**
* Remove the items given by the keys, case insensitively from the data.
*
* @param (string|int)[] $keys
*/
public static function caselessRemove(array $keys, array $data): array
{
$result = [];
foreach ($keys as &$key) {
$key = strtolower((string) $key);
}
foreach ($data as $k => $v) {
if (!in_array(strtolower((string) $k), $keys)) {
$result[$k] = $v;
}
}
return $result;
}
/**
* Copy the contents of a stream into another stream until the given number
* of bytes have been read.
*
* @param StreamInterface $source Stream to read from
* @param StreamInterface $dest Stream to write to
* @param int $maxLen Maximum number of bytes to read. Pass -1
* to read the entire stream.
*
* @throws \RuntimeException on error.
*/
public static function copyToStream(StreamInterface $source, StreamInterface $dest, int $maxLen = -1): void
{
$bufferSize = 8192;
if ($maxLen === -1) {
while (!$source->eof()) {
if (!$dest->write($source->read($bufferSize))) {
break;
}
}
} else {
$remaining = $maxLen;
while ($remaining > 0 && !$source->eof()) {
$buf = $source->read(min($bufferSize, $remaining));
$len = strlen($buf);
if (!$len) {
break;
}
$remaining -= $len;
$dest->write($buf);
}
}
}
/**
* Copy the contents of a stream into a string until the given number of
* bytes have been read.
*
* @param StreamInterface $stream Stream to read
* @param int $maxLen Maximum number of bytes to read. Pass -1
* to read the entire stream.
*
* @throws \RuntimeException on error.
*/
public static function copyToString(StreamInterface $stream, int $maxLen = -1): string
{
$buffer = '';
if ($maxLen === -1) {
while (!$stream->eof()) {
$buf = $stream->read(1048576);
if ($buf === '') {
break;
}
$buffer .= $buf;
}
return $buffer;
}
$len = 0;
while (!$stream->eof() && $len < $maxLen) {
$buf = $stream->read($maxLen - $len);
if ($buf === '') {
break;
}
$buffer .= $buf;
$len = strlen($buffer);
}
return $buffer;
}
/**
* Calculate a hash of a stream.
*
* This method reads the entire stream to calculate a rolling hash, based
* on PHP's `hash_init` functions.
*
* @param StreamInterface $stream Stream to calculate the hash for
* @param string $algo Hash algorithm (e.g. md5, crc32, etc)
* @param bool $rawOutput Whether or not to use raw output
*
* @throws \RuntimeException on error.
*/
public static function hash(StreamInterface $stream, string $algo, bool $rawOutput = \false): string
{
$pos = $stream->tell();
if ($pos > 0) {
$stream->rewind();
}
$ctx = hash_init($algo);
while (!$stream->eof()) {
hash_update($ctx, $stream->read(1048576));
}
$out = hash_final($ctx, $rawOutput);
$stream->seek($pos);
return $out;
}
/**
* Clone and modify a request with the given changes.
*
* This method is useful for reducing the number of clones needed to mutate
* a message.
*
* The changes can be one of:
* - method: (string) Changes the HTTP method.
* - set_headers: (array) Sets the given headers.
* - remove_headers: (array) Remove the given headers.
* - body: (mixed) Sets the given body.
* - uri: (UriInterface) Set the URI.
* - query: (string) Set the query string value of the URI.
* - version: (string) Set the protocol version.
*
* @param RequestInterface $request Request to clone and modify.
* @param array $changes Changes to apply.
*/
public static function modifyRequest(RequestInterface $request, array $changes): RequestInterface
{
if (!$changes) {
return $request;
}
$headers = $request->getHeaders();
if (!isset($changes['uri'])) {
$uri = $request->getUri();
} else {
// Remove the host header if one is on the URI
if ($host = $changes['uri']->getHost()) {
$changes['set_headers']['Host'] = $host;
if ($port = $changes['uri']->getPort()) {
$standardPorts = ['http' => 80, 'https' => 443];
$scheme = $changes['uri']->getScheme();
if (isset($standardPorts[$scheme]) && $port != $standardPorts[$scheme]) {
$changes['set_headers']['Host'] .= ':' . $port;
}
}
}
$uri = $changes['uri'];
}
if (!empty($changes['remove_headers'])) {
$headers = self::caselessRemove($changes['remove_headers'], $headers);
}
if (!empty($changes['set_headers'])) {
$headers = self::caselessRemove(array_keys($changes['set_headers']), $headers);
$headers = $changes['set_headers'] + $headers;
}
if (isset($changes['query'])) {
$uri = $uri->withQuery($changes['query']);
}
if ($request instanceof ServerRequestInterface) {
$new = (new ServerRequest($changes['method'] ?? $request->getMethod(), $uri, $headers, $changes['body'] ?? $request->getBody(), $changes['version'] ?? $request->getProtocolVersion(), $request->getServerParams()))->withParsedBody($request->getParsedBody())->withQueryParams($request->getQueryParams())->withCookieParams($request->getCookieParams())->withUploadedFiles($request->getUploadedFiles());
foreach ($request->getAttributes() as $key => $value) {
$new = $new->withAttribute($key, $value);
}
return $new;
}
return new Request($changes['method'] ?? $request->getMethod(), $uri, $headers, $changes['body'] ?? $request->getBody(), $changes['version'] ?? $request->getProtocolVersion());
}
/**
* Read a line from the stream up to the maximum allowed buffer length.
*
* @param StreamInterface $stream Stream to read from
* @param int|null $maxLength Maximum buffer length
*/
public static function readLine(StreamInterface $stream, ?int $maxLength = null): string
{
$buffer = '';
$size = 0;
while (!$stream->eof()) {
if ('' === $byte = $stream->read(1)) {
return $buffer;
}
$buffer .= $byte;
// Break when a new line is found or the max length - 1 is reached
if ($byte === "\n" || ++$size === $maxLength - 1) {
break;
}
}
return $buffer;
}
/**
* Redact the password in the user info part of a URI.
*/
public static function redactUserInfo(UriInterface $uri): UriInterface
{
$userInfo = $uri->getUserInfo();
if (\false !== $pos = \strpos($userInfo, ':')) {
return $uri->withUserInfo(\substr($userInfo, 0, $pos), '***');
}
return $uri;
}
/**
* Create a new stream based on the input type.
*
* Options is an associative array that can contain the following keys:
* - metadata: Array of custom metadata.
* - size: Size of the stream.
*
* This method accepts the following `$resource` types:
* - `Psr\Http\Message\StreamInterface`: Returns the value as-is.
* - `string`: Creates a stream object that uses the given string as the contents.
* - `resource`: Creates a stream object that wraps the given PHP stream resource.
* - `Iterator`: If the provided value implements `Iterator`, then a read-only
* stream object will be created that wraps the given iterable. Each time the
* stream is read from, data from the iterator will fill a buffer and will be
* continuously called until the buffer is equal to the requested read size.
* Subsequent read calls will first read from the buffer and then call `next`
* on the underlying iterator until it is exhausted.
* - `object` with `__toString()`: If the object has the `__toString()` method,
* the object will be cast to a string and then a stream will be returned that
* uses the string value.
* - `NULL`: When `null` is passed, an empty stream object is returned.
* - `callable` When a callable is passed, a read-only stream object will be
* created that invokes the given callable. The callable is invoked with the
* number of suggested bytes to read. The callable can return any number of
* bytes, but MUST return `false` when there is no more data to return. The
* stream object that wraps the callable will invoke the callable until the
* number of requested bytes are available. Any additional bytes will be
* buffered and used in subsequent reads.
*
* @param resource|string|int|float|bool|StreamInterface|callable|\Iterator|null $resource Entity body data
* @param array{size?: int, metadata?: array} $options Additional options
*
* @throws \InvalidArgumentException if the $resource arg is not valid.
*/
public static function streamFor($resource = '', array $options = []): StreamInterface
{
if (is_scalar($resource)) {
$stream = self::tryFopen('php://temp', 'r+');
if ($resource !== '') {
fwrite($stream, (string) $resource);
fseek($stream, 0);
}
return new Stream($stream, $options);
}
switch (gettype($resource)) {
case 'resource':
/*
* The 'php://input' is a special stream with quirks and inconsistencies.
* We avoid using that stream by reading it into php://temp
*/
/** @var resource $resource */
if ((\stream_get_meta_data($resource)['uri'] ?? '') === 'php://input') {
$stream = self::tryFopen('php://temp', 'w+');
stream_copy_to_stream($resource, $stream);
fseek($stream, 0);
$resource = $stream;
}
return new Stream($resource, $options);
case 'object':
/** @var object $resource */
if ($resource instanceof StreamInterface) {
return $resource;
} elseif ($resource instanceof \Iterator) {
return new PumpStream(function () use ($resource) {
if (!$resource->valid()) {
return \false;
}
$result = $resource->current();
$resource->next();
return $result;
}, $options);
} elseif (method_exists($resource, '__toString')) {
return self::streamFor((string) $resource, $options);
}
break;
case 'NULL':
return new Stream(self::tryFopen('php://temp', 'r+'), $options);
}
if (is_callable($resource)) {
return new PumpStream($resource, $options);
}
throw new \InvalidArgumentException('Invalid resource type: ' . gettype($resource));
}
/**
* Safely opens a PHP stream resource using a filename.
*
* When fopen fails, PHP normally raises a warning. This function adds an
* error handler that checks for errors and throws an exception instead.
*
* @param string $filename File to open
* @param string $mode Mode used to open the file
*
* @return resource
*
* @throws \RuntimeException if the file cannot be opened
*/
public static function tryFopen(string $filename, string $mode)
{
$ex = null;
set_error_handler(static function (int $errno, string $errstr) use ($filename, $mode, &$ex): bool {
$ex = new \RuntimeException(sprintf('Unable to open "%s" using mode "%s": %s', $filename, $mode, $errstr));
return \true;
});
try {
/** @var resource $handle */
$handle = fopen($filename, $mode);
} catch (\Throwable $e) {
$ex = new \RuntimeException(sprintf('Unable to open "%s" using mode "%s": %s', $filename, $mode, $e->getMessage()), 0, $e);
}
restore_error_handler();
if ($ex) {
/** @var $ex \RuntimeException */
throw $ex;
}
return $handle;
}
/**
* Safely gets the contents of a given stream.
*
* When stream_get_contents fails, PHP normally raises a warning. This
* function adds an error handler that checks for errors and throws an
* exception instead.
*
* @param resource $stream
*
* @throws \RuntimeException if the stream cannot be read
*/
public static function tryGetContents($stream): string
{
$ex = null;
set_error_handler(static function (int $errno, string $errstr) use (&$ex): bool {
$ex = new \RuntimeException(sprintf('Unable to read stream contents: %s', $errstr));
return \true;
});
try {
/** @var string|false $contents */
$contents = stream_get_contents($stream);
if ($contents === \false) {
$ex = new \RuntimeException('Unable to read stream contents');
}
} catch (\Throwable $e) {
$ex = new \RuntimeException(sprintf('Unable to read stream contents: %s', $e->getMessage()), 0, $e);
}
restore_error_handler();
if ($ex) {
/** @var $ex \RuntimeException */
throw $ex;
}
return $contents;
}
/**
* Returns a UriInterface for the given value.
*
* This function accepts a string or UriInterface and returns a
* UriInterface for the given value. If the value is already a
* UriInterface, it is returned as-is.
*
* @param string|UriInterface $uri
*
* @throws \InvalidArgumentException
*/
public static function uriFor($uri): UriInterface
{
if ($uri instanceof UriInterface) {
return $uri;
}
if (is_string($uri)) {
return new Uri($uri);
}
throw new \InvalidArgumentException('URI must be a string or UriInterface');
}
}

View File

@ -0,0 +1,9 @@
The MIT License (MIT)
Copyright (c) 2014 Oliver Vogel
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.

View File

@ -0,0 +1,54 @@
{
"name": "intervention\/image",
"description": "Image handling and manipulation library with support for Laravel integration",
"homepage": "http:\/\/image.intervention.io\/",
"keywords": [
"image",
"gd",
"imagick",
"laravel",
"watermark",
"thumbnail"
],
"license": "MIT",
"authors": [
{
"name": "Oliver Vogel",
"email": "oliver@intervention.io",
"homepage": "https:\/\/intervention.io\/"
}
],
"require": {
"php": ">=5.4.0",
"ext-fileinfo": "*",
"guzzlehttp\/psr7": "~1.1 || ^2.0"
},
"require-dev": {
"phpunit\/phpunit": "^4.8 || ^5.7 || ^7.5.15",
"mockery\/mockery": "~0.9.2"
},
"suggest": {
"ext-gd": "to use GD library based image processing.",
"ext-imagick": "to use Imagick based image processing.",
"intervention\/imagecache": "Caching extension for the Intervention Image library"
},
"autoload": {
"psr-4": {
"RegularLabs\\Scoped\\Intervention\\Image\\": "src\/Intervention\/Image"
}
},
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
},
"laravel": {
"providers": [
"RegularLabs\\Scoped\\Intervention\\Image\\ImageServiceProvider"
],
"aliases": {
"Image": "Intervention\\Image\\Facades\\Image"
}
}
},
"minimum-stability": "stable"
}

View File

@ -0,0 +1,11 @@
{
"providers": [
"Intervention\\Image\\ImageServiceProvider"
],
"aliases": [
{
"alias": "Image",
"facade": "Intervention\\Image\\Facades\\Image"
}
]
}

View File

@ -0,0 +1,190 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image;
use RegularLabs\Scoped\Intervention\Image\Exception\NotReadableException;
use RegularLabs\Scoped\Intervention\Image\Exception\NotSupportedException;
abstract class AbstractColor
{
/**
* Initiates color object from integer
*
* @param int $value
* @return \Intervention\Image\AbstractColor
*/
abstract public function initFromInteger($value);
/**
* Initiates color object from given array
*
* @param array $value
* @return \Intervention\Image\AbstractColor
*/
abstract public function initFromArray($value);
/**
* Initiates color object from given string
*
* @param string $value
* @return \Intervention\Image\AbstractColor
*/
abstract public function initFromString($value);
/**
* Initiates color object from given ImagickPixel object
*
* @param ImagickPixel $value
* @return \Intervention\Image\AbstractColor
*/
abstract public function initFromObject($value);
/**
* Initiates color object from given R, G and B values
*
* @param int $r
* @param int $g
* @param int $b
* @return \Intervention\Image\AbstractColor
*/
abstract public function initFromRgb($r, $g, $b);
/**
* Initiates color object from given R, G, B and A values
*
* @param int $r
* @param int $g
* @param int $b
* @param float $a
* @return \Intervention\Image\AbstractColor
*/
abstract public function initFromRgba($r, $g, $b, $a);
/**
* Calculates integer value of current color instance
*
* @return int
*/
abstract public function getInt();
/**
* Calculates hexadecimal value of current color instance
*
* @param string $prefix
* @return string
*/
abstract public function getHex($prefix);
/**
* Calculates RGB(A) in array format of current color instance
*
* @return array
*/
abstract public function getArray();
/**
* Calculates RGBA in string format of current color instance
*
* @return string
*/
abstract public function getRgba();
/**
* Determines if current color is different from given color
*
* @param AbstractColor $color
* @param int $tolerance
* @return boolean
*/
abstract public function differs(AbstractColor $color, $tolerance = 0);
/**
* Creates new instance
*
* @param mixed $value
*/
public function __construct($value = null)
{
$this->parse($value);
}
/**
* Parses given value as color
*
* @param mixed $value
* @return \Intervention\Image\AbstractColor
*/
public function parse($value)
{
switch (\true) {
case is_string($value):
$this->initFromString($value);
break;
case is_int($value):
$this->initFromInteger($value);
break;
case is_array($value):
$this->initFromArray($value);
break;
case is_object($value):
$this->initFromObject($value);
break;
case is_null($value):
$this->initFromArray([255, 255, 255, 0]);
break;
default:
throw new NotReadableException("Color format ({$value}) cannot be read.");
}
return $this;
}
/**
* Formats current color instance into given format
*
* @param string $type
* @return mixed
*/
public function format($type)
{
switch (strtolower($type)) {
case 'rgba':
return $this->getRgba();
case 'hex':
return $this->getHex('#');
case 'int':
case 'integer':
return $this->getInt();
case 'array':
return $this->getArray();
case 'obj':
case 'object':
return $this;
default:
throw new NotSupportedException("Color format ({$type}) is not supported.");
}
}
/**
* Reads RGBA values from string into array
*
* @param string $value
* @return array
*/
protected function rgbaFromString($value)
{
$result = \false;
// parse color string in hexidecimal format like #cccccc or cccccc or ccc
$hexPattern = '/^#?([a-f0-9]{1,2})([a-f0-9]{1,2})([a-f0-9]{1,2})$/i';
// parse color string in format rgb(140, 140, 140)
$rgbPattern = '/^rgb ?\(([0-9]{1,3}), ?([0-9]{1,3}), ?([0-9]{1,3})\)$/i';
// parse color string in format rgba(255, 0, 0, 0.5)
$rgbaPattern = '/^rgba ?\(([0-9]{1,3}), ?([0-9]{1,3}), ?([0-9]{1,3}), ?([0-9.]{1,4})\)$/i';
if (preg_match($hexPattern, $value, $matches)) {
$result = [];
$result[0] = strlen($matches[1]) == '1' ? hexdec($matches[1] . $matches[1]) : hexdec($matches[1]);
$result[1] = strlen($matches[2]) == '1' ? hexdec($matches[2] . $matches[2]) : hexdec($matches[2]);
$result[2] = strlen($matches[3]) == '1' ? hexdec($matches[3] . $matches[3]) : hexdec($matches[3]);
$result[3] = 1;
} elseif (preg_match($rgbPattern, $value, $matches)) {
$result = [];
$result[0] = $matches[1] >= 0 && $matches[1] <= 255 ? intval($matches[1]) : 0;
$result[1] = $matches[2] >= 0 && $matches[2] <= 255 ? intval($matches[2]) : 0;
$result[2] = $matches[3] >= 0 && $matches[3] <= 255 ? intval($matches[3]) : 0;
$result[3] = 1;
} elseif (preg_match($rgbaPattern, $value, $matches)) {
$result = [];
$result[0] = $matches[1] >= 0 && $matches[1] <= 255 ? intval($matches[1]) : 0;
$result[1] = $matches[2] >= 0 && $matches[2] <= 255 ? intval($matches[2]) : 0;
$result[2] = $matches[3] >= 0 && $matches[3] <= 255 ? intval($matches[3]) : 0;
$result[3] = $matches[4] >= 0 && $matches[4] <= 1 ? $matches[4] : 0;
} else {
throw new NotReadableException("Unable to read color ({$value}).");
}
return $result;
}
}

View File

@ -0,0 +1,307 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image;
use RegularLabs\Scoped\GuzzleHttp\Psr7\Stream;
use RegularLabs\Scoped\Intervention\Image\Exception\NotReadableException;
use RegularLabs\Scoped\Psr\Http\Message\StreamInterface;
abstract class AbstractDecoder
{
/**
* Initiates new image from path in filesystem
*
* @param string $path
* @return \Intervention\Image\Image
*/
abstract public function initFromPath($path);
/**
* Initiates new image from binary data
*
* @param string $data
* @return \Intervention\Image\Image
*/
abstract public function initFromBinary($data);
/**
* Initiates new image from GD resource
*
* @param Resource $resource
* @return \Intervention\Image\Image
*/
abstract public function initFromGdResource($resource);
/**
* Initiates new image from Imagick object
*
* @param \Imagick $object
* @return \Intervention\Image\Image
*/
abstract public function initFromImagick(\Imagick $object);
/**
* Buffer of input data
*
* @var mixed
*/
private $data;
/**
* Creates new Decoder with data
*
* @param mixed $data
*/
public function __construct($data = null)
{
$this->data = $data;
}
/**
* Init from given URL
*
* @param string $url
* @return \Intervention\Image\Image
*/
public function initFromUrl($url)
{
$options = ['http' => [
'method' => "GET",
'protocol_version' => 1.1,
// force use HTTP 1.1 for service mesh environment with envoy
'header' => "Accept-language: en\r\n" . "User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36\r\n",
]];
$context = stream_context_create($options);
if ($data = @file_get_contents($url, \false, $context)) {
return $this->initFromBinary($data);
}
throw new NotReadableException("Unable to init from given url (" . $url . ").");
}
/**
* Init from given stream
*
* @param StreamInterface|resource $stream
* @return \Intervention\Image\Image
*/
public function initFromStream($stream)
{
if (!$stream instanceof StreamInterface) {
$stream = new Stream($stream);
}
try {
$offset = $stream->tell();
} catch (\RuntimeException $e) {
$offset = 0;
}
$shouldAndCanSeek = $offset !== 0 && $stream->isSeekable();
if ($shouldAndCanSeek) {
$stream->rewind();
}
try {
$data = $stream->getContents();
} catch (\RuntimeException $e) {
$data = null;
}
if ($shouldAndCanSeek) {
$stream->seek($offset);
}
if ($data) {
return $this->initFromBinary($data);
}
throw new NotReadableException("Unable to init from given stream");
}
/**
* Determines if current source data is GD resource
*
* @return boolean
*/
public function isGdResource()
{
if (is_resource($this->data)) {
return get_resource_type($this->data) == 'gd';
}
if ($this->data instanceof \GdImage) {
return \true;
}
return \false;
}
/**
* Determines if current source data is Imagick object
*
* @return boolean
*/
public function isImagick()
{
return is_a($this->data, 'Imagick');
}
/**
* Determines if current source data is Intervention\Image\Image object
*
* @return boolean
*/
public function isInterventionImage()
{
return is_a($this->data, 'RegularLabs\Scoped\Intervention\Image\Image');
}
/**
* Determines if current data is SplFileInfo object
*
* @return boolean
*/
public function isSplFileInfo()
{
return is_a($this->data, 'SplFileInfo');
}
/**
* Determines if current data is Symfony UploadedFile component
*
* @return boolean
*/
public function isSymfonyUpload()
{
return is_a($this->data, 'RegularLabs\Scoped\Symfony\Component\HttpFoundation\File\UploadedFile');
}
/**
* Determines if current source data is file path
*
* @return boolean
*/
public function isFilePath()
{
if (is_string($this->data)) {
try {
return is_file($this->data);
} catch (\Exception $e) {
return \false;
}
}
return \false;
}
/**
* Determines if current source data is url
*
* @return boolean
*/
public function isUrl()
{
return (bool) filter_var($this->data, \FILTER_VALIDATE_URL);
}
/**
* Determines if current source data is a stream resource
*
* @return boolean
*/
public function isStream()
{
if ($this->data instanceof StreamInterface) {
return \true;
}
if (!is_resource($this->data)) {
return \false;
}
if (get_resource_type($this->data) !== 'stream') {
return \false;
}
return \true;
}
/**
* Determines if current source data is binary data
*
* @return boolean
*/
public function isBinary()
{
if (is_string($this->data)) {
$mime = finfo_buffer(finfo_open(\FILEINFO_MIME_TYPE), $this->data);
return substr($mime, 0, 4) != 'text' && $mime != 'application/x-empty';
}
return \false;
}
/**
* Determines if current source data is data-url
*
* @return boolean
*/
public function isDataUrl()
{
$data = $this->decodeDataUrl($this->data);
return is_null($data) ? \false : \true;
}
/**
* Determines if current source data is base64 encoded
*
* @return boolean
*/
public function isBase64()
{
if (!is_string($this->data)) {
return \false;
}
return base64_encode(base64_decode($this->data)) === str_replace(["\n", "\r"], '', $this->data);
}
/**
* Initiates new Image from Intervention\Image\Image
*
* @param Image $object
* @return \Intervention\Image\Image
*/
public function initFromInterventionImage($object)
{
return $object;
}
/**
* Parses and decodes binary image data from data-url
*
* @param string $data_url
* @return string
*/
private function decodeDataUrl($data_url)
{
if (!is_string($data_url)) {
return null;
}
$pattern = "/^data:(?:image\\/[a-zA-Z\\-\\.]+)(?:charset=\".+\")?;base64,(?P<data>.+)\$/";
preg_match($pattern, str_replace(["\n", "\r"], '', $data_url), $matches);
if (is_array($matches) && array_key_exists('data', $matches)) {
return base64_decode($matches['data']);
}
return null;
}
/**
* Initiates new image from mixed data
*
* @param mixed $data
* @return \Intervention\Image\Image
*/
public function init($data)
{
$this->data = $data;
switch (\true) {
case $this->isGdResource():
return $this->initFromGdResource($this->data);
case $this->isImagick():
return $this->initFromImagick($this->data);
case $this->isInterventionImage():
return $this->initFromInterventionImage($this->data);
case $this->isSplFileInfo():
return $this->initFromPath($this->data->getRealPath());
case $this->isBinary():
return $this->initFromBinary($this->data);
case $this->isUrl():
return $this->initFromUrl($this->data);
case $this->isStream():
return $this->initFromStream($this->data);
case $this->isDataUrl():
return $this->initFromBinary($this->decodeDataUrl($this->data));
case $this->isFilePath():
return $this->initFromPath($this->data);
// isBase64 has to be after isFilePath to prevent false positives
case $this->isBase64():
return $this->initFromBinary(base64_decode($this->data));
default:
throw new NotReadableException("Image source not readable");
}
}
/**
* Decoder object transforms to string source data
*
* @return string
*/
public function __toString()
{
return (string) $this->data;
}
}

View File

@ -0,0 +1,122 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image;
use RegularLabs\Scoped\Intervention\Image\Exception\NotSupportedException;
abstract class AbstractDriver
{
/**
* Decoder instance to init images from
*
* @var \Intervention\Image\AbstractDecoder
*/
public $decoder;
/**
* Image encoder instance
*
* @var \Intervention\Image\AbstractEncoder
*/
public $encoder;
/**
* Creates new image instance
*
* @param int $width
* @param int $height
* @param string $background
* @return \Intervention\Image\Image
*/
abstract public function newImage($width, $height, $background);
/**
* Reads given string into color object
*
* @param string $value
* @return AbstractColor
*/
abstract public function parseColor($value);
/**
* Checks if core module installation is available
*
* @return boolean
*/
abstract protected function coreAvailable();
/**
* Returns clone of given core
*
* @return mixed
*/
public function cloneCore($core)
{
return clone $core;
}
/**
* Initiates new image from given input
*
* @param mixed $data
* @return \Intervention\Image\Image
*/
public function init($data)
{
return $this->decoder->init($data);
}
/**
* Encodes given image
*
* @param Image $image
* @param string $format
* @param int $quality
* @return \Intervention\Image\Image
*/
public function encode($image, $format, $quality)
{
return $this->encoder->process($image, $format, $quality);
}
/**
* Executes named command on given image
*
* @param Image $image
* @param string $name
* @param array $arguments
* @return \Intervention\Image\Commands\AbstractCommand
*/
public function executeCommand($image, $name, $arguments)
{
$commandName = $this->getCommandClassName($name);
$command = new $commandName($arguments);
$command->execute($image);
return $command;
}
/**
* Returns classname of given command name
*
* @param string $name
* @return string
*/
private function getCommandClassName($name)
{
if (extension_loaded('mbstring')) {
$name = mb_strtoupper(mb_substr($name, 0, 1)) . mb_substr($name, 1);
} else {
$name = strtoupper(substr($name, 0, 1)) . substr($name, 1);
}
$drivername = $this->getDriverName();
$classnameLocal = sprintf('\RegularLabs\Scoped\Intervention\Image\%s\Commands\%sCommand', $drivername, ucfirst($name));
$classnameGlobal = sprintf('\RegularLabs\Scoped\Intervention\Image\Commands\%sCommand', ucfirst($name));
if (class_exists($classnameLocal)) {
return $classnameLocal;
} elseif (class_exists($classnameGlobal)) {
return $classnameGlobal;
}
throw new NotSupportedException("Command ({$name}) is not available for driver ({$drivername}).");
}
/**
* Returns name of current driver instance
*
* @return string
*/
public function getDriverName()
{
$reflect = new \ReflectionClass($this);
$namespace = $reflect->getNamespaceName();
return substr(strrchr($namespace, "\\"), 1);
}
}

View File

@ -0,0 +1,225 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image;
use RegularLabs\Scoped\Intervention\Image\Exception\InvalidArgumentException;
use RegularLabs\Scoped\Intervention\Image\Exception\NotSupportedException;
abstract class AbstractEncoder
{
/**
* Buffer of encode result data
*
* @var string
*/
public $result;
/**
* Image object to encode
*
* @var Image
*/
public $image;
/**
* Output format of encoder instance
*
* @var string
*/
public $format;
/**
* Output quality of encoder instance
*
* @var int
*/
public $quality;
/**
* Processes and returns encoded image as JPEG string
*
* @return string
*/
abstract protected function processJpeg();
/**
* Processes and returns encoded image as PNG string
*
* @return string
*/
abstract protected function processPng();
/**
* Processes and returns encoded image as GIF string
*
* @return string
*/
abstract protected function processGif();
/**
* Processes and returns encoded image as TIFF string
*
* @return string
*/
abstract protected function processTiff();
/**
* Processes and returns encoded image as BMP string
*
* @return string
*/
abstract protected function processBmp();
/**
* Processes and returns encoded image as ICO string
*
* @return string
*/
abstract protected function processIco();
/**
* Processes and returns image as WebP encoded string
*
* @return string
*/
abstract protected function processWebp();
/**
* Processes and returns image as Avif encoded string
*
* @return string
*/
abstract protected function processAvif();
/**
* Processes and returns image as Heic encoded string
*
* @return string
*/
abstract protected function processHeic();
/**
* Process a given image
*
* @param Image $image
* @param string $format
* @param int $quality
* @return Image
*/
public function process(Image $image, $format = null, $quality = null)
{
$this->setImage($image);
$this->setFormat($format);
$this->setQuality($quality);
switch (strtolower($this->format)) {
case 'data-url':
$this->result = $this->processDataUrl();
break;
case 'gif':
case 'image/gif':
$this->result = $this->processGif();
break;
case 'png':
case 'image/png':
case 'image/x-png':
$this->result = $this->processPng();
break;
case 'jpg':
case 'jpeg':
case 'jfif':
case 'image/jp2':
case 'image/jpg':
case 'image/jpeg':
case 'image/pjpeg':
case 'image/jfif':
$this->result = $this->processJpeg();
break;
case 'tif':
case 'tiff':
case 'image/tiff':
case 'image/tif':
case 'image/x-tif':
case 'image/x-tiff':
$this->result = $this->processTiff();
break;
case 'bmp':
case 'ms-bmp':
case 'x-bitmap':
case 'x-bmp':
case 'x-ms-bmp':
case 'x-win-bitmap':
case 'x-windows-bmp':
case 'x-xbitmap':
case 'image/ms-bmp':
case 'image/x-bitmap':
case 'image/x-bmp':
case 'image/x-ms-bmp':
case 'image/x-win-bitmap':
case 'image/x-windows-bmp':
case 'image/x-xbitmap':
$this->result = $this->processBmp();
break;
case 'ico':
case 'image/x-ico':
case 'image/x-icon':
case 'image/vnd.microsoft.icon':
$this->result = $this->processIco();
break;
case 'psd':
case 'image/vnd.adobe.photoshop':
$this->result = $this->processPsd();
break;
case 'webp':
case 'image/webp':
case 'image/x-webp':
$this->result = $this->processWebp();
break;
case 'avif':
case 'image/avif':
$this->result = $this->processAvif();
break;
case 'heic':
case 'image/heic':
case 'image/heif':
$this->result = $this->processHeic();
break;
default:
throw new NotSupportedException("Encoding format ({$this->format}) is not supported.");
}
$this->setImage(null);
return $image->setEncoded($this->result);
}
/**
* Processes and returns encoded image as data-url string
*
* @return string
*/
protected function processDataUrl()
{
$mime = $this->image->mime ? $this->image->mime : 'image/png';
return sprintf('data:%s;base64,%s', $mime, base64_encode($this->process($this->image, $mime, $this->quality)));
}
/**
* Sets image to process
*
* @param Image $image
*/
protected function setImage($image)
{
$this->image = $image;
}
/**
* Determines output format
*
* @param string $format
*/
protected function setFormat($format = null)
{
if ($format == '' && $this->image instanceof Image) {
$format = $this->image->mime;
}
$this->format = $format ? $format : 'jpg';
return $this;
}
/**
* Determines output quality
*
* @param int $quality
*/
protected function setQuality($quality)
{
$quality = is_null($quality) ? 90 : $quality;
$quality = $quality === 0 ? 1 : $quality;
if ($quality < 0 || $quality > 100) {
throw new InvalidArgumentException('Quality must range from 0 to 100.');
}
$this->quality = intval($quality);
return $this;
}
}

View File

@ -0,0 +1,259 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image;
abstract class AbstractFont
{
/**
* Text to be written
*
* @var String
*/
public $text;
/**
* Text size in pixels
*
* @var int
*/
public $size = 12;
/**
* Color of the text
*
* @var mixed
*/
public $color = '000000';
/**
* Rotation angle of the text
*
* @var int
*/
public $angle = 0;
/**
* Horizontal alignment of the text
*
* @var String
*/
public $align;
/**
* Vertical alignment of the text
*
* @var String
*/
public $valign;
/**
* Space between text characters
*
* @var float
*/
public $kerning = 0;
/**
* Path to TTF or GD library internal font file of the text
*
* @var mixed
*/
public $file;
/**
* Draws font to given image on given position
*
* @param Image $image
* @param int $posx
* @param int $posy
* @return boolean
*/
abstract public function applyToImage(Image $image, $posx = 0, $posy = 0);
/**
* Calculates bounding box of current font setting
*
* @return array
*/
abstract public function getBoxSize();
/**
* Create a new instance of Font
*
* @param String $text Text to be written
*/
public function __construct($text = null)
{
$this->text = $text;
}
/**
* Set text to be written
*
* @param String $text
* @return self
*/
public function text($text)
{
$this->text = $text;
return $this;
}
/**
* Get text to be written
*
* @return String
*/
public function getText()
{
return $this->text;
}
/**
* Set font size in pixels
*
* @param int $size
* @return self
*/
public function size($size)
{
$this->size = $size;
return $this;
}
/**
* Get font size in pixels
*
* @return int
*/
public function getSize()
{
return $this->size;
}
/**
* Set color of text to be written
*
* @param mixed $color
* @return self
*/
public function color($color)
{
$this->color = $color;
return $this;
}
/**
* Get color of text
*
* @return mixed
*/
public function getColor()
{
return $this->color;
}
/**
* Set rotation angle of text
*
* @param int $angle
* @return self
*/
public function angle($angle)
{
$this->angle = $angle;
return $this;
}
/**
* Get rotation angle of text
*
* @return int
*/
public function getAngle()
{
return $this->angle;
}
/**
* Set horizontal text alignment
*
* @param string $align
* @return self
*/
public function align($align)
{
$this->align = $align;
return $this;
}
/**
* Get horizontal text alignment
*
* @return string
*/
public function getAlign()
{
return $this->align;
}
/**
* Set vertical text alignment
*
* @param string $valign
* @return self
*/
public function valign($valign)
{
$this->valign = $valign;
return $this;
}
/**
* Get vertical text alignment
*
* @return string
*/
public function getValign()
{
return $this->valign;
}
/**
* Set text kerning
*
* @param string $kerning
* @return void
*/
public function kerning($kerning)
{
$this->kerning = $kerning;
}
/**
* Get kerning
*
* @return float
*/
public function getKerning()
{
return $this->kerning;
}
/**
* Set path to font file
*
* @param string $file
* @return self
*/
public function file($file)
{
$this->file = $file;
return $this;
}
/**
* Get path to font file
*
* @return string
*/
public function getFile()
{
return $this->file;
}
/**
* Checks if current font has access to an applicable font file
*
* @return boolean
*/
protected function hasApplicableFontFile()
{
if (is_string($this->file)) {
return file_exists($this->file);
}
return \false;
}
/**
* Counts lines of text to be written
*
* @return int
*/
public function countLines()
{
return count(explode(\PHP_EOL, $this->text));
}
}

View File

@ -0,0 +1,65 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image;
abstract class AbstractShape
{
/**
* Background color of shape
*
* @var string
*/
public $background;
/**
* Border color of current shape
*
* @var string
*/
public $border_color;
/**
* Border width of shape
*
* @var int
*/
public $border_width = 0;
/**
* Draws shape to given image on given position
*
* @param Image $image
* @param int $posx
* @param int $posy
* @return boolean
*/
abstract public function applyToImage(Image $image, $posx = 0, $posy = 0);
/**
* Set text to be written
*
* @param string $text
* @return void
*/
public function background($color)
{
$this->background = $color;
}
/**
* Set border width and color of current shape
*
* @param int $width
* @param string $color
* @return void
*/
public function border($width, $color = null)
{
$this->border_width = is_numeric($width) ? intval($width) : 0;
$this->border_color = is_null($color) ? '#000000' : $color;
}
/**
* Determines if current shape has border
*
* @return boolean
*/
public function hasBorder()
{
return $this->border_width >= 1;
}
}

View File

@ -0,0 +1,73 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Commands;
use RegularLabs\Scoped\Intervention\Image\Commands\Argument;
abstract class AbstractCommand
{
/**
* Arguments of command
*
* @var array
*/
public $arguments;
/**
* Output of command
*
* @var mixed
*/
protected $output;
/**
* Executes current command on given image
*
* @param \Intervention\Image\Image $image
* @return mixed
*/
abstract public function execute($image);
/**
* Creates new command instance
*
* @param array $arguments
*/
public function __construct($arguments)
{
$this->arguments = $arguments;
}
/**
* Creates new argument instance from given argument key
*
* @param int $key
* @return \Intervention\Image\Commands\Argument
*/
public function argument($key)
{
return new Argument($this, $key);
}
/**
* Returns output data of current command
*
* @return mixed
*/
public function getOutput()
{
return $this->output ? $this->output : null;
}
/**
* Determines if current instance has output data
*
* @return boolean
*/
public function hasOutput()
{
return !is_null($this->output);
}
/**
* Sets output data of current command
*
* @param mixed $value
*/
public function setOutput($value)
{
$this->output = $value;
}
}

View File

@ -0,0 +1,185 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Commands;
use RegularLabs\Scoped\Intervention\Image\Exception\InvalidArgumentException;
class Argument
{
/**
* Command with arguments
*
* @var AbstractCommand
*/
public $command;
/**
* Key of argument in array
*
* @var int
*/
public $key;
/**
* Creates new instance from given command and key
*
* @param AbstractCommand $command
* @param int $key
*/
public function __construct(AbstractCommand $command, $key = 0)
{
$this->command = $command;
$this->key = $key;
}
/**
* Returns name of current arguments command
*
* @return string
*/
public function getCommandName()
{
preg_match("/\\\\([\\w]+)Command\$/", get_class($this->command), $matches);
return isset($matches[1]) ? lcfirst($matches[1]) . '()' : 'Method';
}
/**
* Returns value of current argument
*
* @param mixed $default
* @return mixed
*/
public function value($default = null)
{
$arguments = $this->command->arguments;
if (is_array($arguments)) {
return isset($arguments[$this->key]) ? $arguments[$this->key] : $default;
}
return $default;
}
/**
* Defines current argument as required
*
* @return \Intervention\Image\Commands\Argument
*/
public function required()
{
if (!array_key_exists($this->key, $this->command->arguments)) {
throw new InvalidArgumentException(sprintf("Missing argument %d for %s", $this->key + 1, $this->getCommandName()));
}
return $this;
}
/**
* Determines that current argument must be of given type
*
* @return \Intervention\Image\Commands\Argument
*/
public function type($type)
{
$valid = \true;
$value = $this->value();
if ($value === null) {
return $this;
}
switch (strtolower($type)) {
case 'bool':
case 'boolean':
$valid = \is_bool($value);
$message = '%s accepts only boolean values as argument %d.';
break;
case 'int':
case 'integer':
$valid = \is_int($value);
$message = '%s accepts only integer values as argument %d.';
break;
case 'num':
case 'numeric':
$valid = is_numeric($value);
$message = '%s accepts only numeric values as argument %d.';
break;
case 'str':
case 'string':
$valid = \is_string($value);
$message = '%s accepts only string values as argument %d.';
break;
case 'array':
$valid = \is_array($value);
$message = '%s accepts only array as argument %d.';
break;
case 'closure':
$valid = is_a($value, '\Closure');
$message = '%s accepts only Closure as argument %d.';
break;
case 'digit':
$valid = $this->isDigit($value);
$message = '%s accepts only integer values as argument %d.';
break;
}
if (!$valid) {
$commandName = $this->getCommandName();
$argument = $this->key + 1;
if (isset($message)) {
$message = sprintf($message, $commandName, $argument);
} else {
$message = sprintf('Missing argument for %d.', $argument);
}
throw new InvalidArgumentException($message);
}
return $this;
}
/**
* Determines that current argument value must be numeric between given values
*
* @return \Intervention\Image\Commands\Argument
*/
public function between($x, $y)
{
$value = $this->type('numeric')->value();
if (is_null($value)) {
return $this;
}
$alpha = min($x, $y);
$omega = max($x, $y);
if ($value < $alpha || $value > $omega) {
throw new InvalidArgumentException(sprintf('Argument %d must be between %s and %s.', $this->key, $x, $y));
}
return $this;
}
/**
* Determines that current argument must be over a minimum value
*
* @return \Intervention\Image\Commands\Argument
*/
public function min($value)
{
$v = $this->type('numeric')->value();
if (is_null($v)) {
return $this;
}
if ($v < $value) {
throw new InvalidArgumentException(sprintf('Argument %d must be at least %s.', $this->key, $value));
}
return $this;
}
/**
* Determines that current argument must be under a maxiumum value
*
* @return \Intervention\Image\Commands\Argument
*/
public function max($value)
{
$v = $this->type('numeric')->value();
if (is_null($v)) {
return $this;
}
if ($v > $value) {
throw new InvalidArgumentException(sprintf('Argument %d may not be greater than %s.', $this->key, $value));
}
return $this;
}
/**
* Checks if value is "PHP" integer (120 but also 120.0)
*
* @param mixed $value
* @return boolean
*/
private function isDigit($value)
{
return is_numeric($value) ? intval($value) == $value : \false;
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Commands;
class ChecksumCommand extends AbstractCommand
{
/**
* Calculates checksum of given image
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
$colors = [];
$size = $image->getSize();
for ($x = 0; $x <= $size->width - 1; $x++) {
for ($y = 0; $y <= $size->height - 1; $y++) {
$colors[] = $image->pickColor($x, $y, 'array');
}
}
$this->setOutput(md5(serialize($colors)));
return \true;
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Commands;
use Closure;
class CircleCommand extends AbstractCommand
{
/**
* Draw a circle centered on given image
*
* @param \Intervention\Image\image $image
* @return boolean
*/
public function execute($image)
{
$diameter = $this->argument(0)->type('numeric')->required()->value();
$x = $this->argument(1)->type('numeric')->required()->value();
$y = $this->argument(2)->type('numeric')->required()->value();
$callback = $this->argument(3)->type('closure')->value();
$circle_classname = sprintf('\RegularLabs\Scoped\Intervention\Image\%s\Shapes\CircleShape', $image->getDriver()->getDriverName());
$circle = new $circle_classname($diameter);
if ($callback instanceof Closure) {
$callback($circle);
}
$circle->applyToImage($image, $x, $y);
return \true;
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Commands;
use Closure;
class EllipseCommand extends AbstractCommand
{
/**
* Draws ellipse on given image
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
$width = $this->argument(0)->type('numeric')->required()->value();
$height = $this->argument(1)->type('numeric')->required()->value();
$x = $this->argument(2)->type('numeric')->required()->value();
$y = $this->argument(3)->type('numeric')->required()->value();
$callback = $this->argument(4)->type('closure')->value();
$ellipse_classname = sprintf('\RegularLabs\Scoped\Intervention\Image\%s\Shapes\EllipseShape', $image->getDriver()->getDriverName());
$ellipse = new $ellipse_classname($width, $height);
if ($callback instanceof Closure) {
$callback($ellipse);
}
$ellipse->applyToImage($image, $x, $y);
return \true;
}
}

View File

@ -0,0 +1,45 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Commands;
use RegularLabs\Scoped\Intervention\Image\Exception\NotReadableException;
use RegularLabs\Scoped\Intervention\Image\Exception\NotSupportedException;
class ExifCommand extends AbstractCommand
{
/**
* Read Exif data from the given image
*
* Note: Windows PHP Users - in order to use this method you will need to
* enable the mbstring and exif extensions within the php.ini file.
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
if (!function_exists('exif_read_data')) {
throw new NotSupportedException("Reading Exif data is not supported by this PHP installation.");
}
$key = $this->argument(0)->value();
// try to read exif data from image file
try {
if ($image->dirname && $image->basename) {
$stream = $image->dirname . '/' . $image->basename;
} elseif (version_compare(\PHP_VERSION, '7.2.0', '>=')) {
// https://www.php.net/manual/en/function.exif-read-data.php#refsect1-function.exif-read-data-changelog
$stream = $image->stream()->detach();
} else {
// https://bugs.php.net/bug.php?id=65187
$stream = $image->encode('data-url')->encoded;
}
$data = @exif_read_data($stream);
if (!is_null($key) && is_array($data)) {
$data = array_key_exists($key, $data) ? $data[$key] : \false;
}
} catch (\Exception $e) {
throw new NotReadableException(sprintf("Cannot read the Exif data from the filename (%s) provided ", $image->dirname . '/' . $image->basename), $e->getCode(), $e);
}
$this->setOutput($data);
return \true;
}
}

View File

@ -0,0 +1,57 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Commands;
use RegularLabs\Scoped\Intervention\Image\Exception\NotSupportedException;
class IptcCommand extends AbstractCommand
{
/**
* Read Iptc data from the given image
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
if (!function_exists('iptcparse')) {
throw new NotSupportedException("Reading Iptc data is not supported by this PHP installation.");
}
$key = $this->argument(0)->value();
$info = [];
@getimagesize($image->dirname . '/' . $image->basename, $info);
$data = [];
if (array_key_exists('APP13', $info)) {
$iptc = iptcparse($info['APP13']);
if (is_array($iptc)) {
$data['DocumentTitle'] = isset($iptc["2#005"][0]) ? $iptc["2#005"][0] : null;
$data['Urgency'] = isset($iptc["2#010"][0]) ? $iptc["2#010"][0] : null;
$data['Category'] = isset($iptc["2#015"][0]) ? $iptc["2#015"][0] : null;
$data['Subcategories'] = isset($iptc["2#020"][0]) ? $iptc["2#020"][0] : null;
$data['Keywords'] = isset($iptc["2#025"][0]) ? $iptc["2#025"] : null;
$data['ReleaseDate'] = isset($iptc["2#030"][0]) ? $iptc["2#030"][0] : null;
$data['ReleaseTime'] = isset($iptc["2#035"][0]) ? $iptc["2#035"][0] : null;
$data['SpecialInstructions'] = isset($iptc["2#040"][0]) ? $iptc["2#040"][0] : null;
$data['CreationDate'] = isset($iptc["2#055"][0]) ? $iptc["2#055"][0] : null;
$data['CreationTime'] = isset($iptc["2#060"][0]) ? $iptc["2#060"][0] : null;
$data['AuthorByline'] = isset($iptc["2#080"][0]) ? $iptc["2#080"][0] : null;
$data['AuthorTitle'] = isset($iptc["2#085"][0]) ? $iptc["2#085"][0] : null;
$data['City'] = isset($iptc["2#090"][0]) ? $iptc["2#090"][0] : null;
$data['SubLocation'] = isset($iptc["2#092"][0]) ? $iptc["2#092"][0] : null;
$data['State'] = isset($iptc["2#095"][0]) ? $iptc["2#095"][0] : null;
$data['Country'] = isset($iptc["2#101"][0]) ? $iptc["2#101"][0] : null;
$data['OTR'] = isset($iptc["2#103"][0]) ? $iptc["2#103"][0] : null;
$data['Headline'] = isset($iptc["2#105"][0]) ? $iptc["2#105"][0] : null;
$data['Source'] = isset($iptc["2#110"][0]) ? $iptc["2#110"][0] : null;
$data['PhotoSource'] = isset($iptc["2#115"][0]) ? $iptc["2#115"][0] : null;
$data['Copyright'] = isset($iptc["2#116"][0]) ? $iptc["2#116"][0] : null;
$data['Caption'] = isset($iptc["2#120"][0]) ? $iptc["2#120"][0] : null;
$data['CaptionWriter'] = isset($iptc["2#122"][0]) ? $iptc["2#122"][0] : null;
}
}
if (!is_null($key) && is_array($data)) {
$data = array_key_exists($key, $data) ? $data[$key] : \false;
}
$this->setOutput($data);
return \true;
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Commands;
use Closure;
class LineCommand extends AbstractCommand
{
/**
* Draws line on given image
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
$x1 = $this->argument(0)->type('numeric')->required()->value();
$y1 = $this->argument(1)->type('numeric')->required()->value();
$x2 = $this->argument(2)->type('numeric')->required()->value();
$y2 = $this->argument(3)->type('numeric')->required()->value();
$callback = $this->argument(4)->type('closure')->value();
$line_classname = sprintf('\RegularLabs\Scoped\Intervention\Image\%s\Shapes\LineShape', $image->getDriver()->getDriverName());
$line = new $line_classname($x2, $y2);
if ($callback instanceof Closure) {
$callback($line);
}
$line->applyToImage($image, $x1, $y1);
return \true;
}
}

View File

@ -0,0 +1,40 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Commands;
class OrientateCommand extends AbstractCommand
{
/**
* Correct image orientation according to Exif data
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
switch ($image->exif('Orientation')) {
case 2:
$image->flip();
break;
case 3:
$image->rotate(180);
break;
case 4:
$image->rotate(180)->flip();
break;
case 5:
$image->rotate(270)->flip();
break;
case 6:
$image->rotate(270);
break;
case 7:
$image->rotate(90)->flip();
break;
case 8:
$image->rotate(90);
break;
}
return \true;
}
}

View File

@ -0,0 +1,35 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Commands;
use Closure;
use RegularLabs\Scoped\Intervention\Image\Exception\InvalidArgumentException;
class PolygonCommand extends AbstractCommand
{
/**
* Draw a polygon on given image
*
* @param \Intervention\Image\image $image
* @return boolean
*/
public function execute($image)
{
$points = $this->argument(0)->type('array')->required()->value();
$callback = $this->argument(1)->type('closure')->value();
$vertices_count = count($points);
// check if number if coordinates is even
if ($vertices_count % 2 !== 0) {
throw new InvalidArgumentException("The number of given polygon vertices must be even.");
}
if ($vertices_count < 6) {
throw new InvalidArgumentException("You must have at least 3 points in your array.");
}
$polygon_classname = sprintf('\RegularLabs\Scoped\Intervention\Image\%s\Shapes\PolygonShape', $image->getDriver()->getDriverName());
$polygon = new $polygon_classname($points);
if ($callback instanceof Closure) {
$callback($polygon);
}
$polygon->applyToImage($image);
return \true;
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Commands;
use RegularLabs\Scoped\GuzzleHttp\Psr7\Response;
class PsrResponseCommand extends AbstractCommand
{
/**
* Builds PSR7 compatible response. May replace "response" command in
* some future.
*
* Method will generate binary stream and put it inside PSR-7
* ResponseInterface. Following code can be optimized using native php
* streams and more "clean" streaming, however drivers has to be updated
* first.
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
$format = $this->argument(0)->value();
$quality = $this->argument(1)->between(0, 100)->value();
//Encoded property will be populated at this moment
$stream = $image->stream($format, $quality);
$mimetype = finfo_buffer(finfo_open(\FILEINFO_MIME_TYPE), $image->getEncoded());
$this->setOutput(new Response(200, ['Content-Type' => $mimetype, 'Content-Length' => strlen($image->getEncoded())], $stream));
return \true;
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Commands;
use Closure;
class RectangleCommand extends AbstractCommand
{
/**
* Draws rectangle on given image
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
$x1 = $this->argument(0)->type('numeric')->required()->value();
$y1 = $this->argument(1)->type('numeric')->required()->value();
$x2 = $this->argument(2)->type('numeric')->required()->value();
$y2 = $this->argument(3)->type('numeric')->required()->value();
$callback = $this->argument(4)->type('closure')->value();
$rectangle_classname = sprintf('\RegularLabs\Scoped\Intervention\Image\%s\Shapes\RectangleShape', $image->getDriver()->getDriverName());
$rectangle = new $rectangle_classname($x1, $y1, $x2, $y2);
if ($callback instanceof Closure) {
$callback($rectangle);
}
$rectangle->applyToImage($image, $x1, $y1);
return \true;
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Commands;
use RegularLabs\Scoped\Intervention\Image\Response;
class ResponseCommand extends AbstractCommand
{
/**
* Builds HTTP response from given image
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
$format = $this->argument(0)->value();
$quality = $this->argument(1)->between(0, 100)->value();
$response = new Response($image, $format, $quality);
$this->setOutput($response->make());
return \true;
}
}

View File

@ -0,0 +1,37 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Commands;
class StreamCommand extends AbstractCommand
{
/**
* Builds PSR7 stream based on image data. Method uses Guzzle PSR7
* implementation as easiest choice.
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
$format = $this->argument(0)->value();
$quality = $this->argument(1)->between(0, 100)->value();
$data = $image->encode($format, $quality)->getEncoded();
$this->setOutput($this->getStream($data));
return \true;
}
/**
* Create stream from given data
*
* @param string $data
* @return \Psr\Http\Message\StreamInterface
*/
protected function getStream($data)
{
if (class_exists(\RegularLabs\Scoped\GuzzleHttp\Psr7\Utils::class)) {
return \RegularLabs\Scoped\GuzzleHttp\Psr7\Utils::streamFor($data);
// guzzlehttp/psr7 >= 2.0
}
return \RegularLabs\Scoped\GuzzleHttp\Psr7\stream_for($data);
// guzzlehttp/psr7 < 2.0
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Commands;
use Closure;
class TextCommand extends AbstractCommand
{
/**
* Write text on given image
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
$text = $this->argument(0)->required()->value();
$x = $this->argument(1)->type('numeric')->value(0);
$y = $this->argument(2)->type('numeric')->value(0);
$callback = $this->argument(3)->type('closure')->value();
$fontclassname = sprintf('\RegularLabs\Scoped\Intervention\Image\%s\Font', $image->getDriver()->getDriverName());
$font = new $fontclassname($text);
if ($callback instanceof Closure) {
$callback($font);
}
$font->applyToImage($image, $x, $y);
return \true;
}
}

View File

@ -0,0 +1,83 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image;
class Constraint
{
/**
* Bit value of aspect ratio constraint
*/
const ASPECTRATIO = 1;
/**
* Bit value of upsize constraint
*/
const UPSIZE = 2;
/**
* Constraint size
*
* @var \Intervention\Image\Size
*/
private $size;
/**
* Integer value of fixed parameters
*
* @var int
*/
private $fixed = 0;
/**
* Create a new constraint based on size
*
* @param Size $size
*/
public function __construct(Size $size)
{
$this->size = $size;
}
/**
* Returns current size of constraint
*
* @return \Intervention\Image\Size
*/
public function getSize()
{
return $this->size;
}
/**
* Fix the given argument in current constraint
*
* @param int $type
* @return void
*/
public function fix($type)
{
$this->fixed = $this->fixed & ~(1 << $type) | 1 << $type;
}
/**
* Checks if given argument is fixed in current constraint
*
* @param int $type
* @return boolean
*/
public function isFixed($type)
{
return (bool) ($this->fixed & 1 << $type);
}
/**
* Fixes aspect ratio in current constraint
*
* @return void
*/
public function aspectRatio()
{
$this->fix(self::ASPECTRATIO);
}
/**
* Fixes possibility to size up in current constraint
*
* @return void
*/
public function upsize()
{
$this->fix(self::UPSIZE);
}
}

View File

@ -0,0 +1,8 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Exception;
class ImageException extends \RuntimeException
{
# nothing to override
}

View File

@ -0,0 +1,8 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Exception;
class InvalidArgumentException extends ImageException
{
# nothing to override
}

View File

@ -0,0 +1,8 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Exception;
class MissingDependencyException extends ImageException
{
# nothing to override
}

View File

@ -0,0 +1,8 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Exception;
class NotFoundException extends ImageException
{
# nothing to override
}

View File

@ -0,0 +1,8 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Exception;
class NotReadableException extends ImageException
{
# nothing to override
}

View File

@ -0,0 +1,8 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Exception;
class NotSupportedException extends ImageException
{
# nothing to override
}

View File

@ -0,0 +1,8 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Exception;
class NotWritableException extends ImageException
{
# nothing to override
}

View File

@ -0,0 +1,8 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Exception;
class RuntimeException extends ImageException
{
# nothing to override
}

View File

@ -0,0 +1,18 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Facades;
use RegularLabs\Scoped\Illuminate\Support\Facades\Facade;
/**
* @method static \Intervention\Image\Image make(mixed $data)
* @method static self configure(array $config)
* @method static \Intervention\Image\Image canvas(int $width, int $height, mixed $background = null)
* @method static \Intervention\Image\Image cache(\Closure $callback, int $lifetime = null, boolean $returnObj = false)
*/
class Image extends Facade
{
protected static function getFacadeAccessor()
{
return 'image';
}
}

View File

@ -0,0 +1,79 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image;
class File
{
/**
* Mime type
*
* @var string
*/
public $mime;
/**
* Name of directory path
*
* @var string
*/
public $dirname;
/**
* Basename of current file
*
* @var string
*/
public $basename;
/**
* File extension of current file
*
* @var string
*/
public $extension;
/**
* File name of current file
*
* @var string
*/
public $filename;
/**
* Sets all instance properties from given path
*
* @param string $path
*/
public function setFileInfoFromPath($path)
{
$info = pathinfo($path);
$this->dirname = array_key_exists('dirname', $info) ? $info['dirname'] : null;
$this->basename = array_key_exists('basename', $info) ? $info['basename'] : null;
$this->extension = array_key_exists('extension', $info) ? $info['extension'] : null;
$this->filename = array_key_exists('filename', $info) ? $info['filename'] : null;
if (file_exists($path) && is_file($path)) {
$this->mime = finfo_file(finfo_open(\FILEINFO_MIME_TYPE), $path);
}
return $this;
}
/**
* Get file size
*
* @return mixed
*/
public function filesize()
{
$path = $this->basePath();
if (file_exists($path) && is_file($path)) {
return filesize($path);
}
return \false;
}
/**
* Get fully qualified path
*
* @return string
*/
public function basePath()
{
if ($this->dirname && $this->basename) {
return $this->dirname . '/' . $this->basename;
}
return null;
}
}

View File

@ -0,0 +1,39 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Filters;
use RegularLabs\Scoped\Intervention\Image\Image;
class DemoFilter implements FilterInterface
{
/**
* Default size of filter effects
*/
const DEFAULT_SIZE = 10;
/**
* Size of filter effects
*
* @var int
*/
private $size;
/**
* Creates new instance of filter
*
* @param int $size
*/
public function __construct($size = null)
{
$this->size = is_numeric($size) ? intval($size) : self::DEFAULT_SIZE;
}
/**
* Applies filter effects to given image
*
* @param \Intervention\Image\Image $image
* @return \Intervention\Image\Image
*/
public function applyFilter(Image $image)
{
$image->pixelate($this->size);
$image->greyscale();
return $image;
}
}

View File

@ -0,0 +1,15 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Filters;
use RegularLabs\Scoped\Intervention\Image\Image;
interface FilterInterface
{
/**
* Applies filter to given image
*
* @param \Intervention\Image\Image $image
* @return \Intervention\Image\Image
*/
public function applyFilter(Image $image);
}

View File

@ -0,0 +1,189 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Gd;
use RegularLabs\Scoped\Intervention\Image\AbstractColor;
use RegularLabs\Scoped\Intervention\Image\Exception\NotSupportedException;
class Color extends AbstractColor
{
/**
* RGB Red value of current color instance
*
* @var int
*/
public $r;
/**
* RGB Green value of current color instance
*
* @var int
*/
public $g;
/**
* RGB Blue value of current color instance
*
* @var int
*/
public $b;
/**
* RGB Alpha value of current color instance
*
* @var float
*/
public $a;
/**
* Initiates color object from integer
*
* @param int $value
* @return \Intervention\Image\AbstractColor
*/
public function initFromInteger($value)
{
$this->a = $value >> 24 & 0xff;
$this->r = $value >> 16 & 0xff;
$this->g = $value >> 8 & 0xff;
$this->b = $value & 0xff;
}
/**
* Initiates color object from given array
*
* @param array $value
* @return \Intervention\Image\AbstractColor
*/
public function initFromArray($array)
{
$array = array_values($array);
if (count($array) == 4) {
// color array with alpha value
list($r, $g, $b, $a) = $array;
$this->a = $this->alpha2gd($a);
} elseif (count($array) == 3) {
// color array without alpha value
list($r, $g, $b) = $array;
$this->a = 0;
}
$this->r = $r;
$this->g = $g;
$this->b = $b;
}
/**
* Initiates color object from given string
*
* @param string $value
* @return \Intervention\Image\AbstractColor
*/
public function initFromString($value)
{
if ($color = $this->rgbaFromString($value)) {
$this->r = $color[0];
$this->g = $color[1];
$this->b = $color[2];
$this->a = $this->alpha2gd($color[3]);
}
}
/**
* Initiates color object from given R, G and B values
*
* @param int $r
* @param int $g
* @param int $b
* @return \Intervention\Image\AbstractColor
*/
public function initFromRgb($r, $g, $b)
{
$this->r = intval($r);
$this->g = intval($g);
$this->b = intval($b);
$this->a = 0;
}
/**
* Initiates color object from given R, G, B and A values
*
* @param int $r
* @param int $g
* @param int $b
* @param float $a
* @return \Intervention\Image\AbstractColor
*/
public function initFromRgba($r, $g, $b, $a = 1)
{
$this->r = intval($r);
$this->g = intval($g);
$this->b = intval($b);
$this->a = $this->alpha2gd($a);
}
/**
* Initiates color object from given ImagickPixel object
*
* @param ImagickPixel $value
* @return \Intervention\Image\AbstractColor
*/
public function initFromObject($value)
{
throw new NotSupportedException("GD colors cannot init from ImagickPixel objects.");
}
/**
* Calculates integer value of current color instance
*
* @return int
*/
public function getInt()
{
return ($this->a << 24) + ($this->r << 16) + ($this->g << 8) + $this->b;
}
/**
* Calculates hexadecimal value of current color instance
*
* @param string $prefix
* @return string
*/
public function getHex($prefix = '')
{
return sprintf('%s%02x%02x%02x', $prefix, $this->r, $this->g, $this->b);
}
/**
* Calculates RGB(A) in array format of current color instance
*
* @return array
*/
public function getArray()
{
return [$this->r, $this->g, $this->b, round(1 - $this->a / 127, 2)];
}
/**
* Calculates RGBA in string format of current color instance
*
* @return string
*/
public function getRgba()
{
return sprintf('rgba(%d, %d, %d, %.2F)', $this->r, $this->g, $this->b, round(1 - $this->a / 127, 2));
}
/**
* Determines if current color is different from given color
*
* @param AbstractColor $color
* @param int $tolerance
* @return boolean
*/
public function differs(AbstractColor $color, $tolerance = 0)
{
$color_tolerance = round($tolerance * 2.55);
$alpha_tolerance = round($tolerance * 1.27);
$delta = ['r' => abs($color->r - $this->r), 'g' => abs($color->g - $this->g), 'b' => abs($color->b - $this->b), 'a' => abs($color->a - $this->a)];
return $delta['r'] > $color_tolerance or $delta['g'] > $color_tolerance or $delta['b'] > $color_tolerance or $delta['a'] > $alpha_tolerance;
}
/**
* Convert rgba alpha (0-1) value to gd value (0-127)
*
* @param float $input
* @return int
*/
private function alpha2gd($input)
{
$oldMin = 0;
$oldMax = 1;
$newMin = 127;
$newMax = 0;
return ceil(($input - $oldMin) * ($newMax - $newMin) / ($oldMax - $oldMin) + $newMin);
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Gd\Commands;
use RegularLabs\Scoped\Intervention\Image\Commands\AbstractCommand;
class BackupCommand extends AbstractCommand
{
/**
* Saves a backups of current state of image core
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
$backupName = $this->argument(0)->value();
// clone current image resource
$clone = clone $image;
$image->setBackup($clone->getCore(), $backupName);
return \true;
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Gd\Commands;
use RegularLabs\Scoped\Intervention\Image\Commands\AbstractCommand;
class BlurCommand extends AbstractCommand
{
/**
* Applies blur effect on image
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
$amount = $this->argument(0)->between(0, 100)->value(1);
for ($i = 0; $i < intval($amount); $i++) {
imagefilter($image->getCore(), \IMG_FILTER_GAUSSIAN_BLUR);
}
return \true;
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Gd\Commands;
use RegularLabs\Scoped\Intervention\Image\Commands\AbstractCommand;
class BrightnessCommand extends AbstractCommand
{
/**
* Changes image brightness
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
$level = $this->argument(0)->between(-100, 100)->required()->value();
return imagefilter($image->getCore(), \IMG_FILTER_BRIGHTNESS, $level * 2.55);
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Gd\Commands;
use RegularLabs\Scoped\Intervention\Image\Commands\AbstractCommand;
class ColorizeCommand extends AbstractCommand
{
/**
* Changes balance of different RGB color channels
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
$red = $this->argument(0)->between(-100, 100)->required()->value();
$green = $this->argument(1)->between(-100, 100)->required()->value();
$blue = $this->argument(2)->between(-100, 100)->required()->value();
// normalize colorize levels
$red = round($red * 2.55);
$green = round($green * 2.55);
$blue = round($blue * 2.55);
// apply filter
return imagefilter($image->getCore(), \IMG_FILTER_COLORIZE, $red, $green, $blue);
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Gd\Commands;
use RegularLabs\Scoped\Intervention\Image\Commands\AbstractCommand;
class ContrastCommand extends AbstractCommand
{
/**
* Changes contrast of image
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
$level = $this->argument(0)->between(-100, 100)->required()->value();
return imagefilter($image->getCore(), \IMG_FILTER_CONTRAST, $level * -1);
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Gd\Commands;
use RegularLabs\Scoped\Intervention\Image\Point;
use RegularLabs\Scoped\Intervention\Image\Size;
class CropCommand extends ResizeCommand
{
/**
* Crop an image instance
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
$width = $this->argument(0)->type('digit')->required()->value();
$height = $this->argument(1)->type('digit')->required()->value();
$x = $this->argument(2)->type('digit')->value();
$y = $this->argument(3)->type('digit')->value();
if (is_null($width) || is_null($height)) {
throw new \RegularLabs\Scoped\Intervention\Image\Exception\InvalidArgumentException("Width and height of cutout needs to be defined.");
}
$cropped = new Size($width, $height);
$position = new Point($x, $y);
// align boxes
if (is_null($x) && is_null($y)) {
$position = $image->getSize()->align('center')->relativePosition($cropped->align('center'));
}
// crop image core
return $this->modify($image, 0, 0, $position->x, $position->y, $cropped->width, $cropped->height, $cropped->width, $cropped->height);
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Gd\Commands;
use RegularLabs\Scoped\Intervention\Image\Commands\AbstractCommand;
class DestroyCommand extends AbstractCommand
{
/**
* Destroys current image core and frees up memory
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
// destroy image core
imagedestroy($image->getCore());
// destroy backups
foreach ($image->getBackups() as $backup) {
imagedestroy($backup);
}
return \true;
}
}

View File

@ -0,0 +1,54 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Gd\Commands;
use RegularLabs\Scoped\Intervention\Image\Commands\AbstractCommand;
use RegularLabs\Scoped\Intervention\Image\Gd\Color;
use RegularLabs\Scoped\Intervention\Image\Gd\Decoder;
class FillCommand extends AbstractCommand
{
/**
* Fills image with color or pattern
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
$filling = $this->argument(0)->value();
$x = $this->argument(1)->type('digit')->value();
$y = $this->argument(2)->type('digit')->value();
$width = $image->getWidth();
$height = $image->getHeight();
$resource = $image->getCore();
try {
// set image tile filling
$source = new Decoder();
$tile = $source->init($filling);
imagesettile($image->getCore(), $tile->getCore());
$filling = \IMG_COLOR_TILED;
} catch (\RegularLabs\Scoped\Intervention\Image\Exception\NotReadableException $e) {
// set solid color filling
$color = new Color($filling);
$filling = $color->getInt();
}
imagealphablending($resource, \true);
if (is_int($x) && is_int($y)) {
// resource should be visible through transparency
$base = $image->getDriver()->newImage($width, $height)->getCore();
imagecopy($base, $resource, 0, 0, 0, 0, $width, $height);
// floodfill if exact position is defined
imagefill($resource, $x, $y, $filling);
// copy filled original over base
imagecopy($base, $resource, 0, 0, 0, 0, $width, $height);
// set base as new resource-core
$image->setCore($base);
imagedestroy($resource);
} else {
// fill whole image otherwise
imagefilledrectangle($resource, 0, 0, $width - 1, $height - 1, $filling);
}
isset($tile) ? imagedestroy($tile->getCore()) : null;
return \true;
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Gd\Commands;
use RegularLabs\Scoped\Intervention\Image\Size;
class FitCommand extends ResizeCommand
{
/**
* Crops and resized an image at the same time
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
$width = $this->argument(0)->type('digit')->required()->value();
$height = $this->argument(1)->type('digit')->value($width);
$constraints = $this->argument(2)->type('closure')->value();
$position = $this->argument(3)->type('string')->value('center');
// calculate size
$cropped = $image->getSize()->fit(new Size($width, $height), $position);
$resized = clone $cropped;
$resized = $resized->resize($width, $height, $constraints);
// modify image
$this->modify($image, 0, 0, $cropped->pivot->x, $cropped->pivot->y, $resized->getWidth(), $resized->getHeight(), $cropped->getWidth(), $cropped->getHeight());
return \true;
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Gd\Commands;
class FlipCommand extends ResizeCommand
{
/**
* Mirrors an image
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
$mode = $this->argument(0)->value('h');
$size = $image->getSize();
$dst = clone $size;
switch (strtolower($mode)) {
case 2:
case 'v':
case 'vert':
case 'vertical':
$size->pivot->y = $size->height - 1;
$size->height = $size->height * -1;
break;
default:
$size->pivot->x = $size->width - 1;
$size->width = $size->width * -1;
break;
}
return $this->modify($image, 0, 0, $size->pivot->x, $size->pivot->y, $dst->width, $dst->height, $size->width, $size->height);
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Gd\Commands;
use RegularLabs\Scoped\Intervention\Image\Commands\AbstractCommand;
class GammaCommand extends AbstractCommand
{
/**
* Applies gamma correction to a given image
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
$gamma = $this->argument(0)->type('numeric')->required()->value();
return imagegammacorrect($image->getCore(), 1, $gamma);
}
}

View File

@ -0,0 +1,20 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Gd\Commands;
use RegularLabs\Scoped\Intervention\Image\Commands\AbstractCommand;
use RegularLabs\Scoped\Intervention\Image\Size;
class GetSizeCommand extends AbstractCommand
{
/**
* Reads size of given image instance in pixels
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
$this->setOutput(new Size(imagesx($image->getCore()), imagesy($image->getCore())));
return \true;
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Gd\Commands;
use RegularLabs\Scoped\Intervention\Image\Commands\AbstractCommand;
class GreyscaleCommand extends AbstractCommand
{
/**
* Turns an image into a greyscale version
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
return imagefilter($image->getCore(), \IMG_FILTER_GRAYSCALE);
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace RegularLabs\Scoped\Intervention\Image\Gd\Commands;
class HeightenCommand extends ResizeCommand
{
/**
* Resize image proportionally to given height
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
$height = $this->argument(0)->type('digit')->required()->value();
$additionalConstraints = $this->argument(1)->type('closure')->value();
$this->arguments[0] = null;
$this->arguments[1] = $height;
$this->arguments[2] = function ($constraint) use ($additionalConstraints) {
$constraint->aspectRatio();
if (is_callable($additionalConstraints)) {
$additionalConstraints($constraint);
}
};
return parent::execute($image);
}
}

Some files were not shown because too many files have changed in this diff Show More