PageRenderTime 63ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 2ms

/bootstrap/compiled.php

https://github.com/liamjay/basic-laravel-authentication
PHP | 10600 lines | 10510 code | 90 blank | 0 comment | 815 complexity | 256ff71a41db89c2226051e6eb6926ab MD5 | raw file
Possible License(s): BSD-3-Clause

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. namespace Illuminate\Support;
  3. class ClassLoader
  4. {
  5. protected static $directories = array();
  6. protected static $registered = false;
  7. public static function load($class)
  8. {
  9. $class = static::normalizeClass($class);
  10. foreach (static::$directories as $directory) {
  11. if (file_exists($path = $directory . DIRECTORY_SEPARATOR . $class)) {
  12. require_once $path;
  13. return true;
  14. }
  15. }
  16. return false;
  17. }
  18. public static function normalizeClass($class)
  19. {
  20. if ($class[0] == '\\') {
  21. $class = substr($class, 1);
  22. }
  23. return str_replace(array('\\', '_'), DIRECTORY_SEPARATOR, $class) . '.php';
  24. }
  25. public static function register()
  26. {
  27. if (!static::$registered) {
  28. static::$registered = spl_autoload_register(array('\\Illuminate\\Support\\ClassLoader', 'load'));
  29. }
  30. }
  31. public static function addDirectories($directories)
  32. {
  33. static::$directories = array_merge(static::$directories, (array) $directories);
  34. static::$directories = array_unique(static::$directories);
  35. }
  36. public static function removeDirectories($directories = null)
  37. {
  38. if (is_null($directories)) {
  39. static::$directories = array();
  40. } else {
  41. $directories = (array) $directories;
  42. static::$directories = array_filter(static::$directories, function ($directory) use($directories) {
  43. return !in_array($directory, $directories);
  44. });
  45. }
  46. }
  47. public static function getDirectories()
  48. {
  49. return static::$directories;
  50. }
  51. }
  52. namespace Illuminate\Container;
  53. use Closure;
  54. use ArrayAccess;
  55. use ReflectionClass;
  56. use ReflectionParameter;
  57. class BindingResolutionException extends \Exception
  58. {
  59. }
  60. class Container implements ArrayAccess
  61. {
  62. protected $resolved = array();
  63. protected $bindings = array();
  64. protected $instances = array();
  65. protected $aliases = array();
  66. protected $reboundCallbacks = array();
  67. protected $resolvingCallbacks = array();
  68. protected $globalResolvingCallbacks = array();
  69. protected function resolvable($abstract)
  70. {
  71. return $this->bound($abstract) || $this->isAlias($abstract);
  72. }
  73. public function bound($abstract)
  74. {
  75. return isset($this[$abstract]) || isset($this->instances[$abstract]);
  76. }
  77. public function isAlias($name)
  78. {
  79. return isset($this->aliases[$name]);
  80. }
  81. public function bind($abstract, $concrete = null, $shared = false)
  82. {
  83. if (is_array($abstract)) {
  84. list($abstract, $alias) = $this->extractAlias($abstract);
  85. $this->alias($abstract, $alias);
  86. }
  87. $this->dropStaleInstances($abstract);
  88. if (is_null($concrete)) {
  89. $concrete = $abstract;
  90. }
  91. if (!$concrete instanceof Closure) {
  92. $concrete = $this->getClosure($abstract, $concrete);
  93. }
  94. $bound = $this->bound($abstract);
  95. $this->bindings[$abstract] = compact('concrete', 'shared');
  96. if ($bound) {
  97. $this->rebound($abstract);
  98. }
  99. }
  100. protected function getClosure($abstract, $concrete)
  101. {
  102. return function ($c, $parameters = array()) use($abstract, $concrete) {
  103. $method = $abstract == $concrete ? 'build' : 'make';
  104. return $c->{$method}($concrete, $parameters);
  105. };
  106. }
  107. public function bindIf($abstract, $concrete = null, $shared = false)
  108. {
  109. if (!$this->bound($abstract)) {
  110. $this->bind($abstract, $concrete, $shared);
  111. }
  112. }
  113. public function singleton($abstract, $concrete = null)
  114. {
  115. return $this->bind($abstract, $concrete, true);
  116. }
  117. public function share(Closure $closure)
  118. {
  119. return function ($container) use($closure) {
  120. static $object;
  121. if (is_null($object)) {
  122. $object = $closure($container);
  123. }
  124. return $object;
  125. };
  126. }
  127. public function bindShared($abstract, Closure $closure)
  128. {
  129. return $this->bind($abstract, $this->share($closure), true);
  130. }
  131. public function extend($abstract, Closure $closure)
  132. {
  133. if (!isset($this->bindings[$abstract])) {
  134. throw new \InvalidArgumentException("Type {$abstract} is not bound.");
  135. }
  136. if (isset($this->instances[$abstract])) {
  137. $this->instances[$abstract] = $closure($this->instances[$abstract], $this);
  138. $this->rebound($abstract);
  139. } else {
  140. $extender = $this->getExtender($abstract, $closure);
  141. $this->bind($abstract, $extender, $this->isShared($abstract));
  142. }
  143. }
  144. protected function getExtender($abstract, Closure $closure)
  145. {
  146. $resolver = $this->bindings[$abstract]['concrete'];
  147. return function ($container) use($resolver, $closure) {
  148. return $closure($resolver($container), $container);
  149. };
  150. }
  151. public function instance($abstract, $instance)
  152. {
  153. if (is_array($abstract)) {
  154. list($abstract, $alias) = $this->extractAlias($abstract);
  155. $this->alias($abstract, $alias);
  156. }
  157. unset($this->aliases[$abstract]);
  158. $bound = $this->bound($abstract);
  159. $this->instances[$abstract] = $instance;
  160. if ($bound) {
  161. $this->rebound($abstract);
  162. }
  163. }
  164. public function alias($abstract, $alias)
  165. {
  166. $this->aliases[$alias] = $abstract;
  167. }
  168. protected function extractAlias(array $definition)
  169. {
  170. return array(key($definition), current($definition));
  171. }
  172. public function rebinding($abstract, Closure $callback)
  173. {
  174. $this->reboundCallbacks[$abstract][] = $callback;
  175. if ($this->bound($abstract)) {
  176. return $this->make($abstract);
  177. }
  178. }
  179. public function refresh($abstract, $target, $method)
  180. {
  181. return $this->rebinding($abstract, function ($app, $instance) use($target, $method) {
  182. $target->{$method}($instance);
  183. });
  184. }
  185. protected function rebound($abstract)
  186. {
  187. $instance = $this->make($abstract);
  188. foreach ($this->getReboundCallbacks($abstract) as $callback) {
  189. call_user_func($callback, $this, $instance);
  190. }
  191. }
  192. protected function getReboundCallbacks($abstract)
  193. {
  194. if (isset($this->reboundCallbacks[$abstract])) {
  195. return $this->reboundCallbacks[$abstract];
  196. } else {
  197. return array();
  198. }
  199. }
  200. public function make($abstract, $parameters = array())
  201. {
  202. $abstract = $this->getAlias($abstract);
  203. $this->resolved[$abstract] = true;
  204. if (isset($this->instances[$abstract])) {
  205. return $this->instances[$abstract];
  206. }
  207. $concrete = $this->getConcrete($abstract);
  208. if ($this->isBuildable($concrete, $abstract)) {
  209. $object = $this->build($concrete, $parameters);
  210. } else {
  211. $object = $this->make($concrete, $parameters);
  212. }
  213. if ($this->isShared($abstract)) {
  214. $this->instances[$abstract] = $object;
  215. }
  216. $this->fireResolvingCallbacks($abstract, $object);
  217. return $object;
  218. }
  219. protected function getConcrete($abstract)
  220. {
  221. if (!isset($this->bindings[$abstract])) {
  222. if ($this->missingLeadingSlash($abstract) && isset($this->bindings['\\' . $abstract])) {
  223. $abstract = '\\' . $abstract;
  224. }
  225. return $abstract;
  226. } else {
  227. return $this->bindings[$abstract]['concrete'];
  228. }
  229. }
  230. protected function missingLeadingSlash($abstract)
  231. {
  232. return is_string($abstract) && strpos($abstract, '\\') !== 0;
  233. }
  234. public function build($concrete, $parameters = array())
  235. {
  236. if ($concrete instanceof Closure) {
  237. return $concrete($this, $parameters);
  238. }
  239. $reflector = new ReflectionClass($concrete);
  240. if (!$reflector->isInstantiable()) {
  241. $message = "Target [{$concrete}] is not instantiable.";
  242. throw new BindingResolutionException($message);
  243. }
  244. $constructor = $reflector->getConstructor();
  245. if (is_null($constructor)) {
  246. return new $concrete();
  247. }
  248. $dependencies = $constructor->getParameters();
  249. $parameters = $this->keyParametersByArgument($dependencies, $parameters);
  250. $instances = $this->getDependencies($dependencies, $parameters);
  251. return $reflector->newInstanceArgs($instances);
  252. }
  253. protected function getDependencies($parameters, array $primitives = array())
  254. {
  255. $dependencies = array();
  256. foreach ($parameters as $parameter) {
  257. $dependency = $parameter->getClass();
  258. if (array_key_exists($parameter->name, $primitives)) {
  259. $dependencies[] = $primitives[$parameter->name];
  260. } elseif (is_null($dependency)) {
  261. $dependencies[] = $this->resolveNonClass($parameter);
  262. } else {
  263. $dependencies[] = $this->resolveClass($parameter);
  264. }
  265. }
  266. return (array) $dependencies;
  267. }
  268. protected function resolveNonClass(ReflectionParameter $parameter)
  269. {
  270. if ($parameter->isDefaultValueAvailable()) {
  271. return $parameter->getDefaultValue();
  272. } else {
  273. $message = "Unresolvable dependency resolving [{$parameter}].";
  274. throw new BindingResolutionException($message);
  275. }
  276. }
  277. protected function resolveClass(ReflectionParameter $parameter)
  278. {
  279. try {
  280. return $this->make($parameter->getClass()->name);
  281. } catch (BindingResolutionException $e) {
  282. if ($parameter->isOptional()) {
  283. return $parameter->getDefaultValue();
  284. } else {
  285. throw $e;
  286. }
  287. }
  288. }
  289. protected function keyParametersByArgument(array $dependencies, array $parameters)
  290. {
  291. foreach ($parameters as $key => $value) {
  292. if (is_numeric($key)) {
  293. unset($parameters[$key]);
  294. $parameters[$dependencies[$key]->name] = $value;
  295. }
  296. }
  297. return $parameters;
  298. }
  299. public function resolving($abstract, Closure $callback)
  300. {
  301. $this->resolvingCallbacks[$abstract][] = $callback;
  302. }
  303. public function resolvingAny(Closure $callback)
  304. {
  305. $this->globalResolvingCallbacks[] = $callback;
  306. }
  307. protected function fireResolvingCallbacks($abstract, $object)
  308. {
  309. if (isset($this->resolvingCallbacks[$abstract])) {
  310. $this->fireCallbackArray($object, $this->resolvingCallbacks[$abstract]);
  311. }
  312. $this->fireCallbackArray($object, $this->globalResolvingCallbacks);
  313. }
  314. protected function fireCallbackArray($object, array $callbacks)
  315. {
  316. foreach ($callbacks as $callback) {
  317. call_user_func($callback, $object, $this);
  318. }
  319. }
  320. public function isShared($abstract)
  321. {
  322. if (isset($this->bindings[$abstract]['shared'])) {
  323. $shared = $this->bindings[$abstract]['shared'];
  324. } else {
  325. $shared = false;
  326. }
  327. return isset($this->instances[$abstract]) || $shared === true;
  328. }
  329. protected function isBuildable($concrete, $abstract)
  330. {
  331. return $concrete === $abstract || $concrete instanceof Closure;
  332. }
  333. protected function getAlias($abstract)
  334. {
  335. return isset($this->aliases[$abstract]) ? $this->aliases[$abstract] : $abstract;
  336. }
  337. public function getBindings()
  338. {
  339. return $this->bindings;
  340. }
  341. protected function dropStaleInstances($abstract)
  342. {
  343. unset($this->instances[$abstract]);
  344. unset($this->aliases[$abstract]);
  345. }
  346. public function forgetInstance($abstract)
  347. {
  348. unset($this->instances[$abstract]);
  349. }
  350. public function forgetInstances()
  351. {
  352. $this->instances = array();
  353. }
  354. public function offsetExists($key)
  355. {
  356. return isset($this->bindings[$key]);
  357. }
  358. public function offsetGet($key)
  359. {
  360. return $this->make($key);
  361. }
  362. public function offsetSet($key, $value)
  363. {
  364. if (!$value instanceof Closure) {
  365. $value = function () use($value) {
  366. return $value;
  367. };
  368. }
  369. $this->bind($key, $value);
  370. }
  371. public function offsetUnset($key)
  372. {
  373. unset($this->bindings[$key]);
  374. unset($this->instances[$key]);
  375. }
  376. }
  377. namespace Symfony\Component\HttpKernel;
  378. use Symfony\Component\HttpFoundation\Request;
  379. use Symfony\Component\HttpFoundation\Response;
  380. interface HttpKernelInterface
  381. {
  382. const MASTER_REQUEST = 1;
  383. const SUB_REQUEST = 2;
  384. public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true);
  385. }
  386. namespace Symfony\Component\HttpKernel;
  387. use Symfony\Component\HttpFoundation\Request;
  388. use Symfony\Component\HttpFoundation\Response;
  389. interface TerminableInterface
  390. {
  391. public function terminate(Request $request, Response $response);
  392. }
  393. namespace Illuminate\Support\Contracts;
  394. interface ResponsePreparerInterface
  395. {
  396. public function prepareResponse($value);
  397. public function readyForResponses();
  398. }
  399. namespace Illuminate\Foundation;
  400. use Closure;
  401. use Illuminate\Http\Request;
  402. use Illuminate\Http\Response;
  403. use Illuminate\Config\FileLoader;
  404. use Illuminate\Container\Container;
  405. use Illuminate\Filesystem\Filesystem;
  406. use Illuminate\Support\Facades\Facade;
  407. use Illuminate\Events\EventServiceProvider;
  408. use Illuminate\Routing\RoutingServiceProvider;
  409. use Illuminate\Exception\ExceptionServiceProvider;
  410. use Illuminate\Config\FileEnvironmentVariablesLoader;
  411. use Symfony\Component\HttpKernel\HttpKernelInterface;
  412. use Symfony\Component\HttpKernel\TerminableInterface;
  413. use Symfony\Component\HttpKernel\Exception\HttpException;
  414. use Symfony\Component\Debug\Exception\FatalErrorException;
  415. use Illuminate\Support\Contracts\ResponsePreparerInterface;
  416. use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
  417. use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
  418. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  419. class Application extends Container implements HttpKernelInterface, TerminableInterface, ResponsePreparerInterface
  420. {
  421. const VERSION = '4.2.4';
  422. protected $booted = false;
  423. protected $bootingCallbacks = array();
  424. protected $bootedCallbacks = array();
  425. protected $finishCallbacks = array();
  426. protected $shutdownCallbacks = array();
  427. protected $middlewares = array();
  428. protected $serviceProviders = array();
  429. protected $loadedProviders = array();
  430. protected $deferredServices = array();
  431. protected static $requestClass = 'Illuminate\\Http\\Request';
  432. public function __construct(Request $request = null)
  433. {
  434. $this->registerBaseBindings($request ?: $this->createNewRequest());
  435. $this->registerBaseServiceProviders();
  436. $this->registerBaseMiddlewares();
  437. }
  438. protected function createNewRequest()
  439. {
  440. return forward_static_call(array(static::$requestClass, 'createFromGlobals'));
  441. }
  442. protected function registerBaseBindings($request)
  443. {
  444. $this->instance('request', $request);
  445. $this->instance('Illuminate\\Container\\Container', $this);
  446. }
  447. protected function registerBaseServiceProviders()
  448. {
  449. foreach (array('Event', 'Exception', 'Routing') as $name) {
  450. $this->{"register{$name}Provider"}();
  451. }
  452. }
  453. protected function registerExceptionProvider()
  454. {
  455. $this->register(new ExceptionServiceProvider($this));
  456. }
  457. protected function registerRoutingProvider()
  458. {
  459. $this->register(new RoutingServiceProvider($this));
  460. }
  461. protected function registerEventProvider()
  462. {
  463. $this->register(new EventServiceProvider($this));
  464. }
  465. public function bindInstallPaths(array $paths)
  466. {
  467. $this->instance('path', realpath($paths['app']));
  468. foreach (array_except($paths, array('app')) as $key => $value) {
  469. $this->instance("path.{$key}", realpath($value));
  470. }
  471. }
  472. public static function getBootstrapFile()
  473. {
  474. return 'C:\\xampp\\htdocs\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation' . '/start.php';
  475. }
  476. public function startExceptionHandling()
  477. {
  478. $this['exception']->register($this->environment());
  479. $this['exception']->setDebug($this['config']['app.debug']);
  480. }
  481. public function environment()
  482. {
  483. if (count(func_get_args()) > 0) {
  484. return in_array($this['env'], func_get_args());
  485. } else {
  486. return $this['env'];
  487. }
  488. }
  489. public function isLocal()
  490. {
  491. return $this['env'] == 'local';
  492. }
  493. public function detectEnvironment($envs)
  494. {
  495. $args = isset($_SERVER['argv']) ? $_SERVER['argv'] : null;
  496. return $this['env'] = with(new EnvironmentDetector())->detect($envs, $args);
  497. }
  498. public function runningInConsole()
  499. {
  500. return php_sapi_name() == 'cli';
  501. }
  502. public function runningUnitTests()
  503. {
  504. return $this['env'] == 'testing';
  505. }
  506. public function forceRegister($provider, $options = array())
  507. {
  508. return $this->register($provider, $options, true);
  509. }
  510. public function register($provider, $options = array(), $force = false)
  511. {
  512. if ($registered = $this->getRegistered($provider) && !$force) {
  513. return $registered;
  514. }
  515. if (is_string($provider)) {
  516. $provider = $this->resolveProviderClass($provider);
  517. }
  518. $provider->register();
  519. foreach ($options as $key => $value) {
  520. $this[$key] = $value;
  521. }
  522. $this->markAsRegistered($provider);
  523. if ($this->booted) {
  524. $provider->boot();
  525. }
  526. return $provider;
  527. }
  528. public function getRegistered($provider)
  529. {
  530. $name = is_string($provider) ? $provider : get_class($provider);
  531. if (array_key_exists($name, $this->loadedProviders)) {
  532. return array_first($this->serviceProviders, function ($key, $value) use($name) {
  533. return get_class($value) == $name;
  534. });
  535. }
  536. }
  537. public function resolveProviderClass($provider)
  538. {
  539. return new $provider($this);
  540. }
  541. protected function markAsRegistered($provider)
  542. {
  543. $this['events']->fire($class = get_class($provider), array($provider));
  544. $this->serviceProviders[] = $provider;
  545. $this->loadedProviders[$class] = true;
  546. }
  547. public function loadDeferredProviders()
  548. {
  549. foreach ($this->deferredServices as $service => $provider) {
  550. $this->loadDeferredProvider($service);
  551. }
  552. $this->deferredServices = array();
  553. }
  554. protected function loadDeferredProvider($service)
  555. {
  556. $provider = $this->deferredServices[$service];
  557. if (!isset($this->loadedProviders[$provider])) {
  558. $this->registerDeferredProvider($provider, $service);
  559. }
  560. }
  561. public function registerDeferredProvider($provider, $service = null)
  562. {
  563. if ($service) {
  564. unset($this->deferredServices[$service]);
  565. }
  566. $this->register($instance = new $provider($this));
  567. if (!$this->booted) {
  568. $this->booting(function () use($instance) {
  569. $instance->boot();
  570. });
  571. }
  572. }
  573. public function make($abstract, $parameters = array())
  574. {
  575. $abstract = $this->getAlias($abstract);
  576. if (isset($this->deferredServices[$abstract])) {
  577. $this->loadDeferredProvider($abstract);
  578. }
  579. return parent::make($abstract, $parameters);
  580. }
  581. public function before($callback)
  582. {
  583. return $this['router']->before($callback);
  584. }
  585. public function after($callback)
  586. {
  587. return $this['router']->after($callback);
  588. }
  589. public function finish($callback)
  590. {
  591. $this->finishCallbacks[] = $callback;
  592. }
  593. public function shutdown($callback = null)
  594. {
  595. if (is_null($callback)) {
  596. $this->fireAppCallbacks($this->shutdownCallbacks);
  597. } else {
  598. $this->shutdownCallbacks[] = $callback;
  599. }
  600. }
  601. public function useArraySessions(Closure $callback)
  602. {
  603. $this->bind('session.reject', function () use($callback) {
  604. return $callback;
  605. });
  606. }
  607. public function isBooted()
  608. {
  609. return $this->booted;
  610. }
  611. public function boot()
  612. {
  613. if ($this->booted) {
  614. return;
  615. }
  616. array_walk($this->serviceProviders, function ($p) {
  617. $p->boot();
  618. });
  619. $this->bootApplication();
  620. }
  621. protected function bootApplication()
  622. {
  623. $this->fireAppCallbacks($this->bootingCallbacks);
  624. $this->booted = true;
  625. $this->fireAppCallbacks($this->bootedCallbacks);
  626. }
  627. public function booting($callback)
  628. {
  629. $this->bootingCallbacks[] = $callback;
  630. }
  631. public function booted($callback)
  632. {
  633. $this->bootedCallbacks[] = $callback;
  634. if ($this->isBooted()) {
  635. $this->fireAppCallbacks(array($callback));
  636. }
  637. }
  638. public function run(SymfonyRequest $request = null)
  639. {
  640. $request = $request ?: $this['request'];
  641. $response = with($stack = $this->getStackedClient())->handle($request);
  642. $response->send();
  643. $stack->terminate($request, $response);
  644. }
  645. protected function getStackedClient()
  646. {
  647. $sessionReject = $this->bound('session.reject') ? $this['session.reject'] : null;
  648. $client = with(new \Stack\Builder())->push('Illuminate\\Cookie\\Guard', $this['encrypter'])->push('Illuminate\\Cookie\\Queue', $this['cookie'])->push('Illuminate\\Session\\Middleware', $this['session'], $sessionReject);
  649. $this->mergeCustomMiddlewares($client);
  650. return $client->resolve($this);
  651. }
  652. protected function mergeCustomMiddlewares(\Stack\Builder $stack)
  653. {
  654. foreach ($this->middlewares as $middleware) {
  655. list($class, $parameters) = array_values($middleware);
  656. array_unshift($parameters, $class);
  657. call_user_func_array(array($stack, 'push'), $parameters);
  658. }
  659. }
  660. protected function registerBaseMiddlewares()
  661. {
  662. }
  663. public function middleware($class, array $parameters = array())
  664. {
  665. $this->middlewares[] = compact('class', 'parameters');
  666. return $this;
  667. }
  668. public function forgetMiddleware($class)
  669. {
  670. $this->middlewares = array_filter($this->middlewares, function ($m) use($class) {
  671. return $m['class'] != $class;
  672. });
  673. }
  674. public function handle(SymfonyRequest $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
  675. {
  676. try {
  677. $this->refreshRequest($request = Request::createFromBase($request));
  678. $this->boot();
  679. return $this->dispatch($request);
  680. } catch (\Exception $e) {
  681. if ($this->runningUnitTests()) {
  682. throw $e;
  683. }
  684. return $this['exception']->handleException($e);
  685. }
  686. }
  687. public function dispatch(Request $request)
  688. {
  689. if ($this->isDownForMaintenance()) {
  690. $response = $this['events']->until('illuminate.app.down');
  691. if (!is_null($response)) {
  692. return $this->prepareResponse($response, $request);
  693. }
  694. }
  695. if ($this->runningUnitTests() && !$this['session']->isStarted()) {
  696. $this['session']->start();
  697. }
  698. return $this['router']->dispatch($this->prepareRequest($request));
  699. }
  700. public function terminate(SymfonyRequest $request, SymfonyResponse $response)
  701. {
  702. $this->callFinishCallbacks($request, $response);
  703. $this->shutdown();
  704. }
  705. protected function refreshRequest(Request $request)
  706. {
  707. $this->instance('request', $request);
  708. Facade::clearResolvedInstance('request');
  709. }
  710. public function callFinishCallbacks(SymfonyRequest $request, SymfonyResponse $response)
  711. {
  712. foreach ($this->finishCallbacks as $callback) {
  713. call_user_func($callback, $request, $response);
  714. }
  715. }
  716. protected function fireAppCallbacks(array $callbacks)
  717. {
  718. foreach ($callbacks as $callback) {
  719. call_user_func($callback, $this);
  720. }
  721. }
  722. public function prepareRequest(Request $request)
  723. {
  724. if (!is_null($this['config']['session.driver']) && !$request->hasSession()) {
  725. $request->setSession($this['session']->driver());
  726. }
  727. return $request;
  728. }
  729. public function prepareResponse($value)
  730. {
  731. if (!$value instanceof SymfonyResponse) {
  732. $value = new Response($value);
  733. }
  734. return $value->prepare($this['request']);
  735. }
  736. public function readyForResponses()
  737. {
  738. return $this->booted;
  739. }
  740. public function isDownForMaintenance()
  741. {
  742. return file_exists($this['config']['app.manifest'] . '/down');
  743. }
  744. public function down(Closure $callback)
  745. {
  746. $this['events']->listen('illuminate.app.down', $callback);
  747. }
  748. public function abort($code, $message = '', array $headers = array())
  749. {
  750. if ($code == 404) {
  751. throw new NotFoundHttpException($message);
  752. } else {
  753. throw new HttpException($code, $message, null, $headers);
  754. }
  755. }
  756. public function missing(Closure $callback)
  757. {
  758. $this->error(function (NotFoundHttpException $e) use($callback) {
  759. return call_user_func($callback, $e);
  760. });
  761. }
  762. public function error(Closure $callback)
  763. {
  764. $this['exception']->error($callback);
  765. }
  766. public function pushError(Closure $callback)
  767. {
  768. $this['exception']->pushError($callback);
  769. }
  770. public function fatal(Closure $callback)
  771. {
  772. $this->error(function (FatalErrorException $e) use($callback) {
  773. return call_user_func($callback, $e);
  774. });
  775. }
  776. public function getConfigLoader()
  777. {
  778. return new FileLoader(new Filesystem(), $this['path'] . '/config');
  779. }
  780. public function getEnvironmentVariablesLoader()
  781. {
  782. return new FileEnvironmentVariablesLoader(new Filesystem(), $this['path.base']);
  783. }
  784. public function getProviderRepository()
  785. {
  786. $manifest = $this['config']['app.manifest'];
  787. return new ProviderRepository(new Filesystem(), $manifest);
  788. }
  789. public function getLoadedProviders()
  790. {
  791. return $this->loadedProviders;
  792. }
  793. public function setDeferredServices(array $services)
  794. {
  795. $this->deferredServices = $services;
  796. }
  797. public function isDeferredService($service)
  798. {
  799. return isset($this->deferredServices[$service]);
  800. }
  801. public static function requestClass($class = null)
  802. {
  803. if (!is_null($class)) {
  804. static::$requestClass = $class;
  805. }
  806. return static::$requestClass;
  807. }
  808. public function setRequestForConsoleEnvironment()
  809. {
  810. $url = $this['config']->get('app.url', 'http://localhost');
  811. $parameters = array($url, 'GET', array(), array(), array(), $_SERVER);
  812. $this->refreshRequest(static::onRequest('create', $parameters));
  813. }
  814. public static function onRequest($method, $parameters = array())
  815. {
  816. return forward_static_call_array(array(static::requestClass(), $method), $parameters);
  817. }
  818. public function getLocale()
  819. {
  820. return $this['config']->get('app.locale');
  821. }
  822. public function setLocale($locale)
  823. {
  824. $this['config']->set('app.locale', $locale);
  825. $this['translator']->setLocale($locale);
  826. $this['events']->fire('locale.changed', array($locale));
  827. }
  828. public function registerCoreContainerAliases()
  829. {
  830. $aliases = array('app' => 'Illuminate\\Foundation\\Application', 'artisan' => 'Illuminate\\Console\\Application', 'auth' => 'Illuminate\\Auth\\AuthManager', 'auth.reminder.repository' => 'Illuminate\\Auth\\Reminders\\ReminderRepositoryInterface', 'blade.compiler' => 'Illuminate\\View\\Compilers\\BladeCompiler', 'cache' => 'Illuminate\\Cache\\CacheManager', 'cache.store' => 'Illuminate\\Cache\\Repository', 'config' => 'Illuminate\\Config\\Repository', 'cookie' => 'Illuminate\\Cookie\\CookieJar', 'encrypter' => 'Illuminate\\Encryption\\Encrypter', 'db' => 'Illuminate\\Database\\DatabaseManager', 'events' => 'Illuminate\\Events\\Dispatcher', 'files' => 'Illuminate\\Filesystem\\Filesystem', 'form' => 'Illuminate\\Html\\FormBuilder', 'hash' => 'Illuminate\\Hashing\\HasherInterface', 'html' => 'Illuminate\\Html\\HtmlBuilder', 'translator' => 'Illuminate\\Translation\\Translator', 'log' => 'Illuminate\\Log\\Writer', 'mailer' => 'Illuminate\\Mail\\Mailer', 'paginator' => 'Illuminate\\Pagination\\Factory', 'auth.reminder' => 'Illuminate\\Auth\\Reminders\\PasswordBroker', 'queue' => 'Illuminate\\Queue\\QueueManager', 'redirect' => 'Illuminate\\Routing\\Redirector', 'redis' => 'Illuminate\\Redis\\Database', 'request' => 'Illuminate\\Http\\Request', 'router' => 'Illuminate\\Routing\\Router', 'session' => 'Illuminate\\Session\\SessionManager', 'session.store' => 'Illuminate\\Session\\Store', 'remote' => 'Illuminate\\Remote\\RemoteManager', 'url' => 'Illuminate\\Routing\\UrlGenerator', 'validator' => 'Illuminate\\Validation\\Factory', 'view' => 'Illuminate\\View\\Factory');
  831. foreach ($aliases as $key => $alias) {
  832. $this->alias($key, $alias);
  833. }
  834. }
  835. public function __get($key)
  836. {
  837. return $this[$key];
  838. }
  839. public function __set($key, $value)
  840. {
  841. $this[$key] = $value;
  842. }
  843. }
  844. namespace Illuminate\Foundation;
  845. use Closure;
  846. class EnvironmentDetector
  847. {
  848. public function detect($environments, $consoleArgs = null)
  849. {
  850. if ($consoleArgs) {
  851. return $this->detectConsoleEnvironment($environments, $consoleArgs);
  852. } else {
  853. return $this->detectWebEnvironment($environments);
  854. }
  855. }
  856. protected function detectWebEnvironment($environments)
  857. {
  858. if ($environments instanceof Closure) {
  859. return call_user_func($environments);
  860. }
  861. foreach ($environments as $environment => $hosts) {
  862. foreach ((array) $hosts as $host) {
  863. if ($this->isMachine($host)) {
  864. return $environment;
  865. }
  866. }
  867. }
  868. return 'production';
  869. }
  870. protected function detectConsoleEnvironment($environments, array $args)
  871. {
  872. if (!is_null($value = $this->getEnvironmentArgument($args))) {
  873. return head(array_slice(explode('=', $value), 1));
  874. } else {
  875. return $this->detectWebEnvironment($environments);
  876. }
  877. }
  878. protected function getEnvironmentArgument(array $args)
  879. {
  880. return array_first($args, function ($k, $v) {
  881. return starts_with($v, '--env');
  882. });
  883. }
  884. public function isMachine($name)
  885. {
  886. return str_is($name, gethostname());
  887. }
  888. }
  889. namespace Illuminate\Http;
  890. use Symfony\Component\HttpFoundation\ParameterBag;
  891. use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
  892. class Request extends SymfonyRequest
  893. {
  894. protected $json;
  895. protected $sessionStore;
  896. public function instance()
  897. {
  898. return $this;
  899. }
  900. public function method()
  901. {
  902. return $this->getMethod();
  903. }
  904. public function root()
  905. {
  906. return rtrim($this->getSchemeAndHttpHost() . $this->getBaseUrl(), '/');
  907. }
  908. public function url()
  909. {
  910. return rtrim(preg_replace('/\\?.*/', '', $this->getUri()), '/');
  911. }
  912. public function fullUrl()
  913. {
  914. $query = $this->getQueryString();
  915. return $query ? $this->url() . '?' . $query : $this->url();
  916. }
  917. public function path()
  918. {
  919. $pattern = trim($this->getPathInfo(), '/');
  920. return $pattern == '' ? '/' : $pattern;
  921. }
  922. public function decodedPath()
  923. {
  924. return rawurldecode($this->path());
  925. }
  926. public function segment($index, $default = null)
  927. {
  928. return array_get($this->segments(), $index - 1, $default);
  929. }
  930. public function segments()
  931. {
  932. $segments = explode('/', $this->path());
  933. return array_values(array_filter($segments, function ($v) {
  934. return $v != '';
  935. }));
  936. }
  937. public function is()
  938. {
  939. foreach (func_get_args() as $pattern) {
  940. if (str_is($pattern, urldecode($this->path()))) {
  941. return true;
  942. }
  943. }
  944. return false;
  945. }
  946. public function ajax()
  947. {
  948. return $this->isXmlHttpRequest();
  949. }
  950. public function secure()
  951. {
  952. return $this->isSecure();
  953. }
  954. public function exists($key)
  955. {
  956. $keys = is_array($key) ? $key : func_get_args();
  957. $input = $this->all();
  958. foreach ($keys as $value) {
  959. if (!array_key_exists($value, $input)) {
  960. return false;
  961. }
  962. }
  963. return true;
  964. }
  965. public function has($key)
  966. {
  967. $keys = is_array($key) ? $key : func_get_args();
  968. foreach ($keys as $value) {
  969. if ($this->isEmptyString($value)) {
  970. return false;
  971. }
  972. }
  973. return true;
  974. }
  975. protected function isEmptyString($key)
  976. {
  977. $boolOrArray = is_bool($this->input($key)) || is_array($this->input($key));
  978. return !$boolOrArray && trim((string) $this->input($key)) === '';
  979. }
  980. public function all()
  981. {
  982. return array_merge_recursive($this->input(), $this->files->all());
  983. }
  984. public function input($key = null, $default = null)
  985. {
  986. $input = $this->getInputSource()->all() + $this->query->all();
  987. return array_get($input, $key, $default);
  988. }
  989. public function only($keys)
  990. {
  991. $keys = is_array($keys) ? $keys : func_get_args();
  992. return array_only($this->input(), $keys) + array_fill_keys($keys, null);
  993. }
  994. public function except($keys)
  995. {
  996. $keys = is_array($keys) ? $keys : func_get_args();
  997. $results = $this->input();
  998. foreach ($keys as $key) {
  999. array_forget($results, $key);
  1000. }
  1001. return $results;
  1002. }
  1003. public function query($key = null, $default = null)
  1004. {
  1005. return $this->retrieveItem('query', $key, $default);
  1006. }
  1007. public function hasCookie($key)
  1008. {
  1009. return !is_null($this->cookie($key));
  1010. }
  1011. public function cookie($key = null, $default = null)
  1012. {
  1013. return $this->retrieveItem('cookies', $key, $default);
  1014. }
  1015. public function file($key = null, $default = null)
  1016. {
  1017. return array_get($this->files->all(), $key, $default);
  1018. }
  1019. public function hasFile($key)
  1020. {
  1021. if (is_array($file = $this->file($key))) {
  1022. $file = head($file);
  1023. }
  1024. return $file instanceof \SplFileInfo && $file->getPath() != '';
  1025. }
  1026. public function header($key = null, $default = null)
  1027. {
  1028. return $this->retrieveItem('headers', $key, $default);
  1029. }
  1030. public function server($key = null, $default = null)
  1031. {
  1032. return $this->retrieveItem('server', $key, $default);
  1033. }
  1034. public function old($key = null, $default = null)
  1035. {
  1036. return $this->session()->getOldInput($key, $default);
  1037. }
  1038. public function flash($filter = null, $keys = array())
  1039. {
  1040. $flash = !is_null($filter) ? $this->{$filter}($keys) : $this->input();
  1041. $this->session()->flashInput($flash);
  1042. }
  1043. public function flashOnly($keys)
  1044. {
  1045. $keys = is_array($keys) ? $keys : func_get_args();
  1046. return $this->flash('only', $keys);
  1047. }
  1048. public function flashExcept($keys)
  1049. {
  1050. $keys = is_array($keys) ? $keys : func_get_args();
  1051. return $this->flash('except', $keys);
  1052. }
  1053. public function flush()
  1054. {
  1055. $this->session()->flashInput(array());
  1056. }
  1057. protected function retrieveItem($source, $key, $default)
  1058. {
  1059. if (is_null($key)) {
  1060. return $this->{$source}->all();
  1061. } else {
  1062. return $this->{$source}->get($key, $default, true);
  1063. }
  1064. }
  1065. public function merge(array $input)
  1066. {
  1067. $this->getInputSource()->add($input);
  1068. }
  1069. public function replace(array $input)
  1070. {
  1071. $this->getInputSource()->replace($input);
  1072. }
  1073. public function json($key = null, $default = null)
  1074. {
  1075. if (!isset($this->json)) {
  1076. $this->json = new ParameterBag((array) json_decode($this->getContent(), true));
  1077. }
  1078. if (is_null($key)) {
  1079. return $this->json;
  1080. }
  1081. return array_get($this->json->all(), $key, $default);
  1082. }
  1083. protected function getInputSource()
  1084. {
  1085. if ($this->isJson()) {
  1086. return $this->json();
  1087. }
  1088. return $this->getMethod() == 'GET' ? $this->query : $this->request;
  1089. }
  1090. public function isJson()
  1091. {
  1092. return str_contains($this->header('CONTENT_TYPE'), '/json');
  1093. }
  1094. public function wantsJson()
  1095. {
  1096. $acceptable = $this->getAcceptableContentTypes();
  1097. return isset($acceptable[0]) && $acceptable[0] == 'application/json';
  1098. }
  1099. public function format($default = 'html')
  1100. {
  1101. foreach ($this->getAcceptableContentTypes() as $type) {
  1102. if ($format = $this->getFormat($type)) {
  1103. return $format;
  1104. }
  1105. }
  1106. return $default;
  1107. }
  1108. public static function createFromBase(SymfonyRequest $request)
  1109. {
  1110. if ($request instanceof static) {
  1111. return $request;
  1112. }
  1113. return with(new static())->duplicate($request->query->all(), $request->request->all(), $request->attributes->all(), $request->cookies->all(), $request->files->all(), $request->server->all());
  1114. }
  1115. public function session()
  1116. {
  1117. if (!$this->hasSession()) {
  1118. throw new \RuntimeException('Session store not set on request.');
  1119. }
  1120. return $this->getSession();
  1121. }
  1122. }
  1123. namespace Illuminate\Http;
  1124. use Symfony\Component\HttpKernel\HttpKernelInterface;
  1125. use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
  1126. class FrameGuard implements HttpKernelInterface
  1127. {
  1128. protected $app;
  1129. public function __construct(HttpKernelInterface $app)
  1130. {
  1131. $this->app = $app;
  1132. }
  1133. public function handle(SymfonyRequest $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
  1134. {
  1135. $response = $this->app->handle($request, $type, $catch);
  1136. $response->headers->set('X-Frame-Options', 'SAMEORIGIN', false);
  1137. return $response;
  1138. }
  1139. }
  1140. namespace Symfony\Component\HttpFoundation;
  1141. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  1142. class Request
  1143. {
  1144. const HEADER_CLIENT_IP = 'client_ip';
  1145. const HEADER_CLIENT_HOST = 'client_host';
  1146. const HEADER_CLIENT_PROTO = 'client_proto';
  1147. const HEADER_CLIENT_PORT = 'client_port';
  1148. protected static $trustedProxies = array();
  1149. protected static $trustedHostPatterns = array();
  1150. protected static $trustedHosts = array();
  1151. protected static $trustedHeaders = array(self::HEADER_CLIENT_IP => 'X_FORWARDED_FOR', self::HEADER_CLIENT_HOST => 'X_FORWARDED_HOST', self::HEADER_CLIENT_PROTO => 'X_FORWARDED_PROTO', self::HEADER_CLIENT_PORT => 'X_FORWARDED_PORT');
  1152. protected static $httpMethodParameterOverride = false;
  1153. public $attributes;
  1154. public $request;
  1155. public $query;
  1156. public $server;
  1157. public $files;
  1158. public $cookies;
  1159. public $headers;
  1160. protected $content;
  1161. protected $languages;
  1162. protected $charsets;
  1163. protected $encodings;
  1164. protected $acceptableContentTypes;
  1165. protected $pathInfo;
  1166. protected $requestUri;
  1167. protected $baseUrl;
  1168. protected $basePath;
  1169. protected $method;
  1170. protected $format;
  1171. protected $session;
  1172. protected $locale;
  1173. protected $defaultLocale = 'en';
  1174. protected static $formats;
  1175. protected static $requestFactory;
  1176. public function __construct(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null)
  1177. {
  1178. $this->initialize($query, $request, $attributes, $cookies, $files, $server, $content);
  1179. }
  1180. public function initialize(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null)
  1181. {
  1182. $this->request = new ParameterBag($request);
  1183. $this->query = new ParameterBag($query);
  1184. $this->attributes = new ParameterBag($attributes);
  1185. $this->cookies = new ParameterBag($cookies);
  1186. $this->files = new FileBag($files);
  1187. $this->server = new ServerBag($server);
  1188. $this->headers = new HeaderBag($this->server->getHeaders());
  1189. $this->content = $content;
  1190. $this->languages = null;
  1191. $this->charsets = null;
  1192. $this->encodings = null;
  1193. $this->acceptableContentTypes = null;
  1194. $this->pathInfo = null;
  1195. $this->requestUri = null;
  1196. $this->baseUrl = null;
  1197. $this->basePath = null;
  1198. $this->method = null;
  1199. $this->format = null;
  1200. }
  1201. public static function createFromGlobals()
  1202. {
  1203. $request = self::createRequestFromFactory($_GET, $_POST, array(), $_COOKIE, $_FILES, $_SERVER);
  1204. 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'))) {
  1205. parse_str($request->getContent(), $data);
  1206. $request->request = new ParameterBag($data);
  1207. }
  1208. return $request;
  1209. }
  1210. public static function create($uri, $method = 'GET', $parameters = array(), $cookies = array(), $files = array(), $server = array(), $content = null)
  1211. {
  1212. $server = array_replace(array('SERVER_NAME' => 'localhost', 'SERVER_PORT' => 80, 'HTTP_HOST' => 'localhost', 'HTTP_USER_AGENT' => 'Symfony/2.X', 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_LANGUAGE' => 'en-us,en;q=0.5', 'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'REMOTE_ADDR' => '127.0.0.1', 'SCRIPT_NAME' => '', 'SCRIPT_FILENAME' => '', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'REQUEST_TIME' => time()), $server);
  1213. $server['PATH_INFO'] = '';
  1214. $server['REQUEST_METHOD'] = strtoupper($method);
  1215. $components = parse_url($uri);
  1216. if (isset($components['host'])) {
  1217. $server['SERVER_NAME'] = $components['host'];
  1218. $server['HTTP_HOST'] = $components['host'];
  1219. }
  1220. if (isset($components['scheme'])) {
  1221. if ('https' === $components['scheme']) {
  1222. $server['HTTPS'] = 'on';
  1223. $server['SERVER_PORT'] = 443;
  1224. } else {
  1225. unset($server['HTTPS']);
  1226. $server['SERVER_PORT'] = 80;
  1227. }
  1228. }
  1229. if (isset($components['port'])) {
  1230. $server['SERVER_PORT'] = $components['port'];
  1231. $server['HTTP_HOST'] = $server['HTTP_HOST'] . ':' . $components['port'];
  1232. }
  1233. if (isset($components['user'])) {
  1234. $server['PHP_AUTH_USER'] = $components['user'];
  1235. }
  1236. if (isset($components['pass'])) {
  1237. $server['PHP_AUTH_PW'] = $components['pass'];
  1238. }
  1239. if (!isset($components['path'])) {
  1240. $components['path'] = '/';
  1241. }
  1242. switch (strtoupper($method)) {
  1243. case 'POST':
  1244. case 'PUT':
  1245. case 'DELETE':
  1246. if (!isset($server['CONTENT_TYPE'])) {
  1247. $server['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
  1248. }
  1249. case 'PATCH':
  1250. $request = $parameters;
  1251. $query = array();
  1252. break;
  1253. default:
  1254. $request = array();
  1255. $query = $parameters;
  1256. break;
  1257. }
  1258. $queryString = '';
  1259. if (isset($components['query'])) {
  1260. parse_str(html_entity_decode($components['query']), $qs);
  1261. if ($query) {
  1262. $query = array_replace($qs, $query);
  1263. $queryString = http_build_query($query, '', '&');
  1264. } else {
  1265. $query = $qs;
  1266. $queryString = $components['query'];
  1267. }
  1268. } elseif ($query) {
  1269. $queryString = http_build_query($query, '', '&');
  1270. }
  1271. $server['REQUEST_URI'] = $components['path'] . ('' !== $queryString ? '?' . $queryString : '');
  1272. $server['QUERY_STRING'] = $queryString;
  1273. return self::createRequestFromFactory($query, $request, array(), $cookies, $files, $server, $content);
  1274. }
  1275. public static function setFactory($callable)
  1276. {
  1277. self::$requestFactory = $callable;
  1278. }
  1279. public function duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null)
  1280. {
  1281. $dup = clone $this;
  1282. if ($query !== null) {
  1283. $dup->query = new ParameterBag($query);
  1284. }
  1285. if ($request !== null) {
  1286. $dup->request = new ParameterBag($request);
  1287. }
  1288. if ($attributes !== null) {
  1289. $dup->attributes = new ParameterBag($attributes);
  1290. }
  1291. if ($cookies !== null) {
  1292. $dup->cookies = new ParameterBag($cookies);
  1293. }
  1294. if ($files !== null) {
  1295. $dup->files = new FileBag($files);
  1296. }
  1297. if ($server !== null) {
  1298. $dup->server = new ServerBag($server);
  1299. $dup->headers = new HeaderBag($dup->server->getHeaders());
  1300. }
  1301. $dup->languages = null;
  1302. $dup->charsets = null;
  1303. $dup->encodings = null;
  1304. $dup->acceptableContentTypes = null;
  1305. $dup->pathInfo = null;
  1306. $dup->requestUri = null;
  1307. $dup->baseUrl = null;
  1308. $dup->basePath = null;
  1309. $dup->method = null;
  1310. $dup->format = null;
  1311. if (!$dup->get('_format') && $this->get('_format')) {
  1312. $dup->attributes->set('_format', $this->get('_format'));
  1313. }
  1314. if (!$dup->getRequestFormat(null)) {
  1315. $dup->setRequestFormat($format = $this->getRequestFormat(null));
  1316. }
  1317. return $dup;
  1318. }
  1319. public function __clone()
  1320. {
  1321. $this->query = clone $this->query;
  1322. $this->request = clone $this->request;
  1323. $this->attributes = clone $this->attributes;
  1324. $this->cookies = clone $this->cookies;
  1325. $this->files = clone $this->files;
  1326. $this->server = clone $this->server;
  1327. $this->headers = clone $this->headers;
  1328. }
  1329. public function __toString()
  1330. {
  1331. return sprintf('%s %s %s', $this->getMethod(), $this->getRequestUri(), $this->server->get('SERVER_PROTOCOL')) . '
  1332. ' . $this->headers . '
  1333. ' . $this->getContent();
  1334. }
  1335. public function overrideGlobals()
  1336. {
  1337. $_GET = $this->query->all();
  1338. $_POST = $this->request->all();
  1339. $_SERVER = $this->server->all();
  1340. $_COOKIE = $this->cookies->all();
  1341. foreach ($this->headers->all() as $key => $value) {
  1342. $key = strtoupper(str_replace('-', '_', $key));
  1343. if (in_array($key, array('CONTENT_TYPE', 'CONTENT_LENGTH'))) {
  1344. $_SERVER[$key] = implode(', ', $value);
  1345. } else {
  1346. $_SERVER['HTTP_' . $key] = implode(', ', $value);
  1347. }
  1348. }
  1349. $request = array('g' => $_GET, 'p' => $_POST, 'c' => $_COOKIE);
  1350. $requestOrder = ini_get('request_order') ?: ini_get('variables_order');
  1351. $requestOrder = preg_replace('#[^cgp]#', '', strtolower($requestOrder)) ?: 'gp';
  1352. $_REQUEST = array();
  1353. foreach (str_split($requestOrder) as $order) {
  1354. $_REQUEST = array_merge($_REQUEST, $request[$order]);
  1355. }
  1356. }
  1357. public static function setTrustedProxies(array $proxies)
  1358. {
  1359. self::$trustedProxies = $proxies;
  1360. }
  1361. public static function getTrustedProxies()
  1362. {
  1363. return self::$trustedProxies;
  1364. }
  1365. public static function setTrustedHosts(array $hostPatterns)
  1366. {
  1367. self::$trustedHostPatterns = array_map(function ($hostPattern) {
  1368. return sprintf('{%s}i', str_replace('}', '\\}', $hostPattern));
  1369. }, $hostPatterns);
  1370. self::$trustedHosts = array();
  1371. }
  1372. public static function getTrustedHosts()
  1373. {
  1374. return self::$trustedHostPatterns;
  1375. }
  1376. public static function setTrustedHeaderName($key, $value)
  1377. {
  1378. if (!array_key_exists($key, self::$trustedHeaders)) {
  1379. throw new \InvalidArgumentException(sprintf('Unable to set the trusted header name for key "%s".', $key));
  1380. }
  1381. self::$trustedHeaders[$key] = $value;
  1382. }
  1383. public static function getTrustedHeaderName($key)
  1384. {
  1385. if (!array_key_exists($key, self::$trustedHeaders)) {
  1386. throw new \InvalidArgumentException(sprintf('Unable to get the trusted header name for key "%s".', $key));
  1387. }
  1388. return self::$trustedHeaders[$key];
  1389. }
  1390. public static function normalizeQueryString($qs)
  1391. {
  1392. if ('' == $qs) {
  1393. return '';
  1394. }
  1395. $parts = array();
  1396. $order = array();
  1397. foreach (explode('&', $qs) as $param) {
  1398. if ('' === $param || '=' === $param[0]) {
  1399. continue;
  1400. }
  1401. $keyValuePair = explode('=', $param, 2);
  1402. $parts[] = isset($keyValuePair[1]) ? rawurlencode(urldecode($keyValuePair[0])) . '=' . rawurlencode(urldecode($keyValuePair[1])) : rawurlencode(urldecode($keyValuePair[0]));
  1403. $order[] = urldecode($keyValuePair[0]);
  1404. }
  1405. array_multisort($order, SORT_ASC, $p

Large files files are truncated, but you can click here to view the full file