home/mip/mip/vendor/symfony/translation/Resources/functions.php 0000644 00000001063 15152066260 0021103 0 ustar 00 <?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation;
if (!\function_exists(t::class)) {
/**
* @author Nate Wiebe <nate@northern.co>
*/
function t(string $message, array $parameters = [], ?string $domain = null): TranslatableMessage
{
return new TranslatableMessage($message, $parameters, $domain);
}
}
home/mip/mip/vendor/aws/aws-sdk-php/src/functions.php 0000644 00000036332 15152066306 0016616 0 ustar 00 <?php
namespace Aws;
use GuzzleHttp\Client;
use Psr\Http\Message\RequestInterface;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Promise\FulfilledPromise;
//-----------------------------------------------------------------------------
// Functional functions
//-----------------------------------------------------------------------------
/**
* Returns a function that always returns the same value;
*
* @param mixed $value Value to return.
*
* @return callable
*/
function constantly($value)
{
return function () use ($value) { return $value; };
}
/**
* Filters values that do not satisfy the predicate function $pred.
*
* @param mixed $iterable Iterable sequence of data.
* @param callable $pred Function that accepts a value and returns true/false
*
* @return \Generator
*/
function filter($iterable, callable $pred)
{
foreach ($iterable as $value) {
if ($pred($value)) {
yield $value;
}
}
}
/**
* Applies a map function $f to each value in a collection.
*
* @param mixed $iterable Iterable sequence of data.
* @param callable $f Map function to apply.
*
* @return \Generator
*/
function map($iterable, callable $f)
{
foreach ($iterable as $value) {
yield $f($value);
}
}
/**
* Creates a generator that iterates over a sequence, then iterates over each
* value in the sequence and yields the application of the map function to each
* value.
*
* @param mixed $iterable Iterable sequence of data.
* @param callable $f Map function to apply.
*
* @return \Generator
*/
function flatmap($iterable, callable $f)
{
foreach (map($iterable, $f) as $outer) {
foreach ($outer as $inner) {
yield $inner;
}
}
}
/**
* Partitions the input sequence into partitions of the specified size.
*
* @param mixed $iterable Iterable sequence of data.
* @param int $size Size to make each partition (except possibly the last chunk)
*
* @return \Generator
*/
function partition($iterable, $size)
{
$buffer = [];
foreach ($iterable as $value) {
$buffer[] = $value;
if (count($buffer) === $size) {
yield $buffer;
$buffer = [];
}
}
if ($buffer) {
yield $buffer;
}
}
/**
* Returns a function that invokes the provided variadic functions one
* after the other until one of the functions returns a non-null value.
* The return function will call each passed function with any arguments it
* is provided.
*
* $a = function ($x, $y) { return null; };
* $b = function ($x, $y) { return $x + $y; };
* $fn = \Aws\or_chain($a, $b);
* echo $fn(1, 2); // 3
*
* @return callable
*/
function or_chain()
{
$fns = func_get_args();
return function () use ($fns) {
$args = func_get_args();
foreach ($fns as $fn) {
$result = $args ? call_user_func_array($fn, $args) : $fn();
if ($result) {
return $result;
}
}
return null;
};
}
//-----------------------------------------------------------------------------
// JSON compiler and loading functions
//-----------------------------------------------------------------------------
/**
* Loads a compiled JSON file from a PHP file.
*
* If the JSON file has not been cached to disk as a PHP file, it will be loaded
* from the JSON source file and returned.
*
* @param string $path Path to the JSON file on disk
*
* @return mixed Returns the JSON decoded data. Note that JSON objects are
* decoded as associative arrays.
*/
function load_compiled_json($path)
{
static $compiledList = [];
$compiledFilepath = "{$path}.php";
if (!isset($compiledList[$compiledFilepath])) {
if (is_readable($compiledFilepath)) {
$compiledList[$compiledFilepath] = include($compiledFilepath);
}
}
if (isset($compiledList[$compiledFilepath])) {
return $compiledList[$compiledFilepath];
}
if (!file_exists($path)) {
throw new \InvalidArgumentException(
sprintf("File not found: %s", $path)
);
}
return json_decode(file_get_contents($path), true);
}
/**
* No-op
*/
function clear_compiled_json()
{
// pass
}
//-----------------------------------------------------------------------------
// Directory iterator functions.
//-----------------------------------------------------------------------------
/**
* Iterates over the files in a directory and works with custom wrappers.
*
* @param string $path Path to open (e.g., "s3://foo/bar").
* @param resource $context Stream wrapper context.
*
* @return \Generator Yields relative filename strings.
*/
function dir_iterator($path, $context = null)
{
$dh = $context ? opendir($path, $context) : opendir($path);
if (!$dh) {
throw new \InvalidArgumentException('File not found: ' . $path);
}
while (($file = readdir($dh)) !== false) {
yield $file;
}
closedir($dh);
}
/**
* Returns a recursive directory iterator that yields absolute filenames.
*
* This iterator is not broken like PHP's built-in DirectoryIterator (which
* will read the first file from a stream wrapper, then rewind, then read
* it again).
*
* @param string $path Path to traverse (e.g., s3://bucket/key, /tmp)
* @param resource $context Stream context options.
*
* @return \Generator Yields absolute filenames.
*/
function recursive_dir_iterator($path, $context = null)
{
$invalid = ['.' => true, '..' => true];
$pathLen = strlen($path) + 1;
$iterator = dir_iterator($path, $context);
$queue = [];
do {
while ($iterator->valid()) {
$file = $iterator->current();
$iterator->next();
if (isset($invalid[basename($file)])) {
continue;
}
$fullPath = "{$path}/{$file}";
yield $fullPath;
if (is_dir($fullPath)) {
$queue[] = $iterator;
$iterator = map(
dir_iterator($fullPath, $context),
function ($file) use ($fullPath, $pathLen) {
return substr("{$fullPath}/{$file}", $pathLen);
}
);
continue;
}
}
$iterator = array_pop($queue);
} while ($iterator);
}
//-----------------------------------------------------------------------------
// Misc. functions.
//-----------------------------------------------------------------------------
/**
* Debug function used to describe the provided value type and class.
*
* @param mixed $input
*
* @return string Returns a string containing the type of the variable and
* if a class is provided, the class name.
*/
function describe_type($input)
{
switch (gettype($input)) {
case 'object':
return 'object(' . get_class($input) . ')';
case 'array':
return 'array(' . count($input) . ')';
default:
ob_start();
var_dump($input);
// normalize float vs double
return str_replace('double(', 'float(', rtrim(ob_get_clean()));
}
}
/**
* Creates a default HTTP handler based on the available clients.
*
* @return callable
*/
function default_http_handler()
{
$version = guzzle_major_version();
// If Guzzle 6 or 7 installed
if ($version === 6 || $version === 7) {
return new \Aws\Handler\GuzzleV6\GuzzleHandler();
}
// If Guzzle 5 installed
if ($version === 5) {
return new \Aws\Handler\GuzzleV5\GuzzleHandler();
}
throw new \RuntimeException('Unknown Guzzle version: ' . $version);
}
/**
* Gets the default user agent string depending on the Guzzle version
*
* @return string
*/
function default_user_agent()
{
$version = guzzle_major_version();
// If Guzzle 6 or 7 installed
if ($version === 6 || $version === 7) {
return \GuzzleHttp\default_user_agent();
}
// If Guzzle 5 installed
if ($version === 5) {
return \GuzzleHttp\Client::getDefaultUserAgent();
}
throw new \RuntimeException('Unknown Guzzle version: ' . $version);
}
/**
* Get the major version of guzzle that is installed.
*
* @internal This function is internal and should not be used outside aws/aws-sdk-php.
* @return int
* @throws \RuntimeException
*/
function guzzle_major_version()
{
static $cache = null;
if (null !== $cache) {
return $cache;
}
if (defined('\GuzzleHttp\ClientInterface::VERSION')) {
$version = (string) ClientInterface::VERSION;
if ($version[0] === '6') {
return $cache = 6;
}
if ($version[0] === '5') {
return $cache = 5;
}
} elseif (defined('\GuzzleHttp\ClientInterface::MAJOR_VERSION')) {
return $cache = ClientInterface::MAJOR_VERSION;
}
throw new \RuntimeException('Unable to determine what Guzzle version is installed.');
}
/**
* Serialize a request for a command but do not send it.
*
* Returns a promise that is fulfilled with the serialized request.
*
* @param CommandInterface $command Command to serialize.
*
* @return RequestInterface
* @throws \RuntimeException
*/
function serialize(CommandInterface $command)
{
$request = null;
$handlerList = $command->getHandlerList();
// Return a mock result.
$handlerList->setHandler(
function (CommandInterface $_, RequestInterface $r) use (&$request) {
$request = $r;
return new FulfilledPromise(new Result([]));
}
);
call_user_func($handlerList->resolve(), $command)->wait();
if (!$request instanceof RequestInterface) {
throw new \RuntimeException(
'Calling handler did not serialize request'
);
}
return $request;
}
/**
* Retrieves data for a service from the SDK's service manifest file.
*
* Manifest data is stored statically, so it does not need to be loaded more
* than once per process. The JSON data is also cached in opcache.
*
* @param string $service Case-insensitive namespace or endpoint prefix of the
* service for which you are retrieving manifest data.
*
* @return array
* @throws \InvalidArgumentException if the service is not supported.
*/
function manifest($service = null)
{
// Load the manifest and create aliases for lowercased namespaces
static $manifest = [];
static $aliases = [];
if (empty($manifest)) {
$manifest = load_compiled_json(__DIR__ . '/data/manifest.json');
foreach ($manifest as $endpoint => $info) {
$alias = strtolower($info['namespace']);
if ($alias !== $endpoint) {
$aliases[$alias] = $endpoint;
}
}
}
// If no service specified, then return the whole manifest.
if ($service === null) {
return $manifest;
}
// Look up the service's info in the manifest data.
$service = strtolower($service);
if (isset($manifest[$service])) {
return $manifest[$service] + ['endpoint' => $service];
}
if (isset($aliases[$service])) {
return manifest($aliases[$service]);
}
throw new \InvalidArgumentException(
"The service \"{$service}\" is not provided by the AWS SDK for PHP."
);
}
/**
* Checks if supplied parameter is a valid hostname
*
* @param string $hostname
* @return bool
*/
function is_valid_hostname($hostname)
{
return (
preg_match("/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*\.?$/i", $hostname)
&& preg_match("/^.{1,253}$/", $hostname)
&& preg_match("/^[^\.]{1,63}(\.[^\.]{0,63})*$/", $hostname)
);
}
/**
* Checks if supplied parameter is a valid host label
*
* @param $label
* @return bool
*/
function is_valid_hostlabel($label)
{
return preg_match("/^(?!-)[a-zA-Z0-9-]{1,63}(?<!-)$/", $label);
}
/**
* Ignores '#' full line comments, which parse_ini_file no longer does
* in PHP 7+.
*
* @param $filename
* @param bool $process_sections
* @param int $scanner_mode
* @return array|bool
*/
function parse_ini_file(
$filename,
$process_sections = false,
$scanner_mode = INI_SCANNER_NORMAL)
{
return parse_ini_string(
preg_replace('/^#.*\\n/m', "", file_get_contents($filename)),
$process_sections,
$scanner_mode
);
}
/**
* Outputs boolean value of input for a select range of possible values,
* null otherwise
*
* @param $input
* @return bool|null
*/
function boolean_value($input)
{
if (is_bool($input)) {
return $input;
}
if ($input === 0) {
return false;
}
if ($input === 1) {
return true;
}
if (is_string($input)) {
switch (strtolower($input)) {
case "true":
case "on":
case "1":
return true;
break;
case "false":
case "off":
case "0":
return false;
break;
}
}
return null;
}
/**
* Parses ini sections with subsections (i.e. the service section)
*
* @param $filename
* @param $filename
* @return array
*/
function parse_ini_section_with_subsections($filename, $section_name) {
$config = [];
$stream = fopen($filename, 'r');
if (!$stream) {
return $config;
}
$current_subsection = '';
while (!feof($stream)) {
$line = trim(fgets($stream));
if (empty($line) || in_array($line[0], [';', '#'])) {
continue;
}
if (preg_match('/^\[.*\]$/', $line)
&& trim($line, '[]') === $section_name)
{
while (!feof($stream)) {
$line = trim(fgets($stream));
if (empty($line) || in_array($line[0], [';', '#'])) {
continue;
}
if (preg_match('/^\[.*\]$/', $line)
&& trim($line, '[]') === $section_name)
{
continue;
} elseif (strpos($line, '[') === 0) {
break;
}
if (strpos($line, ' = ') !== false) {
list($key, $value) = explode(' = ', $line, 2);
if (empty($current_subsection)) {
$config[$key] = $value;
} else {
$config[$current_subsection][$key] = $value;
}
} else {
$current_subsection = trim(str_replace('=', '', $line));
$config[$current_subsection] = [];
}
}
}
}
fclose($stream);
return $config;
}
/**
* Checks if an input is a valid epoch time
*
* @param $input
* @return bool
*/
function is_valid_epoch($input)
{
if (is_string($input) || is_numeric($input)) {
if (is_string($input) && !preg_match("/^-?[0-9]+\.?[0-9]*$/", $input)) {
return false;
}
return true;
}
return false;
}
/**
* Checks if an input is a fips pseudo region
*
* @param $region
* @return bool
*/
function is_fips_pseudo_region($region)
{
return strpos($region, 'fips-') !== false || strpos($region, '-fips') !== false;
}
/**
* Returns a region without a fips label
*
* @param $region
* @return string
*/
function strip_fips_pseudo_regions($region)
{
return str_replace(['fips-', '-fips'], ['', ''], $region);
}
home/mip/mip/vendor/guzzlehttp/guzzle/src/functions.php 0000644 00000013070 15152066523 0017421 0 ustar 00 <?php
namespace GuzzleHttp;
/**
* Debug function used to describe the provided value type and class.
*
* @param mixed $input Any type of variable to describe the type of. This
* parameter misses a typehint because of that.
*
* @return string Returns a string containing the type of the variable and
* if a class is provided, the class name.
*
* @deprecated describe_type will be removed in guzzlehttp/guzzle:8.0. Use Utils::describeType instead.
*/
function describe_type($input): string
{
return Utils::describeType($input);
}
/**
* Parses an array of header lines into an associative array of headers.
*
* @param iterable $lines Header lines array of strings in the following
* format: "Name: Value"
*
* @deprecated headers_from_lines will be removed in guzzlehttp/guzzle:8.0. Use Utils::headersFromLines instead.
*/
function headers_from_lines(iterable $lines): array
{
return Utils::headersFromLines($lines);
}
/**
* Returns a debug stream based on the provided variable.
*
* @param mixed $value Optional value
*
* @return resource
*
* @deprecated debug_resource will be removed in guzzlehttp/guzzle:8.0. Use Utils::debugResource instead.
*/
function debug_resource($value = null)
{
return Utils::debugResource($value);
}
/**
* Chooses and creates a default handler to use based on the environment.
*
* The returned handler is not wrapped by any default middlewares.
*
* @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the best handler for the given system.
*
* @throws \RuntimeException if no viable Handler is available.
*
* @deprecated choose_handler will be removed in guzzlehttp/guzzle:8.0. Use Utils::chooseHandler instead.
*/
function choose_handler(): callable
{
return Utils::chooseHandler();
}
/**
* Get the default User-Agent string to use with Guzzle.
*
* @deprecated default_user_agent will be removed in guzzlehttp/guzzle:8.0. Use Utils::defaultUserAgent instead.
*/
function default_user_agent(): string
{
return Utils::defaultUserAgent();
}
/**
* Returns the default cacert bundle for the current system.
*
* First, the openssl.cafile and curl.cainfo php.ini settings are checked.
* If those settings are not configured, then the common locations for
* bundles found on Red Hat, CentOS, Fedora, Ubuntu, Debian, FreeBSD, OS X
* and Windows are checked. If any of these file locations are found on
* disk, they will be utilized.
*
* Note: the result of this function is cached for subsequent calls.
*
* @throws \RuntimeException if no bundle can be found.
*
* @deprecated default_ca_bundle will be removed in guzzlehttp/guzzle:8.0. This function is not needed in PHP 5.6+.
*/
function default_ca_bundle(): string
{
return Utils::defaultCaBundle();
}
/**
* Creates an associative array of lowercase header names to the actual
* header casing.
*
* @deprecated normalize_header_keys will be removed in guzzlehttp/guzzle:8.0. Use Utils::normalizeHeaderKeys instead.
*/
function normalize_header_keys(array $headers): array
{
return Utils::normalizeHeaderKeys($headers);
}
/**
* Returns true if the provided host matches any of the no proxy areas.
*
* This method will strip a port from the host if it is present. Each pattern
* can be matched with an exact match (e.g., "foo.com" == "foo.com") or a
* partial match: (e.g., "foo.com" == "baz.foo.com" and ".foo.com" ==
* "baz.foo.com", but ".foo.com" != "foo.com").
*
* Areas are matched in the following cases:
* 1. "*" (without quotes) always matches any hosts.
* 2. An exact match.
* 3. The area starts with "." and the area is the last part of the host. e.g.
* '.mit.edu' will match any host that ends with '.mit.edu'.
*
* @param string $host Host to check against the patterns.
* @param string[] $noProxyArray An array of host patterns.
*
* @throws Exception\InvalidArgumentException
*
* @deprecated is_host_in_noproxy will be removed in guzzlehttp/guzzle:8.0. Use Utils::isHostInNoProxy instead.
*/
function is_host_in_noproxy(string $host, array $noProxyArray): bool
{
return Utils::isHostInNoProxy($host, $noProxyArray);
}
/**
* Wrapper for json_decode that throws when an error occurs.
*
* @param string $json JSON data to parse
* @param bool $assoc When true, returned objects will be converted
* into associative arrays.
* @param int $depth User specified recursion depth.
* @param int $options Bitmask of JSON decode options.
*
* @return object|array|string|int|float|bool|null
*
* @throws Exception\InvalidArgumentException if the JSON cannot be decoded.
*
* @see https://www.php.net/manual/en/function.json-decode.php
* @deprecated json_decode will be removed in guzzlehttp/guzzle:8.0. Use Utils::jsonDecode instead.
*/
function json_decode(string $json, bool $assoc = false, int $depth = 512, int $options = 0)
{
return Utils::jsonDecode($json, $assoc, $depth, $options);
}
/**
* Wrapper for JSON encoding that throws when an error occurs.
*
* @param mixed $value The value being encoded
* @param int $options JSON encode option bitmask
* @param int $depth Set the maximum depth. Must be greater than zero.
*
* @throws Exception\InvalidArgumentException if the JSON cannot be encoded.
*
* @see https://www.php.net/manual/en/function.json-encode.php
* @deprecated json_encode will be removed in guzzlehttp/guzzle:8.0. Use Utils::jsonEncode instead.
*/
function json_encode($value, int $options = 0, int $depth = 512): string
{
return Utils::jsonEncode($value, $options, $depth);
}
home/mip/mip/vendor/ramsey/uuid/src/functions.php 0000644 00000012033 15152100553 0016115 0 ustar 00 <?php
/**
* This file is part of the ramsey/uuid library
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
* @license http://opensource.org/licenses/MIT MIT
* phpcs:disable Squiz.Functions.GlobalFunction
*/
declare(strict_types=1);
namespace Ramsey\Uuid;
use DateTimeInterface;
use Ramsey\Uuid\Type\Hexadecimal;
use Ramsey\Uuid\Type\Integer as IntegerObject;
/**
* Returns a version 1 (Gregorian time) UUID from a host ID, sequence number,
* and the current time
*
* @param Hexadecimal|int|string|null $node A 48-bit number representing the
* hardware address; this number may be represented as an integer or a
* hexadecimal string
* @param int|null $clockSeq A 14-bit number used to help avoid duplicates that
* could arise when the clock is set backwards in time or if the node ID
* changes
*
* @return non-empty-string Version 1 UUID as a string
*/
function v1($node = null, ?int $clockSeq = null): string
{
return Uuid::uuid1($node, $clockSeq)->toString();
}
/**
* Returns a version 2 (DCE Security) UUID from a local domain, local
* identifier, host ID, clock sequence, and the current time
*
* @param int $localDomain The local domain to use when generating bytes,
* according to DCE Security
* @param IntegerObject|null $localIdentifier The local identifier for the
* given domain; this may be a UID or GID on POSIX systems, if the local
* domain is person or group, or it may be a site-defined identifier
* if the local domain is org
* @param Hexadecimal|null $node A 48-bit number representing the hardware
* address
* @param int|null $clockSeq A 14-bit number used to help avoid duplicates
* that could arise when the clock is set backwards in time or if the
* node ID changes
*
* @return non-empty-string Version 2 UUID as a string
*/
function v2(
int $localDomain,
?IntegerObject $localIdentifier = null,
?Hexadecimal $node = null,
?int $clockSeq = null
): string {
return Uuid::uuid2($localDomain, $localIdentifier, $node, $clockSeq)->toString();
}
/**
* Returns a version 3 (name-based) UUID based on the MD5 hash of a
* namespace ID and a name
*
* @param string|UuidInterface $ns The namespace (must be a valid UUID)
*
* @return non-empty-string Version 3 UUID as a string
*
* @psalm-pure note: changing the internal factory is an edge case not covered by purity invariants,
* but under constant factory setups, this method operates in functionally pure manners
*/
function v3($ns, string $name): string
{
return Uuid::uuid3($ns, $name)->toString();
}
/**
* Returns a version 4 (random) UUID
*
* @return non-empty-string Version 4 UUID as a string
*/
function v4(): string
{
return Uuid::uuid4()->toString();
}
/**
* Returns a version 5 (name-based) UUID based on the SHA-1 hash of a
* namespace ID and a name
*
* @param string|UuidInterface $ns The namespace (must be a valid UUID)
*
* @return non-empty-string Version 5 UUID as a string
*
* @psalm-pure note: changing the internal factory is an edge case not covered by purity invariants,
* but under constant factory setups, this method operates in functionally pure manners
*/
function v5($ns, string $name): string
{
return Uuid::uuid5($ns, $name)->toString();
}
/**
* Returns a version 6 (reordered time) UUID from a host ID, sequence number,
* and the current time
*
* @param Hexadecimal|null $node A 48-bit number representing the hardware
* address
* @param int|null $clockSeq A 14-bit number used to help avoid duplicates that
* could arise when the clock is set backwards in time or if the node ID
* changes
*
* @return non-empty-string Version 6 UUID as a string
*/
function v6(?Hexadecimal $node = null, ?int $clockSeq = null): string
{
return Uuid::uuid6($node, $clockSeq)->toString();
}
/**
* Returns a version 7 (Unix Epoch time) UUID
*
* @param DateTimeInterface|null $dateTime An optional date/time from which
* to create the version 7 UUID. If not provided, the UUID is generated
* using the current date/time.
*
* @return non-empty-string Version 7 UUID as a string
*/
function v7(?DateTimeInterface $dateTime = null): string
{
return Uuid::uuid7($dateTime)->toString();
}
/**
* Returns a version 8 (custom) UUID
*
* The bytes provided may contain any value according to your application's
* needs. Be aware, however, that other applications may not understand the
* semantics of the value.
*
* @param string $bytes A 16-byte octet string. This is an open blob
* of data that you may fill with 128 bits of information. Be aware,
* however, bits 48 through 51 will be replaced with the UUID version
* field, and bits 64 and 65 will be replaced with the UUID variant. You
* MUST NOT rely on these bits for your application needs.
*
* @return non-empty-string Version 8 UUID as a string
*/
function v8(string $bytes): string
{
return Uuid::uuid8($bytes)->toString();
}