the middle of the idiots
This commit is contained in:
		
							
								
								
									
										22
									
								
								qwen/php/vendor/slim/psr7/LICENSE.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								qwen/php/vendor/slim/psr7/LICENSE.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
			
		||||
The MIT License (MIT)
 | 
			
		||||
 | 
			
		||||
Copyright (c) 2015 Slim Framework
 | 
			
		||||
 | 
			
		||||
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.
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										76
									
								
								qwen/php/vendor/slim/psr7/composer.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										76
									
								
								qwen/php/vendor/slim/psr7/composer.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,76 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "slim/psr7",
 | 
			
		||||
  "type": "library",
 | 
			
		||||
  "description": "Strict PSR-7 implementation",
 | 
			
		||||
  "keywords": ["psr7","psr-7","http"],
 | 
			
		||||
  "homepage": "https://www.slimframework.com",
 | 
			
		||||
  "license": "MIT",
 | 
			
		||||
  "authors": [
 | 
			
		||||
    {
 | 
			
		||||
      "name": "Josh Lockhart",
 | 
			
		||||
      "email": "hello@joshlockhart.com",
 | 
			
		||||
      "homepage": "https://joshlockhart.com"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "name": "Andrew Smith",
 | 
			
		||||
      "email": "a.smith@silentworks.co.uk",
 | 
			
		||||
      "homepage": "https://silentworks.co.uk"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "name": "Rob Allen",
 | 
			
		||||
      "email": "rob@akrabat.com",
 | 
			
		||||
      "homepage": "https://akrabat.com"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "name": "Pierre Berube",
 | 
			
		||||
      "email": "pierre@lgse.com",
 | 
			
		||||
      "homepage": "https://www.lgse.com"
 | 
			
		||||
    }
 | 
			
		||||
  ],
 | 
			
		||||
  "require": {
 | 
			
		||||
    "php": "^8.0",
 | 
			
		||||
    "fig/http-message-util": "^1.1.5",
 | 
			
		||||
    "psr/http-factory": "^1.1",
 | 
			
		||||
    "psr/http-message": "^1.0 || ^2.0",
 | 
			
		||||
    "ralouphie/getallheaders": "^3.0",
 | 
			
		||||
    "symfony/polyfill-php80": "^1.29"
 | 
			
		||||
  },
 | 
			
		||||
  "require-dev": {
 | 
			
		||||
    "ext-json": "*",
 | 
			
		||||
    "adriansuter/php-autoload-override": "^1.4",
 | 
			
		||||
    "http-interop/http-factory-tests": "^1.0 || ^2.0",
 | 
			
		||||
    "php-http/psr7-integration-tests": "^1.4",
 | 
			
		||||
    "phpspec/prophecy": "^1.19",
 | 
			
		||||
    "phpspec/prophecy-phpunit": "^2.2",
 | 
			
		||||
    "phpstan/phpstan": "^2.1",
 | 
			
		||||
    "phpunit/phpunit": "^9.6 || ^10",
 | 
			
		||||
    "squizlabs/php_codesniffer": "^3.10"
 | 
			
		||||
  },
 | 
			
		||||
  "provide": {
 | 
			
		||||
    "psr/http-message-implementation": "^1.0 || ^2.0",
 | 
			
		||||
    "psr/http-factory-implementation": "^1.0"
 | 
			
		||||
  },
 | 
			
		||||
  "autoload": {
 | 
			
		||||
    "psr-4": {
 | 
			
		||||
      "Slim\\Psr7\\": "src"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  "autoload-dev": {
 | 
			
		||||
    "psr-4": {
 | 
			
		||||
      "Slim\\Tests\\Psr7\\": "tests"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "test": [
 | 
			
		||||
      "@phpunit",
 | 
			
		||||
      "@phpcs",
 | 
			
		||||
      "@phpstan"
 | 
			
		||||
    ],
 | 
			
		||||
    "phpunit": "@php phpunit",
 | 
			
		||||
    "phpcs": "@php phpcs",
 | 
			
		||||
    "phpstan": "@php phpstan --memory-limit=-1"
 | 
			
		||||
  },
 | 
			
		||||
  "config": {
 | 
			
		||||
    "sort-packages": true
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										23
									
								
								qwen/php/vendor/slim/psr7/phpunit.xml.dist
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								qwen/php/vendor/slim/psr7/phpunit.xml.dist
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 | 
			
		||||
         xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
 | 
			
		||||
         backupGlobals="true"
 | 
			
		||||
         beStrictAboutOutputDuringTests="true"
 | 
			
		||||
         colors="true"
 | 
			
		||||
         bootstrap="tests/bootstrap.php"
 | 
			
		||||
>
 | 
			
		||||
    <testsuites>
 | 
			
		||||
        <testsuite name="Slim-Psr7 Test Suite">
 | 
			
		||||
            <directory>tests</directory>
 | 
			
		||||
        </testsuite>
 | 
			
		||||
    </testsuites>
 | 
			
		||||
 | 
			
		||||
    <coverage processUncoveredFiles="true">
 | 
			
		||||
        <include>
 | 
			
		||||
            <directory suffix=".php">src</directory>
 | 
			
		||||
        </include>
 | 
			
		||||
        <report>
 | 
			
		||||
            <html outputDirectory="coverage" lowUpperBound="20" highLowerBound="50"/>
 | 
			
		||||
        </report>
 | 
			
		||||
    </coverage>
 | 
			
		||||
</phpunit>
 | 
			
		||||
							
								
								
									
										218
									
								
								qwen/php/vendor/slim/psr7/src/Cookies.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										218
									
								
								qwen/php/vendor/slim/psr7/src/Cookies.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,218 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Psr7;
 | 
			
		||||
 | 
			
		||||
use InvalidArgumentException;
 | 
			
		||||
 | 
			
		||||
use function array_key_exists;
 | 
			
		||||
use function array_replace;
 | 
			
		||||
use function count;
 | 
			
		||||
use function explode;
 | 
			
		||||
use function gmdate;
 | 
			
		||||
use function in_array;
 | 
			
		||||
use function is_array;
 | 
			
		||||
use function is_string;
 | 
			
		||||
use function preg_split;
 | 
			
		||||
use function rtrim;
 | 
			
		||||
use function strtolower;
 | 
			
		||||
use function strtotime;
 | 
			
		||||
use function urldecode;
 | 
			
		||||
use function urlencode;
 | 
			
		||||
 | 
			
		||||
class Cookies
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * Cookies from HTTP request
 | 
			
		||||
     */
 | 
			
		||||
    protected array $requestCookies = [];
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Cookies for HTTP response
 | 
			
		||||
     */
 | 
			
		||||
    protected array $responseCookies = [];
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Default cookie properties
 | 
			
		||||
     */
 | 
			
		||||
    protected array $defaults = [
 | 
			
		||||
        'value' => '',
 | 
			
		||||
        'domain' => null,
 | 
			
		||||
        'hostonly' => null,
 | 
			
		||||
        'path' => null,
 | 
			
		||||
        'expires' => null,
 | 
			
		||||
        'secure' => false,
 | 
			
		||||
        'httponly' => false,
 | 
			
		||||
        'samesite' => null
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param array $cookies
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct(array $cookies = [])
 | 
			
		||||
    {
 | 
			
		||||
        $this->requestCookies = $cookies;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Set default cookie properties
 | 
			
		||||
     *
 | 
			
		||||
     * @param array $settings
 | 
			
		||||
     *
 | 
			
		||||
     * @return static
 | 
			
		||||
     */
 | 
			
		||||
    public function setDefaults(array $settings): self
 | 
			
		||||
    {
 | 
			
		||||
        $this->defaults = array_replace($this->defaults, $settings);
 | 
			
		||||
 | 
			
		||||
        return $this;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get cookie
 | 
			
		||||
     *
 | 
			
		||||
     * @param string            $name
 | 
			
		||||
     * @param string|array|null $default
 | 
			
		||||
     * @return mixed|null
 | 
			
		||||
     */
 | 
			
		||||
    public function get(string $name, $default = null)
 | 
			
		||||
    {
 | 
			
		||||
        return array_key_exists($name, $this->requestCookies) ? $this->requestCookies[$name] : $default;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Set cookie
 | 
			
		||||
     *
 | 
			
		||||
     * @param string       $name
 | 
			
		||||
     * @param string|array $value
 | 
			
		||||
     * @return static
 | 
			
		||||
     */
 | 
			
		||||
    public function set(string $name, $value): self
 | 
			
		||||
    {
 | 
			
		||||
        if (!is_array($value)) {
 | 
			
		||||
            $value = ['value' => $value];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $this->responseCookies[$name] = array_replace($this->defaults, $value);
 | 
			
		||||
 | 
			
		||||
        return $this;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Convert all response cookies into an associate array of header values
 | 
			
		||||
     *
 | 
			
		||||
     * @return array
 | 
			
		||||
     */
 | 
			
		||||
    public function toHeaders(): array
 | 
			
		||||
    {
 | 
			
		||||
        $headers = [];
 | 
			
		||||
 | 
			
		||||
        foreach ($this->responseCookies as $name => $properties) {
 | 
			
		||||
            $headers[] = $this->toHeader($name, $properties);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $headers;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Convert to `Set-Cookie` header
 | 
			
		||||
     *
 | 
			
		||||
     * @param  string $name       Cookie name
 | 
			
		||||
     * @param  array  $properties Cookie properties
 | 
			
		||||
     *
 | 
			
		||||
     * @return string
 | 
			
		||||
     */
 | 
			
		||||
    protected function toHeader(string $name, array $properties): string
 | 
			
		||||
    {
 | 
			
		||||
        $result = urlencode($name) . '=' . urlencode($properties['value']);
 | 
			
		||||
 | 
			
		||||
        if (isset($properties['domain'])) {
 | 
			
		||||
            $result .= '; domain=' . $properties['domain'];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (isset($properties['path'])) {
 | 
			
		||||
            $result .= '; path=' . $properties['path'];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (isset($properties['expires'])) {
 | 
			
		||||
            if (is_string($properties['expires'])) {
 | 
			
		||||
                $timestamp = strtotime($properties['expires']);
 | 
			
		||||
            } else {
 | 
			
		||||
                $timestamp = (int) $properties['expires'];
 | 
			
		||||
            }
 | 
			
		||||
            if ($timestamp && $timestamp !== 0) {
 | 
			
		||||
                $result .= '; expires=' . gmdate('D, d-M-Y H:i:s e', $timestamp);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (isset($properties['secure']) && $properties['secure']) {
 | 
			
		||||
            $result .= '; secure';
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (isset($properties['hostonly']) && $properties['hostonly']) {
 | 
			
		||||
            $result .= '; HostOnly';
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (isset($properties['httponly']) && $properties['httponly']) {
 | 
			
		||||
            $result .= '; HttpOnly';
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (
 | 
			
		||||
            isset($properties['samesite'])
 | 
			
		||||
            && in_array(strtolower($properties['samesite']), ['lax', 'strict', 'none'], true)
 | 
			
		||||
        ) {
 | 
			
		||||
            // While strtolower is needed for correct comparison, the RFC doesn't care about case
 | 
			
		||||
            $result .= '; SameSite=' . $properties['samesite'];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Parse cookie values from header value
 | 
			
		||||
     *
 | 
			
		||||
     * Returns an associative array of cookie names and values
 | 
			
		||||
     *
 | 
			
		||||
     * @param string|array $header
 | 
			
		||||
     *
 | 
			
		||||
     * @return array
 | 
			
		||||
     */
 | 
			
		||||
    public static function parseHeader($header): array
 | 
			
		||||
    {
 | 
			
		||||
        if (is_array($header)) {
 | 
			
		||||
            $header = $header[0] ?? '';
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!is_string($header)) {
 | 
			
		||||
            throw new InvalidArgumentException('Cannot parse Cookie data. Header value must be a string.');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $header = rtrim($header, "\r\n");
 | 
			
		||||
        $pieces = preg_split('@[;]\s*@', $header);
 | 
			
		||||
        $cookies = [];
 | 
			
		||||
 | 
			
		||||
        if (is_array($pieces)) {
 | 
			
		||||
            foreach ($pieces as $cookie) {
 | 
			
		||||
                $cookie = explode('=', $cookie, 2);
 | 
			
		||||
 | 
			
		||||
                if (count($cookie) === 2) {
 | 
			
		||||
                    $key = urldecode($cookie[0]);
 | 
			
		||||
                    $value = urldecode($cookie[1]);
 | 
			
		||||
 | 
			
		||||
                    if (!isset($cookies[$key])) {
 | 
			
		||||
                        $cookies[$key] = $value;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $cookies;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										55
									
								
								qwen/php/vendor/slim/psr7/src/Environment.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								qwen/php/vendor/slim/psr7/src/Environment.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,55 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Psr7;
 | 
			
		||||
 | 
			
		||||
use function array_merge;
 | 
			
		||||
use function microtime;
 | 
			
		||||
use function time;
 | 
			
		||||
 | 
			
		||||
class Environment
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @param  array $data Array of custom environment keys and values
 | 
			
		||||
     *
 | 
			
		||||
     * @return array
 | 
			
		||||
     */
 | 
			
		||||
    public static function mock(array $data = []): array
 | 
			
		||||
    {
 | 
			
		||||
        if (
 | 
			
		||||
            (isset($data['HTTPS']) && $data['HTTPS'] !== 'off')
 | 
			
		||||
            || ((isset($data['REQUEST_SCHEME']) && $data['REQUEST_SCHEME'] === 'https'))
 | 
			
		||||
        ) {
 | 
			
		||||
            $scheme = 'https';
 | 
			
		||||
            $port = 443;
 | 
			
		||||
        } else {
 | 
			
		||||
            $scheme = 'http';
 | 
			
		||||
            $port = 80;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return array_merge([
 | 
			
		||||
            'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
 | 
			
		||||
            'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
 | 
			
		||||
            'HTTP_ACCEPT_LANGUAGE' => 'en-US,en;q=0.8',
 | 
			
		||||
            'HTTP_USER_AGENT' => 'Slim Framework',
 | 
			
		||||
            'QUERY_STRING' => '',
 | 
			
		||||
            'REMOTE_ADDR' => '127.0.0.1',
 | 
			
		||||
            'REQUEST_METHOD' => 'GET',
 | 
			
		||||
            'REQUEST_SCHEME' => $scheme,
 | 
			
		||||
            'REQUEST_TIME' => time(),
 | 
			
		||||
            'REQUEST_TIME_FLOAT' => microtime(true),
 | 
			
		||||
            'REQUEST_URI' => '',
 | 
			
		||||
            'SCRIPT_NAME' => '',
 | 
			
		||||
            'SERVER_NAME' => 'localhost',
 | 
			
		||||
            'SERVER_PORT' => $port,
 | 
			
		||||
            'SERVER_PROTOCOL' => 'HTTP/1.1',
 | 
			
		||||
        ], $data);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										59
									
								
								qwen/php/vendor/slim/psr7/src/Factory/RequestFactory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								qwen/php/vendor/slim/psr7/src/Factory/RequestFactory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,59 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Psr7\Factory;
 | 
			
		||||
 | 
			
		||||
use InvalidArgumentException;
 | 
			
		||||
use Psr\Http\Message\RequestFactoryInterface;
 | 
			
		||||
use Psr\Http\Message\RequestInterface;
 | 
			
		||||
use Psr\Http\Message\StreamFactoryInterface;
 | 
			
		||||
use Psr\Http\Message\UriFactoryInterface;
 | 
			
		||||
use Psr\Http\Message\UriInterface;
 | 
			
		||||
use Slim\Psr7\Headers;
 | 
			
		||||
use Slim\Psr7\Request;
 | 
			
		||||
 | 
			
		||||
use function is_string;
 | 
			
		||||
 | 
			
		||||
class RequestFactory implements RequestFactoryInterface
 | 
			
		||||
{
 | 
			
		||||
    protected StreamFactoryInterface $streamFactory;
 | 
			
		||||
 | 
			
		||||
    protected UriFactoryInterface $uriFactory;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param StreamFactoryInterface|null $streamFactory
 | 
			
		||||
     * @param UriFactoryInterface|null    $uriFactory
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct(?StreamFactoryInterface $streamFactory = null, ?UriFactoryInterface $uriFactory = null)
 | 
			
		||||
    {
 | 
			
		||||
        $this->streamFactory = $streamFactory ?? new StreamFactory();
 | 
			
		||||
        $this->uriFactory = $uriFactory ?? new UriFactory();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function createRequest(string $method, $uri): RequestInterface
 | 
			
		||||
    {
 | 
			
		||||
        if (is_string($uri)) {
 | 
			
		||||
            $uri = $this->uriFactory->createUri($uri);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!$uri instanceof UriInterface) {
 | 
			
		||||
            throw new InvalidArgumentException(
 | 
			
		||||
                'Parameter 2 of RequestFactory::createRequest() must be a string or a compatible UriInterface.'
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $body = $this->streamFactory->createStream();
 | 
			
		||||
 | 
			
		||||
        return new Request($method, $uri, new Headers(), [], [], $body);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										35
									
								
								qwen/php/vendor/slim/psr7/src/Factory/ResponseFactory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								qwen/php/vendor/slim/psr7/src/Factory/ResponseFactory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,35 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Psr7\Factory;
 | 
			
		||||
 | 
			
		||||
use Fig\Http\Message\StatusCodeInterface;
 | 
			
		||||
use Psr\Http\Message\ResponseFactoryInterface;
 | 
			
		||||
use Psr\Http\Message\ResponseInterface;
 | 
			
		||||
use Slim\Psr7\Response;
 | 
			
		||||
 | 
			
		||||
class ResponseFactory implements ResponseFactoryInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function createResponse(
 | 
			
		||||
        int $code = StatusCodeInterface::STATUS_OK,
 | 
			
		||||
        string $reasonPhrase = ''
 | 
			
		||||
    ): ResponseInterface {
 | 
			
		||||
        $res = new Response($code);
 | 
			
		||||
 | 
			
		||||
        if ($reasonPhrase !== '') {
 | 
			
		||||
            $res = $res->withStatus($code, $reasonPhrase);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $res;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										111
									
								
								qwen/php/vendor/slim/psr7/src/Factory/ServerRequestFactory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										111
									
								
								qwen/php/vendor/slim/psr7/src/Factory/ServerRequestFactory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,111 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Psr7\Factory;
 | 
			
		||||
 | 
			
		||||
use InvalidArgumentException;
 | 
			
		||||
use Psr\Http\Message\ServerRequestFactoryInterface;
 | 
			
		||||
use Psr\Http\Message\ServerRequestInterface;
 | 
			
		||||
use Psr\Http\Message\StreamFactoryInterface;
 | 
			
		||||
use Psr\Http\Message\UriFactoryInterface;
 | 
			
		||||
use Psr\Http\Message\UriInterface;
 | 
			
		||||
use Slim\Psr7\Cookies;
 | 
			
		||||
use Slim\Psr7\Headers;
 | 
			
		||||
use Slim\Psr7\Request;
 | 
			
		||||
use Slim\Psr7\Stream;
 | 
			
		||||
use Slim\Psr7\UploadedFile;
 | 
			
		||||
 | 
			
		||||
use function current;
 | 
			
		||||
use function explode;
 | 
			
		||||
use function fopen;
 | 
			
		||||
use function in_array;
 | 
			
		||||
use function is_string;
 | 
			
		||||
 | 
			
		||||
class ServerRequestFactory implements ServerRequestFactoryInterface
 | 
			
		||||
{
 | 
			
		||||
    protected StreamFactoryInterface $streamFactory;
 | 
			
		||||
 | 
			
		||||
    protected UriFactoryInterface $uriFactory;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param StreamFactoryInterface|null $streamFactory
 | 
			
		||||
     * @param UriFactoryInterface|null    $uriFactory
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct(?StreamFactoryInterface $streamFactory = null, ?UriFactoryInterface $uriFactory = null)
 | 
			
		||||
    {
 | 
			
		||||
        $this->streamFactory = $streamFactory ?? new StreamFactory();
 | 
			
		||||
        $this->uriFactory = $uriFactory ?? new UriFactory();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function createServerRequest(string $method, $uri, array $serverParams = []): ServerRequestInterface
 | 
			
		||||
    {
 | 
			
		||||
        if (is_string($uri)) {
 | 
			
		||||
            $uri = $this->uriFactory->createUri($uri);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!$uri instanceof UriInterface) {
 | 
			
		||||
            throw new InvalidArgumentException('URI must either be string or instance of ' . UriInterface::class);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $body = $this->streamFactory->createStream();
 | 
			
		||||
        $headers = new Headers();
 | 
			
		||||
        $cookies = [];
 | 
			
		||||
 | 
			
		||||
        if (!empty($serverParams)) {
 | 
			
		||||
            $headers = Headers::createFromGlobals();
 | 
			
		||||
            $cookies = Cookies::parseHeader($headers->getHeader('Cookie', []));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return new Request($method, $uri, $headers, $cookies, $serverParams, $body);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Create new ServerRequest from environment.
 | 
			
		||||
     *
 | 
			
		||||
     * @internal This method is not part of PSR-17
 | 
			
		||||
     *
 | 
			
		||||
     * @return Request
 | 
			
		||||
     */
 | 
			
		||||
    public static function createFromGlobals(): Request
 | 
			
		||||
    {
 | 
			
		||||
        /** @var string $method */
 | 
			
		||||
        $method = $_SERVER['REQUEST_METHOD'] ?? 'GET';
 | 
			
		||||
        $uri = (new UriFactory())->createFromGlobals($_SERVER);
 | 
			
		||||
 | 
			
		||||
        $headers = Headers::createFromGlobals();
 | 
			
		||||
        $cookies = Cookies::parseHeader($headers->getHeader('Cookie', []));
 | 
			
		||||
 | 
			
		||||
        // Cache the php://input stream as it cannot be re-read
 | 
			
		||||
        $cacheResource = fopen('php://temp', 'wb+');
 | 
			
		||||
        $cache = $cacheResource ? new Stream($cacheResource) : null;
 | 
			
		||||
 | 
			
		||||
        $body = (new StreamFactory())->createStreamFromFile('php://input', 'r', $cache);
 | 
			
		||||
        $uploadedFiles = UploadedFile::createFromGlobals($_SERVER);
 | 
			
		||||
 | 
			
		||||
        $request = new Request($method, $uri, $headers, $cookies, $_SERVER, $body, $uploadedFiles);
 | 
			
		||||
        $contentTypes = $request->getHeader('Content-Type');
 | 
			
		||||
 | 
			
		||||
        $parsedContentType = '';
 | 
			
		||||
        foreach ($contentTypes as $contentType) {
 | 
			
		||||
            $fragments = explode(';', $contentType);
 | 
			
		||||
            $parsedContentType = current($fragments);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $contentTypesWithParsedBodies = ['application/x-www-form-urlencoded', 'multipart/form-data'];
 | 
			
		||||
        if ($method === 'POST' && in_array($parsedContentType, $contentTypesWithParsedBodies)) {
 | 
			
		||||
            return $request->withParsedBody($_POST);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $request;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										95
									
								
								qwen/php/vendor/slim/psr7/src/Factory/StreamFactory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										95
									
								
								qwen/php/vendor/slim/psr7/src/Factory/StreamFactory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,95 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Psr7\Factory;
 | 
			
		||||
 | 
			
		||||
use InvalidArgumentException;
 | 
			
		||||
use Psr\Http\Message\StreamFactoryInterface;
 | 
			
		||||
use Psr\Http\Message\StreamInterface;
 | 
			
		||||
use RuntimeException;
 | 
			
		||||
use Slim\Psr7\Stream;
 | 
			
		||||
use ValueError;
 | 
			
		||||
 | 
			
		||||
use function fopen;
 | 
			
		||||
use function fwrite;
 | 
			
		||||
use function is_resource;
 | 
			
		||||
use function restore_error_handler;
 | 
			
		||||
use function rewind;
 | 
			
		||||
use function set_error_handler;
 | 
			
		||||
 | 
			
		||||
class StreamFactory implements StreamFactoryInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     *
 | 
			
		||||
     * @throws RuntimeException
 | 
			
		||||
     */
 | 
			
		||||
    public function createStream(string $content = ''): StreamInterface
 | 
			
		||||
    {
 | 
			
		||||
        $resource = fopen('php://temp', 'rw+');
 | 
			
		||||
 | 
			
		||||
        if (!is_resource($resource)) {
 | 
			
		||||
            throw new RuntimeException('StreamFactory::createStream() could not open temporary file stream.');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        fwrite($resource, $content);
 | 
			
		||||
        rewind($resource);
 | 
			
		||||
 | 
			
		||||
        return $this->createStreamFromResource($resource);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function createStreamFromFile(
 | 
			
		||||
        string $filename,
 | 
			
		||||
        string $mode = 'r',
 | 
			
		||||
        ?StreamInterface $cache = null
 | 
			
		||||
    ): StreamInterface {
 | 
			
		||||
        set_error_handler(
 | 
			
		||||
            static function (int $errno, string $errstr) use ($filename, $mode): void {
 | 
			
		||||
                throw new RuntimeException(
 | 
			
		||||
                    "Unable to open $filename using mode $mode: $errstr",
 | 
			
		||||
                    $errno
 | 
			
		||||
                );
 | 
			
		||||
            }
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            $resource = fopen($filename, $mode);
 | 
			
		||||
        } catch (ValueError $exception) {
 | 
			
		||||
            throw new RuntimeException("Unable to open $filename using mode $mode: " . $exception->getMessage());
 | 
			
		||||
        } finally {
 | 
			
		||||
            restore_error_handler();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!is_resource($resource)) {
 | 
			
		||||
            throw new RuntimeException(
 | 
			
		||||
                "StreamFactory::createStreamFromFile() could not create resource from file `$filename`"
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return new Stream($resource, $cache);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function createStreamFromResource($resource, ?StreamInterface $cache = null): StreamInterface
 | 
			
		||||
    {
 | 
			
		||||
        if (!is_resource($resource)) {
 | 
			
		||||
            throw new InvalidArgumentException(
 | 
			
		||||
                'Parameter 1 of StreamFactory::createStreamFromResource() must be a resource.'
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return new Stream($resource, $cache);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										47
									
								
								qwen/php/vendor/slim/psr7/src/Factory/UploadedFileFactory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								qwen/php/vendor/slim/psr7/src/Factory/UploadedFileFactory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,47 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Psr7\Factory;
 | 
			
		||||
 | 
			
		||||
use InvalidArgumentException;
 | 
			
		||||
use Psr\Http\Message\StreamInterface;
 | 
			
		||||
use Psr\Http\Message\UploadedFileFactoryInterface;
 | 
			
		||||
use Psr\Http\Message\UploadedFileInterface;
 | 
			
		||||
use Slim\Psr7\UploadedFile;
 | 
			
		||||
 | 
			
		||||
use function is_string;
 | 
			
		||||
 | 
			
		||||
use const UPLOAD_ERR_OK;
 | 
			
		||||
 | 
			
		||||
class UploadedFileFactory implements UploadedFileFactoryInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function createUploadedFile(
 | 
			
		||||
        StreamInterface $stream,
 | 
			
		||||
        ?int $size = null,
 | 
			
		||||
        int $error = UPLOAD_ERR_OK,
 | 
			
		||||
        ?string $clientFilename = null,
 | 
			
		||||
        ?string $clientMediaType = null
 | 
			
		||||
    ): UploadedFileInterface {
 | 
			
		||||
        $file = $stream->getMetadata('uri');
 | 
			
		||||
 | 
			
		||||
        if (!is_string($file) || !$stream->isReadable()) {
 | 
			
		||||
            throw new InvalidArgumentException('File is not readable.');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if ($size === null) {
 | 
			
		||||
            $size = $stream->getSize();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return new UploadedFile($stream, $clientFilename, $clientMediaType, $size, $error);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										113
									
								
								qwen/php/vendor/slim/psr7/src/Factory/UriFactory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										113
									
								
								qwen/php/vendor/slim/psr7/src/Factory/UriFactory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,113 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Psr7\Factory;
 | 
			
		||||
 | 
			
		||||
use InvalidArgumentException;
 | 
			
		||||
use Psr\Http\Message\UriFactoryInterface;
 | 
			
		||||
use Psr\Http\Message\UriInterface;
 | 
			
		||||
use Slim\Psr7\Uri;
 | 
			
		||||
 | 
			
		||||
use function count;
 | 
			
		||||
use function explode;
 | 
			
		||||
use function parse_url;
 | 
			
		||||
use function preg_match;
 | 
			
		||||
use function strpos;
 | 
			
		||||
use function strstr;
 | 
			
		||||
use function substr;
 | 
			
		||||
 | 
			
		||||
use const PHP_URL_QUERY;
 | 
			
		||||
 | 
			
		||||
class UriFactory implements UriFactoryInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function createUri(string $uri = ''): UriInterface
 | 
			
		||||
    {
 | 
			
		||||
        $parts = parse_url($uri);
 | 
			
		||||
 | 
			
		||||
        if ($parts === false) {
 | 
			
		||||
            throw new InvalidArgumentException('URI cannot be parsed');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $scheme = $parts['scheme'] ?? '';
 | 
			
		||||
        $user = $parts['user'] ?? '';
 | 
			
		||||
        $pass = $parts['pass'] ?? '';
 | 
			
		||||
        $host = $parts['host'] ?? '';
 | 
			
		||||
        $port = $parts['port'] ?? null;
 | 
			
		||||
        $path = $parts['path'] ?? '';
 | 
			
		||||
        $query = $parts['query'] ?? '';
 | 
			
		||||
        $fragment = $parts['fragment'] ?? '';
 | 
			
		||||
 | 
			
		||||
        return new Uri($scheme, $host, $port, $path, $query, $fragment, $user, $pass);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Create new Uri from environment.
 | 
			
		||||
     *
 | 
			
		||||
     * @internal This method is not part of PSR-17
 | 
			
		||||
     *
 | 
			
		||||
     * @param array $globals The global server variables.
 | 
			
		||||
     *
 | 
			
		||||
     * @return Uri
 | 
			
		||||
     */
 | 
			
		||||
    public function createFromGlobals(array $globals): Uri
 | 
			
		||||
    {
 | 
			
		||||
        // Scheme
 | 
			
		||||
        $https = $globals['HTTPS'] ?? false;
 | 
			
		||||
        $scheme = !$https || $https === 'off' ? 'http' : 'https';
 | 
			
		||||
 | 
			
		||||
        // Authority: Username and password
 | 
			
		||||
        $username = $globals['PHP_AUTH_USER'] ?? '';
 | 
			
		||||
        $password = $globals['PHP_AUTH_PW'] ?? '';
 | 
			
		||||
 | 
			
		||||
        // Authority: Host
 | 
			
		||||
        $host = '';
 | 
			
		||||
        if (isset($globals['HTTP_HOST'])) {
 | 
			
		||||
            $host = $globals['HTTP_HOST'];
 | 
			
		||||
        } elseif (isset($globals['SERVER_NAME'])) {
 | 
			
		||||
            $host = $globals['SERVER_NAME'];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Authority: Port
 | 
			
		||||
        $port = !empty($globals['SERVER_PORT']) ? (int)$globals['SERVER_PORT'] : ($scheme === 'https' ? 443 : 80);
 | 
			
		||||
        if (preg_match('/^(\[[a-fA-F0-9:.]+])(:\d+)?\z/', $host, $matches)) {
 | 
			
		||||
            $host = $matches[1];
 | 
			
		||||
 | 
			
		||||
            if (isset($matches[2])) {
 | 
			
		||||
                $port = (int) substr($matches[2], 1);
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            $pos = strpos($host, ':');
 | 
			
		||||
            if ($pos !== false) {
 | 
			
		||||
                $port = (int) substr($host, $pos + 1);
 | 
			
		||||
                $host = strstr($host, ':', true);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Query string
 | 
			
		||||
        $queryString = $globals['QUERY_STRING'] ?? '';
 | 
			
		||||
 | 
			
		||||
        // Request URI
 | 
			
		||||
        $requestUri = '';
 | 
			
		||||
        if (isset($globals['REQUEST_URI'])) {
 | 
			
		||||
            $uriFragments = explode('?', $globals['REQUEST_URI']);
 | 
			
		||||
            $requestUri = $uriFragments[0];
 | 
			
		||||
 | 
			
		||||
            if ($queryString === '' && count($uriFragments) > 1) {
 | 
			
		||||
                $queryString = parse_url('https://www.example.com' . $globals['REQUEST_URI'], PHP_URL_QUERY) ?? '';
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Build Uri and return
 | 
			
		||||
        return new Uri($scheme, $host, $port, $requestUri, $queryString, '', $username, $password);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										63
									
								
								qwen/php/vendor/slim/psr7/src/Header.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								qwen/php/vendor/slim/psr7/src/Header.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,63 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Psr7;
 | 
			
		||||
 | 
			
		||||
use function array_merge;
 | 
			
		||||
use function is_string;
 | 
			
		||||
 | 
			
		||||
class Header
 | 
			
		||||
{
 | 
			
		||||
    private string $originalName;
 | 
			
		||||
 | 
			
		||||
    private string $normalizedName;
 | 
			
		||||
 | 
			
		||||
    private array $values;
 | 
			
		||||
 | 
			
		||||
    public function __construct(string $originalName, string $normalizedName, array $values)
 | 
			
		||||
    {
 | 
			
		||||
        $this->originalName = $originalName;
 | 
			
		||||
        $this->normalizedName = $normalizedName;
 | 
			
		||||
        $this->values = $values;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getOriginalName(): string
 | 
			
		||||
    {
 | 
			
		||||
        return $this->originalName;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getNormalizedName(): string
 | 
			
		||||
    {
 | 
			
		||||
        return $this->normalizedName;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function addValue(string $value): self
 | 
			
		||||
    {
 | 
			
		||||
        $this->values[] = $value;
 | 
			
		||||
 | 
			
		||||
        return $this;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function addValues(array|string $values): self
 | 
			
		||||
    {
 | 
			
		||||
        if (is_string($values)) {
 | 
			
		||||
            return $this->addValue($values);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $this->values = array_merge($this->values, $values);
 | 
			
		||||
 | 
			
		||||
        return $this;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getValues(): array
 | 
			
		||||
    {
 | 
			
		||||
        return $this->values;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										318
									
								
								qwen/php/vendor/slim/psr7/src/Headers.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										318
									
								
								qwen/php/vendor/slim/psr7/src/Headers.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,318 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Psr7;
 | 
			
		||||
 | 
			
		||||
use InvalidArgumentException;
 | 
			
		||||
use Slim\Psr7\Interfaces\HeadersInterface;
 | 
			
		||||
 | 
			
		||||
use function base64_encode;
 | 
			
		||||
use function function_exists;
 | 
			
		||||
use function getallheaders;
 | 
			
		||||
use function is_array;
 | 
			
		||||
use function is_numeric;
 | 
			
		||||
use function is_string;
 | 
			
		||||
use function preg_match;
 | 
			
		||||
use function strpos;
 | 
			
		||||
use function strtolower;
 | 
			
		||||
use function strtr;
 | 
			
		||||
use function substr;
 | 
			
		||||
use function trim;
 | 
			
		||||
 | 
			
		||||
class Headers implements HeadersInterface
 | 
			
		||||
{
 | 
			
		||||
    protected array $globals;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var Header[]
 | 
			
		||||
     */
 | 
			
		||||
    protected array $headers;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param array      $headers
 | 
			
		||||
     * @param array|null $globals
 | 
			
		||||
     */
 | 
			
		||||
    final public function __construct(array $headers = [], ?array $globals = null)
 | 
			
		||||
    {
 | 
			
		||||
        $this->globals = $globals ?? $_SERVER;
 | 
			
		||||
        $this->setHeaders($headers);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function addHeader($name, $value): HeadersInterface
 | 
			
		||||
    {
 | 
			
		||||
        [$values, $originalName, $normalizedName] = $this->prepareHeader($name, $value);
 | 
			
		||||
 | 
			
		||||
        if (isset($this->headers[$normalizedName])) {
 | 
			
		||||
            $header = $this->headers[$normalizedName];
 | 
			
		||||
            $header->addValues($values);
 | 
			
		||||
        } else {
 | 
			
		||||
            $this->headers[$normalizedName] = new Header($originalName, $normalizedName, $values);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $this;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function removeHeader(string $name): HeadersInterface
 | 
			
		||||
    {
 | 
			
		||||
        $name = $this->normalizeHeaderName($name);
 | 
			
		||||
        unset($this->headers[$name]);
 | 
			
		||||
        return $this;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getHeader(string $name, $default = []): array
 | 
			
		||||
    {
 | 
			
		||||
        $name = $this->normalizeHeaderName($name);
 | 
			
		||||
 | 
			
		||||
        if (isset($this->headers[$name])) {
 | 
			
		||||
            $header = $this->headers[$name];
 | 
			
		||||
            return $header->getValues();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (empty($default)) {
 | 
			
		||||
            return $default;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $this->validateHeader($name, $default);
 | 
			
		||||
        return $this->trimHeaderValue($default);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function setHeader($name, $value): HeadersInterface
 | 
			
		||||
    {
 | 
			
		||||
        [$values, $originalName, $normalizedName] = $this->prepareHeader($name, $value);
 | 
			
		||||
 | 
			
		||||
        // Ensure we preserve original case if the header already exists in the stack
 | 
			
		||||
        if (isset($this->headers[$normalizedName])) {
 | 
			
		||||
            $existingHeader = $this->headers[$normalizedName];
 | 
			
		||||
            $originalName = $existingHeader->getOriginalName();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $this->headers[$normalizedName] = new Header($originalName, $normalizedName, $values);
 | 
			
		||||
 | 
			
		||||
        return $this;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function setHeaders(array $headers): HeadersInterface
 | 
			
		||||
    {
 | 
			
		||||
        $this->headers = [];
 | 
			
		||||
 | 
			
		||||
        foreach ($this->parseAuthorizationHeader($headers) as $name => $value) {
 | 
			
		||||
            $this->addHeader($name, $value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $this;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function hasHeader(string $name): bool
 | 
			
		||||
    {
 | 
			
		||||
        $name = $this->normalizeHeaderName($name);
 | 
			
		||||
        return isset($this->headers[$name]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getHeaders(bool $originalCase = false): array
 | 
			
		||||
    {
 | 
			
		||||
        $headers = [];
 | 
			
		||||
 | 
			
		||||
        foreach ($this->headers as $header) {
 | 
			
		||||
            $name = $originalCase ? $header->getOriginalName() : $header->getNormalizedName();
 | 
			
		||||
            $headers[$name] = $header->getValues();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $headers;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param string $name
 | 
			
		||||
     * @param bool   $preserveCase
 | 
			
		||||
     * @return string
 | 
			
		||||
     */
 | 
			
		||||
    protected function normalizeHeaderName(string $name, bool $preserveCase = false): string
 | 
			
		||||
    {
 | 
			
		||||
        $name = strtr($name, '_', '-');
 | 
			
		||||
 | 
			
		||||
        if (!$preserveCase) {
 | 
			
		||||
            $name = strtolower($name);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (strpos(strtolower($name), 'http-') === 0) {
 | 
			
		||||
            $name = substr($name, 5);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $name;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Parse incoming headers and determine Authorization header from original headers
 | 
			
		||||
     *
 | 
			
		||||
     * @param array $headers
 | 
			
		||||
     * @return array
 | 
			
		||||
     */
 | 
			
		||||
    protected function parseAuthorizationHeader(array $headers): array
 | 
			
		||||
    {
 | 
			
		||||
        $hasAuthorizationHeader = false;
 | 
			
		||||
        foreach ($headers as $name => $value) {
 | 
			
		||||
            if (strtolower((string) $name) === 'authorization') {
 | 
			
		||||
                $hasAuthorizationHeader = true;
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!$hasAuthorizationHeader) {
 | 
			
		||||
            if (isset($this->globals['REDIRECT_HTTP_AUTHORIZATION'])) {
 | 
			
		||||
                $headers['Authorization'] = $this->globals['REDIRECT_HTTP_AUTHORIZATION'];
 | 
			
		||||
            } elseif (isset($this->globals['PHP_AUTH_USER'])) {
 | 
			
		||||
                $pw = $this->globals['PHP_AUTH_PW'] ?? '';
 | 
			
		||||
                $headers['Authorization'] = 'Basic ' . base64_encode($this->globals['PHP_AUTH_USER'] . ':' . $pw);
 | 
			
		||||
            } elseif (isset($this->globals['PHP_AUTH_DIGEST'])) {
 | 
			
		||||
                $headers['Authorization'] = $this->globals['PHP_AUTH_DIGEST'];
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $headers;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param array|string $value
 | 
			
		||||
     *
 | 
			
		||||
     * @return array
 | 
			
		||||
     */
 | 
			
		||||
    protected function trimHeaderValue($value): array
 | 
			
		||||
    {
 | 
			
		||||
        $items = is_array($value) ? $value : [$value];
 | 
			
		||||
        $result = [];
 | 
			
		||||
        foreach ($items as $item) {
 | 
			
		||||
            $result[] = trim((string) $item, " \t");
 | 
			
		||||
        }
 | 
			
		||||
        return $result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param string       $name
 | 
			
		||||
     * @param array|string $value
 | 
			
		||||
     *
 | 
			
		||||
     * @throws InvalidArgumentException
 | 
			
		||||
     *
 | 
			
		||||
     * @return array
 | 
			
		||||
     */
 | 
			
		||||
    protected function prepareHeader($name, $value): array
 | 
			
		||||
    {
 | 
			
		||||
        $this->validateHeader($name, $value);
 | 
			
		||||
        $values = $this->trimHeaderValue($value);
 | 
			
		||||
        $originalName = $this->normalizeHeaderName($name, true);
 | 
			
		||||
        $normalizedName = $this->normalizeHeaderName($name);
 | 
			
		||||
        return [$values, $originalName, $normalizedName];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Make sure the header complies with RFC 7230.
 | 
			
		||||
     *
 | 
			
		||||
     * Header names must be a non-empty string consisting of token characters.
 | 
			
		||||
     *
 | 
			
		||||
     * Header values must be strings consisting of visible characters with all optional
 | 
			
		||||
     * leading and trailing whitespace stripped. This method will always strip such
 | 
			
		||||
     * optional whitespace. Note that the method does not allow folding whitespace within
 | 
			
		||||
     * the values as this was deprecated for almost all instances by the RFC.
 | 
			
		||||
     *
 | 
			
		||||
     * header-field = field-name ":" OWS field-value OWS
 | 
			
		||||
     * field-name   = 1*( "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." / "^"
 | 
			
		||||
     *              / "_" / "`" / "|" / "~" / %x30-39 / ( %x41-5A / %x61-7A ) )
 | 
			
		||||
     * OWS          = *( SP / HTAB )
 | 
			
		||||
     * field-value  = *( ( %x21-7E / %x80-FF ) [ 1*( SP / HTAB ) ( %x21-7E / %x80-FF ) ] )
 | 
			
		||||
     *
 | 
			
		||||
     * @see https://tools.ietf.org/html/rfc7230#section-3.2.4
 | 
			
		||||
     *
 | 
			
		||||
     * @param string        $name
 | 
			
		||||
     * @param array|string  $value
 | 
			
		||||
     *
 | 
			
		||||
     * @throws InvalidArgumentException
 | 
			
		||||
     */
 | 
			
		||||
    protected function validateHeader($name, $value): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->validateHeaderName($name);
 | 
			
		||||
        $this->validateHeaderValue($value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param mixed $name
 | 
			
		||||
     *
 | 
			
		||||
     * @throws InvalidArgumentException
 | 
			
		||||
     */
 | 
			
		||||
    protected function validateHeaderName($name): void
 | 
			
		||||
    {
 | 
			
		||||
        if (!is_string($name) || preg_match("@^[!#$%&'*+.^_`|~0-9A-Za-z-]+$@D", $name) !== 1) {
 | 
			
		||||
            throw new InvalidArgumentException('Header name must be an RFC 7230 compatible string.');
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param mixed $value
 | 
			
		||||
     *
 | 
			
		||||
     * @throws InvalidArgumentException
 | 
			
		||||
     */
 | 
			
		||||
    protected function validateHeaderValue($value): void
 | 
			
		||||
    {
 | 
			
		||||
        $items = is_array($value) ? $value : [$value];
 | 
			
		||||
 | 
			
		||||
        if (empty($items)) {
 | 
			
		||||
            throw new InvalidArgumentException(
 | 
			
		||||
                'Header values must be a string or an array of strings, empty array given.'
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $pattern = "@^[ \t\x21-\x7E\x80-\xFF]*$@D";
 | 
			
		||||
        foreach ($items as $item) {
 | 
			
		||||
            $hasInvalidType = !is_numeric($item) && !is_string($item);
 | 
			
		||||
            $rejected = $hasInvalidType || preg_match($pattern, (string) $item) !== 1;
 | 
			
		||||
            if ($rejected) {
 | 
			
		||||
                throw new InvalidArgumentException(
 | 
			
		||||
                    'Header values must be RFC 7230 compatible strings.'
 | 
			
		||||
                );
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @return static
 | 
			
		||||
     */
 | 
			
		||||
    public static function createFromGlobals()
 | 
			
		||||
    {
 | 
			
		||||
        $headers = null;
 | 
			
		||||
 | 
			
		||||
        if (function_exists('getallheaders')) {
 | 
			
		||||
            $headers = getallheaders();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!is_array($headers)) {
 | 
			
		||||
            $headers = [];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return new static($headers);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										90
									
								
								qwen/php/vendor/slim/psr7/src/Interfaces/HeadersInterface.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										90
									
								
								qwen/php/vendor/slim/psr7/src/Interfaces/HeadersInterface.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,90 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Psr7\Interfaces;
 | 
			
		||||
 | 
			
		||||
use InvalidArgumentException;
 | 
			
		||||
 | 
			
		||||
interface HeadersInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * Add header value
 | 
			
		||||
     *
 | 
			
		||||
     * This method appends the value to the existing array of values
 | 
			
		||||
     *
 | 
			
		||||
     * @param string       $name
 | 
			
		||||
     * @param array|string $value
 | 
			
		||||
     *
 | 
			
		||||
     * @return HeadersInterface
 | 
			
		||||
     *
 | 
			
		||||
     * @throws InvalidArgumentException
 | 
			
		||||
     */
 | 
			
		||||
    public function addHeader($name, $value): HeadersInterface;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Remove header value
 | 
			
		||||
     *
 | 
			
		||||
     * @param string $name
 | 
			
		||||
     * @return HeadersInterface
 | 
			
		||||
     */
 | 
			
		||||
    public function removeHeader(string $name): HeadersInterface;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get header value or values.
 | 
			
		||||
     * If the array has a single value it will return that single value.
 | 
			
		||||
     * If the array has multiple values, it will return an array of values.
 | 
			
		||||
     *
 | 
			
		||||
     * @param string   $name
 | 
			
		||||
     * @param string[] $default
 | 
			
		||||
     *
 | 
			
		||||
     * @return array
 | 
			
		||||
     */
 | 
			
		||||
    public function getHeader(string $name, $default = []): array;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Replaces the existing header value with the new value.
 | 
			
		||||
     *
 | 
			
		||||
     * @param string       $name
 | 
			
		||||
     * @param array|string $value
 | 
			
		||||
     *
 | 
			
		||||
     * @return HeadersInterface
 | 
			
		||||
     *
 | 
			
		||||
     * @throws InvalidArgumentException
 | 
			
		||||
     */
 | 
			
		||||
    public function setHeader($name, $value): HeadersInterface;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Replaces all existing headers with the new values.
 | 
			
		||||
     *
 | 
			
		||||
     * @param array $headers
 | 
			
		||||
     *
 | 
			
		||||
     * @return HeadersInterface
 | 
			
		||||
     *
 | 
			
		||||
     * @throws InvalidArgumentException
 | 
			
		||||
     */
 | 
			
		||||
    public function setHeaders(array $headers): HeadersInterface;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Is the header present in the stack.
 | 
			
		||||
     *
 | 
			
		||||
     * @param string $name
 | 
			
		||||
     * @return bool
 | 
			
		||||
     */
 | 
			
		||||
    public function hasHeader(string $name): bool;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Return all headers in the stack.
 | 
			
		||||
     *
 | 
			
		||||
     * @param bool $originalCase
 | 
			
		||||
     *
 | 
			
		||||
     * @return array
 | 
			
		||||
     */
 | 
			
		||||
    public function getHeaders(bool $originalCase): array;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										185
									
								
								qwen/php/vendor/slim/psr7/src/Message.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										185
									
								
								qwen/php/vendor/slim/psr7/src/Message.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,185 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Psr7;
 | 
			
		||||
 | 
			
		||||
use InvalidArgumentException;
 | 
			
		||||
use Psr\Http\Message\MessageInterface;
 | 
			
		||||
use Psr\Http\Message\StreamInterface;
 | 
			
		||||
use Slim\Psr7\Interfaces\HeadersInterface;
 | 
			
		||||
 | 
			
		||||
use function array_keys;
 | 
			
		||||
use function header;
 | 
			
		||||
use function header_remove;
 | 
			
		||||
use function implode;
 | 
			
		||||
use function sprintf;
 | 
			
		||||
 | 
			
		||||
abstract class Message implements MessageInterface
 | 
			
		||||
{
 | 
			
		||||
    protected string $protocolVersion = '1.1';
 | 
			
		||||
 | 
			
		||||
    protected static array $validProtocolVersions = [
 | 
			
		||||
        '1.0' => true,
 | 
			
		||||
        '1.1' => true,
 | 
			
		||||
        '2.0' => true,
 | 
			
		||||
        '2' => true,
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var HeadersInterface
 | 
			
		||||
     */
 | 
			
		||||
    protected $headers;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var StreamInterface
 | 
			
		||||
     */
 | 
			
		||||
    protected $body;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Disable magic setter to ensure immutability
 | 
			
		||||
     *
 | 
			
		||||
     * @param string $name  The property name
 | 
			
		||||
     * @param mixed  $value The property value
 | 
			
		||||
     *
 | 
			
		||||
     * @return void
 | 
			
		||||
     */
 | 
			
		||||
    public function __set($name, $value): void
 | 
			
		||||
    {
 | 
			
		||||
        // Do nothing
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getProtocolVersion(): string
 | 
			
		||||
    {
 | 
			
		||||
        return $this->protocolVersion;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @return static
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function withProtocolVersion($version): MessageInterface
 | 
			
		||||
    {
 | 
			
		||||
        if (!isset(self::$validProtocolVersions[$version])) {
 | 
			
		||||
            throw new InvalidArgumentException(
 | 
			
		||||
                'Invalid HTTP version. Must be one of: '
 | 
			
		||||
                . implode(', ', array_keys(self::$validProtocolVersions))
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $clone = clone $this;
 | 
			
		||||
        $clone->protocolVersion = $version;
 | 
			
		||||
 | 
			
		||||
        return $clone;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getHeaders(): array
 | 
			
		||||
    {
 | 
			
		||||
        return $this->headers->getHeaders(true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function hasHeader($name): bool
 | 
			
		||||
    {
 | 
			
		||||
        return $this->headers->hasHeader($name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getHeader($name): array
 | 
			
		||||
    {
 | 
			
		||||
        return $this->headers->getHeader($name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getHeaderLine($name): string
 | 
			
		||||
    {
 | 
			
		||||
        $values = $this->headers->getHeader($name);
 | 
			
		||||
        return implode(',', $values);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @return static
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function withHeader($name, $value): MessageInterface
 | 
			
		||||
    {
 | 
			
		||||
        $clone = clone $this;
 | 
			
		||||
        $clone->headers->setHeader($name, $value);
 | 
			
		||||
 | 
			
		||||
        if ($this instanceof Response && $this->body instanceof NonBufferedBody) {
 | 
			
		||||
            header(sprintf('%s: %s', $name, $clone->getHeaderLine($name)));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $clone;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @return static
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function withAddedHeader($name, $value): MessageInterface
 | 
			
		||||
    {
 | 
			
		||||
        $clone = clone $this;
 | 
			
		||||
        $clone->headers->addHeader($name, $value);
 | 
			
		||||
 | 
			
		||||
        if ($this instanceof Response && $this->body instanceof NonBufferedBody) {
 | 
			
		||||
            header(sprintf('%s: %s', $name, $clone->getHeaderLine($name)));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $clone;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @return static
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function withoutHeader($name): MessageInterface
 | 
			
		||||
    {
 | 
			
		||||
        $clone = clone $this;
 | 
			
		||||
        $clone->headers->removeHeader($name);
 | 
			
		||||
 | 
			
		||||
        if ($this instanceof Response && $this->body instanceof NonBufferedBody) {
 | 
			
		||||
            header_remove($name);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $clone;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getBody(): StreamInterface
 | 
			
		||||
    {
 | 
			
		||||
        return $this->body;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @return static
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function withBody(StreamInterface $body): MessageInterface
 | 
			
		||||
    {
 | 
			
		||||
        $clone = clone $this;
 | 
			
		||||
        $clone->body = $body;
 | 
			
		||||
 | 
			
		||||
        return $clone;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										153
									
								
								qwen/php/vendor/slim/psr7/src/NonBufferedBody.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										153
									
								
								qwen/php/vendor/slim/psr7/src/NonBufferedBody.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,153 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Psr7;
 | 
			
		||||
 | 
			
		||||
use Psr\Http\Message\StreamInterface;
 | 
			
		||||
use RuntimeException;
 | 
			
		||||
 | 
			
		||||
use function flush;
 | 
			
		||||
use function ob_get_clean;
 | 
			
		||||
use function ob_get_level;
 | 
			
		||||
use function strlen;
 | 
			
		||||
 | 
			
		||||
use const SEEK_SET;
 | 
			
		||||
 | 
			
		||||
class NonBufferedBody implements StreamInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function __toString(): string
 | 
			
		||||
    {
 | 
			
		||||
        return '';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function close(): void
 | 
			
		||||
    {
 | 
			
		||||
        throw new RuntimeException('A NonBufferedBody is not closable.');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function detach()
 | 
			
		||||
    {
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getSize(): ?int
 | 
			
		||||
    {
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function tell(): int
 | 
			
		||||
    {
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function eof(): bool
 | 
			
		||||
    {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function isSeekable(): bool
 | 
			
		||||
    {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function seek($offset, $whence = SEEK_SET): void
 | 
			
		||||
    {
 | 
			
		||||
        throw new RuntimeException('A NonBufferedBody is not seekable.');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function rewind(): void
 | 
			
		||||
    {
 | 
			
		||||
        throw new RuntimeException('A NonBufferedBody is not rewindable.');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function isWritable(): bool
 | 
			
		||||
    {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function write($string): int
 | 
			
		||||
    {
 | 
			
		||||
        $buffered = '';
 | 
			
		||||
        while (0 < ob_get_level()) {
 | 
			
		||||
            $buffered = ob_get_clean() . $buffered;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        echo $buffered . $string;
 | 
			
		||||
 | 
			
		||||
        flush();
 | 
			
		||||
 | 
			
		||||
        return strlen($string) + strlen($buffered);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function isReadable(): bool
 | 
			
		||||
    {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function read($length): string
 | 
			
		||||
    {
 | 
			
		||||
        throw new RuntimeException('A NonBufferedBody is not readable.');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getContents(): string
 | 
			
		||||
    {
 | 
			
		||||
        return '';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getMetadata($key = null): ?array
 | 
			
		||||
    {
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										382
									
								
								qwen/php/vendor/slim/psr7/src/Request.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										382
									
								
								qwen/php/vendor/slim/psr7/src/Request.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,382 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Psr7;
 | 
			
		||||
 | 
			
		||||
use InvalidArgumentException;
 | 
			
		||||
use Psr\Http\Message\RequestInterface;
 | 
			
		||||
use Psr\Http\Message\ServerRequestInterface;
 | 
			
		||||
use Psr\Http\Message\StreamInterface;
 | 
			
		||||
use Psr\Http\Message\UploadedFileInterface;
 | 
			
		||||
use Psr\Http\Message\UriInterface;
 | 
			
		||||
use Slim\Psr7\Interfaces\HeadersInterface;
 | 
			
		||||
 | 
			
		||||
use function get_class;
 | 
			
		||||
use function gettype;
 | 
			
		||||
use function is_array;
 | 
			
		||||
use function is_null;
 | 
			
		||||
use function is_object;
 | 
			
		||||
use function is_string;
 | 
			
		||||
use function ltrim;
 | 
			
		||||
use function parse_str;
 | 
			
		||||
use function preg_match;
 | 
			
		||||
use function sprintf;
 | 
			
		||||
use function str_replace;
 | 
			
		||||
 | 
			
		||||
class Request extends Message implements ServerRequestInterface
 | 
			
		||||
{
 | 
			
		||||
    protected string $method;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var UriInterface
 | 
			
		||||
     */
 | 
			
		||||
    protected $uri;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var string
 | 
			
		||||
     */
 | 
			
		||||
    protected $requestTarget;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var ?array
 | 
			
		||||
     */
 | 
			
		||||
    protected $queryParams;
 | 
			
		||||
 | 
			
		||||
    protected array $cookies;
 | 
			
		||||
 | 
			
		||||
    protected array $serverParams;
 | 
			
		||||
 | 
			
		||||
    protected array $attributes;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var null|array|object
 | 
			
		||||
     */
 | 
			
		||||
    protected $parsedBody;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var UploadedFileInterface[]
 | 
			
		||||
     */
 | 
			
		||||
    protected array $uploadedFiles;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param string           $method        The request method
 | 
			
		||||
     * @param UriInterface     $uri           The request URI object
 | 
			
		||||
     * @param HeadersInterface $headers       The request headers collection
 | 
			
		||||
     * @param array            $cookies       The request cookies collection
 | 
			
		||||
     * @param array            $serverParams  The server environment variables
 | 
			
		||||
     * @param StreamInterface  $body          The request body object
 | 
			
		||||
     * @param array            $uploadedFiles The request uploadedFiles collection
 | 
			
		||||
     * @throws InvalidArgumentException on invalid HTTP method
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        $method,
 | 
			
		||||
        UriInterface $uri,
 | 
			
		||||
        HeadersInterface $headers,
 | 
			
		||||
        array $cookies,
 | 
			
		||||
        array $serverParams,
 | 
			
		||||
        StreamInterface $body,
 | 
			
		||||
        array $uploadedFiles = []
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->method = $this->filterMethod($method);
 | 
			
		||||
        $this->uri = $uri;
 | 
			
		||||
        $this->headers = $headers;
 | 
			
		||||
        $this->cookies = $cookies;
 | 
			
		||||
        $this->serverParams = $serverParams;
 | 
			
		||||
        $this->attributes = [];
 | 
			
		||||
        $this->body = $body;
 | 
			
		||||
        $this->uploadedFiles = $uploadedFiles;
 | 
			
		||||
 | 
			
		||||
        if (isset($serverParams['SERVER_PROTOCOL'])) {
 | 
			
		||||
            $this->protocolVersion = str_replace('HTTP/', '', $serverParams['SERVER_PROTOCOL']);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!$this->headers->hasHeader('Host') || $this->uri->getHost() !== '') {
 | 
			
		||||
            $this->headers->setHeader('Host', $this->uri->getHost());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method is applied to the cloned object after PHP performs an initial shallow-copy.
 | 
			
		||||
     * This method completes a deep-copy by creating new objects for the cloned object's internal reference pointers.
 | 
			
		||||
     */
 | 
			
		||||
    public function __clone()
 | 
			
		||||
    {
 | 
			
		||||
        $this->headers = clone $this->headers;
 | 
			
		||||
        $this->body = clone $this->body;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getMethod(): string
 | 
			
		||||
    {
 | 
			
		||||
        return $this->method;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     * @return static
 | 
			
		||||
     */
 | 
			
		||||
    public function withMethod($method): RequestInterface
 | 
			
		||||
    {
 | 
			
		||||
        $method = $this->filterMethod($method);
 | 
			
		||||
        $clone = clone $this;
 | 
			
		||||
        $clone->method = $method;
 | 
			
		||||
 | 
			
		||||
        return $clone;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Validate the HTTP method
 | 
			
		||||
     *
 | 
			
		||||
     * @param  string $method
 | 
			
		||||
     *
 | 
			
		||||
     * @return string
 | 
			
		||||
     *
 | 
			
		||||
     * @throws InvalidArgumentException on invalid HTTP method.
 | 
			
		||||
     */
 | 
			
		||||
    protected function filterMethod($method): string
 | 
			
		||||
    {
 | 
			
		||||
        /** @var mixed $method */
 | 
			
		||||
        if (!is_string($method)) {
 | 
			
		||||
            throw new InvalidArgumentException(sprintf(
 | 
			
		||||
                'Unsupported HTTP method; must be a string, received %s',
 | 
			
		||||
                (is_object($method) ? get_class($method) : gettype($method))
 | 
			
		||||
            ));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (preg_match("/^[!#$%&'*+.^_`|~0-9a-z-]+$/i", $method) !== 1) {
 | 
			
		||||
            throw new InvalidArgumentException(sprintf(
 | 
			
		||||
                'Unsupported HTTP method "%s" provided',
 | 
			
		||||
                $method
 | 
			
		||||
            ));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $method;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getRequestTarget(): string
 | 
			
		||||
    {
 | 
			
		||||
        if ($this->requestTarget) {
 | 
			
		||||
            return $this->requestTarget;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if ($this->uri === null) {
 | 
			
		||||
            return '/';
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $path = $this->uri->getPath();
 | 
			
		||||
        $path = '/' . ltrim($path, '/');
 | 
			
		||||
 | 
			
		||||
        $query = $this->uri->getQuery();
 | 
			
		||||
        if ($query) {
 | 
			
		||||
            $path .= '?' . $query;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $path;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     * @return static
 | 
			
		||||
     */
 | 
			
		||||
    public function withRequestTarget($requestTarget): RequestInterface
 | 
			
		||||
    {
 | 
			
		||||
        if (!is_string($requestTarget) || preg_match('#\s#', $requestTarget)) {
 | 
			
		||||
            throw new InvalidArgumentException(
 | 
			
		||||
                'Invalid request target provided; must be a string and cannot contain whitespace'
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $clone = clone $this;
 | 
			
		||||
        $clone->requestTarget = $requestTarget;
 | 
			
		||||
 | 
			
		||||
        return $clone;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getUri(): UriInterface
 | 
			
		||||
    {
 | 
			
		||||
        return $this->uri;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     * @return static
 | 
			
		||||
     */
 | 
			
		||||
    public function withUri(UriInterface $uri, $preserveHost = false): RequestInterface
 | 
			
		||||
    {
 | 
			
		||||
        $clone = clone $this;
 | 
			
		||||
        $clone->uri = $uri;
 | 
			
		||||
 | 
			
		||||
        if (!$preserveHost && $uri->getHost() !== '') {
 | 
			
		||||
            $clone->headers->setHeader('Host', $uri->getHost());
 | 
			
		||||
            return $clone;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (($uri->getHost() !== '' && !$this->hasHeader('Host') || $this->getHeaderLine('Host') === '')) {
 | 
			
		||||
            $clone->headers->setHeader('Host', $uri->getHost());
 | 
			
		||||
            return $clone;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $clone;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getCookieParams(): array
 | 
			
		||||
    {
 | 
			
		||||
        return $this->cookies;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     * @return static
 | 
			
		||||
     */
 | 
			
		||||
    public function withCookieParams(array $cookies): ServerRequestInterface
 | 
			
		||||
    {
 | 
			
		||||
        $clone = clone $this;
 | 
			
		||||
        $clone->cookies = $cookies;
 | 
			
		||||
 | 
			
		||||
        return $clone;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getQueryParams(): array
 | 
			
		||||
    {
 | 
			
		||||
        if (is_array($this->queryParams)) {
 | 
			
		||||
            return $this->queryParams;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if ($this->uri === null) {
 | 
			
		||||
            return [];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Decode URL data
 | 
			
		||||
        parse_str($this->uri->getQuery(), $this->queryParams);
 | 
			
		||||
 | 
			
		||||
        return is_array($this->queryParams) ? $this->queryParams : [];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     * @return static
 | 
			
		||||
     */
 | 
			
		||||
    public function withQueryParams(array $query): ServerRequestInterface
 | 
			
		||||
    {
 | 
			
		||||
        $clone = clone $this;
 | 
			
		||||
        $clone->queryParams = $query;
 | 
			
		||||
 | 
			
		||||
        return $clone;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getUploadedFiles(): array
 | 
			
		||||
    {
 | 
			
		||||
        return $this->uploadedFiles;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     * @return static
 | 
			
		||||
     */
 | 
			
		||||
    public function withUploadedFiles(array $uploadedFiles): ServerRequestInterface
 | 
			
		||||
    {
 | 
			
		||||
        $clone = clone $this;
 | 
			
		||||
        $clone->uploadedFiles = $uploadedFiles;
 | 
			
		||||
 | 
			
		||||
        return $clone;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getServerParams(): array
 | 
			
		||||
    {
 | 
			
		||||
        return $this->serverParams;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getAttributes(): array
 | 
			
		||||
    {
 | 
			
		||||
        return $this->attributes;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     * @return mixed
 | 
			
		||||
     */
 | 
			
		||||
    public function getAttribute($name, $default = null)
 | 
			
		||||
    {
 | 
			
		||||
        return $this->attributes[$name] ?? $default;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     * @return static
 | 
			
		||||
     */
 | 
			
		||||
    public function withAttribute($name, $value): ServerRequestInterface
 | 
			
		||||
    {
 | 
			
		||||
        $clone = clone $this;
 | 
			
		||||
        $clone->attributes[$name] = $value;
 | 
			
		||||
 | 
			
		||||
        return $clone;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     * @return static
 | 
			
		||||
     */
 | 
			
		||||
    public function withoutAttribute($name): ServerRequestInterface
 | 
			
		||||
    {
 | 
			
		||||
        $clone = clone $this;
 | 
			
		||||
 | 
			
		||||
        unset($clone->attributes[$name]);
 | 
			
		||||
 | 
			
		||||
        return $clone;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getParsedBody()
 | 
			
		||||
    {
 | 
			
		||||
        return $this->parsedBody;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     * @return static
 | 
			
		||||
     */
 | 
			
		||||
    public function withParsedBody($data): ServerRequestInterface
 | 
			
		||||
    {
 | 
			
		||||
        /** @var mixed $data */
 | 
			
		||||
        if (!is_null($data) && !is_object($data) && !is_array($data)) {
 | 
			
		||||
            throw new InvalidArgumentException('Parsed body value must be an array, an object, or null');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $clone = clone $this;
 | 
			
		||||
        $clone->parsedBody = $data;
 | 
			
		||||
 | 
			
		||||
        return $clone;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										216
									
								
								qwen/php/vendor/slim/psr7/src/Response.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										216
									
								
								qwen/php/vendor/slim/psr7/src/Response.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,216 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Psr7;
 | 
			
		||||
 | 
			
		||||
use Fig\Http\Message\StatusCodeInterface;
 | 
			
		||||
use InvalidArgumentException;
 | 
			
		||||
use Psr\Http\Message\ResponseInterface;
 | 
			
		||||
use Psr\Http\Message\StreamInterface;
 | 
			
		||||
use Slim\Psr7\Factory\StreamFactory;
 | 
			
		||||
use Slim\Psr7\Interfaces\HeadersInterface;
 | 
			
		||||
 | 
			
		||||
use function is_integer;
 | 
			
		||||
use function is_object;
 | 
			
		||||
use function is_string;
 | 
			
		||||
use function method_exists;
 | 
			
		||||
 | 
			
		||||
class Response extends Message implements ResponseInterface
 | 
			
		||||
{
 | 
			
		||||
    protected int $status = StatusCodeInterface::STATUS_OK;
 | 
			
		||||
 | 
			
		||||
    protected string $reasonPhrase = '';
 | 
			
		||||
 | 
			
		||||
    protected static array $messages = [
 | 
			
		||||
        // Informational 1xx
 | 
			
		||||
        StatusCodeInterface::STATUS_CONTINUE => 'Continue',
 | 
			
		||||
        StatusCodeInterface::STATUS_SWITCHING_PROTOCOLS => 'Switching Protocols',
 | 
			
		||||
        StatusCodeInterface::STATUS_PROCESSING => 'Processing',
 | 
			
		||||
 | 
			
		||||
        // Successful 2xx
 | 
			
		||||
        StatusCodeInterface::STATUS_OK => 'OK',
 | 
			
		||||
        StatusCodeInterface::STATUS_CREATED => 'Created',
 | 
			
		||||
        StatusCodeInterface::STATUS_ACCEPTED => 'Accepted',
 | 
			
		||||
        StatusCodeInterface::STATUS_NON_AUTHORITATIVE_INFORMATION => 'Non-Authoritative Information',
 | 
			
		||||
        StatusCodeInterface::STATUS_NO_CONTENT => 'No Content',
 | 
			
		||||
        StatusCodeInterface::STATUS_RESET_CONTENT => 'Reset Content',
 | 
			
		||||
        StatusCodeInterface::STATUS_PARTIAL_CONTENT => 'Partial Content',
 | 
			
		||||
        StatusCodeInterface::STATUS_MULTI_STATUS => 'Multi-Status',
 | 
			
		||||
        StatusCodeInterface::STATUS_ALREADY_REPORTED => 'Already Reported',
 | 
			
		||||
        StatusCodeInterface::STATUS_IM_USED => 'IM Used',
 | 
			
		||||
 | 
			
		||||
        // Redirection 3xx
 | 
			
		||||
        StatusCodeInterface::STATUS_MULTIPLE_CHOICES => 'Multiple Choices',
 | 
			
		||||
        StatusCodeInterface::STATUS_MOVED_PERMANENTLY => 'Moved Permanently',
 | 
			
		||||
        StatusCodeInterface::STATUS_FOUND => 'Found',
 | 
			
		||||
        StatusCodeInterface::STATUS_SEE_OTHER => 'See Other',
 | 
			
		||||
        StatusCodeInterface::STATUS_NOT_MODIFIED => 'Not Modified',
 | 
			
		||||
        StatusCodeInterface::STATUS_USE_PROXY => 'Use Proxy',
 | 
			
		||||
        StatusCodeInterface::STATUS_RESERVED => '(Unused)',
 | 
			
		||||
        StatusCodeInterface::STATUS_TEMPORARY_REDIRECT => 'Temporary Redirect',
 | 
			
		||||
        StatusCodeInterface::STATUS_PERMANENT_REDIRECT => 'Permanent Redirect',
 | 
			
		||||
 | 
			
		||||
        // Client Error 4xx
 | 
			
		||||
        StatusCodeInterface::STATUS_BAD_REQUEST => 'Bad Request',
 | 
			
		||||
        StatusCodeInterface::STATUS_UNAUTHORIZED => 'Unauthorized',
 | 
			
		||||
        StatusCodeInterface::STATUS_PAYMENT_REQUIRED => 'Payment Required',
 | 
			
		||||
        StatusCodeInterface::STATUS_FORBIDDEN => 'Forbidden',
 | 
			
		||||
        StatusCodeInterface::STATUS_NOT_FOUND => 'Not Found',
 | 
			
		||||
        StatusCodeInterface::STATUS_METHOD_NOT_ALLOWED => 'Method Not Allowed',
 | 
			
		||||
        StatusCodeInterface::STATUS_NOT_ACCEPTABLE => 'Not Acceptable',
 | 
			
		||||
        StatusCodeInterface::STATUS_PROXY_AUTHENTICATION_REQUIRED => 'Proxy Authentication Required',
 | 
			
		||||
        StatusCodeInterface::STATUS_REQUEST_TIMEOUT => 'Request Timeout',
 | 
			
		||||
        StatusCodeInterface::STATUS_CONFLICT => 'Conflict',
 | 
			
		||||
        StatusCodeInterface::STATUS_GONE => 'Gone',
 | 
			
		||||
        StatusCodeInterface::STATUS_LENGTH_REQUIRED => 'Length Required',
 | 
			
		||||
        StatusCodeInterface::STATUS_PRECONDITION_FAILED => 'Precondition Failed',
 | 
			
		||||
        StatusCodeInterface::STATUS_PAYLOAD_TOO_LARGE => 'Request Entity Too Large',
 | 
			
		||||
        StatusCodeInterface::STATUS_URI_TOO_LONG => 'Request-URI Too Long',
 | 
			
		||||
        StatusCodeInterface::STATUS_UNSUPPORTED_MEDIA_TYPE => 'Unsupported Media Type',
 | 
			
		||||
        StatusCodeInterface::STATUS_RANGE_NOT_SATISFIABLE => 'Requested Range Not Satisfiable',
 | 
			
		||||
        StatusCodeInterface::STATUS_EXPECTATION_FAILED => 'Expectation Failed',
 | 
			
		||||
        StatusCodeInterface::STATUS_IM_A_TEAPOT => 'I\'m a teapot',
 | 
			
		||||
        StatusCodeInterface::STATUS_MISDIRECTED_REQUEST => 'Misdirected Request',
 | 
			
		||||
        StatusCodeInterface::STATUS_UNPROCESSABLE_ENTITY => 'Unprocessable Entity',
 | 
			
		||||
        StatusCodeInterface::STATUS_LOCKED => 'Locked',
 | 
			
		||||
        StatusCodeInterface::STATUS_FAILED_DEPENDENCY => 'Failed Dependency',
 | 
			
		||||
        StatusCodeInterface::STATUS_UPGRADE_REQUIRED => 'Upgrade Required',
 | 
			
		||||
        StatusCodeInterface::STATUS_PRECONDITION_REQUIRED => 'Precondition Required',
 | 
			
		||||
        StatusCodeInterface::STATUS_TOO_MANY_REQUESTS => 'Too Many Requests',
 | 
			
		||||
        StatusCodeInterface::STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE => 'Request Header Fields Too Large',
 | 
			
		||||
        444 => 'Connection Closed Without Response',
 | 
			
		||||
        StatusCodeInterface::STATUS_UNAVAILABLE_FOR_LEGAL_REASONS => 'Unavailable For Legal Reasons',
 | 
			
		||||
        499 => 'Client Closed Request',
 | 
			
		||||
 | 
			
		||||
        // Server Error 5xx
 | 
			
		||||
        StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR => 'Internal Server Error',
 | 
			
		||||
        StatusCodeInterface::STATUS_NOT_IMPLEMENTED => 'Not Implemented',
 | 
			
		||||
        StatusCodeInterface::STATUS_BAD_GATEWAY => 'Bad Gateway',
 | 
			
		||||
        StatusCodeInterface::STATUS_SERVICE_UNAVAILABLE => 'Service Unavailable',
 | 
			
		||||
        StatusCodeInterface::STATUS_GATEWAY_TIMEOUT => 'Gateway Timeout',
 | 
			
		||||
        StatusCodeInterface::STATUS_VERSION_NOT_SUPPORTED => 'HTTP Version Not Supported',
 | 
			
		||||
        StatusCodeInterface::STATUS_VARIANT_ALSO_NEGOTIATES => 'Variant Also Negotiates',
 | 
			
		||||
        StatusCodeInterface::STATUS_INSUFFICIENT_STORAGE => 'Insufficient Storage',
 | 
			
		||||
        StatusCodeInterface::STATUS_LOOP_DETECTED => 'Loop Detected',
 | 
			
		||||
        StatusCodeInterface::STATUS_NOT_EXTENDED => 'Not Extended',
 | 
			
		||||
        StatusCodeInterface::STATUS_NETWORK_AUTHENTICATION_REQUIRED => 'Network Authentication Required',
 | 
			
		||||
        599 => 'Network Connect Timeout Error',
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param int                   $status  The response status code.
 | 
			
		||||
     * @param HeadersInterface|null $headers The response headers.
 | 
			
		||||
     * @param StreamInterface|null  $body    The response body.
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        int $status = StatusCodeInterface::STATUS_OK,
 | 
			
		||||
        ?HeadersInterface $headers = null,
 | 
			
		||||
        ?StreamInterface $body = null
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->status = $this->filterStatus($status);
 | 
			
		||||
        $this->headers = $headers ?: new Headers([], []);
 | 
			
		||||
        $this->body = $body ?: (new StreamFactory())->createStream();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method is applied to the cloned object after PHP performs an initial shallow-copy.
 | 
			
		||||
     * This method completes a deep-copy by creating new objects for the cloned object's internal reference pointers.
 | 
			
		||||
     */
 | 
			
		||||
    public function __clone()
 | 
			
		||||
    {
 | 
			
		||||
        $this->headers = clone $this->headers;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getStatusCode(): int
 | 
			
		||||
    {
 | 
			
		||||
        return $this->status;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     * @return static
 | 
			
		||||
     */
 | 
			
		||||
    public function withStatus($code, $reasonPhrase = ''): ResponseInterface
 | 
			
		||||
    {
 | 
			
		||||
        $code = $this->filterStatus($code);
 | 
			
		||||
        $reasonPhrase = $this->filterReasonPhrase($reasonPhrase);
 | 
			
		||||
 | 
			
		||||
        $clone = clone $this;
 | 
			
		||||
        $clone->status = $code;
 | 
			
		||||
        $clone->reasonPhrase = $reasonPhrase;
 | 
			
		||||
 | 
			
		||||
        return $clone;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getReasonPhrase(): string
 | 
			
		||||
    {
 | 
			
		||||
        if ($this->reasonPhrase !== '') {
 | 
			
		||||
            return $this->reasonPhrase;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (isset(static::$messages[$this->status])) {
 | 
			
		||||
            return static::$messages[$this->status];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return '';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Filter HTTP status code.
 | 
			
		||||
     *
 | 
			
		||||
     * @param  int $status HTTP status code.
 | 
			
		||||
     *
 | 
			
		||||
     * @return int
 | 
			
		||||
     *
 | 
			
		||||
     * @throws InvalidArgumentException If an invalid HTTP status code is provided.
 | 
			
		||||
     */
 | 
			
		||||
    protected function filterStatus($status): int
 | 
			
		||||
    {
 | 
			
		||||
        if (!is_integer($status) || $status < StatusCodeInterface::STATUS_CONTINUE || $status > 599) {
 | 
			
		||||
            throw new InvalidArgumentException('Invalid HTTP status code.');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $status;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Filter Reason Phrase
 | 
			
		||||
     *
 | 
			
		||||
     * @param mixed $reasonPhrase
 | 
			
		||||
     *
 | 
			
		||||
     * @return string
 | 
			
		||||
     *
 | 
			
		||||
     * @throws InvalidArgumentException
 | 
			
		||||
     */
 | 
			
		||||
    protected function filterReasonPhrase($reasonPhrase = ''): string
 | 
			
		||||
    {
 | 
			
		||||
        if (is_object($reasonPhrase) && method_exists($reasonPhrase, '__toString')) {
 | 
			
		||||
            $reasonPhrase = (string) $reasonPhrase;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!is_string($reasonPhrase)) {
 | 
			
		||||
            throw new InvalidArgumentException('Response reason phrase must be a string.');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (strpos($reasonPhrase, "\r") !== false || strpos($reasonPhrase, "\n") !== false) {
 | 
			
		||||
            throw new InvalidArgumentException(
 | 
			
		||||
                'Reason phrase contains one of the following prohibited characters: \r \n'
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $reasonPhrase;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										396
									
								
								qwen/php/vendor/slim/psr7/src/Stream.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										396
									
								
								qwen/php/vendor/slim/psr7/src/Stream.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,396 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Psr7;
 | 
			
		||||
 | 
			
		||||
use InvalidArgumentException;
 | 
			
		||||
use Psr\Http\Message\StreamInterface;
 | 
			
		||||
use RuntimeException;
 | 
			
		||||
 | 
			
		||||
use function fclose;
 | 
			
		||||
use function feof;
 | 
			
		||||
use function fread;
 | 
			
		||||
use function fseek;
 | 
			
		||||
use function fstat;
 | 
			
		||||
use function ftell;
 | 
			
		||||
use function fwrite;
 | 
			
		||||
use function is_array;
 | 
			
		||||
use function is_resource;
 | 
			
		||||
use function is_string;
 | 
			
		||||
use function pclose;
 | 
			
		||||
use function rewind;
 | 
			
		||||
use function stream_get_contents;
 | 
			
		||||
use function stream_get_meta_data;
 | 
			
		||||
use function strstr;
 | 
			
		||||
 | 
			
		||||
use const SEEK_SET;
 | 
			
		||||
 | 
			
		||||
class Stream implements StreamInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * Bit mask to determine if the stream is a pipe
 | 
			
		||||
     *
 | 
			
		||||
     * This is octal as per header stat.h
 | 
			
		||||
     */
 | 
			
		||||
    public const FSTAT_MODE_S_IFIFO = 0010000;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The underlying stream resource
 | 
			
		||||
     *
 | 
			
		||||
     * @var resource|null
 | 
			
		||||
     */
 | 
			
		||||
    protected $stream;
 | 
			
		||||
 | 
			
		||||
    protected ?array $meta;
 | 
			
		||||
 | 
			
		||||
    protected ?bool $readable = null;
 | 
			
		||||
 | 
			
		||||
    protected ?bool $writable = null;
 | 
			
		||||
 | 
			
		||||
    protected ?bool $seekable = null;
 | 
			
		||||
 | 
			
		||||
    protected ?int $size = null;
 | 
			
		||||
 | 
			
		||||
    protected ?bool $isPipe = null;
 | 
			
		||||
 | 
			
		||||
    protected bool $finished = false;
 | 
			
		||||
 | 
			
		||||
    protected ?StreamInterface $cache;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param resource             $stream A PHP resource handle.
 | 
			
		||||
     * @param StreamInterface|null $cache  A stream to cache $stream (useful for non-seekable streams)
 | 
			
		||||
     *
 | 
			
		||||
     * @throws InvalidArgumentException If argument is not a resource.
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct($stream, ?StreamInterface $cache = null)
 | 
			
		||||
    {
 | 
			
		||||
        $this->attach($stream);
 | 
			
		||||
 | 
			
		||||
        if ($cache && (!$cache->isSeekable() || !$cache->isWritable())) {
 | 
			
		||||
            throw new RuntimeException('Cache stream must be seekable and writable');
 | 
			
		||||
        }
 | 
			
		||||
        $this->cache = $cache;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     * @return array|mixed
 | 
			
		||||
     */
 | 
			
		||||
    public function getMetadata($key = null)
 | 
			
		||||
    {
 | 
			
		||||
        if (!$this->stream) {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $this->meta = stream_get_meta_data($this->stream);
 | 
			
		||||
 | 
			
		||||
        if (!$key) {
 | 
			
		||||
            return $this->meta;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $this->meta[$key] ?? null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Attach new resource to this object.
 | 
			
		||||
     *
 | 
			
		||||
     * @internal This method is not part of the PSR-7 standard.
 | 
			
		||||
     *
 | 
			
		||||
     * @param resource $stream A PHP resource handle.
 | 
			
		||||
     *
 | 
			
		||||
     * @throws InvalidArgumentException If argument is not a valid PHP resource.
 | 
			
		||||
     *
 | 
			
		||||
     * @return void
 | 
			
		||||
     */
 | 
			
		||||
    protected function attach($stream): void
 | 
			
		||||
    {
 | 
			
		||||
        if (!is_resource($stream)) {
 | 
			
		||||
            throw new InvalidArgumentException(__METHOD__ . ' argument must be a valid PHP resource');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if ($this->stream) {
 | 
			
		||||
            $this->detach();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $this->stream = $stream;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function detach()
 | 
			
		||||
    {
 | 
			
		||||
        $oldResource = $this->stream;
 | 
			
		||||
        $this->stream = null;
 | 
			
		||||
        $this->meta = null;
 | 
			
		||||
        $this->readable = null;
 | 
			
		||||
        $this->writable = null;
 | 
			
		||||
        $this->seekable = null;
 | 
			
		||||
        $this->size = null;
 | 
			
		||||
        $this->isPipe = null;
 | 
			
		||||
 | 
			
		||||
        $this->cache = null;
 | 
			
		||||
        $this->finished = false;
 | 
			
		||||
 | 
			
		||||
        return $oldResource;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function __toString(): string
 | 
			
		||||
    {
 | 
			
		||||
        if (!$this->stream) {
 | 
			
		||||
            return '';
 | 
			
		||||
        }
 | 
			
		||||
        if ($this->cache && $this->finished) {
 | 
			
		||||
            $this->cache->rewind();
 | 
			
		||||
            return $this->cache->getContents();
 | 
			
		||||
        }
 | 
			
		||||
        if ($this->isSeekable()) {
 | 
			
		||||
            $this->rewind();
 | 
			
		||||
        }
 | 
			
		||||
        return $this->getContents();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function close(): void
 | 
			
		||||
    {
 | 
			
		||||
        if ($this->stream) {
 | 
			
		||||
            if ($this->isPipe()) {
 | 
			
		||||
                pclose($this->stream);
 | 
			
		||||
            } else {
 | 
			
		||||
                fclose($this->stream);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $this->detach();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getSize(): ?int
 | 
			
		||||
    {
 | 
			
		||||
        if ($this->stream && !$this->size) {
 | 
			
		||||
            $stats = fstat($this->stream);
 | 
			
		||||
 | 
			
		||||
            if ($stats) {
 | 
			
		||||
                $this->size = !$this->isPipe() ? $stats['size'] : null;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $this->size;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function tell(): int
 | 
			
		||||
    {
 | 
			
		||||
        $position = false;
 | 
			
		||||
 | 
			
		||||
        if ($this->stream) {
 | 
			
		||||
            $position = ftell($this->stream);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if ($position === false || $this->isPipe()) {
 | 
			
		||||
            throw new RuntimeException('Could not get the position of the pointer in stream.');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $position;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function eof(): bool
 | 
			
		||||
    {
 | 
			
		||||
        return !$this->stream || feof($this->stream);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function isReadable(): bool
 | 
			
		||||
    {
 | 
			
		||||
        if ($this->readable !== null) {
 | 
			
		||||
            return $this->readable;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $this->readable = false;
 | 
			
		||||
 | 
			
		||||
        if ($this->stream) {
 | 
			
		||||
            $mode = $this->getMetadata('mode');
 | 
			
		||||
 | 
			
		||||
            if (is_string($mode) && (strstr($mode, 'r') !== false || strstr($mode, '+') !== false)) {
 | 
			
		||||
                $this->readable = true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $this->readable;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function isWritable(): bool
 | 
			
		||||
    {
 | 
			
		||||
        if ($this->writable === null) {
 | 
			
		||||
            $this->writable = false;
 | 
			
		||||
 | 
			
		||||
            if ($this->stream) {
 | 
			
		||||
                $mode = $this->getMetadata('mode');
 | 
			
		||||
 | 
			
		||||
                if (is_string($mode) && (strstr($mode, 'w') !== false || strstr($mode, '+') !== false)) {
 | 
			
		||||
                    $this->writable = true;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $this->writable;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function isSeekable(): bool
 | 
			
		||||
    {
 | 
			
		||||
        if ($this->seekable === null) {
 | 
			
		||||
            $this->seekable = false;
 | 
			
		||||
 | 
			
		||||
            if ($this->stream) {
 | 
			
		||||
                $this->seekable = !$this->isPipe() && $this->getMetadata('seekable');
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $this->seekable;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function seek($offset, $whence = SEEK_SET): void
 | 
			
		||||
    {
 | 
			
		||||
        if (!$this->isSeekable() || $this->stream && fseek($this->stream, $offset, $whence) === -1) {
 | 
			
		||||
            throw new RuntimeException('Could not seek in stream.');
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function rewind(): void
 | 
			
		||||
    {
 | 
			
		||||
        if (!$this->isSeekable() || $this->stream && rewind($this->stream) === false) {
 | 
			
		||||
            throw new RuntimeException('Could not rewind stream.');
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function read($length): string
 | 
			
		||||
    {
 | 
			
		||||
        $data = false;
 | 
			
		||||
 | 
			
		||||
        if ($this->isReadable() && $this->stream && $length > 0) {
 | 
			
		||||
            $data = fread($this->stream, $length);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (is_string($data)) {
 | 
			
		||||
            if ($this->cache) {
 | 
			
		||||
                $this->cache->write($data);
 | 
			
		||||
            }
 | 
			
		||||
            if ($this->eof()) {
 | 
			
		||||
                $this->finished = true;
 | 
			
		||||
            }
 | 
			
		||||
            return $data;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        throw new RuntimeException('Could not read from stream.');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     * @return int
 | 
			
		||||
     */
 | 
			
		||||
    public function write($string): int
 | 
			
		||||
    {
 | 
			
		||||
        $written = false;
 | 
			
		||||
 | 
			
		||||
        if ($this->isWritable() && $this->stream) {
 | 
			
		||||
            $written = fwrite($this->stream, $string);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if ($written !== false) {
 | 
			
		||||
            $this->size = null;
 | 
			
		||||
            return $written;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        throw new RuntimeException('Could not write to stream.');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getContents(): string
 | 
			
		||||
    {
 | 
			
		||||
        if ($this->cache && $this->finished) {
 | 
			
		||||
            $this->cache->rewind();
 | 
			
		||||
            return $this->cache->getContents();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $contents = false;
 | 
			
		||||
 | 
			
		||||
        if ($this->stream) {
 | 
			
		||||
            $contents = stream_get_contents($this->stream);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (is_string($contents)) {
 | 
			
		||||
            if ($this->cache) {
 | 
			
		||||
                $this->cache->write($contents);
 | 
			
		||||
            }
 | 
			
		||||
            if ($this->eof()) {
 | 
			
		||||
                $this->finished = true;
 | 
			
		||||
            }
 | 
			
		||||
            return $contents;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        throw new RuntimeException('Could not get contents of stream.');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns whether or not the stream is a pipe.
 | 
			
		||||
     *
 | 
			
		||||
     * @internal This method is not part of the PSR-7 standard.
 | 
			
		||||
     *
 | 
			
		||||
     * @return bool
 | 
			
		||||
     */
 | 
			
		||||
    public function isPipe(): bool
 | 
			
		||||
    {
 | 
			
		||||
        if ($this->isPipe === null) {
 | 
			
		||||
            $this->isPipe = false;
 | 
			
		||||
 | 
			
		||||
            if ($this->stream) {
 | 
			
		||||
                $stats = fstat($this->stream);
 | 
			
		||||
 | 
			
		||||
                if (is_array($stats)) {
 | 
			
		||||
                    $this->isPipe = ($stats['mode'] & self::FSTAT_MODE_S_IFIFO) !== 0;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $this->isPipe;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										279
									
								
								qwen/php/vendor/slim/psr7/src/UploadedFile.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										279
									
								
								qwen/php/vendor/slim/psr7/src/UploadedFile.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,279 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Psr7;
 | 
			
		||||
 | 
			
		||||
use InvalidArgumentException;
 | 
			
		||||
use Psr\Http\Message\StreamInterface;
 | 
			
		||||
use Psr\Http\Message\UploadedFileInterface;
 | 
			
		||||
use RuntimeException;
 | 
			
		||||
use Slim\Psr7\Factory\StreamFactory;
 | 
			
		||||
 | 
			
		||||
use function copy;
 | 
			
		||||
use function dirname;
 | 
			
		||||
use function is_array;
 | 
			
		||||
use function is_string;
 | 
			
		||||
use function is_uploaded_file;
 | 
			
		||||
use function is_writable;
 | 
			
		||||
use function move_uploaded_file;
 | 
			
		||||
use function rename;
 | 
			
		||||
use function sprintf;
 | 
			
		||||
use function strpos;
 | 
			
		||||
use function unlink;
 | 
			
		||||
 | 
			
		||||
use const UPLOAD_ERR_OK;
 | 
			
		||||
 | 
			
		||||
class UploadedFile implements UploadedFileInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * The client-provided full path to the file
 | 
			
		||||
     */
 | 
			
		||||
    protected string $file;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The client-provided file name.
 | 
			
		||||
     */
 | 
			
		||||
    protected ?string $name;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The client-provided media type of the file.
 | 
			
		||||
     */
 | 
			
		||||
    protected ?string $type;
 | 
			
		||||
 | 
			
		||||
    protected ?int $size;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * A valid PHP UPLOAD_ERR_xxx code for the file upload.
 | 
			
		||||
     */
 | 
			
		||||
    protected int $error = UPLOAD_ERR_OK;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Indicates if the upload is from a SAPI environment.
 | 
			
		||||
     */
 | 
			
		||||
    protected bool $sapi = false;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var StreamInterface|null
 | 
			
		||||
     */
 | 
			
		||||
    protected $stream;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Indicates if the uploaded file has already been moved.
 | 
			
		||||
     */
 | 
			
		||||
    protected bool $moved = false;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param string|StreamInterface $fileNameOrStream The full path to the uploaded file provided by the client,
 | 
			
		||||
     *                                                 or a StreamInterface instance.
 | 
			
		||||
     * @param string|null            $name             The file name.
 | 
			
		||||
     * @param string|null            $type             The file media type.
 | 
			
		||||
     * @param int|null               $size             The file size in bytes.
 | 
			
		||||
     * @param int                    $error            The UPLOAD_ERR_XXX code representing the status of the upload.
 | 
			
		||||
     * @param bool                   $sapi             Indicates if the upload is in a SAPI environment.
 | 
			
		||||
     */
 | 
			
		||||
    final public function __construct(
 | 
			
		||||
        $fileNameOrStream,
 | 
			
		||||
        ?string $name = null,
 | 
			
		||||
        ?string $type = null,
 | 
			
		||||
        ?int $size = null,
 | 
			
		||||
        int $error = UPLOAD_ERR_OK,
 | 
			
		||||
        bool $sapi = false
 | 
			
		||||
    ) {
 | 
			
		||||
        if ($fileNameOrStream instanceof StreamInterface) {
 | 
			
		||||
            $file = $fileNameOrStream->getMetadata('uri');
 | 
			
		||||
            if (!is_string($file)) {
 | 
			
		||||
                throw new InvalidArgumentException('No URI associated with the stream.');
 | 
			
		||||
            }
 | 
			
		||||
            $this->file = $file;
 | 
			
		||||
            $this->stream = $fileNameOrStream;
 | 
			
		||||
        } elseif (is_string($fileNameOrStream)) {
 | 
			
		||||
            $this->file = $fileNameOrStream;
 | 
			
		||||
        } else {
 | 
			
		||||
            throw new InvalidArgumentException(
 | 
			
		||||
                'Please provide a string (full path to the uploaded file) or an instance of StreamInterface.'
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
        $this->name = $name;
 | 
			
		||||
        $this->type = $type;
 | 
			
		||||
        $this->size = $size;
 | 
			
		||||
        $this->error = $error;
 | 
			
		||||
        $this->sapi = $sapi;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     * @return StreamInterface
 | 
			
		||||
     */
 | 
			
		||||
    public function getStream(): StreamInterface
 | 
			
		||||
    {
 | 
			
		||||
        if ($this->moved) {
 | 
			
		||||
            throw new RuntimeException(sprintf('Uploaded file %s has already been moved', $this->name));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!$this->stream) {
 | 
			
		||||
            $this->stream = (new StreamFactory())->createStreamFromFile($this->file);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $this->stream;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function moveTo($targetPath): void
 | 
			
		||||
    {
 | 
			
		||||
        if ($this->moved) {
 | 
			
		||||
            throw new RuntimeException('Uploaded file already moved');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $targetIsStream = strpos($targetPath, '://') > 0;
 | 
			
		||||
        if (!$targetIsStream && !is_writable(dirname($targetPath))) {
 | 
			
		||||
            throw new InvalidArgumentException('Upload target path is not writable');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if ($targetIsStream) {
 | 
			
		||||
            if (!copy($this->file, $targetPath)) {
 | 
			
		||||
                throw new RuntimeException(sprintf('Error moving uploaded file %s to %s', $this->name, $targetPath));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (!unlink($this->file)) {
 | 
			
		||||
                throw new RuntimeException(sprintf('Error removing uploaded file %s', $this->name));
 | 
			
		||||
            }
 | 
			
		||||
        } elseif ($this->sapi) {
 | 
			
		||||
            if (!is_uploaded_file($this->file)) {
 | 
			
		||||
                throw new RuntimeException(sprintf('%s is not a valid uploaded file', $this->file));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (!move_uploaded_file($this->file, $targetPath)) {
 | 
			
		||||
                throw new RuntimeException(sprintf('Error moving uploaded file %s to %s', $this->name, $targetPath));
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            if (!rename($this->file, $targetPath)) {
 | 
			
		||||
                throw new RuntimeException(sprintf('Error moving uploaded file %s to %s', $this->name, $targetPath));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $this->moved = true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getError(): int
 | 
			
		||||
    {
 | 
			
		||||
        return $this->error;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getClientFilename(): ?string
 | 
			
		||||
    {
 | 
			
		||||
        return $this->name;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getClientMediaType(): ?string
 | 
			
		||||
    {
 | 
			
		||||
        return $this->type;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getSize(): ?int
 | 
			
		||||
    {
 | 
			
		||||
        return $this->size;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns the client-provided full path to the file
 | 
			
		||||
     *
 | 
			
		||||
     * @internal This method is not part of the PSR-7 standard
 | 
			
		||||
     *
 | 
			
		||||
     * @return string
 | 
			
		||||
     */
 | 
			
		||||
    public function getFilePath(): string
 | 
			
		||||
    {
 | 
			
		||||
        return $this->file;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Create a normalized tree of UploadedFile instances from the Environment.
 | 
			
		||||
     *
 | 
			
		||||
     * @internal This method is not part of the PSR-7 standard.
 | 
			
		||||
     *
 | 
			
		||||
     * @param array $globals The global server variables.
 | 
			
		||||
     *
 | 
			
		||||
     * @return array A normalized tree of UploadedFile instances or null if none are provided.
 | 
			
		||||
     */
 | 
			
		||||
    public static function createFromGlobals(array $globals): array
 | 
			
		||||
    {
 | 
			
		||||
        if (isset($globals['slim.files']) && is_array($globals['slim.files'])) {
 | 
			
		||||
            return $globals['slim.files'];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!empty($_FILES)) {
 | 
			
		||||
            return self::parseUploadedFiles($_FILES);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return [];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Parse a non-normalized, i.e. $_FILES superglobal, tree of uploaded file data.
 | 
			
		||||
     *
 | 
			
		||||
     * @internal This method is not part of the PSR-7 standard.
 | 
			
		||||
     *
 | 
			
		||||
     * @param array $uploadedFiles The non-normalized tree of uploaded file data.
 | 
			
		||||
     *
 | 
			
		||||
     * @return array A normalized tree of UploadedFile instances.
 | 
			
		||||
     */
 | 
			
		||||
    private static function parseUploadedFiles(array $uploadedFiles): array
 | 
			
		||||
    {
 | 
			
		||||
        $parsed = [];
 | 
			
		||||
        foreach ($uploadedFiles as $field => $uploadedFile) {
 | 
			
		||||
            if (!isset($uploadedFile['error'])) {
 | 
			
		||||
                if (is_array($uploadedFile)) {
 | 
			
		||||
                    $parsed[$field] = self::parseUploadedFiles($uploadedFile);
 | 
			
		||||
                }
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            $parsed[$field] = [];
 | 
			
		||||
            if (!is_array($uploadedFile['error'])) {
 | 
			
		||||
                $parsed[$field] = new static(
 | 
			
		||||
                    $uploadedFile['tmp_name'],
 | 
			
		||||
                    $uploadedFile['name'] ?? null,
 | 
			
		||||
                    $uploadedFile['type'] ?? null,
 | 
			
		||||
                    $uploadedFile['size'] ?? null,
 | 
			
		||||
                    $uploadedFile['error'],
 | 
			
		||||
                    true
 | 
			
		||||
                );
 | 
			
		||||
            } else {
 | 
			
		||||
                $subArray = [];
 | 
			
		||||
                foreach ($uploadedFile['error'] as $fileIdx => $error) {
 | 
			
		||||
                    // Normalize sub array and re-parse to move the input's key name up a level
 | 
			
		||||
                    $subArray[$fileIdx]['name'] = $uploadedFile['name'][$fileIdx];
 | 
			
		||||
                    $subArray[$fileIdx]['type'] = $uploadedFile['type'][$fileIdx];
 | 
			
		||||
                    $subArray[$fileIdx]['tmp_name'] = $uploadedFile['tmp_name'][$fileIdx];
 | 
			
		||||
                    $subArray[$fileIdx]['error'] = $uploadedFile['error'][$fileIdx];
 | 
			
		||||
                    $subArray[$fileIdx]['size'] = $uploadedFile['size'][$fileIdx];
 | 
			
		||||
 | 
			
		||||
                    $parsed[$field] = self::parseUploadedFiles($subArray);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $parsed;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										505
									
								
								qwen/php/vendor/slim/psr7/src/Uri.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										505
									
								
								qwen/php/vendor/slim/psr7/src/Uri.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,505 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Psr7;
 | 
			
		||||
 | 
			
		||||
use InvalidArgumentException;
 | 
			
		||||
use Psr\Http\Message\UriInterface;
 | 
			
		||||
 | 
			
		||||
use function filter_var;
 | 
			
		||||
use function is_integer;
 | 
			
		||||
use function is_null;
 | 
			
		||||
use function is_object;
 | 
			
		||||
use function is_string;
 | 
			
		||||
use function ltrim;
 | 
			
		||||
use function method_exists;
 | 
			
		||||
use function preg_replace_callback;
 | 
			
		||||
use function rawurlencode;
 | 
			
		||||
use function str_replace;
 | 
			
		||||
use function str_starts_with;
 | 
			
		||||
use function strtolower;
 | 
			
		||||
 | 
			
		||||
use const FILTER_FLAG_IPV6;
 | 
			
		||||
use const FILTER_VALIDATE_IP;
 | 
			
		||||
 | 
			
		||||
class Uri implements UriInterface
 | 
			
		||||
{
 | 
			
		||||
    public const SUPPORTED_SCHEMES = [
 | 
			
		||||
        '' => null,
 | 
			
		||||
        'http' => 80,
 | 
			
		||||
        'https' => 443
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Uri scheme (without "://" suffix)
 | 
			
		||||
     */
 | 
			
		||||
    protected string $scheme = '';
 | 
			
		||||
 | 
			
		||||
    protected string $user = '';
 | 
			
		||||
 | 
			
		||||
    protected string $password = '';
 | 
			
		||||
 | 
			
		||||
    protected string $host = '';
 | 
			
		||||
 | 
			
		||||
    protected ?int $port;
 | 
			
		||||
 | 
			
		||||
    protected string $path = '';
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Uri query string (without "?" prefix)
 | 
			
		||||
     */
 | 
			
		||||
    protected string $query = '';
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Uri fragment string (without "#" prefix)
 | 
			
		||||
     */
 | 
			
		||||
    protected string $fragment = '';
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param string   $scheme   Uri scheme.
 | 
			
		||||
     * @param string   $host     Uri host.
 | 
			
		||||
     * @param int|null $port     Uri port number.
 | 
			
		||||
     * @param string   $path     Uri path.
 | 
			
		||||
     * @param string   $query    Uri query string.
 | 
			
		||||
     * @param string   $fragment Uri fragment.
 | 
			
		||||
     * @param string   $user     Uri user.
 | 
			
		||||
     * @param string   $password Uri password.
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        string $scheme,
 | 
			
		||||
        string $host,
 | 
			
		||||
        ?int $port = null,
 | 
			
		||||
        string $path = '/',
 | 
			
		||||
        string $query = '',
 | 
			
		||||
        string $fragment = '',
 | 
			
		||||
        string $user = '',
 | 
			
		||||
        string $password = ''
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->scheme = $this->filterScheme($scheme);
 | 
			
		||||
        $this->host = $this->filterHost($host);
 | 
			
		||||
        $this->port = $this->filterPort($port);
 | 
			
		||||
        $this->path = $this->filterPath($path);
 | 
			
		||||
        $this->query = $this->filterQuery($query);
 | 
			
		||||
        $this->fragment = $this->filterFragment($fragment);
 | 
			
		||||
        $this->user = $this->filterUserInfo($user);
 | 
			
		||||
        $this->password = $this->filterUserInfo($password);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getScheme(): string
 | 
			
		||||
    {
 | 
			
		||||
        return $this->scheme;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     * @return static
 | 
			
		||||
     */
 | 
			
		||||
    public function withScheme($scheme): UriInterface
 | 
			
		||||
    {
 | 
			
		||||
        $scheme = $this->filterScheme($scheme);
 | 
			
		||||
        $clone = clone $this;
 | 
			
		||||
        $clone->scheme = $scheme;
 | 
			
		||||
 | 
			
		||||
        return $clone;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Filter Uri scheme.
 | 
			
		||||
     *
 | 
			
		||||
     * @param  mixed $scheme Raw Uri scheme.
 | 
			
		||||
     *
 | 
			
		||||
     * @return string
 | 
			
		||||
     *
 | 
			
		||||
     * @throws InvalidArgumentException If the Uri scheme is not a string.
 | 
			
		||||
     * @throws InvalidArgumentException If Uri scheme is not exists in SUPPORTED_SCHEMES
 | 
			
		||||
     */
 | 
			
		||||
    protected function filterScheme($scheme): string
 | 
			
		||||
    {
 | 
			
		||||
        if (!is_string($scheme)) {
 | 
			
		||||
            throw new InvalidArgumentException('Uri scheme must be a string.');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $scheme = str_replace('://', '', strtolower($scheme));
 | 
			
		||||
        if (!key_exists($scheme, static::SUPPORTED_SCHEMES)) {
 | 
			
		||||
            throw new InvalidArgumentException(
 | 
			
		||||
                'Uri scheme must be one of: "' . implode('", "', array_keys(static::SUPPORTED_SCHEMES)) . '"'
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $scheme;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getAuthority(): string
 | 
			
		||||
    {
 | 
			
		||||
        $userInfo = $this->getUserInfo();
 | 
			
		||||
        $host = $this->getHost();
 | 
			
		||||
        $port = $this->getPort();
 | 
			
		||||
 | 
			
		||||
        return ($userInfo !== '' ? $userInfo . '@' : '') . $host . ($port !== null ? ':' . $port : '');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getUserInfo(): string
 | 
			
		||||
    {
 | 
			
		||||
        $info = $this->user;
 | 
			
		||||
 | 
			
		||||
        if ($this->password !== '') {
 | 
			
		||||
            $info .= ':' . $this->password;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $info;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     * @return static
 | 
			
		||||
     */
 | 
			
		||||
    public function withUserInfo($user, $password = null): UriInterface
 | 
			
		||||
    {
 | 
			
		||||
        $clone = clone $this;
 | 
			
		||||
        $clone->user = $this->filterUserInfo($user);
 | 
			
		||||
 | 
			
		||||
        if ($clone->user !== '') {
 | 
			
		||||
            $clone->password = $this->filterUserInfo($password);
 | 
			
		||||
        } else {
 | 
			
		||||
            $clone->password = '';
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $clone;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Filters the user info string.
 | 
			
		||||
     *
 | 
			
		||||
     * Returns the percent-encoded query string.
 | 
			
		||||
     *
 | 
			
		||||
     * @param string|null $info The raw uri query string.
 | 
			
		||||
     *
 | 
			
		||||
     * @return string
 | 
			
		||||
     */
 | 
			
		||||
    protected function filterUserInfo(?string $info = null): string
 | 
			
		||||
    {
 | 
			
		||||
        if (!is_string($info)) {
 | 
			
		||||
            return '';
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $match =  preg_replace_callback(
 | 
			
		||||
            '/(?:[^%a-zA-Z0-9_\-\.~\pL!\$&\'\(\)\*\+,;=]+|%(?![A-Fa-f0-9]{2}))/',
 | 
			
		||||
            function ($match) {
 | 
			
		||||
                return rawurlencode($match[0]);
 | 
			
		||||
            },
 | 
			
		||||
            $info
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        return is_string($match) ? $match : '';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getHost(): string
 | 
			
		||||
    {
 | 
			
		||||
        return $this->host;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     * @return static
 | 
			
		||||
     */
 | 
			
		||||
    public function withHost($host): UriInterface
 | 
			
		||||
    {
 | 
			
		||||
        $clone = clone $this;
 | 
			
		||||
        $clone->host = $this->filterHost($host);
 | 
			
		||||
 | 
			
		||||
        return $clone;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Filter Uri host.
 | 
			
		||||
     *
 | 
			
		||||
     * If the supplied host is an IPv6 address, then it is converted to a reference
 | 
			
		||||
     * as per RFC 2373.
 | 
			
		||||
     *
 | 
			
		||||
     * @param  mixed $host The host to filter.
 | 
			
		||||
     *
 | 
			
		||||
     * @return string
 | 
			
		||||
     *
 | 
			
		||||
     * @throws InvalidArgumentException for invalid host names.
 | 
			
		||||
     */
 | 
			
		||||
    protected function filterHost($host): string
 | 
			
		||||
    {
 | 
			
		||||
        if (is_object($host) && method_exists($host, '__toString')) {
 | 
			
		||||
            $host = (string) $host;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!is_string($host)) {
 | 
			
		||||
            throw new InvalidArgumentException('Uri host must be a string');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
 | 
			
		||||
            $host = '[' . $host . ']';
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return strtolower($host);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getPort(): ?int
 | 
			
		||||
    {
 | 
			
		||||
        return $this->port && !$this->hasStandardPort() ? $this->port : null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     * @return static
 | 
			
		||||
     */
 | 
			
		||||
    public function withPort($port): UriInterface
 | 
			
		||||
    {
 | 
			
		||||
        $port = $this->filterPort($port);
 | 
			
		||||
        $clone = clone $this;
 | 
			
		||||
        $clone->port = $port;
 | 
			
		||||
 | 
			
		||||
        return $clone;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Does this Uri use a standard port?
 | 
			
		||||
     *
 | 
			
		||||
     * @return bool
 | 
			
		||||
     */
 | 
			
		||||
    protected function hasStandardPort(): bool
 | 
			
		||||
    {
 | 
			
		||||
        return static::SUPPORTED_SCHEMES[$this->scheme] === $this->port;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Filter Uri port.
 | 
			
		||||
     *
 | 
			
		||||
     * @param  int|string|null $port The Uri port number.
 | 
			
		||||
     *
 | 
			
		||||
     * @return int|null
 | 
			
		||||
     *
 | 
			
		||||
     * @throws InvalidArgumentException If the port is invalid.
 | 
			
		||||
     */
 | 
			
		||||
    protected function filterPort($port): ?int
 | 
			
		||||
    {
 | 
			
		||||
        if (is_null($port)) {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $port = (int) $port;
 | 
			
		||||
 | 
			
		||||
        if ($port >= 1 && $port <= 65535) {
 | 
			
		||||
            return $port;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        throw new InvalidArgumentException('Uri port must be null or an integer between 1 and 65535 (inclusive)');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getPath(): string
 | 
			
		||||
    {
 | 
			
		||||
        if (str_starts_with($this->path, '/')) {
 | 
			
		||||
            // Use only one leading slash to prevent XSS attempts.
 | 
			
		||||
            return '/' . ltrim($this->path, '/');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $this->path;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     * @return static
 | 
			
		||||
     */
 | 
			
		||||
    public function withPath($path): UriInterface
 | 
			
		||||
    {
 | 
			
		||||
        if (!is_string($path)) {
 | 
			
		||||
            throw new InvalidArgumentException('Uri path must be a string');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $clone = clone $this;
 | 
			
		||||
        $clone->path = $this->filterPath($path);
 | 
			
		||||
 | 
			
		||||
        return $clone;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Filter Uri path.
 | 
			
		||||
     *
 | 
			
		||||
     * This method percent-encodes all reserved characters in the provided path string.
 | 
			
		||||
     * This method will NOT double-encode characters that are already percent-encoded.
 | 
			
		||||
     *
 | 
			
		||||
     * @param  string $path The raw uri path.
 | 
			
		||||
     *
 | 
			
		||||
     * @return string       The RFC 3986 percent-encoded uri path.
 | 
			
		||||
     *
 | 
			
		||||
     * @link   http://www.faqs.org/rfcs/rfc3986.html
 | 
			
		||||
     */
 | 
			
		||||
    protected function filterPath($path): string
 | 
			
		||||
    {
 | 
			
		||||
        $match = preg_replace_callback(
 | 
			
		||||
            '/(?:[^a-zA-Z0-9_\-\.~:@&=\+\$,\/;%]+|%(?![A-Fa-f0-9]{2}))/',
 | 
			
		||||
            fn (array $match) => rawurlencode($match[0]),
 | 
			
		||||
            $path
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        return is_string($match) ? $match : '';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getQuery(): string
 | 
			
		||||
    {
 | 
			
		||||
        return $this->query;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     * @return static
 | 
			
		||||
     */
 | 
			
		||||
    public function withQuery($query): UriInterface
 | 
			
		||||
    {
 | 
			
		||||
        $query = ltrim($this->filterQuery($query), '?');
 | 
			
		||||
        $clone = clone $this;
 | 
			
		||||
        $clone->query = $query;
 | 
			
		||||
 | 
			
		||||
        return $clone;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Filters the query string of a URI.
 | 
			
		||||
     *
 | 
			
		||||
     * Returns the percent-encoded query string.
 | 
			
		||||
     *
 | 
			
		||||
     * @param mixed $query The raw uri query string.
 | 
			
		||||
     *
 | 
			
		||||
     * @return string
 | 
			
		||||
     */
 | 
			
		||||
    protected function filterQuery($query): string
 | 
			
		||||
    {
 | 
			
		||||
        if (is_object($query) && method_exists($query, '__toString')) {
 | 
			
		||||
            $query = (string) $query;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!is_string($query)) {
 | 
			
		||||
            throw new InvalidArgumentException('Uri query must be a string.');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $match = preg_replace_callback(
 | 
			
		||||
            '/(?:[^a-zA-Z0-9_\-\.~!\$&\'\(\)\*\+,;=%:@\/\?]+|%(?![A-Fa-f0-9]{2}))/',
 | 
			
		||||
            function ($match) {
 | 
			
		||||
                return rawurlencode($match[0]);
 | 
			
		||||
            },
 | 
			
		||||
            $query
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        return is_string($match) ? $match : '';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function getFragment(): string
 | 
			
		||||
    {
 | 
			
		||||
        return $this->fragment;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     * @return static
 | 
			
		||||
     */
 | 
			
		||||
    public function withFragment($fragment): UriInterface
 | 
			
		||||
    {
 | 
			
		||||
        $fragment = $this->filterFragment($fragment);
 | 
			
		||||
        $clone = clone $this;
 | 
			
		||||
        $clone->fragment = $fragment;
 | 
			
		||||
 | 
			
		||||
        return $clone;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Filters fragment of a URI.
 | 
			
		||||
     *
 | 
			
		||||
     * Returns the percent-encoded fragment.
 | 
			
		||||
     *
 | 
			
		||||
     * @param mixed $fragment The raw uri query string.
 | 
			
		||||
     *
 | 
			
		||||
     * @return string
 | 
			
		||||
     */
 | 
			
		||||
    protected function filterFragment($fragment): string
 | 
			
		||||
    {
 | 
			
		||||
        if (is_object($fragment) && method_exists($fragment, '__toString')) {
 | 
			
		||||
            $fragment = (string) $fragment;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!is_string($fragment)) {
 | 
			
		||||
            throw new InvalidArgumentException('Uri fragment must be a string.');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $fragment = ltrim($fragment, '#');
 | 
			
		||||
 | 
			
		||||
        $match = preg_replace_callback(
 | 
			
		||||
            '/(?:[^a-zA-Z0-9_\-\.~!\$&\'\(\)\*\+,;=%:@\/\?]+|%(?![A-Fa-f0-9]{2}))/',
 | 
			
		||||
            function ($match) {
 | 
			
		||||
                return rawurlencode($match[0]);
 | 
			
		||||
            },
 | 
			
		||||
            $fragment
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        return is_string($match) ? $match : '';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function __toString(): string
 | 
			
		||||
    {
 | 
			
		||||
        $scheme = $this->getScheme();
 | 
			
		||||
        $authority = $this->getAuthority();
 | 
			
		||||
        $path = $this->path;
 | 
			
		||||
        $query = $this->getQuery();
 | 
			
		||||
        $fragment = $this->getFragment();
 | 
			
		||||
 | 
			
		||||
        if ($path !== '') {
 | 
			
		||||
            if ($path[0] !== '/') {
 | 
			
		||||
                if ($authority !== '') {
 | 
			
		||||
                    // If the path is rootless and an authority is present, the path MUST be prefixed by "/".
 | 
			
		||||
                    $path = '/' . $path;
 | 
			
		||||
                }
 | 
			
		||||
            } elseif (isset($path[1]) && $path[1] === '/') {
 | 
			
		||||
                if ($authority === '') {
 | 
			
		||||
                    // If the path is starting with more than one "/" and no authority is present,
 | 
			
		||||
                    // the starting slashes MUST be reduced to one.
 | 
			
		||||
                    $path = ltrim($path, '/');
 | 
			
		||||
                    $path = '/' . $path;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return ($scheme !== '' ? $scheme . ':' : '')
 | 
			
		||||
            . ($authority !== '' ? '//' . $authority : '')
 | 
			
		||||
            . $path
 | 
			
		||||
            . ($query !== '' ? '?' . $query : '')
 | 
			
		||||
            . ($fragment !== '' ? '#' . $fragment : '');
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										95
									
								
								qwen/php/vendor/slim/psr7/tests/Assets/HeaderStack.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										95
									
								
								qwen/php/vendor/slim/psr7/tests/Assets/HeaderStack.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,95 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This is a direct copy of zend-diactoros/test/TestAsset/Functions.php and is used to override
 | 
			
		||||
 * header() and headers_sent() so we can test that they do the right thing.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
namespace Slim\Tests\Psr7\Assets;
 | 
			
		||||
 | 
			
		||||
use function strpos;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Zend Framework (http://framework.zend.com/)
 | 
			
		||||
 *
 | 
			
		||||
 * This file exists to allow overriding the various output-related functions
 | 
			
		||||
 * in order to test what happens during the `Server::listen()` cycle.
 | 
			
		||||
 *
 | 
			
		||||
 * These functions include:
 | 
			
		||||
 *
 | 
			
		||||
 * - headers_sent(): we want to always return false so that headers will be
 | 
			
		||||
 *   emitted, and we can test to see their values.
 | 
			
		||||
 * - header(): we want to aggregate calls to this function.
 | 
			
		||||
 *
 | 
			
		||||
 * The HeaderStack class then aggregates that information for us, and the test
 | 
			
		||||
 * harness resets the values pre and post test.
 | 
			
		||||
 *
 | 
			
		||||
 * @see       http://github.com/zendframework/zend-diactoros for the canonical source repository
 | 
			
		||||
 * @copyright Copyright (c) 2015-2016 Zend Technologies USA Inc. (http://www.zend.com)
 | 
			
		||||
 * @license   https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
class HeaderStack
 | 
			
		||||
{
 | 
			
		||||
    private static array $data = [];
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Reset state
 | 
			
		||||
     */
 | 
			
		||||
    public static function reset()
 | 
			
		||||
    {
 | 
			
		||||
        self::$data = [];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Push a header on the stack
 | 
			
		||||
     *
 | 
			
		||||
     * @param string[] $header
 | 
			
		||||
     */
 | 
			
		||||
    public static function push(array $header)
 | 
			
		||||
    {
 | 
			
		||||
        self::$data[] = $header;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Return the current header stack
 | 
			
		||||
     *
 | 
			
		||||
     * @return string[][]
 | 
			
		||||
     */
 | 
			
		||||
    public static function stack(): array
 | 
			
		||||
    {
 | 
			
		||||
        return self::$data;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Verify if there's a header line on the stack
 | 
			
		||||
     *
 | 
			
		||||
     * @param string $header
 | 
			
		||||
     *
 | 
			
		||||
     * @return bool
 | 
			
		||||
     */
 | 
			
		||||
    public static function has($header): bool
 | 
			
		||||
    {
 | 
			
		||||
        foreach (self::$data as $item) {
 | 
			
		||||
            if ($item['header'] === $header) {
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Remove occurrences of $header
 | 
			
		||||
     *
 | 
			
		||||
     * @param string $header
 | 
			
		||||
     */
 | 
			
		||||
    public static function remove($header): void
 | 
			
		||||
    {
 | 
			
		||||
        foreach (self::$data as $key => $item) {
 | 
			
		||||
            if (false !== strpos($item['header'], "$header:")) {
 | 
			
		||||
                unset(self::$data[$key]);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										422
									
								
								qwen/php/vendor/slim/psr7/tests/BodyTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										422
									
								
								qwen/php/vendor/slim/psr7/tests/BodyTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,422 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Tests\Psr7;
 | 
			
		||||
 | 
			
		||||
use InvalidArgumentException;
 | 
			
		||||
use PHPUnit\Framework\TestCase;
 | 
			
		||||
use ReflectionProperty;
 | 
			
		||||
use RuntimeException;
 | 
			
		||||
use Slim\Psr7\Stream;
 | 
			
		||||
 | 
			
		||||
use function fclose;
 | 
			
		||||
use function feof;
 | 
			
		||||
use function fopen;
 | 
			
		||||
use function fread;
 | 
			
		||||
use function fseek;
 | 
			
		||||
use function ftell;
 | 
			
		||||
use function fwrite;
 | 
			
		||||
use function is_array;
 | 
			
		||||
use function is_resource;
 | 
			
		||||
use function mb_strlen;
 | 
			
		||||
use function rewind;
 | 
			
		||||
use function substr;
 | 
			
		||||
 | 
			
		||||
class BodyTest extends TestCase
 | 
			
		||||
{
 | 
			
		||||
    // @codingStandardsIgnoreStart
 | 
			
		||||
    protected string $text = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
 | 
			
		||||
    // @codingStandardsIgnoreEnd
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var resource
 | 
			
		||||
     */
 | 
			
		||||
    protected $stream;
 | 
			
		||||
 | 
			
		||||
    protected function tearDown(): void
 | 
			
		||||
    {
 | 
			
		||||
        if (is_resource($this->stream) === true) {
 | 
			
		||||
            fclose($this->stream);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param string $mode
 | 
			
		||||
     *
 | 
			
		||||
     * @return resource
 | 
			
		||||
     */
 | 
			
		||||
    public function resourceFactory(string $mode = 'r+')
 | 
			
		||||
    {
 | 
			
		||||
        $stream = fopen('php://temp', $mode);
 | 
			
		||||
        fwrite($stream, $this->text);
 | 
			
		||||
        rewind($stream);
 | 
			
		||||
 | 
			
		||||
        return $stream;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testConstructorAttachesStream()
 | 
			
		||||
    {
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
        $bodyStream = new ReflectionProperty($body, 'stream');
 | 
			
		||||
        $bodyStream->setAccessible(true);
 | 
			
		||||
 | 
			
		||||
        $this->assertSame($this->stream, $bodyStream->getValue($body));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testConstructorInvalidStream()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
 | 
			
		||||
        $this->stream = 'foo';
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetMetadata()
 | 
			
		||||
    {
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
 | 
			
		||||
        $this->assertTrue(is_array($body->getMetadata()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetMetadataKey()
 | 
			
		||||
    {
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('php://temp', $body->getMetadata('uri'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetMetadataKeyNotFound()
 | 
			
		||||
    {
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
 | 
			
		||||
        $this->assertNull($body->getMetadata('foo'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testDetach()
 | 
			
		||||
    {
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
 | 
			
		||||
        $bodyStream = new ReflectionProperty($body, 'stream');
 | 
			
		||||
        $bodyStream->setAccessible(true);
 | 
			
		||||
 | 
			
		||||
        $bodyMetadata = new ReflectionProperty($body, 'meta');
 | 
			
		||||
        $bodyMetadata->setAccessible(true);
 | 
			
		||||
 | 
			
		||||
        $bodyReadable = new ReflectionProperty($body, 'readable');
 | 
			
		||||
        $bodyReadable->setAccessible(true);
 | 
			
		||||
 | 
			
		||||
        $bodyWritable = new ReflectionProperty($body, 'writable');
 | 
			
		||||
        $bodyWritable->setAccessible(true);
 | 
			
		||||
 | 
			
		||||
        $bodySeekable = new ReflectionProperty($body, 'seekable');
 | 
			
		||||
        $bodySeekable->setAccessible(true);
 | 
			
		||||
 | 
			
		||||
        $result = $body->detach();
 | 
			
		||||
 | 
			
		||||
        $this->assertSame($this->stream, $result);
 | 
			
		||||
        $this->assertNull($bodyStream->getValue($body));
 | 
			
		||||
        $this->assertNull($bodyMetadata->getValue($body));
 | 
			
		||||
        $this->assertNull($bodyReadable->getValue($body));
 | 
			
		||||
        $this->assertNull($bodyWritable->getValue($body));
 | 
			
		||||
        $this->assertNull($bodySeekable->getValue($body));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testToStringAttached()
 | 
			
		||||
    {
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals($this->text, (string) $body);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testToStringAttachedRewindsFirst()
 | 
			
		||||
    {
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals($this->text, (string) $body);
 | 
			
		||||
        $this->assertEquals($this->text, (string) $body);
 | 
			
		||||
        $this->assertEquals($this->text, (string) $body);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testToStringDetached()
 | 
			
		||||
    {
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
        $bodyStream = new ReflectionProperty($body, 'stream');
 | 
			
		||||
        $bodyStream->setAccessible(true);
 | 
			
		||||
        $bodyStream->setValue($body, null);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('', (string) $body);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testClose()
 | 
			
		||||
    {
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
        $body->close();
 | 
			
		||||
 | 
			
		||||
        $bodyStream = new ReflectionProperty($body, 'stream');
 | 
			
		||||
        $bodyStream->setAccessible(true);
 | 
			
		||||
 | 
			
		||||
        $this->assertNull($bodyStream->getValue($body));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetSizeAttached()
 | 
			
		||||
    {
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(mb_strlen($this->text), $body->getSize());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetSizeDetached()
 | 
			
		||||
    {
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
        $bodyStream = new ReflectionProperty($body, 'stream');
 | 
			
		||||
        $bodyStream->setAccessible(true);
 | 
			
		||||
        $bodyStream->setValue($body, null);
 | 
			
		||||
 | 
			
		||||
        $this->assertNull($body->getSize());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testTellAttached()
 | 
			
		||||
    {
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
        fseek($this->stream, 10);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(10, $body->tell());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testTellDetachedThrowsRuntimeException()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(RuntimeException::class);
 | 
			
		||||
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
        $bodyStream = new ReflectionProperty($body, 'stream');
 | 
			
		||||
        $bodyStream->setAccessible(true);
 | 
			
		||||
        $bodyStream->setValue($body, null);
 | 
			
		||||
 | 
			
		||||
        $body->tell();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testEofAttachedFalse()
 | 
			
		||||
    {
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
        fseek($this->stream, 10);
 | 
			
		||||
 | 
			
		||||
        $this->assertFalse($body->eof());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testEofAttachedTrue()
 | 
			
		||||
    {
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
        while (feof($this->stream) === false) {
 | 
			
		||||
            fread($this->stream, 1024);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $this->assertTrue($body->eof());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testEofDetached()
 | 
			
		||||
    {
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
        $bodyStream = new ReflectionProperty($body, 'stream');
 | 
			
		||||
        $bodyStream->setAccessible(true);
 | 
			
		||||
        $bodyStream->setValue($body, null);
 | 
			
		||||
 | 
			
		||||
        $this->assertTrue($body->eof());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function isReadableAttachedTrue()
 | 
			
		||||
    {
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
 | 
			
		||||
        $this->assertTrue($body->isReadable());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function isReadableAttachedFalse()
 | 
			
		||||
    {
 | 
			
		||||
        $stream = fopen('php://temp', 'w');
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
 | 
			
		||||
        $this->assertFalse($body->isReadable());
 | 
			
		||||
        fclose($stream);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testIsReadableDetached()
 | 
			
		||||
    {
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
        $body->detach();
 | 
			
		||||
 | 
			
		||||
        $this->assertFalse($body->isReadable());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function isWritableAttachedTrue()
 | 
			
		||||
    {
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
 | 
			
		||||
        $this->assertTrue($body->isWritable());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function isWritableAttachedFalse()
 | 
			
		||||
    {
 | 
			
		||||
        $stream = fopen('php://temp', 'r');
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
 | 
			
		||||
        $this->assertFalse($body->isWritable());
 | 
			
		||||
        fclose($stream);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testIsWritableDetached()
 | 
			
		||||
    {
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
        $body->detach();
 | 
			
		||||
 | 
			
		||||
        $this->assertFalse($body->isWritable());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function isSeekableAttachedTrue()
 | 
			
		||||
    {
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
 | 
			
		||||
        $this->assertTrue($body->isSeekable());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // TODO: Is seekable is false when attached... how?
 | 
			
		||||
 | 
			
		||||
    public function testIsSeekableDetached()
 | 
			
		||||
    {
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
        $body->detach();
 | 
			
		||||
 | 
			
		||||
        $this->assertFalse($body->isSeekable());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testSeekAttached()
 | 
			
		||||
    {
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
        $body->seek(10);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(10, ftell($this->stream));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testSeekDetachedThrowsRuntimeException()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(RuntimeException::class);
 | 
			
		||||
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
        $body->detach();
 | 
			
		||||
 | 
			
		||||
        $body->seek(10);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testRewindAttached()
 | 
			
		||||
    {
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
        fseek($this->stream, 10);
 | 
			
		||||
        $body->rewind();
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(0, ftell($this->stream));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testRewindDetachedThrowsRuntimeException()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(RuntimeException::class);
 | 
			
		||||
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
        $body->detach();
 | 
			
		||||
 | 
			
		||||
        $body->rewind();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testReadAttached()
 | 
			
		||||
    {
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(substr($this->text, 0, 10), $body->read(10));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testReadDetachedThrowsRuntimeException()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(RuntimeException::class);
 | 
			
		||||
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
        $body->detach();
 | 
			
		||||
 | 
			
		||||
        $body->read(10);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWriteAttached()
 | 
			
		||||
    {
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
        while (feof($this->stream) === false) {
 | 
			
		||||
            fread($this->stream, 1024);
 | 
			
		||||
        }
 | 
			
		||||
        $body->write('foo');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals($this->text . 'foo', (string) $body);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWriteDetachedThrowsRuntimeException()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(RuntimeException::class);
 | 
			
		||||
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
        $body->detach();
 | 
			
		||||
 | 
			
		||||
        $body->write('foo');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetContentsAttached()
 | 
			
		||||
    {
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
        fseek($this->stream, 10);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(substr($this->text, 10), $body->getContents());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetContentsDetachedThrowsRuntimeException()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(RuntimeException::class);
 | 
			
		||||
 | 
			
		||||
        $this->stream = $this->resourceFactory();
 | 
			
		||||
        $body = new Stream($this->stream);
 | 
			
		||||
        $body->detach();
 | 
			
		||||
 | 
			
		||||
        $body->getContents();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										283
									
								
								qwen/php/vendor/slim/psr7/tests/CookiesTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										283
									
								
								qwen/php/vendor/slim/psr7/tests/CookiesTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,283 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Tests\Psr7;
 | 
			
		||||
 | 
			
		||||
use InvalidArgumentException;
 | 
			
		||||
use PHPUnit\Framework\TestCase;
 | 
			
		||||
use ReflectionClass;
 | 
			
		||||
use ReflectionProperty;
 | 
			
		||||
use Slim\Psr7\Cookies;
 | 
			
		||||
use stdClass;
 | 
			
		||||
 | 
			
		||||
use function gmdate;
 | 
			
		||||
use function json_decode;
 | 
			
		||||
use function strtotime;
 | 
			
		||||
use function time;
 | 
			
		||||
 | 
			
		||||
class CookiesTest extends TestCase
 | 
			
		||||
{
 | 
			
		||||
    public function testConstructor()
 | 
			
		||||
    {
 | 
			
		||||
        $cookies = new Cookies([
 | 
			
		||||
            'test' => 'Works',
 | 
			
		||||
        ]);
 | 
			
		||||
        $prop = new ReflectionProperty($cookies, 'requestCookies');
 | 
			
		||||
        $prop->setAccessible(true);
 | 
			
		||||
        $this->assertNotEmpty($prop->getValue($cookies)['test']);
 | 
			
		||||
        $this->assertEquals('Works', $prop->getValue($cookies)['test']);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testSetDefaults()
 | 
			
		||||
    {
 | 
			
		||||
        $defaults = [
 | 
			
		||||
            'value' => 'toast',
 | 
			
		||||
            'domain' => null,
 | 
			
		||||
            'hostonly' => null,
 | 
			
		||||
            'path' => null,
 | 
			
		||||
            'expires' => null,
 | 
			
		||||
            'secure' => true,
 | 
			
		||||
            'httponly' => true,
 | 
			
		||||
            'samesite' => null
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $cookies = new Cookies();
 | 
			
		||||
 | 
			
		||||
        $prop = new ReflectionProperty($cookies, 'defaults');
 | 
			
		||||
        $prop->setAccessible(true);
 | 
			
		||||
 | 
			
		||||
        $origDefaults = $prop->getValue($cookies);
 | 
			
		||||
 | 
			
		||||
        $cookies->setDefaults($defaults);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals($defaults, $prop->getValue($cookies));
 | 
			
		||||
        $this->assertNotEquals($origDefaults, $prop->getValue($cookies));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testSetCookieValues()
 | 
			
		||||
    {
 | 
			
		||||
        $cookies = new Cookies();
 | 
			
		||||
        $cookies->set('foo', 'bar');
 | 
			
		||||
 | 
			
		||||
        $prop = new ReflectionProperty($cookies, 'responseCookies');
 | 
			
		||||
        $prop->setAccessible(true);
 | 
			
		||||
 | 
			
		||||
        $expectedValue = [
 | 
			
		||||
            'foo' => [
 | 
			
		||||
                'value' => 'bar',
 | 
			
		||||
                'domain' => null,
 | 
			
		||||
                'hostonly' => null,
 | 
			
		||||
                'path' => null,
 | 
			
		||||
                'expires' => null,
 | 
			
		||||
                'secure' => false,
 | 
			
		||||
                'httponly' => false,
 | 
			
		||||
                'samesite' => null
 | 
			
		||||
            ]
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals($expectedValue, $prop->getValue($cookies));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testSetCookieValuesContainDefaults()
 | 
			
		||||
    {
 | 
			
		||||
        $cookies = new Cookies();
 | 
			
		||||
        $defaults = [
 | 
			
		||||
            'value' => 'toast',
 | 
			
		||||
            'domain' => null,
 | 
			
		||||
            'hostonly' => null,
 | 
			
		||||
            'path' => null,
 | 
			
		||||
            'expires' => null,
 | 
			
		||||
            'secure' => true,
 | 
			
		||||
            'httponly' => true,
 | 
			
		||||
            'samesite' => 'lax'
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $cookies->setDefaults($defaults);
 | 
			
		||||
        $cookies->set('foo', 'bar');
 | 
			
		||||
 | 
			
		||||
        $prop = new ReflectionProperty($cookies, 'responseCookies');
 | 
			
		||||
        $prop->setAccessible(true);
 | 
			
		||||
 | 
			
		||||
        $expectedValue = [
 | 
			
		||||
            'foo' => [
 | 
			
		||||
                'value' => 'bar',
 | 
			
		||||
                'domain' => null,
 | 
			
		||||
                'hostonly' => null,
 | 
			
		||||
                'path' => null,
 | 
			
		||||
                'expires' => null,
 | 
			
		||||
                'secure' => true,
 | 
			
		||||
                'httponly' => true,
 | 
			
		||||
                'samesite' => 'lax'
 | 
			
		||||
            ]
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals($expectedValue, $prop->getValue($cookies));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testSetCookieValuesCanOverrideDefaults()
 | 
			
		||||
    {
 | 
			
		||||
        $cookies = new Cookies();
 | 
			
		||||
        $defaults = [
 | 
			
		||||
            'value' => 'toast',
 | 
			
		||||
            'domain' => null,
 | 
			
		||||
            'hostonly' => null,
 | 
			
		||||
            'path' => null,
 | 
			
		||||
            'expires' => null,
 | 
			
		||||
            'secure' => true,
 | 
			
		||||
            'httponly' => true,
 | 
			
		||||
            'samesite' => 'lax'
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $cookies->setDefaults($defaults);
 | 
			
		||||
        $cookies->set('foo', ['value' => 'bar', 'secure' => false, 'samesite' => 'strict']);
 | 
			
		||||
 | 
			
		||||
        $prop = new ReflectionProperty($cookies, 'responseCookies');
 | 
			
		||||
        $prop->setAccessible(true);
 | 
			
		||||
 | 
			
		||||
        $expectedValue = [
 | 
			
		||||
            'foo' => [
 | 
			
		||||
                'value' => 'bar',
 | 
			
		||||
                'domain' => null,
 | 
			
		||||
                'hostonly' => null,
 | 
			
		||||
                'path' => null,
 | 
			
		||||
                'expires' => null,
 | 
			
		||||
                'secure' => false,
 | 
			
		||||
                'httponly' => true,
 | 
			
		||||
                'samesite' => 'strict'
 | 
			
		||||
            ]
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals($expectedValue, $prop->getValue($cookies));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testSetSameSiteCookieValuesAreCaseInsensitive()
 | 
			
		||||
    {
 | 
			
		||||
        $cookies = new Cookies();
 | 
			
		||||
        $defaults = [
 | 
			
		||||
            'value' => 'bacon',
 | 
			
		||||
            'samesite' => 'lax'
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $cookies->setDefaults($defaults);
 | 
			
		||||
        $cookies->set('breakfast', ['samesite' => 'StricT']);
 | 
			
		||||
 | 
			
		||||
        $prop = new ReflectionProperty($cookies, 'responseCookies');
 | 
			
		||||
        $prop->setAccessible(true);
 | 
			
		||||
 | 
			
		||||
        $expectedValue = [
 | 
			
		||||
            'breakfast' => [
 | 
			
		||||
                'value' => 'bacon',
 | 
			
		||||
                'domain' => null,
 | 
			
		||||
                'hostonly' => null,
 | 
			
		||||
                'path' => null,
 | 
			
		||||
                'expires' => null,
 | 
			
		||||
                'secure' => false,
 | 
			
		||||
                'httponly' => false,
 | 
			
		||||
                'samesite' => 'StricT',
 | 
			
		||||
            ]
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals($expectedValue, $prop->getValue($cookies));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGet()
 | 
			
		||||
    {
 | 
			
		||||
        $cookies = new Cookies(['foo' => 'bar', 'baz' => null]);
 | 
			
		||||
        $this->assertEquals('bar', $cookies->get('foo'));
 | 
			
		||||
        $this->assertNull($cookies->get('baz', 'defaultValue'));
 | 
			
		||||
        $this->assertNull($cookies->get('missing'));
 | 
			
		||||
        $this->assertEquals('defaultValue', $cookies->get('missing', 'defaultValue'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testParseHeader()
 | 
			
		||||
    {
 | 
			
		||||
        $cookies = Cookies::parseHeader('foo=bar; name=Josh');
 | 
			
		||||
        $this->assertEquals('bar', $cookies['foo']);
 | 
			
		||||
        $this->assertEquals('Josh', $cookies['name']);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testParseHeaderWithJsonArray()
 | 
			
		||||
    {
 | 
			
		||||
        $cookies = Cookies::parseHeader('foo=bar; testarray=["someVar1","someVar2","someVar3"]');
 | 
			
		||||
        $this->assertEquals('bar', $cookies['foo']);
 | 
			
		||||
        $this->assertContains('someVar3', json_decode($cookies['testarray']));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testToHeaders()
 | 
			
		||||
    {
 | 
			
		||||
        $cookies = new Cookies();
 | 
			
		||||
        $cookies->set('test', 'Works');
 | 
			
		||||
        $cookies->set('test_array', ['value' => 'bar', 'domain' => 'example.com']);
 | 
			
		||||
        $this->assertEquals('test=Works', $cookies->toHeaders()[0]);
 | 
			
		||||
        $this->assertEquals('test_array=bar; domain=example.com', $cookies->toHeaders()[1]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testToHeader()
 | 
			
		||||
    {
 | 
			
		||||
        $cookies = new Cookies();
 | 
			
		||||
        $class = new ReflectionClass($cookies);
 | 
			
		||||
        $method = $class->getMethod('toHeader');
 | 
			
		||||
        $method->setAccessible(true);
 | 
			
		||||
        $properties = [
 | 
			
		||||
            'name' => 'test',
 | 
			
		||||
            'properties' => [
 | 
			
		||||
                'value' => 'Works'
 | 
			
		||||
            ]
 | 
			
		||||
        ];
 | 
			
		||||
        $time = time();
 | 
			
		||||
        $formattedDate = gmdate('D, d-M-Y H:i:s e', $time);
 | 
			
		||||
        $propertiesComplex = [
 | 
			
		||||
            'name' => 'test_complex',
 | 
			
		||||
            'properties' => [
 | 
			
		||||
                'value' => 'Works',
 | 
			
		||||
                'domain' => 'example.com',
 | 
			
		||||
                'expires' => $time,
 | 
			
		||||
                'path' => '/',
 | 
			
		||||
                'secure' => true,
 | 
			
		||||
                'hostonly' => true,
 | 
			
		||||
                'httponly' => true,
 | 
			
		||||
                'samesite' => 'lax'
 | 
			
		||||
            ]
 | 
			
		||||
        ];
 | 
			
		||||
        $stringDate = '2016-01-01 12:00:00';
 | 
			
		||||
        $formattedStringDate = gmdate('D, d-M-Y H:i:s e', strtotime($stringDate));
 | 
			
		||||
        $propertiesStringDate = [
 | 
			
		||||
            'name' => 'test_date',
 | 
			
		||||
            'properties' => [
 | 
			
		||||
                'value' => 'Works',
 | 
			
		||||
                'expires' => $stringDate,
 | 
			
		||||
            ]
 | 
			
		||||
        ];
 | 
			
		||||
        $cookie = $method->invokeArgs($cookies, $properties);
 | 
			
		||||
        $cookieComplex = $method->invokeArgs($cookies, $propertiesComplex);
 | 
			
		||||
        $cookieStringDate = $method->invokeArgs($cookies, $propertiesStringDate);
 | 
			
		||||
        $this->assertEquals('test=Works', $cookie);
 | 
			
		||||
        $this->assertEquals(
 | 
			
		||||
            'test_complex=Works; domain=example.com; path=/; expires='
 | 
			
		||||
            . $formattedDate . '; secure; HostOnly; HttpOnly; SameSite=lax',
 | 
			
		||||
            $cookieComplex
 | 
			
		||||
        );
 | 
			
		||||
        $this->assertEquals('test_date=Works; expires=' . $formattedStringDate, $cookieStringDate);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testParseHeaderException()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
 | 
			
		||||
        Cookies::parseHeader(new stdClass());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testSetSameSiteNoneToHeaders()
 | 
			
		||||
    {
 | 
			
		||||
        $cookies = new Cookies();
 | 
			
		||||
        $cookies->set('foo', ['value' => 'bar', 'samesite' => 'None']);
 | 
			
		||||
        $this->assertEquals('foo=bar; SameSite=None', $cookies->toHeaders()[0]);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										48
									
								
								qwen/php/vendor/slim/psr7/tests/EnvironmentTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								qwen/php/vendor/slim/psr7/tests/EnvironmentTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,48 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Tests\Psr7;
 | 
			
		||||
 | 
			
		||||
use PHPUnit\Framework\TestCase;
 | 
			
		||||
use Slim\Psr7\Environment;
 | 
			
		||||
 | 
			
		||||
class EnvironmentTest extends TestCase
 | 
			
		||||
{
 | 
			
		||||
    public function testMock()
 | 
			
		||||
    {
 | 
			
		||||
        $env = Environment::mock([
 | 
			
		||||
            'SCRIPT_NAME' => '/foo/bar/index.php',
 | 
			
		||||
            'REQUEST_URI' => '/foo/bar?abc=123',
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('/foo/bar/index.php', $env['SCRIPT_NAME']);
 | 
			
		||||
        $this->assertEquals('/foo/bar?abc=123', $env['REQUEST_URI']);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testMockHttps()
 | 
			
		||||
    {
 | 
			
		||||
        $env = Environment::mock([
 | 
			
		||||
            'HTTPS' => 'on'
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('on', $env['HTTPS']);
 | 
			
		||||
        $this->assertEquals(443, $env['SERVER_PORT']);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testMockRequestScheme()
 | 
			
		||||
    {
 | 
			
		||||
        $env = Environment::mock([
 | 
			
		||||
            'REQUEST_SCHEME' => 'https'
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('https', $env['REQUEST_SCHEME']);
 | 
			
		||||
        $this->assertEquals(443, $env['SERVER_PORT']);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										42
									
								
								qwen/php/vendor/slim/psr7/tests/Factory/RequestFactoryTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								qwen/php/vendor/slim/psr7/tests/Factory/RequestFactoryTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,42 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Tests\Psr7\Factory;
 | 
			
		||||
 | 
			
		||||
use Interop\Http\Factory\RequestFactoryTestCase;
 | 
			
		||||
use InvalidArgumentException;
 | 
			
		||||
use Psr\Http\Message\UriInterface;
 | 
			
		||||
use Slim\Psr7\Factory\RequestFactory;
 | 
			
		||||
use Slim\Psr7\Factory\UriFactory;
 | 
			
		||||
use stdClass;
 | 
			
		||||
 | 
			
		||||
class RequestFactoryTest extends RequestFactoryTestCase
 | 
			
		||||
{
 | 
			
		||||
    protected function createRequestFactory(): RequestFactory
 | 
			
		||||
    {
 | 
			
		||||
        return new RequestFactory();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected function createUri($uri): UriInterface
 | 
			
		||||
    {
 | 
			
		||||
        return (new UriFactory())->createUri($uri);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCreateRequestThrowsExceptionWithInvalidUri()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
        $this->expectExceptionMessage('Parameter 2 of RequestFactory::createRequest() must be a string' .
 | 
			
		||||
                                      ' or a compatible UriInterface.');
 | 
			
		||||
 | 
			
		||||
        $factory = $this->createRequestFactory();
 | 
			
		||||
 | 
			
		||||
        $factory->createRequest('GET', new stdClass());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										42
									
								
								qwen/php/vendor/slim/psr7/tests/Factory/ResponseFactoryTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								qwen/php/vendor/slim/psr7/tests/Factory/ResponseFactoryTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,42 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Tests\Psr7\Factory;
 | 
			
		||||
 | 
			
		||||
use Interop\Http\Factory\ResponseFactoryTestCase;
 | 
			
		||||
use Psr\Http\Message\ResponseInterface;
 | 
			
		||||
use Slim\Psr7\Factory\ResponseFactory;
 | 
			
		||||
 | 
			
		||||
class ResponseFactoryTest extends ResponseFactoryTestCase
 | 
			
		||||
{
 | 
			
		||||
    protected function createResponseFactory(): ResponseFactory
 | 
			
		||||
    {
 | 
			
		||||
        return new ResponseFactory();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected function assertResponseCodeAndReasonPhrase(ResponseInterface $response, int $code, string $reasonPhrase)
 | 
			
		||||
    {
 | 
			
		||||
        $this->assertInstanceOf(ResponseInterface::class, $response);
 | 
			
		||||
        $this->assertSame($code, $response->getStatusCode());
 | 
			
		||||
        $this->assertSame($reasonPhrase, $response->getReasonPhrase());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @dataProvider dataCodes
 | 
			
		||||
     *
 | 
			
		||||
     * @param int $code
 | 
			
		||||
     */
 | 
			
		||||
    public function testCreateResponseWithReasonPhrase(int $code)
 | 
			
		||||
    {
 | 
			
		||||
        $response = $this->factory->createResponse($code, 'Reason');
 | 
			
		||||
        $this->assertResponse($response, $code);
 | 
			
		||||
        $this->assertResponseCodeAndReasonPhrase($response, $code, 'Reason');
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										208
									
								
								qwen/php/vendor/slim/psr7/tests/Factory/ServerRequestFactoryTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										208
									
								
								qwen/php/vendor/slim/psr7/tests/Factory/ServerRequestFactoryTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,208 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Tests\Psr7\Factory;
 | 
			
		||||
 | 
			
		||||
use Interop\Http\Factory\ServerRequestFactoryTestCase;
 | 
			
		||||
use InvalidArgumentException;
 | 
			
		||||
use Psr\Http\Message\UriInterface;
 | 
			
		||||
use ReflectionClass;
 | 
			
		||||
use Slim\Psr7\Environment;
 | 
			
		||||
use Slim\Psr7\Factory\ServerRequestFactory;
 | 
			
		||||
use Slim\Psr7\Factory\UriFactory;
 | 
			
		||||
use Slim\Psr7\UploadedFile;
 | 
			
		||||
use stdClass;
 | 
			
		||||
 | 
			
		||||
use function microtime;
 | 
			
		||||
use function time;
 | 
			
		||||
 | 
			
		||||
class ServerRequestFactoryTest extends ServerRequestFactoryTestCase
 | 
			
		||||
{
 | 
			
		||||
    protected function createServerRequestFactory(): ServerRequestFactory
 | 
			
		||||
    {
 | 
			
		||||
        return new ServerRequestFactory();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected function createUri($uri): UriInterface
 | 
			
		||||
    {
 | 
			
		||||
        return (new UriFactory())->createUri($uri);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetProtocolVersion()
 | 
			
		||||
    {
 | 
			
		||||
        $env = Environment::mock(['SERVER_PROTOCOL' => 'HTTP/1.0']);
 | 
			
		||||
        $request = $this->createServerRequestFactory()->createServerRequest('GET', '', $env);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('1.0', $request->getProtocolVersion());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCreateFromGlobals()
 | 
			
		||||
    {
 | 
			
		||||
        $GLOBALS['getallheaders_return'] = [
 | 
			
		||||
            'ACCEPT' => 'application/json',
 | 
			
		||||
            'ACCEPT-CHARSET' => 'utf-8',
 | 
			
		||||
            'ACCEPT-LANGUAGE' => 'en-US',
 | 
			
		||||
            'CONTENT-TYPE' => 'multipart/form-data',
 | 
			
		||||
            'HOST' => 'example.com',
 | 
			
		||||
            'USER-AGENT' => 'Slim Framework',
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $_SERVER = Environment::mock([
 | 
			
		||||
            'HTTP_HOST' => 'example.com',
 | 
			
		||||
            'PHP_AUTH_PW' => 'sekrit',
 | 
			
		||||
            'PHP_AUTH_USER' => 'josh',
 | 
			
		||||
            'QUERY_STRING' => 'abc=123',
 | 
			
		||||
            'REMOTE_ADDR' => '127.0.0.1',
 | 
			
		||||
            'REQUEST_METHOD' => 'GET',
 | 
			
		||||
            'REQUEST_TIME' => time(),
 | 
			
		||||
            'REQUEST_TIME_FLOAT' => microtime(true),
 | 
			
		||||
            'REQUEST_URI' => '/foo/bar',
 | 
			
		||||
            'SCRIPT_NAME' => '/index.php',
 | 
			
		||||
            'SERVER_NAME' => 'localhost',
 | 
			
		||||
            'SERVER_PORT' => 8080,
 | 
			
		||||
            'SERVER_PROTOCOL' => 'HTTP/1.1',
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        $request = ServerRequestFactory::createFromGlobals();
 | 
			
		||||
 | 
			
		||||
        unset($GLOBALS['getallheaders_return']);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('GET', $request->getMethod());
 | 
			
		||||
        $this->assertEquals('1.1', $request->getProtocolVersion());
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('application/json', $request->getHeaderLine('Accept'));
 | 
			
		||||
        $this->assertEquals('utf-8', $request->getHeaderLine('Accept-Charset'));
 | 
			
		||||
        $this->assertEquals('en-US', $request->getHeaderLine('Accept-Language'));
 | 
			
		||||
        $this->assertEquals('multipart/form-data', $request->getHeaderLine('Content-Type'));
 | 
			
		||||
 | 
			
		||||
        $uri = $request->getUri();
 | 
			
		||||
        $this->assertEquals('josh:sekrit', $uri->getUserInfo());
 | 
			
		||||
        $this->assertEquals('example.com', $uri->getHost());
 | 
			
		||||
        $this->assertEquals('8080', $uri->getPort());
 | 
			
		||||
        $this->assertEquals('/foo/bar', $uri->getPath());
 | 
			
		||||
        $this->assertEquals('abc=123', $uri->getQuery());
 | 
			
		||||
        $this->assertEquals('', $uri->getFragment());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCreateFromGlobalsWithParsedBody()
 | 
			
		||||
    {
 | 
			
		||||
        $_SERVER = Environment::mock([
 | 
			
		||||
            'HTTP_CONTENT_TYPE' => 'multipart/form-data',
 | 
			
		||||
            'REQUEST_METHOD' => 'POST',
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        $_POST = [
 | 
			
		||||
            'def' => '456',
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $request = ServerRequestFactory::createFromGlobals();
 | 
			
		||||
 | 
			
		||||
        // $_POST should be placed into the parsed body
 | 
			
		||||
        $this->assertEquals($_POST, $request->getParsedBody());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCreateFromGlobalsBodyPointsToPhpInput()
 | 
			
		||||
    {
 | 
			
		||||
        $request = ServerRequestFactory::createFromGlobals();
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('php://input', $request->getBody()->getMetadata('uri'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCreateFromGlobalsSetsACache()
 | 
			
		||||
    {
 | 
			
		||||
        $request = ServerRequestFactory::createFromGlobals();
 | 
			
		||||
 | 
			
		||||
        // ensure that the Stream's $cache property has been set for this php://input stream
 | 
			
		||||
        $stream = $request->getBody();
 | 
			
		||||
        $class = new ReflectionClass($stream);
 | 
			
		||||
        $property = $class->getProperty('cache');
 | 
			
		||||
        $property->setAccessible(true);
 | 
			
		||||
        $cacheStreamValue = $property->getValue($stream);
 | 
			
		||||
        $this->assertNotNull($cacheStreamValue);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCreateFromGlobalsWithUploadedFiles()
 | 
			
		||||
    {
 | 
			
		||||
        $_SERVER = Environment::mock([
 | 
			
		||||
            'HTTP_CONTENT_TYPE' => 'multipart/form-data',
 | 
			
		||||
            'REQUEST_METHOD' => 'POST',
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        $_FILES = [
 | 
			
		||||
            'uploaded_file' => [
 | 
			
		||||
                'name' => [
 | 
			
		||||
                    0 => 'foo.jpg',
 | 
			
		||||
                    1 => 'bar.jpg',
 | 
			
		||||
                ],
 | 
			
		||||
 | 
			
		||||
                'type' => [
 | 
			
		||||
                    0 => 'image/jpeg',
 | 
			
		||||
                    1 => 'image/jpeg',
 | 
			
		||||
                ],
 | 
			
		||||
 | 
			
		||||
                'tmp_name' => [
 | 
			
		||||
                    0 => '/tmp/phpUA3XUw',
 | 
			
		||||
                    1 => '/tmp/phpXUFS0x',
 | 
			
		||||
                ],
 | 
			
		||||
 | 
			
		||||
                'error' => [
 | 
			
		||||
                    0 => 0,
 | 
			
		||||
                    1 => 0,
 | 
			
		||||
                ],
 | 
			
		||||
 | 
			
		||||
                'size' => [
 | 
			
		||||
                    0 => 358708,
 | 
			
		||||
                    1 => 236162,
 | 
			
		||||
                ],
 | 
			
		||||
            ]
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $request = ServerRequestFactory::createFromGlobals();
 | 
			
		||||
 | 
			
		||||
        // $_FILES should be mapped to an array of UploadedFile objects
 | 
			
		||||
        $uploadedFiles = $request->getUploadedFiles();
 | 
			
		||||
        $this->assertCount(1, $uploadedFiles);
 | 
			
		||||
        $this->assertArrayHasKey('uploaded_file', $uploadedFiles);
 | 
			
		||||
        $this->assertInstanceOf(UploadedFile::class, $uploadedFiles['uploaded_file'][0]);
 | 
			
		||||
        $this->assertInstanceOf(UploadedFile::class, $uploadedFiles['uploaded_file'][1]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCreateFromGlobalsParsesBodyWithFragmentedContentType()
 | 
			
		||||
    {
 | 
			
		||||
        $_SERVER = Environment::mock([
 | 
			
		||||
            'HTTP_CONTENT_TYPE' => 'application/x-www-form-urlencoded;charset=utf-8',
 | 
			
		||||
            'REQUEST_METHOD' => 'POST',
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        $_POST = [
 | 
			
		||||
            'def' => '456',
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $request = ServerRequestFactory::createFromGlobals();
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals($_POST, $request->getParsedBody());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCreateServerRequestWithNullAsUri()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
 | 
			
		||||
        $env = Environment::mock();
 | 
			
		||||
        $this->createServerRequestFactory()->createServerRequest('GET', null, $env);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCreateServerRequestWithInvalidUriObject()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
 | 
			
		||||
        $env = Environment::mock();
 | 
			
		||||
        $this->createServerRequestFactory()->createServerRequest('GET', new stdClass(), $env);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										66
									
								
								qwen/php/vendor/slim/psr7/tests/Factory/StreamFactoryTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								qwen/php/vendor/slim/psr7/tests/Factory/StreamFactoryTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,66 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Tests\Psr7\Factory;
 | 
			
		||||
 | 
			
		||||
use Interop\Http\Factory\StreamFactoryTestCase;
 | 
			
		||||
use InvalidArgumentException;
 | 
			
		||||
use RuntimeException;
 | 
			
		||||
use Slim\Psr7\Factory\StreamFactory;
 | 
			
		||||
 | 
			
		||||
class StreamFactoryTest extends StreamFactoryTestCase
 | 
			
		||||
{
 | 
			
		||||
    public function tearDown(): void
 | 
			
		||||
    {
 | 
			
		||||
        if (isset($GLOBALS['fopen_return'])) {
 | 
			
		||||
            unset($GLOBALS['fopen_return']);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected function createStreamFactory(): StreamFactory
 | 
			
		||||
    {
 | 
			
		||||
        return new StreamFactory();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCreateStreamThrowsRuntimeException()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(RuntimeException::class);
 | 
			
		||||
        $this->expectExceptionMessage('StreamFactory::createStream() could not open temporary file stream.');
 | 
			
		||||
 | 
			
		||||
        $GLOBALS['fopen_return'] = false;
 | 
			
		||||
 | 
			
		||||
        $factory = $this->createStreamFactory();
 | 
			
		||||
 | 
			
		||||
        $factory->createStream();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCreateStreamFromFileThrowsRuntimeException()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(RuntimeException::class);
 | 
			
		||||
        $this->expectExceptionMessage('StreamFactory::createStreamFromFile() could not create resource'
 | 
			
		||||
                                      . ' from file `non-readable`');
 | 
			
		||||
 | 
			
		||||
        $GLOBALS['fopen_return'] = false;
 | 
			
		||||
 | 
			
		||||
        $factory = $this->createStreamFactory();
 | 
			
		||||
 | 
			
		||||
        $factory->createStreamFromFile('non-readable');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCreateStreamFromResourceThrowsRuntimeException()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
        $this->expectExceptionMessage('Parameter 1 of StreamFactory::createStreamFromResource() must be a resource.');
 | 
			
		||||
 | 
			
		||||
        $factory = $this->createStreamFactory();
 | 
			
		||||
 | 
			
		||||
        $factory->createStreamFromResource('not-resource');
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										114
									
								
								qwen/php/vendor/slim/psr7/tests/Factory/UploadedFileFactoryTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										114
									
								
								qwen/php/vendor/slim/psr7/tests/Factory/UploadedFileFactoryTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,114 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Tests\Psr7\Factory;
 | 
			
		||||
 | 
			
		||||
use Interop\Http\Factory\UploadedFileFactoryTestCase;
 | 
			
		||||
use InvalidArgumentException;
 | 
			
		||||
use Prophecy\PhpUnit\ProphecyTrait;
 | 
			
		||||
use Psr\Http\Message\StreamInterface;
 | 
			
		||||
use Slim\Psr7\Factory\StreamFactory;
 | 
			
		||||
use Slim\Psr7\Factory\UploadedFileFactory;
 | 
			
		||||
 | 
			
		||||
use function fopen;
 | 
			
		||||
use function fwrite;
 | 
			
		||||
use function rewind;
 | 
			
		||||
use function sys_get_temp_dir;
 | 
			
		||||
use function tempnam;
 | 
			
		||||
 | 
			
		||||
class UploadedFileFactoryTest extends UploadedFileFactoryTestCase
 | 
			
		||||
{
 | 
			
		||||
    use ProphecyTrait;
 | 
			
		||||
 | 
			
		||||
    protected function createUploadedFileFactory(): UploadedFileFactory
 | 
			
		||||
    {
 | 
			
		||||
        return new UploadedFileFactory();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected function createStream($content): StreamInterface
 | 
			
		||||
    {
 | 
			
		||||
        $file = tempnam(sys_get_temp_dir(), 'Slim_Http_UploadedFileTest_');
 | 
			
		||||
        $resource = fopen($file, 'r+');
 | 
			
		||||
        fwrite($resource, $content);
 | 
			
		||||
        rewind($resource);
 | 
			
		||||
 | 
			
		||||
        return (new StreamFactory())->createStreamFromResource($resource);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Prophesize a `\Psr\Http\Message\StreamInterface` with a `getMetadata` method prophecy.
 | 
			
		||||
     *
 | 
			
		||||
     * @param string $argKey Argument for the method prophecy.
 | 
			
		||||
     * @param mixed $returnValue Return value of the `getMetadata` method.
 | 
			
		||||
     *
 | 
			
		||||
     * @return StreamInterface
 | 
			
		||||
     */
 | 
			
		||||
    protected function prophesizeStreamInterfaceWithGetMetadataMethod(string $argKey, $returnValue): StreamInterface
 | 
			
		||||
    {
 | 
			
		||||
        $streamProphecy = $this->prophesize(StreamInterface::class);
 | 
			
		||||
 | 
			
		||||
        /** @noinspection PhpUndefinedMethodInspection */
 | 
			
		||||
        $streamProphecy
 | 
			
		||||
            ->getMetadata($argKey)
 | 
			
		||||
            ->willReturn($returnValue)
 | 
			
		||||
            ->shouldBeCalled();
 | 
			
		||||
 | 
			
		||||
        /** @var StreamInterface $stream */
 | 
			
		||||
        $stream = $streamProphecy->reveal();
 | 
			
		||||
 | 
			
		||||
        return $stream;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCreateUploadedFileWithInvalidUri()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
        $this->expectExceptionMessage('File is not readable.');
 | 
			
		||||
 | 
			
		||||
        // Prophesize a `\Psr\Http\Message\StreamInterface` with a `getMetadata` method prophecy.
 | 
			
		||||
        $streamProphecy = $this->prophesize(StreamInterface::class);
 | 
			
		||||
 | 
			
		||||
        /** @noinspection PhpUndefinedMethodInspection */
 | 
			
		||||
        $streamProphecy
 | 
			
		||||
            ->getMetadata('uri')
 | 
			
		||||
            ->willReturn(null)
 | 
			
		||||
            ->shouldBeCalled();
 | 
			
		||||
 | 
			
		||||
        /** @var StreamInterface $stream */
 | 
			
		||||
        $stream = $streamProphecy->reveal();
 | 
			
		||||
 | 
			
		||||
        $this->factory->createUploadedFile($stream);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCreateUploadedFileWithNonReadableFile()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
        $this->expectExceptionMessage('File is not readable.');
 | 
			
		||||
 | 
			
		||||
        // Prophesize a `\Psr\Http\Message\StreamInterface` with a `getMetadata` and `isReadable` method prophecies.
 | 
			
		||||
        $streamProphecy = $this->prophesize(StreamInterface::class);
 | 
			
		||||
 | 
			
		||||
        /** @noinspection PhpUndefinedMethodInspection */
 | 
			
		||||
        $streamProphecy
 | 
			
		||||
            ->getMetadata('uri')
 | 
			
		||||
            ->willReturn('non-readable')
 | 
			
		||||
            ->shouldBeCalled();
 | 
			
		||||
 | 
			
		||||
        /** @noinspection PhpUndefinedMethodInspection */
 | 
			
		||||
        $streamProphecy
 | 
			
		||||
            ->isReadable()
 | 
			
		||||
            ->willReturn(false)
 | 
			
		||||
            ->shouldBeCalled();
 | 
			
		||||
 | 
			
		||||
        /** @var StreamInterface $stream */
 | 
			
		||||
        $stream = $streamProphecy->reveal();
 | 
			
		||||
 | 
			
		||||
        $this->factory->createUploadedFile($stream);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										243
									
								
								qwen/php/vendor/slim/psr7/tests/Factory/UriFactoryTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										243
									
								
								qwen/php/vendor/slim/psr7/tests/Factory/UriFactoryTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,243 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Tests\Psr7\Factory;
 | 
			
		||||
 | 
			
		||||
use Interop\Http\Factory\UriFactoryTestCase;
 | 
			
		||||
use Slim\Psr7\Environment;
 | 
			
		||||
use Slim\Psr7\Factory\UriFactory;
 | 
			
		||||
 | 
			
		||||
class UriFactoryTest extends UriFactoryTestCase
 | 
			
		||||
{
 | 
			
		||||
    protected function createUriFactory(): UriFactory
 | 
			
		||||
    {
 | 
			
		||||
        return new UriFactory();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetAuthorityWithUsername()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->createUriFactory()->createUri('https://josh@example.com/foo/bar?abc=123#section3');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('josh@example.com', $uri->getAuthority());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetAuthority()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->createUriFactory()->createUri('https://example.com/foo/bar?abc=123#section3');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('example.com', $uri->getAuthority());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetAuthorityWithNonStandardPort()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->createUriFactory()->createUri('https://example.com:400/foo/bar?abc=123#section3');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('example.com:400', $uri->getAuthority());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetUserInfoWithUsernameAndPassword()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->createUriFactory()->createUri('https://josh:sekrit@example.com:443/foo/bar?abc=123#section3');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('josh:sekrit', $uri->getUserInfo());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetUserInfoWithUsernameAndPasswordEncodesCorrectly()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this
 | 
			
		||||
            ->createUriFactory()
 | 
			
		||||
            ->createUri('https://bob@example.com:pass:word@example.com:443/foo/bar?abc=123#section3');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('bob%40example.com:pass%3Aword', $uri->getUserInfo());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetUserInfoWithUsername()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->createUriFactory()->createUri('http://josh@example.com/foo/bar?abc=123#section3');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('josh', $uri->getUserInfo());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetUserInfoNone()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->createUriFactory()->createUri('https://example.com/foo/bar?abc=123#section3');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('', $uri->getUserInfo());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCreateFromString()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->createUriFactory()->createUri('https://example.com:8080/foo/bar?abc=123');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('https', $uri->getScheme());
 | 
			
		||||
        $this->assertEquals('example.com', $uri->getHost());
 | 
			
		||||
        $this->assertEquals('8080', $uri->getPort());
 | 
			
		||||
        $this->assertEquals('/foo/bar', $uri->getPath());
 | 
			
		||||
        $this->assertEquals('abc=123', $uri->getQuery());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCreateFromGlobals()
 | 
			
		||||
    {
 | 
			
		||||
        $globals = Environment::mock([
 | 
			
		||||
            'SCRIPT_NAME' => '/index.php',
 | 
			
		||||
            'REQUEST_URI' => '/foo/bar?baz=1',
 | 
			
		||||
            'PHP_AUTH_USER' => 'josh',
 | 
			
		||||
            'PHP_AUTH_PW' => 'sekrit',
 | 
			
		||||
            'QUERY_STRING' => 'abc=123',
 | 
			
		||||
            'HTTP_HOST' => 'example.com:8080',
 | 
			
		||||
            'SERVER_PORT' => 8080,
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        $uri = $this->createUriFactory()->createFromGlobals($globals);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('josh:sekrit', $uri->getUserInfo());
 | 
			
		||||
        $this->assertEquals('example.com', $uri->getHost());
 | 
			
		||||
        $this->assertEquals('8080', $uri->getPort());
 | 
			
		||||
        $this->assertEquals('/foo/bar', $uri->getPath());
 | 
			
		||||
        $this->assertEquals('abc=123', $uri->getQuery());
 | 
			
		||||
        $this->assertEquals('', $uri->getFragment());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCreateFromGlobalsWithHttps()
 | 
			
		||||
    {
 | 
			
		||||
        $globals = Environment::mock(
 | 
			
		||||
            [
 | 
			
		||||
                'HTTPS' => 'on',
 | 
			
		||||
                'HTTP_HOST' => 'example.com'
 | 
			
		||||
            ]
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        // Make the 'SERVER_PORT' empty as we want to test if the default server port gets set correctly.
 | 
			
		||||
        $globals['SERVER_PORT'] = '';
 | 
			
		||||
 | 
			
		||||
        $uri = $this->createUriFactory()->createFromGlobals($globals);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('https', $uri->getScheme());
 | 
			
		||||
        $this->assertEquals('example.com', $uri->getHost());
 | 
			
		||||
 | 
			
		||||
        // The port is expected to be NULL as the server port is the default standard (443 in case of https).
 | 
			
		||||
        $this->assertNull($uri->getPort());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCreateFromGlobalsUsesServerNameAsHostIfHostHeaderIsNotPresent()
 | 
			
		||||
    {
 | 
			
		||||
        $globals = Environment::mock([
 | 
			
		||||
            'SERVER_NAME' => 'example.com',
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        $uri = $this->createUriFactory()->createFromGlobals($globals);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('example.com', $uri->getHost());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCreateFromGlobalWithIPv6HostNoPort()
 | 
			
		||||
    {
 | 
			
		||||
        $environment = Environment::mock([
 | 
			
		||||
            'SCRIPT_NAME' => '/index.php',
 | 
			
		||||
            'REQUEST_URI' => '/foo/bar',
 | 
			
		||||
            'PHP_AUTH_USER' => 'josh',
 | 
			
		||||
            'PHP_AUTH_PW' => 'sekrit',
 | 
			
		||||
            'QUERY_STRING' => 'abc=123',
 | 
			
		||||
            'HTTP_HOST' => '[2001:db8::1]',
 | 
			
		||||
            'REMOTE_ADDR' => '2001:db8::1',
 | 
			
		||||
            'SERVER_PORT' => 8080,
 | 
			
		||||
        ]);
 | 
			
		||||
        $uri = $this->createUriFactory()->createFromGlobals($environment);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('josh:sekrit', $uri->getUserInfo());
 | 
			
		||||
        $this->assertEquals('[2001:db8::1]', $uri->getHost());
 | 
			
		||||
        $this->assertEquals('8080', $uri->getPort());
 | 
			
		||||
        $this->assertEquals('/foo/bar', $uri->getPath());
 | 
			
		||||
        $this->assertEquals('abc=123', $uri->getQuery());
 | 
			
		||||
        $this->assertEquals('', $uri->getFragment());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCreateFromGlobalsWithIPv6HostWithPort()
 | 
			
		||||
    {
 | 
			
		||||
        $globals = Environment::mock([
 | 
			
		||||
            'SCRIPT_NAME' => '/index.php',
 | 
			
		||||
            'REQUEST_URI' => '/foo/bar',
 | 
			
		||||
            'PHP_AUTH_USER' => 'josh',
 | 
			
		||||
            'PHP_AUTH_PW' => 'sekrit',
 | 
			
		||||
            'QUERY_STRING' => 'abc=123',
 | 
			
		||||
            'HTTP_HOST' => '[2001:db8::1]:8080',
 | 
			
		||||
            'REMOTE_ADDR' => '2001:db8::1',
 | 
			
		||||
            'SERVER_PORT' => 8080,
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        $uri = $this->createUriFactory()->createFromGlobals($globals);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('josh:sekrit', $uri->getUserInfo());
 | 
			
		||||
        $this->assertEquals('[2001:db8::1]', $uri->getHost());
 | 
			
		||||
        $this->assertEquals('8080', $uri->getPort());
 | 
			
		||||
        $this->assertEquals('/foo/bar', $uri->getPath());
 | 
			
		||||
        $this->assertEquals('abc=123', $uri->getQuery());
 | 
			
		||||
        $this->assertEquals('', $uri->getFragment());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCreateFromGlobalsWithBasePathContainingSpace()
 | 
			
		||||
    {
 | 
			
		||||
        $globals = Environment::mock([
 | 
			
		||||
            'SCRIPT_NAME' => "/f'oo bar/index.php",
 | 
			
		||||
            'REQUEST_URI' => "/f%27oo%20bar/baz",
 | 
			
		||||
        ]);
 | 
			
		||||
        $uri = $this->createUriFactory()->createFromGlobals($globals);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('/f%27oo%20bar/baz', $uri->getPath());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithPathWhenBaseRootIsEmpty()
 | 
			
		||||
    {
 | 
			
		||||
        $globals = Environment::mock([
 | 
			
		||||
            'SCRIPT_NAME' => '/index.php',
 | 
			
		||||
            'REQUEST_URI' => '/bar',
 | 
			
		||||
        ]);
 | 
			
		||||
        $uri = $this->createUriFactory()->createFromGlobals($globals);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('http://localhost/test', (string) $uri->withPath('test'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * When the URL is /foo/index.php/bar/baz, we need the baseURL to be
 | 
			
		||||
     * /foo/index.php so that routing works correctly.
 | 
			
		||||
     *
 | 
			
		||||
     * @ticket 1639 as a fix to 1590 broke this.
 | 
			
		||||
     */
 | 
			
		||||
    public function testRequestURIContainsIndexDotPhp()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->createUriFactory()->createFromGlobals(
 | 
			
		||||
            Environment::mock(
 | 
			
		||||
                [
 | 
			
		||||
                    'SCRIPT_NAME' => '/foo/index.php',
 | 
			
		||||
                    'REQUEST_URI' => '/foo/index.php/bar/baz',
 | 
			
		||||
                ]
 | 
			
		||||
            )
 | 
			
		||||
        );
 | 
			
		||||
        $this->assertSame('/foo/index.php/bar/baz', $uri->getPath());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testRequestURICanContainParams()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->createUriFactory()->createFromGlobals(
 | 
			
		||||
            Environment::mock(
 | 
			
		||||
                [
 | 
			
		||||
                    'REQUEST_URI' => '/foo?abc=123',
 | 
			
		||||
                ]
 | 
			
		||||
            )
 | 
			
		||||
        );
 | 
			
		||||
        $this->assertEquals('abc=123', $uri->getQuery());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testUriDistinguishZeroFromEmptyString()
 | 
			
		||||
    {
 | 
			
		||||
        $expected = 'https://0:0@0:1/0?0#0';
 | 
			
		||||
        $this->assertSame($expected, (string) $this->createUriFactory()->createUri($expected));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										61
									
								
								qwen/php/vendor/slim/psr7/tests/HeaderTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								qwen/php/vendor/slim/psr7/tests/HeaderTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,61 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Tests\Psr7;
 | 
			
		||||
 | 
			
		||||
use PHPUnit\Framework\TestCase;
 | 
			
		||||
use Slim\Psr7\Header;
 | 
			
		||||
 | 
			
		||||
class HeaderTest extends TestCase
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * Instantiate a default header.
 | 
			
		||||
     *
 | 
			
		||||
     * @return Header
 | 
			
		||||
     */
 | 
			
		||||
    protected function headerFactory(): Header
 | 
			
		||||
    {
 | 
			
		||||
        $originalName = 'ACCEPT';
 | 
			
		||||
        $normalizedName = 'accept';
 | 
			
		||||
        $values = ['application/json'];
 | 
			
		||||
 | 
			
		||||
        return new Header($originalName, $normalizedName, $values);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetOriginalName(): void
 | 
			
		||||
    {
 | 
			
		||||
        $header = $this->headerFactory();
 | 
			
		||||
        $this->assertEquals('ACCEPT', $header->getOriginalName());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetNormalizedName(): void
 | 
			
		||||
    {
 | 
			
		||||
        $header = $this->headerFactory();
 | 
			
		||||
        $this->assertEquals('accept', $header->getNormalizedName());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testAddValue(): void
 | 
			
		||||
    {
 | 
			
		||||
        $header = $this->headerFactory();
 | 
			
		||||
        $header2 = $header->addValue('text/html');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(['application/json', 'text/html'], $header->getValues());
 | 
			
		||||
        $this->assertSame($header2, $header);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testAddValuesString(): void
 | 
			
		||||
    {
 | 
			
		||||
        $header = $this->headerFactory();
 | 
			
		||||
        $header2 = $header->addValues('text/html');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(['application/json', 'text/html'], $header->getValues());
 | 
			
		||||
        $this->assertSame($header2, $header);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										288
									
								
								qwen/php/vendor/slim/psr7/tests/HeadersTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										288
									
								
								qwen/php/vendor/slim/psr7/tests/HeadersTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,288 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Tests\Psr7;
 | 
			
		||||
 | 
			
		||||
use InvalidArgumentException;
 | 
			
		||||
use PHPUnit\Framework\TestCase;
 | 
			
		||||
use Slim\Psr7\Headers;
 | 
			
		||||
use stdClass;
 | 
			
		||||
 | 
			
		||||
use function base64_encode;
 | 
			
		||||
 | 
			
		||||
class HeadersTest extends TestCase
 | 
			
		||||
{
 | 
			
		||||
    public function testCreateFromGlobals()
 | 
			
		||||
    {
 | 
			
		||||
        $GLOBALS['getallheaders_return'] = [
 | 
			
		||||
            'HTTP_ACCEPT' => 'application/json',
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $headers = Headers::createFromGlobals();
 | 
			
		||||
 | 
			
		||||
        unset($GLOBALS['getallheaders_return']);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(['accept' => ['application/json']], $headers->getHeaders());
 | 
			
		||||
        $this->assertEquals(['ACCEPT' => ['application/json']], $headers->getHeaders(true));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCreateFromGlobalsUsesEmptyArrayIfGetAllHeadersReturnsFalse()
 | 
			
		||||
    {
 | 
			
		||||
        $GLOBALS['getallheaders_return'] = false;
 | 
			
		||||
 | 
			
		||||
        $headers = Headers::createFromGlobals();
 | 
			
		||||
 | 
			
		||||
        unset($GLOBALS['getallheaders_return']);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals([], $headers->getHeaders());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testAddHeader()
 | 
			
		||||
    {
 | 
			
		||||
        $headers = new Headers([
 | 
			
		||||
            'Accept' => 'application/json',
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        $headers->addHeader('Accept', 'text/html');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(['application/json', 'text/html'], $headers->getHeader('Accept'));
 | 
			
		||||
        $this->assertEquals(['accept' => ['application/json', 'text/html']], $headers->getHeaders());
 | 
			
		||||
        $this->assertEquals(['Accept' => ['application/json', 'text/html']], $headers->getHeaders(true));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testAddHeaderValueEmptyArray()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
 | 
			
		||||
        $headers = new Headers();
 | 
			
		||||
        $headers->addHeader('Header', []);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testRemoveHeader()
 | 
			
		||||
    {
 | 
			
		||||
        $headers = new Headers([
 | 
			
		||||
            'Accept' => 'application/json',
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        $headers->removeHeader('Accept');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals([], $headers->getHeader('Accept'));
 | 
			
		||||
        $this->assertEquals([], $headers->getHeaders());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @doesNotPerformAssertions
 | 
			
		||||
     */
 | 
			
		||||
    public function testRemoveHeaderByIncompatibleStringWithRFC()
 | 
			
		||||
    {
 | 
			
		||||
        $headers = new Headers();
 | 
			
		||||
        $headers->removeHeader('<incompatible with RFC>');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetHeader()
 | 
			
		||||
    {
 | 
			
		||||
        $headers = new Headers([
 | 
			
		||||
            'Accept' => ['application/json', 'text/html'],
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(['application/json', 'text/html'], $headers->getHeader('accept'));
 | 
			
		||||
        $this->assertEquals(['application/json', 'text/html'], $headers->getHeader('Accept'));
 | 
			
		||||
        $this->assertEquals(['application/json', 'text/html'], $headers->getHeader('HTTP_ACCEPT'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetHeaderReturnsValidatedAndTrimedHeaderDefaultValue()
 | 
			
		||||
    {
 | 
			
		||||
        $headers = new Headers([]);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(['application/json'], $headers->getHeader('accept', ' application/json'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetHeaderThrowsExceptionWithInvalidDefaultArgument()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
 | 
			
		||||
        $headers = new Headers([]);
 | 
			
		||||
 | 
			
		||||
        $headers->getHeader('accept', new stdClass());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testSetHeader()
 | 
			
		||||
    {
 | 
			
		||||
        $headers = new Headers([
 | 
			
		||||
            'Content-Length' => 0,
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        $headers->setHeader('Content-Length', 100);
 | 
			
		||||
 | 
			
		||||
        $this->assertSame(['100'], $headers->getHeader('Content-Length'));
 | 
			
		||||
        $this->assertEquals(['content-length' => ['100']], $headers->getHeaders());
 | 
			
		||||
        $this->assertEquals(['Content-Length' => ['100']], $headers->getHeaders(true));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testSetHeaderPreservesOriginalCaseIfHeaderAlreadyExists()
 | 
			
		||||
    {
 | 
			
		||||
        $headers = new Headers([
 | 
			
		||||
            'CONTENT-LENGTH' => 0,
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        $headers->setHeader('Content-Length', 100);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(['content-length' => ['100']], $headers->getHeaders());
 | 
			
		||||
        $this->assertEquals(['CONTENT-LENGTH' => ['100']], $headers->getHeaders(true));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testSetHeaders()
 | 
			
		||||
    {
 | 
			
		||||
        $headers = new Headers([
 | 
			
		||||
            'Content-Length' => 0,
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        $headers->setHeaders([
 | 
			
		||||
            'Accept' => 'application/json',
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(['accept' => ['application/json']], $headers->getHeaders());
 | 
			
		||||
        $this->assertEquals(['Accept' => ['application/json']], $headers->getHeaders(true));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testHasHeader()
 | 
			
		||||
    {
 | 
			
		||||
        $headers = new Headers([
 | 
			
		||||
            'Accept' => 'application/json',
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        $this->assertTrue($headers->hasHeader('accept'));
 | 
			
		||||
        $this->assertTrue($headers->hasHeader('Accept'));
 | 
			
		||||
        $this->assertTrue($headers->hasHeader('HTTP_ACCEPT'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetHeaders()
 | 
			
		||||
    {
 | 
			
		||||
        $headers = new Headers([
 | 
			
		||||
            'HTTP_ACCEPT' => 'text/html',
 | 
			
		||||
            'HTTP_CONTENT_TYPE' => 'application/json',
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        $expectedNormalizedHeaders = [
 | 
			
		||||
            'accept' => ['text/html'],
 | 
			
		||||
            'content-type' => ['application/json'],
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals($expectedNormalizedHeaders, $headers->getHeaders());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetHeadersPreservesOriginalCase()
 | 
			
		||||
    {
 | 
			
		||||
        $headers = new Headers([
 | 
			
		||||
            'HTTP_ACCEPT' => 'text/html',
 | 
			
		||||
            'HTTP_CONTENT_TYPE' => 'application/json',
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        $expectedOriginalHeaders = [
 | 
			
		||||
            'ACCEPT' => ['text/html'],
 | 
			
		||||
            'CONTENT-TYPE' => ['application/json'],
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals($expectedOriginalHeaders, $headers->getHeaders(true));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testParseAuthorizationHeader()
 | 
			
		||||
    {
 | 
			
		||||
        $expectedValue = 'Basic ' . base64_encode('user:password');
 | 
			
		||||
 | 
			
		||||
        $headers = new Headers(['Authorization' => $expectedValue]);
 | 
			
		||||
        $this->assertEquals([$expectedValue], $headers->getHeader('Authorization'));
 | 
			
		||||
 | 
			
		||||
        $headers = new Headers([], ['REDIRECT_HTTP_AUTHORIZATION' => 'cookie']);
 | 
			
		||||
        $this->assertEquals(['cookie'], $headers->getHeader('Authorization'));
 | 
			
		||||
 | 
			
		||||
        $headers = new Headers([], ['PHP_AUTH_USER' => 'user', 'PHP_AUTH_PW' => 'password']);
 | 
			
		||||
        $this->assertEquals([$expectedValue], $headers->getHeader('Authorization'));
 | 
			
		||||
 | 
			
		||||
        $headers = new Headers([], ['PHP_AUTH_DIGEST' => 'digest']);
 | 
			
		||||
        $this->assertEquals(['digest'], $headers->getHeader('Authorization'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @dataProvider provideInvalidHeaderNames
 | 
			
		||||
     */
 | 
			
		||||
    public function testWithInvalidHeaderName($headerName): void
 | 
			
		||||
    {
 | 
			
		||||
        $headers = new Headers();
 | 
			
		||||
 | 
			
		||||
        $this->expectException(\InvalidArgumentException::class);
 | 
			
		||||
 | 
			
		||||
        $headers->setHeader($headerName, 'foo');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static function provideInvalidHeaderNames(): array
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            [[]],
 | 
			
		||||
            [false],
 | 
			
		||||
            [new \stdClass()],
 | 
			
		||||
            ["Content-Type\r\n\r\n"],
 | 
			
		||||
            ["Content-Type\r\n"],
 | 
			
		||||
            ["Content-Type\n"],
 | 
			
		||||
            ["\r\nContent-Type"],
 | 
			
		||||
            ["\nContent-Type"],
 | 
			
		||||
            ["\n"],
 | 
			
		||||
            ["\r\n"],
 | 
			
		||||
            ["\t"],
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @dataProvider provideInvalidHeaderValues
 | 
			
		||||
     */
 | 
			
		||||
    public function testSetInvalidHeaderValue($headerValue)
 | 
			
		||||
    {
 | 
			
		||||
        $headers = new Headers();
 | 
			
		||||
 | 
			
		||||
        $this->expectException(\InvalidArgumentException::class);
 | 
			
		||||
 | 
			
		||||
        $headers->setHeader('Content-Type', $headerValue);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static function provideInvalidHeaderValues(): array
 | 
			
		||||
    {
 | 
			
		||||
        // Explicit tests for newlines as the most common exploit vector.
 | 
			
		||||
        $tests = [
 | 
			
		||||
            ["new\nline"],
 | 
			
		||||
            ["new\r\nline"],
 | 
			
		||||
            ["new\rline"],
 | 
			
		||||
            ["new\r\n line"],
 | 
			
		||||
            ["newline\n"],
 | 
			
		||||
            ["\nnewline"],
 | 
			
		||||
            ["newline\r\n"],
 | 
			
		||||
            ["\n\rnewline"],
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        for ($i = 0; $i <= 0xff; $i++) {
 | 
			
		||||
            if (\chr($i) == "\t") {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            if (\chr($i) == " ") {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            if ($i >= 0x21 && $i <= 0x7e) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            if ($i >= 0x80) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            $tests[] = ["foo" . \chr($i) . "bar"];
 | 
			
		||||
            $tests[] = ["foo" . \chr($i)];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $tests;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										57
									
								
								qwen/php/vendor/slim/psr7/tests/Integration/BaseTestFactories.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								qwen/php/vendor/slim/psr7/tests/Integration/BaseTestFactories.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,57 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Tests\Psr7\Integration;
 | 
			
		||||
 | 
			
		||||
use Psr\Http\Message\UriInterface;
 | 
			
		||||
use Slim\Psr7\Factory\UriFactory;
 | 
			
		||||
use Slim\Psr7\Stream;
 | 
			
		||||
use Slim\Psr7\UploadedFile;
 | 
			
		||||
 | 
			
		||||
use function fopen;
 | 
			
		||||
use function fwrite;
 | 
			
		||||
use function is_resource;
 | 
			
		||||
 | 
			
		||||
trait BaseTestFactories
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @param string $uri
 | 
			
		||||
     * @return UriInterface
 | 
			
		||||
     */
 | 
			
		||||
    protected function buildUri($uri): UriInterface
 | 
			
		||||
    {
 | 
			
		||||
        return (new UriFactory())->createUri($uri);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param $data
 | 
			
		||||
     * @return Stream
 | 
			
		||||
     */
 | 
			
		||||
    protected function buildStream($data): Stream
 | 
			
		||||
    {
 | 
			
		||||
        if (!is_resource($data)) {
 | 
			
		||||
            $h = fopen('php://temp', 'w+');
 | 
			
		||||
            fwrite($h, $data);
 | 
			
		||||
 | 
			
		||||
            $data = $h;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return new Stream($data);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param $data
 | 
			
		||||
     * @return UploadedFile
 | 
			
		||||
     */
 | 
			
		||||
    protected function buildUploadableFile($data): UploadedFile
 | 
			
		||||
    {
 | 
			
		||||
        return new UploadedFile($this->buildStream($data));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										36
									
								
								qwen/php/vendor/slim/psr7/tests/Integration/RequestTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								qwen/php/vendor/slim/psr7/tests/Integration/RequestTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Tests\Psr7\Integration;
 | 
			
		||||
 | 
			
		||||
use Http\Psr7Test\RequestIntegrationTest;
 | 
			
		||||
use Psr\Http\Message\RequestInterface;
 | 
			
		||||
use Slim\Psr7\Headers;
 | 
			
		||||
use Slim\Psr7\Request;
 | 
			
		||||
 | 
			
		||||
class RequestTest extends RequestIntegrationTest
 | 
			
		||||
{
 | 
			
		||||
    use BaseTestFactories;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @return RequestInterface that is used in the tests
 | 
			
		||||
     */
 | 
			
		||||
    public function createSubject(): RequestInterface
 | 
			
		||||
    {
 | 
			
		||||
        return new Request(
 | 
			
		||||
            'GET',
 | 
			
		||||
            $this->buildUri('/'),
 | 
			
		||||
            new Headers(),
 | 
			
		||||
            [],
 | 
			
		||||
            [],
 | 
			
		||||
            $this->buildStream('')
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										27
									
								
								qwen/php/vendor/slim/psr7/tests/Integration/ResponseTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								qwen/php/vendor/slim/psr7/tests/Integration/ResponseTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Tests\Psr7\Integration;
 | 
			
		||||
 | 
			
		||||
use Http\Psr7Test\ResponseIntegrationTest;
 | 
			
		||||
use Slim\Psr7\Response;
 | 
			
		||||
 | 
			
		||||
class ResponseTest extends ResponseIntegrationTest
 | 
			
		||||
{
 | 
			
		||||
    use BaseTestFactories;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @return Response that is used in the tests
 | 
			
		||||
     */
 | 
			
		||||
    public function createSubject(): Response
 | 
			
		||||
    {
 | 
			
		||||
        return new Response();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										35
									
								
								qwen/php/vendor/slim/psr7/tests/Integration/ServerRequestTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								qwen/php/vendor/slim/psr7/tests/Integration/ServerRequestTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,35 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Tests\Psr7\Integration;
 | 
			
		||||
 | 
			
		||||
use Http\Psr7Test\ServerRequestIntegrationTest;
 | 
			
		||||
use Slim\Psr7\Headers;
 | 
			
		||||
use Slim\Psr7\Request;
 | 
			
		||||
 | 
			
		||||
class ServerRequestTest extends ServerRequestIntegrationTest
 | 
			
		||||
{
 | 
			
		||||
    use BaseTestFactories;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @return Request
 | 
			
		||||
     */
 | 
			
		||||
    public function createSubject(): Request
 | 
			
		||||
    {
 | 
			
		||||
        return new Request(
 | 
			
		||||
            'GET',
 | 
			
		||||
            $this->buildUri('/'),
 | 
			
		||||
            new Headers(),
 | 
			
		||||
            $_COOKIE,
 | 
			
		||||
            $_SERVER,
 | 
			
		||||
            $this->buildStream('')
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										46
									
								
								qwen/php/vendor/slim/psr7/tests/Integration/StreamTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								qwen/php/vendor/slim/psr7/tests/Integration/StreamTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,46 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Tests\Psr7\Integration;
 | 
			
		||||
 | 
			
		||||
use Http\Psr7Test\StreamIntegrationTest;
 | 
			
		||||
use InvalidArgumentException;
 | 
			
		||||
use Psr\Http\Message\StreamInterface;
 | 
			
		||||
use Slim\Psr7\Stream;
 | 
			
		||||
 | 
			
		||||
use function fopen;
 | 
			
		||||
use function fwrite;
 | 
			
		||||
use function is_resource;
 | 
			
		||||
use function is_string;
 | 
			
		||||
 | 
			
		||||
class StreamTest extends StreamIntegrationTest
 | 
			
		||||
{
 | 
			
		||||
    use BaseTestFactories;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param string|resource|StreamInterface $data
 | 
			
		||||
     *
 | 
			
		||||
     * @return StreamInterface
 | 
			
		||||
     */
 | 
			
		||||
    public function createStream($data)
 | 
			
		||||
    {
 | 
			
		||||
        if ($data instanceof StreamInterface) {
 | 
			
		||||
            return $data;
 | 
			
		||||
        } elseif (is_resource($data)) {
 | 
			
		||||
            return new Stream($data);
 | 
			
		||||
        } elseif (is_string($data)) {
 | 
			
		||||
            $s = fopen('php://temp', 'w+');
 | 
			
		||||
            fwrite($s, $data);
 | 
			
		||||
            return new Stream($s);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        throw new InvalidArgumentException();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										51
									
								
								qwen/php/vendor/slim/psr7/tests/Integration/UploadedFileTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								qwen/php/vendor/slim/psr7/tests/Integration/UploadedFileTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,51 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Tests\Psr7\Integration;
 | 
			
		||||
 | 
			
		||||
use Http\Psr7Test\UploadedFileIntegrationTest;
 | 
			
		||||
use Psr\Http\Message\UploadedFileInterface;
 | 
			
		||||
use Slim\Psr7\UploadedFile;
 | 
			
		||||
 | 
			
		||||
use function sys_get_temp_dir;
 | 
			
		||||
use function tempnam;
 | 
			
		||||
 | 
			
		||||
class UploadedFileTest extends UploadedFileIntegrationTest
 | 
			
		||||
{
 | 
			
		||||
    use BaseTestFactories;
 | 
			
		||||
 | 
			
		||||
    protected string $tempFilename;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @return UploadedFileInterface
 | 
			
		||||
     */
 | 
			
		||||
    public function createSubject()
 | 
			
		||||
    {
 | 
			
		||||
        $this->tempFilename = tempnam(sys_get_temp_dir(), 'Slim_Http_UploadedFileTest_');
 | 
			
		||||
        if (!$this->tempFilename) {
 | 
			
		||||
            throw new \RuntimeException("Unable to create temporary file");
 | 
			
		||||
        }
 | 
			
		||||
        file_put_contents($this->tempFilename, '12345');
 | 
			
		||||
 | 
			
		||||
        return new UploadedFile(
 | 
			
		||||
            $this->tempFilename,
 | 
			
		||||
            basename($this->tempFilename),
 | 
			
		||||
            'text/plain',
 | 
			
		||||
            (int)filesize($this->tempFilename)
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected function tearDown(): void
 | 
			
		||||
    {
 | 
			
		||||
        if (is_file($this->tempFilename)) {
 | 
			
		||||
            unlink($this->tempFilename);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										30
									
								
								qwen/php/vendor/slim/psr7/tests/Integration/UriTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								qwen/php/vendor/slim/psr7/tests/Integration/UriTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,30 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Tests\Psr7\Integration;
 | 
			
		||||
 | 
			
		||||
use Http\Psr7Test\UriIntegrationTest;
 | 
			
		||||
use Psr\Http\Message\UriInterface;
 | 
			
		||||
use Slim\Psr7\Factory\UriFactory;
 | 
			
		||||
 | 
			
		||||
class UriTest extends UriIntegrationTest
 | 
			
		||||
{
 | 
			
		||||
    use BaseTestFactories;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param string $uri
 | 
			
		||||
     *
 | 
			
		||||
     * @return UriInterface
 | 
			
		||||
     */
 | 
			
		||||
    public function createUri($uri): UriInterface
 | 
			
		||||
    {
 | 
			
		||||
        return (new UriFactory())->createUri($uri);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										186
									
								
								qwen/php/vendor/slim/psr7/tests/MessageTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										186
									
								
								qwen/php/vendor/slim/psr7/tests/MessageTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,186 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Tests\Psr7;
 | 
			
		||||
 | 
			
		||||
use InvalidArgumentException;
 | 
			
		||||
use PHPUnit\Framework\MockObject\MockObject;
 | 
			
		||||
use PHPUnit\Framework\TestCase;
 | 
			
		||||
use Slim\Psr7\Headers;
 | 
			
		||||
use Slim\Psr7\Stream;
 | 
			
		||||
use Slim\Tests\Psr7\Mocks\MessageStub;
 | 
			
		||||
 | 
			
		||||
class MessageTest extends TestCase
 | 
			
		||||
{
 | 
			
		||||
    public function testGetProtocolVersion()
 | 
			
		||||
    {
 | 
			
		||||
        $message = new MessageStub();
 | 
			
		||||
        $message->protocolVersion = '1.0';
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('1.0', $message->getProtocolVersion());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithProtocolVersion()
 | 
			
		||||
    {
 | 
			
		||||
        $message = new MessageStub();
 | 
			
		||||
        $clone = $message->withProtocolVersion('1.0');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('1.0', $clone->protocolVersion);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithProtocolVersionInvalidThrowsException()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
 | 
			
		||||
        $message = new MessageStub();
 | 
			
		||||
        $message->withProtocolVersion('3.0');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetHeaders()
 | 
			
		||||
    {
 | 
			
		||||
        $headers = new Headers();
 | 
			
		||||
        $headers->addHeader('X-Foo', 'one');
 | 
			
		||||
        $headers->addHeader('X-Foo', 'two');
 | 
			
		||||
        $headers->addHeader('X-Foo', 'three');
 | 
			
		||||
 | 
			
		||||
        $message = new MessageStub();
 | 
			
		||||
        $message->headers = $headers;
 | 
			
		||||
 | 
			
		||||
        $shouldBe = [
 | 
			
		||||
            'X-Foo' => [
 | 
			
		||||
                'one',
 | 
			
		||||
                'two',
 | 
			
		||||
                'three',
 | 
			
		||||
            ],
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals($shouldBe, $message->getHeaders());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testHasHeader()
 | 
			
		||||
    {
 | 
			
		||||
        $headers = new Headers();
 | 
			
		||||
        $headers->addHeader('X-Foo', 'one');
 | 
			
		||||
 | 
			
		||||
        $message = new MessageStub();
 | 
			
		||||
        $message->headers = $headers;
 | 
			
		||||
 | 
			
		||||
        $this->assertTrue($message->hasHeader('X-Foo'));
 | 
			
		||||
        $this->assertFalse($message->hasHeader('X-Bar'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetHeaderLine()
 | 
			
		||||
    {
 | 
			
		||||
        $headers = new Headers();
 | 
			
		||||
        $headers->addHeader('X-Foo', 'one');
 | 
			
		||||
        $headers->addHeader('X-Foo', 'two');
 | 
			
		||||
        $headers->addHeader('X-Foo', 'three');
 | 
			
		||||
 | 
			
		||||
        $message = new MessageStub();
 | 
			
		||||
        $message->headers = $headers;
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('one,two,three', $message->getHeaderLine('X-Foo'));
 | 
			
		||||
        $this->assertEquals('', $message->getHeaderLine('X-Bar'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetHeader()
 | 
			
		||||
    {
 | 
			
		||||
        $headers = new Headers();
 | 
			
		||||
        $headers->addHeader('X-Foo', 'one');
 | 
			
		||||
        $headers->addHeader('X-Foo', 'two');
 | 
			
		||||
        $headers->addHeader('X-Foo', 'three');
 | 
			
		||||
 | 
			
		||||
        $message = new MessageStub();
 | 
			
		||||
        $message->headers = $headers;
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(['one', 'two', 'three'], $message->getHeader('X-Foo'));
 | 
			
		||||
        $this->assertEquals([], $message->getHeader('X-Bar'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithHeader()
 | 
			
		||||
    {
 | 
			
		||||
        $headers = new Headers();
 | 
			
		||||
        $headers->addHeader('X-Foo', 'one');
 | 
			
		||||
        $message = new MessageStub();
 | 
			
		||||
        $message->headers = $headers;
 | 
			
		||||
        $clone = $message->withHeader('X-Foo', 'bar');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('bar', $clone->getHeaderLine('X-Foo'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithAddedHeader()
 | 
			
		||||
    {
 | 
			
		||||
        $headers = new Headers();
 | 
			
		||||
        $headers->addHeader('X-Foo', 'one');
 | 
			
		||||
        $message = new MessageStub();
 | 
			
		||||
        $message->headers = $headers;
 | 
			
		||||
        $clone = $message->withAddedHeader('X-Foo', 'two');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('one,two', $clone->getHeaderLine('X-Foo'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithoutHeader()
 | 
			
		||||
    {
 | 
			
		||||
        $headers = new Headers();
 | 
			
		||||
        $headers->addHeader('X-Foo', 'one');
 | 
			
		||||
        $headers->addHeader('X-Bar', 'two');
 | 
			
		||||
        $response = new MessageStub();
 | 
			
		||||
        $response->headers = $headers;
 | 
			
		||||
        $clone = $response->withoutHeader('X-Foo');
 | 
			
		||||
        $shouldBe = [
 | 
			
		||||
            'X-Bar' => ['two'],
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals($shouldBe, $clone->getHeaders());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @doesNotPerformAssertions
 | 
			
		||||
     */
 | 
			
		||||
    public function testWithoutHeaderByIncompatibleStringWithRFC()
 | 
			
		||||
    {
 | 
			
		||||
        $headers = new Headers();
 | 
			
		||||
        $response = new MessageStub();
 | 
			
		||||
        $response->headers = $headers;
 | 
			
		||||
        $response->withoutHeader('<incompatible with RFC');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetBody()
 | 
			
		||||
    {
 | 
			
		||||
        $body = $this->getBody();
 | 
			
		||||
        $message = new MessageStub();
 | 
			
		||||
        $message->body = $body;
 | 
			
		||||
 | 
			
		||||
        $this->assertSame($body, $message->getBody());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithBody()
 | 
			
		||||
    {
 | 
			
		||||
        $body = $this->getBody();
 | 
			
		||||
        $body2 = $this->getBody();
 | 
			
		||||
        $message = new MessageStub();
 | 
			
		||||
        $message->body = $body;
 | 
			
		||||
        $clone = $message->withBody($body2);
 | 
			
		||||
 | 
			
		||||
        $this->assertSame($body, $message->body);
 | 
			
		||||
        $this->assertSame($body2, $clone->body);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @return MockObject|Stream
 | 
			
		||||
     */
 | 
			
		||||
    protected function getBody()
 | 
			
		||||
    {
 | 
			
		||||
        return $this
 | 
			
		||||
            ->getMockBuilder(Stream::class)
 | 
			
		||||
            ->disableOriginalConstructor()
 | 
			
		||||
            ->getMock();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										37
									
								
								qwen/php/vendor/slim/psr7/tests/Mocks/MessageStub.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								qwen/php/vendor/slim/psr7/tests/Mocks/MessageStub.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,37 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Tests\Psr7\Mocks;
 | 
			
		||||
 | 
			
		||||
use Psr\Http\Message\StreamInterface;
 | 
			
		||||
use Slim\Psr7\Interfaces\HeadersInterface;
 | 
			
		||||
use Slim\Psr7\Message;
 | 
			
		||||
 | 
			
		||||
class MessageStub extends Message
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * Protocol version
 | 
			
		||||
     */
 | 
			
		||||
    public string $protocolVersion;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Headers
 | 
			
		||||
     *
 | 
			
		||||
     * @var HeadersInterface
 | 
			
		||||
     */
 | 
			
		||||
    public $headers;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Body object
 | 
			
		||||
     *
 | 
			
		||||
     * @var StreamInterface
 | 
			
		||||
     */
 | 
			
		||||
    public $body;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										159
									
								
								qwen/php/vendor/slim/psr7/tests/NonBufferedBodyTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										159
									
								
								qwen/php/vendor/slim/psr7/tests/NonBufferedBodyTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,159 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Tests\Psr7;
 | 
			
		||||
 | 
			
		||||
use PHPUnit\Framework\TestCase;
 | 
			
		||||
use RuntimeException;
 | 
			
		||||
use Slim\Psr7\NonBufferedBody;
 | 
			
		||||
use Slim\Psr7\Response;
 | 
			
		||||
use Slim\Tests\Psr7\Assets\HeaderStack;
 | 
			
		||||
 | 
			
		||||
use function ob_get_clean;
 | 
			
		||||
use function ob_get_level;
 | 
			
		||||
use function ob_start;
 | 
			
		||||
use function strlen;
 | 
			
		||||
 | 
			
		||||
class NonBufferedBodyTest extends TestCase
 | 
			
		||||
{
 | 
			
		||||
    protected function setUp(): void
 | 
			
		||||
    {
 | 
			
		||||
        HeaderStack::reset();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected function tearDown(): void
 | 
			
		||||
    {
 | 
			
		||||
        HeaderStack::reset();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testTheStreamContract()
 | 
			
		||||
    {
 | 
			
		||||
        $body = new NonBufferedBody();
 | 
			
		||||
        self::assertSame('', (string) $body, 'Casting to string returns no data, since the class does not store any');
 | 
			
		||||
        self::assertNull($body->detach(), 'Returns null since there is no such underlying stream');
 | 
			
		||||
        self::assertNull($body->getSize(), 'Current size is undefined');
 | 
			
		||||
        self::assertSame(0, $body->tell(), 'Pointer is considered to be at position 0 to conform');
 | 
			
		||||
        self::assertTrue($body->eof(), 'Always considered to be at EOF');
 | 
			
		||||
        self::assertFalse($body->isSeekable(), 'Cannot seek');
 | 
			
		||||
        self::assertTrue($body->isWritable(), 'Body is writable');
 | 
			
		||||
        self::assertFalse($body->isReadable(), 'Body is not readable');
 | 
			
		||||
        self::assertSame('', $body->getContents(), 'Data cannot be retrieved once written');
 | 
			
		||||
        self::assertNull($body->getMetadata(), 'Metadata mechanism is not implemented');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWrite()
 | 
			
		||||
    {
 | 
			
		||||
        $ob_initial_level = ob_get_level();
 | 
			
		||||
 | 
			
		||||
        // Start output buffering.
 | 
			
		||||
        ob_start();
 | 
			
		||||
 | 
			
		||||
        // Start output buffering again to test the while-loop in the `write()`
 | 
			
		||||
        // method that calls `ob_get_clean()` as long as the ob level is bigger
 | 
			
		||||
        // than 0.
 | 
			
		||||
        ob_start();
 | 
			
		||||
        echo 'buffer content: ';
 | 
			
		||||
 | 
			
		||||
        // Set the ob level shift that should be applied in the `ob_get_level()`
 | 
			
		||||
        // function override. That way, the `write()` method would only flush
 | 
			
		||||
        // the second ob, not the first one. We will add the initial ob level
 | 
			
		||||
        // because phpunit may have started ob too.
 | 
			
		||||
        $GLOBALS['ob_get_level_shift'] = -($ob_initial_level + 1);
 | 
			
		||||
 | 
			
		||||
        $body = new NonBufferedBody();
 | 
			
		||||
        $length0 = $body->write('hello ');
 | 
			
		||||
        $length1 = $body->write('world');
 | 
			
		||||
 | 
			
		||||
        unset($GLOBALS['ob_get_level_shift']);
 | 
			
		||||
        $contents = ob_get_clean();
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(strlen('buffer content: ') + strlen('hello '), $length0);
 | 
			
		||||
        $this->assertEquals(strlen('world'), $length1);
 | 
			
		||||
        $this->assertEquals('buffer content: hello world', $contents);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithHeader()
 | 
			
		||||
    {
 | 
			
		||||
        (new Response())
 | 
			
		||||
            ->withBody(new NonBufferedBody())
 | 
			
		||||
            ->withHeader('Foo', 'Bar');
 | 
			
		||||
 | 
			
		||||
        self::assertSame([
 | 
			
		||||
            [
 | 
			
		||||
                'header' => 'Foo: Bar',
 | 
			
		||||
                'replace' => true,
 | 
			
		||||
                'status_code' => null
 | 
			
		||||
            ]
 | 
			
		||||
        ], HeaderStack::stack());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithAddedHeader()
 | 
			
		||||
    {
 | 
			
		||||
        (new Response())
 | 
			
		||||
            ->withBody(new NonBufferedBody())
 | 
			
		||||
            ->withHeader('Foo', 'Bar')
 | 
			
		||||
            ->withAddedHeader('Foo', 'Baz');
 | 
			
		||||
 | 
			
		||||
        self::assertSame([
 | 
			
		||||
            [
 | 
			
		||||
                'header' => 'Foo: Bar',
 | 
			
		||||
                'replace' => true,
 | 
			
		||||
                'status_code' => null
 | 
			
		||||
            ],
 | 
			
		||||
            [
 | 
			
		||||
                'header' => 'Foo: Bar,Baz',
 | 
			
		||||
                'replace' => true,
 | 
			
		||||
                'status_code' => null
 | 
			
		||||
            ]
 | 
			
		||||
        ], HeaderStack::stack());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithoutHeader()
 | 
			
		||||
    {
 | 
			
		||||
        (new Response())
 | 
			
		||||
            ->withBody(new NonBufferedBody())
 | 
			
		||||
            ->withHeader('Foo', 'Bar')
 | 
			
		||||
            ->withoutHeader('Foo');
 | 
			
		||||
 | 
			
		||||
        self::assertSame([], HeaderStack::stack());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCloseThrowsRuntimeException()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(RuntimeException::class);
 | 
			
		||||
        $this->expectExceptionMessage('A NonBufferedBody is not closable.');
 | 
			
		||||
 | 
			
		||||
        (new NonBufferedBody())->close();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testSeekThrowsRuntimeException()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(RuntimeException::class);
 | 
			
		||||
        $this->expectExceptionMessage('A NonBufferedBody is not seekable.');
 | 
			
		||||
 | 
			
		||||
        (new NonBufferedBody())->seek(10);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testRewindThrowsRuntimeException()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(RuntimeException::class);
 | 
			
		||||
        $this->expectExceptionMessage('A NonBufferedBody is not rewindable.');
 | 
			
		||||
 | 
			
		||||
        (new NonBufferedBody())->rewind();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testReadThrowsRuntimeException()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(RuntimeException::class);
 | 
			
		||||
        $this->expectExceptionMessage('A NonBufferedBody is not readable.');
 | 
			
		||||
 | 
			
		||||
        (new NonBufferedBody())->read(10);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										458
									
								
								qwen/php/vendor/slim/psr7/tests/RequestTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										458
									
								
								qwen/php/vendor/slim/psr7/tests/RequestTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,458 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Tests\Psr7;
 | 
			
		||||
 | 
			
		||||
use InvalidArgumentException;
 | 
			
		||||
use PHPUnit\Framework\TestCase;
 | 
			
		||||
use ReflectionProperty;
 | 
			
		||||
use Slim\Psr7\Environment;
 | 
			
		||||
use Slim\Psr7\Factory\StreamFactory;
 | 
			
		||||
use Slim\Psr7\Factory\UriFactory;
 | 
			
		||||
use Slim\Psr7\Headers;
 | 
			
		||||
use Slim\Psr7\Request;
 | 
			
		||||
use Slim\Psr7\UploadedFile;
 | 
			
		||||
use Slim\Psr7\Uri;
 | 
			
		||||
 | 
			
		||||
use function property_exists;
 | 
			
		||||
use function sprintf;
 | 
			
		||||
 | 
			
		||||
class RequestTest extends TestCase
 | 
			
		||||
{
 | 
			
		||||
    public function requestFactory($envData = []): Request
 | 
			
		||||
    {
 | 
			
		||||
        $env = Environment::mock($envData);
 | 
			
		||||
 | 
			
		||||
        $uri = (new UriFactory())->createUri('https://example.com:443/foo/bar?abc=123');
 | 
			
		||||
        $headers = Headers::createFromGlobals($env);
 | 
			
		||||
        $cookies = [
 | 
			
		||||
            'user' => 'john',
 | 
			
		||||
            'id' => '123',
 | 
			
		||||
        ];
 | 
			
		||||
        $serverParams = $env;
 | 
			
		||||
        $body = (new StreamFactory())->createStream();
 | 
			
		||||
        $uploadedFiles = UploadedFile::createFromGlobals($env);
 | 
			
		||||
        $request = new Request('GET', $uri, $headers, $cookies, $serverParams, $body, $uploadedFiles);
 | 
			
		||||
 | 
			
		||||
        return $request;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testDisableSetter()
 | 
			
		||||
    {
 | 
			
		||||
        $request = $this->requestFactory();
 | 
			
		||||
        $request->foo = 'bar';
 | 
			
		||||
 | 
			
		||||
        $this->assertFalse(property_exists($request, 'foo'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testAddsHostHeaderFromUri()
 | 
			
		||||
    {
 | 
			
		||||
        $request = $this->requestFactory();
 | 
			
		||||
        $this->assertEquals('example.com', $request->getHeaderLine('Host'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetMethod()
 | 
			
		||||
    {
 | 
			
		||||
        $this->assertEquals('GET', $this->requestFactory()->getMethod());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithMethod()
 | 
			
		||||
    {
 | 
			
		||||
        $request = $this->requestFactory()->withMethod('PUT');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('PUT', $request->getMethod());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithMethodCaseSensitive()
 | 
			
		||||
    {
 | 
			
		||||
        $request = $this->requestFactory()->withMethod('pOsT');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('pOsT', $request->getMethod());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithAllAllowedCharactersMethod()
 | 
			
		||||
    {
 | 
			
		||||
        $request = $this->requestFactory()->withMethod("!#$%&'*+.^_`|~09AZ-");
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals("!#$%&'*+.^_`|~09AZ-", $request->getMethod());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithMethodInvalid()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
 | 
			
		||||
        $this->requestFactory()->withMethod('B@R');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCreateRequestWithInvalidMethodString()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
 | 
			
		||||
        $uri = (new UriFactory())->createUri('https://example.com:443/foo/bar?abc=123');
 | 
			
		||||
        $headers = new Headers();
 | 
			
		||||
        $cookies = [];
 | 
			
		||||
        $serverParams = [];
 | 
			
		||||
        $body = (new StreamFactory())->createStream();
 | 
			
		||||
 | 
			
		||||
        new Request('B@R', $uri, $headers, $cookies, $serverParams, $body);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCreateRequestWithInvalidMethodOther()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
 | 
			
		||||
        $uri = (new UriFactory())->createUri('https://example.com:443/foo/bar?abc=123');
 | 
			
		||||
        $headers = new Headers();
 | 
			
		||||
        $cookies = [];
 | 
			
		||||
        $serverParams = [];
 | 
			
		||||
        $body = (new StreamFactory())->createStream();
 | 
			
		||||
 | 
			
		||||
        new Request(10, $uri, $headers, $cookies, $serverParams, $body);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetRequestTarget()
 | 
			
		||||
    {
 | 
			
		||||
        $this->assertEquals('/foo/bar?abc=123', $this->requestFactory()->getRequestTarget());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetRequestTargetAlreadySet()
 | 
			
		||||
    {
 | 
			
		||||
        $request = $this->requestFactory();
 | 
			
		||||
        $prop = new ReflectionProperty($request, 'requestTarget');
 | 
			
		||||
        $prop->setAccessible(true);
 | 
			
		||||
        $prop->setValue($request, '/foo/bar?abc=123');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('/foo/bar?abc=123', $request->getRequestTarget());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetRequestTargetIfNoUri()
 | 
			
		||||
    {
 | 
			
		||||
        $request = $this->requestFactory();
 | 
			
		||||
        $prop = new ReflectionProperty($request, 'uri');
 | 
			
		||||
        $prop->setAccessible(true);
 | 
			
		||||
        $prop->setValue($request, null);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('/', $request->getRequestTarget());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithRequestTarget()
 | 
			
		||||
    {
 | 
			
		||||
        $clone = $this->requestFactory()->withRequestTarget('/test?user=1');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('/test?user=1', $clone->getRequestTarget());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithRequestTargetThatHasSpaces()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
 | 
			
		||||
        $this->requestFactory()->withRequestTarget('/test/m ore/stuff?user=1');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetUri()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = (new UriFactory())->createUri('https://example.com:443/foo/bar?abc=123');
 | 
			
		||||
        $headers = new Headers();
 | 
			
		||||
        $cookies = [];
 | 
			
		||||
        $serverParams = [];
 | 
			
		||||
        $body = (new StreamFactory())->createStream();
 | 
			
		||||
        $request = new Request('GET', $uri, $headers, $cookies, $serverParams, $body);
 | 
			
		||||
 | 
			
		||||
        $this->assertSame($uri, $request->getUri());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithUri()
 | 
			
		||||
    {
 | 
			
		||||
        // Uris
 | 
			
		||||
        $uri1 = (new UriFactory())->createUri('https://example.com:443/foo/bar?abc=123');
 | 
			
		||||
        $uri2 = (new UriFactory())->createUri('https://example2.com:443/test?xyz=123');
 | 
			
		||||
 | 
			
		||||
        // Request
 | 
			
		||||
        $headers = new Headers();
 | 
			
		||||
        $cookies = [];
 | 
			
		||||
        $serverParams = [];
 | 
			
		||||
        $body = (new StreamFactory())->createStream();
 | 
			
		||||
        $request = new Request('GET', $uri1, $headers, $cookies, $serverParams, $body);
 | 
			
		||||
        $clone = $request->withUri($uri2);
 | 
			
		||||
 | 
			
		||||
        $this->assertSame($uri2, $clone->getUri());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithUriPreservesHost()
 | 
			
		||||
    {
 | 
			
		||||
        // When `$preserveHost` is set to `true`, this method interacts with
 | 
			
		||||
        // the Host header in the following ways:
 | 
			
		||||
 | 
			
		||||
        // - If the Host header is missing or empty, and the new URI contains
 | 
			
		||||
        //   a host component, this method MUST update the Host header in the returned
 | 
			
		||||
        //   request.
 | 
			
		||||
        $uri1 = (new UriFactory())->createUri('');
 | 
			
		||||
        $uri2 = (new UriFactory())->createUri('http://example2.com/test');
 | 
			
		||||
 | 
			
		||||
        // Request
 | 
			
		||||
        $headers = new Headers();
 | 
			
		||||
        $cookies = [];
 | 
			
		||||
        $serverParams = [];
 | 
			
		||||
        $body = (new StreamFactory())->createStream();
 | 
			
		||||
        $request = new Request('GET', $uri1, $headers, $cookies, $serverParams, $body);
 | 
			
		||||
 | 
			
		||||
        $clone = $request->withUri($uri2, true);
 | 
			
		||||
        $this->assertSame('example2.com', $clone->getHeaderLine('Host'));
 | 
			
		||||
 | 
			
		||||
        // - If the Host header is missing or empty, and the new URI does not contain a
 | 
			
		||||
        //   host component, this method MUST NOT update the Host header in the returned
 | 
			
		||||
        //   request.
 | 
			
		||||
        $uri3 = (new UriFactory())->createUri('');
 | 
			
		||||
 | 
			
		||||
        $clone = $request->withUri($uri3, true);
 | 
			
		||||
        $this->assertSame('', $clone->getHeaderLine('Host'));
 | 
			
		||||
 | 
			
		||||
        // - If a Host header is present and non-empty, this method MUST NOT update
 | 
			
		||||
        //   the Host header in the returned request.
 | 
			
		||||
        $request = $request->withHeader('Host', 'example.com');
 | 
			
		||||
        $clone = $request->withUri($uri2, true);
 | 
			
		||||
        $this->assertSame('example.com', $clone->getHeaderLine('Host'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetCookieParams()
 | 
			
		||||
    {
 | 
			
		||||
        $shouldBe = [
 | 
			
		||||
            'user' => 'john',
 | 
			
		||||
            'id' => '123',
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals($shouldBe, $this->requestFactory()->getCookieParams());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithCookieParams()
 | 
			
		||||
    {
 | 
			
		||||
        $request = $this->requestFactory();
 | 
			
		||||
        $clone = $request->withCookieParams(['type' => 'framework']);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(['type' => 'framework'], $clone->getCookieParams());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetQueryParams()
 | 
			
		||||
    {
 | 
			
		||||
        $this->assertEquals(['abc' => '123'], $this->requestFactory()->getQueryParams());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetQueryParamsAlreadySet()
 | 
			
		||||
    {
 | 
			
		||||
        $request = $this->requestFactory();
 | 
			
		||||
        $prop = new ReflectionProperty($request, 'queryParams');
 | 
			
		||||
        $prop->setAccessible(true);
 | 
			
		||||
        $prop->setValue($request, ['foo' => 'bar']);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(['foo' => 'bar'], $request->getQueryParams());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithQueryParams()
 | 
			
		||||
    {
 | 
			
		||||
        $request = $this->requestFactory();
 | 
			
		||||
        $clone = $request->withQueryParams(['foo' => 'bar']);
 | 
			
		||||
        $cloneUri = $clone->getUri();
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('abc=123', $cloneUri->getQuery()); // <-- Unchanged
 | 
			
		||||
        $this->assertEquals(['foo' => 'bar'], $clone->getQueryParams()); // <-- Changed
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithQueryParamsEmptyArray()
 | 
			
		||||
    {
 | 
			
		||||
        $request = $this->requestFactory();
 | 
			
		||||
        $clone = $request->withQueryParams([]);
 | 
			
		||||
        $cloneUri = $clone->getUri();
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('abc=123', $cloneUri->getQuery()); // <-- Unchanged
 | 
			
		||||
        $this->assertEquals([], $clone->getQueryParams()); // <-- Changed
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetQueryParamsWithoutUri()
 | 
			
		||||
    {
 | 
			
		||||
        $request = $this->requestFactory();
 | 
			
		||||
        $prop = new ReflectionProperty($request, 'uri');
 | 
			
		||||
        $prop->setAccessible(true);
 | 
			
		||||
        $prop->setValue($request, null);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals([], $request->getQueryParams());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithUploadedFiles()
 | 
			
		||||
    {
 | 
			
		||||
        $files = [new UploadedFile('foo.txt'), new UploadedFile('bar.txt')];
 | 
			
		||||
 | 
			
		||||
        $request = $this->requestFactory();
 | 
			
		||||
        $prevUploaded = $request->getUploadedFiles();
 | 
			
		||||
        $clone = $request->withUploadedFiles($files);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals($prevUploaded, $request->getUploadedFiles());
 | 
			
		||||
        $this->assertEquals($files, $clone->getUploadedFiles());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetServerParams()
 | 
			
		||||
    {
 | 
			
		||||
        $mockEnv = Environment::mock(["HTTP_AUTHORIZATION" => "test"]);
 | 
			
		||||
        $request = $this->requestFactory(["HTTP_AUTHORIZATION" => "test"]);
 | 
			
		||||
 | 
			
		||||
        $serverParams = $request->getServerParams();
 | 
			
		||||
        foreach ($serverParams as $key => $value) {
 | 
			
		||||
            if ($key == 'REQUEST_TIME' || $key == 'REQUEST_TIME_FLOAT') {
 | 
			
		||||
                $this->assertGreaterThanOrEqual(
 | 
			
		||||
                    $mockEnv[$key],
 | 
			
		||||
                    $value,
 | 
			
		||||
                    sprintf("%s value of %s was less than expected value of %s", $key, $value, $mockEnv[$key])
 | 
			
		||||
                );
 | 
			
		||||
            } else {
 | 
			
		||||
                $this->assertEquals(
 | 
			
		||||
                    $mockEnv[$key],
 | 
			
		||||
                    $value,
 | 
			
		||||
                    sprintf("%s value of %s did not equal expected value of %s", $key, $value, $mockEnv[$key])
 | 
			
		||||
                );
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetAttributes()
 | 
			
		||||
    {
 | 
			
		||||
        $request = $this->requestFactory();
 | 
			
		||||
        $attrProp = new ReflectionProperty($request, 'attributes');
 | 
			
		||||
        $attrProp->setAccessible(true);
 | 
			
		||||
        $attrProp->setValue($request, ['foo' => 'bar']);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(['foo' => 'bar'], $request->getAttributes());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetAttribute()
 | 
			
		||||
    {
 | 
			
		||||
        $request = $this->requestFactory();
 | 
			
		||||
        $attrProp = new ReflectionProperty($request, 'attributes');
 | 
			
		||||
        $attrProp->setAccessible(true);
 | 
			
		||||
        $attrProp->setValue($request, ['foo' => 'bar']);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('bar', $request->getAttribute('foo'));
 | 
			
		||||
        $this->assertNull($request->getAttribute('bar'));
 | 
			
		||||
        $this->assertEquals(2, $request->getAttribute('bar', 2));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithAttribute()
 | 
			
		||||
    {
 | 
			
		||||
        $request = $this->requestFactory();
 | 
			
		||||
        $attrProp = new ReflectionProperty($request, 'attributes');
 | 
			
		||||
        $attrProp->setAccessible(true);
 | 
			
		||||
        $attrProp->setValue($request, ['foo' => 'bar']);
 | 
			
		||||
        $clone = $request->withAttribute('test', '123');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('123', $clone->getAttribute('test'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithoutAttribute()
 | 
			
		||||
    {
 | 
			
		||||
        $request = $this->requestFactory();
 | 
			
		||||
        $attrProp = new ReflectionProperty($request, 'attributes');
 | 
			
		||||
        $attrProp->setAccessible(true);
 | 
			
		||||
        $attrProp->setValue($request, ['foo' => 'bar']);
 | 
			
		||||
        $clone = $request->withoutAttribute('foo');
 | 
			
		||||
 | 
			
		||||
        $this->assertNull($clone->getAttribute('foo'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetParsedBodyWhenAlreadyParsed()
 | 
			
		||||
    {
 | 
			
		||||
        $request = $this->requestFactory();
 | 
			
		||||
        $prop = new ReflectionProperty($request, 'parsedBody');
 | 
			
		||||
        $prop->setAccessible(true);
 | 
			
		||||
        $prop->setValue($request, ['foo' => 'bar']);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(['foo' => 'bar'], $request->getParsedBody());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetParsedBodyWhenBodyDoesNotExist()
 | 
			
		||||
    {
 | 
			
		||||
        $request = $this->requestFactory();
 | 
			
		||||
        $prop = new ReflectionProperty($request, 'body');
 | 
			
		||||
        $prop->setAccessible(true);
 | 
			
		||||
        $prop->setValue($request, null);
 | 
			
		||||
 | 
			
		||||
        $this->assertNull($request->getParsedBody());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithParsedBody()
 | 
			
		||||
    {
 | 
			
		||||
        $clone = $this->requestFactory()->withParsedBody(['xyz' => '123']);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(['xyz' => '123'], $clone->getParsedBody());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithParsedBodyEmptyArray()
 | 
			
		||||
    {
 | 
			
		||||
        $method = 'GET';
 | 
			
		||||
        $uri = new Uri('https', 'example.com', 443, '/foo/bar', 'abc=123', '', '');
 | 
			
		||||
        $headers = new Headers();
 | 
			
		||||
        $headers->setHeader('Content-Type', 'application/x-www-form-urlencoded;charset=utf8');
 | 
			
		||||
        $cookies = [];
 | 
			
		||||
        $serverParams = [];
 | 
			
		||||
        $body = (new StreamFactory())->createStream();
 | 
			
		||||
        $body->write('foo=bar');
 | 
			
		||||
        $request = new Request($method, $uri, $headers, $cookies, $serverParams, $body);
 | 
			
		||||
 | 
			
		||||
        $clone = $request->withParsedBody([]);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals([], $clone->getParsedBody());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithParsedBodyNull()
 | 
			
		||||
    {
 | 
			
		||||
        $method = 'GET';
 | 
			
		||||
        $uri = new Uri('https', 'example.com', 443, '/foo/bar', 'abc=123', '', '');
 | 
			
		||||
        $headers = new Headers();
 | 
			
		||||
        $headers->setHeader('Content-Type', 'application/x-www-form-urlencoded;charset=utf8');
 | 
			
		||||
        $cookies = [];
 | 
			
		||||
        $serverParams = [];
 | 
			
		||||
        $body = (new StreamFactory())->createStream();
 | 
			
		||||
        $body->write('foo=bar');
 | 
			
		||||
        $request = new Request($method, $uri, $headers, $cookies, $serverParams, $body);
 | 
			
		||||
 | 
			
		||||
        $clone = $request->withParsedBody(null);
 | 
			
		||||
 | 
			
		||||
        $this->assertNull($clone->getParsedBody());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetParsedBodyReturnsNullWhenThereIsNoBodyData()
 | 
			
		||||
    {
 | 
			
		||||
        $request = $this->requestFactory(['REQUEST_METHOD' => 'POST']);
 | 
			
		||||
 | 
			
		||||
        $this->assertNull($request->getParsedBody());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetParsedBodyReturnsNullWhenThereIsNoMediaTypeParserRegistered()
 | 
			
		||||
    {
 | 
			
		||||
        $request = $this->requestFactory([
 | 
			
		||||
            'REQUEST_METHOD' => 'POST',
 | 
			
		||||
            'CONTENT_TYPE' => 'text/csv',
 | 
			
		||||
        ]);
 | 
			
		||||
        $request->getBody()->write('foo,bar,baz');
 | 
			
		||||
 | 
			
		||||
        $this->assertNull($request->getParsedBody());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithParsedBodyInvalid()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
 | 
			
		||||
        $this->requestFactory()->withParsedBody(2);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithParsedBodyInvalidFalseValue()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
 | 
			
		||||
        $this->requestFactory()->withParsedBody(false);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										191
									
								
								qwen/php/vendor/slim/psr7/tests/ResponseTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										191
									
								
								qwen/php/vendor/slim/psr7/tests/ResponseTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,191 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Tests\Psr7;
 | 
			
		||||
 | 
			
		||||
use InvalidArgumentException;
 | 
			
		||||
use PHPUnit\Framework\TestCase;
 | 
			
		||||
use ReflectionProperty;
 | 
			
		||||
use Slim\Psr7\Environment;
 | 
			
		||||
use Slim\Psr7\Headers;
 | 
			
		||||
use Slim\Psr7\Response;
 | 
			
		||||
use Slim\Psr7\Stream;
 | 
			
		||||
use stdClass;
 | 
			
		||||
 | 
			
		||||
use function fopen;
 | 
			
		||||
use function property_exists;
 | 
			
		||||
 | 
			
		||||
class ResponseTest extends TestCase
 | 
			
		||||
{
 | 
			
		||||
    public function testConstructorWithDefaultArgs()
 | 
			
		||||
    {
 | 
			
		||||
        $response = new Response();
 | 
			
		||||
 | 
			
		||||
        $headersReflection = new ReflectionProperty($response, 'headers');
 | 
			
		||||
        $headersReflection->setAccessible(true);
 | 
			
		||||
 | 
			
		||||
        $bodyReflection = new ReflectionProperty($response, 'body');
 | 
			
		||||
        $bodyReflection->setAccessible(true);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(200, $response->getStatusCode());
 | 
			
		||||
        $this->assertInstanceOf(Headers::class, $headersReflection->getValue($response));
 | 
			
		||||
        $this->assertInstanceOf(Stream::class, $bodyReflection->getValue($response));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testConstructorWithCustomArgs()
 | 
			
		||||
    {
 | 
			
		||||
        $headers = new Headers();
 | 
			
		||||
        $body = new Stream(fopen('php://temp', 'r+'));
 | 
			
		||||
        $response = new Response(404, $headers, $body);
 | 
			
		||||
 | 
			
		||||
        $headersReflection = new ReflectionProperty($response, 'headers');
 | 
			
		||||
        $headersReflection->setAccessible(true);
 | 
			
		||||
 | 
			
		||||
        $bodyReflection = new ReflectionProperty($response, 'body');
 | 
			
		||||
        $bodyReflection->setAccessible(true);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(404, $response->getStatusCode());
 | 
			
		||||
        $this->assertSame($headers, $headersReflection->getValue($response));
 | 
			
		||||
        $this->assertSame($body, $bodyReflection->getValue($response));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testDeepCopyClone()
 | 
			
		||||
    {
 | 
			
		||||
        $headers = new Headers();
 | 
			
		||||
        $body = new Stream(fopen('php://temp', 'r+'));
 | 
			
		||||
        $response = new Response(404, $headers, $body);
 | 
			
		||||
        $clone = clone $response;
 | 
			
		||||
 | 
			
		||||
        $headersReflection = new ReflectionProperty($response, 'headers');
 | 
			
		||||
        $headersReflection->setAccessible(true);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(404, $clone->getStatusCode());
 | 
			
		||||
        $this->assertEquals('1.1', $clone->getProtocolVersion());
 | 
			
		||||
        $this->assertNotSame($headers, $headersReflection->getValue($clone));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testDisableSetter()
 | 
			
		||||
    {
 | 
			
		||||
        $response = new Response();
 | 
			
		||||
        $response->foo = 'bar';
 | 
			
		||||
 | 
			
		||||
        $this->assertFalse(property_exists($response, 'foo'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetStatusCode()
 | 
			
		||||
    {
 | 
			
		||||
        $response = new Response();
 | 
			
		||||
        $responseStatus = new ReflectionProperty($response, 'status');
 | 
			
		||||
        $responseStatus->setAccessible(true);
 | 
			
		||||
        $responseStatus->setValue($response, 404);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(404, $response->getStatusCode());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithStatus()
 | 
			
		||||
    {
 | 
			
		||||
        $response = new Response();
 | 
			
		||||
        $clone = $response->withStatus(302);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(302, $clone->getStatusCode());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithStatusInvalidStatusCodeThrowsException()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
 | 
			
		||||
        $response = new Response();
 | 
			
		||||
        $response->withStatus(800);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithStatusInvalidReasonPhraseThrowsException()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
        $this->expectExceptionMessage('Response reason phrase must be a string');
 | 
			
		||||
 | 
			
		||||
        $response = new Response();
 | 
			
		||||
        $response->withStatus(200, null);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithStatusEmptyReasonPhrase()
 | 
			
		||||
    {
 | 
			
		||||
        $responseWithNoMessage = new Response(310);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('', $responseWithNoMessage->getReasonPhrase());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testReasonPhraseContainsCarriageReturn()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
        $this->expectExceptionMessage('Reason phrase contains one of the following prohibited characters: \r \n');
 | 
			
		||||
 | 
			
		||||
        $response = new Response();
 | 
			
		||||
        $response = $response->withStatus(404, "Not Found\r");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testReasonPhraseContainsLineFeed()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
        $this->expectExceptionMessage('Reason phrase contains one of the following prohibited characters: \r \n');
 | 
			
		||||
 | 
			
		||||
        $response = new Response();
 | 
			
		||||
        $response = $response->withStatus(404, "Not Found\n");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithStatusValidReasonPhraseObject()
 | 
			
		||||
    {
 | 
			
		||||
        $response = new Response();
 | 
			
		||||
        $response = $response->withStatus(200, new StringableTestObject('Slim OK'));
 | 
			
		||||
        $this->assertEquals('Slim OK', $response->getReasonPhrase());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetReasonPhrase()
 | 
			
		||||
    {
 | 
			
		||||
        $response = new Response(404);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('Not Found', $response->getReasonPhrase());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testEmptyReasonPhraseForUnrecognisedCode()
 | 
			
		||||
    {
 | 
			
		||||
        $response = new Response();
 | 
			
		||||
        $response = $response->withStatus(199);
 | 
			
		||||
 | 
			
		||||
        $this->assertSame('', $response->getReasonPhrase());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testSetReasonPhraseForUnrecognisedCode()
 | 
			
		||||
    {
 | 
			
		||||
        $response = new Response();
 | 
			
		||||
        $response = $response->withStatus(199, 'Random Message');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('Random Message', $response->getReasonPhrase());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetCustomReasonPhrase()
 | 
			
		||||
    {
 | 
			
		||||
        $response = new Response();
 | 
			
		||||
        $clone = $response->withStatus(200, 'Custom Phrase');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('Custom Phrase', $clone->getReasonPhrase());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testResponseHeadersDoNotContainAuthorizationHeader()
 | 
			
		||||
    {
 | 
			
		||||
        $_SERVER = Environment::mock(
 | 
			
		||||
            [
 | 
			
		||||
                'PHP_AUTH_USER' => 'foo'
 | 
			
		||||
            ]
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        $response = new Response();
 | 
			
		||||
        $this->assertEmpty($response->getHeaders());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										284
									
								
								qwen/php/vendor/slim/psr7/tests/StreamTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										284
									
								
								qwen/php/vendor/slim/psr7/tests/StreamTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,284 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Tests\Psr7;
 | 
			
		||||
 | 
			
		||||
use PHPUnit\Framework\TestCase;
 | 
			
		||||
use Prophecy\PhpUnit\ProphecyTrait;
 | 
			
		||||
use ReflectionException;
 | 
			
		||||
use ReflectionMethod;
 | 
			
		||||
use ReflectionProperty;
 | 
			
		||||
use RuntimeException;
 | 
			
		||||
use Slim\Psr7\Stream;
 | 
			
		||||
 | 
			
		||||
use function fopen;
 | 
			
		||||
use function popen;
 | 
			
		||||
use function stream_get_contents;
 | 
			
		||||
use function trim;
 | 
			
		||||
 | 
			
		||||
class StreamTest extends TestCase
 | 
			
		||||
{
 | 
			
		||||
    use ProphecyTrait;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var resource pipe stream file handle
 | 
			
		||||
     */
 | 
			
		||||
    private $pipeFh;
 | 
			
		||||
 | 
			
		||||
    private Stream $pipeStream;
 | 
			
		||||
 | 
			
		||||
    public function tearDown(): void
 | 
			
		||||
    {
 | 
			
		||||
        if ($this->pipeFh != null) {
 | 
			
		||||
            // prevent broken pipe error message
 | 
			
		||||
            stream_get_contents($this->pipeFh);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testIsPipe()
 | 
			
		||||
    {
 | 
			
		||||
        $this->openPipeStream();
 | 
			
		||||
 | 
			
		||||
        $this->assertTrue($this->pipeStream->isPipe());
 | 
			
		||||
 | 
			
		||||
        $this->pipeStream->detach();
 | 
			
		||||
        $this->assertFalse($this->pipeStream->isPipe());
 | 
			
		||||
 | 
			
		||||
        $fhFile = fopen(__FILE__, 'r');
 | 
			
		||||
        $fileStream = new Stream($fhFile);
 | 
			
		||||
        $this->assertFalse($fileStream->isPipe());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testIsPipeReadable()
 | 
			
		||||
    {
 | 
			
		||||
        $this->openPipeStream();
 | 
			
		||||
 | 
			
		||||
        $this->assertTrue($this->pipeStream->isReadable());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testPipeIsNotSeekable()
 | 
			
		||||
    {
 | 
			
		||||
        $this->openPipeStream();
 | 
			
		||||
 | 
			
		||||
        $this->assertFalse($this->pipeStream->isSeekable());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCannotSeekPipe()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(RuntimeException::class);
 | 
			
		||||
 | 
			
		||||
        $this->openPipeStream();
 | 
			
		||||
 | 
			
		||||
        $this->pipeStream->seek(0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCannotTellPipe()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(RuntimeException::class);
 | 
			
		||||
 | 
			
		||||
        $this->openPipeStream();
 | 
			
		||||
 | 
			
		||||
        $this->pipeStream->tell();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCannotRewindPipe()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(RuntimeException::class);
 | 
			
		||||
 | 
			
		||||
        $this->openPipeStream();
 | 
			
		||||
 | 
			
		||||
        $this->pipeStream->rewind();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testPipeGetSizeYieldsNull()
 | 
			
		||||
    {
 | 
			
		||||
        $this->openPipeStream();
 | 
			
		||||
 | 
			
		||||
        $this->assertNull($this->pipeStream->getSize());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testClosePipe()
 | 
			
		||||
    {
 | 
			
		||||
        $this->openPipeStream();
 | 
			
		||||
 | 
			
		||||
        // prevent broken pipe error message
 | 
			
		||||
        stream_get_contents($this->pipeFh);
 | 
			
		||||
 | 
			
		||||
        $this->pipeStream->close();
 | 
			
		||||
        $this->pipeFh = null;
 | 
			
		||||
 | 
			
		||||
        $this->assertFalse($this->pipeStream->isPipe());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testPipeToString()
 | 
			
		||||
    {
 | 
			
		||||
        $this->openPipeStream();
 | 
			
		||||
        $content = trim((string) $this->pipeStream);
 | 
			
		||||
 | 
			
		||||
        $this->assertSame('12', $content);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testConvertsToStringPartiallyReadNonSeekableStream()
 | 
			
		||||
    {
 | 
			
		||||
        $this->openPipeStream();
 | 
			
		||||
        $head = $this->pipeStream->read(1);
 | 
			
		||||
        $tail = trim((string) $this->pipeStream);
 | 
			
		||||
 | 
			
		||||
        $this->assertSame('1', $head);
 | 
			
		||||
        $this->assertSame('2', $tail);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testPipeGetContents()
 | 
			
		||||
    {
 | 
			
		||||
        $this->openPipeStream();
 | 
			
		||||
 | 
			
		||||
        $contents = trim($this->pipeStream->getContents());
 | 
			
		||||
        $this->assertSame('12', $contents);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testIsWriteable()
 | 
			
		||||
    {
 | 
			
		||||
        $resource = fopen('php://temp', 'w');
 | 
			
		||||
        $stream = new Stream($resource);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(13, $stream->write('Hello, world!'));
 | 
			
		||||
 | 
			
		||||
        $this->assertTrue($stream->isWritable());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testIsReadable()
 | 
			
		||||
    {
 | 
			
		||||
        $resource = fopen('php://temp', 'r');
 | 
			
		||||
        $stream = new Stream($resource);
 | 
			
		||||
 | 
			
		||||
        $this->assertTrue($stream->isReadable());
 | 
			
		||||
        $this->assertFalse($stream->isWritable());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testIsWritableAndReadable()
 | 
			
		||||
    {
 | 
			
		||||
        $resource = fopen('php://temp', 'w+');
 | 
			
		||||
        $stream = new Stream($resource);
 | 
			
		||||
 | 
			
		||||
        $stream->write('Hello, world!');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('Hello, world!', $stream);
 | 
			
		||||
 | 
			
		||||
        $this->assertTrue($stream->isWritable());
 | 
			
		||||
        $this->assertTrue($stream->isReadable());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Test that a call to the protected method `attach` would invoke `detach`.
 | 
			
		||||
     *
 | 
			
		||||
     * @throws ReflectionException
 | 
			
		||||
     */
 | 
			
		||||
    public function testAttachAgain()
 | 
			
		||||
    {
 | 
			
		||||
        $this->openPipeStream();
 | 
			
		||||
 | 
			
		||||
        $streamProphecy = $this->prophesize(Stream::class);
 | 
			
		||||
 | 
			
		||||
        /** @noinspection PhpUndefinedMethodInspection */
 | 
			
		||||
        $streamProphecy->detach()->shouldBeCalled();
 | 
			
		||||
 | 
			
		||||
        /** @var Stream $stream */
 | 
			
		||||
        $stream = $streamProphecy->reveal();
 | 
			
		||||
 | 
			
		||||
        $streamProperty = new ReflectionProperty(Stream::class, 'stream');
 | 
			
		||||
        $streamProperty->setAccessible(true);
 | 
			
		||||
        $streamProperty->setValue($stream, $this->pipeFh);
 | 
			
		||||
 | 
			
		||||
        $attachMethod = new ReflectionMethod(Stream::class, 'attach');
 | 
			
		||||
        $attachMethod->setAccessible(true);
 | 
			
		||||
        $attachMethod->invoke($stream, $this->pipeFh);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetMetaDataReturnsNullIfStreamIsDetached()
 | 
			
		||||
    {
 | 
			
		||||
        $resource = fopen('php://temp', 'rw+');
 | 
			
		||||
        $stream = new Stream($resource);
 | 
			
		||||
        $stream->detach();
 | 
			
		||||
 | 
			
		||||
        $this->assertNull($stream->getMetadata());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private function openPipeStream()
 | 
			
		||||
    {
 | 
			
		||||
        $this->pipeFh = popen('echo 12', 'r');
 | 
			
		||||
        $this->pipeStream = new Stream($this->pipeFh);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testReadOnlyCachedStreamsAreDisallowed()
 | 
			
		||||
    {
 | 
			
		||||
        $resource = fopen('php://temp', 'w+');
 | 
			
		||||
        $cache =  new Stream(fopen('php://temp', 'r'));
 | 
			
		||||
 | 
			
		||||
        $this->expectException(RuntimeException::class);
 | 
			
		||||
        $this->expectExceptionMessage('Cache stream must be seekable and writable');
 | 
			
		||||
        new Stream($resource, $cache);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testNonSeekableCachedStreamsAreDisallowed()
 | 
			
		||||
    {
 | 
			
		||||
        $resource = fopen('php://temp', 'w+');
 | 
			
		||||
        $cache =  new Stream(fopen('php://output', 'w'));
 | 
			
		||||
 | 
			
		||||
        $this->expectException(RuntimeException::class);
 | 
			
		||||
        $this->expectExceptionMessage('Cache stream must be seekable and writable');
 | 
			
		||||
 | 
			
		||||
        new Stream($resource, $cache);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCachedStreamsGetsContentFromTheCache()
 | 
			
		||||
    {
 | 
			
		||||
        $resource = popen('echo HelloWorld', 'r');
 | 
			
		||||
        $stream = new Stream($resource, new Stream(fopen('php://temp', 'w+')));
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals("HelloWorld\n", $stream->getContents());
 | 
			
		||||
        $this->assertEquals("HelloWorld\n", $stream->getContents());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCachedStreamsFillsCacheOnRead()
 | 
			
		||||
    {
 | 
			
		||||
        $resource = fopen('data://,0', 'r');
 | 
			
		||||
        $stream = new Stream($resource, new Stream(fopen('php://temp', 'w+')));
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals("0", $stream->read(100));
 | 
			
		||||
        $this->assertEquals("0", $stream->__toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testDetachingStreamDropsCache()
 | 
			
		||||
    {
 | 
			
		||||
        $cache = new Stream(fopen('php://temp', 'w+'));
 | 
			
		||||
        $resource = fopen('data://,foo', 'r');
 | 
			
		||||
        $stream = new Stream($resource, $cache);
 | 
			
		||||
 | 
			
		||||
        $stream->detach();
 | 
			
		||||
 | 
			
		||||
        $cacheProperty = new ReflectionProperty(Stream::class, 'cache');
 | 
			
		||||
        $cacheProperty->setAccessible(true);
 | 
			
		||||
        $finishedProperty = new ReflectionProperty(Stream::class, 'finished');
 | 
			
		||||
        $finishedProperty->setAccessible(true);
 | 
			
		||||
 | 
			
		||||
        $this->assertNull($cacheProperty->getValue($stream));
 | 
			
		||||
        $this->assertFalse($finishedProperty->getValue($stream));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCachedStreamsRewindIfFinishedOnToString()
 | 
			
		||||
    {
 | 
			
		||||
        $resource = fopen('data://,foo', 'r');
 | 
			
		||||
 | 
			
		||||
        $stream = new Stream($resource, new Stream(fopen('php://temp', 'w+')));
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('foo', (string)$stream);
 | 
			
		||||
        $this->assertEquals('foo', (string)$stream);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										23
									
								
								qwen/php/vendor/slim/psr7/tests/StringableTestObject.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								qwen/php/vendor/slim/psr7/tests/StringableTestObject.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Tests\Psr7;
 | 
			
		||||
 | 
			
		||||
final class StringableTestObject implements \Stringable
 | 
			
		||||
{
 | 
			
		||||
    public function __construct(private string $value)
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function __toString(): string
 | 
			
		||||
    {
 | 
			
		||||
        return $this->value;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										676
									
								
								qwen/php/vendor/slim/psr7/tests/UploadedFileTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										676
									
								
								qwen/php/vendor/slim/psr7/tests/UploadedFileTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,676 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Tests\Psr7;
 | 
			
		||||
 | 
			
		||||
use InvalidArgumentException;
 | 
			
		||||
use PHPUnit\Framework\TestCase;
 | 
			
		||||
use Prophecy\PhpUnit\ProphecyTrait;
 | 
			
		||||
use Psr\Http\Message\StreamInterface;
 | 
			
		||||
use Psr\Http\Message\UploadedFileInterface;
 | 
			
		||||
use ReflectionProperty;
 | 
			
		||||
use RuntimeException;
 | 
			
		||||
use Slim\Psr7\Environment;
 | 
			
		||||
use Slim\Psr7\Factory\StreamFactory;
 | 
			
		||||
use Slim\Psr7\Factory\UploadedFileFactory;
 | 
			
		||||
use Slim\Psr7\Stream;
 | 
			
		||||
use Slim\Psr7\UploadedFile;
 | 
			
		||||
 | 
			
		||||
use function call_user_func;
 | 
			
		||||
use function fclose;
 | 
			
		||||
use function file_exists;
 | 
			
		||||
use function file_get_contents;
 | 
			
		||||
use function fopen;
 | 
			
		||||
use function fwrite;
 | 
			
		||||
use function microtime;
 | 
			
		||||
use function ob_get_clean;
 | 
			
		||||
use function ob_start;
 | 
			
		||||
use function strlen;
 | 
			
		||||
use function sys_get_temp_dir;
 | 
			
		||||
use function uniqid;
 | 
			
		||||
use function unlink;
 | 
			
		||||
use function version_compare;
 | 
			
		||||
 | 
			
		||||
use const DIRECTORY_SEPARATOR;
 | 
			
		||||
use const UPLOAD_ERR_CANT_WRITE;
 | 
			
		||||
use const UPLOAD_ERR_OK;
 | 
			
		||||
 | 
			
		||||
class UploadedFileTest extends TestCase
 | 
			
		||||
{
 | 
			
		||||
    use ProphecyTrait;
 | 
			
		||||
 | 
			
		||||
    private static string $filename = './phpUxcOty';
 | 
			
		||||
 | 
			
		||||
    private static array $tmpFiles = ['./phpUxcOty'];
 | 
			
		||||
 | 
			
		||||
    public static function setUpBeforeClass(): void
 | 
			
		||||
    {
 | 
			
		||||
        $fh = fopen(self::$filename, "w");
 | 
			
		||||
        fwrite($fh, "12345678");
 | 
			
		||||
        fclose($fh);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static function tearDownAfterClass(): void
 | 
			
		||||
    {
 | 
			
		||||
        foreach (self::$tmpFiles as $filename) {
 | 
			
		||||
            if (file_exists($filename)) {
 | 
			
		||||
                unlink($filename);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function tearDown(): void
 | 
			
		||||
    {
 | 
			
		||||
        if (isset($GLOBALS['is_uploaded_file_return'])) {
 | 
			
		||||
            unset($GLOBALS['is_uploaded_file_return']);
 | 
			
		||||
        }
 | 
			
		||||
        if (isset($GLOBALS['copy_return'])) {
 | 
			
		||||
            unset($GLOBALS['copy_return']);
 | 
			
		||||
        }
 | 
			
		||||
        if (isset($GLOBALS['rename_return'])) {
 | 
			
		||||
            unset($GLOBALS['rename_return']);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected function generateNewTmpFile(): UploadedFile
 | 
			
		||||
    {
 | 
			
		||||
        $filename = './php' . microtime();
 | 
			
		||||
 | 
			
		||||
        $fh = fopen($filename, "w");
 | 
			
		||||
        fwrite($fh, "12345678");
 | 
			
		||||
        fclose($fh);
 | 
			
		||||
 | 
			
		||||
        self::$tmpFiles[] = $filename;
 | 
			
		||||
 | 
			
		||||
        return new UploadedFile($filename);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param array $input    The input array to parse.
 | 
			
		||||
     * @param array $expected The expected normalized output.
 | 
			
		||||
     *
 | 
			
		||||
     * @dataProvider providerCreateFromGlobals
 | 
			
		||||
     */
 | 
			
		||||
    public function testCreateFromGlobalsFromFilesSuperglobal(array $input, array $expected)
 | 
			
		||||
    {
 | 
			
		||||
        $_FILES = $input;
 | 
			
		||||
 | 
			
		||||
        $uploadedFile = UploadedFile::createFromGlobals(Environment::mock());
 | 
			
		||||
        $this->assertEquals($expected, $uploadedFile);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param array $input The input array to parse.
 | 
			
		||||
     *
 | 
			
		||||
     * @dataProvider providerCreateFromGlobals
 | 
			
		||||
     */
 | 
			
		||||
    public function testCreateFromGlobalsFromUserData(array $input)
 | 
			
		||||
    {
 | 
			
		||||
        //If slim.files provided - it will return what was provided
 | 
			
		||||
        $userData['slim.files'] = $input;
 | 
			
		||||
 | 
			
		||||
        $uploadedFile = UploadedFile::createFromGlobals(Environment::mock($userData));
 | 
			
		||||
        $this->assertEquals($input, $uploadedFile);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCreateFromGlobalsWithoutFile()
 | 
			
		||||
    {
 | 
			
		||||
        unset($_FILES);
 | 
			
		||||
 | 
			
		||||
        $uploadedFile = UploadedFile::createFromGlobals(Environment::mock());
 | 
			
		||||
        $this->assertEquals([], $uploadedFile);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testConstructor(): UploadedFile
 | 
			
		||||
    {
 | 
			
		||||
        $attr = [
 | 
			
		||||
            'tmp_name' => self::$filename,
 | 
			
		||||
            'name' => 'my-avatar.txt',
 | 
			
		||||
            'size' => 8,
 | 
			
		||||
            'type' => 'text/plain',
 | 
			
		||||
            'error' => 0,
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $uploadedFile = new UploadedFile(
 | 
			
		||||
            $attr['tmp_name'],
 | 
			
		||||
            $attr['name'],
 | 
			
		||||
            $attr['type'],
 | 
			
		||||
            $attr['size'],
 | 
			
		||||
            $attr['error'],
 | 
			
		||||
            false
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals($attr['name'], $uploadedFile->getClientFilename());
 | 
			
		||||
        $this->assertEquals($attr['type'], $uploadedFile->getClientMediaType());
 | 
			
		||||
        $this->assertEquals($attr['size'], $uploadedFile->getSize());
 | 
			
		||||
        $this->assertEquals($attr['error'], $uploadedFile->getError());
 | 
			
		||||
        $this->assertEquals($attr['tmp_name'], $uploadedFile->getFilePath());
 | 
			
		||||
 | 
			
		||||
        return $uploadedFile;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testConstructorSapi(): UploadedFile
 | 
			
		||||
    {
 | 
			
		||||
        $attr = [
 | 
			
		||||
            'tmp_name' => self::$filename,
 | 
			
		||||
            'name' => 'my-avatar.txt',
 | 
			
		||||
            'size' => 8,
 | 
			
		||||
            'type' => 'text/plain',
 | 
			
		||||
            'error' => 0,
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $uploadedFile = new UploadedFile(
 | 
			
		||||
            $attr['tmp_name'],
 | 
			
		||||
            $attr['name'],
 | 
			
		||||
            $attr['type'],
 | 
			
		||||
            $attr['size'],
 | 
			
		||||
            $attr['error'],
 | 
			
		||||
            true
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals($attr['name'], $uploadedFile->getClientFilename());
 | 
			
		||||
        $this->assertEquals($attr['type'], $uploadedFile->getClientMediaType());
 | 
			
		||||
        $this->assertEquals($attr['size'], $uploadedFile->getSize());
 | 
			
		||||
        $this->assertEquals($attr['error'], $uploadedFile->getError());
 | 
			
		||||
        $this->assertEquals($attr['tmp_name'], $uploadedFile->getFilePath());
 | 
			
		||||
 | 
			
		||||
        return $uploadedFile;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @depends testConstructor
 | 
			
		||||
     *
 | 
			
		||||
     * @param UploadedFile $uploadedFile
 | 
			
		||||
     *
 | 
			
		||||
     * @return UploadedFile
 | 
			
		||||
     */
 | 
			
		||||
    public function testGetStream(UploadedFile $uploadedFile): UploadedFile
 | 
			
		||||
    {
 | 
			
		||||
        $stream = $uploadedFile->getStream();
 | 
			
		||||
        $this->assertEquals(true, $uploadedFile->getStream() instanceof Stream);
 | 
			
		||||
        $stream->close();
 | 
			
		||||
 | 
			
		||||
        return $uploadedFile;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @depends testConstructor
 | 
			
		||||
     *
 | 
			
		||||
     * @param UploadedFile $uploadedFile
 | 
			
		||||
     *
 | 
			
		||||
     */
 | 
			
		||||
    public function testMoveToNotWritable(UploadedFile $uploadedFile)
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
 | 
			
		||||
        $tempName = uniqid('file-');
 | 
			
		||||
        $path = 'some_random_dir' . DIRECTORY_SEPARATOR . $tempName;
 | 
			
		||||
        $uploadedFile->moveTo($path);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @depends testConstructor
 | 
			
		||||
     *
 | 
			
		||||
     * @param UploadedFile $uploadedFile
 | 
			
		||||
     *
 | 
			
		||||
     * @return UploadedFile
 | 
			
		||||
     */
 | 
			
		||||
    public function testMoveTo(UploadedFile $uploadedFile): UploadedFile
 | 
			
		||||
    {
 | 
			
		||||
        $tempName = uniqid('file-');
 | 
			
		||||
        $path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $tempName;
 | 
			
		||||
        $uploadedFile->moveTo($path);
 | 
			
		||||
 | 
			
		||||
        $this->assertFileExists($path);
 | 
			
		||||
 | 
			
		||||
        unlink($path);
 | 
			
		||||
 | 
			
		||||
        return $uploadedFile;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testMoveToRenameFailure()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(RuntimeException::class);
 | 
			
		||||
        $this->expectExceptionMessageMatches('/^Error moving uploaded file .* to .*$/');
 | 
			
		||||
 | 
			
		||||
        $uploadedFile = $this->generateNewTmpFile();
 | 
			
		||||
 | 
			
		||||
        $tempName = uniqid('file-');
 | 
			
		||||
        $path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $tempName;
 | 
			
		||||
 | 
			
		||||
        $GLOBALS['rename_return'] = false;
 | 
			
		||||
        $uploadedFile->moveTo($path);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @depends testConstructorSapi
 | 
			
		||||
     *
 | 
			
		||||
     * @param UploadedFile $uploadedFile
 | 
			
		||||
     *
 | 
			
		||||
     */
 | 
			
		||||
    public function testMoveToSapiNonUploadedFile(UploadedFile $uploadedFile)
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(RuntimeException::class);
 | 
			
		||||
 | 
			
		||||
        $tempName = uniqid('file-');
 | 
			
		||||
        $path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $tempName;
 | 
			
		||||
        $uploadedFile->moveTo($path);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @depends testConstructorSapi
 | 
			
		||||
     *
 | 
			
		||||
     * @param UploadedFile $uploadedFile
 | 
			
		||||
     *
 | 
			
		||||
     */
 | 
			
		||||
    public function testMoveToSapiMoveUploadedFileFails(UploadedFile $uploadedFile)
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(RuntimeException::class);
 | 
			
		||||
        $this->expectExceptionMessageMatches('~Error moving uploaded file.*~');
 | 
			
		||||
 | 
			
		||||
        $GLOBALS['is_uploaded_file_return'] = true;
 | 
			
		||||
 | 
			
		||||
        $tempName = uniqid('file-');
 | 
			
		||||
        $path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $tempName;
 | 
			
		||||
        $uploadedFile->moveTo($path);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @depends testMoveTo
 | 
			
		||||
     *
 | 
			
		||||
     * @param UploadedFile $uploadedFile
 | 
			
		||||
     *
 | 
			
		||||
     */
 | 
			
		||||
    public function testMoveToCannotBeDoneTwice(UploadedFile $uploadedFile)
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(RuntimeException::class);
 | 
			
		||||
 | 
			
		||||
        $tempName = uniqid('file-');
 | 
			
		||||
        $path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $tempName;
 | 
			
		||||
        $uploadedFile->moveTo($path);
 | 
			
		||||
        $this->assertFileExists($path);
 | 
			
		||||
        unlink($path);
 | 
			
		||||
 | 
			
		||||
        $uploadedFile->moveTo($path);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This test must run after testMoveTo
 | 
			
		||||
     *
 | 
			
		||||
     * @depends testConstructor
 | 
			
		||||
     *
 | 
			
		||||
     * @param UploadedFile $uploadedFile
 | 
			
		||||
     *
 | 
			
		||||
     */
 | 
			
		||||
    public function testMoveToAgain(UploadedFile $uploadedFile)
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(RuntimeException::class);
 | 
			
		||||
 | 
			
		||||
        $tempName = uniqid('file-');
 | 
			
		||||
        $path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $tempName;
 | 
			
		||||
        $uploadedFile->moveTo($path);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This test must run after testMoveTo
 | 
			
		||||
     *
 | 
			
		||||
     * @depends testConstructor
 | 
			
		||||
     *
 | 
			
		||||
     * @param UploadedFile $uploadedFile
 | 
			
		||||
     *
 | 
			
		||||
     */
 | 
			
		||||
    public function testMovedStream(UploadedFile $uploadedFile)
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(RuntimeException::class);
 | 
			
		||||
 | 
			
		||||
        $uploadedFile->getStream();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testMoveToStream()
 | 
			
		||||
    {
 | 
			
		||||
        $uploadedFile = $this->generateNewTmpFile();
 | 
			
		||||
 | 
			
		||||
        $fileProperty = new ReflectionProperty($uploadedFile, 'file');
 | 
			
		||||
        $fileProperty->setAccessible(true);
 | 
			
		||||
        $fileName = $fileProperty->getValue($uploadedFile);
 | 
			
		||||
 | 
			
		||||
        $contents = file_get_contents($fileName);
 | 
			
		||||
 | 
			
		||||
        ob_start();
 | 
			
		||||
        $uploadedFile->moveTo('php://output');
 | 
			
		||||
        $movedFileContents = ob_get_clean();
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals($contents, $movedFileContents);
 | 
			
		||||
        $this->assertFileDoesNotExist($fileName);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testMoveToStreamCopyFailure()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(RuntimeException::class);
 | 
			
		||||
        $this->expectExceptionMessage('Error moving uploaded file  to php://output');
 | 
			
		||||
 | 
			
		||||
        $uploadedFile = $this->generateNewTmpFile();
 | 
			
		||||
 | 
			
		||||
        $GLOBALS['copy_return'] = false;
 | 
			
		||||
        $uploadedFile->moveTo('php://output');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testFileUploadWithTempStream()
 | 
			
		||||
    {
 | 
			
		||||
        $streamFactory = function (...$args) {
 | 
			
		||||
            return (new StreamFactory())->createStream(...$args);
 | 
			
		||||
        };
 | 
			
		||||
        $uploadedFileFactory = function (...$args) {
 | 
			
		||||
            return (new UploadedFileFactory())->createUploadedFile(...$args);
 | 
			
		||||
        };
 | 
			
		||||
        $this->runFileUploadWithTempStreamTest($streamFactory, $uploadedFileFactory);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This test sequence has been inspired by UploadedFileFactoryTestCase from http-interop/http-factory-tests package.
 | 
			
		||||
     *
 | 
			
		||||
     * @param callable $streamFactory
 | 
			
		||||
     * @param callable $uploadedFileFactory
 | 
			
		||||
     */
 | 
			
		||||
    private function runFileUploadWithTempStreamTest(callable $streamFactory, callable $uploadedFileFactory)
 | 
			
		||||
    {
 | 
			
		||||
        $content = 'this is your capitan speaking';
 | 
			
		||||
        $error = UPLOAD_ERR_OK;
 | 
			
		||||
        $clientFilename = 'test.txt';
 | 
			
		||||
        $clientMediaType = 'text/plain';
 | 
			
		||||
 | 
			
		||||
        $stream = call_user_func($streamFactory, $content);
 | 
			
		||||
        $file = call_user_func(
 | 
			
		||||
            $uploadedFileFactory,
 | 
			
		||||
            $stream,
 | 
			
		||||
            strlen($content),
 | 
			
		||||
            $error,
 | 
			
		||||
            $clientFilename,
 | 
			
		||||
            $clientMediaType
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        $this->assertInstanceOf(UploadedFileInterface::class, $file);
 | 
			
		||||
        $this->assertSame($content, (string)$file->getStream());
 | 
			
		||||
        $this->assertSame(strlen($content), $file->getSize());
 | 
			
		||||
        $this->assertSame($error, $file->getError());
 | 
			
		||||
        $this->assertSame($clientFilename, $file->getClientFilename());
 | 
			
		||||
        $this->assertSame($clientMediaType, $file->getClientMediaType());
 | 
			
		||||
        $this->assertSame($stream->getMetadata('uri'), $file->getFilePath());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCreateUploadedFileWithInvalidArguments()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
 | 
			
		||||
        new UploadedFile(42); // a random value that is neither a string nor an instance of StreamInterface
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCreateUploadedFileWithInvalidUri()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
 | 
			
		||||
        $streamProphecy = $this->prophesize(StreamInterface::class);
 | 
			
		||||
 | 
			
		||||
        /** @noinspection PhpUndefinedMethodInspection */
 | 
			
		||||
        $streamProphecy
 | 
			
		||||
            ->getMetadata('uri')
 | 
			
		||||
            ->willReturn(null)
 | 
			
		||||
            ->shouldBeCalled();
 | 
			
		||||
        $stream = $streamProphecy->reveal();
 | 
			
		||||
 | 
			
		||||
        // Test with a StreamInterface that returns `null`
 | 
			
		||||
        // when `$stream->getMetadata('uri')` is called (which is an invalid case).
 | 
			
		||||
        new UploadedFile($stream);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static function providerCreateFromGlobals(): array
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            // no nest: <input name="avatar" type="file">
 | 
			
		||||
            [
 | 
			
		||||
                // $_FILES array
 | 
			
		||||
                [
 | 
			
		||||
                    'avatar' => [
 | 
			
		||||
                        'tmp_name' => 'phpUxcOty',
 | 
			
		||||
                        'name' => 'my-avatar.png',
 | 
			
		||||
                        'size' => 90996,
 | 
			
		||||
                        'type' => 'image/png',
 | 
			
		||||
                        'error' => 0,
 | 
			
		||||
                    ],
 | 
			
		||||
                ],
 | 
			
		||||
                // expected format of array
 | 
			
		||||
                [
 | 
			
		||||
                    'avatar' => new UploadedFile('phpUxcOty', 'my-avatar.png', 'image/png', 90996, UPLOAD_ERR_OK, true)
 | 
			
		||||
                ]
 | 
			
		||||
            ],
 | 
			
		||||
            // no nest, with error: <input name="avatar" type="file">
 | 
			
		||||
            [
 | 
			
		||||
                // $_FILES array
 | 
			
		||||
                [
 | 
			
		||||
                    'avatar' => [
 | 
			
		||||
                        'tmp_name' => 'phpUxcOty',
 | 
			
		||||
                        'name' => 'my-avatar.png',
 | 
			
		||||
                        'size' => 90996,
 | 
			
		||||
                        'type' => 'image/png',
 | 
			
		||||
                        'error' => 7,
 | 
			
		||||
                    ],
 | 
			
		||||
                ],
 | 
			
		||||
                // expected format of array
 | 
			
		||||
                [
 | 
			
		||||
                    'avatar' => new UploadedFile(
 | 
			
		||||
                        'phpUxcOty',
 | 
			
		||||
                        'my-avatar.png',
 | 
			
		||||
                        'image/png',
 | 
			
		||||
                        90996,
 | 
			
		||||
                        UPLOAD_ERR_CANT_WRITE,
 | 
			
		||||
                        true
 | 
			
		||||
                    )
 | 
			
		||||
                ]
 | 
			
		||||
            ],
 | 
			
		||||
 | 
			
		||||
            // array of files: <input name="avatars[]" type="file">
 | 
			
		||||
            [
 | 
			
		||||
                // $_FILES array
 | 
			
		||||
                [
 | 
			
		||||
                    'avatars' => [
 | 
			
		||||
                        'tmp_name' => [
 | 
			
		||||
                            0 => __DIR__ . DIRECTORY_SEPARATOR . 'file0.txt',
 | 
			
		||||
                            1 => __DIR__ . DIRECTORY_SEPARATOR . 'file1.html',
 | 
			
		||||
                        ],
 | 
			
		||||
                        'name' => [
 | 
			
		||||
                            0 => 'file0.txt',
 | 
			
		||||
                            1 => 'file1.html',
 | 
			
		||||
                        ],
 | 
			
		||||
                        'type' => [
 | 
			
		||||
                            0 => 'text/plain',
 | 
			
		||||
                            1 => 'text/html',
 | 
			
		||||
                        ],
 | 
			
		||||
                        'error' => [
 | 
			
		||||
                            0 => 0,
 | 
			
		||||
                            1 => 0
 | 
			
		||||
                        ],
 | 
			
		||||
                        'size' => [
 | 
			
		||||
                            0 => 0,
 | 
			
		||||
                            1 => 0
 | 
			
		||||
                        ]
 | 
			
		||||
                    ],
 | 
			
		||||
                ],
 | 
			
		||||
                // expected format of array
 | 
			
		||||
                [
 | 
			
		||||
                    'avatars' => [
 | 
			
		||||
                        0 => new UploadedFile(
 | 
			
		||||
                            __DIR__ . DIRECTORY_SEPARATOR . 'file0.txt',
 | 
			
		||||
                            'file0.txt',
 | 
			
		||||
                            'text/plain',
 | 
			
		||||
                            null,
 | 
			
		||||
                            UPLOAD_ERR_OK,
 | 
			
		||||
                            true
 | 
			
		||||
                        ),
 | 
			
		||||
                        1 => new UploadedFile(
 | 
			
		||||
                            __DIR__ . DIRECTORY_SEPARATOR . 'file1.html',
 | 
			
		||||
                            'file1.html',
 | 
			
		||||
                            'text/html',
 | 
			
		||||
                            null,
 | 
			
		||||
                            UPLOAD_ERR_OK,
 | 
			
		||||
                            true
 | 
			
		||||
                        ),
 | 
			
		||||
                    ],
 | 
			
		||||
                ]
 | 
			
		||||
            ],
 | 
			
		||||
            // array of files as multidimensional array: <input name="avatars[]" type="file">
 | 
			
		||||
            [
 | 
			
		||||
                // $_FILES array
 | 
			
		||||
                [
 | 
			
		||||
                    [
 | 
			
		||||
                        'avatars' => [
 | 
			
		||||
                            'tmp_name' => [
 | 
			
		||||
                                0 => __DIR__ . DIRECTORY_SEPARATOR . 'file0.txt',
 | 
			
		||||
                                1 => __DIR__ . DIRECTORY_SEPARATOR . 'file1.html',
 | 
			
		||||
                            ],
 | 
			
		||||
                            'name' => [
 | 
			
		||||
                                0 => 'file0.txt',
 | 
			
		||||
                                1 => 'file1.html',
 | 
			
		||||
                            ],
 | 
			
		||||
                            'type' => [
 | 
			
		||||
                                0 => 'text/plain',
 | 
			
		||||
                                1 => 'text/html',
 | 
			
		||||
                            ],
 | 
			
		||||
                            'size' => [
 | 
			
		||||
                                0 => 0,
 | 
			
		||||
                                1 => 0,
 | 
			
		||||
                            ],
 | 
			
		||||
                        ],
 | 
			
		||||
                    ],
 | 
			
		||||
                ],
 | 
			
		||||
                // expected format of array
 | 
			
		||||
                [
 | 
			
		||||
                    0 =>
 | 
			
		||||
                        [
 | 
			
		||||
                            'avatars' =>
 | 
			
		||||
                                [
 | 
			
		||||
                                    'tmp_name' => [],
 | 
			
		||||
                                    'name' => [],
 | 
			
		||||
                                    'type' => [],
 | 
			
		||||
                                    'size' => [],
 | 
			
		||||
                                ],
 | 
			
		||||
                        ],
 | 
			
		||||
                ],
 | 
			
		||||
            ],
 | 
			
		||||
            // single nested file: <input name="details[avatar]" type="file">
 | 
			
		||||
            [
 | 
			
		||||
                // $_FILES array
 | 
			
		||||
                [
 | 
			
		||||
                    'details' => [
 | 
			
		||||
                        'tmp_name' => [
 | 
			
		||||
                            'avatar' => __DIR__ . DIRECTORY_SEPARATOR . 'file0.txt',
 | 
			
		||||
                        ],
 | 
			
		||||
                        'name' => [
 | 
			
		||||
                            'avatar' => 'file0.txt',
 | 
			
		||||
                        ],
 | 
			
		||||
                        'type' => [
 | 
			
		||||
                            'avatar' => 'text/plain',
 | 
			
		||||
                        ],
 | 
			
		||||
                        'error' => [
 | 
			
		||||
                            'avatar' => 0,
 | 
			
		||||
                        ],
 | 
			
		||||
                        'size' => [
 | 
			
		||||
                            'avatar' => 0,
 | 
			
		||||
                        ],
 | 
			
		||||
                    ],
 | 
			
		||||
                ],
 | 
			
		||||
                // expected format of array
 | 
			
		||||
                [
 | 
			
		||||
                    'details' => [
 | 
			
		||||
                        'avatar' => new UploadedFile(
 | 
			
		||||
                            __DIR__ . DIRECTORY_SEPARATOR . 'file0.txt',
 | 
			
		||||
                            'file0.txt',
 | 
			
		||||
                            'text/plain',
 | 
			
		||||
                            null,
 | 
			
		||||
                            UPLOAD_ERR_OK,
 | 
			
		||||
                            true
 | 
			
		||||
                        ),
 | 
			
		||||
                    ],
 | 
			
		||||
                ]
 | 
			
		||||
            ],
 | 
			
		||||
            // nested array of files: <input name="files[details][avatar][]" type="file">
 | 
			
		||||
            [
 | 
			
		||||
                [
 | 
			
		||||
                    'files' => [
 | 
			
		||||
                        'tmp_name' => [
 | 
			
		||||
                            'details' => [
 | 
			
		||||
                                'avatar' => [
 | 
			
		||||
                                    0 => __DIR__ . DIRECTORY_SEPARATOR . 'file0.txt',
 | 
			
		||||
                                    1 => __DIR__ . DIRECTORY_SEPARATOR . 'file1.html',
 | 
			
		||||
                                ],
 | 
			
		||||
                            ],
 | 
			
		||||
                        ],
 | 
			
		||||
                        'name' => [
 | 
			
		||||
                            'details' => [
 | 
			
		||||
                                'avatar' => [
 | 
			
		||||
                                    0 => 'file0.txt',
 | 
			
		||||
                                    1 => 'file1.html',
 | 
			
		||||
                                ],
 | 
			
		||||
                            ],
 | 
			
		||||
                        ],
 | 
			
		||||
                        'type' => [
 | 
			
		||||
                            'details' => [
 | 
			
		||||
                                'avatar' => [
 | 
			
		||||
                                    0 => 'text/plain',
 | 
			
		||||
                                    1 => 'text/html',
 | 
			
		||||
                                ],
 | 
			
		||||
                            ],
 | 
			
		||||
                        ],
 | 
			
		||||
                        'error' => [
 | 
			
		||||
                            'details' => [
 | 
			
		||||
                                'avatar' => [
 | 
			
		||||
                                    0 => 0,
 | 
			
		||||
                                    1 => 0
 | 
			
		||||
                                ],
 | 
			
		||||
                            ],
 | 
			
		||||
                        ],
 | 
			
		||||
                        'size' => [
 | 
			
		||||
                            'details' => [
 | 
			
		||||
                                'avatar' => [
 | 
			
		||||
                                    0 => 0,
 | 
			
		||||
                                    1 => 0
 | 
			
		||||
                                ],
 | 
			
		||||
                            ],
 | 
			
		||||
                        ],
 | 
			
		||||
                    ],
 | 
			
		||||
                ],
 | 
			
		||||
                // expected format of array
 | 
			
		||||
                [
 | 
			
		||||
                    'files' => [
 | 
			
		||||
                        'details' => [
 | 
			
		||||
                            'avatar' => [
 | 
			
		||||
                                0 => new UploadedFile(
 | 
			
		||||
                                    __DIR__ . DIRECTORY_SEPARATOR . 'file0.txt',
 | 
			
		||||
                                    'file0.txt',
 | 
			
		||||
                                    'text/plain',
 | 
			
		||||
                                    null,
 | 
			
		||||
                                    UPLOAD_ERR_OK,
 | 
			
		||||
                                    true
 | 
			
		||||
                                ),
 | 
			
		||||
                                1 => new UploadedFile(
 | 
			
		||||
                                    __DIR__ . DIRECTORY_SEPARATOR . 'file1.html',
 | 
			
		||||
                                    'file1.html',
 | 
			
		||||
                                    'text/html',
 | 
			
		||||
                                    null,
 | 
			
		||||
                                    UPLOAD_ERR_OK,
 | 
			
		||||
                                    true
 | 
			
		||||
                                ),
 | 
			
		||||
                            ],
 | 
			
		||||
                        ],
 | 
			
		||||
                    ],
 | 
			
		||||
                ]
 | 
			
		||||
            ],
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										383
									
								
								qwen/php/vendor/slim/psr7/tests/UriTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										383
									
								
								qwen/php/vendor/slim/psr7/tests/UriTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,383 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Tests\Psr7;
 | 
			
		||||
 | 
			
		||||
use InvalidArgumentException;
 | 
			
		||||
use PHPUnit\Framework\TestCase;
 | 
			
		||||
use Slim\Psr7\Uri;
 | 
			
		||||
use stdClass;
 | 
			
		||||
 | 
			
		||||
class UriTest extends TestCase
 | 
			
		||||
{
 | 
			
		||||
    public function uriFactory(): Uri
 | 
			
		||||
    {
 | 
			
		||||
        $scheme = 'https';
 | 
			
		||||
        $host = 'example.com';
 | 
			
		||||
        $port = 443;
 | 
			
		||||
        $path = '/foo/bar';
 | 
			
		||||
        $query = 'abc=123';
 | 
			
		||||
        $fragment = 'section3';
 | 
			
		||||
        $user = 'josh';
 | 
			
		||||
        $password = 'sekrit';
 | 
			
		||||
 | 
			
		||||
        return new Uri($scheme, $host, $port, $path, $query, $fragment, $user, $password);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testSupportOtherSchemes()
 | 
			
		||||
    {
 | 
			
		||||
        $wsUri = new class ('ws', 'example.com') extends Uri {
 | 
			
		||||
            public const SUPPORTED_SCHEMES = [
 | 
			
		||||
                'ws' => 80,
 | 
			
		||||
                'wss' => 443,
 | 
			
		||||
            ];
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('ws', $wsUri->getScheme());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetScheme()
 | 
			
		||||
    {
 | 
			
		||||
        $this->assertEquals('https', $this->uriFactory()->getScheme());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithScheme()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->uriFactory()->withScheme('http');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('http', $uri->getScheme());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithSchemeRemovesSuffix()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->uriFactory()->withScheme('http://');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('http', $uri->getScheme());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithSchemeEmpty()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->uriFactory()->withScheme('');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('', $uri->getScheme());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithSchemeInvalid()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
        $this->expectExceptionMessageMatches('/^Uri scheme must be one of:.*$/');
 | 
			
		||||
 | 
			
		||||
        $this->uriFactory()->withScheme('ftp');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithSchemeInvalidType()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
        $this->expectExceptionMessage('Uri scheme must be a string');
 | 
			
		||||
 | 
			
		||||
        $this->uriFactory()->withScheme([]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetAuthorityWithUsernameAndPassword()
 | 
			
		||||
    {
 | 
			
		||||
        $this->assertEquals('josh:sekrit@example.com', $this->uriFactory()->getAuthority());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithUserInfo()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->uriFactory()->withUserInfo('bob', 'pass');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('bob:pass', $uri->getUserInfo());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithUserInfoEncodesCorrectly()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->uriFactory()->withUserInfo('bob@example.com', 'pass:word');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('bob%40example.com:pass%3Aword', $uri->getUserInfo());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithUserInfoRemovesPassword()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->uriFactory()->withUserInfo('bob');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('bob', $uri->getUserInfo());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithUserInfoRemovesInfo()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->uriFactory()->withUserInfo('bob', 'password');
 | 
			
		||||
        $uri = $uri->withUserInfo('');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('', $uri->getUserInfo());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetHost()
 | 
			
		||||
    {
 | 
			
		||||
        $this->assertEquals('example.com', $this->uriFactory()->getHost());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithHost()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->uriFactory()->withHost('slimframework.com');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('slimframework.com', $uri->getHost());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithHostValidObject()
 | 
			
		||||
    {
 | 
			
		||||
        $mock = new StringableTestObject('host.test');
 | 
			
		||||
 | 
			
		||||
        $uri = $this->uriFactory()->withHost($mock);
 | 
			
		||||
        $this->assertEquals('host.test', $uri->getHost());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithHostInvalidObject()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
        $this->expectExceptionMessage('Uri host must be a string');
 | 
			
		||||
 | 
			
		||||
        $this->uriFactory()->withHost(new stdClass());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testFilterHost()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = new Uri('http', '2001:db8::1');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('[2001:db8::1]', $uri->getHost());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetPortWithSchemeAndNonDefaultPort()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = new Uri('https', 'www.example.com', 4000);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(4000, $uri->getPort());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetPortWithSchemeAndDefaultPort()
 | 
			
		||||
    {
 | 
			
		||||
        $uriHttp = new Uri('http', 'www.example.com', 80);
 | 
			
		||||
        $uriHttps = new Uri('https', 'www.example.com', 443);
 | 
			
		||||
 | 
			
		||||
        $this->assertNull($uriHttp->getPort());
 | 
			
		||||
        $this->assertNull($uriHttps->getPort());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetPortWithoutSchemeAndPort()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = new Uri('', 'www.example.com');
 | 
			
		||||
 | 
			
		||||
        $this->assertNull($uri->getPort());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetPortWithSchemeWithoutPort()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = new Uri('http', 'www.example.com');
 | 
			
		||||
 | 
			
		||||
        $this->assertNull($uri->getPort());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithPort()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->uriFactory()->withPort(8000);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(8000, $uri->getPort());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithPortNull()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->uriFactory()->withPort(null);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(null, $uri->getPort());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithPortInvalidInt()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
 | 
			
		||||
        $this->uriFactory()->withPort(70000);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithPortInvalidString()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
 | 
			
		||||
        $this->uriFactory()->withPort('Foo');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithPortIntegerAsString()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->uriFactory()->withPort("199");
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(199, $uri->getPort());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetPath()
 | 
			
		||||
    {
 | 
			
		||||
        $this->assertEquals('/foo/bar', $this->uriFactory()->getPath());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithPath()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->uriFactory()->withPath('/new');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('/new', $uri->getPath());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithPathWithoutPrefix()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->uriFactory()->withPath('new');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('new', $uri->getPath());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithPathEmptyValue()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->uriFactory()->withPath('');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('', $uri->getPath());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithPathUrlEncodesInput()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->uriFactory()->withPath('/includes?/new');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('/includes%3F/new', $uri->getPath());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithPathDoesNotDoubleEncodeInput()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->uriFactory()->withPath('/include%25s/new');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('/include%25s/new', $uri->getPath());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithPathInvalidType()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
        $this->expectExceptionMessage('Uri path must be a string');
 | 
			
		||||
 | 
			
		||||
        $this->uriFactory()->withPath(['foo']);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetQuery()
 | 
			
		||||
    {
 | 
			
		||||
        $this->assertEquals('abc=123', $this->uriFactory()->getQuery());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithQuery()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->uriFactory()->withQuery('xyz=123');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('xyz=123', $uri->getQuery());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithQueryRemovesPrefix()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->uriFactory()->withQuery('?xyz=123');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('xyz=123', $uri->getQuery());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithQueryEmpty()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->uriFactory()->withQuery('');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('', $uri->getQuery());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithQueryValidObject()
 | 
			
		||||
    {
 | 
			
		||||
        $mock = new StringableTestObject('xyz=123');
 | 
			
		||||
 | 
			
		||||
        $uri = $this->uriFactory()->withQuery($mock);
 | 
			
		||||
        $this->assertEquals('xyz=123', $uri->getQuery());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testFilterQuery()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->uriFactory()->withQuery('?foobar=%match');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('foobar=%25match', $uri->getQuery());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithQueryInvalidType()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
        $this->expectExceptionMessage('Uri query must be a string');
 | 
			
		||||
 | 
			
		||||
        $this->uriFactory()->withQuery(['foo']);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetFragment()
 | 
			
		||||
    {
 | 
			
		||||
        $this->assertEquals('section3', $this->uriFactory()->getFragment());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithFragment()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->uriFactory()->withFragment('other-fragment');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('other-fragment', $uri->getFragment());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithFragmentRemovesPrefix()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->uriFactory()->withFragment('#other-fragment');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('other-fragment', $uri->getFragment());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithFragmentEmpty()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->uriFactory()->withFragment('');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('', $uri->getFragment());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithFragmentValidObject()
 | 
			
		||||
    {
 | 
			
		||||
        $mock = new StringableTestObject('other-fragment');
 | 
			
		||||
 | 
			
		||||
        $uri = $this->uriFactory()->withFragment($mock);
 | 
			
		||||
        $this->assertEquals('other-fragment', $uri->getFragment());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithFragmentUrlEncode()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->uriFactory()->withFragment('^a');
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('%5Ea', $uri->getFragment());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testWithFragmentInvalidType()
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(InvalidArgumentException::class);
 | 
			
		||||
        $this->expectExceptionMessage('Uri fragment must be a string');
 | 
			
		||||
 | 
			
		||||
        $this->uriFactory()->withFragment(['foo']);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testToString()
 | 
			
		||||
    {
 | 
			
		||||
        $uri = $this->uriFactory();
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('https://josh:sekrit@example.com/foo/bar?abc=123#section3', (string) $uri);
 | 
			
		||||
 | 
			
		||||
        $uri = $uri->withPath('bar');
 | 
			
		||||
        $this->assertEquals('https://josh:sekrit@example.com/bar?abc=123#section3', (string) $uri);
 | 
			
		||||
 | 
			
		||||
        $uri = $uri->withPath('/bar');
 | 
			
		||||
        $this->assertEquals('https://josh:sekrit@example.com/bar?abc=123#section3', (string) $uri);
 | 
			
		||||
 | 
			
		||||
        $uri = $uri->withScheme('')->withHost('')->withPort(null)->withUserInfo('')->withPath('//bar');
 | 
			
		||||
        $this->assertEquals('/bar?abc=123#section3', (string) $uri);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										99
									
								
								qwen/php/vendor/slim/psr7/tests/bootstrap.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										99
									
								
								qwen/php/vendor/slim/psr7/tests/bootstrap.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,99 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
use AdrianSuter\Autoload\Override\Override;
 | 
			
		||||
use Slim\Psr7\Factory;
 | 
			
		||||
use Slim\Psr7\Headers;
 | 
			
		||||
use Slim\Psr7\Message;
 | 
			
		||||
use Slim\Psr7\NonBufferedBody;
 | 
			
		||||
use Slim\Psr7\UploadedFile;
 | 
			
		||||
use Slim\Tests\Psr7\Assets\HeaderStack;
 | 
			
		||||
 | 
			
		||||
$classLoader = require __DIR__ . '/../vendor/autoload.php';
 | 
			
		||||
 | 
			
		||||
Override::apply($classLoader, [
 | 
			
		||||
    Headers::class => [
 | 
			
		||||
        'getallheaders' => function () {
 | 
			
		||||
            if (array_key_exists('getallheaders_return', $GLOBALS)) {
 | 
			
		||||
                return $GLOBALS['getallheaders_return'];
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return getallheaders();
 | 
			
		||||
        }
 | 
			
		||||
    ],
 | 
			
		||||
    Message::class => [
 | 
			
		||||
        'header' => function (string $string, bool $replace = true, ?int $statusCode = null): void {
 | 
			
		||||
            HeaderStack::push(
 | 
			
		||||
                [
 | 
			
		||||
                    'header'      => $string,
 | 
			
		||||
                    'replace'     => $replace,
 | 
			
		||||
                    'status_code' => $statusCode,
 | 
			
		||||
                ]
 | 
			
		||||
            );
 | 
			
		||||
        },
 | 
			
		||||
        'header_remove' => function ($name = null): void {
 | 
			
		||||
            HeaderStack::remove($name);
 | 
			
		||||
        }
 | 
			
		||||
    ],
 | 
			
		||||
    NonBufferedBody::class => [
 | 
			
		||||
        'ob_get_level' => function (): int {
 | 
			
		||||
            if (isset($GLOBALS['ob_get_level_shift'])) {
 | 
			
		||||
                return ob_get_level() + $GLOBALS['ob_get_level_shift'];
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return ob_get_level();
 | 
			
		||||
        }
 | 
			
		||||
    ],
 | 
			
		||||
    UploadedFile::class => [
 | 
			
		||||
        'copy' => function (string $source, string $destination, $context = null): bool {
 | 
			
		||||
            if (isset($GLOBALS['copy_return'])) {
 | 
			
		||||
                return $GLOBALS['copy_return'];
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if ($context === null) {
 | 
			
		||||
                return copy($source, $destination);
 | 
			
		||||
            }
 | 
			
		||||
            return copy($source, $destination, $context);
 | 
			
		||||
        },
 | 
			
		||||
        'is_uploaded_file' => function (string $filename): bool {
 | 
			
		||||
            if (isset($GLOBALS['is_uploaded_file_return'])) {
 | 
			
		||||
                return $GLOBALS['is_uploaded_file_return'];
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return is_uploaded_file($filename);
 | 
			
		||||
        },
 | 
			
		||||
        'rename' => function (string $oldName, string $newName, $context = null): bool {
 | 
			
		||||
            if (isset($GLOBALS['rename_return'])) {
 | 
			
		||||
                return $GLOBALS['rename_return'];
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if ($context === null) {
 | 
			
		||||
                return rename($oldName, $newName);
 | 
			
		||||
            }
 | 
			
		||||
            return rename($oldName, $newName, $context = null);
 | 
			
		||||
        }
 | 
			
		||||
    ],
 | 
			
		||||
    Factory\StreamFactory::class => [
 | 
			
		||||
        'fopen' => function (string $filename, string $mode) {
 | 
			
		||||
            if (isset($GLOBALS['fopen_return'])) {
 | 
			
		||||
                return isset($GLOBALS['fopen_return']);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return fopen($filename, $mode);
 | 
			
		||||
        },
 | 
			
		||||
        'is_readable' => function (string $filename) {
 | 
			
		||||
            if ($filename === 'non-readable') {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return is_readable($filename);
 | 
			
		||||
        }
 | 
			
		||||
    ]
 | 
			
		||||
]);
 | 
			
		||||
							
								
								
									
										339
									
								
								qwen/php/vendor/slim/slim/CHANGELOG.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										339
									
								
								qwen/php/vendor/slim/slim/CHANGELOG.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,339 @@
 | 
			
		||||
# Changelog
 | 
			
		||||
 | 
			
		||||
## [Unreleased]
 | 
			
		||||
 | 
			
		||||
### Fixed
 | 
			
		||||
 | 
			
		||||
### Added
 | 
			
		||||
 | 
			
		||||
### Changed
 | 
			
		||||
 | 
			
		||||
### Removed
 | 
			
		||||
 | 
			
		||||
## 4.15.0 - 2025-08-24
 | 
			
		||||
 | 
			
		||||
### Fixed
 | 
			
		||||
 | 
			
		||||
- Fix DocBlocks for callable route handlers (#3389)
 | 
			
		||||
- Change class keyword to lowercase (#3346)
 | 
			
		||||
- Fix tests for PHP 8.3
 | 
			
		||||
- Fixes the build status badge in Readme (#3331)
 | 
			
		||||
- Fix text and eol attributes for * selector in .gitattributes (#3391)
 | 
			
		||||
- Deprecate setArgument/s (#3383)
 | 
			
		||||
 | 
			
		||||
### Added
 | 
			
		||||
 | 
			
		||||
- Add support for PHP 8.4
 | 
			
		||||
- Add phpstan v2
 | 
			
		||||
 | 
			
		||||
### Changed
 | 
			
		||||
 | 
			
		||||
- Update http urls in composer.json (#3399)
 | 
			
		||||
 | 
			
		||||
**Full Changelog**: https://github.com/slimphp/Slim/compare/4.14.0...4.15.0
 | 
			
		||||
 | 
			
		||||
## 4.14.0 - 2024-06-13
 | 
			
		||||
 | 
			
		||||
### Changed
 | 
			
		||||
 | 
			
		||||
- Do not HTML entity encode in PlainTextErrorRenderer by @akrabat in https://github.com/slimphp/Slim/pull/3319
 | 
			
		||||
- Only render tip to error log if plain text renderer is used by @akrabat in https://github.com/slimphp/Slim/pull/3321
 | 
			
		||||
- Add template generics for PSR-11 implementations in PHPStan and Psalm by @limarkxx in https://github.com/slimphp/Slim/pull/3322
 | 
			
		||||
- Update squizlabs/php_codesniffer requirement from ^3.9 to ^3.10 by @dependabot in https://github.com/slimphp/Slim/pull/3324
 | 
			
		||||
- Update phpstan/phpstan requirement from ^1.10 to ^1.11 by @dependabot in https://github.com/slimphp/Slim/pull/3325
 | 
			
		||||
- Update psr/http-factory requirement from ^1.0 to ^1.1 by @dependabot in https://github.com/slimphp/Slim/pull/3326
 | 
			
		||||
 | 
			
		||||
#### Type hinting with template generics
 | 
			
		||||
 | 
			
		||||
With the introduction of template generics, if you type-hint `Slim\App` instance variable using `/** @var \Slim\App $app */`, then you will need to change it to either:
 | 
			
		||||
 | 
			
		||||
*  `/** @var \Slim\App<null> $app */` if you are not using a DI container, or
 | 
			
		||||
* `/** @var \Slim\App<\Psr\Container\ContainerInterface> $app */` if you are
 | 
			
		||||
 | 
			
		||||
You can also type-hint to the concrete instance of the container you are using too. For example, if you are using [PHP-DI](https://php-di.org), then you can use: `/** @var \Slim\App<DI\Container> $app */`.
 | 
			
		||||
 | 
			
		||||
### New Contributors
 | 
			
		||||
 | 
			
		||||
* @limarkxx made their first contribution in https://github.com/slimphp/Slim/pull/3322
 | 
			
		||||
 | 
			
		||||
**Full Changelog**: https://github.com/slimphp/Slim/compare/4.13.0...4.14.0
 | 
			
		||||
 | 
			
		||||
# 4.13.0 - 2024-03-03
 | 
			
		||||
 | 
			
		||||
- [3277: Create HttpTooManyRequestsException.php](https://github.com/slimphp/Slim/pull/3277) thanks to @flavioheleno
 | 
			
		||||
- [3278: Remove HttpGoneException executable flag](https://github.com/slimphp/Slim/pull/3278) thanks to @flavioheleno
 | 
			
		||||
- [3285: Update guzzlehttp/psr7 requirement from ^2.5 to ^2.6](https://github.com/slimphp/Slim/pull/3285) thanks to @dependabot[bot]
 | 
			
		||||
- [3290: Bump actions/checkout from 3 to 4](https://github.com/slimphp/Slim/pull/3290) thanks to @dependabot[bot]
 | 
			
		||||
- [3291: Fix line length](https://github.com/slimphp/Slim/pull/3291) thanks to @l0gicgate
 | 
			
		||||
- [3296: PSR 7 http-message version requirement](https://github.com/slimphp/Slim/issues/3296) thanks to @rotexdegba
 | 
			
		||||
- [3297: Allow Diactoros 3](https://github.com/slimphp/Slim/pull/3297) thanks to @derrabus
 | 
			
		||||
- [3299: Update tests and add PHP 8.3 to the CI matrix](https://github.com/slimphp/Slim/pull/3299) thanks to @akrabat
 | 
			
		||||
- [3301: Update nyholm/psr7-server requirement from ^1.0 to ^1.1](https://github.com/slimphp/Slim/pull/3301) thanks to @dependabot[bot]
 | 
			
		||||
- [3302: Add support for psr/http-message ^2.0](https://github.com/slimphp/Slim/pull/3302) thanks to @rotexdegba
 | 
			
		||||
- [3305: Update phpspec/prophecy-phpunit requirement from ^2.0 to ^2.1](https://github.com/slimphp/Slim/pull/3305) thanks to @dependabot[bot]
 | 
			
		||||
- [3306: Update phpspec/prophecy requirement from ^1.17 to ^1.18](https://github.com/slimphp/Slim/pull/3306) thanks to @dependabot[bot]
 | 
			
		||||
- [3308: Update squizlabs/php_codesniffer requirement from ^3.7 to ^3.8](https://github.com/slimphp/Slim/pull/3308) thanks to @dependabot[bot]
 | 
			
		||||
- [3313: Bump ramsey/composer-install from 2 to 3](https://github.com/slimphp/Slim/pull/3313) thanks to @dependabot[bot]
 | 
			
		||||
- [3314: Update phpspec/prophecy requirement from ^1.18 to ^1.19](https://github.com/slimphp/Slim/pull/3314) thanks to @dependabot[bot]
 | 
			
		||||
- [3315: Update squizlabs/php_codesniffer requirement from ^3.8 to ^3.9](https://github.com/slimphp/Slim/pull/3315) thanks to @dependabot[bot]
 | 
			
		||||
 | 
			
		||||
# 4.12.0 - 2023-07-23
 | 
			
		||||
 | 
			
		||||
- [3220: Refactor](https://github.com/slimphp/Slim/pull/3220) thanks to @amirkhodabande
 | 
			
		||||
- [3237: Update phpstan/phpstan requirement from ^1.8 to ^1.9](https://github.com/slimphp/Slim/pull/3237) thanks to @dependabot[bot]
 | 
			
		||||
- [3238: Update slim/http requirement from ^1.2 to ^1.3](https://github.com/slimphp/Slim/pull/3238) thanks to @dependabot[bot]
 | 
			
		||||
- [3239: Update slim/psr7 requirement from ^1.5 to ^1.6](https://github.com/slimphp/Slim/pull/3239) thanks to @dependabot[bot]
 | 
			
		||||
- [3240: Update phpspec/prophecy requirement from ^1.15 to ^1.16](https://github.com/slimphp/Slim/pull/3240) thanks to @dependabot[bot]
 | 
			
		||||
- [3241: Update adriansuter/php-autoload-override requirement from ^1.3 to ^1.4](https://github.com/slimphp/Slim/pull/3241) thanks to @dependabot[bot]
 | 
			
		||||
- [3245: New ability to override RouteGroupInterface in the Route class](https://github.com/slimphp/Slim/pull/3245) thanks to @githubjeka
 | 
			
		||||
- [3253: Fix HttpBadRequestException description](https://github.com/slimphp/Slim/pull/3253) thanks to @jsanahuja
 | 
			
		||||
- [3254: Update phpunit/phpunit requirement from ^9.5 to ^9.6](https://github.com/slimphp/Slim/pull/3254) thanks to @dependabot[bot]
 | 
			
		||||
- [3255: Update phpstan/phpstan requirement from ^1.9 to ^1.10](https://github.com/slimphp/Slim/pull/3255) thanks to @dependabot[bot]
 | 
			
		||||
- [3256: Update phpspec/prophecy requirement from ^1.16 to ^1.17](https://github.com/slimphp/Slim/pull/3256) thanks to @dependabot[bot]
 | 
			
		||||
- [3264: Update psr/http-message requirement from ^1.0 to ^1.1](https://github.com/slimphp/Slim/pull/3264) thanks to @dependabot[bot]
 | 
			
		||||
- [3265: Update nyholm/psr7 requirement from ^1.5 to ^1.7](https://github.com/slimphp/Slim/pull/3265) thanks to @dependabot[bot]
 | 
			
		||||
- [3266: Update guzzlehttp/psr7 requirement from ^2.4 to ^2.5](https://github.com/slimphp/Slim/pull/3266) thanks to @dependabot[bot]
 | 
			
		||||
- [3267: Update nyholm/psr7 requirement from ^1.7 to ^1.8](https://github.com/slimphp/Slim/pull/3267) thanks to @dependabot[bot]
 | 
			
		||||
- [3269: Update httpsoft/http-server-request requirement from ^1.0 to ^1.1](https://github.com/slimphp/Slim/pull/3269) thanks to @dependabot[bot]
 | 
			
		||||
- [3270: Update httpsoft/http-message requirement from ^1.0 to ^1.1](https://github.com/slimphp/Slim/pull/3270) thanks to @dependabot[bot]
 | 
			
		||||
- [3271: prevent multiple entries of same methode in FastRouteDispatcher](https://github.com/slimphp/Slim/pull/3271) thanks to @papparazzo
 | 
			
		||||
 | 
			
		||||
## 4.11.0 - 2022-11-06
 | 
			
		||||
 | 
			
		||||
- [3180: Declare types](https://github.com/slimphp/Slim/pull/3180) thanks to @nbayramberdiyev
 | 
			
		||||
- [3181: Update laminas/laminas-diactoros requirement from ^2.8 to ^2.9](https://github.com/slimphp/Slim/pull/3181) thanks to @dependabot[bot]
 | 
			
		||||
- [3182: Update guzzlehttp/psr7 requirement from ^2.1 to ^2.2](https://github.com/slimphp/Slim/pull/3182) thanks to @dependabot[bot]
 | 
			
		||||
- [3183: Update phpstan/phpstan requirement from ^1.4 to ^1.5](https://github.com/slimphp/Slim/pull/3183) thanks to @dependabot[bot]
 | 
			
		||||
- [3184: Update adriansuter/php-autoload-override requirement from ^1.2 to ^1.3](https://github.com/slimphp/Slim/pull/3184) thanks to @dependabot[bot]
 | 
			
		||||
- [3189: Update phpstan/phpstan requirement from ^1.5 to ^1.6](https://github.com/slimphp/Slim/pull/3189) thanks to @dependabot[bot]
 | 
			
		||||
- [3191: Adding property types to Middleware classes](https://github.com/slimphp/Slim/pull/3191) thanks to @ashleycoles
 | 
			
		||||
- [3193: Handlers types](https://github.com/slimphp/Slim/pull/3193) thanks to @ashleycoles
 | 
			
		||||
- [3194: Adding types to AbstractErrorRenderer](https://github.com/slimphp/Slim/pull/3194) thanks to @ashleycoles
 | 
			
		||||
- [3195: Adding prop types for Exception classes](https://github.com/slimphp/Slim/pull/3195) thanks to @ashleycoles
 | 
			
		||||
- [3196: Adding property type declarations for Factory classes](https://github.com/slimphp/Slim/pull/3196) thanks to @ashleycoles
 | 
			
		||||
- [3197: Remove redundant docblock types](https://github.com/slimphp/Slim/pull/3197) thanks to @theodorejb
 | 
			
		||||
- [3199: Update laminas/laminas-diactoros requirement from ^2.9 to ^2.11](https://github.com/slimphp/Slim/pull/3199) thanks to @dependabot[bot]
 | 
			
		||||
- [3200: Update phpstan/phpstan requirement from ^1.6 to ^1.7](https://github.com/slimphp/Slim/pull/3200) thanks to @dependabot[bot]
 | 
			
		||||
- [3205: Update guzzlehttp/psr7 requirement from ^2.2 to ^2.4](https://github.com/slimphp/Slim/pull/3205) thanks to @dependabot[bot]
 | 
			
		||||
- [3206: Update squizlabs/php_codesniffer requirement from ^3.6 to ^3.7](https://github.com/slimphp/Slim/pull/3206) thanks to @dependabot[bot]
 | 
			
		||||
- [3207: Update phpstan/phpstan requirement from ^1.7 to ^1.8](https://github.com/slimphp/Slim/pull/3207) thanks to @dependabot[bot]
 | 
			
		||||
- [3211: Assign null coalescing to coalesce equal](https://github.com/slimphp/Slim/pull/3211) thanks to @MathiasReker
 | 
			
		||||
- [3213: Void return](https://github.com/slimphp/Slim/pull/3213) thanks to @MathiasReker
 | 
			
		||||
- [3214: Is null](https://github.com/slimphp/Slim/pull/3214) thanks to @MathiasReker
 | 
			
		||||
- [3216: Refactor](https://github.com/slimphp/Slim/pull/3216) thanks to @mehdihasanpour
 | 
			
		||||
- [3218: Refactor some code](https://github.com/slimphp/Slim/pull/3218) thanks to @mehdihasanpour
 | 
			
		||||
- [3221: Cleanup](https://github.com/slimphp/Slim/pull/3221) thanks to @mehdihasanpour
 | 
			
		||||
- [3225: Update laminas/laminas-diactoros requirement from ^2.11 to ^2.14](https://github.com/slimphp/Slim/pull/3225) thanks to @dependabot[bot]
 | 
			
		||||
- [3228: Using assertSame to let assert equal be restricted](https://github.com/slimphp/Slim/pull/3228) thanks to @peter279k
 | 
			
		||||
- [3229: Update laminas/laminas-diactoros requirement from ^2.14 to ^2.17](https://github.com/slimphp/Slim/pull/3229) thanks to @dependabot[bot]
 | 
			
		||||
- [3235: Persist routes indexed by name in RouteCollector for improved performance.](https://github.com/slimphp/Slim/pull/3235) thanks to @BusterNeece
 | 
			
		||||
 | 
			
		||||
## 4.10.0 - 2022-03-14
 | 
			
		||||
 | 
			
		||||
- [3120: Add a new PSR-17 factory to Psr17FactoryProvider](https://github.com/slimphp/Slim/pull/3120) thanks to @solventt
 | 
			
		||||
- [3123: Replace deprecated setMethods() in tests](https://github.com/slimphp/Slim/pull/3123) thanks to @solventt
 | 
			
		||||
- [3126: Update guzzlehttp/psr7 requirement from ^2.0 to ^2.1](https://github.com/slimphp/Slim/pull/3126) thanks to @dependabot[bot]
 | 
			
		||||
- [3127: PHPStan v1.0](https://github.com/slimphp/Slim/pull/3127) thanks to @t0mmy742
 | 
			
		||||
- [3128: Update phpstan/phpstan requirement from ^1.0 to ^1.2](https://github.com/slimphp/Slim/pull/3128) thanks to @dependabot[bot]
 | 
			
		||||
- [3129: Deprecate PHP 7.3](https://github.com/slimphp/Slim/pull/3129) thanks to @l0gicgate
 | 
			
		||||
- [3130: Removed double defined PHP 7.4](https://github.com/slimphp/Slim/pull/3130) thanks to @flangofas
 | 
			
		||||
- [3132: Add new `RequestResponseNamedArgs` route strategy](https://github.com/slimphp/Slim/pull/3132) thanks to @adoy
 | 
			
		||||
- [3133: Improve typehinting for `RouteParserInterface`](https://github.com/slimphp/Slim/pull/3133) thanks to @jerowork
 | 
			
		||||
- [3135: Update phpstan/phpstan requirement from ^1.2 to ^1.3](https://github.com/slimphp/Slim/pull/3135) thanks to @dependabot[bot]
 | 
			
		||||
- [3137: Update phpspec/prophecy requirement from ^1.14 to ^1.15](https://github.com/slimphp/Slim/pull/3137) thanks to @dependabot[bot]
 | 
			
		||||
- [3138: Update license year](https://github.com/slimphp/Slim/pull/3138) thanks to @Awilum
 | 
			
		||||
- [3139: Fixed #1730 (reintroduced in 4.x)](https://github.com/slimphp/Slim/pull/3139) thanks to @adoy
 | 
			
		||||
- [3145: Update phpstan/phpstan requirement from ^1.3 to ^1.4](https://github.com/slimphp/Slim/pull/3145) thanks to @dependabot[bot]
 | 
			
		||||
- [3146: Inherit HttpException from RuntimeException](https://github.com/slimphp/Slim/pull/3146) thanks to @nbayramberdiyev
 | 
			
		||||
- [3148: Upgrade to HTML5](https://github.com/slimphp/Slim/pull/3148) thanks to @nbayramberdiyev
 | 
			
		||||
- [3172: Update nyholm/psr7 requirement from ^1.4 to ^1.5](https://github.com/slimphp/Slim/pull/3172) thanks to @dependabot[bot]
 | 
			
		||||
 | 
			
		||||
## 4.9.0 - 2021-10-05
 | 
			
		||||
 | 
			
		||||
- [3058: Implement exception class for Gone Http error](https://github.com/slimphp/Slim/pull/3058) thanks to @TheKernelPanic
 | 
			
		||||
- [3086: Update slim/psr7 requirement from ^1.3 to ^1.4](https://github.com/slimphp/Slim/pull/3086) thanks to @dependabot[bot]
 | 
			
		||||
- [3087: Update nyholm/psr7-server requirement from ^1.0.1 to ^1.0.2](https://github.com/slimphp/Slim/pull/3087) thanks to @dependabot[bot]
 | 
			
		||||
- [3093: Update phpstan/phpstan requirement from ^0.12.85 to ^0.12.90](https://github.com/slimphp/Slim/pull/3093) thanks to @dependabot[bot]
 | 
			
		||||
- [3099: Allow updated psr log](https://github.com/slimphp/Slim/pull/3099) thanks to @t0mmy742
 | 
			
		||||
- [3104: Drop php7.2](https://github.com/slimphp/Slim/pull/3104) thanks to @t0mmy742
 | 
			
		||||
- [3106: Use PSR-17 factory from Guzzle/psr7 2.0](https://github.com/slimphp/Slim/pull/3106) thanks to @t0mmy742
 | 
			
		||||
- [3108: Update README file](https://github.com/slimphp/Slim/pull/3108) thanks to @t0mmy742
 | 
			
		||||
- [3112: Update laminas/laminas-diactoros requirement from ^2.6 to ^2.8](https://github.com/slimphp/Slim/pull/3112) thanks to @dependabot[bot]
 | 
			
		||||
- [3114: Update slim/psr7 requirement from ^1.4 to ^1.5](https://github.com/slimphp/Slim/pull/3114) thanks to @dependabot[bot]
 | 
			
		||||
- [3115: Update phpstan/phpstan requirement from ^0.12.96 to ^0.12.99](https://github.com/slimphp/Slim/pull/3115) thanks to @dependabot[bot]
 | 
			
		||||
- [3116: Remove Zend Diactoros references](https://github.com/slimphp/Slim/pull/3116) thanks to @l0gicgate
 | 
			
		||||
 | 
			
		||||
## 4.8.0 - 2021-05-19
 | 
			
		||||
 | 
			
		||||
- [3034: Fix phpunit dependency version](https://github.com/slimphp/Slim/pull/3034) thanks to @l0gicgate
 | 
			
		||||
- [3037: Replace Travis by GitHub Actions](https://github.com/slimphp/Slim/pull/3037) thanks to @t0mmy742
 | 
			
		||||
- [3043: Cover App creation from AppFactory with empty Container](https://github.com/slimphp/Slim/pull/3043) thanks to @t0mmy742
 | 
			
		||||
- [3045: Update phpstan/phpstan requirement from ^0.12.58 to ^0.12.64](https://github.com/slimphp/Slim/pull/3045) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [3047: documentation: min php 7.2 required](https://github.com/slimphp/Slim/pull/3047) thanks to @Rotzbua
 | 
			
		||||
- [3054: Update phpstan/phpstan requirement from ^0.12.64 to ^0.12.70](https://github.com/slimphp/Slim/pull/3054) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [3056: Fix docblock in ErrorMiddleware](https://github.com/slimphp/Slim/pull/3056) thanks to @piotr-cz
 | 
			
		||||
- [3060: Update phpstan/phpstan requirement from ^0.12.70 to ^0.12.80](https://github.com/slimphp/Slim/pull/3060) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [3061: Update nyholm/psr7 requirement from ^1.3 to ^1.4](https://github.com/slimphp/Slim/pull/3061) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [3063: Allow ^1.0 || ^2.0 in psr/container](https://github.com/slimphp/Slim/pull/3063) thanks to @Ayesh
 | 
			
		||||
- [3069: Classname/Method Callable Arrays](https://github.com/slimphp/Slim/pull/3069) thanks to @ddrv
 | 
			
		||||
- [3078: Update squizlabs/php_codesniffer requirement from ^3.5 to ^3.6](https://github.com/slimphp/Slim/pull/3078) thanks to @dependabot[bot]
 | 
			
		||||
- [3079: Update phpspec/prophecy requirement from ^1.12 to ^1.13](https://github.com/slimphp/Slim/pull/3079) thanks to @dependabot[bot]
 | 
			
		||||
- [3080: Update guzzlehttp/psr7 requirement from ^1.7 to ^1.8](https://github.com/slimphp/Slim/pull/3080) thanks to @dependabot[bot]
 | 
			
		||||
- [3082: Update phpstan/phpstan requirement from ^0.12.80 to ^0.12.85](https://github.com/slimphp/Slim/pull/3082) thanks to @dependabot[bot]
 | 
			
		||||
 | 
			
		||||
## 4.7.0 - 2020-11-30
 | 
			
		||||
 | 
			
		||||
### Fixed
 | 
			
		||||
- [3027: Fix: FastRoute dispatcher and data generator should match](https://github.com/slimphp/Slim/pull/3027) thanks to @edudobay
 | 
			
		||||
 | 
			
		||||
### Added
 | 
			
		||||
- [3015: PHP 8 support](https://github.com/slimphp/Slim/pull/3015) thanks to @edudobay
 | 
			
		||||
 | 
			
		||||
### Optimizations
 | 
			
		||||
- [3024: Randomize tests](https://github.com/slimphp/Slim/pull/3024) thanks to @pawel-slowik
 | 
			
		||||
 | 
			
		||||
## 4.6.0 - 2020-11-15
 | 
			
		||||
 | 
			
		||||
### Fixed
 | 
			
		||||
- [2942: Fix PHPdoc for error handlers in ErrorMiddleware ](https://github.com/slimphp/Slim/pull/2942) thanks to @TiMESPLiNTER
 | 
			
		||||
- [2944: Remove unused function in ErrorHandler](https://github.com/slimphp/Slim/pull/2944) thanks to @l0gicgate
 | 
			
		||||
- [2960: Fix phpstan 0.12 errors](https://github.com/slimphp/Slim/pull/2960) thanks to @adriansuter
 | 
			
		||||
- [2982: Removing cloning statements in tests](https://github.com/slimphp/Slim/pull/2982) thanks to @l0gicgate
 | 
			
		||||
- [3017: Fix request creator factory test](https://github.com/slimphp/Slim/pull/3017) thanks to @pawel-slowik
 | 
			
		||||
- [3022: Ensure RouteParser Always Present After Routing](https://github.com/slimphp/Slim/pull/3022) thanks to @l0gicgate
 | 
			
		||||
 | 
			
		||||
### Added
 | 
			
		||||
- [2949: Add the support in composer.json](https://github.com/slimphp/Slim/pull/2949) thanks to @ddrv
 | 
			
		||||
- [2958: Strict empty string content type checking in BodyParsingMiddleware::getMediaType](https://github.com/slimphp/Slim/pull/2958) thanks to @Ayesh
 | 
			
		||||
- [2997: Add hints to methods](https://github.com/slimphp/Slim/pull/2997) thanks to @evgsavosin - [3000: Fix route controller test](https://github.com/slimphp/Slim/pull/3000) thanks to @pawel-slowik
 | 
			
		||||
- [3001: Add missing `$strategy` parameter in a Route test](https://github.com/slimphp/Slim/pull/3001) thanks to @pawel-slowik
 | 
			
		||||
 | 
			
		||||
### Optimizations
 | 
			
		||||
- [2951: Minor optimizations in if() blocks](https://github.com/slimphp/Slim/pull/2951) thanks to @Ayesh
 | 
			
		||||
- [2959: Micro optimization: Declare closures in BodyParsingMiddleware as static](https://github.com/slimphp/Slim/pull/2959) thanks to @Ayesh
 | 
			
		||||
- [2978: Split the routing results to its own function.](https://github.com/slimphp/Slim/pull/2978) thanks to @dlundgren
 | 
			
		||||
 | 
			
		||||
### Dependencies Updated
 | 
			
		||||
- [2953: Update nyholm/psr7-server requirement from ^0.4.1](https://github.com/slimphp/Slim/pull/2953) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [2954: Update laminas/laminas-diactoros requirement from ^2.1 to ^2.3](https://github.com/slimphp/Slim/pull/2954) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [2955: Update guzzlehttp/psr7 requirement from ^1.5 to ^1.6](https://github.com/slimphp/Slim/pull/2955) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [2956: Update slim/psr7 requirement from ^1.0 to ^1.1](https://github.com/slimphp/Slim/pull/2956) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [2957: Update nyholm/psr7 requirement from ^1.1 to ^1.2](https://github.com/slimphp/Slim/pull/2957) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [2963: Update phpstan/phpstan requirement from ^0.12.23 to ^0.12.25](https://github.com/slimphp/Slim/pull/2963) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [2965: Update adriansuter/php-autoload-override requirement from ^1.0 to ^1.1](https://github.com/slimphp/Slim/pull/2965) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [2967: Update nyholm/psr7 requirement from ^1.2 to ^1.3](https://github.com/slimphp/Slim/pull/2967) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [2969: Update nyholm/psr7-server requirement from ^0.4.1 to ^1.0.0](https://github.com/slimphp/Slim/pull/2969) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [2970: Update phpstan/phpstan requirement from ^0.12.25 to ^0.12.26](https://github.com/slimphp/Slim/pull/2970) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [2971: Update phpstan/phpstan requirement from ^0.12.26 to ^0.12.27](https://github.com/slimphp/Slim/pull/2971) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [2972: Update phpstan/phpstan requirement from ^0.12.27 to ^0.12.28](https://github.com/slimphp/Slim/pull/2972) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [2973: Update phpstan/phpstan requirement from ^0.12.28 to ^0.12.29](https://github.com/slimphp/Slim/pull/2973) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [2975: Update phpstan/phpstan requirement from ^0.12.29 to ^0.12.30](https://github.com/slimphp/Slim/pull/2975) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [2976: Update phpstan/phpstan requirement from ^0.12.30 to ^0.12.31](https://github.com/slimphp/Slim/pull/2976) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [2980: Update phpstan/phpstan requirement from ^0.12.31 to ^0.12.32](https://github.com/slimphp/Slim/pull/2980) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [2981: Update phpspec/prophecy requirement from ^1.10 to ^1.11](https://github.com/slimphp/Slim/pull/2981) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [2986: Update phpstan/phpstan requirement from ^0.12.32 to ^0.12.33](https://github.com/slimphp/Slim/pull/2986) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [2990: Update phpstan/phpstan requirement from ^0.12.33 to ^0.12.34](https://github.com/slimphp/Slim/pull/2990) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [2991: Update phpstan/phpstan requirement from ^0.12.34 to ^0.12.35](https://github.com/slimphp/Slim/pull/2991) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [2993: Update phpstan/phpstan requirement from ^0.12.35 to ^0.12.36](https://github.com/slimphp/Slim/pull/2993) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [2995: Update phpstan/phpstan requirement from ^0.12.36 to ^0.12.37](https://github.com/slimphp/Slim/pull/2995) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [3010: Update guzzlehttp/psr7 requirement from ^1.6 to ^1.7](https://github.com/slimphp/Slim/pull/3010) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [3011: Update phpspec/prophecy requirement from ^1.11 to ^1.12](https://github.com/slimphp/Slim/pull/3011) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [3012: Update slim/http requirement from ^1.0 to ^1.1](https://github.com/slimphp/Slim/pull/3012) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [3013: Update slim/psr7 requirement from ^1.1 to ^1.2](https://github.com/slimphp/Slim/pull/3013) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [3014: Update laminas/laminas-diactoros requirement from ^2.3 to ^2.4](https://github.com/slimphp/Slim/pull/3014) thanks to @dependabot-preview[bot]
 | 
			
		||||
- [3018: Update phpstan/phpstan requirement from ^0.12.37 to ^0.12.54](https://github.com/slimphp/Slim/pull/3018) thanks to @dependabot-preview[bot]
 | 
			
		||||
 | 
			
		||||
## 4.5.0 - 2020-04-14
 | 
			
		||||
 | 
			
		||||
### Added
 | 
			
		||||
- [2928](https://github.com/slimphp/Slim/pull/2928) Test against PHP 7.4
 | 
			
		||||
- [2937](https://github.com/slimphp/Slim/pull/2937) Add support for PSR-3
 | 
			
		||||
 | 
			
		||||
### Fixed
 | 
			
		||||
- [2916](https://github.com/slimphp/Slim/pull/2916) Rename phpcs.xml to phpcs.xml.dist
 | 
			
		||||
- [2917](https://github.com/slimphp/Slim/pull/2917) Update .editorconfig
 | 
			
		||||
- [2925](https://github.com/slimphp/Slim/pull/2925) ResponseEmitter: Don't remove Content-Type and Content-Length when body is empt
 | 
			
		||||
- [2932](https://github.com/slimphp/Slim/pull/2932) Update the Tidelift enterprise language
 | 
			
		||||
- [2938](https://github.com/slimphp/Slim/pull/2938) Modify usage of deprecated expectExceptionMessageRegExp() method
 | 
			
		||||
 | 
			
		||||
## 4.4.0 - 2020-01-04
 | 
			
		||||
 | 
			
		||||
### Added
 | 
			
		||||
- [2862](https://github.com/slimphp/Slim/pull/2862) Optionally handle subclasses of exceptions in custom error handler
 | 
			
		||||
- [2869](https://github.com/slimphp/Slim/pull/2869) php-di/php-di added in composer suggestion
 | 
			
		||||
- [2874](https://github.com/slimphp/Slim/pull/2874) Add `null` to param type-hints
 | 
			
		||||
- [2889](https://github.com/slimphp/Slim/pull/2889) Make `RouteContext` attributes customizable and change default to use private names
 | 
			
		||||
- [2907](https://github.com/slimphp/Slim/pull/2907) Migrate to PSR-12 convention
 | 
			
		||||
- [2910](https://github.com/slimphp/Slim/pull/2910) Migrate Zend to Laminas
 | 
			
		||||
- [2912](https://github.com/slimphp/Slim/pull/2912) Add Laminas PSR17 Factory
 | 
			
		||||
- [2913](https://github.com/slimphp/Slim/pull/2913) Update php-autoload-override version
 | 
			
		||||
- [2914](https://github.com/slimphp/Slim/pull/2914) Added ability to add handled exceptions as an array
 | 
			
		||||
 | 
			
		||||
### Fixed
 | 
			
		||||
- [2864](https://github.com/slimphp/Slim/pull/2864) Optimize error message in error handling if displayErrorDetails was not set
 | 
			
		||||
- [2876](https://github.com/slimphp/Slim/pull/2876) Update links from http to https
 | 
			
		||||
- [2877](https://github.com/slimphp/Slim/pull/2877) Fix docblock for `Slim\Routing\RouteCollector::cacheFile`
 | 
			
		||||
- [2878](https://github.com/slimphp/Slim/pull/2878) check body is writable only on ouput buffering append
 | 
			
		||||
- [2896](https://github.com/slimphp/Slim/pull/2896) Render errors uniformly
 | 
			
		||||
- [2902](https://github.com/slimphp/Slim/pull/2902) Fix prophecies
 | 
			
		||||
- [2908](https://github.com/slimphp/Slim/pull/2908) Use autoload-dev for `Slim\Tests` namespace
 | 
			
		||||
 | 
			
		||||
### Removed
 | 
			
		||||
- [2871](https://github.com/slimphp/Slim/pull/2871) Remove explicit type-hint
 | 
			
		||||
- [2872](https://github.com/slimphp/Slim/pull/2872) Remove type-hint
 | 
			
		||||
 | 
			
		||||
## 4.3.0 - 2019-10-05
 | 
			
		||||
 | 
			
		||||
### Added
 | 
			
		||||
- [2819](https://github.com/slimphp/Slim/pull/2819) Added description to addRoutingMiddleware()
 | 
			
		||||
- [2820](https://github.com/slimphp/Slim/pull/2820) Update link to homepage in composer.json
 | 
			
		||||
- [2828](https://github.com/slimphp/Slim/pull/2828) Allow URIs with leading multi-slashes
 | 
			
		||||
- [2832](https://github.com/slimphp/Slim/pull/2832) Refactor `FastRouteDispatcher`
 | 
			
		||||
- [2835](https://github.com/slimphp/Slim/pull/2835) Rename `pathFor` to `urlFor` in docblock
 | 
			
		||||
- [2846](https://github.com/slimphp/Slim/pull/2846) Correcting the branch name as per issue-2843
 | 
			
		||||
- [2849](https://github.com/slimphp/Slim/pull/2849) Create class alias for FastRoute\RouteCollector
 | 
			
		||||
- [2855](https://github.com/slimphp/Slim/pull/2855) Add list of allowed methods to HttpMethodNotAllowedException
 | 
			
		||||
- [2860](https://github.com/slimphp/Slim/pull/2860) Add base path to `$request` and use `RouteContext` to read
 | 
			
		||||
 | 
			
		||||
### Fixed
 | 
			
		||||
- [2839](https://github.com/slimphp/Slim/pull/2839) Fix description for handler signature in phpdocs
 | 
			
		||||
- [2844](https://github.com/slimphp/Slim/pull/2844) Handle base path by routeCollector instead of RouteCollectorProxy
 | 
			
		||||
- [2845](https://github.com/slimphp/Slim/pull/2845) Fix composer scripts
 | 
			
		||||
- [2851](https://github.com/slimphp/Slim/pull/2851) Fix example of 'Hello World' app
 | 
			
		||||
- [2854](https://github.com/slimphp/Slim/pull/2854) Fix undefined property in tests
 | 
			
		||||
 | 
			
		||||
### Removed
 | 
			
		||||
- [2853](https://github.com/slimphp/Slim/pull/2853) Remove unused classes
 | 
			
		||||
 | 
			
		||||
## 4.2.0 - 2019-08-20
 | 
			
		||||
 | 
			
		||||
### Added
 | 
			
		||||
- [2787](https://github.com/slimphp/Slim/pull/2787) Add an advanced callable resolver
 | 
			
		||||
- [2791](https://github.com/slimphp/Slim/pull/2791) Add `inferPrivatePropertyTypeFromConstructor` to phpstan
 | 
			
		||||
- [2793](https://github.com/slimphp/Slim/pull/2793) Add ability to configure application via a container in `AppFactory`
 | 
			
		||||
- [2798](https://github.com/slimphp/Slim/pull/2798) Add PSR-7 Agnostic Body Parsing Middleware
 | 
			
		||||
- [2801](https://github.com/slimphp/Slim/pull/2801) Add `setLogErrorRenderer()` method to `ErrorHandler`
 | 
			
		||||
- [2807](https://github.com/slimphp/Slim/pull/2807) Add check for Slim callable notation if no resolver given
 | 
			
		||||
- [2803](https://github.com/slimphp/Slim/pull/2803) Add ability to emit non seekable streams in `ResponseEmitter`
 | 
			
		||||
- [2817](https://github.com/slimphp/Slim/pull/2817) Add the ability to pass in a custom `MiddlewareDispatcherInterface` to the `App`
 | 
			
		||||
 | 
			
		||||
### Fixed
 | 
			
		||||
- [2789](https://github.com/slimphp/Slim/pull/2789) Fix Cookie header detection in `ResponseEmitter`
 | 
			
		||||
- [2796](https://github.com/slimphp/Slim/pull/2796) Fix http message format
 | 
			
		||||
- [2800](https://github.com/slimphp/Slim/pull/2800) Fix null comparisons more clear in `ErrorHandler`
 | 
			
		||||
- [2802](https://github.com/slimphp/Slim/pull/2802) Fix incorrect search of a header in stack
 | 
			
		||||
- [2806](https://github.com/slimphp/Slim/pull/2806) Simplify `Route::prepare()` method argument preparation
 | 
			
		||||
- [2809](https://github.com/slimphp/Slim/pull/2809) Eliminate a duplicate code via HOF in `MiddlewareDispatcher`
 | 
			
		||||
- [2816](https://github.com/slimphp/Slim/pull/2816) Fix RouteCollectorProxy::redirect() bug
 | 
			
		||||
 | 
			
		||||
### Removed
 | 
			
		||||
- [2811](https://github.com/slimphp/Slim/pull/2811) Remove `DeferredCallable`
 | 
			
		||||
 | 
			
		||||
## 4.1.0 - 2019-08-06
 | 
			
		||||
 | 
			
		||||
### Added
 | 
			
		||||
- [#2779](https://github.com/slimphp/Slim/pull/2774) Add support for Slim callables `Class:method` resolution & Container Closure auto-binding in `MiddlewareDispatcher`
 | 
			
		||||
- [#2774](https://github.com/slimphp/Slim/pull/2774) Add possibility for custom `RequestHandler` invocation strategies
 | 
			
		||||
 | 
			
		||||
### Fixed
 | 
			
		||||
- [#2776](https://github.com/slimphp/Slim/pull/2774) Fix group middleware on multiple nested groups
 | 
			
		||||
							
								
								
									
										19
									
								
								qwen/php/vendor/slim/slim/LICENSE.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								qwen/php/vendor/slim/slim/LICENSE.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
			
		||||
Copyright (c) 2011-2022 Josh Lockhart
 | 
			
		||||
 | 
			
		||||
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.
 | 
			
		||||
							
								
								
									
										17
									
								
								qwen/php/vendor/slim/slim/MAINTAINERS.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								qwen/php/vendor/slim/slim/MAINTAINERS.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
			
		||||
# Maintainers
 | 
			
		||||
 | 
			
		||||
There aren't many rules for maintainers of Slim to remember; what we have is listed here.
 | 
			
		||||
 | 
			
		||||
## We don't merge our own PRs
 | 
			
		||||
 | 
			
		||||
Our code is better if more than one set of eyes looks at it. Therefore we do not merge our own pull requests unless there is an exceptional circumstance. This helps to spot errors in the patch and also enables us to share information about the project around the maintainer team.
 | 
			
		||||
 | 
			
		||||
## PRs tagged `WIP` are not ready to be merged
 | 
			
		||||
 | 
			
		||||
Sometimes it's helpful to collaborate on a patch before it's ready to be merged. We use the text `WIP` (for _Work in Progress_) in the title to mark these PRs. 
 | 
			
		||||
 | 
			
		||||
If a PR has `WIP` in its title, then it is not to be merged. The person who raised the PR will remove the `WIP` text when they are ready for a full review and merge.
 | 
			
		||||
 | 
			
		||||
## Assign a merged PR to a milestone
 | 
			
		||||
 | 
			
		||||
By ensuring that all merged PRs are assigned to a milestone, we can easily find which PRs were in which release.
 | 
			
		||||
							
								
								
									
										14
									
								
								qwen/php/vendor/slim/slim/SECURITY.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								qwen/php/vendor/slim/slim/SECURITY.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,14 @@
 | 
			
		||||
# Security Policy
 | 
			
		||||
 | 
			
		||||
### Supported Versions
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| Version | Supported          |
 | 
			
		||||
| ------- | ------------------ |
 | 
			
		||||
| 3.x.x   | :white_check_mark: |
 | 
			
		||||
| 4.x.x   | :white_check_mark: |
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### Reporting a Vulnerability
 | 
			
		||||
 | 
			
		||||
To report a vulnerability please send an email to security@slimframework.com
 | 
			
		||||
							
								
								
									
										226
									
								
								qwen/php/vendor/slim/slim/Slim/App.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										226
									
								
								qwen/php/vendor/slim/slim/Slim/App.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,226 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim;
 | 
			
		||||
 | 
			
		||||
use Psr\Container\ContainerInterface;
 | 
			
		||||
use Psr\Http\Message\ResponseFactoryInterface;
 | 
			
		||||
use Psr\Http\Message\ResponseInterface;
 | 
			
		||||
use Psr\Http\Message\ServerRequestInterface;
 | 
			
		||||
use Psr\Http\Server\MiddlewareInterface;
 | 
			
		||||
use Psr\Http\Server\RequestHandlerInterface;
 | 
			
		||||
use Psr\Log\LoggerInterface;
 | 
			
		||||
use Slim\Factory\ServerRequestCreatorFactory;
 | 
			
		||||
use Slim\Interfaces\CallableResolverInterface;
 | 
			
		||||
use Slim\Interfaces\MiddlewareDispatcherInterface;
 | 
			
		||||
use Slim\Interfaces\RouteCollectorInterface;
 | 
			
		||||
use Slim\Interfaces\RouteResolverInterface;
 | 
			
		||||
use Slim\Middleware\BodyParsingMiddleware;
 | 
			
		||||
use Slim\Middleware\ErrorMiddleware;
 | 
			
		||||
use Slim\Middleware\RoutingMiddleware;
 | 
			
		||||
use Slim\Routing\RouteCollectorProxy;
 | 
			
		||||
use Slim\Routing\RouteResolver;
 | 
			
		||||
use Slim\Routing\RouteRunner;
 | 
			
		||||
 | 
			
		||||
use function strtoupper;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @api
 | 
			
		||||
 * @template TContainerInterface of (ContainerInterface|null)
 | 
			
		||||
 * @template-extends RouteCollectorProxy<TContainerInterface>
 | 
			
		||||
 */
 | 
			
		||||
class App extends RouteCollectorProxy implements RequestHandlerInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * Current version
 | 
			
		||||
     *
 | 
			
		||||
     * @var string
 | 
			
		||||
     */
 | 
			
		||||
    public const VERSION = '4.15.0';
 | 
			
		||||
 | 
			
		||||
    protected RouteResolverInterface $routeResolver;
 | 
			
		||||
 | 
			
		||||
    protected MiddlewareDispatcherInterface $middlewareDispatcher;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param TContainerInterface $container
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        ResponseFactoryInterface $responseFactory,
 | 
			
		||||
        ?ContainerInterface $container = null,
 | 
			
		||||
        ?CallableResolverInterface $callableResolver = null,
 | 
			
		||||
        ?RouteCollectorInterface $routeCollector = null,
 | 
			
		||||
        ?RouteResolverInterface $routeResolver = null,
 | 
			
		||||
        ?MiddlewareDispatcherInterface $middlewareDispatcher = null
 | 
			
		||||
    ) {
 | 
			
		||||
        parent::__construct(
 | 
			
		||||
            $responseFactory,
 | 
			
		||||
            $callableResolver ?? new CallableResolver($container),
 | 
			
		||||
            $container,
 | 
			
		||||
            $routeCollector
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        $this->routeResolver = $routeResolver ?? new RouteResolver($this->routeCollector);
 | 
			
		||||
        $routeRunner = new RouteRunner($this->routeResolver, $this->routeCollector->getRouteParser(), $this);
 | 
			
		||||
 | 
			
		||||
        if (!$middlewareDispatcher) {
 | 
			
		||||
            $middlewareDispatcher = new MiddlewareDispatcher($routeRunner, $this->callableResolver, $container);
 | 
			
		||||
        } else {
 | 
			
		||||
            $middlewareDispatcher->seedMiddlewareStack($routeRunner);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $this->middlewareDispatcher = $middlewareDispatcher;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @return RouteResolverInterface
 | 
			
		||||
     */
 | 
			
		||||
    public function getRouteResolver(): RouteResolverInterface
 | 
			
		||||
    {
 | 
			
		||||
        return $this->routeResolver;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @return MiddlewareDispatcherInterface
 | 
			
		||||
     */
 | 
			
		||||
    public function getMiddlewareDispatcher(): MiddlewareDispatcherInterface
 | 
			
		||||
    {
 | 
			
		||||
        return $this->middlewareDispatcher;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param MiddlewareInterface|string|callable $middleware
 | 
			
		||||
     * @return App<TContainerInterface>
 | 
			
		||||
     */
 | 
			
		||||
    public function add($middleware): self
 | 
			
		||||
    {
 | 
			
		||||
        $this->middlewareDispatcher->add($middleware);
 | 
			
		||||
        return $this;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param MiddlewareInterface $middleware
 | 
			
		||||
     * @return App<TContainerInterface>
 | 
			
		||||
     */
 | 
			
		||||
    public function addMiddleware(MiddlewareInterface $middleware): self
 | 
			
		||||
    {
 | 
			
		||||
        $this->middlewareDispatcher->addMiddleware($middleware);
 | 
			
		||||
        return $this;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Add the Slim built-in routing middleware to the app middleware stack
 | 
			
		||||
     *
 | 
			
		||||
     * This method can be used to control middleware order and is not required for default routing operation.
 | 
			
		||||
     *
 | 
			
		||||
     * @return RoutingMiddleware
 | 
			
		||||
     */
 | 
			
		||||
    public function addRoutingMiddleware(): RoutingMiddleware
 | 
			
		||||
    {
 | 
			
		||||
        $routingMiddleware = new RoutingMiddleware(
 | 
			
		||||
            $this->getRouteResolver(),
 | 
			
		||||
            $this->getRouteCollector()->getRouteParser()
 | 
			
		||||
        );
 | 
			
		||||
        $this->add($routingMiddleware);
 | 
			
		||||
        return $routingMiddleware;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Add the Slim built-in error middleware to the app middleware stack
 | 
			
		||||
     *
 | 
			
		||||
     * @param bool                 $displayErrorDetails
 | 
			
		||||
     * @param bool                 $logErrors
 | 
			
		||||
     * @param bool                 $logErrorDetails
 | 
			
		||||
     * @param LoggerInterface|null $logger
 | 
			
		||||
     *
 | 
			
		||||
     * @return ErrorMiddleware
 | 
			
		||||
     */
 | 
			
		||||
    public function addErrorMiddleware(
 | 
			
		||||
        bool $displayErrorDetails,
 | 
			
		||||
        bool $logErrors,
 | 
			
		||||
        bool $logErrorDetails,
 | 
			
		||||
        ?LoggerInterface $logger = null
 | 
			
		||||
    ): ErrorMiddleware {
 | 
			
		||||
        $errorMiddleware = new ErrorMiddleware(
 | 
			
		||||
            $this->getCallableResolver(),
 | 
			
		||||
            $this->getResponseFactory(),
 | 
			
		||||
            $displayErrorDetails,
 | 
			
		||||
            $logErrors,
 | 
			
		||||
            $logErrorDetails,
 | 
			
		||||
            $logger
 | 
			
		||||
        );
 | 
			
		||||
        $this->add($errorMiddleware);
 | 
			
		||||
        return $errorMiddleware;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Add the Slim body parsing middleware to the app middleware stack
 | 
			
		||||
     *
 | 
			
		||||
     * @param callable[] $bodyParsers
 | 
			
		||||
     *
 | 
			
		||||
     * @return BodyParsingMiddleware
 | 
			
		||||
     */
 | 
			
		||||
    public function addBodyParsingMiddleware(array $bodyParsers = []): BodyParsingMiddleware
 | 
			
		||||
    {
 | 
			
		||||
        $bodyParsingMiddleware = new BodyParsingMiddleware($bodyParsers);
 | 
			
		||||
        $this->add($bodyParsingMiddleware);
 | 
			
		||||
        return $bodyParsingMiddleware;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Run application
 | 
			
		||||
     *
 | 
			
		||||
     * This method traverses the application middleware stack and then sends the
 | 
			
		||||
     * resultant Response object to the HTTP client.
 | 
			
		||||
     *
 | 
			
		||||
     * @param ServerRequestInterface|null $request
 | 
			
		||||
     * @return void
 | 
			
		||||
     */
 | 
			
		||||
    public function run(?ServerRequestInterface $request = null): void
 | 
			
		||||
    {
 | 
			
		||||
        if (!$request) {
 | 
			
		||||
            $serverRequestCreator = ServerRequestCreatorFactory::create();
 | 
			
		||||
            $request = $serverRequestCreator->createServerRequestFromGlobals();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $response = $this->handle($request);
 | 
			
		||||
        $responseEmitter = new ResponseEmitter();
 | 
			
		||||
        $responseEmitter->emit($response);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Handle a request
 | 
			
		||||
     *
 | 
			
		||||
     * This method traverses the application middleware stack and then returns the
 | 
			
		||||
     * resultant Response object.
 | 
			
		||||
     *
 | 
			
		||||
     * @param ServerRequestInterface $request
 | 
			
		||||
     * @return ResponseInterface
 | 
			
		||||
     */
 | 
			
		||||
    public function handle(ServerRequestInterface $request): ResponseInterface
 | 
			
		||||
    {
 | 
			
		||||
        $response = $this->middlewareDispatcher->handle($request);
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * This is to be in compliance with RFC 2616, Section 9.
 | 
			
		||||
         * If the incoming request method is HEAD, we need to ensure that the response body
 | 
			
		||||
         * is empty as the request may fall back on a GET route handler due to FastRoute's
 | 
			
		||||
         * routing logic which could potentially append content to the response body
 | 
			
		||||
         * https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.4
 | 
			
		||||
         */
 | 
			
		||||
        $method = strtoupper($request->getMethod());
 | 
			
		||||
        if ($method === 'HEAD') {
 | 
			
		||||
            $emptyBody = $this->responseFactory->createResponse()->getBody();
 | 
			
		||||
            return $response->withBody($emptyBody);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $response;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										200
									
								
								qwen/php/vendor/slim/slim/Slim/CallableResolver.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										200
									
								
								qwen/php/vendor/slim/slim/Slim/CallableResolver.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,200 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim;
 | 
			
		||||
 | 
			
		||||
use Closure;
 | 
			
		||||
use Psr\Container\ContainerInterface;
 | 
			
		||||
use Psr\Http\Server\MiddlewareInterface;
 | 
			
		||||
use Psr\Http\Server\RequestHandlerInterface;
 | 
			
		||||
use RuntimeException;
 | 
			
		||||
use Slim\Interfaces\AdvancedCallableResolverInterface;
 | 
			
		||||
 | 
			
		||||
use function class_exists;
 | 
			
		||||
use function is_array;
 | 
			
		||||
use function is_callable;
 | 
			
		||||
use function is_object;
 | 
			
		||||
use function is_string;
 | 
			
		||||
use function json_encode;
 | 
			
		||||
use function preg_match;
 | 
			
		||||
use function sprintf;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @template TContainerInterface of (ContainerInterface|null)
 | 
			
		||||
 */
 | 
			
		||||
final class CallableResolver implements AdvancedCallableResolverInterface
 | 
			
		||||
{
 | 
			
		||||
    public static string $callablePattern = '!^([^\:]+)\:([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)$!';
 | 
			
		||||
 | 
			
		||||
    /** @var TContainerInterface $container */
 | 
			
		||||
    private ?ContainerInterface $container;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param TContainerInterface $container
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct(?ContainerInterface $container = null)
 | 
			
		||||
    {
 | 
			
		||||
        $this->container = $container;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function resolve($toResolve): callable
 | 
			
		||||
    {
 | 
			
		||||
        $toResolve = $this->prepareToResolve($toResolve);
 | 
			
		||||
        if (is_callable($toResolve)) {
 | 
			
		||||
            return $this->bindToContainer($toResolve);
 | 
			
		||||
        }
 | 
			
		||||
        $resolved = $toResolve;
 | 
			
		||||
        if (is_string($toResolve)) {
 | 
			
		||||
            $resolved = $this->resolveSlimNotation($toResolve);
 | 
			
		||||
            $resolved[1] ??= '__invoke';
 | 
			
		||||
        }
 | 
			
		||||
        $callable = $this->assertCallable($resolved, $toResolve);
 | 
			
		||||
        return $this->bindToContainer($callable);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function resolveRoute($toResolve): callable
 | 
			
		||||
    {
 | 
			
		||||
        return $this->resolveByPredicate($toResolve, [$this, 'isRoute'], 'handle');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function resolveMiddleware($toResolve): callable
 | 
			
		||||
    {
 | 
			
		||||
        return $this->resolveByPredicate($toResolve, [$this, 'isMiddleware'], 'process');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param callable|array{class-string, string}|string $toResolve
 | 
			
		||||
     *
 | 
			
		||||
     * @throws RuntimeException
 | 
			
		||||
     */
 | 
			
		||||
    private function resolveByPredicate($toResolve, callable $predicate, string $defaultMethod): callable
 | 
			
		||||
    {
 | 
			
		||||
        $toResolve = $this->prepareToResolve($toResolve);
 | 
			
		||||
        if (is_callable($toResolve)) {
 | 
			
		||||
            return $this->bindToContainer($toResolve);
 | 
			
		||||
        }
 | 
			
		||||
        $resolved = $toResolve;
 | 
			
		||||
        if ($predicate($toResolve)) {
 | 
			
		||||
            $resolved = [$toResolve, $defaultMethod];
 | 
			
		||||
        }
 | 
			
		||||
        if (is_string($toResolve)) {
 | 
			
		||||
            [$instance, $method] = $this->resolveSlimNotation($toResolve);
 | 
			
		||||
            if ($method === null && $predicate($instance)) {
 | 
			
		||||
                $method = $defaultMethod;
 | 
			
		||||
            }
 | 
			
		||||
            $resolved = [$instance, $method ?? '__invoke'];
 | 
			
		||||
        }
 | 
			
		||||
        $callable = $this->assertCallable($resolved, $toResolve);
 | 
			
		||||
        return $this->bindToContainer($callable);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param mixed $toResolve
 | 
			
		||||
     */
 | 
			
		||||
    private function isRoute($toResolve): bool
 | 
			
		||||
    {
 | 
			
		||||
        return $toResolve instanceof RequestHandlerInterface;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param mixed $toResolve
 | 
			
		||||
     */
 | 
			
		||||
    private function isMiddleware($toResolve): bool
 | 
			
		||||
    {
 | 
			
		||||
        return $toResolve instanceof MiddlewareInterface;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @throws RuntimeException
 | 
			
		||||
     *
 | 
			
		||||
     * @return array{object, string|null} [Instance, Method Name]
 | 
			
		||||
     */
 | 
			
		||||
    private function resolveSlimNotation(string $toResolve): array
 | 
			
		||||
    {
 | 
			
		||||
        /** @psalm-suppress ArgumentTypeCoercion */
 | 
			
		||||
        preg_match(CallableResolver::$callablePattern, $toResolve, $matches);
 | 
			
		||||
        [$class, $method] = $matches ? [$matches[1], $matches[2]] : [$toResolve, null];
 | 
			
		||||
 | 
			
		||||
        if ($this->container && $this->container->has($class)) {
 | 
			
		||||
            $instance = $this->container->get($class);
 | 
			
		||||
            if (!is_object($instance)) {
 | 
			
		||||
                throw new RuntimeException(sprintf('%s container entry is not an object', $class));
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            if (!class_exists($class)) {
 | 
			
		||||
                if ($method) {
 | 
			
		||||
                    $class .= '::' . $method . '()';
 | 
			
		||||
                }
 | 
			
		||||
                throw new RuntimeException(sprintf('Callable %s does not exist', $class));
 | 
			
		||||
            }
 | 
			
		||||
            $instance = new $class($this->container);
 | 
			
		||||
        }
 | 
			
		||||
        return [$instance, $method];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param mixed $resolved
 | 
			
		||||
     * @param mixed $toResolve
 | 
			
		||||
     *
 | 
			
		||||
     * @throws RuntimeException
 | 
			
		||||
     */
 | 
			
		||||
    private function assertCallable($resolved, $toResolve): callable
 | 
			
		||||
    {
 | 
			
		||||
        if (!is_callable($resolved)) {
 | 
			
		||||
            if (is_callable($toResolve) || is_object($toResolve) || is_array($toResolve)) {
 | 
			
		||||
                $formatedToResolve = ($toResolveJson = json_encode($toResolve)) !== false ? $toResolveJson : '';
 | 
			
		||||
            } else {
 | 
			
		||||
                $formatedToResolve = is_string($toResolve) ? $toResolve : '';
 | 
			
		||||
            }
 | 
			
		||||
            throw new RuntimeException(sprintf('%s is not resolvable', $formatedToResolve));
 | 
			
		||||
        }
 | 
			
		||||
        return $resolved;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private function bindToContainer(callable $callable): callable
 | 
			
		||||
    {
 | 
			
		||||
        if (is_array($callable) && $callable[0] instanceof Closure) {
 | 
			
		||||
            $callable = $callable[0];
 | 
			
		||||
        }
 | 
			
		||||
        if ($this->container && $callable instanceof Closure) {
 | 
			
		||||
            /** @var Closure $callable */
 | 
			
		||||
            $callable = $callable->bindTo($this->container);
 | 
			
		||||
        }
 | 
			
		||||
        return $callable;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param callable|string|array{class-string, string}|mixed $toResolve
 | 
			
		||||
     *
 | 
			
		||||
     * @return callable|string|array{class-string, string}|mixed
 | 
			
		||||
     */
 | 
			
		||||
    private function prepareToResolve($toResolve)
 | 
			
		||||
    {
 | 
			
		||||
        if (!is_array($toResolve)) {
 | 
			
		||||
            return $toResolve;
 | 
			
		||||
        }
 | 
			
		||||
        $candidate = $toResolve;
 | 
			
		||||
        $class = array_shift($candidate);
 | 
			
		||||
        $method = array_shift($candidate);
 | 
			
		||||
        if (is_string($class) && is_string($method)) {
 | 
			
		||||
            return $class . ':' . $method;
 | 
			
		||||
        }
 | 
			
		||||
        return $toResolve;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										46
									
								
								qwen/php/vendor/slim/slim/Slim/Error/AbstractErrorRenderer.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								qwen/php/vendor/slim/slim/Slim/Error/AbstractErrorRenderer.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,46 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Error;
 | 
			
		||||
 | 
			
		||||
use Slim\Exception\HttpException;
 | 
			
		||||
use Slim\Interfaces\ErrorRendererInterface;
 | 
			
		||||
use Throwable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Abstract Slim application error renderer
 | 
			
		||||
 *
 | 
			
		||||
 * It outputs the error message and diagnostic information in one of the following formats:
 | 
			
		||||
 * JSON, XML, Plain Text or HTML
 | 
			
		||||
 */
 | 
			
		||||
abstract class AbstractErrorRenderer implements ErrorRendererInterface
 | 
			
		||||
{
 | 
			
		||||
    protected string $defaultErrorTitle = 'Slim Application Error';
 | 
			
		||||
 | 
			
		||||
    protected string $defaultErrorDescription = 'A website error has occurred. Sorry for the temporary inconvenience.';
 | 
			
		||||
 | 
			
		||||
    protected function getErrorTitle(Throwable $exception): string
 | 
			
		||||
    {
 | 
			
		||||
        if ($exception instanceof HttpException) {
 | 
			
		||||
            return $exception->getTitle();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $this->defaultErrorTitle;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected function getErrorDescription(Throwable $exception): string
 | 
			
		||||
    {
 | 
			
		||||
        if ($exception instanceof HttpException) {
 | 
			
		||||
            return $exception->getDescription();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $this->defaultErrorDescription;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										83
									
								
								qwen/php/vendor/slim/slim/Slim/Error/Renderers/HtmlErrorRenderer.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										83
									
								
								qwen/php/vendor/slim/slim/Slim/Error/Renderers/HtmlErrorRenderer.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,83 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Error\Renderers;
 | 
			
		||||
 | 
			
		||||
use Slim\Error\AbstractErrorRenderer;
 | 
			
		||||
use Throwable;
 | 
			
		||||
 | 
			
		||||
use function get_class;
 | 
			
		||||
use function htmlentities;
 | 
			
		||||
use function sprintf;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Default Slim application HTML Error Renderer
 | 
			
		||||
 */
 | 
			
		||||
class HtmlErrorRenderer extends AbstractErrorRenderer
 | 
			
		||||
{
 | 
			
		||||
    public function __invoke(Throwable $exception, bool $displayErrorDetails): string
 | 
			
		||||
    {
 | 
			
		||||
        if ($displayErrorDetails) {
 | 
			
		||||
            $html = '<p>The application could not run because of the following error:</p>';
 | 
			
		||||
            $html .= '<h2>Details</h2>';
 | 
			
		||||
            $html .= $this->renderExceptionFragment($exception);
 | 
			
		||||
        } else {
 | 
			
		||||
            $html = "<p>{$this->getErrorDescription($exception)}</p>";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $this->renderHtmlBody($this->getErrorTitle($exception), $html);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private function renderExceptionFragment(Throwable $exception): string
 | 
			
		||||
    {
 | 
			
		||||
        $html = sprintf('<div><strong>Type:</strong> %s</div>', get_class($exception));
 | 
			
		||||
 | 
			
		||||
        $code = $exception->getCode();
 | 
			
		||||
        $html .= sprintf('<div><strong>Code:</strong> %s</div>', $code);
 | 
			
		||||
 | 
			
		||||
        $html .= sprintf('<div><strong>Message:</strong> %s</div>', htmlentities($exception->getMessage()));
 | 
			
		||||
 | 
			
		||||
        $html .= sprintf('<div><strong>File:</strong> %s</div>', $exception->getFile());
 | 
			
		||||
 | 
			
		||||
        $html .= sprintf('<div><strong>Line:</strong> %s</div>', $exception->getLine());
 | 
			
		||||
 | 
			
		||||
        $html .= '<h2>Trace</h2>';
 | 
			
		||||
        $html .= sprintf('<pre>%s</pre>', htmlentities($exception->getTraceAsString()));
 | 
			
		||||
 | 
			
		||||
        return $html;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function renderHtmlBody(string $title = '', string $html = ''): string
 | 
			
		||||
    {
 | 
			
		||||
        return sprintf(
 | 
			
		||||
            '<!doctype html>' .
 | 
			
		||||
            '<html lang="en">' .
 | 
			
		||||
            '    <head>' .
 | 
			
		||||
            '        <meta charset="utf-8">' .
 | 
			
		||||
            '        <meta name="viewport" content="width=device-width, initial-scale=1">' .
 | 
			
		||||
            '        <title>%s</title>' .
 | 
			
		||||
            '        <style>' .
 | 
			
		||||
            '            body{margin:0;padding:30px;font:12px/1.5 Helvetica,Arial,Verdana,sans-serif}' .
 | 
			
		||||
            '            h1{margin:0;font-size:48px;font-weight:normal;line-height:48px}' .
 | 
			
		||||
            '            strong{display:inline-block;width:65px}' .
 | 
			
		||||
            '        </style>' .
 | 
			
		||||
            '    </head>' .
 | 
			
		||||
            '    <body>' .
 | 
			
		||||
            '        <h1>%s</h1>' .
 | 
			
		||||
            '        <div>%s</div>' .
 | 
			
		||||
            '        <a href="#" onclick="window.history.go(-1)">Go Back</a>' .
 | 
			
		||||
            '    </body>' .
 | 
			
		||||
            '</html>',
 | 
			
		||||
            $title,
 | 
			
		||||
            $title,
 | 
			
		||||
            $html
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										55
									
								
								qwen/php/vendor/slim/slim/Slim/Error/Renderers/JsonErrorRenderer.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								qwen/php/vendor/slim/slim/Slim/Error/Renderers/JsonErrorRenderer.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,55 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Error\Renderers;
 | 
			
		||||
 | 
			
		||||
use Slim\Error\AbstractErrorRenderer;
 | 
			
		||||
use Throwable;
 | 
			
		||||
 | 
			
		||||
use function get_class;
 | 
			
		||||
use function json_encode;
 | 
			
		||||
 | 
			
		||||
use const JSON_PRETTY_PRINT;
 | 
			
		||||
use const JSON_UNESCAPED_SLASHES;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Default Slim application JSON Error Renderer
 | 
			
		||||
 */
 | 
			
		||||
class JsonErrorRenderer extends AbstractErrorRenderer
 | 
			
		||||
{
 | 
			
		||||
    public function __invoke(Throwable $exception, bool $displayErrorDetails): string
 | 
			
		||||
    {
 | 
			
		||||
        $error = ['message' => $this->getErrorTitle($exception)];
 | 
			
		||||
 | 
			
		||||
        if ($displayErrorDetails) {
 | 
			
		||||
            $error['exception'] = [];
 | 
			
		||||
            do {
 | 
			
		||||
                $error['exception'][] = $this->formatExceptionFragment($exception);
 | 
			
		||||
            } while ($exception = $exception->getPrevious());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return (string) json_encode($error, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @return array<string|int>
 | 
			
		||||
     */
 | 
			
		||||
    private function formatExceptionFragment(Throwable $exception): array
 | 
			
		||||
    {
 | 
			
		||||
        $code = $exception->getCode();
 | 
			
		||||
        return [
 | 
			
		||||
            'type' => get_class($exception),
 | 
			
		||||
            'code' => $code,
 | 
			
		||||
            'message' => $exception->getMessage(),
 | 
			
		||||
            'file' => $exception->getFile(),
 | 
			
		||||
            'line' => $exception->getLine(),
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										59
									
								
								qwen/php/vendor/slim/slim/Slim/Error/Renderers/PlainTextErrorRenderer.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								qwen/php/vendor/slim/slim/Slim/Error/Renderers/PlainTextErrorRenderer.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,59 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Error\Renderers;
 | 
			
		||||
 | 
			
		||||
use Slim\Error\AbstractErrorRenderer;
 | 
			
		||||
use Throwable;
 | 
			
		||||
 | 
			
		||||
use function get_class;
 | 
			
		||||
use function htmlentities;
 | 
			
		||||
use function sprintf;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Default Slim application Plain Text Error Renderer
 | 
			
		||||
 */
 | 
			
		||||
class PlainTextErrorRenderer extends AbstractErrorRenderer
 | 
			
		||||
{
 | 
			
		||||
    public function __invoke(Throwable $exception, bool $displayErrorDetails): string
 | 
			
		||||
    {
 | 
			
		||||
        $text = "{$this->getErrorTitle($exception)}\n";
 | 
			
		||||
 | 
			
		||||
        if ($displayErrorDetails) {
 | 
			
		||||
            $text .= $this->formatExceptionFragment($exception);
 | 
			
		||||
 | 
			
		||||
            while ($exception = $exception->getPrevious()) {
 | 
			
		||||
                $text .= "\nPrevious Error:\n";
 | 
			
		||||
                $text .= $this->formatExceptionFragment($exception);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $text;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private function formatExceptionFragment(Throwable $exception): string
 | 
			
		||||
    {
 | 
			
		||||
        $text = sprintf("Type: %s\n", get_class($exception));
 | 
			
		||||
 | 
			
		||||
        $code = $exception->getCode();
 | 
			
		||||
 | 
			
		||||
        $text .= sprintf("Code: %s\n", $code);
 | 
			
		||||
 | 
			
		||||
        $text .= sprintf("Message: %s\n", $exception->getMessage());
 | 
			
		||||
 | 
			
		||||
        $text .= sprintf("File: %s\n", $exception->getFile());
 | 
			
		||||
 | 
			
		||||
        $text .= sprintf("Line: %s\n", $exception->getLine());
 | 
			
		||||
 | 
			
		||||
        $text .= sprintf('Trace: %s', $exception->getTraceAsString());
 | 
			
		||||
 | 
			
		||||
        return $text;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										54
									
								
								qwen/php/vendor/slim/slim/Slim/Error/Renderers/XmlErrorRenderer.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								qwen/php/vendor/slim/slim/Slim/Error/Renderers/XmlErrorRenderer.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,54 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Error\Renderers;
 | 
			
		||||
 | 
			
		||||
use Slim\Error\AbstractErrorRenderer;
 | 
			
		||||
use Throwable;
 | 
			
		||||
 | 
			
		||||
use function get_class;
 | 
			
		||||
use function sprintf;
 | 
			
		||||
use function str_replace;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Default Slim application XML Error Renderer
 | 
			
		||||
 */
 | 
			
		||||
class XmlErrorRenderer extends AbstractErrorRenderer
 | 
			
		||||
{
 | 
			
		||||
    public function __invoke(Throwable $exception, bool $displayErrorDetails): string
 | 
			
		||||
    {
 | 
			
		||||
        $xml = '<' . '?xml version="1.0" encoding="UTF-8" standalone="yes"?' . ">\n";
 | 
			
		||||
        $xml .= "<error>\n  <message>" . $this->createCdataSection($this->getErrorTitle($exception)) . "</message>\n";
 | 
			
		||||
 | 
			
		||||
        if ($displayErrorDetails) {
 | 
			
		||||
            do {
 | 
			
		||||
                $xml .= "  <exception>\n";
 | 
			
		||||
                $xml .= '    <type>' . get_class($exception) . "</type>\n";
 | 
			
		||||
                $xml .= '    <code>' . $exception->getCode() . "</code>\n";
 | 
			
		||||
                $xml .= '    <message>' . $this->createCdataSection($exception->getMessage()) . "</message>\n";
 | 
			
		||||
                $xml .= '    <file>' . $exception->getFile() . "</file>\n";
 | 
			
		||||
                $xml .= '    <line>' . $exception->getLine() . "</line>\n";
 | 
			
		||||
                $xml .= "  </exception>\n";
 | 
			
		||||
            } while ($exception = $exception->getPrevious());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $xml .= '</error>';
 | 
			
		||||
 | 
			
		||||
        return $xml;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns a CDATA section with the given content.
 | 
			
		||||
     */
 | 
			
		||||
    private function createCdataSection(string $content): string
 | 
			
		||||
    {
 | 
			
		||||
        return sprintf('<![CDATA[%s]]>', str_replace(']]>', ']]]]><![CDATA[>', $content));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										29
									
								
								qwen/php/vendor/slim/slim/Slim/Exception/HttpBadRequestException.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								qwen/php/vendor/slim/slim/Slim/Exception/HttpBadRequestException.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,29 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Exception;
 | 
			
		||||
 | 
			
		||||
/** @api */
 | 
			
		||||
class HttpBadRequestException extends HttpSpecializedException
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @var int
 | 
			
		||||
     */
 | 
			
		||||
    protected $code = 400;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var string
 | 
			
		||||
     */
 | 
			
		||||
    protected $message = 'Bad request.';
 | 
			
		||||
 | 
			
		||||
    protected string $title = '400 Bad Request';
 | 
			
		||||
    protected string $description = 'The server cannot or will not process ' .
 | 
			
		||||
        'the request due to an apparent client error.';
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										65
									
								
								qwen/php/vendor/slim/slim/Slim/Exception/HttpException.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								qwen/php/vendor/slim/slim/Slim/Exception/HttpException.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,65 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Exception;
 | 
			
		||||
 | 
			
		||||
use Psr\Http\Message\ServerRequestInterface;
 | 
			
		||||
use RuntimeException;
 | 
			
		||||
use Throwable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @api
 | 
			
		||||
 * @method int getCode()
 | 
			
		||||
 */
 | 
			
		||||
class HttpException extends RuntimeException
 | 
			
		||||
{
 | 
			
		||||
    protected ServerRequestInterface $request;
 | 
			
		||||
 | 
			
		||||
    protected string $title = '';
 | 
			
		||||
 | 
			
		||||
    protected string $description = '';
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        ServerRequestInterface $request,
 | 
			
		||||
        string $message = '',
 | 
			
		||||
        int $code = 0,
 | 
			
		||||
        ?Throwable $previous = null
 | 
			
		||||
    ) {
 | 
			
		||||
        parent::__construct($message, $code, $previous);
 | 
			
		||||
        $this->request = $request;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getRequest(): ServerRequestInterface
 | 
			
		||||
    {
 | 
			
		||||
        return $this->request;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getTitle(): string
 | 
			
		||||
    {
 | 
			
		||||
        return $this->title;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function setTitle(string $title): self
 | 
			
		||||
    {
 | 
			
		||||
        $this->title = $title;
 | 
			
		||||
        return $this;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getDescription(): string
 | 
			
		||||
    {
 | 
			
		||||
        return $this->description;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function setDescription(string $description): self
 | 
			
		||||
    {
 | 
			
		||||
        $this->description = $description;
 | 
			
		||||
        return $this;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										28
									
								
								qwen/php/vendor/slim/slim/Slim/Exception/HttpForbiddenException.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								qwen/php/vendor/slim/slim/Slim/Exception/HttpForbiddenException.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Exception;
 | 
			
		||||
 | 
			
		||||
/** @api */
 | 
			
		||||
class HttpForbiddenException extends HttpSpecializedException
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @var int
 | 
			
		||||
     */
 | 
			
		||||
    protected $code = 403;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var string
 | 
			
		||||
     */
 | 
			
		||||
    protected $message = 'Forbidden.';
 | 
			
		||||
 | 
			
		||||
    protected string $title = '403 Forbidden';
 | 
			
		||||
    protected string $description = 'You are not permitted to perform the requested operation.';
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										28
									
								
								qwen/php/vendor/slim/slim/Slim/Exception/HttpGoneException.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								qwen/php/vendor/slim/slim/Slim/Exception/HttpGoneException.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Exception;
 | 
			
		||||
 | 
			
		||||
/** @api */
 | 
			
		||||
class HttpGoneException extends HttpSpecializedException
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @var int
 | 
			
		||||
     */
 | 
			
		||||
    protected $code = 410;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var string
 | 
			
		||||
     */
 | 
			
		||||
    protected $message = 'Gone.';
 | 
			
		||||
 | 
			
		||||
    protected string $title = '410 Gone';
 | 
			
		||||
    protected string $description = 'The target resource is no longer available at the origin server.';
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										28
									
								
								qwen/php/vendor/slim/slim/Slim/Exception/HttpInternalServerErrorException.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								qwen/php/vendor/slim/slim/Slim/Exception/HttpInternalServerErrorException.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Exception;
 | 
			
		||||
 | 
			
		||||
/** @api */
 | 
			
		||||
class HttpInternalServerErrorException extends HttpSpecializedException
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @var int
 | 
			
		||||
     */
 | 
			
		||||
    protected $code = 500;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var string
 | 
			
		||||
     */
 | 
			
		||||
    protected $message = 'Internal server error.';
 | 
			
		||||
 | 
			
		||||
    protected string $title = '500 Internal Server Error';
 | 
			
		||||
    protected string $description = 'Unexpected condition encountered preventing server from fulfilling request.';
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										52
									
								
								qwen/php/vendor/slim/slim/Slim/Exception/HttpMethodNotAllowedException.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								qwen/php/vendor/slim/slim/Slim/Exception/HttpMethodNotAllowedException.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,52 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Exception;
 | 
			
		||||
 | 
			
		||||
use function implode;
 | 
			
		||||
 | 
			
		||||
class HttpMethodNotAllowedException extends HttpSpecializedException
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @var string[]
 | 
			
		||||
     */
 | 
			
		||||
    protected array $allowedMethods = [];
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var int
 | 
			
		||||
     */
 | 
			
		||||
    protected $code = 405;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var string
 | 
			
		||||
     */
 | 
			
		||||
    protected $message = 'Method not allowed.';
 | 
			
		||||
 | 
			
		||||
    protected string $title = '405 Method Not Allowed';
 | 
			
		||||
    protected string $description = 'The request method is not supported for the requested resource.';
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @return string[]
 | 
			
		||||
     */
 | 
			
		||||
    public function getAllowedMethods(): array
 | 
			
		||||
    {
 | 
			
		||||
        return $this->allowedMethods;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param string[] $methods
 | 
			
		||||
     */
 | 
			
		||||
    public function setAllowedMethods(array $methods): self
 | 
			
		||||
    {
 | 
			
		||||
        $this->allowedMethods = $methods;
 | 
			
		||||
        $this->message = 'Method not allowed. Must be one of: ' . implode(', ', $methods);
 | 
			
		||||
        return $this;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										27
									
								
								qwen/php/vendor/slim/slim/Slim/Exception/HttpNotFoundException.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								qwen/php/vendor/slim/slim/Slim/Exception/HttpNotFoundException.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Exception;
 | 
			
		||||
 | 
			
		||||
class HttpNotFoundException extends HttpSpecializedException
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @var int
 | 
			
		||||
     */
 | 
			
		||||
    protected $code = 404;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var string
 | 
			
		||||
     */
 | 
			
		||||
    protected $message = 'Not found.';
 | 
			
		||||
 | 
			
		||||
    protected string $title = '404 Not Found';
 | 
			
		||||
    protected string $description = 'The requested resource could not be found. Please verify the URI and try again.';
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										28
									
								
								qwen/php/vendor/slim/slim/Slim/Exception/HttpNotImplementedException.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								qwen/php/vendor/slim/slim/Slim/Exception/HttpNotImplementedException.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Exception;
 | 
			
		||||
 | 
			
		||||
/** @api */
 | 
			
		||||
class HttpNotImplementedException extends HttpSpecializedException
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @var int
 | 
			
		||||
     */
 | 
			
		||||
    protected $code = 501;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var string
 | 
			
		||||
     */
 | 
			
		||||
    protected $message = 'Not implemented.';
 | 
			
		||||
 | 
			
		||||
    protected string $title = '501 Not Implemented';
 | 
			
		||||
    protected string $description = 'The server does not support the functionality required to fulfill the request.';
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										32
									
								
								qwen/php/vendor/slim/slim/Slim/Exception/HttpSpecializedException.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								qwen/php/vendor/slim/slim/Slim/Exception/HttpSpecializedException.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,32 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Exception;
 | 
			
		||||
 | 
			
		||||
use Psr\Http\Message\ServerRequestInterface;
 | 
			
		||||
use Throwable;
 | 
			
		||||
 | 
			
		||||
abstract class HttpSpecializedException extends HttpException
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @param ServerRequestInterface $request
 | 
			
		||||
     * @param string|null $message
 | 
			
		||||
     * @param Throwable|null $previous
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct(ServerRequestInterface $request, ?string $message = null, ?Throwable $previous = null)
 | 
			
		||||
    {
 | 
			
		||||
        if ($message !== null) {
 | 
			
		||||
            $this->message = $message;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // @phpstan-ignore-next-line
 | 
			
		||||
        parent::__construct($request, $this->message, $this->code, $previous);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										29
									
								
								qwen/php/vendor/slim/slim/Slim/Exception/HttpTooManyRequestsException.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								qwen/php/vendor/slim/slim/Slim/Exception/HttpTooManyRequestsException.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,29 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Exception;
 | 
			
		||||
 | 
			
		||||
/** @api */
 | 
			
		||||
class HttpTooManyRequestsException extends HttpSpecializedException
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @var int
 | 
			
		||||
     */
 | 
			
		||||
    protected $code = 429;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var string
 | 
			
		||||
     */
 | 
			
		||||
    protected $message = 'Too many requests.';
 | 
			
		||||
 | 
			
		||||
    protected string $title = '429 Too Many Requests';
 | 
			
		||||
    protected string $description = 'The client application has surpassed its rate limit, ' .
 | 
			
		||||
                                    'or number of requests they can send in a given period of time.';
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										28
									
								
								qwen/php/vendor/slim/slim/Slim/Exception/HttpUnauthorizedException.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								qwen/php/vendor/slim/slim/Slim/Exception/HttpUnauthorizedException.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Exception;
 | 
			
		||||
 | 
			
		||||
/** @api */
 | 
			
		||||
class HttpUnauthorizedException extends HttpSpecializedException
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @var int
 | 
			
		||||
     */
 | 
			
		||||
    protected $code = 401;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var string
 | 
			
		||||
     */
 | 
			
		||||
    protected $message = 'Unauthorized.';
 | 
			
		||||
 | 
			
		||||
    protected string $title = '401 Unauthorized';
 | 
			
		||||
    protected string $description = 'The request requires valid user authentication.';
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										217
									
								
								qwen/php/vendor/slim/slim/Slim/Factory/AppFactory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										217
									
								
								qwen/php/vendor/slim/slim/Slim/Factory/AppFactory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,217 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Factory;
 | 
			
		||||
 | 
			
		||||
use Psr\Container\ContainerInterface;
 | 
			
		||||
use Psr\Http\Message\ResponseFactoryInterface;
 | 
			
		||||
use Psr\Http\Message\StreamFactoryInterface;
 | 
			
		||||
use RuntimeException;
 | 
			
		||||
use Slim\App;
 | 
			
		||||
use Slim\Factory\Psr17\Psr17Factory;
 | 
			
		||||
use Slim\Factory\Psr17\Psr17FactoryProvider;
 | 
			
		||||
use Slim\Factory\Psr17\SlimHttpPsr17Factory;
 | 
			
		||||
use Slim\Interfaces\CallableResolverInterface;
 | 
			
		||||
use Slim\Interfaces\MiddlewareDispatcherInterface;
 | 
			
		||||
use Slim\Interfaces\Psr17FactoryProviderInterface;
 | 
			
		||||
use Slim\Interfaces\RouteCollectorInterface;
 | 
			
		||||
use Slim\Interfaces\RouteResolverInterface;
 | 
			
		||||
 | 
			
		||||
/** @api */
 | 
			
		||||
class AppFactory
 | 
			
		||||
{
 | 
			
		||||
    protected static ?Psr17FactoryProviderInterface $psr17FactoryProvider = null;
 | 
			
		||||
 | 
			
		||||
    protected static ?ResponseFactoryInterface $responseFactory = null;
 | 
			
		||||
 | 
			
		||||
    protected static ?StreamFactoryInterface $streamFactory = null;
 | 
			
		||||
 | 
			
		||||
    protected static ?ContainerInterface $container = null;
 | 
			
		||||
 | 
			
		||||
    protected static ?CallableResolverInterface $callableResolver = null;
 | 
			
		||||
 | 
			
		||||
    protected static ?RouteCollectorInterface $routeCollector = null;
 | 
			
		||||
 | 
			
		||||
    protected static ?RouteResolverInterface $routeResolver = null;
 | 
			
		||||
 | 
			
		||||
    protected static ?MiddlewareDispatcherInterface $middlewareDispatcher = null;
 | 
			
		||||
 | 
			
		||||
    protected static bool $slimHttpDecoratorsAutomaticDetectionEnabled = true;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @template TContainerInterface of (ContainerInterface|null)
 | 
			
		||||
     * @param TContainerInterface $container
 | 
			
		||||
     * @return (TContainerInterface is ContainerInterface ? App<TContainerInterface> : App<ContainerInterface|null>)
 | 
			
		||||
     */
 | 
			
		||||
    public static function create(
 | 
			
		||||
        ?ResponseFactoryInterface $responseFactory = null,
 | 
			
		||||
        ?ContainerInterface $container = null,
 | 
			
		||||
        ?CallableResolverInterface $callableResolver = null,
 | 
			
		||||
        ?RouteCollectorInterface $routeCollector = null,
 | 
			
		||||
        ?RouteResolverInterface $routeResolver = null,
 | 
			
		||||
        ?MiddlewareDispatcherInterface $middlewareDispatcher = null
 | 
			
		||||
    ): App {
 | 
			
		||||
        static::$responseFactory = $responseFactory ?? static::$responseFactory;
 | 
			
		||||
        return new App(
 | 
			
		||||
            self::determineResponseFactory(),
 | 
			
		||||
            $container ?? static::$container,
 | 
			
		||||
            $callableResolver ?? static::$callableResolver,
 | 
			
		||||
            $routeCollector ?? static::$routeCollector,
 | 
			
		||||
            $routeResolver ?? static::$routeResolver,
 | 
			
		||||
            $middlewareDispatcher ?? static::$middlewareDispatcher
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @template TContainerInterface of (ContainerInterface)
 | 
			
		||||
     * @param TContainerInterface $container
 | 
			
		||||
     * @return App<TContainerInterface>
 | 
			
		||||
     */
 | 
			
		||||
    public static function createFromContainer(ContainerInterface $container): App
 | 
			
		||||
    {
 | 
			
		||||
        $responseFactory = $container->has(ResponseFactoryInterface::class)
 | 
			
		||||
        && (
 | 
			
		||||
            $responseFactoryFromContainer = $container->get(ResponseFactoryInterface::class)
 | 
			
		||||
        ) instanceof ResponseFactoryInterface
 | 
			
		||||
            ? $responseFactoryFromContainer
 | 
			
		||||
            : self::determineResponseFactory();
 | 
			
		||||
 | 
			
		||||
        $callableResolver = $container->has(CallableResolverInterface::class)
 | 
			
		||||
        && (
 | 
			
		||||
            $callableResolverFromContainer = $container->get(CallableResolverInterface::class)
 | 
			
		||||
        ) instanceof CallableResolverInterface
 | 
			
		||||
            ? $callableResolverFromContainer
 | 
			
		||||
            : null;
 | 
			
		||||
 | 
			
		||||
        $routeCollector = $container->has(RouteCollectorInterface::class)
 | 
			
		||||
        && (
 | 
			
		||||
            $routeCollectorFromContainer = $container->get(RouteCollectorInterface::class)
 | 
			
		||||
        ) instanceof RouteCollectorInterface
 | 
			
		||||
            ? $routeCollectorFromContainer
 | 
			
		||||
            : null;
 | 
			
		||||
 | 
			
		||||
        $routeResolver = $container->has(RouteResolverInterface::class)
 | 
			
		||||
        && (
 | 
			
		||||
            $routeResolverFromContainer = $container->get(RouteResolverInterface::class)
 | 
			
		||||
        ) instanceof RouteResolverInterface
 | 
			
		||||
            ? $routeResolverFromContainer
 | 
			
		||||
            : null;
 | 
			
		||||
 | 
			
		||||
        $middlewareDispatcher = $container->has(MiddlewareDispatcherInterface::class)
 | 
			
		||||
        && (
 | 
			
		||||
            $middlewareDispatcherFromContainer = $container->get(MiddlewareDispatcherInterface::class)
 | 
			
		||||
        ) instanceof MiddlewareDispatcherInterface
 | 
			
		||||
            ? $middlewareDispatcherFromContainer
 | 
			
		||||
            : null;
 | 
			
		||||
 | 
			
		||||
        return new App(
 | 
			
		||||
            $responseFactory,
 | 
			
		||||
            $container,
 | 
			
		||||
            $callableResolver,
 | 
			
		||||
            $routeCollector,
 | 
			
		||||
            $routeResolver,
 | 
			
		||||
            $middlewareDispatcher
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @throws RuntimeException
 | 
			
		||||
     */
 | 
			
		||||
    public static function determineResponseFactory(): ResponseFactoryInterface
 | 
			
		||||
    {
 | 
			
		||||
        if (static::$responseFactory) {
 | 
			
		||||
            if (static::$streamFactory) {
 | 
			
		||||
                return static::attemptResponseFactoryDecoration(static::$responseFactory, static::$streamFactory);
 | 
			
		||||
            }
 | 
			
		||||
            return static::$responseFactory;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $psr17FactoryProvider = static::$psr17FactoryProvider ?? new Psr17FactoryProvider();
 | 
			
		||||
 | 
			
		||||
        /** @var Psr17Factory $psr17factory */
 | 
			
		||||
        foreach ($psr17FactoryProvider->getFactories() as $psr17factory) {
 | 
			
		||||
            if ($psr17factory::isResponseFactoryAvailable()) {
 | 
			
		||||
                $responseFactory = $psr17factory::getResponseFactory();
 | 
			
		||||
 | 
			
		||||
                if (static::$streamFactory || $psr17factory::isStreamFactoryAvailable()) {
 | 
			
		||||
                    $streamFactory = static::$streamFactory ?? $psr17factory::getStreamFactory();
 | 
			
		||||
                    return static::attemptResponseFactoryDecoration($responseFactory, $streamFactory);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                return $responseFactory;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        throw new RuntimeException(
 | 
			
		||||
            "Could not detect any PSR-17 ResponseFactory implementations. " .
 | 
			
		||||
            "Please install a supported implementation in order to use `AppFactory::create()`. " .
 | 
			
		||||
            "See https://github.com/slimphp/Slim/blob/4.x/README.md for a list of supported implementations."
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected static function attemptResponseFactoryDecoration(
 | 
			
		||||
        ResponseFactoryInterface $responseFactory,
 | 
			
		||||
        StreamFactoryInterface $streamFactory
 | 
			
		||||
    ): ResponseFactoryInterface {
 | 
			
		||||
        if (
 | 
			
		||||
            static::$slimHttpDecoratorsAutomaticDetectionEnabled
 | 
			
		||||
            && SlimHttpPsr17Factory::isResponseFactoryAvailable()
 | 
			
		||||
        ) {
 | 
			
		||||
            return SlimHttpPsr17Factory::createDecoratedResponseFactory($responseFactory, $streamFactory);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $responseFactory;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static function setPsr17FactoryProvider(Psr17FactoryProviderInterface $psr17FactoryProvider): void
 | 
			
		||||
    {
 | 
			
		||||
        static::$psr17FactoryProvider = $psr17FactoryProvider;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static function setResponseFactory(ResponseFactoryInterface $responseFactory): void
 | 
			
		||||
    {
 | 
			
		||||
        static::$responseFactory = $responseFactory;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static function setStreamFactory(StreamFactoryInterface $streamFactory): void
 | 
			
		||||
    {
 | 
			
		||||
        static::$streamFactory = $streamFactory;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static function setContainer(ContainerInterface $container): void
 | 
			
		||||
    {
 | 
			
		||||
        static::$container = $container;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static function setCallableResolver(CallableResolverInterface $callableResolver): void
 | 
			
		||||
    {
 | 
			
		||||
        static::$callableResolver = $callableResolver;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static function setRouteCollector(RouteCollectorInterface $routeCollector): void
 | 
			
		||||
    {
 | 
			
		||||
        static::$routeCollector = $routeCollector;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static function setRouteResolver(RouteResolverInterface $routeResolver): void
 | 
			
		||||
    {
 | 
			
		||||
        static::$routeResolver = $routeResolver;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static function setMiddlewareDispatcher(MiddlewareDispatcherInterface $middlewareDispatcher): void
 | 
			
		||||
    {
 | 
			
		||||
        static::$middlewareDispatcher = $middlewareDispatcher;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static function setSlimHttpDecoratorsAutomaticDetection(bool $enabled): void
 | 
			
		||||
    {
 | 
			
		||||
        static::$slimHttpDecoratorsAutomaticDetectionEnabled = $enabled;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										19
									
								
								qwen/php/vendor/slim/slim/Slim/Factory/Psr17/GuzzlePsr17Factory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								qwen/php/vendor/slim/slim/Slim/Factory/Psr17/GuzzlePsr17Factory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Factory\Psr17;
 | 
			
		||||
 | 
			
		||||
class GuzzlePsr17Factory extends Psr17Factory
 | 
			
		||||
{
 | 
			
		||||
    protected static string $responseFactoryClass = 'GuzzleHttp\Psr7\HttpFactory';
 | 
			
		||||
    protected static string $streamFactoryClass = 'GuzzleHttp\Psr7\HttpFactory';
 | 
			
		||||
    protected static string $serverRequestCreatorClass = 'GuzzleHttp\Psr7\ServerRequest';
 | 
			
		||||
    protected static string $serverRequestCreatorMethod = 'fromGlobals';
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										19
									
								
								qwen/php/vendor/slim/slim/Slim/Factory/Psr17/HttpSoftPsr17Factory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								qwen/php/vendor/slim/slim/Slim/Factory/Psr17/HttpSoftPsr17Factory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Factory\Psr17;
 | 
			
		||||
 | 
			
		||||
class HttpSoftPsr17Factory extends Psr17Factory
 | 
			
		||||
{
 | 
			
		||||
    protected static string $responseFactoryClass = 'HttpSoft\Message\ResponseFactory';
 | 
			
		||||
    protected static string $streamFactoryClass = 'HttpSoft\Message\StreamFactory';
 | 
			
		||||
    protected static string $serverRequestCreatorClass = 'HttpSoft\ServerRequest\ServerRequestCreator';
 | 
			
		||||
    protected static string $serverRequestCreatorMethod = 'createFromGlobals';
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										19
									
								
								qwen/php/vendor/slim/slim/Slim/Factory/Psr17/LaminasDiactorosPsr17Factory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								qwen/php/vendor/slim/slim/Slim/Factory/Psr17/LaminasDiactorosPsr17Factory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Factory\Psr17;
 | 
			
		||||
 | 
			
		||||
class LaminasDiactorosPsr17Factory extends Psr17Factory
 | 
			
		||||
{
 | 
			
		||||
    protected static string $responseFactoryClass = 'Laminas\Diactoros\ResponseFactory';
 | 
			
		||||
    protected static string $streamFactoryClass = 'Laminas\Diactoros\StreamFactory';
 | 
			
		||||
    protected static string $serverRequestCreatorClass = 'Laminas\Diactoros\ServerRequestFactory';
 | 
			
		||||
    protected static string $serverRequestCreatorMethod = 'fromGlobals';
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										36
									
								
								qwen/php/vendor/slim/slim/Slim/Factory/Psr17/NyholmPsr17Factory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								qwen/php/vendor/slim/slim/Slim/Factory/Psr17/NyholmPsr17Factory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Factory\Psr17;
 | 
			
		||||
 | 
			
		||||
use Slim\Interfaces\ServerRequestCreatorInterface;
 | 
			
		||||
 | 
			
		||||
class NyholmPsr17Factory extends Psr17Factory
 | 
			
		||||
{
 | 
			
		||||
    protected static string $responseFactoryClass = 'Nyholm\Psr7\Factory\Psr17Factory';
 | 
			
		||||
    protected static string $streamFactoryClass = 'Nyholm\Psr7\Factory\Psr17Factory';
 | 
			
		||||
    protected static string $serverRequestCreatorClass = 'Nyholm\Psr7Server\ServerRequestCreator';
 | 
			
		||||
    protected static string $serverRequestCreatorMethod = 'fromGlobals';
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public static function getServerRequestCreator(): ServerRequestCreatorInterface
 | 
			
		||||
    {
 | 
			
		||||
        /*
 | 
			
		||||
         * Nyholm Psr17Factory implements all factories in one unified
 | 
			
		||||
         * factory which implements all of the PSR-17 factory interfaces
 | 
			
		||||
         */
 | 
			
		||||
        $psr17Factory = new static::$responseFactoryClass();
 | 
			
		||||
 | 
			
		||||
        $serverRequestCreator = new static::$serverRequestCreatorClass(
 | 
			
		||||
            $psr17Factory,
 | 
			
		||||
            $psr17Factory,
 | 
			
		||||
            $psr17Factory,
 | 
			
		||||
            $psr17Factory
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        return new ServerRequestCreator($serverRequestCreator, static::$serverRequestCreatorMethod);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										101
									
								
								qwen/php/vendor/slim/slim/Slim/Factory/Psr17/Psr17Factory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										101
									
								
								qwen/php/vendor/slim/slim/Slim/Factory/Psr17/Psr17Factory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,101 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Factory\Psr17;
 | 
			
		||||
 | 
			
		||||
use Psr\Http\Message\ResponseFactoryInterface;
 | 
			
		||||
use Psr\Http\Message\StreamFactoryInterface;
 | 
			
		||||
use RuntimeException;
 | 
			
		||||
use Slim\Interfaces\Psr17FactoryInterface;
 | 
			
		||||
use Slim\Interfaces\ServerRequestCreatorInterface;
 | 
			
		||||
 | 
			
		||||
use function class_exists;
 | 
			
		||||
use function get_called_class;
 | 
			
		||||
 | 
			
		||||
abstract class Psr17Factory implements Psr17FactoryInterface
 | 
			
		||||
{
 | 
			
		||||
    protected static string $responseFactoryClass;
 | 
			
		||||
 | 
			
		||||
    protected static string $streamFactoryClass;
 | 
			
		||||
 | 
			
		||||
    protected static string $serverRequestCreatorClass;
 | 
			
		||||
 | 
			
		||||
    protected static string $serverRequestCreatorMethod;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public static function getResponseFactory(): ResponseFactoryInterface
 | 
			
		||||
    {
 | 
			
		||||
        if (
 | 
			
		||||
            !static::isResponseFactoryAvailable()
 | 
			
		||||
            || !(($responseFactory = new static::$responseFactoryClass()) instanceof ResponseFactoryInterface)
 | 
			
		||||
        ) {
 | 
			
		||||
            throw new RuntimeException(get_called_class() . ' could not instantiate a response factory.');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $responseFactory;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public static function getStreamFactory(): StreamFactoryInterface
 | 
			
		||||
    {
 | 
			
		||||
        if (
 | 
			
		||||
            !static::isStreamFactoryAvailable()
 | 
			
		||||
            || !(($streamFactory = new static::$streamFactoryClass()) instanceof StreamFactoryInterface)
 | 
			
		||||
        ) {
 | 
			
		||||
            throw new RuntimeException(get_called_class() . ' could not instantiate a stream factory.');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $streamFactory;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public static function getServerRequestCreator(): ServerRequestCreatorInterface
 | 
			
		||||
    {
 | 
			
		||||
        if (!static::isServerRequestCreatorAvailable()) {
 | 
			
		||||
            throw new RuntimeException(get_called_class() . ' could not instantiate a server request creator.');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return new ServerRequestCreator(static::$serverRequestCreatorClass, static::$serverRequestCreatorMethod);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public static function isResponseFactoryAvailable(): bool
 | 
			
		||||
    {
 | 
			
		||||
        return static::$responseFactoryClass && class_exists(static::$responseFactoryClass);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public static function isStreamFactoryAvailable(): bool
 | 
			
		||||
    {
 | 
			
		||||
        return static::$streamFactoryClass && class_exists(static::$streamFactoryClass);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public static function isServerRequestCreatorAvailable(): bool
 | 
			
		||||
    {
 | 
			
		||||
        return (
 | 
			
		||||
            static::$serverRequestCreatorClass
 | 
			
		||||
            && static::$serverRequestCreatorMethod
 | 
			
		||||
            && class_exists(static::$serverRequestCreatorClass)
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										53
									
								
								qwen/php/vendor/slim/slim/Slim/Factory/Psr17/Psr17FactoryProvider.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								qwen/php/vendor/slim/slim/Slim/Factory/Psr17/Psr17FactoryProvider.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,53 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Factory\Psr17;
 | 
			
		||||
 | 
			
		||||
use Slim\Interfaces\Psr17FactoryProviderInterface;
 | 
			
		||||
 | 
			
		||||
use function array_unshift;
 | 
			
		||||
 | 
			
		||||
class Psr17FactoryProvider implements Psr17FactoryProviderInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @var string[]
 | 
			
		||||
     */
 | 
			
		||||
    protected static array $factories = [
 | 
			
		||||
        SlimPsr17Factory::class,
 | 
			
		||||
        HttpSoftPsr17Factory::class,
 | 
			
		||||
        NyholmPsr17Factory::class,
 | 
			
		||||
        LaminasDiactorosPsr17Factory::class,
 | 
			
		||||
        GuzzlePsr17Factory::class,
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public static function getFactories(): array
 | 
			
		||||
    {
 | 
			
		||||
        return static::$factories;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public static function setFactories(array $factories): void
 | 
			
		||||
    {
 | 
			
		||||
        static::$factories = $factories;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public static function addFactory(string $factory): void
 | 
			
		||||
    {
 | 
			
		||||
        array_unshift(static::$factories, $factory);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										46
									
								
								qwen/php/vendor/slim/slim/Slim/Factory/Psr17/ServerRequestCreator.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								qwen/php/vendor/slim/slim/Slim/Factory/Psr17/ServerRequestCreator.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,46 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Factory\Psr17;
 | 
			
		||||
 | 
			
		||||
use Closure;
 | 
			
		||||
use Psr\Http\Message\ServerRequestInterface;
 | 
			
		||||
use Slim\Interfaces\ServerRequestCreatorInterface;
 | 
			
		||||
 | 
			
		||||
class ServerRequestCreator implements ServerRequestCreatorInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @var object|string
 | 
			
		||||
     */
 | 
			
		||||
    protected $serverRequestCreator;
 | 
			
		||||
 | 
			
		||||
    protected string $serverRequestCreatorMethod;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param object|string $serverRequestCreator
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct($serverRequestCreator, string $serverRequestCreatorMethod)
 | 
			
		||||
    {
 | 
			
		||||
        $this->serverRequestCreator = $serverRequestCreator;
 | 
			
		||||
        $this->serverRequestCreatorMethod = $serverRequestCreatorMethod;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function createServerRequestFromGlobals(): ServerRequestInterface
 | 
			
		||||
    {
 | 
			
		||||
        /** @var callable $callable */
 | 
			
		||||
        $callable = [$this->serverRequestCreator, $this->serverRequestCreatorMethod];
 | 
			
		||||
 | 
			
		||||
        /** @var ServerRequestInterface */
 | 
			
		||||
        return (Closure::fromCallable($callable))();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								qwen/php/vendor/slim/slim/Slim/Factory/Psr17/SlimHttpPsr17Factory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								qwen/php/vendor/slim/slim/Slim/Factory/Psr17/SlimHttpPsr17Factory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Factory\Psr17;
 | 
			
		||||
 | 
			
		||||
use Psr\Http\Message\ResponseFactoryInterface;
 | 
			
		||||
use Psr\Http\Message\StreamFactoryInterface;
 | 
			
		||||
use RuntimeException;
 | 
			
		||||
 | 
			
		||||
class SlimHttpPsr17Factory extends Psr17Factory
 | 
			
		||||
{
 | 
			
		||||
    protected static string $responseFactoryClass = 'Slim\Http\Factory\DecoratedResponseFactory';
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @throws RuntimeException when the factory could not be instantiated
 | 
			
		||||
     */
 | 
			
		||||
    public static function createDecoratedResponseFactory(
 | 
			
		||||
        ResponseFactoryInterface $responseFactory,
 | 
			
		||||
        StreamFactoryInterface $streamFactory
 | 
			
		||||
    ): ResponseFactoryInterface {
 | 
			
		||||
        if (
 | 
			
		||||
            !((
 | 
			
		||||
                $decoratedResponseFactory = new static::$responseFactoryClass($responseFactory, $streamFactory)
 | 
			
		||||
                ) instanceof ResponseFactoryInterface
 | 
			
		||||
            )
 | 
			
		||||
        ) {
 | 
			
		||||
            throw new RuntimeException(get_called_class() . ' could not instantiate a decorated response factory.');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $decoratedResponseFactory;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										56
									
								
								qwen/php/vendor/slim/slim/Slim/Factory/Psr17/SlimHttpServerRequestCreator.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								qwen/php/vendor/slim/slim/Slim/Factory/Psr17/SlimHttpServerRequestCreator.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,56 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Factory\Psr17;
 | 
			
		||||
 | 
			
		||||
use Psr\Http\Message\ServerRequestInterface;
 | 
			
		||||
use RuntimeException;
 | 
			
		||||
use Slim\Interfaces\ServerRequestCreatorInterface;
 | 
			
		||||
 | 
			
		||||
use function class_exists;
 | 
			
		||||
 | 
			
		||||
class SlimHttpServerRequestCreator implements ServerRequestCreatorInterface
 | 
			
		||||
{
 | 
			
		||||
    protected ServerRequestCreatorInterface $serverRequestCreator;
 | 
			
		||||
 | 
			
		||||
    protected static string $serverRequestDecoratorClass = 'Slim\Http\ServerRequest';
 | 
			
		||||
 | 
			
		||||
    public function __construct(ServerRequestCreatorInterface $serverRequestCreator)
 | 
			
		||||
    {
 | 
			
		||||
        $this->serverRequestCreator = $serverRequestCreator;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function createServerRequestFromGlobals(): ServerRequestInterface
 | 
			
		||||
    {
 | 
			
		||||
        if (!static::isServerRequestDecoratorAvailable()) {
 | 
			
		||||
            throw new RuntimeException('The Slim-Http ServerRequest decorator is not available.');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $request = $this->serverRequestCreator->createServerRequestFromGlobals();
 | 
			
		||||
 | 
			
		||||
        if (
 | 
			
		||||
            !((
 | 
			
		||||
                $decoratedServerRequest = new static::$serverRequestDecoratorClass($request)
 | 
			
		||||
                ) instanceof ServerRequestInterface)
 | 
			
		||||
        ) {
 | 
			
		||||
            throw new RuntimeException(get_called_class() . ' could not instantiate a decorated server request.');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $decoratedServerRequest;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static function isServerRequestDecoratorAvailable(): bool
 | 
			
		||||
    {
 | 
			
		||||
        return class_exists(static::$serverRequestDecoratorClass);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										19
									
								
								qwen/php/vendor/slim/slim/Slim/Factory/Psr17/SlimPsr17Factory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								qwen/php/vendor/slim/slim/Slim/Factory/Psr17/SlimPsr17Factory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Factory\Psr17;
 | 
			
		||||
 | 
			
		||||
class SlimPsr17Factory extends Psr17Factory
 | 
			
		||||
{
 | 
			
		||||
    protected static string $responseFactoryClass = 'Slim\Psr7\Factory\ResponseFactory';
 | 
			
		||||
    protected static string $streamFactoryClass = 'Slim\Psr7\Factory\StreamFactory';
 | 
			
		||||
    protected static string $serverRequestCreatorClass = 'Slim\Psr7\Factory\ServerRequestFactory';
 | 
			
		||||
    protected static string $serverRequestCreatorMethod = 'createFromGlobals';
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										88
									
								
								qwen/php/vendor/slim/slim/Slim/Factory/ServerRequestCreatorFactory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										88
									
								
								qwen/php/vendor/slim/slim/Slim/Factory/ServerRequestCreatorFactory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,88 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Factory;
 | 
			
		||||
 | 
			
		||||
use RuntimeException;
 | 
			
		||||
use Slim\Factory\Psr17\Psr17Factory;
 | 
			
		||||
use Slim\Factory\Psr17\Psr17FactoryProvider;
 | 
			
		||||
use Slim\Factory\Psr17\SlimHttpServerRequestCreator;
 | 
			
		||||
use Slim\Interfaces\Psr17FactoryProviderInterface;
 | 
			
		||||
use Slim\Interfaces\ServerRequestCreatorInterface;
 | 
			
		||||
 | 
			
		||||
/** @api */
 | 
			
		||||
class ServerRequestCreatorFactory
 | 
			
		||||
{
 | 
			
		||||
    protected static ?Psr17FactoryProviderInterface $psr17FactoryProvider = null;
 | 
			
		||||
 | 
			
		||||
    protected static ?ServerRequestCreatorInterface $serverRequestCreator = null;
 | 
			
		||||
 | 
			
		||||
    protected static bool $slimHttpDecoratorsAutomaticDetectionEnabled = true;
 | 
			
		||||
 | 
			
		||||
    public static function create(): ServerRequestCreatorInterface
 | 
			
		||||
    {
 | 
			
		||||
        return static::determineServerRequestCreator();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @throws RuntimeException
 | 
			
		||||
     */
 | 
			
		||||
    public static function determineServerRequestCreator(): ServerRequestCreatorInterface
 | 
			
		||||
    {
 | 
			
		||||
        if (static::$serverRequestCreator) {
 | 
			
		||||
            return static::attemptServerRequestCreatorDecoration(static::$serverRequestCreator);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $psr17FactoryProvider = static::$psr17FactoryProvider ?? new Psr17FactoryProvider();
 | 
			
		||||
 | 
			
		||||
        /** @var Psr17Factory $psr17Factory */
 | 
			
		||||
        foreach ($psr17FactoryProvider->getFactories() as $psr17Factory) {
 | 
			
		||||
            if ($psr17Factory::isServerRequestCreatorAvailable()) {
 | 
			
		||||
                $serverRequestCreator = $psr17Factory::getServerRequestCreator();
 | 
			
		||||
                return static::attemptServerRequestCreatorDecoration($serverRequestCreator);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        throw new RuntimeException(
 | 
			
		||||
            "Could not detect any ServerRequest creator implementations. " .
 | 
			
		||||
            "Please install a supported implementation in order to use `App::run()` " .
 | 
			
		||||
            "without having to pass in a `ServerRequest` object. " .
 | 
			
		||||
            "See https://github.com/slimphp/Slim/blob/4.x/README.md for a list of supported implementations."
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected static function attemptServerRequestCreatorDecoration(
 | 
			
		||||
        ServerRequestCreatorInterface $serverRequestCreator
 | 
			
		||||
    ): ServerRequestCreatorInterface {
 | 
			
		||||
        if (
 | 
			
		||||
            static::$slimHttpDecoratorsAutomaticDetectionEnabled
 | 
			
		||||
            && SlimHttpServerRequestCreator::isServerRequestDecoratorAvailable()
 | 
			
		||||
        ) {
 | 
			
		||||
            return new SlimHttpServerRequestCreator($serverRequestCreator);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $serverRequestCreator;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static function setPsr17FactoryProvider(Psr17FactoryProviderInterface $psr17FactoryProvider): void
 | 
			
		||||
    {
 | 
			
		||||
        static::$psr17FactoryProvider = $psr17FactoryProvider;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static function setServerRequestCreator(ServerRequestCreatorInterface $serverRequestCreator): void
 | 
			
		||||
    {
 | 
			
		||||
        self::$serverRequestCreator = $serverRequestCreator;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static function setSlimHttpDecoratorsAutomaticDetection(bool $enabled): void
 | 
			
		||||
    {
 | 
			
		||||
        static::$slimHttpDecoratorsAutomaticDetectionEnabled = $enabled;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										314
									
								
								qwen/php/vendor/slim/slim/Slim/Handlers/ErrorHandler.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										314
									
								
								qwen/php/vendor/slim/slim/Slim/Handlers/ErrorHandler.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,314 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Handlers;
 | 
			
		||||
 | 
			
		||||
use Psr\Http\Message\ResponseFactoryInterface;
 | 
			
		||||
use Psr\Http\Message\ResponseInterface;
 | 
			
		||||
use Psr\Http\Message\ServerRequestInterface;
 | 
			
		||||
use Psr\Log\LoggerInterface;
 | 
			
		||||
use RuntimeException;
 | 
			
		||||
use Slim\Error\Renderers\HtmlErrorRenderer;
 | 
			
		||||
use Slim\Error\Renderers\JsonErrorRenderer;
 | 
			
		||||
use Slim\Error\Renderers\PlainTextErrorRenderer;
 | 
			
		||||
use Slim\Error\Renderers\XmlErrorRenderer;
 | 
			
		||||
use Slim\Exception\HttpException;
 | 
			
		||||
use Slim\Exception\HttpMethodNotAllowedException;
 | 
			
		||||
use Slim\Interfaces\CallableResolverInterface;
 | 
			
		||||
use Slim\Interfaces\ErrorHandlerInterface;
 | 
			
		||||
use Slim\Interfaces\ErrorRendererInterface;
 | 
			
		||||
use Slim\Logger;
 | 
			
		||||
use Throwable;
 | 
			
		||||
 | 
			
		||||
use function array_intersect;
 | 
			
		||||
use function array_key_exists;
 | 
			
		||||
use function array_keys;
 | 
			
		||||
use function call_user_func;
 | 
			
		||||
use function count;
 | 
			
		||||
use function current;
 | 
			
		||||
use function explode;
 | 
			
		||||
use function implode;
 | 
			
		||||
use function next;
 | 
			
		||||
use function preg_match;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Default Slim application error handler
 | 
			
		||||
 *
 | 
			
		||||
 * It outputs the error message and diagnostic information in one of the following formats:
 | 
			
		||||
 * JSON, XML, Plain Text or HTML based on the Accept header.
 | 
			
		||||
 * @api
 | 
			
		||||
 */
 | 
			
		||||
class ErrorHandler implements ErrorHandlerInterface
 | 
			
		||||
{
 | 
			
		||||
    protected string $defaultErrorRendererContentType = 'text/html';
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var ErrorRendererInterface|string|callable
 | 
			
		||||
     */
 | 
			
		||||
    protected $defaultErrorRenderer = HtmlErrorRenderer::class;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var ErrorRendererInterface|string|callable
 | 
			
		||||
     */
 | 
			
		||||
    protected $logErrorRenderer = PlainTextErrorRenderer::class;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var array<string|callable>
 | 
			
		||||
     */
 | 
			
		||||
    protected array $errorRenderers = [
 | 
			
		||||
        'application/json' => JsonErrorRenderer::class,
 | 
			
		||||
        'application/xml' => XmlErrorRenderer::class,
 | 
			
		||||
        'text/xml' => XmlErrorRenderer::class,
 | 
			
		||||
        'text/html' => HtmlErrorRenderer::class,
 | 
			
		||||
        'text/plain' => PlainTextErrorRenderer::class,
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
    protected bool $displayErrorDetails = false;
 | 
			
		||||
 | 
			
		||||
    protected bool $logErrors;
 | 
			
		||||
 | 
			
		||||
    protected bool $logErrorDetails = false;
 | 
			
		||||
 | 
			
		||||
    protected ?string $contentType = null;
 | 
			
		||||
 | 
			
		||||
    protected ?string $method = null;
 | 
			
		||||
 | 
			
		||||
    protected ServerRequestInterface $request;
 | 
			
		||||
 | 
			
		||||
    protected Throwable $exception;
 | 
			
		||||
 | 
			
		||||
    protected int $statusCode;
 | 
			
		||||
 | 
			
		||||
    protected CallableResolverInterface $callableResolver;
 | 
			
		||||
 | 
			
		||||
    protected ResponseFactoryInterface $responseFactory;
 | 
			
		||||
 | 
			
		||||
    protected LoggerInterface $logger;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        CallableResolverInterface $callableResolver,
 | 
			
		||||
        ResponseFactoryInterface $responseFactory,
 | 
			
		||||
        ?LoggerInterface $logger = null
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->callableResolver = $callableResolver;
 | 
			
		||||
        $this->responseFactory = $responseFactory;
 | 
			
		||||
        $this->logger = $logger ?: $this->getDefaultLogger();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Invoke error handler
 | 
			
		||||
     *
 | 
			
		||||
     * @param ServerRequestInterface $request             The most recent Request object
 | 
			
		||||
     * @param Throwable              $exception           The caught Exception object
 | 
			
		||||
     * @param bool                   $displayErrorDetails Whether or not to display the error details
 | 
			
		||||
     * @param bool                   $logErrors           Whether or not to log errors
 | 
			
		||||
     * @param bool                   $logErrorDetails     Whether or not to log error details
 | 
			
		||||
     */
 | 
			
		||||
    public function __invoke(
 | 
			
		||||
        ServerRequestInterface $request,
 | 
			
		||||
        Throwable $exception,
 | 
			
		||||
        bool $displayErrorDetails,
 | 
			
		||||
        bool $logErrors,
 | 
			
		||||
        bool $logErrorDetails
 | 
			
		||||
    ): ResponseInterface {
 | 
			
		||||
        $this->displayErrorDetails = $displayErrorDetails;
 | 
			
		||||
        $this->logErrors = $logErrors;
 | 
			
		||||
        $this->logErrorDetails = $logErrorDetails;
 | 
			
		||||
        $this->request = $request;
 | 
			
		||||
        $this->exception = $exception;
 | 
			
		||||
        $this->method = $request->getMethod();
 | 
			
		||||
        $this->statusCode = $this->determineStatusCode();
 | 
			
		||||
        if ($this->contentType === null) {
 | 
			
		||||
            $this->contentType = $this->determineContentType($request);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if ($logErrors) {
 | 
			
		||||
            $this->writeToErrorLog();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $this->respond();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Force the content type for all error handler responses.
 | 
			
		||||
     *
 | 
			
		||||
     * @param string|null $contentType The content type
 | 
			
		||||
     */
 | 
			
		||||
    public function forceContentType(?string $contentType): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->contentType = $contentType;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected function determineStatusCode(): int
 | 
			
		||||
    {
 | 
			
		||||
        if ($this->method === 'OPTIONS') {
 | 
			
		||||
            return 200;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if ($this->exception instanceof HttpException) {
 | 
			
		||||
            return $this->exception->getCode();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return 500;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Determine which content type we know about is wanted using Accept header
 | 
			
		||||
     *
 | 
			
		||||
     * Note: This method is a bare-bones implementation designed specifically for
 | 
			
		||||
     * Slim's error handling requirements. Consider a fully-feature solution such
 | 
			
		||||
     * as willdurand/negotiation for any other situation.
 | 
			
		||||
     */
 | 
			
		||||
    protected function determineContentType(ServerRequestInterface $request): ?string
 | 
			
		||||
    {
 | 
			
		||||
        $acceptHeader = $request->getHeaderLine('Accept');
 | 
			
		||||
        $selectedContentTypes = array_intersect(
 | 
			
		||||
            explode(',', $acceptHeader),
 | 
			
		||||
            array_keys($this->errorRenderers)
 | 
			
		||||
        );
 | 
			
		||||
        $count = count($selectedContentTypes);
 | 
			
		||||
 | 
			
		||||
        if ($count) {
 | 
			
		||||
            $current = current($selectedContentTypes);
 | 
			
		||||
 | 
			
		||||
            /**
 | 
			
		||||
             * Ensure other supported content types take precedence over text/plain
 | 
			
		||||
             * when multiple content types are provided via Accept header.
 | 
			
		||||
             */
 | 
			
		||||
            if ($current === 'text/plain' && $count > 1) {
 | 
			
		||||
                $next = next($selectedContentTypes);
 | 
			
		||||
                if (is_string($next)) {
 | 
			
		||||
                    return $next;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // @phpstan-ignore-next-line
 | 
			
		||||
            if (is_string($current)) {
 | 
			
		||||
                return $current;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (preg_match('/\+(json|xml)/', $acceptHeader, $matches)) {
 | 
			
		||||
            $mediaType = 'application/' . $matches[1];
 | 
			
		||||
            if (array_key_exists($mediaType, $this->errorRenderers)) {
 | 
			
		||||
                return $mediaType;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Determine which renderer to use based on content type
 | 
			
		||||
     *
 | 
			
		||||
     * @throws RuntimeException
 | 
			
		||||
     */
 | 
			
		||||
    protected function determineRenderer(): callable
 | 
			
		||||
    {
 | 
			
		||||
        if ($this->contentType !== null && array_key_exists($this->contentType, $this->errorRenderers)) {
 | 
			
		||||
            $renderer = $this->errorRenderers[$this->contentType];
 | 
			
		||||
        } else {
 | 
			
		||||
            $renderer = $this->defaultErrorRenderer;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $this->callableResolver->resolve($renderer);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Register an error renderer for a specific content-type
 | 
			
		||||
     *
 | 
			
		||||
     * @param string  $contentType  The content-type this renderer should be registered to
 | 
			
		||||
     * @param ErrorRendererInterface|string|callable $errorRenderer The error renderer
 | 
			
		||||
     */
 | 
			
		||||
    public function registerErrorRenderer(string $contentType, $errorRenderer): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->errorRenderers[$contentType] = $errorRenderer;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Set the default error renderer
 | 
			
		||||
     *
 | 
			
		||||
     * @param string                                 $contentType   The content type of the default error renderer
 | 
			
		||||
     * @param ErrorRendererInterface|string|callable $errorRenderer The default error renderer
 | 
			
		||||
     */
 | 
			
		||||
    public function setDefaultErrorRenderer(string $contentType, $errorRenderer): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->defaultErrorRendererContentType = $contentType;
 | 
			
		||||
        $this->defaultErrorRenderer = $errorRenderer;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Set the renderer for the error logger
 | 
			
		||||
     *
 | 
			
		||||
     * @param ErrorRendererInterface|string|callable $logErrorRenderer
 | 
			
		||||
     */
 | 
			
		||||
    public function setLogErrorRenderer($logErrorRenderer): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->logErrorRenderer = $logErrorRenderer;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Write to the error log if $logErrors has been set to true
 | 
			
		||||
     */
 | 
			
		||||
    protected function writeToErrorLog(): void
 | 
			
		||||
    {
 | 
			
		||||
        $renderer = $this->callableResolver->resolve($this->logErrorRenderer);
 | 
			
		||||
 | 
			
		||||
        /** @var string $error */
 | 
			
		||||
        $error = $renderer($this->exception, $this->logErrorDetails);
 | 
			
		||||
 | 
			
		||||
        if ($this->logErrorRenderer === PlainTextErrorRenderer::class && !$this->displayErrorDetails) {
 | 
			
		||||
            $error .= "\nTips: To display error details in HTTP response ";
 | 
			
		||||
            $error .= 'set "displayErrorDetails" to true in the ErrorHandler constructor.';
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $this->logError($error);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Wraps the error_log function so that this can be easily tested
 | 
			
		||||
     */
 | 
			
		||||
    protected function logError(string $error): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->logger->error($error);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns a default logger implementation.
 | 
			
		||||
     */
 | 
			
		||||
    protected function getDefaultLogger(): LoggerInterface
 | 
			
		||||
    {
 | 
			
		||||
        return new Logger();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected function respond(): ResponseInterface
 | 
			
		||||
    {
 | 
			
		||||
        $response = $this->responseFactory->createResponse($this->statusCode);
 | 
			
		||||
        if ($this->contentType !== null && array_key_exists($this->contentType, $this->errorRenderers)) {
 | 
			
		||||
            $response = $response->withHeader('Content-type', $this->contentType);
 | 
			
		||||
        } else {
 | 
			
		||||
            $response = $response->withHeader('Content-type', $this->defaultErrorRendererContentType);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if ($this->exception instanceof HttpMethodNotAllowedException) {
 | 
			
		||||
            $allowedMethods = implode(', ', $this->exception->getAllowedMethods());
 | 
			
		||||
            $response = $response->withHeader('Allow', $allowedMethods);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $renderer = $this->determineRenderer();
 | 
			
		||||
        $body = call_user_func($renderer, $this->exception, $this->displayErrorDetails);
 | 
			
		||||
        if ($body !== false) {
 | 
			
		||||
            /** @var string $body */
 | 
			
		||||
            $response->getBody()->write($body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $response;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										49
									
								
								qwen/php/vendor/slim/slim/Slim/Handlers/Strategies/RequestHandler.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								qwen/php/vendor/slim/slim/Slim/Handlers/Strategies/RequestHandler.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,49 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Handlers\Strategies;
 | 
			
		||||
 | 
			
		||||
use Psr\Http\Message\ResponseInterface;
 | 
			
		||||
use Psr\Http\Message\ServerRequestInterface;
 | 
			
		||||
use Slim\Interfaces\RequestHandlerInvocationStrategyInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * PSR-15 RequestHandler invocation strategy
 | 
			
		||||
 */
 | 
			
		||||
class RequestHandler implements RequestHandlerInvocationStrategyInterface
 | 
			
		||||
{
 | 
			
		||||
    protected bool $appendRouteArgumentsToRequestAttributes;
 | 
			
		||||
 | 
			
		||||
    public function __construct(bool $appendRouteArgumentsToRequestAttributes = false)
 | 
			
		||||
    {
 | 
			
		||||
        $this->appendRouteArgumentsToRequestAttributes = $appendRouteArgumentsToRequestAttributes;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Invoke a route callable that implements RequestHandlerInterface
 | 
			
		||||
     *
 | 
			
		||||
     * @param array<string, string>  $routeArguments
 | 
			
		||||
     */
 | 
			
		||||
    public function __invoke(
 | 
			
		||||
        callable $callable,
 | 
			
		||||
        ServerRequestInterface $request,
 | 
			
		||||
        ResponseInterface $response,
 | 
			
		||||
        array $routeArguments
 | 
			
		||||
    ): ResponseInterface {
 | 
			
		||||
        if ($this->appendRouteArgumentsToRequestAttributes) {
 | 
			
		||||
            foreach ($routeArguments as $k => $v) {
 | 
			
		||||
                $request = $request->withAttribute($k, $v);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /** @var ResponseInterface */
 | 
			
		||||
        return $callable($request);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										41
									
								
								qwen/php/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								qwen/php/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,41 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Handlers\Strategies;
 | 
			
		||||
 | 
			
		||||
use Psr\Http\Message\ResponseInterface;
 | 
			
		||||
use Psr\Http\Message\ServerRequestInterface;
 | 
			
		||||
use Slim\Interfaces\InvocationStrategyInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Default route callback strategy with route parameters as an array of arguments.
 | 
			
		||||
 */
 | 
			
		||||
class RequestResponse implements InvocationStrategyInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * Invoke a route callable with request, response, and all route parameters
 | 
			
		||||
     * as an array of arguments.
 | 
			
		||||
     *
 | 
			
		||||
     * @param array<string, string>  $routeArguments
 | 
			
		||||
     */
 | 
			
		||||
    public function __invoke(
 | 
			
		||||
        callable $callable,
 | 
			
		||||
        ServerRequestInterface $request,
 | 
			
		||||
        ResponseInterface $response,
 | 
			
		||||
        array $routeArguments
 | 
			
		||||
    ): ResponseInterface {
 | 
			
		||||
        foreach ($routeArguments as $k => $v) {
 | 
			
		||||
            $request = $request->withAttribute($k, $v);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /** @var ResponseInterface */
 | 
			
		||||
        return $callable($request, $response, $routeArguments);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										40
									
								
								qwen/php/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponseArgs.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								qwen/php/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponseArgs.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,40 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Handlers\Strategies;
 | 
			
		||||
 | 
			
		||||
use Psr\Http\Message\ResponseInterface;
 | 
			
		||||
use Psr\Http\Message\ServerRequestInterface;
 | 
			
		||||
use Slim\Interfaces\InvocationStrategyInterface;
 | 
			
		||||
 | 
			
		||||
use function array_values;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Route callback strategy with route parameters as individual arguments.
 | 
			
		||||
 * @api
 | 
			
		||||
 */
 | 
			
		||||
class RequestResponseArgs implements InvocationStrategyInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * Invoke a route callable with request, response and all route parameters
 | 
			
		||||
     * as individual arguments.
 | 
			
		||||
     *
 | 
			
		||||
     * @param array<string, string>  $routeArguments
 | 
			
		||||
     */
 | 
			
		||||
    public function __invoke(
 | 
			
		||||
        callable $callable,
 | 
			
		||||
        ServerRequestInterface $request,
 | 
			
		||||
        ResponseInterface $response,
 | 
			
		||||
        array $routeArguments
 | 
			
		||||
    ): ResponseInterface {
 | 
			
		||||
        /** @var ResponseInterface */
 | 
			
		||||
        return $callable($request, $response, ...array_values($routeArguments));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								qwen/php/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponseNamedArgs.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								qwen/php/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponseNamedArgs.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Handlers\Strategies;
 | 
			
		||||
 | 
			
		||||
use Psr\Http\Message\ResponseInterface;
 | 
			
		||||
use Psr\Http\Message\ServerRequestInterface;
 | 
			
		||||
use Slim\Interfaces\InvocationStrategyInterface;
 | 
			
		||||
use RuntimeException;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Route callback strategy with route parameters as individual arguments.
 | 
			
		||||
 * @api
 | 
			
		||||
 */
 | 
			
		||||
class RequestResponseNamedArgs implements InvocationStrategyInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * Invoke a route callable with request, response and all route parameters
 | 
			
		||||
     * as individual arguments.
 | 
			
		||||
     *
 | 
			
		||||
     * @param array<string, string>  $routeArguments
 | 
			
		||||
     */
 | 
			
		||||
    public function __invoke(
 | 
			
		||||
        callable $callable,
 | 
			
		||||
        ServerRequestInterface $request,
 | 
			
		||||
        ResponseInterface $response,
 | 
			
		||||
        array $routeArguments
 | 
			
		||||
    ): ResponseInterface {
 | 
			
		||||
        /** @var ResponseInterface */
 | 
			
		||||
        return $callable($request, $response, ...$routeArguments);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										28
									
								
								qwen/php/vendor/slim/slim/Slim/Interfaces/AdvancedCallableResolverInterface.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								qwen/php/vendor/slim/slim/Slim/Interfaces/AdvancedCallableResolverInterface.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Interfaces;
 | 
			
		||||
 | 
			
		||||
interface AdvancedCallableResolverInterface extends CallableResolverInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * Resolve $toResolve into a callable
 | 
			
		||||
     *
 | 
			
		||||
     * @param callable|array{class-string, string}|string $toResolve
 | 
			
		||||
     */
 | 
			
		||||
    public function resolveRoute($toResolve): callable;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Resolve $toResolve into a callable
 | 
			
		||||
     *
 | 
			
		||||
     * @param callable|array{class-string, string}|string $toResolve
 | 
			
		||||
     */
 | 
			
		||||
    public function resolveMiddleware($toResolve): callable;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										21
									
								
								qwen/php/vendor/slim/slim/Slim/Interfaces/CallableResolverInterface.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								qwen/php/vendor/slim/slim/Slim/Interfaces/CallableResolverInterface.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,21 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Interfaces;
 | 
			
		||||
 | 
			
		||||
interface CallableResolverInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * Resolve $toResolve into a callable
 | 
			
		||||
     *
 | 
			
		||||
     * @param callable|array{class-string, string}|string $toResolve
 | 
			
		||||
     */
 | 
			
		||||
    public function resolve($toResolve): callable;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										28
									
								
								qwen/php/vendor/slim/slim/Slim/Interfaces/DispatcherInterface.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								qwen/php/vendor/slim/slim/Slim/Interfaces/DispatcherInterface.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Interfaces;
 | 
			
		||||
 | 
			
		||||
use Slim\Routing\RoutingResults;
 | 
			
		||||
 | 
			
		||||
interface DispatcherInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * Get routing results for a given request method and uri
 | 
			
		||||
     */
 | 
			
		||||
    public function dispatch(string $method, string $uri): RoutingResults;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get allowed methods for a given uri
 | 
			
		||||
     *
 | 
			
		||||
     * @return string[]
 | 
			
		||||
     */
 | 
			
		||||
    public function getAllowedMethods(string $uri): array;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										26
									
								
								qwen/php/vendor/slim/slim/Slim/Interfaces/ErrorHandlerInterface.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								qwen/php/vendor/slim/slim/Slim/Interfaces/ErrorHandlerInterface.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Interfaces;
 | 
			
		||||
 | 
			
		||||
use Psr\Http\Message\ResponseInterface;
 | 
			
		||||
use Psr\Http\Message\ServerRequestInterface;
 | 
			
		||||
use Throwable;
 | 
			
		||||
 | 
			
		||||
interface ErrorHandlerInterface
 | 
			
		||||
{
 | 
			
		||||
    public function __invoke(
 | 
			
		||||
        ServerRequestInterface $request,
 | 
			
		||||
        Throwable $exception,
 | 
			
		||||
        bool $displayErrorDetails,
 | 
			
		||||
        bool $logErrors,
 | 
			
		||||
        bool $logErrorDetails
 | 
			
		||||
    ): ResponseInterface;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										18
									
								
								qwen/php/vendor/slim/slim/Slim/Interfaces/ErrorRendererInterface.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								qwen/php/vendor/slim/slim/Slim/Interfaces/ErrorRendererInterface.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Interfaces;
 | 
			
		||||
 | 
			
		||||
use Throwable;
 | 
			
		||||
 | 
			
		||||
interface ErrorRendererInterface
 | 
			
		||||
{
 | 
			
		||||
    public function __invoke(Throwable $exception, bool $displayErrorDetails): string;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										37
									
								
								qwen/php/vendor/slim/slim/Slim/Interfaces/InvocationStrategyInterface.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								qwen/php/vendor/slim/slim/Slim/Interfaces/InvocationStrategyInterface.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,37 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Interfaces;
 | 
			
		||||
 | 
			
		||||
use Psr\Http\Message\ResponseInterface;
 | 
			
		||||
use Psr\Http\Message\ServerRequestInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Defines a contract for invoking a route callable.
 | 
			
		||||
 */
 | 
			
		||||
interface InvocationStrategyInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * Invoke a route callable.
 | 
			
		||||
     *
 | 
			
		||||
     * @param callable               $callable       The callable to invoke using the strategy.
 | 
			
		||||
     * @param ServerRequestInterface $request        The request object.
 | 
			
		||||
     * @param ResponseInterface      $response       The response object.
 | 
			
		||||
     * @param array<string, string>  $routeArguments The route's placeholder arguments
 | 
			
		||||
     *
 | 
			
		||||
     * @return ResponseInterface The response from the callable.
 | 
			
		||||
     */
 | 
			
		||||
    public function __invoke(
 | 
			
		||||
        callable $callable,
 | 
			
		||||
        ServerRequestInterface $request,
 | 
			
		||||
        ResponseInterface $response,
 | 
			
		||||
        array $routeArguments
 | 
			
		||||
    ): ResponseInterface;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										43
									
								
								qwen/php/vendor/slim/slim/Slim/Interfaces/MiddlewareDispatcherInterface.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								qwen/php/vendor/slim/slim/Slim/Interfaces/MiddlewareDispatcherInterface.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,43 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Interfaces;
 | 
			
		||||
 | 
			
		||||
use Psr\Http\Server\MiddlewareInterface;
 | 
			
		||||
use Psr\Http\Server\RequestHandlerInterface;
 | 
			
		||||
 | 
			
		||||
/** @api */
 | 
			
		||||
interface MiddlewareDispatcherInterface extends RequestHandlerInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * Add a new middleware to the stack
 | 
			
		||||
     *
 | 
			
		||||
     * Middleware are organized as a stack. That means middleware
 | 
			
		||||
     * that have been added before will be executed after the newly
 | 
			
		||||
     * added one (last in, first out).
 | 
			
		||||
     *
 | 
			
		||||
     * @param MiddlewareInterface|string|callable $middleware
 | 
			
		||||
     */
 | 
			
		||||
    public function add($middleware): self;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Add a new middleware to the stack
 | 
			
		||||
     *
 | 
			
		||||
     * Middleware are organized as a stack. That means middleware
 | 
			
		||||
     * that have been added before will be executed after the newly
 | 
			
		||||
     * added one (last in, first out).
 | 
			
		||||
     */
 | 
			
		||||
    public function addMiddleware(MiddlewareInterface $middleware): self;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Seed the middleware stack with the inner request handler
 | 
			
		||||
     */
 | 
			
		||||
    public function seedMiddlewareStack(RequestHandlerInterface $kernel): void;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										48
									
								
								qwen/php/vendor/slim/slim/Slim/Interfaces/Psr17FactoryInterface.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								qwen/php/vendor/slim/slim/Slim/Interfaces/Psr17FactoryInterface.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,48 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Interfaces;
 | 
			
		||||
 | 
			
		||||
use Psr\Http\Message\ResponseFactoryInterface;
 | 
			
		||||
use Psr\Http\Message\StreamFactoryInterface;
 | 
			
		||||
use RuntimeException;
 | 
			
		||||
 | 
			
		||||
interface Psr17FactoryInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @throws RuntimeException when the factory could not be instantiated
 | 
			
		||||
     */
 | 
			
		||||
    public static function getResponseFactory(): ResponseFactoryInterface;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @throws RuntimeException when the factory could not be instantiated
 | 
			
		||||
     */
 | 
			
		||||
    public static function getStreamFactory(): StreamFactoryInterface;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @throws RuntimeException when the factory could not be instantiated
 | 
			
		||||
     */
 | 
			
		||||
    public static function getServerRequestCreator(): ServerRequestCreatorInterface;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Is the PSR-17 ResponseFactory available
 | 
			
		||||
     */
 | 
			
		||||
    public static function isResponseFactoryAvailable(): bool;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Is the PSR-17 StreamFactory available
 | 
			
		||||
     */
 | 
			
		||||
    public static function isStreamFactoryAvailable(): bool;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Is the ServerRequest creator available
 | 
			
		||||
     */
 | 
			
		||||
    public static function isServerRequestCreatorAvailable(): bool;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										27
									
								
								qwen/php/vendor/slim/slim/Slim/Interfaces/Psr17FactoryProviderInterface.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								qwen/php/vendor/slim/slim/Slim/Interfaces/Psr17FactoryProviderInterface.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Interfaces;
 | 
			
		||||
 | 
			
		||||
/** @api */
 | 
			
		||||
interface Psr17FactoryProviderInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @return string[]
 | 
			
		||||
     */
 | 
			
		||||
    public static function getFactories(): array;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param string[] $factories
 | 
			
		||||
     */
 | 
			
		||||
    public static function setFactories(array $factories): void;
 | 
			
		||||
 | 
			
		||||
    public static function addFactory(string $factory): void;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										15
									
								
								qwen/php/vendor/slim/slim/Slim/Interfaces/RequestHandlerInvocationStrategyInterface.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								qwen/php/vendor/slim/slim/Slim/Interfaces/RequestHandlerInvocationStrategyInterface.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Interfaces;
 | 
			
		||||
 | 
			
		||||
interface RequestHandlerInvocationStrategyInterface extends InvocationStrategyInterface
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										103
									
								
								qwen/php/vendor/slim/slim/Slim/Interfaces/RouteCollectorInterface.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										103
									
								
								qwen/php/vendor/slim/slim/Slim/Interfaces/RouteCollectorInterface.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,103 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Slim Framework (https://slimframework.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Slim\Interfaces;
 | 
			
		||||
 | 
			
		||||
use InvalidArgumentException;
 | 
			
		||||
use RuntimeException;
 | 
			
		||||
 | 
			
		||||
/** @api */
 | 
			
		||||
interface RouteCollectorInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the route parser
 | 
			
		||||
     */
 | 
			
		||||
    public function getRouteParser(): RouteParserInterface;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get default route invocation strategy
 | 
			
		||||
     */
 | 
			
		||||
    public function getDefaultInvocationStrategy(): InvocationStrategyInterface;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Set default route invocation strategy
 | 
			
		||||
     */
 | 
			
		||||
    public function setDefaultInvocationStrategy(InvocationStrategyInterface $strategy): RouteCollectorInterface;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get path to FastRoute cache file
 | 
			
		||||
     */
 | 
			
		||||
    public function getCacheFile(): ?string;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Set path to FastRoute cache file
 | 
			
		||||
     *
 | 
			
		||||
     * @throws InvalidArgumentException
 | 
			
		||||
     * @throws RuntimeException
 | 
			
		||||
     */
 | 
			
		||||
    public function setCacheFile(string $cacheFile): RouteCollectorInterface;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the base path used in pathFor()
 | 
			
		||||
     */
 | 
			
		||||
    public function getBasePath(): string;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Set the base path used in pathFor()
 | 
			
		||||
     */
 | 
			
		||||
    public function setBasePath(string $basePath): RouteCollectorInterface;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get route objects
 | 
			
		||||
     *
 | 
			
		||||
     * @return RouteInterface[]
 | 
			
		||||
     */
 | 
			
		||||
    public function getRoutes(): array;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get named route object
 | 
			
		||||
     *
 | 
			
		||||
     * @param string $name Route name
 | 
			
		||||
     *
 | 
			
		||||
     * @throws RuntimeException   If named route does not exist
 | 
			
		||||
     */
 | 
			
		||||
    public function getNamedRoute(string $name): RouteInterface;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Remove named route
 | 
			
		||||
     *
 | 
			
		||||
     * @param string $name Route name
 | 
			
		||||
     *
 | 
			
		||||
     * @throws RuntimeException   If named route does not exist
 | 
			
		||||
     */
 | 
			
		||||
    public function removeNamedRoute(string $name): RouteCollectorInterface;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Lookup a route via the route's unique identifier
 | 
			
		||||
     *
 | 
			
		||||
     * @throws RuntimeException   If route of identifier does not exist
 | 
			
		||||
     */
 | 
			
		||||
    public function lookupRoute(string $identifier): RouteInterface;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Add route group
 | 
			
		||||
     * @param string|callable $callable
 | 
			
		||||
     */
 | 
			
		||||
    public function group(string $pattern, $callable): RouteGroupInterface;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Add route
 | 
			
		||||
     *
 | 
			
		||||
     * @param string[] $methods Array of HTTP methods
 | 
			
		||||
     * @param string $pattern The route pattern
 | 
			
		||||
     * @param callable|array{class-string, string}|string $handler The route callable
 | 
			
		||||
     */
 | 
			
		||||
    public function map(array $methods, string $pattern, $handler): RouteInterface;
 | 
			
		||||
}
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user