Файловый менеджер - Редактировать - /home/beautybuzzbeyond/public_html/private/Utility.tar
Назад
InputValidator.php 0000644 00000004720 14720073374 0010234 0 ustar 00 <?php /** * Input validation utilities. * * @package Requests\Utilities */ namespace WpOrg\Requests\Utility; use ArrayAccess; use CurlHandle; use Traversable; /** * Input validation utilities. * * @package Requests\Utilities */ final class InputValidator { /** * Verify that a received input parameter is of type string or is "stringable". * * @param mixed $input Input parameter to verify. * * @return bool */ public static function is_string_or_stringable($input) { return is_string($input) || self::is_stringable_object($input); } /** * Verify whether a received input parameter is usable as an integer array key. * * @param mixed $input Input parameter to verify. * * @return bool */ public static function is_numeric_array_key($input) { if (is_int($input)) { return true; } if (!is_string($input)) { return false; } return (bool) preg_match('`^-?[0-9]+$`', $input); } /** * Verify whether a received input parameter is "stringable". * * @param mixed $input Input parameter to verify. * * @return bool */ public static function is_stringable_object($input) { return is_object($input) && method_exists($input, '__toString'); } /** * Verify whether a received input parameter is _accessible as if it were an array_. * * @param mixed $input Input parameter to verify. * * @return bool */ public static function has_array_access($input) { return is_array($input) || $input instanceof ArrayAccess; } /** * Verify whether a received input parameter is "iterable". * * @internal The PHP native `is_iterable()` function was only introduced in PHP 7.1 * and this library still supports PHP 5.6. * * @param mixed $input Input parameter to verify. * * @return bool */ public static function is_iterable($input) { return is_array($input) || $input instanceof Traversable; } /** * Verify whether a received input parameter is a Curl handle. * * The PHP Curl extension worked with resources prior to PHP 8.0 and with * an instance of the `CurlHandle` class since PHP 8.0. * {@link https://www.php.net/manual/en/migration80.incompatible.php#migration80.incompatible.resource2object} * * @param mixed $input Input parameter to verify. * * @return bool */ public static function is_curl_handle($input) { if (is_resource($input)) { return get_resource_type($input) === 'curl'; } if (is_object($input)) { return $input instanceof CurlHandle; } return false; } } CaseInsensitiveDictionary.php 0000644 00000004713 14720073374 0012413 0 ustar 00 <?php /** * Case-insensitive dictionary, suitable for HTTP headers * * @package Requests\Utilities */ namespace WpOrg\Requests\Utility; use ArrayAccess; use ArrayIterator; use IteratorAggregate; use ReturnTypeWillChange; use WpOrg\Requests\Exception; /** * Case-insensitive dictionary, suitable for HTTP headers * * @package Requests\Utilities */ class CaseInsensitiveDictionary implements ArrayAccess, IteratorAggregate { /** * Actual item data * * @var array */ protected $data = []; /** * Creates a case insensitive dictionary. * * @param array $data Dictionary/map to convert to case-insensitive */ public function __construct(array $data = []) { foreach ($data as $offset => $value) { $this->offsetSet($offset, $value); } } /** * Check if the given item exists * * @param string $offset Item key * @return boolean Does the item exist? */ #[ReturnTypeWillChange] public function offsetExists($offset) { if (is_string($offset)) { $offset = strtolower($offset); } return isset($this->data[$offset]); } /** * Get the value for the item * * @param string $offset Item key * @return string|null Item value (null if the item key doesn't exist) */ #[ReturnTypeWillChange] public function offsetGet($offset) { if (is_string($offset)) { $offset = strtolower($offset); } if (!isset($this->data[$offset])) { return null; } return $this->data[$offset]; } /** * Set the given item * * @param string $offset Item name * @param string $value Item value * * @throws \WpOrg\Requests\Exception On attempting to use dictionary as list (`invalidset`) */ #[ReturnTypeWillChange] public function offsetSet($offset, $value) { if ($offset === null) { throw new Exception('Object is a dictionary, not a list', 'invalidset'); } if (is_string($offset)) { $offset = strtolower($offset); } $this->data[$offset] = $value; } /** * Unset the given header * * @param string $offset The key for the item to unset. */ #[ReturnTypeWillChange] public function offsetUnset($offset) { if (is_string($offset)) { $offset = strtolower($offset); } unset($this->data[$offset]); } /** * Get an iterator for the data * * @return \ArrayIterator */ #[ReturnTypeWillChange] public function getIterator() { return new ArrayIterator($this->data); } /** * Get the headers as an array * * @return array Header data */ public function getAll() { return $this->data; } } FilteredIterator.php 0000644 00000004155 14720073374 0010541 0 ustar 00 <?php /** * Iterator for arrays requiring filtered values * * @package Requests\Utilities */ namespace WpOrg\Requests\Utility; use ArrayIterator; use ReturnTypeWillChange; use WpOrg\Requests\Exception\InvalidArgument; use WpOrg\Requests\Utility\InputValidator; /** * Iterator for arrays requiring filtered values * * @package Requests\Utilities */ final class FilteredIterator extends ArrayIterator { /** * Callback to run as a filter * * @var callable */ private $callback; /** * Create a new iterator * * @param array $data The array or object to be iterated on. * @param callable $callback Callback to be called on each value * * @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $data argument is not iterable. */ public function __construct($data, $callback) { if (InputValidator::is_iterable($data) === false) { throw InvalidArgument::create(1, '$data', 'iterable', gettype($data)); } parent::__construct($data); if (is_callable($callback)) { $this->callback = $callback; } } /** * Prevent unserialization of the object for security reasons. * * @phpcs:disable PHPCompatibility.FunctionNameRestrictions.NewMagicMethods.__unserializeFound * * @param array $data Restored array of data originally serialized. * * @return void */ #[ReturnTypeWillChange] public function __unserialize($data) {} // phpcs:enable /** * Perform reinitialization tasks. * * Prevents a callback from being injected during unserialization of an object. * * @return void */ public function __wakeup() { unset($this->callback); } /** * Get the current item's value after filtering * * @return string */ #[ReturnTypeWillChange] public function current() { $value = parent::current(); if (is_callable($this->callback)) { $value = call_user_func($this->callback, $value); } return $value; } /** * Prevent creating a PHP value from a stored representation of the object for security reasons. * * @param string $data The serialized string. * * @return void */ #[ReturnTypeWillChange] public function unserialize($data) {} }
| ver. 1.4 |
Github
|
.
| PHP 8.0.30 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка