@ -95,7 +95,7 @@ public function getInt($key, $default = 0, $deep = false)
{
return (int) $this->get($key, $default, $deep);
}
public function filter($key, $default = null, $deep = false, $filter=FILTER_DEFAULT, $options=array())
public function filter($key, $default = null, $deep = false, $filter = FILTER_DEFAULT, $options = array())
{
$value = $this->get($key, $default, $deep);
if (!is_array($options) && $options) {
@ -120,12 +120,10 @@ namespace Symfony\Component\HttpFoundation
{
class HeaderBag implements \IteratorAggregate, \Countable
{
protected $headers;
protected $cacheControl;
protected $headers = array() ;
protected $cacheControl = array() ;
public function __construct(array $headers = array())
{
$this->cacheControl = array();
$this->headers = array();
foreach ($headers as $key => $values) {
$this->set($key, $values);
}
@ -418,6 +416,7 @@ public $headers;
protected $content;
protected $languages;
protected $charsets;
protected $encodings;
protected $acceptableContentTypes;
protected $pathInfo;
protected $requestUri;
@ -429,6 +428,7 @@ protected $session;
protected $locale;
protected $defaultLocale ='en';
protected static $formats;
protected static $requestFactory;
public function __construct(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null)
{
$this->initialize($query, $request, $attributes, $cookies, $files, $server, $content);
@ -445,6 +445,7 @@ $this->headers = new HeaderBag($this->server->getHeaders());
$this->content = $content;
$this->languages = null;
$this->charsets = null;
$this->encodings = null;
$this->acceptableContentTypes = null;
$this->pathInfo = null;
$this->requestUri = null;
@ -455,7 +456,7 @@ $this->format = null;
}
public static function createFromGlobals()
{
$request = new static ($_GET, $_POST, array(), $_COOKIE, $_FILES, $_SERVER);
$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'))
) {
@ -528,7 +529,11 @@ $queryString = http_build_query($query,'','&');
}
$server['REQUEST_URI'] = $components['path'].(''!== $queryString ?'?'.$queryString :'');
$server['QUERY_STRING'] = $queryString;
return new static($query, $request, array(), $cookies, $files, $server, $content);
return self::createRequestFromFactory($query, $request, array(), $cookies, $files, $server, $content);
}
public static function setFactory($callable)
{
self::$requestFactory = $callable;
}
public function duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null)
{
@ -554,6 +559,7 @@ $dup->headers = new HeaderBag($dup->server->getHeaders());
}
$dup->languages = null;
$dup->charsets = null;
$dup->encodings = null;
$dup->acceptableContentTypes = null;
$dup->pathInfo = null;
$dup->requestUri = null;
@ -832,7 +838,7 @@ $host = $this->server->get('SERVER_ADDR','');
}
$host = strtolower(preg_replace('/:\d+$/','', trim($host)));
if ($host && !preg_match('/^\[?(?:[a-zA-Z0-9-:\]_]+\.?)+$/', $host)) {
throw new \UnexpectedValueException('Invalid Host "'.$host.'"' );
throw new \UnexpectedValueException(sprintf('Invalid Host "%s"', $host) );
}
if (count(self::$trustedHostPatterns) > 0) {
if (in_array($host, self::$trustedHosts)) {
@ -844,7 +850,7 @@ self::$trustedHosts[] = $host;
return $host;
}
}
throw new \UnexpectedValueException('Untrusted Host "'.$host.'"' );
throw new \UnexpectedValueException(sprintf('Untrusted Host "%s"', $host) );
}
return $host;
}
@ -1016,6 +1022,13 @@ return $this->charsets;
}
return $this->charsets = array_keys(AcceptHeader::fromString($this->headers->get('Accept-Charset'))->all());
}
public function getEncodings()
{
if (null !== $this->encodings) {
return $this->encodings;
}
return $this->encodings = array_keys(AcceptHeader::fromString($this->headers->get('Accept-Encoding'))->all());
}
public function getAcceptableContentTypes()
{
if (null !== $this->acceptableContentTypes) {
@ -1160,12 +1173,65 @@ return $match[0];
}
return false;
}
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);
if (!$request instanceof Request) {
throw new \LogicException('The Request factory must return an instance of Symfony\Component\HttpFoundation\Request.');
}
return $request;
}
return new static($query, $request, $attributes, $cookies, $files, $server, $content);
}
}
}
namespace Symfony\Component\HttpFoundation
{
class Response
{
const HTTP_CONTINUE = 100;
const HTTP_SWITCHING_PROTOCOLS = 101;
const HTTP_PROCESSING = 102; const HTTP_OK = 200;
const HTTP_CREATED = 201;
const HTTP_ACCEPTED = 202;
const HTTP_NON_AUTHORITATIVE_INFORMATION = 203;
const HTTP_NO_CONTENT = 204;
const HTTP_RESET_CONTENT = 205;
const HTTP_PARTIAL_CONTENT = 206;
const HTTP_MULTI_STATUS = 207; const HTTP_ALREADY_REPORTED = 208; const HTTP_IM_USED = 226; const HTTP_MULTIPLE_CHOICES = 300;
const HTTP_MOVED_PERMANENTLY = 301;
const HTTP_FOUND = 302;
const HTTP_SEE_OTHER = 303;
const HTTP_NOT_MODIFIED = 304;
const HTTP_USE_PROXY = 305;
const HTTP_RESERVED = 306;
const HTTP_TEMPORARY_REDIRECT = 307;
const HTTP_PERMANENTLY_REDIRECT = 308; const HTTP_BAD_REQUEST = 400;
const HTTP_UNAUTHORIZED = 401;
const HTTP_PAYMENT_REQUIRED = 402;
const HTTP_FORBIDDEN = 403;
const HTTP_NOT_FOUND = 404;
const HTTP_METHOD_NOT_ALLOWED = 405;
const HTTP_NOT_ACCEPTABLE = 406;
const HTTP_PROXY_AUTHENTICATION_REQUIRED = 407;
const HTTP_REQUEST_TIMEOUT = 408;
const HTTP_CONFLICT = 409;
const HTTP_GONE = 410;
const HTTP_LENGTH_REQUIRED = 411;
const HTTP_PRECONDITION_FAILED = 412;
const HTTP_REQUEST_ENTITY_TOO_LARGE = 413;
const HTTP_REQUEST_URI_TOO_LONG = 414;
const HTTP_UNSUPPORTED_MEDIA_TYPE = 415;
const HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = 416;
const HTTP_EXPECTATION_FAILED = 417;
const HTTP_I_AM_A_TEAPOT = 418; const HTTP_UNPROCESSABLE_ENTITY = 422; const HTTP_LOCKED = 423; const HTTP_FAILED_DEPENDENCY = 424; const HTTP_RESERVED_FOR_WEBDAV_ADVANCED_COLLECTIONS_EXPIRED_PROPOSAL = 425; const HTTP_UPGRADE_REQUIRED = 426; const HTTP_PRECONDITION_REQUIRED = 428; const HTTP_TOO_MANY_REQUESTS = 429; const HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = 431; const HTTP_INTERNAL_SERVER_ERROR = 500;
const HTTP_NOT_IMPLEMENTED = 501;
const HTTP_BAD_GATEWAY = 502;
const HTTP_SERVICE_UNAVAILABLE = 503;
const HTTP_GATEWAY_TIMEOUT = 504;
const HTTP_VERSION_NOT_SUPPORTED = 505;
const HTTP_VARIANT_ALSO_NEGOTIATES_EXPERIMENTAL = 506; const HTTP_INSUFFICIENT_STORAGE = 507; const HTTP_LOOP_DETECTED = 508; const HTTP_NOT_EXTENDED = 510; const HTTP_NETWORK_AUTHENTICATION_REQUIRED = 511;
public $headers;
protected $content;
protected $version;
@ -1283,10 +1349,10 @@ public function sendHeaders()
if (headers_sent()) {
return $this;
}
header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText));
header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), true, $this->statusCode );
foreach ($this->headers->allPreserveCase() as $name => $values) {
foreach ($values as $value) {
header($name.': '.$value, false);
header($name.': '.$value, false, $this->statusCode );
}
}
foreach ($this->headers->getCookies() as $cookie) {
@ -1306,22 +1372,7 @@ $this->sendContent();
if (function_exists('fastcgi_finish_request')) {
fastcgi_finish_request();
} elseif ('cli'!== PHP_SAPI) {
$previous = null;
$obStatus = ob_get_status(1);
while (($level = ob_get_level()) > 0 && $level !== $previous) {
$previous = $level;
if ($obStatus[$level - 1]) {
if (version_compare(PHP_VERSION,'5.4','>=')) {
if (isset($obStatus[$level - 1]['flags']) && ($obStatus[$level - 1]['flags'] & PHP_OUTPUT_HANDLER_REMOVABLE)) {
ob_end_flush();
}
} else {
if (isset($obStatus[$level - 1]['del']) && $obStatus[$level - 1]['del']) {
ob_end_flush();
}
}
}
}
static::closeOutputBuffers(0, true);
flush();
}
return $this;
@ -1647,6 +1698,25 @@ public function isEmpty()
{
return in_array($this->statusCode, array(204, 304));
}
public static function closeOutputBuffers($targetLevel, $flush)
{
$status = ob_get_status(true);
$level = count($status);
while ($level-- > $targetLevel
&& (!empty($status[$level]['del'])
|| (isset($status[$level]['flags'])
&& ($status[$level]['flags'] & PHP_OUTPUT_HANDLER_REMOVABLE)
&& ($status[$level]['flags'] & ($flush ? PHP_OUTPUT_HANDLER_FLUSHABLE : PHP_OUTPUT_HANDLER_CLEANABLE))
)
)
) {
if ($flush) {
ob_end_flush();
} else {
ob_end_clean();
}
}
}
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()) {
@ -1858,23 +1928,17 @@ use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
class Container implements IntrospectableContainerInterface
{
protected $parameterBag;
protected $services;
protected $methodMap;
protected $aliases;
protected $scopes;
protected $scopeChildren;
protected $scopedServices;
protected $scopeStacks;
protected $services = array() ;
protected $methodMap = array() ;
protected $aliases = array() ;
protected $scopes = array() ;
protected $scopeChildren = array() ;
protected $scopedServices = array() ;
protected $scopeStacks = array() ;
protected $loading = array();
public function __construct(ParameterBagInterface $parameterBag = null)
{
$this->parameterBag = null === $parameterBag ? new ParameterBag() : $parameterBag;
$this->services = array();
$this->aliases = array();
$this->scopes = array();
$this->scopeChildren = array();
$this->scopedServices = array();
$this->scopeStacks = array();
$this->parameterBag = $parameterBag ?: new ParameterBag();
$this->set('service_container', $this);
}
public function compile()
@ -2159,33 +2223,30 @@ use Symfony\Component\Config\Loader\LoaderResolver;
use Symfony\Component\Config\Loader\DelegatingLoader;
use Symfony\Component\Config\ConfigCache;
use Symfony\Component\ClassLoader\ClassCollectionLoader;
use Symfony\Component\Filesystem\Filesystem;
abstract class Kernel implements KernelInterface, TerminableInterface
{
protected $bundles;
protected $bundles = array() ;
protected $bundleMap;
protected $container;
protected $rootDir;
protected $environment;
protected $debug;
protected $booted;
protected $booted = false ;
protected $name;
protected $startTime;
protected $loadClassCache;
const VERSION ='2.3.15 ';
const VERSION_ID ='2031 5';
const VERSION ='2.5.0 ';
const VERSION_ID ='20500 ';
const MAJOR_VERSION ='2';
const MINOR_VERSION ='3 ';
const RELEASE_VERSION ='15 ';
const MINOR_VERSION ='5 ';
const RELEASE_VERSION ='0 ';
const EXTRA_VERSION ='';
public function __construct($environment, $debug)
{
$this->environment = $environment;
$this->debug = (bool) $debug;
$this->booted = false;
$this->rootDir = $this->getRootDir();
$this->name = $this->getName();
$this->bundles = array();
if ($this->debug) {
$this->startTime = microtime(true);
}
@ -2520,33 +2581,8 @@ $content = $dumper->dump(array('class'=> $class,'base_class'=> $baseClass));
if (!$this->debug) {
$content = static::stripComments($content);
}
$content = $this->removeAbsolutePathsFromContainer($content);
$cache->write($content, $container->getResources());
}
private function removeAbsolutePathsFromContainer($content)
{
if (!class_exists('Symfony\Component\Filesystem\Filesystem')) {
return $content;
}
$rootDir = $this->getRootDir();
$previous = $rootDir;
while (!file_exists($rootDir.'/composer.json')) {
if ($previous === $rootDir = realpath($rootDir.'/..')) {
return $content;
}
$previous = $rootDir;
}
$rootDir = rtrim($rootDir,'/');
$cacheDir = $this->getCacheDir();
$filesystem = new Filesystem();
return preg_replace_callback("{'([^']*)(".preg_quote($rootDir)."[^']*)'}", function ($match) use ($filesystem, $cacheDir) {
$prefix = isset($match[1]) && $match[1] ? "'$match[1]'.__DIR__" :"__DIR__";
if ('.'=== $relativePath = rtrim($filesystem->makePathRelative($match[2], $cacheDir),'/')) {
return $prefix;
}
return $prefix.".'/".$relativePath."'";
}, $content);
}
protected function getContainerLoader(ContainerInterface $container)
{
$locator = new FileLocator($this);
@ -2691,8 +2727,8 @@ use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
abstract class Bundle extends ContainerAware implements BundleInterface
{
protected $name;
protected $reflected;
protected $extension;
protected $path;
public function boot()
{
}
@ -2726,17 +2762,16 @@ return $this->extension;
}
public function getNamespace()
{
if (null === $this->reflected) {
$this->reflected = new \ReflectionObject($this);
}
return $this->reflected->getNamespaceName();
$class = get_class($this);
return substr($class, 0, strrpos($class,'\\'));
}
public function getPath()
{
if (null === $this->reflected) {
$this->reflected = new \ReflectionObject($this);
if (null === $this->path) {
$reflected = new \ReflectionObject($this);
$this->path = dirname($reflected->getFileName());
}
return dirname($this->reflected->getFileName()) ;
return $this->path ;
}
public function getParent()
{
@ -2763,7 +2798,14 @@ $ns = $prefix;
if ($relativePath = $file->getRelativePath()) {
$ns .='\\'.strtr($relativePath,'/','\\');
}
$r = new \ReflectionClass($ns.'\\'.$file->getBasename('.php'));
$class = $ns.'\\'.$file->getBasename('.php');
if ($this->container) {
$alias ='console.command.'.strtolower(str_replace('\\','_', $class));
if ($this->container->has($alias)) {
continue;
}
}
$r = new \ReflectionClass($class);
if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract() && !$r->getConstructor()->getNumberOfRequiredParameters()) {
$application->add($r->newInstance());
}
@ -2841,21 +2883,25 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class HttpKernel implements HttpKernelInterface, TerminableInterface
{
protected $dispatcher;
protected $resolver;
public function __construct(EventDispatcherInterface $dispatcher, ControllerResolverInterface $resolver)
protected $requestStack;
public function __construct(EventDispatcherInterface $dispatcher, ControllerResolverInterface $resolver, RequestStack $requestStack = null)
{
$this->dispatcher = $dispatcher;
$this->resolver = $resolver;
$this->requestStack = $requestStack ?: new RequestStack();
}
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
@ -2863,6 +2909,7 @@ try {
return $this->handleRaw($request, $type);
} catch (\Exception $e) {
if (false === $catch) {
$this->finishRequest($request, $type);
throw $e;
}
return $this->handleException($e, $request, $type);
@ -2872,8 +2919,19 @@ public function terminate(Request $request, Response $response)
{
$this->dispatcher->dispatch(KernelEvents::TERMINATE, new PostResponseEvent($this, $request, $response));
}
public function terminateWithException(\Exception $exception)
{
if (!$request = $this->requestStack->getMasterRequest()) {
throw new \LogicException('Request stack is empty', 0, $exception);
}
$response = $this->handleException($exception, $request, self::MASTER_REQUEST);
$response->sendHeaders();
$response->sendContent();
$this->terminate($request, $response);
}
private function handleRaw(Request $request, $type = self::MASTER_REQUEST)
{
$this->requestStack->push($request);
$event = new GetResponseEvent($this, $request, $type);
$this->dispatcher->dispatch(KernelEvents::REQUEST, $event);
if ($event->hasResponse()) {
@ -2907,14 +2965,21 @@ private function filterResponse(Response $response, Request $request, $type)
{
$event = new FilterResponseEvent($this, $request, $type, $response);
$this->dispatcher->dispatch(KernelEvents::RESPONSE, $event);
$this->finishRequest($request, $type);
return $event->getResponse();
}
private function finishRequest(Request $request, $type)
{
$this->dispatcher->dispatch(KernelEvents::FINISH_REQUEST, new FinishRequestEvent($this, $request, $type));
$this->requestStack->pop();
}
private function handleException(\Exception $e, $request, $type)
{
$event = new GetResponseForExceptionEvent($this, $request, $type, $e);
$this->dispatcher->dispatch(KernelEvents::EXCEPTION, $event);
$e = $event->getException();
if (!$event->hasResponse()) {
$this->finishRequest($request, $type);
throw $e;
}
$response = $event->getResponse();
@ -2966,6 +3031,7 @@ return (string) $var;
namespace Symfony\Component\HttpKernel\DependencyInjection
{
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\HttpKernel;
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
@ -2975,9 +3041,9 @@ use Symfony\Component\DependencyInjection\Scope;
class ContainerAwareHttpKernel extends HttpKernel
{
protected $container;
public function __construct(EventDispatcherInterface $dispatcher, ContainerInterface $container, ControllerResolverInterface $controllerResolver)
public function __construct(EventDispatcherInterface $dispatcher, ContainerInterface $container, ControllerResolverInterface $controllerResolver, RequestStack $requestStack = null )
{
parent::__construct($dispatcher, $controllerResolver);
parent::__construct($dispatcher, $controllerResolver, $requestStack );
$this->container = $container;
if (!$container->hasScope('request')) {
$container->addScope(new Scope('request'));