update2
This commit is contained in:
parent
98419bd18d
commit
8a69e45efa
4919 changed files with 28311 additions and 224136 deletions
0
pfosten/vendor/symfony/http-foundation/.gitignore
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/.gitignore
vendored
Executable file → Normal file
6
pfosten/vendor/symfony/http-foundation/AcceptHeader.php
vendored
Executable file → Normal file
6
pfosten/vendor/symfony/http-foundation/AcceptHeader.php
vendored
Executable file → Normal file
|
|
@ -32,8 +32,6 @@ class AcceptHeader
|
|||
private $sorted = true;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param AcceptHeaderItem[] $items
|
||||
*/
|
||||
public function __construct(array $items)
|
||||
|
|
@ -99,8 +97,6 @@ class AcceptHeader
|
|||
/**
|
||||
* Adds an item.
|
||||
*
|
||||
* @param AcceptHeaderItem $item
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function add(AcceptHeaderItem $item)
|
||||
|
|
@ -155,7 +151,7 @@ class AcceptHeader
|
|||
private function sort()
|
||||
{
|
||||
if (!$this->sorted) {
|
||||
uasort($this->items, function ($a, $b) {
|
||||
uasort($this->items, function (AcceptHeaderItem $a, AcceptHeaderItem $b) {
|
||||
$qA = $a->getQuality();
|
||||
$qB = $b->getQuality();
|
||||
|
||||
|
|
|
|||
25
pfosten/vendor/symfony/http-foundation/AcceptHeaderItem.php
vendored
Executable file → Normal file
25
pfosten/vendor/symfony/http-foundation/AcceptHeaderItem.php
vendored
Executable file → Normal file
|
|
@ -18,29 +18,12 @@ namespace Symfony\Component\HttpFoundation;
|
|||
*/
|
||||
class AcceptHeaderItem
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $quality = 1.0;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $index = 0;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $attributes = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $value
|
||||
* @param array $attributes
|
||||
*/
|
||||
|
|
@ -67,18 +50,18 @@ class AcceptHeaderItem
|
|||
|
||||
$lastNullAttribute = null;
|
||||
foreach ($bits as $bit) {
|
||||
if (($start = substr($bit, 0, 1)) === ($end = substr($bit, -1)) && ($start === '"' || $start === '\'')) {
|
||||
if (($start = substr($bit, 0, 1)) === ($end = substr($bit, -1)) && ('"' === $start || '\'' === $start)) {
|
||||
$attributes[$lastNullAttribute] = substr($bit, 1, -1);
|
||||
} elseif ('=' === $end) {
|
||||
$lastNullAttribute = $bit = substr($bit, 0, -1);
|
||||
$attributes[$bit] = null;
|
||||
} else {
|
||||
$parts = explode('=', $bit);
|
||||
$attributes[$parts[0]] = isset($parts[1]) && strlen($parts[1]) > 0 ? $parts[1] : '';
|
||||
$attributes[$parts[0]] = isset($parts[1]) && \strlen($parts[1]) > 0 ? $parts[1] : '';
|
||||
}
|
||||
}
|
||||
|
||||
return new self(($start = substr($value, 0, 1)) === ($end = substr($value, -1)) && ($start === '"' || $start === '\'') ? substr($value, 1, -1) : $value, $attributes);
|
||||
return new self(($start = substr($value, 0, 1)) === ($end = substr($value, -1)) && ('"' === $start || '\'' === $start) ? substr($value, 1, -1) : $value, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -89,7 +72,7 @@ class AcceptHeaderItem
|
|||
public function __toString()
|
||||
{
|
||||
$string = $this->value.($this->quality < 1 ? ';q='.$this->quality : '');
|
||||
if (count($this->attributes) > 0) {
|
||||
if (\count($this->attributes) > 0) {
|
||||
$string .= ';'.implode(';', array_map(function ($name, $value) {
|
||||
return sprintf(preg_match('/[,;=]/', $value) ? '%s="%s"' : '%s=%s', $name, $value);
|
||||
}, array_keys($this->attributes), $this->attributes));
|
||||
|
|
|
|||
2
pfosten/vendor/symfony/http-foundation/ApacheRequest.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/http-foundation/ApacheRequest.php
vendored
Executable file → Normal file
|
|
@ -35,7 +35,7 @@ class ApacheRequest extends Request
|
|||
|
||||
if (false === strpos($this->server->get('REQUEST_URI'), $baseUrl)) {
|
||||
// assume mod_rewrite
|
||||
return rtrim(dirname($baseUrl), '/\\');
|
||||
return rtrim(\dirname($baseUrl), '/\\');
|
||||
}
|
||||
|
||||
return $baseUrl;
|
||||
|
|
|
|||
24
pfosten/vendor/symfony/http-foundation/BinaryFileResponse.php
vendored
Executable file → Normal file
24
pfosten/vendor/symfony/http-foundation/BinaryFileResponse.php
vendored
Executable file → Normal file
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
namespace Symfony\Component\HttpFoundation;
|
||||
|
||||
use Symfony\Component\HttpFoundation\File\File;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileException;
|
||||
use Symfony\Component\HttpFoundation\File\File;
|
||||
|
||||
/**
|
||||
* BinaryFileResponse represents an HTTP response delivering a file.
|
||||
|
|
@ -36,8 +36,6 @@ class BinaryFileResponse extends Response
|
|||
protected $deleteFileAfterSend = false;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param \SplFileInfo|string $file The file to stream
|
||||
* @param int $status The response status code
|
||||
* @param array $headers An array of response headers
|
||||
|
|
@ -141,7 +139,7 @@ class BinaryFileResponse extends Response
|
|||
*/
|
||||
public function setAutoEtag()
|
||||
{
|
||||
$this->setEtag(sha1_file($this->file->getPathname()));
|
||||
$this->setEtag(base64_encode(hash_file('sha256', $this->file->getPathname(), true)));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -150,24 +148,24 @@ class BinaryFileResponse extends Response
|
|||
* Sets the Content-Disposition header with the given filename.
|
||||
*
|
||||
* @param string $disposition ResponseHeaderBag::DISPOSITION_INLINE or ResponseHeaderBag::DISPOSITION_ATTACHMENT
|
||||
* @param string $filename Optionally use this filename instead of the real name of the file
|
||||
* @param string $filename Optionally use this UTF-8 encoded filename instead of the real name of the file
|
||||
* @param string $filenameFallback A fallback filename, containing only ASCII characters. Defaults to an automatically encoded filename
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setContentDisposition($disposition, $filename = '', $filenameFallback = '')
|
||||
{
|
||||
if ($filename === '') {
|
||||
if ('' === $filename) {
|
||||
$filename = $this->file->getFilename();
|
||||
}
|
||||
|
||||
if ('' === $filenameFallback && (!preg_match('/^[\x20-\x7e]*$/', $filename) || false !== strpos($filename, '%'))) {
|
||||
$encoding = mb_detect_encoding($filename, null, true);
|
||||
$encoding = mb_detect_encoding($filename, null, true) ?: '8bit';
|
||||
|
||||
for ($i = 0, $filenameLength = mb_strlen($filename, $encoding); $i < $filenameLength; ++$i) {
|
||||
$char = mb_substr($filename, $i, 1, $encoding);
|
||||
|
||||
if ('%' === $char || ord($char) < 32 || ord($char) > 126) {
|
||||
if ('%' === $char || \ord($char) < 32 || \ord($char) > 126) {
|
||||
$filenameFallback .= '_';
|
||||
} else {
|
||||
$filenameFallback .= $char;
|
||||
|
|
@ -217,18 +215,18 @@ class BinaryFileResponse extends Response
|
|||
if (false === $path) {
|
||||
$path = $this->file->getPathname();
|
||||
}
|
||||
if (strtolower($type) === 'x-accel-redirect') {
|
||||
if ('x-accel-redirect' === strtolower($type)) {
|
||||
// Do X-Accel-Mapping substitutions.
|
||||
// @link http://wiki.nginx.org/X-accel#X-Accel-Redirect
|
||||
foreach (explode(',', $request->headers->get('X-Accel-Mapping', '')) as $mapping) {
|
||||
$mapping = explode('=', $mapping, 2);
|
||||
|
||||
if (2 === count($mapping)) {
|
||||
if (2 === \count($mapping)) {
|
||||
$pathPrefix = trim($mapping[0]);
|
||||
$location = trim($mapping[1]);
|
||||
|
||||
if (substr($path, 0, strlen($pathPrefix)) === $pathPrefix) {
|
||||
$path = $location.substr($path, strlen($pathPrefix));
|
||||
if (substr($path, 0, \strlen($pathPrefix)) === $pathPrefix) {
|
||||
$path = $location.substr($path, \strlen($pathPrefix));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -256,7 +254,7 @@ class BinaryFileResponse extends Response
|
|||
if ($start < 0 || $end > $fileSize - 1) {
|
||||
$this->setStatusCode(416);
|
||||
$this->headers->set('Content-Range', sprintf('bytes */%s', $fileSize));
|
||||
} elseif ($start !== 0 || $end !== $fileSize - 1) {
|
||||
} elseif (0 !== $start || $end !== $fileSize - 1) {
|
||||
$this->maxlen = $end < $fileSize ? $end - $start + 1 : -1;
|
||||
$this->offset = $start;
|
||||
|
||||
|
|
|
|||
16
pfosten/vendor/symfony/http-foundation/CHANGELOG.md
vendored
Executable file → Normal file
16
pfosten/vendor/symfony/http-foundation/CHANGELOG.md
vendored
Executable file → Normal file
|
|
@ -1,6 +1,22 @@
|
|||
CHANGELOG
|
||||
=========
|
||||
|
||||
3.4.14
|
||||
------
|
||||
|
||||
* [BC BREAK] Support for the IIS-only `X_ORIGINAL_URL` and `X_REWRITE_URL`
|
||||
HTTP headers has been dropped for security reasons.
|
||||
|
||||
3.4.0
|
||||
-----
|
||||
|
||||
* implemented PHP 7.0's `SessionUpdateTimestampHandlerInterface` with a new
|
||||
`AbstractSessionHandler` base class and a new `StrictSessionHandler` wrapper
|
||||
* deprecated the `WriteCheckSessionHandler`, `NativeSessionHandler` and `NativeProxy` classes
|
||||
* deprecated setting session save handlers that do not implement `\SessionHandlerInterface` in `NativeSessionStorage::setSaveHandler()`
|
||||
* deprecated using `MongoDbSessionHandler` with the legacy mongo extension; use it with the mongodb/mongodb package and ext-mongodb instead
|
||||
* deprecated `MemcacheSessionHandler`; use `MemcachedSessionHandler` instead
|
||||
|
||||
3.3.0
|
||||
-----
|
||||
|
||||
|
|
|
|||
22
pfosten/vendor/symfony/http-foundation/Cookie.php
vendored
Executable file → Normal file
22
pfosten/vendor/symfony/http-foundation/Cookie.php
vendored
Executable file → Normal file
|
|
@ -46,7 +46,7 @@ class Cookie
|
|||
'path' => '/',
|
||||
'domain' => null,
|
||||
'secure' => false,
|
||||
'httponly' => true,
|
||||
'httponly' => false,
|
||||
'raw' => !$decode,
|
||||
'samesite' => null,
|
||||
);
|
||||
|
|
@ -81,8 +81,6 @@ class Cookie
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $name The name of the cookie
|
||||
* @param string|null $value The value of the cookie
|
||||
* @param int|string|\DateTimeInterface $expire The time the cookie expires
|
||||
|
|
@ -126,7 +124,11 @@ class Cookie
|
|||
$this->httpOnly = (bool) $httpOnly;
|
||||
$this->raw = (bool) $raw;
|
||||
|
||||
if (!in_array($sameSite, array(self::SAMESITE_LAX, self::SAMESITE_STRICT, null), true)) {
|
||||
if (null !== $sameSite) {
|
||||
$sameSite = strtolower($sameSite);
|
||||
}
|
||||
|
||||
if (!\in_array($sameSite, array(self::SAMESITE_LAX, self::SAMESITE_STRICT, null), true)) {
|
||||
throw new \InvalidArgumentException('The "sameSite" parameter value is not valid.');
|
||||
}
|
||||
|
||||
|
|
@ -143,12 +145,12 @@ class Cookie
|
|||
$str = ($this->isRaw() ? $this->getName() : urlencode($this->getName())).'=';
|
||||
|
||||
if ('' === (string) $this->getValue()) {
|
||||
$str .= 'deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; max-age=-31536001';
|
||||
$str .= 'deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; Max-Age=0';
|
||||
} else {
|
||||
$str .= $this->isRaw() ? $this->getValue() : urlencode($this->getValue());
|
||||
$str .= $this->isRaw() ? $this->getValue() : rawurlencode($this->getValue());
|
||||
|
||||
if (0 !== $this->getExpiresTime()) {
|
||||
$str .= '; expires='.gmdate('D, d-M-Y H:i:s T', $this->getExpiresTime()).'; max-age='.$this->getMaxAge();
|
||||
$str .= '; expires='.gmdate('D, d-M-Y H:i:s T', $this->getExpiresTime()).'; Max-Age='.$this->getMaxAge();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -222,7 +224,9 @@ class Cookie
|
|||
*/
|
||||
public function getMaxAge()
|
||||
{
|
||||
return 0 !== $this->expire ? $this->expire - time() : 0;
|
||||
$maxAge = $this->expire - time();
|
||||
|
||||
return 0 >= $maxAge ? 0 : $maxAge;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -262,7 +266,7 @@ class Cookie
|
|||
*/
|
||||
public function isCleared()
|
||||
{
|
||||
return $this->expire < time();
|
||||
return 0 !== $this->expire && $this->expire < time();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/http-foundation/Exception/ConflictingHeadersException.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/Exception/ConflictingHeadersException.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/Exception/RequestExceptionInterface.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/Exception/RequestExceptionInterface.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/Exception/SuspiciousOperationException.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/Exception/SuspiciousOperationException.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/ExpressionRequestMatcher.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/ExpressionRequestMatcher.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/http-foundation/File/Exception/AccessDeniedException.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/http-foundation/File/Exception/AccessDeniedException.php
vendored
Executable file → Normal file
|
|
@ -19,8 +19,6 @@ namespace Symfony\Component\HttpFoundation\File\Exception;
|
|||
class AccessDeniedException extends FileException
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $path The path to the accessed file
|
||||
*/
|
||||
public function __construct($path)
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/http-foundation/File/Exception/FileException.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/File/Exception/FileException.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/http-foundation/File/Exception/FileNotFoundException.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/http-foundation/File/Exception/FileNotFoundException.php
vendored
Executable file → Normal file
|
|
@ -19,8 +19,6 @@ namespace Symfony\Component\HttpFoundation\File\Exception;
|
|||
class FileNotFoundException extends FileException
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $path The path to the file that was not found
|
||||
*/
|
||||
public function __construct($path)
|
||||
|
|
|
|||
2
pfosten/vendor/symfony/http-foundation/File/Exception/UnexpectedTypeException.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/http-foundation/File/Exception/UnexpectedTypeException.php
vendored
Executable file → Normal file
|
|
@ -15,6 +15,6 @@ class UnexpectedTypeException extends FileException
|
|||
{
|
||||
public function __construct($value, $expectedType)
|
||||
{
|
||||
parent::__construct(sprintf('Expected argument of type %s, %s given', $expectedType, is_object($value) ? get_class($value) : gettype($value)));
|
||||
parent::__construct(sprintf('Expected argument of type %s, %s given', $expectedType, \is_object($value) ? \get_class($value) : \gettype($value)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/http-foundation/File/Exception/UploadException.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/File/Exception/UploadException.php
vendored
Executable file → Normal file
12
pfosten/vendor/symfony/http-foundation/File/File.php
vendored
Executable file → Normal file
12
pfosten/vendor/symfony/http-foundation/File/File.php
vendored
Executable file → Normal file
|
|
@ -13,8 +13,8 @@ namespace Symfony\Component\HttpFoundation\File;
|
|||
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileException;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
||||
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
|
||||
use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser;
|
||||
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
|
||||
|
||||
/**
|
||||
* A file in the file system.
|
||||
|
|
@ -93,9 +93,11 @@ class File extends \SplFileInfo
|
|||
{
|
||||
$target = $this->getTargetFile($directory, $name);
|
||||
|
||||
if (!@rename($this->getPathname(), $target)) {
|
||||
$error = error_get_last();
|
||||
throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $target, strip_tags($error['message'])));
|
||||
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
|
||||
$renamed = rename($this->getPathname(), $target);
|
||||
restore_error_handler();
|
||||
if (!$renamed) {
|
||||
throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $target, strip_tags($error)));
|
||||
}
|
||||
|
||||
@chmod($target, 0666 & ~umask());
|
||||
|
|
@ -113,7 +115,7 @@ class File extends \SplFileInfo
|
|||
throw new FileException(sprintf('Unable to write in the "%s" directory', $directory));
|
||||
}
|
||||
|
||||
$target = rtrim($directory, '/\\').DIRECTORY_SEPARATOR.(null === $name ? $this->getBasename() : $this->getName($name));
|
||||
$target = rtrim($directory, '/\\').\DIRECTORY_SEPARATOR.(null === $name ? $this->getBasename() : $this->getName($name));
|
||||
|
||||
return new self($target, false);
|
||||
}
|
||||
|
|
|
|||
2
pfosten/vendor/symfony/http-foundation/File/MimeType/ExtensionGuesser.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/http-foundation/File/MimeType/ExtensionGuesser.php
vendored
Executable file → Normal file
|
|
@ -65,8 +65,6 @@ class ExtensionGuesser implements ExtensionGuesserInterface
|
|||
* Registers a new extension guesser.
|
||||
*
|
||||
* When guessing, this guesser is preferred over previously registered ones.
|
||||
*
|
||||
* @param ExtensionGuesserInterface $guesser
|
||||
*/
|
||||
public function register(ExtensionGuesserInterface $guesser)
|
||||
{
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/http-foundation/File/MimeType/ExtensionGuesserInterface.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/File/MimeType/ExtensionGuesserInterface.php
vendored
Executable file → Normal file
20
pfosten/vendor/symfony/http-foundation/File/MimeType/FileBinaryMimeTypeGuesser.php
vendored
Executable file → Normal file
20
pfosten/vendor/symfony/http-foundation/File/MimeType/FileBinaryMimeTypeGuesser.php
vendored
Executable file → Normal file
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
namespace Symfony\Component\HttpFoundation\File\MimeType;
|
||||
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
||||
|
||||
/**
|
||||
* Guesses the mime type with the binary "file" (only available on *nix).
|
||||
|
|
@ -24,8 +24,6 @@ class FileBinaryMimeTypeGuesser implements MimeTypeGuesserInterface
|
|||
private $cmd;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* The $cmd pattern must contain a "%s" string that will be replaced
|
||||
* with the file name to guess.
|
||||
*
|
||||
|
|
@ -45,7 +43,21 @@ class FileBinaryMimeTypeGuesser implements MimeTypeGuesserInterface
|
|||
*/
|
||||
public static function isSupported()
|
||||
{
|
||||
return '\\' !== DIRECTORY_SEPARATOR && function_exists('passthru') && function_exists('escapeshellarg');
|
||||
static $supported = null;
|
||||
|
||||
if (null !== $supported) {
|
||||
return $supported;
|
||||
}
|
||||
|
||||
if ('\\' === \DIRECTORY_SEPARATOR || !\function_exists('passthru') || !\function_exists('escapeshellarg')) {
|
||||
return $supported = false;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
passthru('command -v file', $exitStatus);
|
||||
$binPath = trim(ob_get_clean());
|
||||
|
||||
return $supported = 0 === $exitStatus && '' !== $binPath;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
6
pfosten/vendor/symfony/http-foundation/File/MimeType/FileinfoMimeTypeGuesser.php
vendored
Executable file → Normal file
6
pfosten/vendor/symfony/http-foundation/File/MimeType/FileinfoMimeTypeGuesser.php
vendored
Executable file → Normal file
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
namespace Symfony\Component\HttpFoundation\File\MimeType;
|
||||
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
||||
|
||||
/**
|
||||
* Guesses the mime type using the PECL extension FileInfo.
|
||||
|
|
@ -24,8 +24,6 @@ class FileinfoMimeTypeGuesser implements MimeTypeGuesserInterface
|
|||
private $magicFile;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $magicFile A magic file to use with the finfo instance
|
||||
*
|
||||
* @see http://www.php.net/manual/en/function.finfo-open.php
|
||||
|
|
@ -42,7 +40,7 @@ class FileinfoMimeTypeGuesser implements MimeTypeGuesserInterface
|
|||
*/
|
||||
public static function isSupported()
|
||||
{
|
||||
return function_exists('finfo_open');
|
||||
return \function_exists('finfo_open');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
3
pfosten/vendor/symfony/http-foundation/File/MimeType/MimeTypeExtensionGuesser.php
vendored
Executable file → Normal file
3
pfosten/vendor/symfony/http-foundation/File/MimeType/MimeTypeExtensionGuesser.php
vendored
Executable file → Normal file
|
|
@ -23,8 +23,6 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface
|
|||
* This list has been updated from upstream on 2013-04-23.
|
||||
*
|
||||
* @see http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultExtensions = array(
|
||||
'application/andrew-inset' => 'ez',
|
||||
|
|
@ -601,6 +599,7 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface
|
|||
'application/x-xliff+xml' => 'xlf',
|
||||
'application/x-xpinstall' => 'xpi',
|
||||
'application/x-xz' => 'xz',
|
||||
'application/x-zip-compressed' => 'zip',
|
||||
'application/x-zmachine' => 'z1',
|
||||
'application/xaml+xml' => 'xaml',
|
||||
'application/xcap-diff+xml' => 'xdf',
|
||||
|
|
|
|||
25
pfosten/vendor/symfony/http-foundation/File/MimeType/MimeTypeGuesser.php
vendored
Executable file → Normal file
25
pfosten/vendor/symfony/http-foundation/File/MimeType/MimeTypeGuesser.php
vendored
Executable file → Normal file
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
namespace Symfony\Component\HttpFoundation\File\MimeType;
|
||||
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
||||
|
||||
/**
|
||||
* A singleton mime type guesser.
|
||||
|
|
@ -80,21 +80,14 @@ class MimeTypeGuesser implements MimeTypeGuesserInterface
|
|||
*/
|
||||
private function __construct()
|
||||
{
|
||||
if (FileBinaryMimeTypeGuesser::isSupported()) {
|
||||
$this->register(new FileBinaryMimeTypeGuesser());
|
||||
}
|
||||
|
||||
if (FileinfoMimeTypeGuesser::isSupported()) {
|
||||
$this->register(new FileinfoMimeTypeGuesser());
|
||||
}
|
||||
$this->register(new FileBinaryMimeTypeGuesser());
|
||||
$this->register(new FileinfoMimeTypeGuesser());
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new mime type guesser.
|
||||
*
|
||||
* When guessing, this guesser is preferred over previously registered ones.
|
||||
*
|
||||
* @param MimeTypeGuesserInterface $guesser
|
||||
*/
|
||||
public function register(MimeTypeGuesserInterface $guesser)
|
||||
{
|
||||
|
|
@ -127,18 +120,14 @@ class MimeTypeGuesser implements MimeTypeGuesserInterface
|
|||
throw new AccessDeniedException($path);
|
||||
}
|
||||
|
||||
if (!$this->guessers) {
|
||||
$msg = 'Unable to guess the mime type as no guessers are available';
|
||||
if (!FileinfoMimeTypeGuesser::isSupported()) {
|
||||
$msg .= ' (Did you enable the php_fileinfo extension?)';
|
||||
}
|
||||
throw new \LogicException($msg);
|
||||
}
|
||||
|
||||
foreach ($this->guessers as $guesser) {
|
||||
if (null !== $mimeType = $guesser->guess($path)) {
|
||||
return $mimeType;
|
||||
}
|
||||
}
|
||||
|
||||
if (2 === \count($this->guessers) && !FileBinaryMimeTypeGuesser::isSupported() && !FileinfoMimeTypeGuesser::isSupported()) {
|
||||
throw new \LogicException('Unable to guess the mime type as no guessers are available (Did you enable the php_fileinfo extension?)');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
pfosten/vendor/symfony/http-foundation/File/MimeType/MimeTypeGuesserInterface.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/http-foundation/File/MimeType/MimeTypeGuesserInterface.php
vendored
Executable file → Normal file
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
namespace Symfony\Component\HttpFoundation\File\MimeType;
|
||||
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
||||
|
||||
/**
|
||||
* Guesses the mime type of a file.
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/http-foundation/File/Stream.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/File/Stream.php
vendored
Executable file → Normal file
55
pfosten/vendor/symfony/http-foundation/File/UploadedFile.php
vendored
Executable file → Normal file
55
pfosten/vendor/symfony/http-foundation/File/UploadedFile.php
vendored
Executable file → Normal file
|
|
@ -24,41 +24,10 @@ use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser;
|
|||
*/
|
||||
class UploadedFile extends File
|
||||
{
|
||||
/**
|
||||
* Whether the test mode is activated.
|
||||
*
|
||||
* Local files are used in test mode hence the code should not enforce HTTP uploads.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $test = false;
|
||||
|
||||
/**
|
||||
* The original name of the uploaded file.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $originalName;
|
||||
|
||||
/**
|
||||
* The mime type provided by the uploader.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $mimeType;
|
||||
|
||||
/**
|
||||
* The file size provided by the uploader.
|
||||
*
|
||||
* @var int|null
|
||||
*/
|
||||
private $size;
|
||||
|
||||
/**
|
||||
* The UPLOAD_ERR_XXX constant provided by the uploader.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $error;
|
||||
|
||||
/**
|
||||
|
|
@ -76,11 +45,12 @@ class UploadedFile extends File
|
|||
* Calling any other method on an non-valid instance will cause an unpredictable result.
|
||||
*
|
||||
* @param string $path The full temporary path to the file
|
||||
* @param string $originalName The original file name
|
||||
* @param string $originalName The original file name of the uploaded file
|
||||
* @param string|null $mimeType The type of the file as provided by PHP; null defaults to application/octet-stream
|
||||
* @param int|null $size The file size
|
||||
* @param int|null $size The file size provided by the uploader
|
||||
* @param int|null $error The error constant of the upload (one of PHP's UPLOAD_ERR_XXX constants); null defaults to UPLOAD_ERR_OK
|
||||
* @param bool $test Whether the test mode is active
|
||||
* Local files are used in test mode hence the code should not enforce HTTP uploads
|
||||
*
|
||||
* @throws FileException If file_uploads is disabled
|
||||
* @throws FileNotFoundException If the file does not exist
|
||||
|
|
@ -198,7 +168,7 @@ class UploadedFile extends File
|
|||
*/
|
||||
public function isValid()
|
||||
{
|
||||
$isOk = $this->error === UPLOAD_ERR_OK;
|
||||
$isOk = UPLOAD_ERR_OK === $this->error;
|
||||
|
||||
return $this->test ? $isOk : $isOk && is_uploaded_file($this->getPathname());
|
||||
}
|
||||
|
|
@ -222,9 +192,11 @@ class UploadedFile extends File
|
|||
|
||||
$target = $this->getTargetFile($directory, $name);
|
||||
|
||||
if (!@move_uploaded_file($this->getPathname(), $target)) {
|
||||
$error = error_get_last();
|
||||
throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $target, strip_tags($error['message'])));
|
||||
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
|
||||
$moved = move_uploaded_file($this->getPathname(), $target);
|
||||
restore_error_handler();
|
||||
if (!$moved) {
|
||||
throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $target, strip_tags($error)));
|
||||
}
|
||||
|
||||
@chmod($target, 0666 & ~umask());
|
||||
|
|
@ -250,17 +222,20 @@ class UploadedFile extends File
|
|||
|
||||
$max = ltrim($iniMax, '+');
|
||||
if (0 === strpos($max, '0x')) {
|
||||
$max = intval($max, 16);
|
||||
$max = \intval($max, 16);
|
||||
} elseif (0 === strpos($max, '0')) {
|
||||
$max = intval($max, 8);
|
||||
$max = \intval($max, 8);
|
||||
} else {
|
||||
$max = (int) $max;
|
||||
}
|
||||
|
||||
switch (substr($iniMax, -1)) {
|
||||
case 't': $max *= 1024;
|
||||
// no break
|
||||
case 'g': $max *= 1024;
|
||||
// no break
|
||||
case 'm': $max *= 1024;
|
||||
// no break
|
||||
case 'k': $max *= 1024;
|
||||
}
|
||||
|
||||
|
|
@ -285,7 +260,7 @@ class UploadedFile extends File
|
|||
);
|
||||
|
||||
$errorCode = $this->error;
|
||||
$maxFilesize = $errorCode === UPLOAD_ERR_INI_SIZE ? self::getMaxFilesize() / 1024 : 0;
|
||||
$maxFilesize = UPLOAD_ERR_INI_SIZE === $errorCode ? self::getMaxFilesize() / 1024 : 0;
|
||||
$message = isset($errors[$errorCode]) ? $errors[$errorCode] : 'The file "%s" was not uploaded due to an unknown error.';
|
||||
|
||||
return sprintf($message, $this->getClientOriginalName(), $maxFilesize);
|
||||
|
|
|
|||
17
pfosten/vendor/symfony/http-foundation/FileBag.php
vendored
Executable file → Normal file
17
pfosten/vendor/symfony/http-foundation/FileBag.php
vendored
Executable file → Normal file
|
|
@ -24,8 +24,6 @@ class FileBag extends ParameterBag
|
|||
private static $fileKeys = array('error', 'name', 'size', 'tmp_name', 'type');
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $parameters An array of HTTP files
|
||||
*/
|
||||
public function __construct(array $parameters = array())
|
||||
|
|
@ -47,7 +45,7 @@ class FileBag extends ParameterBag
|
|||
*/
|
||||
public function set($key, $value)
|
||||
{
|
||||
if (!is_array($value) && !$value instanceof UploadedFile) {
|
||||
if (!\is_array($value) && !$value instanceof UploadedFile) {
|
||||
throw new \InvalidArgumentException('An uploaded file must be an array or an instance of UploadedFile.');
|
||||
}
|
||||
|
||||
|
|
@ -69,7 +67,7 @@ class FileBag extends ParameterBag
|
|||
*
|
||||
* @param array|UploadedFile $file A (multi-dimensional) array of uploaded file information
|
||||
*
|
||||
* @return UploadedFile|UploadedFile[] A (multi-dimensional) array of UploadedFile instances
|
||||
* @return UploadedFile[]|UploadedFile|null A (multi-dimensional) array of UploadedFile instances
|
||||
*/
|
||||
protected function convertFileInformation($file)
|
||||
{
|
||||
|
|
@ -78,7 +76,7 @@ class FileBag extends ParameterBag
|
|||
}
|
||||
|
||||
$file = $this->fixPhpFilesArray($file);
|
||||
if (is_array($file)) {
|
||||
if (\is_array($file)) {
|
||||
$keys = array_keys($file);
|
||||
sort($keys);
|
||||
|
||||
|
|
@ -90,6 +88,9 @@ class FileBag extends ParameterBag
|
|||
}
|
||||
} else {
|
||||
$file = array_map(array($this, 'convertFileInformation'), $file);
|
||||
if (array_keys($keys) === $keys) {
|
||||
$file = array_filter($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -108,20 +109,18 @@ class FileBag extends ParameterBag
|
|||
* It's safe to pass an already converted array, in which case this method
|
||||
* just returns the original array unmodified.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function fixPhpFilesArray($data)
|
||||
{
|
||||
if (!is_array($data)) {
|
||||
if (!\is_array($data)) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
$keys = array_keys($data);
|
||||
sort($keys);
|
||||
|
||||
if (self::$fileKeys != $keys || !isset($data['name']) || !is_array($data['name'])) {
|
||||
if (self::$fileKeys != $keys || !isset($data['name']) || !\is_array($data['name'])) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
|
|
|||
40
pfosten/vendor/symfony/http-foundation/HeaderBag.php
vendored
Executable file → Normal file
40
pfosten/vendor/symfony/http-foundation/HeaderBag.php
vendored
Executable file → Normal file
|
|
@ -22,8 +22,6 @@ class HeaderBag implements \IteratorAggregate, \Countable
|
|||
protected $cacheControl = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $headers An array of HTTP headers
|
||||
*/
|
||||
public function __construct(array $headers = array())
|
||||
|
|
@ -103,11 +101,11 @@ class HeaderBag implements \IteratorAggregate, \Countable
|
|||
/**
|
||||
* Returns a header value by name.
|
||||
*
|
||||
* @param string $key The header name
|
||||
* @param mixed $default The default value
|
||||
* @param bool $first Whether to return the first value or all header values
|
||||
* @param string $key The header name
|
||||
* @param string|string[]|null $default The default value
|
||||
* @param bool $first Whether to return the first value or all header values
|
||||
*
|
||||
* @return string|array The first header value if $first is true, an array of values otherwise
|
||||
* @return string|string[]|null The first header value or default value if $first is true, an array of values otherwise
|
||||
*/
|
||||
public function get($key, $default = null, $first = true)
|
||||
{
|
||||
|
|
@ -123,7 +121,7 @@ class HeaderBag implements \IteratorAggregate, \Countable
|
|||
}
|
||||
|
||||
if ($first) {
|
||||
return count($headers[$key]) ? $headers[$key][0] : $default;
|
||||
return \count($headers[$key]) ? $headers[$key][0] : $default;
|
||||
}
|
||||
|
||||
return $headers[$key];
|
||||
|
|
@ -132,24 +130,32 @@ class HeaderBag implements \IteratorAggregate, \Countable
|
|||
/**
|
||||
* Sets a header by name.
|
||||
*
|
||||
* @param string $key The key
|
||||
* @param string|array $values The value or an array of values
|
||||
* @param bool $replace Whether to replace the actual value or not (true by default)
|
||||
* @param string $key The key
|
||||
* @param string|string[] $values The value or an array of values
|
||||
* @param bool $replace Whether to replace the actual value or not (true by default)
|
||||
*/
|
||||
public function set($key, $values, $replace = true)
|
||||
{
|
||||
$key = str_replace('_', '-', strtolower($key));
|
||||
|
||||
$values = array_values((array) $values);
|
||||
if (\is_array($values)) {
|
||||
$values = array_values($values);
|
||||
|
||||
if (true === $replace || !isset($this->headers[$key])) {
|
||||
$this->headers[$key] = $values;
|
||||
if (true === $replace || !isset($this->headers[$key])) {
|
||||
$this->headers[$key] = $values;
|
||||
} else {
|
||||
$this->headers[$key] = array_merge($this->headers[$key], $values);
|
||||
}
|
||||
} else {
|
||||
$this->headers[$key] = array_merge($this->headers[$key], $values);
|
||||
if (true === $replace || !isset($this->headers[$key])) {
|
||||
$this->headers[$key] = array($values);
|
||||
} else {
|
||||
$this->headers[$key][] = $values;
|
||||
}
|
||||
}
|
||||
|
||||
if ('cache-control' === $key) {
|
||||
$this->cacheControl = $this->parseCacheControl($values[0]);
|
||||
$this->cacheControl = $this->parseCacheControl(implode(', ', $this->headers[$key]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -175,7 +181,7 @@ class HeaderBag implements \IteratorAggregate, \Countable
|
|||
*/
|
||||
public function contains($key, $value)
|
||||
{
|
||||
return in_array($value, $this->get($key, null, false));
|
||||
return \in_array($value, $this->get($key, null, false));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -283,7 +289,7 @@ class HeaderBag implements \IteratorAggregate, \Countable
|
|||
*/
|
||||
public function count()
|
||||
{
|
||||
return count($this->headers);
|
||||
return \count($this->headers);
|
||||
}
|
||||
|
||||
protected function getCacheControlHeader()
|
||||
|
|
|
|||
42
pfosten/vendor/symfony/http-foundation/IpUtils.php
vendored
Executable file → Normal file
42
pfosten/vendor/symfony/http-foundation/IpUtils.php
vendored
Executable file → Normal file
|
|
@ -18,6 +18,8 @@ namespace Symfony\Component\HttpFoundation;
|
|||
*/
|
||||
class IpUtils
|
||||
{
|
||||
private static $checkedIps = array();
|
||||
|
||||
/**
|
||||
* This class should not be instantiated.
|
||||
*/
|
||||
|
|
@ -35,7 +37,7 @@ class IpUtils
|
|||
*/
|
||||
public static function checkIp($requestIp, $ips)
|
||||
{
|
||||
if (!is_array($ips)) {
|
||||
if (!\is_array($ips)) {
|
||||
$ips = array($ips);
|
||||
}
|
||||
|
||||
|
|
@ -61,26 +63,35 @@ class IpUtils
|
|||
*/
|
||||
public static function checkIp4($requestIp, $ip)
|
||||
{
|
||||
$cacheKey = $requestIp.'-'.$ip;
|
||||
if (isset(self::$checkedIps[$cacheKey])) {
|
||||
return self::$checkedIps[$cacheKey];
|
||||
}
|
||||
|
||||
if (!filter_var($requestIp, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
|
||||
return false;
|
||||
return self::$checkedIps[$cacheKey] = false;
|
||||
}
|
||||
|
||||
if (false !== strpos($ip, '/')) {
|
||||
list($address, $netmask) = explode('/', $ip, 2);
|
||||
|
||||
if ($netmask === '0') {
|
||||
return filter_var($address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
|
||||
if ('0' === $netmask) {
|
||||
return self::$checkedIps[$cacheKey] = filter_var($address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
|
||||
}
|
||||
|
||||
if ($netmask < 0 || $netmask > 32) {
|
||||
return false;
|
||||
return self::$checkedIps[$cacheKey] = false;
|
||||
}
|
||||
} else {
|
||||
$address = $ip;
|
||||
$netmask = 32;
|
||||
}
|
||||
|
||||
return 0 === substr_compare(sprintf('%032b', ip2long($requestIp)), sprintf('%032b', ip2long($address)), 0, $netmask);
|
||||
if (false === ip2long($address)) {
|
||||
return self::$checkedIps[$cacheKey] = false;
|
||||
}
|
||||
|
||||
return self::$checkedIps[$cacheKey] = 0 === substr_compare(sprintf('%032b', ip2long($requestIp)), sprintf('%032b', ip2long($address)), 0, $netmask);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -100,15 +111,24 @@ class IpUtils
|
|||
*/
|
||||
public static function checkIp6($requestIp, $ip)
|
||||
{
|
||||
if (!((extension_loaded('sockets') && defined('AF_INET6')) || @inet_pton('::1'))) {
|
||||
$cacheKey = $requestIp.'-'.$ip;
|
||||
if (isset(self::$checkedIps[$cacheKey])) {
|
||||
return self::$checkedIps[$cacheKey];
|
||||
}
|
||||
|
||||
if (!((\extension_loaded('sockets') && \defined('AF_INET6')) || @inet_pton('::1'))) {
|
||||
throw new \RuntimeException('Unable to check Ipv6. Check that PHP was not compiled with option "disable-ipv6".');
|
||||
}
|
||||
|
||||
if (false !== strpos($ip, '/')) {
|
||||
list($address, $netmask) = explode('/', $ip, 2);
|
||||
|
||||
if ('0' === $netmask) {
|
||||
return (bool) unpack('n*', @inet_pton($address));
|
||||
}
|
||||
|
||||
if ($netmask < 1 || $netmask > 128) {
|
||||
return false;
|
||||
return self::$checkedIps[$cacheKey] = false;
|
||||
}
|
||||
} else {
|
||||
$address = $ip;
|
||||
|
|
@ -119,7 +139,7 @@ class IpUtils
|
|||
$bytesTest = unpack('n*', @inet_pton($requestIp));
|
||||
|
||||
if (!$bytesAddr || !$bytesTest) {
|
||||
return false;
|
||||
return self::$checkedIps[$cacheKey] = false;
|
||||
}
|
||||
|
||||
for ($i = 1, $ceil = ceil($netmask / 16); $i <= $ceil; ++$i) {
|
||||
|
|
@ -127,10 +147,10 @@ class IpUtils
|
|||
$left = ($left <= 16) ? $left : 16;
|
||||
$mask = ~(0xffff >> $left) & 0xffff;
|
||||
if (($bytesAddr[$i] & $mask) != ($bytesTest[$i] & $mask)) {
|
||||
return false;
|
||||
return self::$checkedIps[$cacheKey] = false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return self::$checkedIps[$cacheKey] = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
28
pfosten/vendor/symfony/http-foundation/JsonResponse.php
vendored
Executable file → Normal file
28
pfosten/vendor/symfony/http-foundation/JsonResponse.php
vendored
Executable file → Normal file
|
|
@ -101,7 +101,7 @@ class JsonResponse extends Response
|
|||
);
|
||||
$parts = explode('.', $callback);
|
||||
foreach ($parts as $part) {
|
||||
if (!preg_match($pattern, $part) || in_array($part, $reserved, true)) {
|
||||
if (!preg_match($pattern, $part) || \in_array($part, $reserved, true)) {
|
||||
throw new \InvalidArgumentException('The callback name is not valid.');
|
||||
}
|
||||
}
|
||||
|
|
@ -139,22 +139,28 @@ class JsonResponse extends Response
|
|||
*/
|
||||
public function setData($data = array())
|
||||
{
|
||||
if (defined('HHVM_VERSION')) {
|
||||
if (\defined('HHVM_VERSION')) {
|
||||
// HHVM does not trigger any warnings and let exceptions
|
||||
// thrown from a JsonSerializable object pass through.
|
||||
// If only PHP did the same...
|
||||
$data = json_encode($data, $this->encodingOptions);
|
||||
} else {
|
||||
try {
|
||||
// PHP 5.4 and up wrap exceptions thrown by JsonSerializable
|
||||
// objects in a new exception that needs to be removed.
|
||||
// Fortunately, PHP 5.5 and up do not trigger any warning anymore.
|
||||
$data = json_encode($data, $this->encodingOptions);
|
||||
} catch (\Exception $e) {
|
||||
if ('Exception' === get_class($e) && 0 === strpos($e->getMessage(), 'Failed calling ')) {
|
||||
throw $e->getPrevious() ?: $e;
|
||||
if (!interface_exists('JsonSerializable', false)) {
|
||||
set_error_handler(function () { return false; });
|
||||
try {
|
||||
$data = @json_encode($data, $this->encodingOptions);
|
||||
} finally {
|
||||
restore_error_handler();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
$data = json_encode($data, $this->encodingOptions);
|
||||
} catch (\Exception $e) {
|
||||
if ('Exception' === \get_class($e) && 0 === strpos($e->getMessage(), 'Failed calling ')) {
|
||||
throw $e->getPrevious() ?: $e;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
2
pfosten/vendor/symfony/http-foundation/LICENSE
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/http-foundation/LICENSE
vendored
Executable file → Normal file
|
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2004-2017 Fabien Potencier
|
||||
Copyright (c) 2004-2018 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
|||
10
pfosten/vendor/symfony/http-foundation/ParameterBag.php
vendored
Executable file → Normal file
10
pfosten/vendor/symfony/http-foundation/ParameterBag.php
vendored
Executable file → Normal file
|
|
@ -20,14 +20,10 @@ class ParameterBag implements \IteratorAggregate, \Countable
|
|||
{
|
||||
/**
|
||||
* Parameter storage.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $parameters;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $parameters An array of parameters
|
||||
*/
|
||||
public function __construct(array $parameters = array())
|
||||
|
|
@ -204,12 +200,12 @@ class ParameterBag implements \IteratorAggregate, \Countable
|
|||
$value = $this->get($key, $default);
|
||||
|
||||
// Always turn $options into an array - this allows filter_var option shortcuts.
|
||||
if (!is_array($options) && $options) {
|
||||
if (!\is_array($options) && $options) {
|
||||
$options = array('flags' => $options);
|
||||
}
|
||||
|
||||
// Add a convenience check for arrays.
|
||||
if (is_array($value) && !isset($options['flags'])) {
|
||||
if (\is_array($value) && !isset($options['flags'])) {
|
||||
$options['flags'] = FILTER_REQUIRE_ARRAY;
|
||||
}
|
||||
|
||||
|
|
@ -233,6 +229,6 @@ class ParameterBag implements \IteratorAggregate, \Countable
|
|||
*/
|
||||
public function count()
|
||||
{
|
||||
return count($this->parameters);
|
||||
return \count($this->parameters);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/http-foundation/README.md
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/README.md
vendored
Executable file → Normal file
10
pfosten/vendor/symfony/http-foundation/RedirectResponse.php
vendored
Executable file → Normal file
10
pfosten/vendor/symfony/http-foundation/RedirectResponse.php
vendored
Executable file → Normal file
|
|
@ -48,7 +48,13 @@ class RedirectResponse extends Response
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* Factory method for chainability.
|
||||
*
|
||||
* @param string $url The url to redirect to
|
||||
* @param int $status The response status code
|
||||
* @param array $headers An array of response headers
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function create($url = '', $status = 302, $headers = array())
|
||||
{
|
||||
|
|
@ -87,7 +93,7 @@ class RedirectResponse extends Response
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="refresh" content="1;url=%1$s" />
|
||||
<meta http-equiv="refresh" content="0;url=%1$s" />
|
||||
|
||||
<title>Redirecting to %1$s</title>
|
||||
</head>
|
||||
|
|
|
|||
247
pfosten/vendor/symfony/http-foundation/Request.php
vendored
Executable file → Normal file
247
pfosten/vendor/symfony/http-foundation/Request.php
vendored
Executable file → Normal file
|
|
@ -144,7 +144,7 @@ class Request
|
|||
public $headers;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @var string|resource|false|null
|
||||
*/
|
||||
protected $content;
|
||||
|
||||
|
|
@ -221,7 +221,6 @@ class Request
|
|||
protected static $requestFactory;
|
||||
|
||||
private $isHostValid = true;
|
||||
private $isClientIpsValid = true;
|
||||
private $isForwardedValid = true;
|
||||
|
||||
private static $trustedHeaderSet = -1;
|
||||
|
|
@ -243,15 +242,13 @@ class Request
|
|||
);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $query The GET parameters
|
||||
* @param array $request The POST parameters
|
||||
* @param array $attributes The request attributes (parameters parsed from the PATH_INFO, ...)
|
||||
* @param array $cookies The COOKIE parameters
|
||||
* @param array $files The FILES parameters
|
||||
* @param array $server The SERVER parameters
|
||||
* @param string|resource $content The raw body data
|
||||
* @param array $query The GET parameters
|
||||
* @param array $request The POST parameters
|
||||
* @param array $attributes The request attributes (parameters parsed from the PATH_INFO, ...)
|
||||
* @param array $cookies The COOKIE parameters
|
||||
* @param array $files The FILES parameters
|
||||
* @param array $server The SERVER parameters
|
||||
* @param string|resource|null $content The raw body data
|
||||
*/
|
||||
public function __construct(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null)
|
||||
{
|
||||
|
|
@ -263,13 +260,13 @@ class Request
|
|||
*
|
||||
* This method also re-initializes all properties.
|
||||
*
|
||||
* @param array $query The GET parameters
|
||||
* @param array $request The POST parameters
|
||||
* @param array $attributes The request attributes (parameters parsed from the PATH_INFO, ...)
|
||||
* @param array $cookies The COOKIE parameters
|
||||
* @param array $files The FILES parameters
|
||||
* @param array $server The SERVER parameters
|
||||
* @param string|resource $content The raw body data
|
||||
* @param array $query The GET parameters
|
||||
* @param array $request The POST parameters
|
||||
* @param array $attributes The request attributes (parameters parsed from the PATH_INFO, ...)
|
||||
* @param array $cookies The COOKIE parameters
|
||||
* @param array $files The FILES parameters
|
||||
* @param array $server The SERVER parameters
|
||||
* @param string|resource|null $content The raw body data
|
||||
*/
|
||||
public function initialize(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null)
|
||||
{
|
||||
|
|
@ -305,7 +302,7 @@ class Request
|
|||
// stores the Content-Type and Content-Length header values in
|
||||
// HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH fields.
|
||||
$server = $_SERVER;
|
||||
if ('cli-server' === PHP_SAPI) {
|
||||
if ('cli-server' === \PHP_SAPI) {
|
||||
if (array_key_exists('HTTP_CONTENT_LENGTH', $_SERVER)) {
|
||||
$server['CONTENT_LENGTH'] = $_SERVER['HTTP_CONTENT_LENGTH'];
|
||||
}
|
||||
|
|
@ -317,7 +314,7 @@ class Request
|
|||
$request = self::createRequestFromFactory($_GET, $_POST, array(), $_COOKIE, $_FILES, $server);
|
||||
|
||||
if (0 === strpos($request->headers->get('CONTENT_TYPE'), 'application/x-www-form-urlencoded')
|
||||
&& in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), array('PUT', 'DELETE', 'PATCH'))
|
||||
&& \in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), array('PUT', 'DELETE', 'PATCH'))
|
||||
) {
|
||||
parse_str($request->getContent(), $data);
|
||||
$request->request = new ParameterBag($data);
|
||||
|
|
@ -332,13 +329,13 @@ class Request
|
|||
* The information contained in the URI always take precedence
|
||||
* over the other information (server and parameters).
|
||||
*
|
||||
* @param string $uri The URI
|
||||
* @param string $method The HTTP method
|
||||
* @param array $parameters The query (GET) or request (POST) parameters
|
||||
* @param array $cookies The request cookies ($_COOKIE)
|
||||
* @param array $files The request files ($_FILES)
|
||||
* @param array $server The server parameters ($_SERVER)
|
||||
* @param string $content The raw body data
|
||||
* @param string $uri The URI
|
||||
* @param string $method The HTTP method
|
||||
* @param array $parameters The query (GET) or request (POST) parameters
|
||||
* @param array $cookies The request cookies ($_COOKIE)
|
||||
* @param array $files The request files ($_FILES)
|
||||
* @param array $server The server parameters ($_SERVER)
|
||||
* @param string|resource|null $content The raw body data
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
|
|
@ -463,22 +460,22 @@ class Request
|
|||
public function duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null)
|
||||
{
|
||||
$dup = clone $this;
|
||||
if ($query !== null) {
|
||||
if (null !== $query) {
|
||||
$dup->query = new ParameterBag($query);
|
||||
}
|
||||
if ($request !== null) {
|
||||
if (null !== $request) {
|
||||
$dup->request = new ParameterBag($request);
|
||||
}
|
||||
if ($attributes !== null) {
|
||||
if (null !== $attributes) {
|
||||
$dup->attributes = new ParameterBag($attributes);
|
||||
}
|
||||
if ($cookies !== null) {
|
||||
if (null !== $cookies) {
|
||||
$dup->cookies = new ParameterBag($cookies);
|
||||
}
|
||||
if ($files !== null) {
|
||||
if (null !== $files) {
|
||||
$dup->files = new FileBag($files);
|
||||
}
|
||||
if ($server !== null) {
|
||||
if (null !== $server) {
|
||||
$dup->server = new ServerBag($server);
|
||||
$dup->headers = new HeaderBag($dup->server->getHeaders());
|
||||
}
|
||||
|
|
@ -534,9 +531,21 @@ class Request
|
|||
return trigger_error($e, E_USER_ERROR);
|
||||
}
|
||||
|
||||
$cookieHeader = '';
|
||||
$cookies = array();
|
||||
|
||||
foreach ($this->cookies as $k => $v) {
|
||||
$cookies[] = $k.'='.$v;
|
||||
}
|
||||
|
||||
if (!empty($cookies)) {
|
||||
$cookieHeader = 'Cookie: '.implode('; ', $cookies)."\r\n";
|
||||
}
|
||||
|
||||
return
|
||||
sprintf('%s %s %s', $this->getMethod(), $this->getRequestUri(), $this->server->get('SERVER_PROTOCOL'))."\r\n".
|
||||
$this->headers."\r\n".
|
||||
$this->headers.
|
||||
$cookieHeader."\r\n".
|
||||
$content;
|
||||
}
|
||||
|
||||
|
|
@ -548,7 +557,7 @@ class Request
|
|||
*/
|
||||
public function overrideGlobals()
|
||||
{
|
||||
$this->server->set('QUERY_STRING', static::normalizeQueryString(http_build_query($this->query->all(), null, '&')));
|
||||
$this->server->set('QUERY_STRING', static::normalizeQueryString(http_build_query($this->query->all(), '', '&')));
|
||||
|
||||
$_GET = $this->query->all();
|
||||
$_POST = $this->request->all();
|
||||
|
|
@ -557,7 +566,7 @@ class Request
|
|||
|
||||
foreach ($this->headers->all() as $key => $value) {
|
||||
$key = strtoupper(str_replace('-', '_', $key));
|
||||
if (in_array($key, array('CONTENT_TYPE', 'CONTENT_LENGTH'))) {
|
||||
if (\in_array($key, array('CONTENT_TYPE', 'CONTENT_LENGTH'))) {
|
||||
$_SERVER[$key] = implode(', ', $value);
|
||||
} else {
|
||||
$_SERVER['HTTP_'.$key] = implode(', ', $value);
|
||||
|
|
@ -589,8 +598,8 @@ class Request
|
|||
{
|
||||
self::$trustedProxies = $proxies;
|
||||
|
||||
if (2 > func_num_args()) {
|
||||
@trigger_error(sprintf('The %s() method expects a bit field of Request::HEADER_* as second argument since version 3.3. Defining it will be required in 4.0. ', __METHOD__), E_USER_DEPRECATED);
|
||||
if (2 > \func_num_args()) {
|
||||
@trigger_error(sprintf('The %s() method expects a bit field of Request::HEADER_* as second argument since Symfony 3.3. Defining it will be required in 4.0. ', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -632,7 +641,7 @@ class Request
|
|||
public static function setTrustedHosts(array $hostPatterns)
|
||||
{
|
||||
self::$trustedHostPatterns = array_map(function ($hostPattern) {
|
||||
return sprintf('#%s#i', $hostPattern);
|
||||
return sprintf('{%s}i', $hostPattern);
|
||||
}, $hostPatterns);
|
||||
// we need to reset trusted hosts on trusted host patterns change
|
||||
self::$trustedHosts = array();
|
||||
|
|
@ -670,9 +679,19 @@ class Request
|
|||
*/
|
||||
public static function setTrustedHeaderName($key, $value)
|
||||
{
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated since version 3.3 and will be removed in 4.0. Use the $trustedHeaderSet argument of the Request::setTrustedProxies() method instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.3 and will be removed in 4.0. Use the $trustedHeaderSet argument of the Request::setTrustedProxies() method instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
if (!array_key_exists($key, self::$trustedHeaders)) {
|
||||
if ('forwarded' === $key) {
|
||||
$key = self::HEADER_FORWARDED;
|
||||
} elseif ('client_ip' === $key) {
|
||||
$key = self::HEADER_CLIENT_IP;
|
||||
} elseif ('client_host' === $key) {
|
||||
$key = self::HEADER_CLIENT_HOST;
|
||||
} elseif ('client_proto' === $key) {
|
||||
$key = self::HEADER_CLIENT_PROTO;
|
||||
} elseif ('client_port' === $key) {
|
||||
$key = self::HEADER_CLIENT_PORT;
|
||||
} elseif (!array_key_exists($key, self::$trustedHeaders)) {
|
||||
throw new \InvalidArgumentException(sprintf('Unable to set the trusted header name for key "%s".', $key));
|
||||
}
|
||||
|
||||
|
|
@ -699,8 +718,8 @@ class Request
|
|||
*/
|
||||
public static function getTrustedHeaderName($key)
|
||||
{
|
||||
if (2 > func_num_args() || func_get_arg(1)) {
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated since version 3.3 and will be removed in 4.0. Use the Request::getTrustedHeaderSet() method instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
if (2 > \func_num_args() || func_get_arg(1)) {
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.3 and will be removed in 4.0. Use the Request::getTrustedHeaderSet() method instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
if (!array_key_exists($key, self::$trustedHeaders)) {
|
||||
|
|
@ -788,8 +807,8 @@ class Request
|
|||
*
|
||||
* Order of precedence: PATH (routing placeholders or custom attributes), GET, BODY
|
||||
*
|
||||
* @param string $key the key
|
||||
* @param mixed $default the default value if the parameter key does not exist
|
||||
* @param string $key The key
|
||||
* @param mixed $default The default value if the parameter key does not exist
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
|
|
@ -1012,7 +1031,7 @@ class Request
|
|||
return $this->server->get('SERVER_PORT');
|
||||
}
|
||||
|
||||
if ($host[0] === '[') {
|
||||
if ('[' === $host[0]) {
|
||||
$pos = strpos($host, ':', strrpos($host, ']'));
|
||||
} else {
|
||||
$pos = strrpos($host, ':');
|
||||
|
|
@ -1074,7 +1093,7 @@ class Request
|
|||
$scheme = $this->getScheme();
|
||||
$port = $this->getPort();
|
||||
|
||||
if (('http' == $scheme && $port == 80) || ('https' == $scheme && $port == 443)) {
|
||||
if (('http' == $scheme && 80 == $port) || ('https' == $scheme && 443 == $port)) {
|
||||
return $this->getHost();
|
||||
}
|
||||
|
||||
|
|
@ -1180,7 +1199,7 @@ class Request
|
|||
}
|
||||
|
||||
$targetDirs[] = $targetFile;
|
||||
$path = str_repeat('../', count($sourceDirs)).implode('/', $targetDirs);
|
||||
$path = str_repeat('../', \count($sourceDirs)).implode('/', $targetDirs);
|
||||
|
||||
// A reference to the same base directory or an empty subdirectory must be prefixed with "./".
|
||||
// This also applies to a segment with a colon character (e.g., "file:colon") that cannot be used
|
||||
|
|
@ -1223,7 +1242,7 @@ class Request
|
|||
public function isSecure()
|
||||
{
|
||||
if ($this->isFromTrustedProxy() && $proto = $this->getTrustedValues(self::HEADER_CLIENT_PROTO)) {
|
||||
return in_array(strtolower($proto[0]), array('https', 'on', 'ssl', '1'), true);
|
||||
return \in_array(strtolower($proto[0]), array('https', 'on', 'ssl', '1'), true);
|
||||
}
|
||||
|
||||
$https = $this->server->get('HTTPS');
|
||||
|
|
@ -1273,10 +1292,10 @@ class Request
|
|||
throw new SuspiciousOperationException(sprintf('Invalid Host "%s".', $host));
|
||||
}
|
||||
|
||||
if (count(self::$trustedHostPatterns) > 0) {
|
||||
if (\count(self::$trustedHostPatterns) > 0) {
|
||||
// to avoid host header injection attacks, you should provide a list of trusted host patterns
|
||||
|
||||
if (in_array($host, self::$trustedHosts)) {
|
||||
if (\in_array($host, self::$trustedHosts)) {
|
||||
return $host;
|
||||
}
|
||||
|
||||
|
|
@ -1334,7 +1353,10 @@ class Request
|
|||
if ($method = $this->headers->get('X-HTTP-METHOD-OVERRIDE')) {
|
||||
$this->method = strtoupper($method);
|
||||
} elseif (self::$httpMethodParameterOverride) {
|
||||
$this->method = strtoupper($this->request->get('_method', $this->query->get('_method', 'POST')));
|
||||
$method = $this->request->get('_method', $this->query->get('_method', 'POST'));
|
||||
if (\is_string($method)) {
|
||||
$this->method = strtoupper($method);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1359,7 +1381,7 @@ class Request
|
|||
*
|
||||
* @param string $format The format
|
||||
*
|
||||
* @return string The associated mime type (null if not found)
|
||||
* @return string|null The associated mime type (null if not found)
|
||||
*/
|
||||
public function getMimeType($format)
|
||||
{
|
||||
|
|
@ -1405,10 +1427,10 @@ class Request
|
|||
}
|
||||
|
||||
foreach (static::$formats as $format => $mimeTypes) {
|
||||
if (in_array($mimeType, (array) $mimeTypes)) {
|
||||
if (\in_array($mimeType, (array) $mimeTypes)) {
|
||||
return $format;
|
||||
}
|
||||
if (null !== $canonicalMimeType && in_array($canonicalMimeType, (array) $mimeTypes)) {
|
||||
if (null !== $canonicalMimeType && \in_array($canonicalMimeType, (array) $mimeTypes)) {
|
||||
return $format;
|
||||
}
|
||||
}
|
||||
|
|
@ -1426,7 +1448,7 @@ class Request
|
|||
static::initializeFormats();
|
||||
}
|
||||
|
||||
static::$formats[$format] = is_array($mimeTypes) ? $mimeTypes : array($mimeTypes);
|
||||
static::$formats[$format] = \is_array($mimeTypes) ? $mimeTypes : array($mimeTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1538,15 +1560,15 @@ class Request
|
|||
*/
|
||||
public function isMethodSafe(/* $andCacheable = true */)
|
||||
{
|
||||
if (!func_num_args() || func_get_arg(0)) {
|
||||
if (!\func_num_args() || func_get_arg(0)) {
|
||||
// This deprecation should be turned into a BadMethodCallException in 4.0 (without adding the argument in the signature)
|
||||
// then setting $andCacheable to false should be deprecated in 4.1
|
||||
@trigger_error('Checking only for cacheable HTTP methods with Symfony\Component\HttpFoundation\Request::isMethodSafe() is deprecated since version 3.2 and will throw an exception in 4.0. Disable checking only for cacheable methods by calling the method with `false` as first argument or use the Request::isMethodCacheable() instead.', E_USER_DEPRECATED);
|
||||
@trigger_error('Checking only for cacheable HTTP methods with Symfony\Component\HttpFoundation\Request::isMethodSafe() is deprecated since Symfony 3.2 and will throw an exception in 4.0. Disable checking only for cacheable methods by calling the method with `false` as first argument or use the Request::isMethodCacheable() instead.', E_USER_DEPRECATED);
|
||||
|
||||
return in_array($this->getMethod(), array('GET', 'HEAD'));
|
||||
return \in_array($this->getMethod(), array('GET', 'HEAD'));
|
||||
}
|
||||
|
||||
return in_array($this->getMethod(), array('GET', 'HEAD', 'OPTIONS', 'TRACE'));
|
||||
return \in_array($this->getMethod(), array('GET', 'HEAD', 'OPTIONS', 'TRACE'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1556,7 +1578,7 @@ class Request
|
|||
*/
|
||||
public function isMethodIdempotent()
|
||||
{
|
||||
return in_array($this->getMethod(), array('HEAD', 'GET', 'PUT', 'DELETE', 'TRACE', 'OPTIONS', 'PURGE'));
|
||||
return \in_array($this->getMethod(), array('HEAD', 'GET', 'PUT', 'DELETE', 'TRACE', 'OPTIONS', 'PURGE'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1568,7 +1590,31 @@ class Request
|
|||
*/
|
||||
public function isMethodCacheable()
|
||||
{
|
||||
return in_array($this->getMethod(), array('GET', 'HEAD'));
|
||||
return \in_array($this->getMethod(), array('GET', 'HEAD'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the protocol version.
|
||||
*
|
||||
* If the application is behind a proxy, the protocol version used in the
|
||||
* requests between the client and the proxy and between the proxy and the
|
||||
* server might be different. This returns the former (from the "Via" header)
|
||||
* if the proxy is trusted (see "setTrustedProxies()"), otherwise it returns
|
||||
* the latter (from the "SERVER_PROTOCOL" server parameter).
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getProtocolVersion()
|
||||
{
|
||||
if ($this->isFromTrustedProxy()) {
|
||||
preg_match('~^(HTTP/)?([1-9]\.[0-9]) ~', $this->headers->get('Via'), $matches);
|
||||
|
||||
if ($matches) {
|
||||
return 'HTTP/'.$matches[2];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->server->get('SERVER_PROTOCOL');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1582,7 +1628,7 @@ class Request
|
|||
*/
|
||||
public function getContent($asResource = false)
|
||||
{
|
||||
$currentContentIsResource = is_resource($this->content);
|
||||
$currentContentIsResource = \is_resource($this->content);
|
||||
if (\PHP_VERSION_ID < 50600 && false === $this->content) {
|
||||
throw new \LogicException('getContent() can only be called once when using the resource return type and PHP below 5.6.');
|
||||
}
|
||||
|
|
@ -1595,7 +1641,7 @@ class Request
|
|||
}
|
||||
|
||||
// Content passed in parameter (test)
|
||||
if (is_string($this->content)) {
|
||||
if (\is_string($this->content)) {
|
||||
$resource = fopen('php://temp', 'r+');
|
||||
fwrite($resource, $this->content);
|
||||
rewind($resource);
|
||||
|
|
@ -1663,7 +1709,7 @@ class Request
|
|||
$extendedPreferredLanguages[] = $language;
|
||||
if (false !== $position = strpos($language, '_')) {
|
||||
$superLanguage = substr($language, 0, $position);
|
||||
if (!in_array($superLanguage, $preferredLanguages)) {
|
||||
if (!\in_array($superLanguage, $preferredLanguages)) {
|
||||
$extendedPreferredLanguages[] = $superLanguage;
|
||||
}
|
||||
}
|
||||
|
|
@ -1694,12 +1740,12 @@ class Request
|
|||
// Language not listed in ISO 639 that are not variants
|
||||
// of any listed language, which can be registered with the
|
||||
// i-prefix, such as i-cherokee
|
||||
if (count($codes) > 1) {
|
||||
if (\count($codes) > 1) {
|
||||
$lang = $codes[1];
|
||||
}
|
||||
} else {
|
||||
for ($i = 0, $max = count($codes); $i < $max; ++$i) {
|
||||
if ($i === 0) {
|
||||
for ($i = 0, $max = \count($codes); $i < $max; ++$i) {
|
||||
if (0 === $i) {
|
||||
$lang = strtolower($codes[0]);
|
||||
} else {
|
||||
$lang .= '_'.strtoupper($codes[$i]);
|
||||
|
|
@ -1783,18 +1829,7 @@ class Request
|
|||
{
|
||||
$requestUri = '';
|
||||
|
||||
if ($this->headers->has('X_ORIGINAL_URL')) {
|
||||
// IIS with Microsoft Rewrite Module
|
||||
$requestUri = $this->headers->get('X_ORIGINAL_URL');
|
||||
$this->headers->remove('X_ORIGINAL_URL');
|
||||
$this->server->remove('HTTP_X_ORIGINAL_URL');
|
||||
$this->server->remove('UNENCODED_URL');
|
||||
$this->server->remove('IIS_WasUrlRewritten');
|
||||
} elseif ($this->headers->has('X_REWRITE_URL')) {
|
||||
// IIS with ISAPI_Rewrite
|
||||
$requestUri = $this->headers->get('X_REWRITE_URL');
|
||||
$this->headers->remove('X_REWRITE_URL');
|
||||
} elseif ($this->server->get('IIS_WasUrlRewritten') == '1' && $this->server->get('UNENCODED_URL') != '') {
|
||||
if ('1' == $this->server->get('IIS_WasUrlRewritten') && '' != $this->server->get('UNENCODED_URL')) {
|
||||
// IIS7 with URL Rewrite: make sure we get the unencoded URL (double slash problem)
|
||||
$requestUri = $this->server->get('UNENCODED_URL');
|
||||
$this->server->remove('UNENCODED_URL');
|
||||
|
|
@ -1803,8 +1838,8 @@ class Request
|
|||
$requestUri = $this->server->get('REQUEST_URI');
|
||||
// HTTP proxy reqs setup request URI with scheme and host [and port] + the URL path, only use URL path
|
||||
$schemeAndHttpHost = $this->getSchemeAndHttpHost();
|
||||
if (strpos($requestUri, $schemeAndHttpHost) === 0) {
|
||||
$requestUri = substr($requestUri, strlen($schemeAndHttpHost));
|
||||
if (0 === strpos($requestUri, $schemeAndHttpHost)) {
|
||||
$requestUri = substr($requestUri, \strlen($schemeAndHttpHost));
|
||||
}
|
||||
} elseif ($this->server->has('ORIG_PATH_INFO')) {
|
||||
// IIS 5.0, PHP as CGI
|
||||
|
|
@ -1844,7 +1879,7 @@ class Request
|
|||
$segs = explode('/', trim($file, '/'));
|
||||
$segs = array_reverse($segs);
|
||||
$index = 0;
|
||||
$last = count($segs);
|
||||
$last = \count($segs);
|
||||
$baseUrl = '';
|
||||
do {
|
||||
$seg = $segs[$index];
|
||||
|
|
@ -1855,15 +1890,18 @@ class Request
|
|||
|
||||
// Does the baseUrl have anything in common with the request_uri?
|
||||
$requestUri = $this->getRequestUri();
|
||||
if ('' !== $requestUri && '/' !== $requestUri[0]) {
|
||||
$requestUri = '/'.$requestUri;
|
||||
}
|
||||
|
||||
if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, $baseUrl)) {
|
||||
// full $baseUrl matches
|
||||
return $prefix;
|
||||
}
|
||||
|
||||
if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, rtrim(dirname($baseUrl), '/'.DIRECTORY_SEPARATOR).'/')) {
|
||||
if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, rtrim(\dirname($baseUrl), '/'.\DIRECTORY_SEPARATOR).'/')) {
|
||||
// directory portion of $baseUrl matches
|
||||
return rtrim($prefix, '/'.DIRECTORY_SEPARATOR);
|
||||
return rtrim($prefix, '/'.\DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
$truncatedRequestUri = $requestUri;
|
||||
|
|
@ -1880,11 +1918,11 @@ class Request
|
|||
// If using mod_rewrite or ISAPI_Rewrite strip the script filename
|
||||
// out of baseUrl. $pos !== 0 makes sure it is not matching a value
|
||||
// from PATH_INFO or QUERY_STRING
|
||||
if (strlen($requestUri) >= strlen($baseUrl) && (false !== $pos = strpos($requestUri, $baseUrl)) && $pos !== 0) {
|
||||
$baseUrl = substr($requestUri, 0, $pos + strlen($baseUrl));
|
||||
if (\strlen($requestUri) >= \strlen($baseUrl) && (false !== $pos = strpos($requestUri, $baseUrl)) && 0 !== $pos) {
|
||||
$baseUrl = substr($requestUri, 0, $pos + \strlen($baseUrl));
|
||||
}
|
||||
|
||||
return rtrim($baseUrl, '/'.DIRECTORY_SEPARATOR);
|
||||
return rtrim($baseUrl, '/'.\DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1894,19 +1932,19 @@ class Request
|
|||
*/
|
||||
protected function prepareBasePath()
|
||||
{
|
||||
$filename = basename($this->server->get('SCRIPT_FILENAME'));
|
||||
$baseUrl = $this->getBaseUrl();
|
||||
if (empty($baseUrl)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$filename = basename($this->server->get('SCRIPT_FILENAME'));
|
||||
if (basename($baseUrl) === $filename) {
|
||||
$basePath = dirname($baseUrl);
|
||||
$basePath = \dirname($baseUrl);
|
||||
} else {
|
||||
$basePath = $baseUrl;
|
||||
}
|
||||
|
||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$basePath = str_replace('\\', '/', $basePath);
|
||||
}
|
||||
|
||||
|
|
@ -1920,23 +1958,26 @@ class Request
|
|||
*/
|
||||
protected function preparePathInfo()
|
||||
{
|
||||
$baseUrl = $this->getBaseUrl();
|
||||
|
||||
if (null === ($requestUri = $this->getRequestUri())) {
|
||||
return '/';
|
||||
}
|
||||
|
||||
// Remove the query string from REQUEST_URI
|
||||
if ($pos = strpos($requestUri, '?')) {
|
||||
if (false !== $pos = strpos($requestUri, '?')) {
|
||||
$requestUri = substr($requestUri, 0, $pos);
|
||||
}
|
||||
if ('' !== $requestUri && '/' !== $requestUri[0]) {
|
||||
$requestUri = '/'.$requestUri;
|
||||
}
|
||||
|
||||
$pathInfo = substr($requestUri, strlen($baseUrl));
|
||||
if (null !== $baseUrl && (false === $pathInfo || '' === $pathInfo)) {
|
||||
if (null === ($baseUrl = $this->getBaseUrl())) {
|
||||
return $requestUri;
|
||||
}
|
||||
|
||||
$pathInfo = substr($requestUri, \strlen($baseUrl));
|
||||
if (false === $pathInfo || '' === $pathInfo) {
|
||||
// If substr() returns false then PATH_INFO is set to an empty string
|
||||
return '/';
|
||||
} elseif (null === $baseUrl) {
|
||||
return $requestUri;
|
||||
}
|
||||
|
||||
return (string) $pathInfo;
|
||||
|
|
@ -1953,6 +1994,7 @@ class Request
|
|||
'js' => array('application/javascript', 'application/x-javascript', 'text/javascript'),
|
||||
'css' => array('text/css'),
|
||||
'json' => array('application/json', 'application/x-json'),
|
||||
'jsonld' => array('application/ld+json'),
|
||||
'xml' => array('text/xml', 'application/xml', 'application/x-xml'),
|
||||
'rdf' => array('application/rdf+xml'),
|
||||
'atom' => array('application/atom+xml'),
|
||||
|
|
@ -1994,7 +2036,7 @@ class Request
|
|||
return false;
|
||||
}
|
||||
|
||||
$len = strlen($prefix);
|
||||
$len = \strlen($prefix);
|
||||
|
||||
if (preg_match(sprintf('#^(%%[[:xdigit:]]{2}|.){%d}#', $len), $string, $match)) {
|
||||
return $match[0];
|
||||
|
|
@ -2006,7 +2048,7 @@ class Request
|
|||
private static function createRequestFromFactory(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null)
|
||||
{
|
||||
if (self::$requestFactory) {
|
||||
$request = call_user_func(self::$requestFactory, $query, $request, $attributes, $cookies, $files, $server, $content);
|
||||
$request = \call_user_func(self::$requestFactory, $query, $request, $attributes, $cookies, $files, $server, $content);
|
||||
|
||||
if (!$request instanceof self) {
|
||||
throw new \LogicException('The Request factory must return an instance of Symfony\Component\HttpFoundation\Request.');
|
||||
|
|
@ -2045,6 +2087,11 @@ class Request
|
|||
if (self::$trustedHeaders[self::HEADER_FORWARDED] && $this->headers->has(self::$trustedHeaders[self::HEADER_FORWARDED])) {
|
||||
$forwardedValues = $this->headers->get(self::$trustedHeaders[self::HEADER_FORWARDED]);
|
||||
$forwardedValues = preg_match_all(sprintf('{(?:%s)=(?:"?\[?)([a-zA-Z0-9\.:_\-/]*+)}', self::$forwardedParams[$type]), $forwardedValues, $matches) ? $matches[1] : array();
|
||||
if (self::HEADER_CLIENT_PORT === $type) {
|
||||
foreach ($forwardedValues as $k => $v) {
|
||||
$forwardedValues[$k] = substr_replace($v, '0.0.0.0', 0, strrpos($v, ':'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (null !== $ip) {
|
||||
|
|
|
|||
6
pfosten/vendor/symfony/http-foundation/RequestMatcher.php
vendored
Executable file → Normal file
6
pfosten/vendor/symfony/http-foundation/RequestMatcher.php
vendored
Executable file → Normal file
|
|
@ -145,11 +145,11 @@ class RequestMatcher implements RequestMatcherInterface
|
|||
*/
|
||||
public function matches(Request $request)
|
||||
{
|
||||
if ($this->schemes && !in_array($request->getScheme(), $this->schemes, true)) {
|
||||
if ($this->schemes && !\in_array($request->getScheme(), $this->schemes, true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->methods && !in_array($request->getMethod(), $this->methods, true)) {
|
||||
if ($this->methods && !\in_array($request->getMethod(), $this->methods, true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -173,6 +173,6 @@ class RequestMatcher implements RequestMatcherInterface
|
|||
|
||||
// Note to future implementors: add additional checks above the
|
||||
// foreach above or else your check might not be run!
|
||||
return count($this->ips) === 0;
|
||||
return 0 === \count($this->ips);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
pfosten/vendor/symfony/http-foundation/RequestMatcherInterface.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/http-foundation/RequestMatcherInterface.php
vendored
Executable file → Normal file
|
|
@ -21,8 +21,6 @@ interface RequestMatcherInterface
|
|||
/**
|
||||
* Decides whether the rule(s) implemented by the strategy matches the supplied request.
|
||||
*
|
||||
* @param Request $request The request to check for a match
|
||||
*
|
||||
* @return bool true if the request matches, false otherwise
|
||||
*/
|
||||
public function matches(Request $request);
|
||||
|
|
|
|||
2
pfosten/vendor/symfony/http-foundation/RequestStack.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/http-foundation/RequestStack.php
vendored
Executable file → Normal file
|
|
@ -92,7 +92,7 @@ class RequestStack
|
|||
*/
|
||||
public function getParentRequest()
|
||||
{
|
||||
$pos = count($this->requests) - 2;
|
||||
$pos = \count($this->requests) - 2;
|
||||
|
||||
if (!isset($this->requests[$pos])) {
|
||||
return;
|
||||
|
|
|
|||
128
pfosten/vendor/symfony/http-foundation/Response.php
vendored
Executable file → Normal file
128
pfosten/vendor/symfony/http-foundation/Response.php
vendored
Executable file → Normal file
|
|
@ -21,6 +21,7 @@ class Response
|
|||
const HTTP_CONTINUE = 100;
|
||||
const HTTP_SWITCHING_PROTOCOLS = 101;
|
||||
const HTTP_PROCESSING = 102; // RFC2518
|
||||
const HTTP_EARLY_HINTS = 103; // RFC8297
|
||||
const HTTP_OK = 200;
|
||||
const HTTP_CREATED = 201;
|
||||
const HTTP_ACCEPTED = 202;
|
||||
|
|
@ -63,7 +64,12 @@ class Response
|
|||
const HTTP_UNPROCESSABLE_ENTITY = 422; // RFC4918
|
||||
const HTTP_LOCKED = 423; // RFC4918
|
||||
const HTTP_FAILED_DEPENDENCY = 424; // RFC4918
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
const HTTP_RESERVED_FOR_WEBDAV_ADVANCED_COLLECTIONS_EXPIRED_PROPOSAL = 425; // RFC2817
|
||||
const HTTP_TOO_EARLY = 425; // RFC-ietf-httpbis-replay-04
|
||||
const HTTP_UPGRADE_REQUIRED = 426; // RFC2817
|
||||
const HTTP_PRECONDITION_REQUIRED = 428; // RFC6585
|
||||
const HTTP_TOO_MANY_REQUESTS = 429; // RFC6585
|
||||
|
|
@ -126,6 +132,7 @@ class Response
|
|||
100 => 'Continue',
|
||||
101 => 'Switching Protocols',
|
||||
102 => 'Processing', // RFC2518
|
||||
103 => 'Early Hints',
|
||||
200 => 'OK',
|
||||
201 => 'Created',
|
||||
202 => 'Accepted',
|
||||
|
|
@ -167,7 +174,7 @@ class Response
|
|||
422 => 'Unprocessable Entity', // RFC4918
|
||||
423 => 'Locked', // RFC4918
|
||||
424 => 'Failed Dependency', // RFC4918
|
||||
425 => 'Reserved for WebDAV advanced collections expired proposal', // RFC2817
|
||||
425 => 'Too Early', // RFC-ietf-httpbis-replay-04
|
||||
426 => 'Upgrade Required', // RFC2817
|
||||
428 => 'Precondition Required', // RFC6585
|
||||
429 => 'Too Many Requests', // RFC6585
|
||||
|
|
@ -187,8 +194,6 @@ class Response
|
|||
);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param mixed $content The response content, see setContent()
|
||||
* @param int $status The response status code
|
||||
* @param array $headers An array of response headers
|
||||
|
|
@ -201,11 +206,6 @@ class Response
|
|||
$this->setContent($content);
|
||||
$this->setStatusCode($status);
|
||||
$this->setProtocolVersion('1.0');
|
||||
|
||||
/* RFC2616 - 14.18 says all Responses need to have a Date */
|
||||
if (!$this->headers->has('Date')) {
|
||||
$this->setDate(\DateTime::createFromFormat('U', time()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -261,8 +261,6 @@ class Response
|
|||
* compliant with RFC 2616. Most of the changes are based on
|
||||
* the Request that is "associated" with this Response.
|
||||
*
|
||||
* @param Request $request A Request instance
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function prepare(Request $request)
|
||||
|
|
@ -334,11 +332,6 @@ class Response
|
|||
return $this;
|
||||
}
|
||||
|
||||
/* RFC2616 - 14.18 says all Responses need to have a Date */
|
||||
if (!$this->headers->has('Date')) {
|
||||
$this->setDate(\DateTime::createFromFormat('U', time()));
|
||||
}
|
||||
|
||||
// headers
|
||||
foreach ($this->headers->allPreserveCaseWithoutCookies() as $name => $values) {
|
||||
foreach ($values as $value) {
|
||||
|
|
@ -346,18 +339,14 @@ class Response
|
|||
}
|
||||
}
|
||||
|
||||
// status
|
||||
header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), true, $this->statusCode);
|
||||
|
||||
// cookies
|
||||
foreach ($this->headers->getCookies() as $cookie) {
|
||||
if ($cookie->isRaw()) {
|
||||
setrawcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
|
||||
} else {
|
||||
setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
|
||||
}
|
||||
header('Set-Cookie: '.$cookie->getName().strstr($cookie, '='), false, $this->statusCode);
|
||||
}
|
||||
|
||||
// status
|
||||
header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), true, $this->statusCode);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -383,9 +372,9 @@ class Response
|
|||
$this->sendHeaders();
|
||||
$this->sendContent();
|
||||
|
||||
if (function_exists('fastcgi_finish_request')) {
|
||||
if (\function_exists('fastcgi_finish_request')) {
|
||||
fastcgi_finish_request();
|
||||
} elseif ('cli' !== PHP_SAPI) {
|
||||
} elseif (!\in_array(\PHP_SAPI, array('cli', 'phpdbg'), true)) {
|
||||
static::closeOutputBuffers(0, true);
|
||||
}
|
||||
|
||||
|
|
@ -405,8 +394,8 @@ class Response
|
|||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
if (null !== $content && !is_string($content) && !is_numeric($content) && !is_callable(array($content, '__toString'))) {
|
||||
throw new \UnexpectedValueException(sprintf('The Response content must be a string or object implementing __toString(), "%s" given.', gettype($content)));
|
||||
if (null !== $content && !\is_string($content) && !is_numeric($content) && !\is_callable(array($content, '__toString'))) {
|
||||
throw new \UnexpectedValueException(sprintf('The Response content must be a string or object implementing __toString(), "%s" given.', \gettype($content)));
|
||||
}
|
||||
|
||||
$this->content = (string) $content;
|
||||
|
|
@ -455,12 +444,12 @@ class Response
|
|||
/**
|
||||
* Sets the response status code.
|
||||
*
|
||||
* @param int $code HTTP status code
|
||||
* @param mixed $text HTTP status text
|
||||
*
|
||||
* If the status text is null it will be automatically populated for the known
|
||||
* status codes and left empty otherwise.
|
||||
*
|
||||
* @param int $code HTTP status code
|
||||
* @param mixed $text HTTP status text
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \InvalidArgumentException When the HTTP status code is not valid
|
||||
|
|
@ -532,13 +521,19 @@ class Response
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns true if the response is worth caching under any circumstance.
|
||||
* Returns true if the response may safely be kept in a shared (surrogate) cache.
|
||||
*
|
||||
* Responses marked "private" with an explicit Cache-Control directive are
|
||||
* considered uncacheable.
|
||||
*
|
||||
* Responses with neither a freshness lifetime (Expires, max-age) nor cache
|
||||
* validator (Last-Modified, ETag) are considered uncacheable.
|
||||
* validator (Last-Modified, ETag) are considered uncacheable because there is
|
||||
* no way to tell when or how to remove them from the cache.
|
||||
*
|
||||
* Note that RFC 7231 and RFC 7234 possibly allow for a more permissive implementation,
|
||||
* for example "status codes that are defined as cacheable by default [...]
|
||||
* can be reused by a cache with heuristic expiration unless otherwise indicated"
|
||||
* (https://tools.ietf.org/html/rfc7231#section-6.1)
|
||||
*
|
||||
* @return bool true if the response is worth caching, false otherwise
|
||||
*
|
||||
|
|
@ -546,7 +541,7 @@ class Response
|
|||
*/
|
||||
public function isCacheable()
|
||||
{
|
||||
if (!in_array($this->statusCode, array(200, 203, 300, 301, 302, 404, 410))) {
|
||||
if (!\in_array($this->statusCode, array(200, 203, 300, 301, 302, 404, 410))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -620,6 +615,38 @@ class Response
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the response as "immutable".
|
||||
*
|
||||
* @param bool $immutable enables or disables the immutable directive
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
public function setImmutable($immutable = true)
|
||||
{
|
||||
if ($immutable) {
|
||||
$this->headers->addCacheControlDirective('immutable');
|
||||
} else {
|
||||
$this->headers->removeCacheControlDirective('immutable');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the response is marked as "immutable".
|
||||
*
|
||||
* @return bool returns true if the response is marked as "immutable"; otherwise false
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
public function isImmutable()
|
||||
{
|
||||
return $this->headers->hasCacheControlDirective('immutable');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the response must be revalidated by caches.
|
||||
*
|
||||
|
|
@ -648,23 +675,12 @@ class Response
|
|||
*/
|
||||
public function getDate()
|
||||
{
|
||||
/*
|
||||
RFC2616 - 14.18 says all Responses need to have a Date.
|
||||
Make sure we provide one even if it the header
|
||||
has been removed in the meantime.
|
||||
*/
|
||||
if (!$this->headers->has('Date')) {
|
||||
$this->setDate(\DateTime::createFromFormat('U', time()));
|
||||
}
|
||||
|
||||
return $this->headers->getDate('Date');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Date header.
|
||||
*
|
||||
* @param \DateTime $date A \DateTime instance
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @final since version 3.2
|
||||
|
|
@ -944,7 +960,7 @@ class Response
|
|||
/**
|
||||
* Sets the response's cache headers (validation and/or expiration).
|
||||
*
|
||||
* Available options are: etag, last_modified, max_age, s_maxage, private, and public.
|
||||
* Available options are: etag, last_modified, max_age, s_maxage, private, public and immutable.
|
||||
*
|
||||
* @param array $options An array of cache options
|
||||
*
|
||||
|
|
@ -956,7 +972,7 @@ class Response
|
|||
*/
|
||||
public function setCache(array $options)
|
||||
{
|
||||
if ($diff = array_diff(array_keys($options), array('etag', 'last_modified', 'max_age', 's_maxage', 'private', 'public'))) {
|
||||
if ($diff = array_diff(array_keys($options), array('etag', 'last_modified', 'max_age', 's_maxage', 'private', 'public', 'immutable'))) {
|
||||
throw new \InvalidArgumentException(sprintf('Response does not support the following options: "%s".', implode('", "', array_values($diff))));
|
||||
}
|
||||
|
||||
|
|
@ -992,6 +1008,10 @@ class Response
|
|||
}
|
||||
}
|
||||
|
||||
if (isset($options['immutable'])) {
|
||||
$this->setImmutable((bool) $options['immutable']);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -1077,8 +1097,6 @@ class Response
|
|||
* If the Response is not modified, it sets the status code to 304 and
|
||||
* removes the actual content by calling the setNotModified() method.
|
||||
*
|
||||
* @param Request $request A Request instance
|
||||
*
|
||||
* @return bool true if the Response validators match the Request, false otherwise
|
||||
*
|
||||
* @final since version 3.3
|
||||
|
|
@ -1094,7 +1112,7 @@ class Response
|
|||
$modifiedSince = $request->headers->get('If-Modified-Since');
|
||||
|
||||
if ($etags = $request->getETags()) {
|
||||
$notModified = in_array($this->getEtag(), $etags) || in_array('*', $etags);
|
||||
$notModified = \in_array($this->getEtag(), $etags) || \in_array('*', $etags);
|
||||
}
|
||||
|
||||
if ($modifiedSince && $lastModified) {
|
||||
|
|
@ -1229,7 +1247,7 @@ class Response
|
|||
*/
|
||||
public function isRedirect($location = null)
|
||||
{
|
||||
return in_array($this->statusCode, array(201, 301, 302, 303, 307, 308)) && (null === $location ?: $location == $this->headers->get('Location'));
|
||||
return \in_array($this->statusCode, array(201, 301, 302, 303, 307, 308)) && (null === $location ?: $location == $this->headers->get('Location'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1241,7 +1259,7 @@ class Response
|
|||
*/
|
||||
public function isEmpty()
|
||||
{
|
||||
return in_array($this->statusCode, array(204, 304));
|
||||
return \in_array($this->statusCode, array(204, 304));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1257,11 +1275,11 @@ class Response
|
|||
public static function closeOutputBuffers($targetLevel, $flush)
|
||||
{
|
||||
$status = ob_get_status(true);
|
||||
$level = count($status);
|
||||
$level = \count($status);
|
||||
// PHP_OUTPUT_HANDLER_* are not defined on HHVM 3.3
|
||||
$flags = defined('PHP_OUTPUT_HANDLER_REMOVABLE') ? PHP_OUTPUT_HANDLER_REMOVABLE | ($flush ? PHP_OUTPUT_HANDLER_FLUSHABLE : PHP_OUTPUT_HANDLER_CLEANABLE) : -1;
|
||||
$flags = \defined('PHP_OUTPUT_HANDLER_REMOVABLE') ? PHP_OUTPUT_HANDLER_REMOVABLE | ($flush ? PHP_OUTPUT_HANDLER_FLUSHABLE : PHP_OUTPUT_HANDLER_CLEANABLE) : -1;
|
||||
|
||||
while ($level-- > $targetLevel && ($s = $status[$level]) && (!isset($s['del']) ? !isset($s['flags']) || $flags === ($s['flags'] & $flags) : $s['del'])) {
|
||||
while ($level-- > $targetLevel && ($s = $status[$level]) && (!isset($s['del']) ? !isset($s['flags']) || ($s['flags'] & $flags) === $flags : $s['del'])) {
|
||||
if ($flush) {
|
||||
ob_end_flush();
|
||||
} else {
|
||||
|
|
@ -1279,7 +1297,7 @@ class Response
|
|||
*/
|
||||
protected function ensureIEOverSSLCompatibility(Request $request)
|
||||
{
|
||||
if (false !== stripos($this->headers->get('Content-Disposition'), 'attachment') && preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) == 1 && true === $request->isSecure()) {
|
||||
if (false !== stripos($this->headers->get('Content-Disposition'), 'attachment') && 1 == preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) && true === $request->isSecure()) {
|
||||
if ((int) preg_replace('/(MSIE )(.*?);/', '$2', $match[0]) < 9) {
|
||||
$this->headers->remove('Cache-Control');
|
||||
}
|
||||
|
|
|
|||
49
pfosten/vendor/symfony/http-foundation/ResponseHeaderBag.php
vendored
Executable file → Normal file
49
pfosten/vendor/symfony/http-foundation/ResponseHeaderBag.php
vendored
Executable file → Normal file
|
|
@ -24,26 +24,10 @@ class ResponseHeaderBag extends HeaderBag
|
|||
const DISPOSITION_ATTACHMENT = 'attachment';
|
||||
const DISPOSITION_INLINE = 'inline';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $computedCacheControl = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $cookies = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $headerNames = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $headers An array of HTTP headers
|
||||
*/
|
||||
public function __construct(array $headers = array())
|
||||
{
|
||||
parent::__construct($headers);
|
||||
|
|
@ -51,6 +35,11 @@ class ResponseHeaderBag extends HeaderBag
|
|||
if (!isset($this->headers['cache-control'])) {
|
||||
$this->set('Cache-Control', '');
|
||||
}
|
||||
|
||||
/* RFC2616 - 14.18 says all Responses need to have a Date */
|
||||
if (!isset($this->headers['date'])) {
|
||||
$this->initDate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -90,6 +79,10 @@ class ResponseHeaderBag extends HeaderBag
|
|||
if (!isset($this->headers['cache-control'])) {
|
||||
$this->set('Cache-Control', '');
|
||||
}
|
||||
|
||||
if (!isset($this->headers['date'])) {
|
||||
$this->initDate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -129,7 +122,7 @@ class ResponseHeaderBag extends HeaderBag
|
|||
parent::set($key, $values, $replace);
|
||||
|
||||
// ensure the cache-control header has sensible defaults
|
||||
if (in_array($uniqueKey, array('cache-control', 'etag', 'last-modified', 'expires'))) {
|
||||
if (\in_array($uniqueKey, array('cache-control', 'etag', 'last-modified', 'expires'), true)) {
|
||||
$computed = $this->computeCacheControlValue();
|
||||
$this->headers['cache-control'] = array($computed);
|
||||
$this->headerNames['cache-control'] = 'Cache-Control';
|
||||
|
|
@ -156,6 +149,10 @@ class ResponseHeaderBag extends HeaderBag
|
|||
if ('cache-control' === $uniqueKey) {
|
||||
$this->computedCacheControl = array();
|
||||
}
|
||||
|
||||
if ('date' === $uniqueKey) {
|
||||
$this->initDate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -174,11 +171,6 @@ class ResponseHeaderBag extends HeaderBag
|
|||
return array_key_exists($key, $this->computedCacheControl) ? $this->computedCacheControl[$key] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a cookie.
|
||||
*
|
||||
* @param Cookie $cookie
|
||||
*/
|
||||
public function setCookie(Cookie $cookie)
|
||||
{
|
||||
$this->cookies[$cookie->getDomain()][$cookie->getPath()][$cookie->getName()] = $cookie;
|
||||
|
|
@ -218,13 +210,13 @@ class ResponseHeaderBag extends HeaderBag
|
|||
*
|
||||
* @param string $format
|
||||
*
|
||||
* @return array
|
||||
* @return Cookie[]
|
||||
*
|
||||
* @throws \InvalidArgumentException When the $format is invalid
|
||||
*/
|
||||
public function getCookies($format = self::COOKIES_FLAT)
|
||||
{
|
||||
if (!in_array($format, array(self::COOKIES_FLAT, self::COOKIES_ARRAY))) {
|
||||
if (!\in_array($format, array(self::COOKIES_FLAT, self::COOKIES_ARRAY))) {
|
||||
throw new \InvalidArgumentException(sprintf('Format "%s" invalid (%s).', $format, implode(', ', array(self::COOKIES_FLAT, self::COOKIES_ARRAY))));
|
||||
}
|
||||
|
||||
|
|
@ -275,7 +267,7 @@ class ResponseHeaderBag extends HeaderBag
|
|||
*/
|
||||
public function makeDisposition($disposition, $filename, $filenameFallback = '')
|
||||
{
|
||||
if (!in_array($disposition, array(self::DISPOSITION_ATTACHMENT, self::DISPOSITION_INLINE))) {
|
||||
if (!\in_array($disposition, array(self::DISPOSITION_ATTACHMENT, self::DISPOSITION_INLINE))) {
|
||||
throw new \InvalidArgumentException(sprintf('The disposition must be either "%s" or "%s".', self::DISPOSITION_ATTACHMENT, self::DISPOSITION_INLINE));
|
||||
}
|
||||
|
||||
|
|
@ -338,4 +330,11 @@ class ResponseHeaderBag extends HeaderBag
|
|||
|
||||
return $header;
|
||||
}
|
||||
|
||||
private function initDate()
|
||||
{
|
||||
$now = \DateTime::createFromFormat('U', time());
|
||||
$now->setTimezone(new \DateTimeZone('UTC'));
|
||||
$this->set('Date', $now->format('D, d M Y H:i:s').' GMT');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
pfosten/vendor/symfony/http-foundation/ServerBag.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/http-foundation/ServerBag.php
vendored
Executable file → Normal file
|
|
@ -68,7 +68,7 @@ class ServerBag extends ParameterBag
|
|||
if (0 === stripos($authorizationHeader, 'basic ')) {
|
||||
// Decode AUTHORIZATION header into PHP_AUTH_USER and PHP_AUTH_PW when authorization header is basic
|
||||
$exploded = explode(':', base64_decode(substr($authorizationHeader, 6)), 2);
|
||||
if (count($exploded) == 2) {
|
||||
if (2 == \count($exploded)) {
|
||||
list($headers['PHP_AUTH_USER'], $headers['PHP_AUTH_PW']) = $exploded;
|
||||
}
|
||||
} elseif (empty($this->parameters['PHP_AUTH_DIGEST']) && (0 === stripos($authorizationHeader, 'digest '))) {
|
||||
|
|
|
|||
11
pfosten/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php
vendored
Executable file → Normal file
11
pfosten/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php
vendored
Executable file → Normal file
|
|
@ -17,20 +17,11 @@ namespace Symfony\Component\HttpFoundation\Session\Attribute;
|
|||
class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Countable
|
||||
{
|
||||
private $name = 'attributes';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $storageKey;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $attributes = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $storageKey The key used to store attributes in the session
|
||||
*/
|
||||
public function __construct($storageKey = '_sf2_attributes')
|
||||
|
|
@ -152,6 +143,6 @@ class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Counta
|
|||
*/
|
||||
public function count()
|
||||
{
|
||||
return count($this->attributes);
|
||||
return \count($this->attributes);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/http-foundation/Session/Attribute/AttributeBagInterface.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/Session/Attribute/AttributeBagInterface.php
vendored
Executable file → Normal file
21
pfosten/vendor/symfony/http-foundation/Session/Attribute/NamespacedAttributeBag.php
vendored
Executable file → Normal file
21
pfosten/vendor/symfony/http-foundation/Session/Attribute/NamespacedAttributeBag.php
vendored
Executable file → Normal file
|
|
@ -19,16 +19,9 @@ namespace Symfony\Component\HttpFoundation\Session\Attribute;
|
|||
*/
|
||||
class NamespacedAttributeBag extends AttributeBag
|
||||
{
|
||||
/**
|
||||
* Namespace character.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $namespaceCharacter;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $storageKey Session storage key
|
||||
* @param string $namespaceCharacter Namespace character to use in keys
|
||||
*/
|
||||
|
|
@ -109,7 +102,7 @@ class NamespacedAttributeBag extends AttributeBag
|
|||
protected function &resolveAttributePath($name, $writeContext = false)
|
||||
{
|
||||
$array = &$this->attributes;
|
||||
$name = (strpos($name, $this->namespaceCharacter) === 0) ? substr($name, 1) : $name;
|
||||
$name = (0 === strpos($name, $this->namespaceCharacter)) ? substr($name, 1) : $name;
|
||||
|
||||
// Check if there is anything to do, else return
|
||||
if (!$name) {
|
||||
|
|
@ -117,7 +110,7 @@ class NamespacedAttributeBag extends AttributeBag
|
|||
}
|
||||
|
||||
$parts = explode($this->namespaceCharacter, $name);
|
||||
if (count($parts) < 2) {
|
||||
if (\count($parts) < 2) {
|
||||
if (!$writeContext) {
|
||||
return $array;
|
||||
}
|
||||
|
|
@ -127,11 +120,17 @@ class NamespacedAttributeBag extends AttributeBag
|
|||
return $array;
|
||||
}
|
||||
|
||||
unset($parts[count($parts) - 1]);
|
||||
unset($parts[\count($parts) - 1]);
|
||||
|
||||
foreach ($parts as $part) {
|
||||
if (null !== $array && !array_key_exists($part, $array)) {
|
||||
$array[$part] = $writeContext ? array() : null;
|
||||
if (!$writeContext) {
|
||||
$null = null;
|
||||
|
||||
return $null;
|
||||
}
|
||||
|
||||
$array[$part] = array();
|
||||
}
|
||||
|
||||
$array = &$array[$part];
|
||||
|
|
|
|||
18
pfosten/vendor/symfony/http-foundation/Session/Flash/AutoExpireFlashBag.php
vendored
Executable file → Normal file
18
pfosten/vendor/symfony/http-foundation/Session/Flash/AutoExpireFlashBag.php
vendored
Executable file → Normal file
|
|
@ -19,27 +19,13 @@ namespace Symfony\Component\HttpFoundation\Session\Flash;
|
|||
class AutoExpireFlashBag implements FlashBagInterface
|
||||
{
|
||||
private $name = 'flashes';
|
||||
|
||||
/**
|
||||
* Flash messages.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $flashes = array('display' => array(), 'new' => array());
|
||||
|
||||
/**
|
||||
* The storage key for flashes in the session.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $storageKey;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $storageKey The key used to store flashes in the session
|
||||
*/
|
||||
public function __construct($storageKey = '_sf2_flashes')
|
||||
public function __construct($storageKey = '_symfony_flashes')
|
||||
{
|
||||
$this->storageKey = $storageKey;
|
||||
}
|
||||
|
|
@ -120,7 +106,7 @@ class AutoExpireFlashBag implements FlashBagInterface
|
|||
public function all()
|
||||
{
|
||||
$return = $this->flashes['display'];
|
||||
$this->flashes = array('new' => array(), 'display' => array());
|
||||
$this->flashes['display'] = array();
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
|
|
|||
16
pfosten/vendor/symfony/http-foundation/Session/Flash/FlashBag.php
vendored
Executable file → Normal file
16
pfosten/vendor/symfony/http-foundation/Session/Flash/FlashBag.php
vendored
Executable file → Normal file
|
|
@ -19,27 +19,13 @@ namespace Symfony\Component\HttpFoundation\Session\Flash;
|
|||
class FlashBag implements FlashBagInterface
|
||||
{
|
||||
private $name = 'flashes';
|
||||
|
||||
/**
|
||||
* Flash messages.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $flashes = array();
|
||||
|
||||
/**
|
||||
* The storage key for flashes in the session.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $storageKey;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $storageKey The key used to store flashes in the session
|
||||
*/
|
||||
public function __construct($storageKey = '_sf2_flashes')
|
||||
public function __construct($storageKey = '_symfony_flashes')
|
||||
{
|
||||
$this->storageKey = $storageKey;
|
||||
}
|
||||
|
|
|
|||
4
pfosten/vendor/symfony/http-foundation/Session/Flash/FlashBagInterface.php
vendored
Executable file → Normal file
4
pfosten/vendor/symfony/http-foundation/Session/Flash/FlashBagInterface.php
vendored
Executable file → Normal file
|
|
@ -24,7 +24,7 @@ interface FlashBagInterface extends SessionBagInterface
|
|||
* Adds a flash message for type.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $message
|
||||
* @param mixed $message
|
||||
*/
|
||||
public function add($type, $message);
|
||||
|
||||
|
|
@ -72,8 +72,6 @@ interface FlashBagInterface extends SessionBagInterface
|
|||
|
||||
/**
|
||||
* Sets all flash messages.
|
||||
*
|
||||
* @param array $messages
|
||||
*/
|
||||
public function setAll(array $messages);
|
||||
|
||||
|
|
|
|||
61
pfosten/vendor/symfony/http-foundation/Session/Session.php
vendored
Executable file → Normal file
61
pfosten/vendor/symfony/http-foundation/Session/Session.php
vendored
Executable file → Normal file
|
|
@ -11,41 +11,27 @@
|
|||
|
||||
namespace Symfony\Component\HttpFoundation\Session;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface;
|
||||
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag;
|
||||
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBagInterface;
|
||||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
|
||||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface;
|
||||
|
||||
/**
|
||||
* Session.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Drak <drak@zikula.org>
|
||||
*/
|
||||
class Session implements SessionInterface, \IteratorAggregate, \Countable
|
||||
{
|
||||
/**
|
||||
* Storage driver.
|
||||
*
|
||||
* @var SessionStorageInterface
|
||||
*/
|
||||
protected $storage;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $flashName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $attributeName;
|
||||
private $data = array();
|
||||
private $usageIndex = 0;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param SessionStorageInterface $storage A SessionStorageInterface instance
|
||||
* @param AttributeBagInterface $attributes An AttributeBagInterface instance, (defaults null for default AttributeBag)
|
||||
* @param FlashBagInterface $flashes A FlashBagInterface instance (defaults null for default FlashBag)
|
||||
|
|
@ -124,7 +110,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
|
|||
*/
|
||||
public function clear()
|
||||
{
|
||||
$this->storage->getBag($this->attributeName)->clear();
|
||||
$this->getAttributeBag()->clear();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -152,7 +138,36 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
|
|||
*/
|
||||
public function count()
|
||||
{
|
||||
return count($this->getAttributeBag()->all());
|
||||
return \count($this->getAttributeBag()->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function getUsageIndex()
|
||||
{
|
||||
return $this->usageIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function isEmpty()
|
||||
{
|
||||
if ($this->isStarted()) {
|
||||
++$this->usageIndex;
|
||||
}
|
||||
foreach ($this->data as &$data) {
|
||||
if (!empty($data)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -218,6 +233,8 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
|
|||
*/
|
||||
public function getMetadataBag()
|
||||
{
|
||||
++$this->usageIndex;
|
||||
|
||||
return $this->storage->getMetadataBag();
|
||||
}
|
||||
|
||||
|
|
@ -226,7 +243,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
|
|||
*/
|
||||
public function registerBag(SessionBagInterface $bag)
|
||||
{
|
||||
$this->storage->registerBag($bag);
|
||||
$this->storage->registerBag(new SessionBagProxy($bag, $this->data, $this->usageIndex));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -234,7 +251,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
|
|||
*/
|
||||
public function getBag($name)
|
||||
{
|
||||
return $this->storage->getBag($name);
|
||||
return $this->storage->getBag($name)->getBag();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -256,6 +273,6 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
|
|||
*/
|
||||
private function getAttributeBag()
|
||||
{
|
||||
return $this->storage->getBag($this->attributeName);
|
||||
return $this->getBag($this->attributeName);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
pfosten/vendor/symfony/http-foundation/Session/SessionBagInterface.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/http-foundation/Session/SessionBagInterface.php
vendored
Executable file → Normal file
|
|
@ -27,8 +27,6 @@ interface SessionBagInterface
|
|||
|
||||
/**
|
||||
* Initializes the Bag.
|
||||
*
|
||||
* @param array $array
|
||||
*/
|
||||
public function initialize(array &$array);
|
||||
|
||||
|
|
|
|||
4
pfosten/vendor/symfony/http-foundation/Session/SessionInterface.php
vendored
Executable file → Normal file
4
pfosten/vendor/symfony/http-foundation/Session/SessionInterface.php
vendored
Executable file → Normal file
|
|
@ -25,7 +25,7 @@ interface SessionInterface
|
|||
*
|
||||
* @return bool True if session started
|
||||
*
|
||||
* @throws \RuntimeException If session fails to start.
|
||||
* @throws \RuntimeException if session fails to start
|
||||
*/
|
||||
public function start();
|
||||
|
||||
|
|
@ -159,8 +159,6 @@ interface SessionInterface
|
|||
|
||||
/**
|
||||
* Registers a SessionBagInterface with the session.
|
||||
*
|
||||
* @param SessionBagInterface $bag
|
||||
*/
|
||||
public function registerBag(SessionBagInterface $bag);
|
||||
|
||||
|
|
|
|||
13
pfosten/vendor/symfony/http-foundation/Session/Storage/Handler/MemcacheSessionHandler.php
vendored
Executable file → Normal file
13
pfosten/vendor/symfony/http-foundation/Session/Storage/Handler/MemcacheSessionHandler.php
vendored
Executable file → Normal file
|
|
@ -11,16 +11,15 @@
|
|||
|
||||
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
|
||||
|
||||
@trigger_error(sprintf('The class %s is deprecated since Symfony 3.4 and will be removed in 4.0. Use Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler instead.', MemcacheSessionHandler::class), E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* MemcacheSessionHandler.
|
||||
*
|
||||
* @author Drak <drak@zikula.org>
|
||||
*
|
||||
* @deprecated since version 3.4, to be removed in 4.0. Use Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler instead.
|
||||
*/
|
||||
class MemcacheSessionHandler implements \SessionHandlerInterface
|
||||
{
|
||||
/**
|
||||
* @var \Memcache Memcache driver
|
||||
*/
|
||||
private $memcache;
|
||||
|
||||
/**
|
||||
|
|
@ -95,7 +94,9 @@ class MemcacheSessionHandler implements \SessionHandlerInterface
|
|||
*/
|
||||
public function destroy($sessionId)
|
||||
{
|
||||
return $this->memcache->delete($this->prefix.$sessionId);
|
||||
$this->memcache->delete($this->prefix.$sessionId);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
37
pfosten/vendor/symfony/http-foundation/Session/Storage/Handler/MemcachedSessionHandler.php
vendored
Executable file → Normal file
37
pfosten/vendor/symfony/http-foundation/Session/Storage/Handler/MemcachedSessionHandler.php
vendored
Executable file → Normal file
|
|
@ -12,8 +12,6 @@
|
|||
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
|
||||
|
||||
/**
|
||||
* MemcachedSessionHandler.
|
||||
*
|
||||
* Memcached based session storage handler based on the Memcached class
|
||||
* provided by the PHP memcached extension.
|
||||
*
|
||||
|
|
@ -21,11 +19,8 @@ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
|
|||
*
|
||||
* @author Drak <drak@zikula.org>
|
||||
*/
|
||||
class MemcachedSessionHandler implements \SessionHandlerInterface
|
||||
class MemcachedSessionHandler extends AbstractSessionHandler
|
||||
{
|
||||
/**
|
||||
* @var \Memcached Memcached driver
|
||||
*/
|
||||
private $memcached;
|
||||
|
||||
/**
|
||||
|
|
@ -43,7 +38,7 @@ class MemcachedSessionHandler implements \SessionHandlerInterface
|
|||
*
|
||||
* List of available options:
|
||||
* * prefix: The prefix to use for the memcached keys in order to avoid collision
|
||||
* * expiretime: The time to live in seconds
|
||||
* * expiretime: The time to live in seconds.
|
||||
*
|
||||
* @param \Memcached $memcached A \Memcached instance
|
||||
* @param array $options An associative array of Memcached options
|
||||
|
|
@ -64,14 +59,6 @@ class MemcachedSessionHandler implements \SessionHandlerInterface
|
|||
$this->prefix = isset($options['prefix']) ? $options['prefix'] : 'sf2s';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function open($savePath, $sessionName)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -83,7 +70,7 @@ class MemcachedSessionHandler implements \SessionHandlerInterface
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function read($sessionId)
|
||||
protected function doRead($sessionId)
|
||||
{
|
||||
return $this->memcached->get($this->prefix.$sessionId) ?: '';
|
||||
}
|
||||
|
|
@ -91,7 +78,17 @@ class MemcachedSessionHandler implements \SessionHandlerInterface
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function write($sessionId, $data)
|
||||
public function updateTimestamp($sessionId, $data)
|
||||
{
|
||||
$this->memcached->touch($this->prefix.$sessionId, time() + $this->ttl);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doWrite($sessionId, $data)
|
||||
{
|
||||
return $this->memcached->set($this->prefix.$sessionId, $data, time() + $this->ttl);
|
||||
}
|
||||
|
|
@ -99,9 +96,11 @@ class MemcachedSessionHandler implements \SessionHandlerInterface
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function destroy($sessionId)
|
||||
protected function doDestroy($sessionId)
|
||||
{
|
||||
return $this->memcached->delete($this->prefix.$sessionId);
|
||||
$result = $this->memcached->delete($this->prefix.$sessionId);
|
||||
|
||||
return $result || \Memcached::RES_NOTFOUND == $this->memcached->getResultCode();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
63
pfosten/vendor/symfony/http-foundation/Session/Storage/Handler/MongoDbSessionHandler.php
vendored
Executable file → Normal file
63
pfosten/vendor/symfony/http-foundation/Session/Storage/Handler/MongoDbSessionHandler.php
vendored
Executable file → Normal file
|
|
@ -12,15 +12,15 @@
|
|||
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
|
||||
|
||||
/**
|
||||
* MongoDB session handler.
|
||||
* Session handler using the mongodb/mongodb package and MongoDB driver extension.
|
||||
*
|
||||
* @author Markus Bachmann <markus.bachmann@bachi.biz>
|
||||
*
|
||||
* @see https://packagist.org/packages/mongodb/mongodb
|
||||
* @see http://php.net/manual/en/set.mongodb.php
|
||||
*/
|
||||
class MongoDbSessionHandler implements \SessionHandlerInterface
|
||||
class MongoDbSessionHandler extends AbstractSessionHandler
|
||||
{
|
||||
/**
|
||||
* @var \Mongo|\MongoClient|\MongoDB\Client
|
||||
*/
|
||||
private $mongo;
|
||||
|
||||
/**
|
||||
|
|
@ -42,7 +42,7 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
|
|||
* * id_field: The field name for storing the session id [default: _id]
|
||||
* * data_field: The field name for storing the session data [default: data]
|
||||
* * time_field: The field name for storing the timestamp [default: time]
|
||||
* * expiry_field: The field name for storing the expiry-timestamp [default: expires_at]
|
||||
* * expiry_field: The field name for storing the expiry-timestamp [default: expires_at].
|
||||
*
|
||||
* It is strongly recommended to put an index on the `expiry_field` for
|
||||
* garbage-collection. Alternatively it's possible to automatically expire
|
||||
|
|
@ -61,14 +61,18 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
|
|||
* If you use such an index, you can drop `gc_probability` to 0 since
|
||||
* no garbage-collection is required.
|
||||
*
|
||||
* @param \Mongo|\MongoClient|\MongoDB\Client $mongo A MongoDB\Client, MongoClient or Mongo instance
|
||||
* @param array $options An associative array of field options
|
||||
* @param \MongoDB\Client $mongo A MongoDB\Client instance
|
||||
* @param array $options An associative array of field options
|
||||
*
|
||||
* @throws \InvalidArgumentException When MongoClient or Mongo instance not provided
|
||||
* @throws \InvalidArgumentException When "database" or "collection" not provided
|
||||
*/
|
||||
public function __construct($mongo, array $options)
|
||||
{
|
||||
if ($mongo instanceof \MongoClient || $mongo instanceof \Mongo) {
|
||||
@trigger_error(sprintf('Using %s with the legacy mongo extension is deprecated as of 3.4 and will be removed in 4.0. Use it with the mongodb/mongodb package and ext-mongodb instead.', __CLASS__), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
if (!($mongo instanceof \MongoDB\Client || $mongo instanceof \MongoClient || $mongo instanceof \Mongo)) {
|
||||
throw new \InvalidArgumentException('MongoClient or Mongo instance required');
|
||||
}
|
||||
|
|
@ -87,14 +91,6 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
|
|||
), $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function open($savePath, $sessionName)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -106,7 +102,7 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function destroy($sessionId)
|
||||
protected function doDestroy($sessionId)
|
||||
{
|
||||
$methodName = $this->mongo instanceof \MongoDB\Client ? 'deleteOne' : 'remove';
|
||||
|
||||
|
|
@ -122,7 +118,7 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
|
|||
*/
|
||||
public function gc($maxlifetime)
|
||||
{
|
||||
$methodName = $this->mongo instanceof \MongoDB\Client ? 'deleteOne' : 'remove';
|
||||
$methodName = $this->mongo instanceof \MongoDB\Client ? 'deleteMany' : 'remove';
|
||||
|
||||
$this->getCollection()->$methodName(array(
|
||||
$this->options['expiry_field'] => array('$lt' => $this->createDateTime()),
|
||||
|
|
@ -134,7 +130,7 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function write($sessionId, $data)
|
||||
protected function doWrite($sessionId, $data)
|
||||
{
|
||||
$expiry = $this->createDateTime(time() + (int) ini_get('session.gc_maxlifetime'));
|
||||
|
||||
|
|
@ -166,7 +162,34 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function read($sessionId)
|
||||
public function updateTimestamp($sessionId, $data)
|
||||
{
|
||||
$expiry = $this->createDateTime(time() + (int) ini_get('session.gc_maxlifetime'));
|
||||
|
||||
if ($this->mongo instanceof \MongoDB\Client) {
|
||||
$methodName = 'updateOne';
|
||||
$options = array();
|
||||
} else {
|
||||
$methodName = 'update';
|
||||
$options = array('multiple' => false);
|
||||
}
|
||||
|
||||
$this->getCollection()->$methodName(
|
||||
array($this->options['id_field'] => $sessionId),
|
||||
array('$set' => array(
|
||||
$this->options['time_field'] => $this->createDateTime(),
|
||||
$this->options['expiry_field'] => $expiry,
|
||||
)),
|
||||
$options
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doRead($sessionId)
|
||||
{
|
||||
$dbData = $this->getCollection()->findOne(array(
|
||||
$this->options['id_field'] => $sessionId,
|
||||
|
|
|
|||
5
pfosten/vendor/symfony/http-foundation/Session/Storage/Handler/NativeFileSessionHandler.php
vendored
Executable file → Normal file
5
pfosten/vendor/symfony/http-foundation/Session/Storage/Handler/NativeFileSessionHandler.php
vendored
Executable file → Normal file
|
|
@ -12,8 +12,6 @@
|
|||
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
|
||||
|
||||
/**
|
||||
* NativeFileSessionHandler.
|
||||
*
|
||||
* Native session handler using PHP's built in file storage.
|
||||
*
|
||||
* @author Drak <drak@zikula.org>
|
||||
|
|
@ -21,8 +19,6 @@ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
|
|||
class NativeFileSessionHandler extends NativeSessionHandler
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $savePath Path of directory to save session files
|
||||
* Default null will leave setting as defined by PHP.
|
||||
* '/path', 'N;/path', or 'N;octal-mode;/path
|
||||
|
|
@ -30,6 +26,7 @@ class NativeFileSessionHandler extends NativeSessionHandler
|
|||
* @see http://php.net/session.configuration.php#ini.session.save-path for further details.
|
||||
*
|
||||
* @throws \InvalidArgumentException On invalid $savePath
|
||||
* @throws \RuntimeException When failing to create the save directory
|
||||
*/
|
||||
public function __construct($savePath = null)
|
||||
{
|
||||
|
|
|
|||
7
pfosten/vendor/symfony/http-foundation/Session/Storage/Handler/NativeSessionHandler.php
vendored
Executable file → Normal file
7
pfosten/vendor/symfony/http-foundation/Session/Storage/Handler/NativeSessionHandler.php
vendored
Executable file → Normal file
|
|
@ -12,10 +12,13 @@
|
|||
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
|
||||
|
||||
/**
|
||||
* Adds SessionHandler functionality if available.
|
||||
*
|
||||
* @deprecated since version 3.4, to be removed in 4.0. Use \SessionHandler instead.
|
||||
* @see http://php.net/sessionhandler
|
||||
*/
|
||||
class NativeSessionHandler extends \SessionHandler
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
@trigger_error('The '.__NAMESPACE__.'\NativeSessionHandler class is deprecated since Symfony 3.4 and will be removed in 4.0. Use the \SessionHandler class instead.', E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
48
pfosten/vendor/symfony/http-foundation/Session/Storage/Handler/NullSessionHandler.php
vendored
Executable file → Normal file
48
pfosten/vendor/symfony/http-foundation/Session/Storage/Handler/NullSessionHandler.php
vendored
Executable file → Normal file
|
|
@ -12,22 +12,12 @@
|
|||
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
|
||||
|
||||
/**
|
||||
* NullSessionHandler.
|
||||
*
|
||||
* Can be used in unit testing or in a situations where persisted sessions are not desired.
|
||||
*
|
||||
* @author Drak <drak@zikula.org>
|
||||
*/
|
||||
class NullSessionHandler implements \SessionHandlerInterface
|
||||
class NullSessionHandler extends AbstractSessionHandler
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function open($savePath, $sessionName)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -39,15 +29,7 @@ class NullSessionHandler implements \SessionHandlerInterface
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function read($sessionId)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function write($sessionId, $data)
|
||||
public function validateId($sessionId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
@ -55,7 +37,31 @@ class NullSessionHandler implements \SessionHandlerInterface
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function destroy($sessionId)
|
||||
protected function doRead($sessionId)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function updateTimestamp($sessionId, $data)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doWrite($sessionId, $data)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDestroy($sessionId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
335
pfosten/vendor/symfony/http-foundation/Session/Storage/Handler/PdoSessionHandler.php
vendored
Executable file → Normal file
335
pfosten/vendor/symfony/http-foundation/Session/Storage/Handler/PdoSessionHandler.php
vendored
Executable file → Normal file
|
|
@ -38,7 +38,7 @@ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
|
|||
* @author Michael Williams <michael.williams@funsational.com>
|
||||
* @author Tobias Schultze <http://tobion.de>
|
||||
*/
|
||||
class PdoSessionHandler implements \SessionHandlerInterface
|
||||
class PdoSessionHandler extends AbstractSessionHandler
|
||||
{
|
||||
/**
|
||||
* No locking is done. This means sessions are prone to loss of data due to
|
||||
|
|
@ -148,8 +148,6 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
|||
private $gcCalled = false;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* You can either pass an existing database connection as PDO instance or
|
||||
* pass a DSN string that will be used to lazy-connect to the database
|
||||
* when the session is actually used. Furthermore it's possible to pass null
|
||||
|
|
@ -166,7 +164,7 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
|||
* * db_connection_options: An array of driver-specific connection options [default: array()]
|
||||
* * lock_mode: The strategy for locking, see constants [default: LOCK_TRANSACTIONAL]
|
||||
*
|
||||
* @param \PDO|string|null $pdoOrDsn A \PDO instance or DSN string or null
|
||||
* @param \PDO|string|null $pdoOrDsn A \PDO instance or DSN string or URL string or null
|
||||
* @param array $options An associative array of options
|
||||
*
|
||||
* @throws \InvalidArgumentException When PDO error mode is not PDO::ERRMODE_EXCEPTION
|
||||
|
|
@ -180,6 +178,8 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
|||
|
||||
$this->pdo = $pdoOrDsn;
|
||||
$this->driver = $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME);
|
||||
} elseif (\is_string($pdoOrDsn) && false !== strpos($pdoOrDsn, '://')) {
|
||||
$this->dsn = $this->buildDsnFromUrl($pdoOrDsn);
|
||||
} else {
|
||||
$this->dsn = $pdoOrDsn;
|
||||
}
|
||||
|
|
@ -262,11 +262,13 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
|||
*/
|
||||
public function open($savePath, $sessionName)
|
||||
{
|
||||
$this->sessionExpired = false;
|
||||
|
||||
if (null === $this->pdo) {
|
||||
$this->connect($this->dsn ?: $savePath);
|
||||
}
|
||||
|
||||
return true;
|
||||
return parent::open($savePath, $sessionName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -275,7 +277,7 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
|||
public function read($sessionId)
|
||||
{
|
||||
try {
|
||||
return $this->doRead($sessionId);
|
||||
return parent::read($sessionId);
|
||||
} catch (\PDOException $e) {
|
||||
$this->rollback();
|
||||
|
||||
|
|
@ -298,7 +300,7 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function destroy($sessionId)
|
||||
protected function doDestroy($sessionId)
|
||||
{
|
||||
// delete the record associated with this id
|
||||
$sql = "DELETE FROM $this->table WHERE $this->idCol = :id";
|
||||
|
|
@ -319,7 +321,7 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function write($sessionId, $data)
|
||||
protected function doWrite($sessionId, $data)
|
||||
{
|
||||
$maxlifetime = (int) ini_get('session.gc_maxlifetime');
|
||||
|
||||
|
|
@ -332,13 +334,7 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
|||
return true;
|
||||
}
|
||||
|
||||
$updateStmt = $this->pdo->prepare(
|
||||
"UPDATE $this->table SET $this->dataCol = :data, $this->lifetimeCol = :lifetime, $this->timeCol = :time WHERE $this->idCol = :id"
|
||||
);
|
||||
$updateStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR);
|
||||
$updateStmt->bindParam(':data', $data, \PDO::PARAM_LOB);
|
||||
$updateStmt->bindParam(':lifetime', $maxlifetime, \PDO::PARAM_INT);
|
||||
$updateStmt->bindValue(':time', time(), \PDO::PARAM_INT);
|
||||
$updateStmt = $this->getUpdateStatement($sessionId, $data, $maxlifetime);
|
||||
$updateStmt->execute();
|
||||
|
||||
// When MERGE is not supported, like in Postgres < 9.5, we have to use this approach that can result in
|
||||
|
|
@ -348,13 +344,7 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
|||
// false positives due to longer gap locking.
|
||||
if (!$updateStmt->rowCount()) {
|
||||
try {
|
||||
$insertStmt = $this->pdo->prepare(
|
||||
"INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time)"
|
||||
);
|
||||
$insertStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR);
|
||||
$insertStmt->bindParam(':data', $data, \PDO::PARAM_LOB);
|
||||
$insertStmt->bindParam(':lifetime', $maxlifetime, \PDO::PARAM_INT);
|
||||
$insertStmt->bindValue(':time', time(), \PDO::PARAM_INT);
|
||||
$insertStmt = $this->getInsertStatement($sessionId, $data, $maxlifetime);
|
||||
$insertStmt->execute();
|
||||
} catch (\PDOException $e) {
|
||||
// Handle integrity violation SQLSTATE 23000 (or a subclass like 23505 in Postgres) for duplicate keys
|
||||
|
|
@ -374,6 +364,30 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function updateTimestamp($sessionId, $data)
|
||||
{
|
||||
$maxlifetime = (int) ini_get('session.gc_maxlifetime');
|
||||
|
||||
try {
|
||||
$updateStmt = $this->pdo->prepare(
|
||||
"UPDATE $this->table SET $this->lifetimeCol = :lifetime, $this->timeCol = :time WHERE $this->idCol = :id"
|
||||
);
|
||||
$updateStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR);
|
||||
$updateStmt->bindParam(':lifetime', $maxlifetime, \PDO::PARAM_INT);
|
||||
$updateStmt->bindValue(':time', time(), \PDO::PARAM_INT);
|
||||
$updateStmt->execute();
|
||||
} catch (\PDOException $e) {
|
||||
$this->rollback();
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -389,7 +403,11 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
|||
$this->gcCalled = false;
|
||||
|
||||
// delete the session records that have expired
|
||||
$sql = "DELETE FROM $this->table WHERE $this->lifetimeCol + $this->timeCol < :time";
|
||||
if ('mysql' === $this->driver) {
|
||||
$sql = "DELETE FROM $this->table WHERE $this->lifetimeCol + $this->timeCol < :time";
|
||||
} else {
|
||||
$sql = "DELETE FROM $this->table WHERE $this->lifetimeCol < :time - $this->timeCol";
|
||||
}
|
||||
|
||||
$stmt = $this->pdo->prepare($sql);
|
||||
$stmt->bindValue(':time', time(), \PDO::PARAM_INT);
|
||||
|
|
@ -415,6 +433,102 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
|||
$this->driver = $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a PDO DSN from a URL-like connection string.
|
||||
*
|
||||
* @param string $dsnOrUrl
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @todo implement missing support for oci DSN (which look totally different from other PDO ones)
|
||||
*/
|
||||
private function buildDsnFromUrl($dsnOrUrl)
|
||||
{
|
||||
// (pdo_)?sqlite3?:///... => (pdo_)?sqlite3?://localhost/... or else the URL will be invalid
|
||||
$url = preg_replace('#^((?:pdo_)?sqlite3?):///#', '$1://localhost/', $dsnOrUrl);
|
||||
|
||||
$params = parse_url($url);
|
||||
|
||||
if (false === $params) {
|
||||
return $dsnOrUrl; // If the URL is not valid, let's assume it might be a DSN already.
|
||||
}
|
||||
|
||||
$params = array_map('rawurldecode', $params);
|
||||
|
||||
// Override the default username and password. Values passed through options will still win over these in the constructor.
|
||||
if (isset($params['user'])) {
|
||||
$this->username = $params['user'];
|
||||
}
|
||||
|
||||
if (isset($params['pass'])) {
|
||||
$this->password = $params['pass'];
|
||||
}
|
||||
|
||||
if (!isset($params['scheme'])) {
|
||||
throw new \InvalidArgumentException('URLs without scheme are not supported to configure the PdoSessionHandler');
|
||||
}
|
||||
|
||||
$driverAliasMap = array(
|
||||
'mssql' => 'sqlsrv',
|
||||
'mysql2' => 'mysql', // Amazon RDS, for some weird reason
|
||||
'postgres' => 'pgsql',
|
||||
'postgresql' => 'pgsql',
|
||||
'sqlite3' => 'sqlite',
|
||||
);
|
||||
|
||||
$driver = isset($driverAliasMap[$params['scheme']]) ? $driverAliasMap[$params['scheme']] : $params['scheme'];
|
||||
|
||||
// Doctrine DBAL supports passing its internal pdo_* driver names directly too (allowing both dashes and underscores). This allows supporting the same here.
|
||||
if (0 === strpos($driver, 'pdo_') || 0 === strpos($driver, 'pdo-')) {
|
||||
$driver = substr($driver, 4);
|
||||
}
|
||||
|
||||
switch ($driver) {
|
||||
case 'mysql':
|
||||
case 'pgsql':
|
||||
$dsn = $driver.':';
|
||||
|
||||
if (isset($params['host']) && '' !== $params['host']) {
|
||||
$dsn .= 'host='.$params['host'].';';
|
||||
}
|
||||
|
||||
if (isset($params['port']) && '' !== $params['port']) {
|
||||
$dsn .= 'port='.$params['port'].';';
|
||||
}
|
||||
|
||||
if (isset($params['path'])) {
|
||||
$dbName = substr($params['path'], 1); // Remove the leading slash
|
||||
$dsn .= 'dbname='.$dbName.';';
|
||||
}
|
||||
|
||||
return $dsn;
|
||||
|
||||
case 'sqlite':
|
||||
return 'sqlite:'.substr($params['path'], 1);
|
||||
|
||||
case 'sqlsrv':
|
||||
$dsn = 'sqlsrv:server=';
|
||||
|
||||
if (isset($params['host'])) {
|
||||
$dsn .= $params['host'];
|
||||
}
|
||||
|
||||
if (isset($params['port']) && '' !== $params['port']) {
|
||||
$dsn .= ','.$params['port'];
|
||||
}
|
||||
|
||||
if (isset($params['path'])) {
|
||||
$dbName = substr($params['path'], 1); // Remove the leading slash
|
||||
$dsn .= ';Database='.$dbName;
|
||||
}
|
||||
|
||||
return $dsn;
|
||||
|
||||
default:
|
||||
throw new \InvalidArgumentException(sprintf('The scheme "%s" is not supported by the PdoSessionHandler URL configuration. Pass a PDO DSN directly.', $params['scheme']));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to begin a transaction.
|
||||
*
|
||||
|
|
@ -493,10 +607,8 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
|||
*
|
||||
* @return string The session data
|
||||
*/
|
||||
private function doRead($sessionId)
|
||||
protected function doRead($sessionId)
|
||||
{
|
||||
$this->sessionExpired = false;
|
||||
|
||||
if (self::LOCK_ADVISORY === $this->lockMode) {
|
||||
$this->unlockStatements[] = $this->doAdvisoryLock($sessionId);
|
||||
}
|
||||
|
|
@ -504,6 +616,7 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
|||
$selectSql = $this->getSelectSql();
|
||||
$selectStmt = $this->pdo->prepare($selectSql);
|
||||
$selectStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR);
|
||||
$insertStmt = null;
|
||||
|
||||
do {
|
||||
$selectStmt->execute();
|
||||
|
|
@ -516,20 +629,21 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
|||
return '';
|
||||
}
|
||||
|
||||
return is_resource($sessionRows[0][0]) ? stream_get_contents($sessionRows[0][0]) : $sessionRows[0][0];
|
||||
return \is_resource($sessionRows[0][0]) ? stream_get_contents($sessionRows[0][0]) : $sessionRows[0][0];
|
||||
}
|
||||
|
||||
if (self::LOCK_TRANSACTIONAL === $this->lockMode && 'sqlite' !== $this->driver) {
|
||||
if (null !== $insertStmt) {
|
||||
$this->rollback();
|
||||
throw new \RuntimeException('Failed to read session: INSERT reported a duplicate id but next SELECT did not return any data.');
|
||||
}
|
||||
|
||||
if (!ini_get('session.use_strict_mode') && self::LOCK_TRANSACTIONAL === $this->lockMode && 'sqlite' !== $this->driver) {
|
||||
// In strict mode, session fixation is not possible: new sessions always start with a unique
|
||||
// random id, so that concurrency is not possible and this code path can be skipped.
|
||||
// Exclusive-reading of non-existent rows does not block, so we need to do an insert to block
|
||||
// until other connections to the session are committed.
|
||||
try {
|
||||
$insertStmt = $this->pdo->prepare(
|
||||
"INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time)"
|
||||
);
|
||||
$insertStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR);
|
||||
$insertStmt->bindValue(':data', '', \PDO::PARAM_LOB);
|
||||
$insertStmt->bindValue(':lifetime', 0, \PDO::PARAM_INT);
|
||||
$insertStmt->bindValue(':time', time(), \PDO::PARAM_INT);
|
||||
$insertStmt = $this->getInsertStatement($sessionId, '', 0);
|
||||
$insertStmt->execute();
|
||||
} catch (\PDOException $e) {
|
||||
// Catch duplicate key error because other connection created the session already.
|
||||
|
|
@ -568,23 +682,25 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
|||
{
|
||||
switch ($this->driver) {
|
||||
case 'mysql':
|
||||
// MySQL 5.7.5 and later enforces a maximum length on lock names of 64 characters. Previously, no limit was enforced.
|
||||
$lockId = \substr($sessionId, 0, 64);
|
||||
// should we handle the return value? 0 on timeout, null on error
|
||||
// we use a timeout of 50 seconds which is also the default for innodb_lock_wait_timeout
|
||||
$stmt = $this->pdo->prepare('SELECT GET_LOCK(:key, 50)');
|
||||
$stmt->bindValue(':key', $sessionId, \PDO::PARAM_STR);
|
||||
$stmt->bindValue(':key', $lockId, \PDO::PARAM_STR);
|
||||
$stmt->execute();
|
||||
|
||||
$releaseStmt = $this->pdo->prepare('DO RELEASE_LOCK(:key)');
|
||||
$releaseStmt->bindValue(':key', $sessionId, \PDO::PARAM_STR);
|
||||
$releaseStmt->bindValue(':key', $lockId, \PDO::PARAM_STR);
|
||||
|
||||
return $releaseStmt;
|
||||
case 'pgsql':
|
||||
// Obtaining an exclusive session level advisory lock requires an integer key.
|
||||
// So we convert the HEX representation of the session id to an integer.
|
||||
// Since integers are signed, we have to skip one hex char to fit in the range.
|
||||
if (4 === PHP_INT_SIZE) {
|
||||
$sessionInt1 = hexdec(substr($sessionId, 0, 7));
|
||||
$sessionInt2 = hexdec(substr($sessionId, 7, 7));
|
||||
// When session.sid_bits_per_character > 4, the session id can contain non-hex-characters.
|
||||
// So we cannot just use hexdec().
|
||||
if (4 === \PHP_INT_SIZE) {
|
||||
$sessionInt1 = $this->convertStringToInt($sessionId);
|
||||
$sessionInt2 = $this->convertStringToInt(substr($sessionId, 4, 4));
|
||||
|
||||
$stmt = $this->pdo->prepare('SELECT pg_advisory_lock(:key1, :key2)');
|
||||
$stmt->bindValue(':key1', $sessionInt1, \PDO::PARAM_INT);
|
||||
|
|
@ -595,7 +711,7 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
|||
$releaseStmt->bindValue(':key1', $sessionInt1, \PDO::PARAM_INT);
|
||||
$releaseStmt->bindValue(':key2', $sessionInt2, \PDO::PARAM_INT);
|
||||
} else {
|
||||
$sessionBigInt = hexdec(substr($sessionId, 0, 15));
|
||||
$sessionBigInt = $this->convertStringToInt($sessionId);
|
||||
|
||||
$stmt = $this->pdo->prepare('SELECT pg_advisory_lock(:key)');
|
||||
$stmt->bindValue(':key', $sessionBigInt, \PDO::PARAM_INT);
|
||||
|
|
@ -613,6 +729,27 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the first 4 (when PHP_INT_SIZE == 4) or 8 characters of the string as an integer.
|
||||
*
|
||||
* Keep in mind, PHP integers are signed.
|
||||
*
|
||||
* @param string $string
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function convertStringToInt($string)
|
||||
{
|
||||
if (4 === \PHP_INT_SIZE) {
|
||||
return (\ord($string[3]) << 24) + (\ord($string[2]) << 16) + (\ord($string[1]) << 8) + \ord($string[0]);
|
||||
}
|
||||
|
||||
$int1 = (\ord($string[7]) << 24) + (\ord($string[6]) << 16) + (\ord($string[5]) << 8) + \ord($string[4]);
|
||||
$int2 = (\ord($string[3]) << 24) + (\ord($string[2]) << 16) + (\ord($string[1]) << 8) + \ord($string[0]);
|
||||
|
||||
return $int2 + ($int1 << 32);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a locking or nonlocking SQL query to read session information.
|
||||
*
|
||||
|
|
@ -643,6 +780,72 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
|||
return "SELECT $this->dataCol, $this->lifetimeCol, $this->timeCol FROM $this->table WHERE $this->idCol = :id";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an insert statement supported by the database for writing session data.
|
||||
*
|
||||
* @param string $sessionId Session ID
|
||||
* @param string $sessionData Encoded session data
|
||||
* @param int $maxlifetime session.gc_maxlifetime
|
||||
*
|
||||
* @return \PDOStatement The insert statement
|
||||
*/
|
||||
private function getInsertStatement($sessionId, $sessionData, $maxlifetime)
|
||||
{
|
||||
switch ($this->driver) {
|
||||
case 'oci':
|
||||
$data = fopen('php://memory', 'r+');
|
||||
fwrite($data, $sessionData);
|
||||
rewind($data);
|
||||
$sql = "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, EMPTY_BLOB(), :lifetime, :time) RETURNING $this->dataCol into :data";
|
||||
break;
|
||||
default:
|
||||
$data = $sessionData;
|
||||
$sql = "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time)";
|
||||
break;
|
||||
}
|
||||
|
||||
$stmt = $this->pdo->prepare($sql);
|
||||
$stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR);
|
||||
$stmt->bindParam(':data', $data, \PDO::PARAM_LOB);
|
||||
$stmt->bindParam(':lifetime', $maxlifetime, \PDO::PARAM_INT);
|
||||
$stmt->bindValue(':time', time(), \PDO::PARAM_INT);
|
||||
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an update statement supported by the database for writing session data.
|
||||
*
|
||||
* @param string $sessionId Session ID
|
||||
* @param string $sessionData Encoded session data
|
||||
* @param int $maxlifetime session.gc_maxlifetime
|
||||
*
|
||||
* @return \PDOStatement The update statement
|
||||
*/
|
||||
private function getUpdateStatement($sessionId, $sessionData, $maxlifetime)
|
||||
{
|
||||
switch ($this->driver) {
|
||||
case 'oci':
|
||||
$data = fopen('php://memory', 'r+');
|
||||
fwrite($data, $sessionData);
|
||||
rewind($data);
|
||||
$sql = "UPDATE $this->table SET $this->dataCol = EMPTY_BLOB(), $this->lifetimeCol = :lifetime, $this->timeCol = :time WHERE $this->idCol = :id RETURNING $this->dataCol into :data";
|
||||
break;
|
||||
default:
|
||||
$data = $sessionData;
|
||||
$sql = "UPDATE $this->table SET $this->dataCol = :data, $this->lifetimeCol = :lifetime, $this->timeCol = :time WHERE $this->idCol = :id";
|
||||
break;
|
||||
}
|
||||
|
||||
$stmt = $this->pdo->prepare($sql);
|
||||
$stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR);
|
||||
$stmt->bindParam(':data', $data, \PDO::PARAM_LOB);
|
||||
$stmt->bindParam(':lifetime', $maxlifetime, \PDO::PARAM_INT);
|
||||
$stmt->bindValue(':time', time(), \PDO::PARAM_INT);
|
||||
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a merge/upsert (i.e. insert or update) statement when supported by the database for writing session data.
|
||||
*
|
||||
|
|
@ -654,18 +857,11 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
|||
*/
|
||||
private function getMergeStatement($sessionId, $data, $maxlifetime)
|
||||
{
|
||||
$mergeSql = null;
|
||||
switch (true) {
|
||||
case 'mysql' === $this->driver:
|
||||
$mergeSql = "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time) ".
|
||||
"ON DUPLICATE KEY UPDATE $this->dataCol = VALUES($this->dataCol), $this->lifetimeCol = VALUES($this->lifetimeCol), $this->timeCol = VALUES($this->timeCol)";
|
||||
break;
|
||||
case 'oci' === $this->driver:
|
||||
// DUAL is Oracle specific dummy table
|
||||
$mergeSql = "MERGE INTO $this->table USING DUAL ON ($this->idCol = ?) ".
|
||||
"WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (?, ?, ?, ?) ".
|
||||
"WHEN MATCHED THEN UPDATE SET $this->dataCol = ?, $this->lifetimeCol = ?, $this->timeCol = ?";
|
||||
break;
|
||||
case 'sqlsrv' === $this->driver && version_compare($this->pdo->getAttribute(\PDO::ATTR_SERVER_VERSION), '10', '>='):
|
||||
// MERGE is only available since SQL Server 2008 and must be terminated by semicolon
|
||||
// It also requires HOLDLOCK according to http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condition-With-MERGE.aspx
|
||||
|
|
@ -680,29 +876,30 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
|||
$mergeSql = "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time) ".
|
||||
"ON CONFLICT ($this->idCol) DO UPDATE SET ($this->dataCol, $this->lifetimeCol, $this->timeCol) = (EXCLUDED.$this->dataCol, EXCLUDED.$this->lifetimeCol, EXCLUDED.$this->timeCol)";
|
||||
break;
|
||||
default:
|
||||
// MERGE is not supported with LOBs: http://www.oracle.com/technetwork/articles/fuecks-lobs-095315.html
|
||||
return null;
|
||||
}
|
||||
|
||||
if (null !== $mergeSql) {
|
||||
$mergeStmt = $this->pdo->prepare($mergeSql);
|
||||
$mergeStmt = $this->pdo->prepare($mergeSql);
|
||||
|
||||
if ('sqlsrv' === $this->driver || 'oci' === $this->driver) {
|
||||
$mergeStmt->bindParam(1, $sessionId, \PDO::PARAM_STR);
|
||||
$mergeStmt->bindParam(2, $sessionId, \PDO::PARAM_STR);
|
||||
$mergeStmt->bindParam(3, $data, \PDO::PARAM_LOB);
|
||||
$mergeStmt->bindParam(4, $maxlifetime, \PDO::PARAM_INT);
|
||||
$mergeStmt->bindValue(5, time(), \PDO::PARAM_INT);
|
||||
$mergeStmt->bindParam(6, $data, \PDO::PARAM_LOB);
|
||||
$mergeStmt->bindParam(7, $maxlifetime, \PDO::PARAM_INT);
|
||||
$mergeStmt->bindValue(8, time(), \PDO::PARAM_INT);
|
||||
} else {
|
||||
$mergeStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR);
|
||||
$mergeStmt->bindParam(':data', $data, \PDO::PARAM_LOB);
|
||||
$mergeStmt->bindParam(':lifetime', $maxlifetime, \PDO::PARAM_INT);
|
||||
$mergeStmt->bindValue(':time', time(), \PDO::PARAM_INT);
|
||||
}
|
||||
|
||||
return $mergeStmt;
|
||||
if ('sqlsrv' === $this->driver) {
|
||||
$mergeStmt->bindParam(1, $sessionId, \PDO::PARAM_STR);
|
||||
$mergeStmt->bindParam(2, $sessionId, \PDO::PARAM_STR);
|
||||
$mergeStmt->bindParam(3, $data, \PDO::PARAM_LOB);
|
||||
$mergeStmt->bindParam(4, $maxlifetime, \PDO::PARAM_INT);
|
||||
$mergeStmt->bindValue(5, time(), \PDO::PARAM_INT);
|
||||
$mergeStmt->bindParam(6, $data, \PDO::PARAM_LOB);
|
||||
$mergeStmt->bindParam(7, $maxlifetime, \PDO::PARAM_INT);
|
||||
$mergeStmt->bindValue(8, time(), \PDO::PARAM_INT);
|
||||
} else {
|
||||
$mergeStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR);
|
||||
$mergeStmt->bindParam(':data', $data, \PDO::PARAM_LOB);
|
||||
$mergeStmt->bindParam(':lifetime', $maxlifetime, \PDO::PARAM_INT);
|
||||
$mergeStmt->bindValue(':time', time(), \PDO::PARAM_INT);
|
||||
}
|
||||
|
||||
return $mergeStmt;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
7
pfosten/vendor/symfony/http-foundation/Session/Storage/Handler/WriteCheckSessionHandler.php
vendored
Executable file → Normal file
7
pfosten/vendor/symfony/http-foundation/Session/Storage/Handler/WriteCheckSessionHandler.php
vendored
Executable file → Normal file
|
|
@ -15,12 +15,11 @@ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
|
|||
* Wraps another SessionHandlerInterface to only write the session when it has been modified.
|
||||
*
|
||||
* @author Adrien Brault <adrien.brault@gmail.com>
|
||||
*
|
||||
* @deprecated since version 3.4, to be removed in 4.0. Implement `SessionUpdateTimestampHandlerInterface` or extend `AbstractSessionHandler` instead.
|
||||
*/
|
||||
class WriteCheckSessionHandler implements \SessionHandlerInterface
|
||||
{
|
||||
/**
|
||||
* @var \SessionHandlerInterface
|
||||
*/
|
||||
private $wrappedSessionHandler;
|
||||
|
||||
/**
|
||||
|
|
@ -30,6 +29,8 @@ class WriteCheckSessionHandler implements \SessionHandlerInterface
|
|||
|
||||
public function __construct(\SessionHandlerInterface $wrappedSessionHandler)
|
||||
{
|
||||
@trigger_error(sprintf('The %s class is deprecated since Symfony 3.4 and will be removed in 4.0. Implement `SessionUpdateTimestampHandlerInterface` or extend `AbstractSessionHandler` instead.', self::class), E_USER_DEPRECATED);
|
||||
|
||||
$this->wrappedSessionHandler = $wrappedSessionHandler;
|
||||
}
|
||||
|
||||
|
|
|
|||
2
pfosten/vendor/symfony/http-foundation/Session/Storage/MetadataBag.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/http-foundation/Session/Storage/MetadataBag.php
vendored
Executable file → Normal file
|
|
@ -54,8 +54,6 @@ class MetadataBag implements SessionBagInterface
|
|||
private $updateThreshold;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $storageKey The key used to store bag in the session
|
||||
* @param int $updateThreshold The time to wait between two UPDATED updates
|
||||
*/
|
||||
|
|
|
|||
12
pfosten/vendor/symfony/http-foundation/Session/Storage/MockArraySessionStorage.php
vendored
Executable file → Normal file
12
pfosten/vendor/symfony/http-foundation/Session/Storage/MockArraySessionStorage.php
vendored
Executable file → Normal file
|
|
@ -63,8 +63,6 @@ class MockArraySessionStorage implements SessionStorageInterface
|
|||
protected $bags = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $name Session name
|
||||
* @param MetadataBag $metaBag MetadataBag instance
|
||||
*/
|
||||
|
|
@ -74,11 +72,6 @@ class MockArraySessionStorage implements SessionStorageInterface
|
|||
$this->setMetadataBag($metaBag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the session data.
|
||||
*
|
||||
* @param array $array
|
||||
*/
|
||||
public function setSessionData(array $array)
|
||||
{
|
||||
$this->data = $array;
|
||||
|
|
@ -215,11 +208,6 @@ class MockArraySessionStorage implements SessionStorageInterface
|
|||
return $this->started;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the MetadataBag.
|
||||
*
|
||||
* @param MetadataBag $bag
|
||||
*/
|
||||
public function setMetadataBag(MetadataBag $bag = null)
|
||||
{
|
||||
if (null === $bag) {
|
||||
|
|
|
|||
26
pfosten/vendor/symfony/http-foundation/Session/Storage/MockFileSessionStorage.php
vendored
Executable file → Normal file
26
pfosten/vendor/symfony/http-foundation/Session/Storage/MockFileSessionStorage.php
vendored
Executable file → Normal file
|
|
@ -24,14 +24,9 @@ namespace Symfony\Component\HttpFoundation\Session\Storage;
|
|||
*/
|
||||
class MockFileSessionStorage extends MockArraySessionStorage
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $savePath;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $savePath Path of directory to save session files
|
||||
* @param string $name Session name
|
||||
* @param MetadataBag $metaBag MetadataBag instance
|
||||
|
|
@ -96,7 +91,26 @@ class MockFileSessionStorage extends MockArraySessionStorage
|
|||
throw new \RuntimeException('Trying to save a session that was not started yet or was already closed');
|
||||
}
|
||||
|
||||
file_put_contents($this->getFilePath(), serialize($this->data));
|
||||
$data = $this->data;
|
||||
|
||||
foreach ($this->bags as $bag) {
|
||||
if (empty($data[$key = $bag->getStorageKey()])) {
|
||||
unset($data[$key]);
|
||||
}
|
||||
}
|
||||
if (array($key = $this->metadataBag->getStorageKey()) === array_keys($data)) {
|
||||
unset($data[$key]);
|
||||
}
|
||||
|
||||
try {
|
||||
if ($data) {
|
||||
file_put_contents($this->getFilePath(), serialize($data));
|
||||
} else {
|
||||
$this->destroy();
|
||||
}
|
||||
} finally {
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
// this is needed for Silex, where the session object is re-used across requests
|
||||
// in functional tests. In Symfony, the container is rebooted, so we don't have
|
||||
|
|
|
|||
99
pfosten/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php
vendored
Executable file → Normal file
99
pfosten/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php
vendored
Executable file → Normal file
|
|
@ -11,9 +11,8 @@
|
|||
|
||||
namespace Symfony\Component\HttpFoundation\Session\Storage;
|
||||
|
||||
use Symfony\Component\Debug\Exception\ContextErrorException;
|
||||
use Symfony\Component\HttpFoundation\Session\SessionBagInterface;
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler;
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\Handler\StrictSessionHandler;
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy;
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy;
|
||||
|
||||
|
|
@ -25,11 +24,9 @@ use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy;
|
|||
class NativeSessionStorage implements SessionStorageInterface
|
||||
{
|
||||
/**
|
||||
* Array of SessionBagInterface.
|
||||
*
|
||||
* @var SessionBagInterface[]
|
||||
*/
|
||||
protected $bags;
|
||||
protected $bags = array();
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
|
|
@ -42,7 +39,7 @@ class NativeSessionStorage implements SessionStorageInterface
|
|||
protected $closed = false;
|
||||
|
||||
/**
|
||||
* @var AbstractProxy
|
||||
* @var AbstractProxy|\SessionHandlerInterface
|
||||
*/
|
||||
protected $saveHandler;
|
||||
|
||||
|
|
@ -52,8 +49,6 @@ class NativeSessionStorage implements SessionStorageInterface
|
|||
protected $metadataBag;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Depending on how you want the storage driver to behave you probably
|
||||
* want to override this constructor entirely.
|
||||
*
|
||||
|
|
@ -66,6 +61,7 @@ class NativeSessionStorage implements SessionStorageInterface
|
|||
* PHP starts to execute user-land code. Setting during runtime has no effect).
|
||||
*
|
||||
* cache_limiter, "" (use "0" to prevent headers from being sent entirely).
|
||||
* cache_expire, "0"
|
||||
* cookie_domain, ""
|
||||
* cookie_httponly, ""
|
||||
* cookie_lifetime, "0"
|
||||
|
|
@ -78,6 +74,7 @@ class NativeSessionStorage implements SessionStorageInterface
|
|||
* gc_probability, "1"
|
||||
* hash_bits_per_character, "4"
|
||||
* hash_function, "0"
|
||||
* lazy_write, "1"
|
||||
* name, "PHPSESSID"
|
||||
* referer_check, ""
|
||||
* serialize_handler, "php"
|
||||
|
|
@ -92,15 +89,23 @@ class NativeSessionStorage implements SessionStorageInterface
|
|||
* upload_progress.freq, "1%"
|
||||
* upload_progress.min-freq, "1"
|
||||
* url_rewriter.tags, "a=href,area=href,frame=src,form=,fieldset="
|
||||
* sid_length, "32"
|
||||
* sid_bits_per_character, "5"
|
||||
* trans_sid_hosts, $_SERVER['HTTP_HOST']
|
||||
* trans_sid_tags, "a=href,area=href,frame=src,form="
|
||||
*
|
||||
* @param array $options Session configuration options
|
||||
* @param AbstractProxy|NativeSessionHandler|\SessionHandlerInterface|null $handler
|
||||
* @param MetadataBag $metaBag MetadataBag
|
||||
* @param array $options Session configuration options
|
||||
* @param \SessionHandlerInterface|null $handler
|
||||
* @param MetadataBag $metaBag MetadataBag
|
||||
*/
|
||||
public function __construct(array $options = array(), $handler = null, MetadataBag $metaBag = null)
|
||||
{
|
||||
session_cache_limiter(''); // disable by default because it's managed by HeaderBag (if used)
|
||||
ini_set('session.use_cookies', 1);
|
||||
$options += array(
|
||||
'cache_limiter' => '',
|
||||
'cache_expire' => 0,
|
||||
'use_cookies' => 1,
|
||||
'lazy_write' => 1,
|
||||
);
|
||||
|
||||
session_register_shutdown();
|
||||
|
||||
|
|
@ -112,7 +117,7 @@ class NativeSessionStorage implements SessionStorageInterface
|
|||
/**
|
||||
* Gets the save handler instance.
|
||||
*
|
||||
* @return AbstractProxy
|
||||
* @return AbstractProxy|\SessionHandlerInterface
|
||||
*/
|
||||
public function getSaveHandler()
|
||||
{
|
||||
|
|
@ -188,6 +193,10 @@ class NativeSessionStorage implements SessionStorageInterface
|
|||
return false;
|
||||
}
|
||||
|
||||
if (headers_sent()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (null !== $lifetime) {
|
||||
ini_set('session.cookie_lifetime', $lifetime);
|
||||
}
|
||||
|
|
@ -210,15 +219,31 @@ class NativeSessionStorage implements SessionStorageInterface
|
|||
*/
|
||||
public function save()
|
||||
{
|
||||
$session = $_SESSION;
|
||||
|
||||
foreach ($this->bags as $bag) {
|
||||
if (empty($_SESSION[$key = $bag->getStorageKey()])) {
|
||||
unset($_SESSION[$key]);
|
||||
}
|
||||
}
|
||||
if (array($key = $this->metadataBag->getStorageKey()) === array_keys($_SESSION)) {
|
||||
unset($_SESSION[$key]);
|
||||
}
|
||||
|
||||
// Register custom error handler to catch a possible failure warning during session write
|
||||
set_error_handler(function ($errno, $errstr, $errfile, $errline, $errcontext) {
|
||||
throw new ContextErrorException($errstr, $errno, E_WARNING, $errfile, $errline, $errcontext);
|
||||
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
|
||||
throw new \ErrorException($errstr, $errno, E_WARNING, $errfile, $errline);
|
||||
}, E_WARNING);
|
||||
|
||||
try {
|
||||
$e = null;
|
||||
session_write_close();
|
||||
} catch (\ErrorException $e) {
|
||||
} finally {
|
||||
restore_error_handler();
|
||||
} catch (ContextErrorException $e) {
|
||||
$_SESSION = $session;
|
||||
}
|
||||
if (null !== $e) {
|
||||
// The default PHP error message is not very helpful, as it does not give any information on the current save handler.
|
||||
// Therefore, we catch this error and trigger a warning with a better error message
|
||||
$handler = $this->getSaveHandler();
|
||||
|
|
@ -226,8 +251,7 @@ class NativeSessionStorage implements SessionStorageInterface
|
|||
$handler = $handler->getHandler();
|
||||
}
|
||||
|
||||
restore_error_handler();
|
||||
trigger_error(sprintf('session_write_close(): Failed to write session data with %s handler', get_class($handler)), E_USER_WARNING);
|
||||
trigger_error(sprintf('session_write_close(): Failed to write session data with %s handler', \get_class($handler)), E_USER_WARNING);
|
||||
}
|
||||
|
||||
$this->closed = true;
|
||||
|
|
@ -272,7 +296,7 @@ class NativeSessionStorage implements SessionStorageInterface
|
|||
throw new \InvalidArgumentException(sprintf('The SessionBagInterface %s is not registered.', $name));
|
||||
}
|
||||
|
||||
if ($this->saveHandler->isActive() && !$this->started) {
|
||||
if (!$this->started && $this->saveHandler->isActive()) {
|
||||
$this->loadSession();
|
||||
} elseif (!$this->started) {
|
||||
$this->start();
|
||||
|
|
@ -281,11 +305,6 @@ class NativeSessionStorage implements SessionStorageInterface
|
|||
return $this->bags[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the MetadataBag.
|
||||
*
|
||||
* @param MetadataBag $metaBag
|
||||
*/
|
||||
public function setMetadataBag(MetadataBag $metaBag = null)
|
||||
{
|
||||
if (null === $metaBag) {
|
||||
|
|
@ -325,21 +344,26 @@ class NativeSessionStorage implements SessionStorageInterface
|
|||
*/
|
||||
public function setOptions(array $options)
|
||||
{
|
||||
if (headers_sent() || \PHP_SESSION_ACTIVE === session_status()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$validOptions = array_flip(array(
|
||||
'cache_limiter', 'cookie_domain', 'cookie_httponly',
|
||||
'cache_expire', 'cache_limiter', 'cookie_domain', 'cookie_httponly',
|
||||
'cookie_lifetime', 'cookie_path', 'cookie_secure',
|
||||
'entropy_file', 'entropy_length', 'gc_divisor',
|
||||
'gc_maxlifetime', 'gc_probability', 'hash_bits_per_character',
|
||||
'hash_function', 'name', 'referer_check',
|
||||
'hash_function', 'lazy_write', 'name', 'referer_check',
|
||||
'serialize_handler', 'use_strict_mode', 'use_cookies',
|
||||
'use_only_cookies', 'use_trans_sid', 'upload_progress.enabled',
|
||||
'upload_progress.cleanup', 'upload_progress.prefix', 'upload_progress.name',
|
||||
'upload_progress.freq', 'upload_progress.min-freq', 'url_rewriter.tags',
|
||||
'upload_progress.freq', 'upload_progress.min_freq', 'url_rewriter.tags',
|
||||
'sid_length', 'sid_bits_per_character', 'trans_sid_hosts', 'trans_sid_tags',
|
||||
));
|
||||
|
||||
foreach ($options as $key => $value) {
|
||||
if (isset($validOptions[$key])) {
|
||||
ini_set('session.'.$key, $value);
|
||||
ini_set('url_rewriter.tags' !== $key ? 'session.'.$key : $key, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -353,7 +377,7 @@ class NativeSessionStorage implements SessionStorageInterface
|
|||
* ini_set('session.save_handler', 'files');
|
||||
* ini_set('session.save_path', '/tmp');
|
||||
*
|
||||
* or pass in a NativeSessionHandler instance which configures session.save_handler in the
|
||||
* or pass in a \SessionHandler instance which configures session.save_handler in the
|
||||
* constructor, for a template see NativeFileSessionHandler or use handlers in
|
||||
* composer package drak/native-session
|
||||
*
|
||||
|
|
@ -362,28 +386,31 @@ class NativeSessionStorage implements SessionStorageInterface
|
|||
* @see http://php.net/sessionhandler
|
||||
* @see http://github.com/drak/NativeSession
|
||||
*
|
||||
* @param AbstractProxy|NativeSessionHandler|\SessionHandlerInterface|null $saveHandler
|
||||
* @param \SessionHandlerInterface|null $saveHandler
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setSaveHandler($saveHandler = null)
|
||||
{
|
||||
if (!$saveHandler instanceof AbstractProxy &&
|
||||
!$saveHandler instanceof NativeSessionHandler &&
|
||||
!$saveHandler instanceof \SessionHandlerInterface &&
|
||||
null !== $saveHandler) {
|
||||
throw new \InvalidArgumentException('Must be instance of AbstractProxy or NativeSessionHandler; implement \SessionHandlerInterface; or be null.');
|
||||
throw new \InvalidArgumentException('Must be instance of AbstractProxy; implement \SessionHandlerInterface; or be null.');
|
||||
}
|
||||
|
||||
// Wrap $saveHandler in proxy and prevent double wrapping of proxy
|
||||
if (!$saveHandler instanceof AbstractProxy && $saveHandler instanceof \SessionHandlerInterface) {
|
||||
$saveHandler = new SessionHandlerProxy($saveHandler);
|
||||
} elseif (!$saveHandler instanceof AbstractProxy) {
|
||||
$saveHandler = new SessionHandlerProxy(new \SessionHandler());
|
||||
$saveHandler = new SessionHandlerProxy(new StrictSessionHandler(new \SessionHandler()));
|
||||
}
|
||||
$this->saveHandler = $saveHandler;
|
||||
|
||||
if ($this->saveHandler instanceof \SessionHandlerInterface) {
|
||||
if (headers_sent() || \PHP_SESSION_ACTIVE === session_status()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->saveHandler instanceof SessionHandlerProxy) {
|
||||
session_set_save_handler($this->saveHandler, false);
|
||||
}
|
||||
}
|
||||
|
|
@ -395,8 +422,6 @@ class NativeSessionStorage implements SessionStorageInterface
|
|||
* are set to (either PHP's internal, or a custom save handler set with session_set_save_handler()).
|
||||
* PHP takes the return value from the read() handler, unserializes it
|
||||
* and populates $_SESSION with the result automatically.
|
||||
*
|
||||
* @param array|null $session
|
||||
*/
|
||||
protected function loadSession(array &$session = null)
|
||||
{
|
||||
|
|
|
|||
9
pfosten/vendor/symfony/http-foundation/Session/Storage/PhpBridgeSessionStorage.php
vendored
Executable file → Normal file
9
pfosten/vendor/symfony/http-foundation/Session/Storage/PhpBridgeSessionStorage.php
vendored
Executable file → Normal file
|
|
@ -11,9 +11,6 @@
|
|||
|
||||
namespace Symfony\Component\HttpFoundation\Session\Storage;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy;
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler;
|
||||
|
||||
/**
|
||||
* Allows session to be started by PHP and managed by Symfony.
|
||||
*
|
||||
|
|
@ -22,10 +19,8 @@ use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandle
|
|||
class PhpBridgeSessionStorage extends NativeSessionStorage
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param AbstractProxy|NativeSessionHandler|\SessionHandlerInterface|null $handler
|
||||
* @param MetadataBag $metaBag MetadataBag
|
||||
* @param \SessionHandlerInterface|null $handler
|
||||
* @param MetadataBag $metaBag MetadataBag
|
||||
*/
|
||||
public function __construct($handler = null, MetadataBag $metaBag = null)
|
||||
{
|
||||
|
|
|
|||
2
pfosten/vendor/symfony/http-foundation/Session/Storage/Proxy/AbstractProxy.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/http-foundation/Session/Storage/Proxy/AbstractProxy.php
vendored
Executable file → Normal file
|
|
@ -12,8 +12,6 @@
|
|||
namespace Symfony\Component\HttpFoundation\Session\Storage\Proxy;
|
||||
|
||||
/**
|
||||
* AbstractProxy.
|
||||
*
|
||||
* @author Drak <drak@zikula.org>
|
||||
*/
|
||||
abstract class AbstractProxy
|
||||
|
|
|
|||
9
pfosten/vendor/symfony/http-foundation/Session/Storage/Proxy/NativeProxy.php
vendored
Executable file → Normal file
9
pfosten/vendor/symfony/http-foundation/Session/Storage/Proxy/NativeProxy.php
vendored
Executable file → Normal file
|
|
@ -11,18 +11,17 @@
|
|||
|
||||
namespace Symfony\Component\HttpFoundation\Session\Storage\Proxy;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\NativeProxy class is deprecated since Symfony 3.4 and will be removed in 4.0. Use your session handler implementation directly.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* NativeProxy.
|
||||
* This proxy is built-in session handlers in PHP 5.3.x.
|
||||
*
|
||||
* This proxy is built-in session handlers in PHP 5.3.x
|
||||
* @deprecated since version 3.4, to be removed in 4.0. Use your session handler implementation directly.
|
||||
*
|
||||
* @author Drak <drak@zikula.org>
|
||||
*/
|
||||
class NativeProxy extends AbstractProxy
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// this makes an educated guess as to what the handler is since it should already be set.
|
||||
|
|
|
|||
28
pfosten/vendor/symfony/http-foundation/Session/Storage/Proxy/SessionHandlerProxy.php
vendored
Executable file → Normal file
28
pfosten/vendor/symfony/http-foundation/Session/Storage/Proxy/SessionHandlerProxy.php
vendored
Executable file → Normal file
|
|
@ -12,22 +12,12 @@
|
|||
namespace Symfony\Component\HttpFoundation\Session\Storage\Proxy;
|
||||
|
||||
/**
|
||||
* SessionHandler proxy.
|
||||
*
|
||||
* @author Drak <drak@zikula.org>
|
||||
*/
|
||||
class SessionHandlerProxy extends AbstractProxy implements \SessionHandlerInterface
|
||||
class SessionHandlerProxy extends AbstractProxy implements \SessionHandlerInterface, \SessionUpdateTimestampHandlerInterface
|
||||
{
|
||||
/**
|
||||
* @var \SessionHandlerInterface
|
||||
*/
|
||||
protected $handler;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param \SessionHandlerInterface $handler
|
||||
*/
|
||||
public function __construct(\SessionHandlerInterface $handler)
|
||||
{
|
||||
$this->handler = $handler;
|
||||
|
|
@ -92,4 +82,20 @@ class SessionHandlerProxy extends AbstractProxy implements \SessionHandlerInterf
|
|||
{
|
||||
return (bool) $this->handler->gc($maxlifetime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validateId($sessionId)
|
||||
{
|
||||
return !$this->handler instanceof \SessionUpdateTimestampHandlerInterface || $this->handler->validateId($sessionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function updateTimestamp($sessionId, $data)
|
||||
{
|
||||
return $this->handler instanceof \SessionUpdateTimestampHandlerInterface ? $this->handler->updateTimestamp($sessionId, $data) : $this->write($sessionId, $data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
8
pfosten/vendor/symfony/http-foundation/Session/Storage/SessionStorageInterface.php
vendored
Executable file → Normal file
8
pfosten/vendor/symfony/http-foundation/Session/Storage/SessionStorageInterface.php
vendored
Executable file → Normal file
|
|
@ -26,7 +26,7 @@ interface SessionStorageInterface
|
|||
*
|
||||
* @return bool True if started
|
||||
*
|
||||
* @throws \RuntimeException If something goes wrong starting the session.
|
||||
* @throws \RuntimeException if something goes wrong starting the session
|
||||
*/
|
||||
public function start();
|
||||
|
||||
|
|
@ -104,8 +104,8 @@ interface SessionStorageInterface
|
|||
* a real PHP session would interfere with testing, in which case
|
||||
* it should actually persist the session data if required.
|
||||
*
|
||||
* @throws \RuntimeException If the session is saved without being started, or if the session
|
||||
* is already closed.
|
||||
* @throws \RuntimeException if the session is saved without being started, or if the session
|
||||
* is already closed
|
||||
*/
|
||||
public function save();
|
||||
|
||||
|
|
@ -127,8 +127,6 @@ interface SessionStorageInterface
|
|||
|
||||
/**
|
||||
* Registers a SessionBagInterface for use.
|
||||
*
|
||||
* @param SessionBagInterface $bag
|
||||
*/
|
||||
public function registerBag(SessionBagInterface $bag);
|
||||
|
||||
|
|
|
|||
36
pfosten/vendor/symfony/http-foundation/StreamedResponse.php
vendored
Executable file → Normal file
36
pfosten/vendor/symfony/http-foundation/StreamedResponse.php
vendored
Executable file → Normal file
|
|
@ -31,8 +31,6 @@ class StreamedResponse extends Response
|
|||
private $headersSent;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param callable|null $callback A valid PHP callback or null to set it later
|
||||
* @param int $status The response status code
|
||||
* @param array $headers An array of response headers
|
||||
|
|
@ -66,37 +64,45 @@ class StreamedResponse extends Response
|
|||
* Sets the PHP callback associated with this Response.
|
||||
*
|
||||
* @param callable $callback A valid PHP callback
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCallback(callable $callback)
|
||||
{
|
||||
$this->callback = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* This method only sends the headers once.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function sendHeaders()
|
||||
{
|
||||
if ($this->headersSent) {
|
||||
return;
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->headersSent = true;
|
||||
|
||||
parent::sendHeaders();
|
||||
return parent::sendHeaders();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* This method only sends the content once.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function sendContent()
|
||||
{
|
||||
if ($this->streamed) {
|
||||
return;
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->streamed = true;
|
||||
|
|
@ -105,19 +111,25 @@ class StreamedResponse extends Response
|
|||
throw new \LogicException('The Response callback must not be null.');
|
||||
}
|
||||
|
||||
call_user_func($this->callback);
|
||||
\call_user_func($this->callback);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @throws \LogicException when the content is not null
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
if (null !== $content) {
|
||||
throw new \LogicException('The content cannot be set on a StreamedResponse instance.');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -129,4 +141,16 @@ class StreamedResponse extends Response
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setNotModified()
|
||||
{
|
||||
$this->setCallback(function () {});
|
||||
|
||||
return parent::setNotModified();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/http-foundation/Tests/AcceptHeaderItemTest.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/Tests/AcceptHeaderItemTest.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/Tests/AcceptHeaderTest.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/Tests/AcceptHeaderTest.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/Tests/ApacheRequestTest.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/Tests/ApacheRequestTest.php
vendored
Executable file → Normal file
11
pfosten/vendor/symfony/http-foundation/Tests/BinaryFileResponseTest.php
vendored
Executable file → Normal file
11
pfosten/vendor/symfony/http-foundation/Tests/BinaryFileResponseTest.php
vendored
Executable file → Normal file
|
|
@ -69,6 +69,17 @@ class BinaryFileResponseTest extends ResponseTestCase
|
|||
$this->assertSame('attachment; filename="f__.html"; filename*=utf-8\'\'f%C3%B6%C3%B6.html', $response->headers->get('Content-Disposition'));
|
||||
}
|
||||
|
||||
public function testSetContentDispositionGeneratesSafeFallbackFilenameForWronglyEncodedFilename()
|
||||
{
|
||||
$response = new BinaryFileResponse(__FILE__);
|
||||
|
||||
$iso88591EncodedFilename = utf8_decode('föö.html');
|
||||
$response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $iso88591EncodedFilename);
|
||||
|
||||
// the parameter filename* is invalid in this case (rawurldecode('f%F6%F6') does not provide a UTF-8 string but an ISO-8859-1 encoded one)
|
||||
$this->assertSame('attachment; filename="f__.html"; filename*=utf-8\'\'f%F6%F6.html', $response->headers->get('Content-Disposition'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideRanges
|
||||
*/
|
||||
|
|
|
|||
40
pfosten/vendor/symfony/http-foundation/Tests/CookieTest.php
vendored
Executable file → Normal file
40
pfosten/vendor/symfony/http-foundation/Tests/CookieTest.php
vendored
Executable file → Normal file
|
|
@ -157,15 +157,30 @@ class CookieTest extends TestCase
|
|||
$cookie = new Cookie('foo', 'bar', time() - 20);
|
||||
|
||||
$this->assertTrue($cookie->isCleared(), '->isCleared() returns true if the cookie has expired');
|
||||
|
||||
$cookie = new Cookie('foo', 'bar');
|
||||
|
||||
$this->assertFalse($cookie->isCleared());
|
||||
|
||||
$cookie = new Cookie('foo', 'bar', 0);
|
||||
|
||||
$this->assertFalse($cookie->isCleared());
|
||||
|
||||
$cookie = new Cookie('foo', 'bar', -1);
|
||||
|
||||
$this->assertFalse($cookie->isCleared());
|
||||
}
|
||||
|
||||
public function testToString()
|
||||
{
|
||||
$cookie = new Cookie('foo', 'bar', $expire = strtotime('Fri, 20-May-2011 15:25:52 GMT'), '/', '.myfoodomain.com', true);
|
||||
$this->assertEquals('foo=bar; expires=Fri, 20-May-2011 15:25:52 GMT; max-age='.($expire - time()).'; path=/; domain=.myfoodomain.com; secure; httponly', (string) $cookie, '->__toString() returns string representation of the cookie');
|
||||
$this->assertEquals('foo=bar; expires=Fri, 20-May-2011 15:25:52 GMT; Max-Age=0; path=/; domain=.myfoodomain.com; secure; httponly', (string) $cookie, '->__toString() returns string representation of the cookie');
|
||||
|
||||
$cookie = new Cookie('foo', 'bar with white spaces', strtotime('Fri, 20-May-2011 15:25:52 GMT'), '/', '.myfoodomain.com', true);
|
||||
$this->assertEquals('foo=bar%20with%20white%20spaces; expires=Fri, 20-May-2011 15:25:52 GMT; Max-Age=0; path=/; domain=.myfoodomain.com; secure; httponly', (string) $cookie, '->__toString() encodes the value of the cookie according to RFC 3986 (white space = %20)');
|
||||
|
||||
$cookie = new Cookie('foo', null, 1, '/admin/', '.myfoodomain.com');
|
||||
$this->assertEquals('foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', $expire = time() - 31536001).'; max-age='.($expire - time()).'; path=/admin/; domain=.myfoodomain.com; httponly', (string) $cookie, '->__toString() returns string representation of a cleared cookie if value is NULL');
|
||||
$this->assertEquals('foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', $expire = time() - 31536001).'; Max-Age=0; path=/admin/; domain=.myfoodomain.com; httponly', (string) $cookie, '->__toString() returns string representation of a cleared cookie if value is NULL');
|
||||
|
||||
$cookie = new Cookie('foo', 'bar', 0, '/', '');
|
||||
$this->assertEquals('foo=bar; path=/; httponly', (string) $cookie);
|
||||
|
|
@ -175,7 +190,7 @@ class CookieTest extends TestCase
|
|||
{
|
||||
$cookie = new Cookie('foo', 'b a r', 0, '/', null, false, false);
|
||||
$this->assertFalse($cookie->isRaw());
|
||||
$this->assertEquals('foo=b+a+r; path=/', (string) $cookie);
|
||||
$this->assertEquals('foo=b%20a%20r; path=/', (string) $cookie);
|
||||
|
||||
$cookie = new Cookie('foo', 'b+a+r', 0, '/', null, false, false, true);
|
||||
$this->assertTrue($cookie->isRaw());
|
||||
|
|
@ -191,7 +206,7 @@ class CookieTest extends TestCase
|
|||
$this->assertEquals($expire - time(), $cookie->getMaxAge());
|
||||
|
||||
$cookie = new Cookie('foo', 'bar', $expire = time() - 100);
|
||||
$this->assertEquals($expire - time(), $cookie->getMaxAge());
|
||||
$this->assertEquals(0, $cookie->getMaxAge());
|
||||
}
|
||||
|
||||
public function testFromString()
|
||||
|
|
@ -200,6 +215,21 @@ class CookieTest extends TestCase
|
|||
$this->assertEquals(new Cookie('foo', 'bar', strtotime('Fri, 20-May-2011 15:25:52 GMT'), '/', '.myfoodomain.com', true, true, true), $cookie);
|
||||
|
||||
$cookie = Cookie::fromString('foo=bar', true);
|
||||
$this->assertEquals(new Cookie('foo', 'bar'), $cookie);
|
||||
$this->assertEquals(new Cookie('foo', 'bar', 0, '/', null, false, false), $cookie);
|
||||
}
|
||||
|
||||
public function testFromStringWithHttpOnly()
|
||||
{
|
||||
$cookie = Cookie::fromString('foo=bar; expires=Fri, 20-May-2011 15:25:52 GMT; path=/; domain=.myfoodomain.com; secure; httponly');
|
||||
$this->assertTrue($cookie->isHttpOnly());
|
||||
|
||||
$cookie = Cookie::fromString('foo=bar; expires=Fri, 20-May-2011 15:25:52 GMT; path=/; domain=.myfoodomain.com; secure');
|
||||
$this->assertFalse($cookie->isHttpOnly());
|
||||
}
|
||||
|
||||
public function testSameSiteAttributeIsCaseInsensitive()
|
||||
{
|
||||
$cookie = new Cookie('foo', 'bar', 0, '/', null, false, true, false, 'Lax');
|
||||
$this->assertEquals('lax', $cookie->getSameSite());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/http-foundation/Tests/ExpressionRequestMatcherTest.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/Tests/ExpressionRequestMatcherTest.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/Tests/File/FakeFile.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/Tests/File/FakeFile.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/Tests/File/FileTest.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/Tests/File/FileTest.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/Tests/File/Fixtures/.unknownextension
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/Tests/File/Fixtures/.unknownextension
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/Tests/File/Fixtures/directory/.empty
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/Tests/File/Fixtures/directory/.empty
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/Tests/File/Fixtures/other-file.example
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/Tests/File/Fixtures/other-file.example
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/Tests/File/Fixtures/test
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/Tests/File/Fixtures/test
vendored
Executable file → Normal file
|
Before Width: | Height: | Size: 35 B After Width: | Height: | Size: 35 B |
0
pfosten/vendor/symfony/http-foundation/Tests/File/Fixtures/test.gif
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/Tests/File/Fixtures/test.gif
vendored
Executable file → Normal file
|
Before Width: | Height: | Size: 35 B After Width: | Height: | Size: 35 B |
6
pfosten/vendor/symfony/http-foundation/Tests/File/MimeType/MimeTypeTest.php
vendored
Executable file → Normal file
6
pfosten/vendor/symfony/http-foundation/Tests/File/MimeType/MimeTypeTest.php
vendored
Executable file → Normal file
|
|
@ -12,8 +12,8 @@
|
|||
namespace Symfony\Component\HttpFoundation\Tests\File\MimeType;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
|
||||
use Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser;
|
||||
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
|
||||
|
||||
/**
|
||||
* @requires extension fileinfo
|
||||
|
|
@ -59,7 +59,7 @@ class MimeTypeTest extends TestCase
|
|||
|
||||
public function testGuessWithNonReadablePath()
|
||||
{
|
||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$this->markTestSkipped('Can not verify chmod operations on Windows');
|
||||
}
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ class MimeTypeTest extends TestCase
|
|||
touch($path);
|
||||
@chmod($path, 0333);
|
||||
|
||||
if (substr(sprintf('%o', fileperms($path)), -4) == '0333') {
|
||||
if ('0333' == substr(sprintf('%o', fileperms($path)), -4)) {
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException');
|
||||
MimeTypeGuesser::getInstance()->guess($path);
|
||||
} else {
|
||||
|
|
|
|||
2
pfosten/vendor/symfony/http-foundation/Tests/File/UploadedFileTest.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/http-foundation/Tests/File/UploadedFileTest.php
vendored
Executable file → Normal file
|
|
@ -46,7 +46,7 @@ class UploadedFileTest extends TestCase
|
|||
|
||||
$this->assertEquals('application/octet-stream', $file->getClientMimeType());
|
||||
|
||||
if (extension_loaded('fileinfo')) {
|
||||
if (\extension_loaded('fileinfo')) {
|
||||
$this->assertEquals('image/gif', $file->getMimeType());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
26
pfosten/vendor/symfony/http-foundation/Tests/FileBagTest.php
vendored
Executable file → Normal file
26
pfosten/vendor/symfony/http-foundation/Tests/FileBagTest.php
vendored
Executable file → Normal file
|
|
@ -60,6 +60,32 @@ class FileBagTest extends TestCase
|
|||
$this->assertNull($bag->get('file'));
|
||||
}
|
||||
|
||||
public function testShouldRemoveEmptyUploadedFilesForMultiUpload()
|
||||
{
|
||||
$bag = new FileBag(array('files' => array(
|
||||
'name' => array(''),
|
||||
'type' => array(''),
|
||||
'tmp_name' => array(''),
|
||||
'error' => array(UPLOAD_ERR_NO_FILE),
|
||||
'size' => array(0),
|
||||
)));
|
||||
|
||||
$this->assertSame(array(), $bag->get('files'));
|
||||
}
|
||||
|
||||
public function testShouldNotRemoveEmptyUploadedFilesForAssociativeArray()
|
||||
{
|
||||
$bag = new FileBag(array('files' => array(
|
||||
'name' => array('file1' => ''),
|
||||
'type' => array('file1' => ''),
|
||||
'tmp_name' => array('file1' => ''),
|
||||
'error' => array('file1' => UPLOAD_ERR_NO_FILE),
|
||||
'size' => array('file1' => 0),
|
||||
)));
|
||||
|
||||
$this->assertSame(array('file1' => null), $bag->get('files'));
|
||||
}
|
||||
|
||||
public function testShouldConvertUploadedFilesWithPhpBug()
|
||||
{
|
||||
$tmpFile = $this->createTempFile();
|
||||
|
|
|
|||
4
pfosten/vendor/symfony/http-foundation/Tests/HeaderBagTest.php
vendored
Executable file → Normal file
4
pfosten/vendor/symfony/http-foundation/Tests/HeaderBagTest.php
vendored
Executable file → Normal file
|
|
@ -192,7 +192,7 @@ class HeaderBagTest extends TestCase
|
|||
$this->assertEquals(array($headers[$key]), $val);
|
||||
}
|
||||
|
||||
$this->assertEquals(count($headers), $i);
|
||||
$this->assertEquals(\count($headers), $i);
|
||||
}
|
||||
|
||||
public function testCount()
|
||||
|
|
@ -200,6 +200,6 @@ class HeaderBagTest extends TestCase
|
|||
$headers = array('foo' => 'bar', 'HELLO' => 'WORLD');
|
||||
$headerBag = new HeaderBag($headers);
|
||||
|
||||
$this->assertEquals(count($headers), count($headerBag));
|
||||
$this->assertCount(\count($headers), $headerBag);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
23
pfosten/vendor/symfony/http-foundation/Tests/IpUtilsTest.php
vendored
Executable file → Normal file
23
pfosten/vendor/symfony/http-foundation/Tests/IpUtilsTest.php
vendored
Executable file → Normal file
|
|
@ -47,7 +47,7 @@ class IpUtilsTest extends TestCase
|
|||
*/
|
||||
public function testIpv6($matches, $remoteAddr, $cidr)
|
||||
{
|
||||
if (!defined('AF_INET6')) {
|
||||
if (!\defined('AF_INET6')) {
|
||||
$this->markTestSkipped('Only works when PHP is compiled without the option "disable-ipv6".');
|
||||
}
|
||||
|
||||
|
|
@ -62,6 +62,8 @@ class IpUtilsTest extends TestCase
|
|||
array(false, '2a01:198:603:0:396e:4789:8e99:890f', '::1'),
|
||||
array(true, '0:0:0:0:0:0:0:1', '::1'),
|
||||
array(false, '0:0:603:0:396e:4789:8e99:0001', '::1'),
|
||||
array(true, '0:0:603:0:396e:4789:8e99:0001', '::/0'),
|
||||
array(true, '0:0:603:0:396e:4789:8e99:0001', '2a01:198:603:0::/0'),
|
||||
array(true, '2a01:198:603:0:396e:4789:8e99:890f', array('::1', '2a01:198:603:0::/65')),
|
||||
array(true, '2a01:198:603:0:396e:4789:8e99:890f', array('2a01:198:603:0::/65', '::1')),
|
||||
array(false, '2a01:198:603:0:396e:4789:8e99:890f', array('::1', '1a01:198:603:0::/65')),
|
||||
|
|
@ -76,10 +78,27 @@ class IpUtilsTest extends TestCase
|
|||
*/
|
||||
public function testAnIpv6WithOptionDisabledIpv6()
|
||||
{
|
||||
if (defined('AF_INET6')) {
|
||||
if (\defined('AF_INET6')) {
|
||||
$this->markTestSkipped('Only works when PHP is compiled with the option "disable-ipv6".');
|
||||
}
|
||||
|
||||
IpUtils::checkIp('2a01:198:603:0:396e:4789:8e99:890f', '2a01:198:603:0::/65');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider invalidIpAddressData
|
||||
*/
|
||||
public function testInvalidIpAddressesDoNotMatch($requestIp, $proxyIp)
|
||||
{
|
||||
$this->assertFalse(IpUtils::checkIp4($requestIp, $proxyIp));
|
||||
}
|
||||
|
||||
public function invalidIpAddressData()
|
||||
{
|
||||
return array(
|
||||
'invalid proxy wildcard' => array('192.168.20.13', '*'),
|
||||
'invalid proxy missing netmask' => array('192.168.20.13', '0.0.0.0'),
|
||||
'invalid request IP with invalid proxy wildcard' => array('0.0.0.0', '*'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
15
pfosten/vendor/symfony/http-foundation/Tests/JsonResponseTest.php
vendored
Executable file → Normal file
15
pfosten/vendor/symfony/http-foundation/Tests/JsonResponseTest.php
vendored
Executable file → Normal file
|
|
@ -16,6 +16,15 @@ use Symfony\Component\HttpFoundation\JsonResponse;
|
|||
|
||||
class JsonResponseTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
if (!\defined('HHVM_VERSION')) {
|
||||
$this->iniSet('serialize_precision', 14);
|
||||
}
|
||||
}
|
||||
|
||||
public function testConstructorEmptyCreatesJsonObject()
|
||||
{
|
||||
$response = new JsonResponse();
|
||||
|
|
@ -228,6 +237,10 @@ class JsonResponseTest extends TestCase
|
|||
*/
|
||||
public function testSetContentJsonSerializeError()
|
||||
{
|
||||
if (!interface_exists('JsonSerializable', false)) {
|
||||
$this->markTestSkipped('JsonSerializable is required.');
|
||||
}
|
||||
|
||||
$serializable = new JsonSerializableObject();
|
||||
|
||||
JsonResponse::create($serializable);
|
||||
|
|
@ -242,7 +255,7 @@ class JsonResponseTest extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
if (interface_exists('JsonSerializable')) {
|
||||
if (interface_exists('JsonSerializable', false)) {
|
||||
class JsonSerializableObject implements \JsonSerializable
|
||||
{
|
||||
public function jsonSerialize()
|
||||
|
|
|
|||
4
pfosten/vendor/symfony/http-foundation/Tests/ParameterBagTest.php
vendored
Executable file → Normal file
4
pfosten/vendor/symfony/http-foundation/Tests/ParameterBagTest.php
vendored
Executable file → Normal file
|
|
@ -171,7 +171,7 @@ class ParameterBagTest extends TestCase
|
|||
$this->assertEquals($parameters[$key], $val);
|
||||
}
|
||||
|
||||
$this->assertEquals(count($parameters), $i);
|
||||
$this->assertEquals(\count($parameters), $i);
|
||||
}
|
||||
|
||||
public function testCount()
|
||||
|
|
@ -179,7 +179,7 @@ class ParameterBagTest extends TestCase
|
|||
$parameters = array('foo' => 'bar', 'hello' => 'world');
|
||||
$bag = new ParameterBag($parameters);
|
||||
|
||||
$this->assertEquals(count($parameters), count($bag));
|
||||
$this->assertCount(\count($parameters), $bag);
|
||||
}
|
||||
|
||||
public function testGetBoolean()
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/http-foundation/Tests/RedirectResponseTest.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/Tests/RedirectResponseTest.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/http-foundation/Tests/RequestMatcherTest.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/http-foundation/Tests/RequestMatcherTest.php
vendored
Executable file → Normal file
|
|
@ -12,8 +12,8 @@
|
|||
namespace Symfony\Component\HttpFoundation\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\RequestMatcher;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestMatcher;
|
||||
|
||||
class RequestMatcherTest extends TestCase
|
||||
{
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/http-foundation/Tests/RequestStackTest.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/Tests/RequestStackTest.php
vendored
Executable file → Normal file
207
pfosten/vendor/symfony/http-foundation/Tests/RequestTest.php
vendored
Executable file → Normal file
207
pfosten/vendor/symfony/http-foundation/Tests/RequestTest.php
vendored
Executable file → Normal file
|
|
@ -13,16 +13,16 @@ namespace Symfony\Component\HttpFoundation\Tests;
|
|||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException;
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
||||
use Symfony\Component\HttpFoundation\Session\Session;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Session\Session;
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
||||
|
||||
class RequestTest extends TestCase
|
||||
{
|
||||
protected function tearDown()
|
||||
{
|
||||
// reset
|
||||
Request::setTrustedProxies(array(), -1);
|
||||
Request::setTrustedHosts(array());
|
||||
}
|
||||
|
||||
public function testInitialize()
|
||||
|
|
@ -52,18 +52,18 @@ class RequestTest extends TestCase
|
|||
|
||||
public function testGetUser()
|
||||
{
|
||||
$request = Request::create('http://user_test:password_test@test.com/');
|
||||
$request = Request::create('http://user:password@test.com');
|
||||
$user = $request->getUser();
|
||||
|
||||
$this->assertEquals('user_test', $user);
|
||||
$this->assertEquals('user', $user);
|
||||
}
|
||||
|
||||
public function testGetPassword()
|
||||
{
|
||||
$request = Request::create('http://user_test:password_test@test.com/');
|
||||
$request = Request::create('http://user:password@test.com');
|
||||
$password = $request->getPassword();
|
||||
|
||||
$this->assertEquals('password_test', $password);
|
||||
$this->assertEquals('password', $password);
|
||||
}
|
||||
|
||||
public function testIsNoCache()
|
||||
|
|
@ -372,6 +372,7 @@ class RequestTest extends TestCase
|
|||
array('js', array('application/javascript', 'application/x-javascript', 'text/javascript')),
|
||||
array('css', array('text/css')),
|
||||
array('json', array('application/json', 'application/x-json')),
|
||||
array('jsonld', array('application/ld+json')),
|
||||
array('xml', array('text/xml', 'application/xml', 'application/x-xml')),
|
||||
array('rdf', array('application/rdf+xml')),
|
||||
array('atom', array('application/atom+xml')),
|
||||
|
|
@ -847,6 +848,11 @@ class RequestTest extends TestCase
|
|||
$request->setMethod('POST');
|
||||
$request->headers->set('X-HTTP-METHOD-OVERRIDE', 'delete');
|
||||
$this->assertEquals('DELETE', $request->getMethod(), '->getMethod() returns the method from X-HTTP-Method-Override if defined and POST');
|
||||
|
||||
$request = new Request();
|
||||
$request->setMethod('POST');
|
||||
$request->query->set('_method', array('delete', 'patch'));
|
||||
$this->assertSame('POST', $request->getMethod(), '->getMethod() returns the request method if invalid type is defined in query');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -968,6 +974,26 @@ class RequestTest extends TestCase
|
|||
$request->getClientIps();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getClientIpsWithConflictingHeadersProvider
|
||||
*/
|
||||
public function testGetClientIpsOnlyXHttpForwardedForTrusted($httpForwarded, $httpXForwardedFor)
|
||||
{
|
||||
$request = new Request();
|
||||
|
||||
$server = array(
|
||||
'REMOTE_ADDR' => '88.88.88.88',
|
||||
'HTTP_FORWARDED' => $httpForwarded,
|
||||
'HTTP_X_FORWARDED_FOR' => $httpXForwardedFor,
|
||||
);
|
||||
|
||||
Request::setTrustedProxies(array('88.88.88.88'), Request::HEADER_X_FORWARDED_FOR);
|
||||
|
||||
$request->initialize(array(), array(), array(), array(), array(), $server);
|
||||
|
||||
$this->assertSame(array_reverse(explode(',', $httpXForwardedFor)), $request->getClientIps());
|
||||
}
|
||||
|
||||
public function getClientIpsWithConflictingHeadersProvider()
|
||||
{
|
||||
// $httpForwarded $httpXForwardedFor
|
||||
|
|
@ -1286,6 +1312,12 @@ class RequestTest extends TestCase
|
|||
$request->initialize(array(), array(), array(), array(), array(), $server);
|
||||
|
||||
$this->assertEquals('/path%20test/info', $request->getPathInfo());
|
||||
|
||||
$server = array();
|
||||
$server['REQUEST_URI'] = '?a=b';
|
||||
$request->initialize(array(), array(), array(), array(), array(), $server);
|
||||
|
||||
$this->assertEquals('/', $request->getPathInfo());
|
||||
}
|
||||
|
||||
public function testGetParameterPrecedence()
|
||||
|
|
@ -1496,8 +1528,18 @@ class RequestTest extends TestCase
|
|||
$request = new Request();
|
||||
|
||||
$request->headers->set('Accept-language', 'zh, en-us; q=0.8, en; q=0.6');
|
||||
$request->cookies->set('Foo', 'Bar');
|
||||
|
||||
$this->assertContains('Accept-Language: zh, en-us; q=0.8, en; q=0.6', $request->__toString());
|
||||
$asString = (string) $request;
|
||||
|
||||
$this->assertContains('Accept-Language: zh, en-us; q=0.8, en; q=0.6', $asString);
|
||||
$this->assertContains('Cookie: Foo=Bar', $asString);
|
||||
|
||||
$request->cookies->set('Another', 'Cookie');
|
||||
|
||||
$asString = (string) $request;
|
||||
|
||||
$this->assertContains('Cookie: Foo=Bar; Another=Cookie', $asString);
|
||||
}
|
||||
|
||||
public function testIsMethod()
|
||||
|
|
@ -1729,7 +1771,7 @@ class RequestTest extends TestCase
|
|||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation The "Symfony\Component\HttpFoundation\Request::setTrustedHeaderName()" method is deprecated since version 3.3 and will be removed in 4.0. Use the $trustedHeaderSet argument of the Request::setTrustedProxies() method instead.
|
||||
* @expectedDeprecation The "Symfony\Component\HttpFoundation\Request::setTrustedHeaderName()" method is deprecated since Symfony 3.3 and will be removed in 4.0. Use the $trustedHeaderSet argument of the Request::setTrustedProxies() method instead.
|
||||
*/
|
||||
public function testLegacyTrustedProxies()
|
||||
{
|
||||
|
|
@ -1862,20 +1904,6 @@ class RequestTest extends TestCase
|
|||
public function iisRequestUriProvider()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array(
|
||||
'X_ORIGINAL_URL' => '/foo/bar',
|
||||
),
|
||||
array(),
|
||||
'/foo/bar',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'X_REWRITE_URL' => '/foo/bar',
|
||||
),
|
||||
array(),
|
||||
'/foo/bar',
|
||||
),
|
||||
array(
|
||||
array(),
|
||||
array(
|
||||
|
|
@ -1884,36 +1912,6 @@ class RequestTest extends TestCase
|
|||
),
|
||||
'/foo/bar',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'X_ORIGINAL_URL' => '/foo/bar',
|
||||
),
|
||||
array(
|
||||
'HTTP_X_ORIGINAL_URL' => '/foo/bar',
|
||||
),
|
||||
'/foo/bar',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'X_ORIGINAL_URL' => '/foo/bar',
|
||||
),
|
||||
array(
|
||||
'IIS_WasUrlRewritten' => '1',
|
||||
'UNENCODED_URL' => '/foo/bar',
|
||||
),
|
||||
'/foo/bar',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'X_ORIGINAL_URL' => '/foo/bar',
|
||||
),
|
||||
array(
|
||||
'HTTP_X_ORIGINAL_URL' => '/foo/bar',
|
||||
'IIS_WasUrlRewritten' => '1',
|
||||
'UNENCODED_URL' => '/foo/bar',
|
||||
),
|
||||
'/foo/bar',
|
||||
),
|
||||
array(
|
||||
array(),
|
||||
array(
|
||||
|
|
@ -1970,9 +1968,15 @@ class RequestTest extends TestCase
|
|||
|
||||
$request->headers->set('host', 'subdomain.trusted.com');
|
||||
$this->assertEquals('subdomain.trusted.com', $request->getHost());
|
||||
}
|
||||
|
||||
// reset request for following tests
|
||||
Request::setTrustedHosts(array());
|
||||
public function testSetTrustedHostsDoesNotBreakOnSpecialCharacters()
|
||||
{
|
||||
Request::setTrustedHosts(array('localhost(\.local){0,1}#,example.com', 'localhost'));
|
||||
|
||||
$request = Request::create('/');
|
||||
$request->headers->set('host', 'localhost');
|
||||
$this->assertSame('localhost', $request->getHost());
|
||||
}
|
||||
|
||||
public function testFactory()
|
||||
|
|
@ -2099,7 +2103,7 @@ class RequestTest extends TestCase
|
|||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Checking only for cacheable HTTP methods with Symfony\Component\HttpFoundation\Request::isMethodSafe() is deprecated since version 3.2 and will throw an exception in 4.0. Disable checking only for cacheable methods by calling the method with `false` as first argument or use the Request::isMethodCacheable() instead.
|
||||
* @expectedDeprecation Checking only for cacheable HTTP methods with Symfony\Component\HttpFoundation\Request::isMethodSafe() is deprecated since Symfony 3.2 and will throw an exception in 4.0. Disable checking only for cacheable methods by calling the method with `false` as first argument or use the Request::isMethodCacheable() instead.
|
||||
*/
|
||||
public function testMethodSafeChecksCacheable()
|
||||
{
|
||||
|
|
@ -2111,11 +2115,11 @@ class RequestTest extends TestCase
|
|||
/**
|
||||
* @dataProvider methodCacheableProvider
|
||||
*/
|
||||
public function testMethodCacheable($method, $chacheable)
|
||||
public function testMethodCacheable($method, $cacheable)
|
||||
{
|
||||
$request = new Request();
|
||||
$request->setMethod($method);
|
||||
$this->assertEquals($chacheable, $request->isMethodCacheable());
|
||||
$this->assertEquals($cacheable, $request->isMethodCacheable());
|
||||
}
|
||||
|
||||
public function methodCacheableProvider()
|
||||
|
|
@ -2188,13 +2192,98 @@ class RequestTest extends TestCase
|
|||
Request::setTrustedHeaderName(Request::HEADER_CLIENT_PORT, 'X_FORWARDED_PORT');
|
||||
Request::setTrustedHeaderName(Request::HEADER_CLIENT_PROTO, 'X_FORWARDED_PROTO');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider protocolVersionProvider
|
||||
*/
|
||||
public function testProtocolVersion($serverProtocol, $trustedProxy, $via, $expected)
|
||||
{
|
||||
if ($trustedProxy) {
|
||||
Request::setTrustedProxies(array('1.1.1.1'), -1);
|
||||
}
|
||||
|
||||
$request = new Request();
|
||||
$request->server->set('SERVER_PROTOCOL', $serverProtocol);
|
||||
$request->server->set('REMOTE_ADDR', '1.1.1.1');
|
||||
$request->headers->set('Via', $via);
|
||||
|
||||
$this->assertSame($expected, $request->getProtocolVersion());
|
||||
}
|
||||
|
||||
public function protocolVersionProvider()
|
||||
{
|
||||
return array(
|
||||
'untrusted without via' => array('HTTP/2.0', false, '', 'HTTP/2.0'),
|
||||
'untrusted with via' => array('HTTP/2.0', false, '1.0 fred, 1.1 nowhere.com (Apache/1.1)', 'HTTP/2.0'),
|
||||
'trusted without via' => array('HTTP/2.0', true, '', 'HTTP/2.0'),
|
||||
'trusted with via' => array('HTTP/2.0', true, '1.0 fred, 1.1 nowhere.com (Apache/1.1)', 'HTTP/1.0'),
|
||||
'trusted with via and protocol name' => array('HTTP/2.0', true, 'HTTP/1.0 fred, HTTP/1.1 nowhere.com (Apache/1.1)', 'HTTP/1.0'),
|
||||
'trusted with broken via' => array('HTTP/2.0', true, 'HTTP/1^0 foo', 'HTTP/2.0'),
|
||||
'trusted with partially-broken via' => array('HTTP/2.0', true, '1.0 fred, foo', 'HTTP/1.0'),
|
||||
);
|
||||
}
|
||||
|
||||
public function nonstandardRequestsData()
|
||||
{
|
||||
return array(
|
||||
array('', '', '/', 'http://host:8080/', ''),
|
||||
array('/', '', '/', 'http://host:8080/', ''),
|
||||
|
||||
array('hello/app.php/x', '', '/x', 'http://host:8080/hello/app.php/x', '/hello', '/hello/app.php'),
|
||||
array('/hello/app.php/x', '', '/x', 'http://host:8080/hello/app.php/x', '/hello', '/hello/app.php'),
|
||||
|
||||
array('', 'a=b', '/', 'http://host:8080/?a=b'),
|
||||
array('?a=b', 'a=b', '/', 'http://host:8080/?a=b'),
|
||||
array('/?a=b', 'a=b', '/', 'http://host:8080/?a=b'),
|
||||
|
||||
array('x', 'a=b', '/x', 'http://host:8080/x?a=b'),
|
||||
array('x?a=b', 'a=b', '/x', 'http://host:8080/x?a=b'),
|
||||
array('/x?a=b', 'a=b', '/x', 'http://host:8080/x?a=b'),
|
||||
|
||||
array('hello/x', '', '/x', 'http://host:8080/hello/x', '/hello'),
|
||||
array('/hello/x', '', '/x', 'http://host:8080/hello/x', '/hello'),
|
||||
|
||||
array('hello/app.php/x', 'a=b', '/x', 'http://host:8080/hello/app.php/x?a=b', '/hello', '/hello/app.php'),
|
||||
array('hello/app.php/x?a=b', 'a=b', '/x', 'http://host:8080/hello/app.php/x?a=b', '/hello', '/hello/app.php'),
|
||||
array('/hello/app.php/x?a=b', 'a=b', '/x', 'http://host:8080/hello/app.php/x?a=b', '/hello', '/hello/app.php'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider nonstandardRequestsData
|
||||
*/
|
||||
public function testNonstandardRequests($requestUri, $queryString, $expectedPathInfo, $expectedUri, $expectedBasePath = '', $expectedBaseUrl = null)
|
||||
{
|
||||
if (null === $expectedBaseUrl) {
|
||||
$expectedBaseUrl = $expectedBasePath;
|
||||
}
|
||||
|
||||
$server = array(
|
||||
'HTTP_HOST' => 'host:8080',
|
||||
'SERVER_PORT' => '8080',
|
||||
'QUERY_STRING' => $queryString,
|
||||
'PHP_SELF' => '/hello/app.php',
|
||||
'SCRIPT_FILENAME' => '/some/path/app.php',
|
||||
'REQUEST_URI' => $requestUri,
|
||||
);
|
||||
|
||||
$request = new Request(array(), array(), array(), array(), array(), $server);
|
||||
|
||||
$this->assertEquals($expectedPathInfo, $request->getPathInfo());
|
||||
$this->assertEquals($expectedUri, $request->getUri());
|
||||
$this->assertEquals($queryString, $request->getQueryString());
|
||||
$this->assertEquals(8080, $request->getPort());
|
||||
$this->assertEquals('host:8080', $request->getHttpHost());
|
||||
$this->assertEquals($expectedBaseUrl, $request->getBaseUrl());
|
||||
$this->assertEquals($expectedBasePath, $request->getBasePath());
|
||||
}
|
||||
}
|
||||
|
||||
class RequestContentProxy extends Request
|
||||
{
|
||||
public function getContent($asResource = false)
|
||||
{
|
||||
return http_build_query(array('_method' => 'PUT', 'content' => 'mycontent'));
|
||||
return http_build_query(array('_method' => 'PUT', 'content' => 'mycontent'), '', '&');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
134
pfosten/vendor/symfony/http-foundation/Tests/ResponseHeaderBagTest.php
vendored
Executable file → Normal file
134
pfosten/vendor/symfony/http-foundation/Tests/ResponseHeaderBagTest.php
vendored
Executable file → Normal file
|
|
@ -12,56 +12,32 @@
|
|||
namespace Symfony\Component\HttpFoundation\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
|
||||
use Symfony\Component\HttpFoundation\Cookie;
|
||||
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
|
||||
|
||||
/**
|
||||
* @group time-sensitive
|
||||
*/
|
||||
class ResponseHeaderBagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideAllPreserveCase
|
||||
*/
|
||||
public function testAllPreserveCase($headers, $expected)
|
||||
public function testAllPreserveCase()
|
||||
{
|
||||
$bag = new ResponseHeaderBag($headers);
|
||||
|
||||
$this->assertEquals($expected, $bag->allPreserveCase(), '->allPreserveCase() gets all input keys in original case');
|
||||
}
|
||||
|
||||
public function provideAllPreserveCase()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array('fOo' => 'BAR'),
|
||||
array('fOo' => array('BAR'), 'Cache-Control' => array('no-cache, private')),
|
||||
),
|
||||
array(
|
||||
array('ETag' => 'xyzzy'),
|
||||
array('ETag' => array('xyzzy'), 'Cache-Control' => array('private, must-revalidate')),
|
||||
),
|
||||
array(
|
||||
array('Content-MD5' => 'Q2hlY2sgSW50ZWdyaXR5IQ=='),
|
||||
array('Content-MD5' => array('Q2hlY2sgSW50ZWdyaXR5IQ=='), 'Cache-Control' => array('no-cache, private')),
|
||||
),
|
||||
array(
|
||||
array('P3P' => 'CP="CAO PSA OUR"'),
|
||||
array('P3P' => array('CP="CAO PSA OUR"'), 'Cache-Control' => array('no-cache, private')),
|
||||
),
|
||||
array(
|
||||
array('WWW-Authenticate' => 'Basic realm="WallyWorld"'),
|
||||
array('WWW-Authenticate' => array('Basic realm="WallyWorld"'), 'Cache-Control' => array('no-cache, private')),
|
||||
),
|
||||
array(
|
||||
array('X-UA-Compatible' => 'IE=edge,chrome=1'),
|
||||
array('X-UA-Compatible' => array('IE=edge,chrome=1'), 'Cache-Control' => array('no-cache, private')),
|
||||
),
|
||||
array(
|
||||
array('X-XSS-Protection' => '1; mode=block'),
|
||||
array('X-XSS-Protection' => array('1; mode=block'), 'Cache-Control' => array('no-cache, private')),
|
||||
),
|
||||
$headers = array(
|
||||
'fOo' => 'BAR',
|
||||
'ETag' => 'xyzzy',
|
||||
'Content-MD5' => 'Q2hlY2sgSW50ZWdyaXR5IQ==',
|
||||
'P3P' => 'CP="CAO PSA OUR"',
|
||||
'WWW-Authenticate' => 'Basic realm="WallyWorld"',
|
||||
'X-UA-Compatible' => 'IE=edge,chrome=1',
|
||||
'X-XSS-Protection' => '1; mode=block',
|
||||
);
|
||||
|
||||
$bag = new ResponseHeaderBag($headers);
|
||||
$allPreservedCase = $bag->allPreserveCase();
|
||||
|
||||
foreach (array_keys($headers) as $headerName) {
|
||||
$this->assertArrayHasKey($headerName, $allPreservedCase, '->allPreserveCase() gets all input keys in original case');
|
||||
}
|
||||
}
|
||||
|
||||
public function testCacheControlHeader()
|
||||
|
|
@ -110,6 +86,17 @@ class ResponseHeaderBagTest extends TestCase
|
|||
$bag = new ResponseHeaderBag();
|
||||
$bag->set('Last-Modified', 'abcde');
|
||||
$this->assertEquals('private, must-revalidate', $bag->get('Cache-Control'));
|
||||
|
||||
$bag = new ResponseHeaderBag();
|
||||
$bag->set('Cache-Control', array('public', 'must-revalidate'));
|
||||
$this->assertCount(1, $bag->get('Cache-Control', null, false));
|
||||
$this->assertEquals('must-revalidate, public', $bag->get('Cache-Control'));
|
||||
|
||||
$bag = new ResponseHeaderBag();
|
||||
$bag->set('Cache-Control', 'public');
|
||||
$bag->set('Cache-Control', 'must-revalidate', false);
|
||||
$this->assertCount(1, $bag->get('Cache-Control', null, false));
|
||||
$this->assertEquals('must-revalidate, public', $bag->get('Cache-Control'));
|
||||
}
|
||||
|
||||
public function testCacheControlClone()
|
||||
|
|
@ -129,7 +116,7 @@ class ResponseHeaderBagTest extends TestCase
|
|||
|
||||
$bag->clearCookie('foo');
|
||||
|
||||
$this->assertSetCookieHeader('foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; max-age=-31536001; path=/; httponly', $bag);
|
||||
$this->assertSetCookieHeader('foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; Max-Age=0; path=/; httponly', $bag);
|
||||
}
|
||||
|
||||
public function testClearCookieSecureNotHttpOnly()
|
||||
|
|
@ -138,7 +125,7 @@ class ResponseHeaderBagTest extends TestCase
|
|||
|
||||
$bag->clearCookie('foo', '/', null, true, false);
|
||||
|
||||
$this->assertSetCookieHeader('foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; max-age=-31536001; path=/; secure', $bag);
|
||||
$this->assertSetCookieHeader('foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; Max-Age=0; path=/; secure', $bag);
|
||||
}
|
||||
|
||||
public function testReplace()
|
||||
|
|
@ -188,10 +175,10 @@ class ResponseHeaderBagTest extends TestCase
|
|||
|
||||
$cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY);
|
||||
|
||||
$this->assertTrue(isset($cookies['foo.bar']['/path/foo']['foo']));
|
||||
$this->assertTrue(isset($cookies['foo.bar']['/path/bar']['foo']));
|
||||
$this->assertTrue(isset($cookies['bar.foo']['/path/bar']['foo']));
|
||||
$this->assertTrue(isset($cookies['']['/']['foo']));
|
||||
$this->assertArrayHasKey('foo', $cookies['foo.bar']['/path/foo']);
|
||||
$this->assertArrayHasKey('foo', $cookies['foo.bar']['/path/bar']);
|
||||
$this->assertArrayHasKey('foo', $cookies['bar.foo']['/path/bar']);
|
||||
$this->assertArrayHasKey('foo', $cookies['']['/']);
|
||||
}
|
||||
|
||||
public function testRemoveCookie()
|
||||
|
|
@ -204,19 +191,19 @@ class ResponseHeaderBagTest extends TestCase
|
|||
$this->assertTrue($bag->has('set-cookie'));
|
||||
|
||||
$cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY);
|
||||
$this->assertTrue(isset($cookies['foo.bar']['/path/foo']));
|
||||
$this->assertArrayHasKey('/path/foo', $cookies['foo.bar']);
|
||||
|
||||
$bag->removeCookie('foo', '/path/foo', 'foo.bar');
|
||||
$this->assertTrue($bag->has('set-cookie'));
|
||||
|
||||
$cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY);
|
||||
$this->assertFalse(isset($cookies['foo.bar']['/path/foo']));
|
||||
$this->assertArrayNotHasKey('/path/foo', $cookies['foo.bar']);
|
||||
|
||||
$bag->removeCookie('bar', '/path/bar', 'foo.bar');
|
||||
$this->assertFalse($bag->has('set-cookie'));
|
||||
|
||||
$cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY);
|
||||
$this->assertFalse(isset($cookies['foo.bar']));
|
||||
$this->assertArrayNotHasKey('foo.bar', $cookies);
|
||||
}
|
||||
|
||||
public function testRemoveCookieWithNullRemove()
|
||||
|
|
@ -226,11 +213,11 @@ class ResponseHeaderBagTest extends TestCase
|
|||
$bag->setCookie(new Cookie('bar', 'foo', 0));
|
||||
|
||||
$cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY);
|
||||
$this->assertTrue(isset($cookies['']['/']));
|
||||
$this->assertArrayHasKey('/', $cookies['']);
|
||||
|
||||
$bag->removeCookie('foo', null);
|
||||
$cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY);
|
||||
$this->assertFalse(isset($cookies['']['/']['foo']));
|
||||
$this->assertArrayNotHasKey('foo', $cookies['']['/']);
|
||||
|
||||
$bag->removeCookie('bar', null);
|
||||
$cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY);
|
||||
|
|
@ -241,12 +228,12 @@ class ResponseHeaderBagTest extends TestCase
|
|||
{
|
||||
$bag = new ResponseHeaderBag();
|
||||
$bag->set('set-cookie', 'foo=bar');
|
||||
$this->assertEquals(array(new Cookie('foo', 'bar', 0, '/', null, false, true, true)), $bag->getCookies());
|
||||
$this->assertEquals(array(new Cookie('foo', 'bar', 0, '/', null, false, false, true)), $bag->getCookies());
|
||||
|
||||
$bag->set('set-cookie', 'foo2=bar2', false);
|
||||
$this->assertEquals(array(
|
||||
new Cookie('foo', 'bar', 0, '/', null, false, true, true),
|
||||
new Cookie('foo2', 'bar2', 0, '/', null, false, true, true),
|
||||
new Cookie('foo', 'bar', 0, '/', null, false, false, true),
|
||||
new Cookie('foo2', 'bar2', 0, '/', null, false, false, true),
|
||||
), $bag->getCookies());
|
||||
|
||||
$bag->remove('set-cookie');
|
||||
|
|
@ -332,6 +319,43 @@ class ResponseHeaderBagTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
public function testDateHeaderAddedOnCreation()
|
||||
{
|
||||
$now = time();
|
||||
|
||||
$bag = new ResponseHeaderBag();
|
||||
$this->assertTrue($bag->has('Date'));
|
||||
|
||||
$this->assertEquals($now, $bag->getDate('Date')->getTimestamp());
|
||||
}
|
||||
|
||||
public function testDateHeaderCanBeSetOnCreation()
|
||||
{
|
||||
$someDate = 'Thu, 23 Mar 2017 09:15:12 GMT';
|
||||
$bag = new ResponseHeaderBag(array('Date' => $someDate));
|
||||
|
||||
$this->assertEquals($someDate, $bag->get('Date'));
|
||||
}
|
||||
|
||||
public function testDateHeaderWillBeRecreatedWhenRemoved()
|
||||
{
|
||||
$someDate = 'Thu, 23 Mar 2017 09:15:12 GMT';
|
||||
$bag = new ResponseHeaderBag(array('Date' => $someDate));
|
||||
$bag->remove('Date');
|
||||
|
||||
// a (new) Date header is still present
|
||||
$this->assertTrue($bag->has('Date'));
|
||||
$this->assertNotEquals($someDate, $bag->get('Date'));
|
||||
}
|
||||
|
||||
public function testDateHeaderWillBeRecreatedWhenHeadersAreReplaced()
|
||||
{
|
||||
$bag = new ResponseHeaderBag();
|
||||
$bag->replace(array());
|
||||
|
||||
$this->assertTrue($bag->has('Date'));
|
||||
}
|
||||
|
||||
private function assertSetCookieHeader($expected, ResponseHeaderBag $actual)
|
||||
{
|
||||
$this->assertRegExp('#^Set-Cookie:\s+'.preg_quote($expected, '#').'$#m', str_replace("\r\n", "\n", (string) $actual));
|
||||
|
|
|
|||
35
pfosten/vendor/symfony/http-foundation/Tests/ResponseTest.php
vendored
Executable file → Normal file
35
pfosten/vendor/symfony/http-foundation/Tests/ResponseTest.php
vendored
Executable file → Normal file
|
|
@ -126,7 +126,7 @@ class ResponseTest extends ResponseTestCase
|
|||
|
||||
public function testSetNotModified()
|
||||
{
|
||||
$response = new Response();
|
||||
$response = new Response('foo');
|
||||
$modified = $response->setNotModified();
|
||||
$this->assertObjectHasAttribute('headers', $modified);
|
||||
$this->assertObjectHasAttribute('content', $modified);
|
||||
|
|
@ -135,6 +135,11 @@ class ResponseTest extends ResponseTestCase
|
|||
$this->assertObjectHasAttribute('statusText', $modified);
|
||||
$this->assertObjectHasAttribute('charset', $modified);
|
||||
$this->assertEquals(304, $modified->getStatusCode());
|
||||
|
||||
ob_start();
|
||||
$modified->sendContent();
|
||||
$string = ob_get_clean();
|
||||
$this->assertEmpty($string);
|
||||
}
|
||||
|
||||
public function testIsSuccessful()
|
||||
|
|
@ -610,6 +615,12 @@ class ResponseTest extends ResponseTestCase
|
|||
$response->setCache(array('private' => false));
|
||||
$this->assertTrue($response->headers->hasCacheControlDirective('public'));
|
||||
$this->assertFalse($response->headers->hasCacheControlDirective('private'));
|
||||
|
||||
$response->setCache(array('immutable' => true));
|
||||
$this->assertTrue($response->headers->hasCacheControlDirective('immutable'));
|
||||
|
||||
$response->setCache(array('immutable' => false));
|
||||
$this->assertFalse($response->headers->hasCacheControlDirective('immutable'));
|
||||
}
|
||||
|
||||
public function testSendContent()
|
||||
|
|
@ -631,6 +642,22 @@ class ResponseTest extends ResponseTestCase
|
|||
$this->assertFalse($response->headers->hasCacheControlDirective('private'));
|
||||
}
|
||||
|
||||
public function testSetImmutable()
|
||||
{
|
||||
$response = new Response();
|
||||
$response->setImmutable();
|
||||
|
||||
$this->assertTrue($response->headers->hasCacheControlDirective('immutable'));
|
||||
}
|
||||
|
||||
public function testIsImmutable()
|
||||
{
|
||||
$response = new Response();
|
||||
$response->setImmutable();
|
||||
|
||||
$this->assertTrue($response->isImmutable());
|
||||
}
|
||||
|
||||
public function testSetExpires()
|
||||
{
|
||||
$response = new Response();
|
||||
|
|
@ -904,7 +931,7 @@ class ResponseTest extends ResponseTestCase
|
|||
*/
|
||||
public function ianaCodesReasonPhrasesProvider()
|
||||
{
|
||||
if (!in_array('https', stream_get_wrappers(), true)) {
|
||||
if (!\in_array('https', stream_get_wrappers(), true)) {
|
||||
$this->markTestSkipped('The "https" wrapper is not available');
|
||||
}
|
||||
|
||||
|
|
@ -924,7 +951,7 @@ class ResponseTest extends ResponseTestCase
|
|||
|
||||
$ianaCodesReasonPhrases = array();
|
||||
|
||||
$xpath = new \DomXPath($ianaHttpStatusCodes);
|
||||
$xpath = new \DOMXPath($ianaHttpStatusCodes);
|
||||
$xpath->registerNamespace('ns', 'http://www.iana.org/assignments');
|
||||
|
||||
$records = $xpath->query('//ns:record');
|
||||
|
|
@ -932,7 +959,7 @@ class ResponseTest extends ResponseTestCase
|
|||
$value = $xpath->query('.//ns:value', $record)->item(0)->nodeValue;
|
||||
$description = $xpath->query('.//ns:description', $record)->item(0)->nodeValue;
|
||||
|
||||
if (in_array($description, array('Unassigned', '(Unused)'), true)) {
|
||||
if (\in_array($description, array('Unassigned', '(Unused)'), true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/http-foundation/Tests/ResponseTestCase.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/Tests/ResponseTestCase.php
vendored
Executable file → Normal file
8
pfosten/vendor/symfony/http-foundation/Tests/ServerBagTest.php
vendored
Executable file → Normal file
8
pfosten/vendor/symfony/http-foundation/Tests/ServerBagTest.php
vendored
Executable file → Normal file
|
|
@ -74,8 +74,8 @@ class ServerBagTest extends TestCase
|
|||
|
||||
// Username and passwords should not be set as the header is bogus
|
||||
$headers = $bag->getHeaders();
|
||||
$this->assertFalse(isset($headers['PHP_AUTH_USER']));
|
||||
$this->assertFalse(isset($headers['PHP_AUTH_PW']));
|
||||
$this->assertArrayNotHasKey('PHP_AUTH_USER', $headers);
|
||||
$this->assertArrayNotHasKey('PHP_AUTH_PW', $headers);
|
||||
}
|
||||
|
||||
public function testHttpBasicAuthWithPhpCgiRedirect()
|
||||
|
|
@ -118,8 +118,8 @@ class ServerBagTest extends TestCase
|
|||
|
||||
// Username and passwords should not be set as the header is bogus
|
||||
$headers = $bag->getHeaders();
|
||||
$this->assertFalse(isset($headers['PHP_AUTH_USER']));
|
||||
$this->assertFalse(isset($headers['PHP_AUTH_PW']));
|
||||
$this->assertArrayNotHasKey('PHP_AUTH_USER', $headers);
|
||||
$this->assertArrayNotHasKey('PHP_AUTH_PW', $headers);
|
||||
}
|
||||
|
||||
public function testHttpDigestAuthWithPhpCgiRedirect()
|
||||
|
|
|
|||
9
pfosten/vendor/symfony/http-foundation/Tests/Session/Attribute/AttributeBagTest.php
vendored
Executable file → Normal file
9
pfosten/vendor/symfony/http-foundation/Tests/Session/Attribute/AttributeBagTest.php
vendored
Executable file → Normal file
|
|
@ -21,10 +21,7 @@ use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag;
|
|||
*/
|
||||
class AttributeBagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $array;
|
||||
private $array = array();
|
||||
|
||||
/**
|
||||
* @var AttributeBag
|
||||
|
|
@ -179,11 +176,11 @@ class AttributeBagTest extends TestCase
|
|||
++$i;
|
||||
}
|
||||
|
||||
$this->assertEquals(count($this->array), $i);
|
||||
$this->assertEquals(\count($this->array), $i);
|
||||
}
|
||||
|
||||
public function testCount()
|
||||
{
|
||||
$this->assertEquals(count($this->array), count($this->bag));
|
||||
$this->assertCount(\count($this->array), $this->bag);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
27
pfosten/vendor/symfony/http-foundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php
vendored
Executable file → Normal file
27
pfosten/vendor/symfony/http-foundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php
vendored
Executable file → Normal file
|
|
@ -21,10 +21,7 @@ use Symfony\Component\HttpFoundation\Session\Attribute\NamespacedAttributeBag;
|
|||
*/
|
||||
class NamespacedAttributeBagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $array;
|
||||
private $array = array();
|
||||
|
||||
/**
|
||||
* @var NamespacedAttributeBag
|
||||
|
|
@ -85,6 +82,17 @@ class NamespacedAttributeBagTest extends TestCase
|
|||
$this->assertEquals($exists, $this->bag->has($key));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider attributesProvider
|
||||
*/
|
||||
public function testHasNoSideEffect($key, $value, $expected)
|
||||
{
|
||||
$expected = json_encode($this->bag->all());
|
||||
$this->bag->has($key);
|
||||
|
||||
$this->assertEquals($expected, json_encode($this->bag->all()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider attributesProvider
|
||||
*/
|
||||
|
|
@ -99,6 +107,17 @@ class NamespacedAttributeBagTest extends TestCase
|
|||
$this->assertEquals('default', $this->bag->get('user2.login', 'default'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider attributesProvider
|
||||
*/
|
||||
public function testGetNoSideEffect($key, $value, $expected)
|
||||
{
|
||||
$expected = json_encode($this->bag->all());
|
||||
$this->bag->get($key);
|
||||
|
||||
$this->assertEquals($expected, json_encode($this->bag->all()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider attributesProvider
|
||||
*/
|
||||
|
|
|
|||
13
pfosten/vendor/symfony/http-foundation/Tests/Session/Flash/AutoExpireFlashBagTest.php
vendored
Executable file → Normal file
13
pfosten/vendor/symfony/http-foundation/Tests/Session/Flash/AutoExpireFlashBagTest.php
vendored
Executable file → Normal file
|
|
@ -26,9 +26,6 @@ class AutoExpireFlashBagTest extends TestCase
|
|||
*/
|
||||
private $bag;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $array = array();
|
||||
|
||||
protected function setUp()
|
||||
|
|
@ -62,7 +59,7 @@ class AutoExpireFlashBagTest extends TestCase
|
|||
|
||||
public function testGetStorageKey()
|
||||
{
|
||||
$this->assertEquals('_sf2_flashes', $this->bag->getStorageKey());
|
||||
$this->assertEquals('_symfony_flashes', $this->bag->getStorageKey());
|
||||
$attributeBag = new FlashBag('test');
|
||||
$this->assertEquals('test', $attributeBag->getStorageKey());
|
||||
}
|
||||
|
|
@ -153,4 +150,12 @@ class AutoExpireFlashBagTest extends TestCase
|
|||
{
|
||||
$this->assertEquals(array('notice' => array('A previous flash message')), $this->bag->clear());
|
||||
}
|
||||
|
||||
public function testDoNotRemoveTheNewFlashesWhenDisplayingTheExistingOnes()
|
||||
{
|
||||
$this->bag->add('success', 'Something');
|
||||
$this->bag->all();
|
||||
|
||||
$this->assertEquals(array('new' => array('success' => array('Something')), 'display' => array()), $this->array);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
30
pfosten/vendor/symfony/http-foundation/Tests/Session/Flash/FlashBagTest.php
vendored
Executable file → Normal file
30
pfosten/vendor/symfony/http-foundation/Tests/Session/Flash/FlashBagTest.php
vendored
Executable file → Normal file
|
|
@ -26,9 +26,6 @@ class FlashBagTest extends TestCase
|
|||
*/
|
||||
private $bag;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $array = array();
|
||||
|
||||
protected function setUp()
|
||||
|
|
@ -57,7 +54,7 @@ class FlashBagTest extends TestCase
|
|||
|
||||
public function testGetStorageKey()
|
||||
{
|
||||
$this->assertEquals('_sf2_flashes', $this->bag->getStorageKey());
|
||||
$this->assertEquals('_symfony_flashes', $this->bag->getStorageKey());
|
||||
$attributeBag = new FlashBag('test');
|
||||
$this->assertEquals('test', $attributeBag->getStorageKey());
|
||||
}
|
||||
|
|
@ -77,6 +74,18 @@ class FlashBagTest extends TestCase
|
|||
$this->assertEquals(array('A previous flash message'), $this->bag->peek('notice'));
|
||||
}
|
||||
|
||||
public function testAdd()
|
||||
{
|
||||
$tab = array('bar' => 'baz');
|
||||
$this->bag->add('string_message', 'lorem');
|
||||
$this->bag->add('object_message', new \stdClass());
|
||||
$this->bag->add('array_message', $tab);
|
||||
|
||||
$this->assertEquals(array('lorem'), $this->bag->get('string_message'));
|
||||
$this->assertEquals(array(new \stdClass()), $this->bag->get('object_message'));
|
||||
$this->assertEquals(array($tab), $this->bag->get('array_message'));
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
{
|
||||
$this->assertEquals(array(), $this->bag->get('non_existing'));
|
||||
|
|
@ -115,6 +124,19 @@ class FlashBagTest extends TestCase
|
|||
$this->assertEquals(array('notice'), $this->bag->keys());
|
||||
}
|
||||
|
||||
public function testSetAll()
|
||||
{
|
||||
$this->bag->add('one_flash', 'Foo');
|
||||
$this->bag->add('another_flash', 'Bar');
|
||||
$this->assertTrue($this->bag->has('one_flash'));
|
||||
$this->assertTrue($this->bag->has('another_flash'));
|
||||
$this->bag->setAll(array('unique_flash' => 'FooBar'));
|
||||
$this->assertFalse($this->bag->has('one_flash'));
|
||||
$this->assertFalse($this->bag->has('another_flash'));
|
||||
$this->assertSame(array('unique_flash' => 'FooBar'), $this->bag->all());
|
||||
$this->assertSame(array(), $this->bag->all());
|
||||
}
|
||||
|
||||
public function testPeekAll()
|
||||
{
|
||||
$this->bag->set('notice', 'Foo');
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue