package and depencies

This commit is contained in:
RafficMohammed
2023-01-08 02:57:24 +05:30
parent d5332eb421
commit 1d54b8bc7f
4309 changed files with 193331 additions and 172289 deletions

View File

@@ -11,13 +11,10 @@
namespace Symfony\Component\HttpKernel;
use Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator;
use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper;
use Symfony\Component\Config\Builder\ConfigBuilderGenerator;
use Symfony\Component\Config\ConfigCache;
use Symfony\Component\Config\Loader\DelegatingLoader;
use Symfony\Component\Config\Loader\LoaderResolver;
use Symfony\Component\Debug\DebugClassLoader as LegacyDebugClassLoader;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -68,25 +65,25 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
protected $booted = false;
protected $startTime;
private $projectDir;
private $warmupDir;
private $requestStackSize = 0;
private $resetServices = false;
private string $projectDir;
private ?string $warmupDir = null;
private int $requestStackSize = 0;
private bool $resetServices = false;
/**
* @var array<string, bool>
*/
private static $freshCache = [];
private static array $freshCache = [];
public const VERSION = '5.4.18';
public const VERSION_ID = 50418;
public const MAJOR_VERSION = 5;
public const MINOR_VERSION = 4;
public const RELEASE_VERSION = 18;
public const VERSION = '6.2.4';
public const VERSION_ID = 60204;
public const MAJOR_VERSION = 6;
public const MINOR_VERSION = 2;
public const RELEASE_VERSION = 4;
public const EXTRA_VERSION = '';
public const END_OF_MAINTENANCE = '11/2024';
public const END_OF_LIFE = '11/2025';
public const END_OF_MAINTENANCE = '07/2023';
public const END_OF_LIFE = '07/2023';
public function __construct(string $environment, bool $debug)
{
@@ -105,9 +102,6 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
$this->resetServices = false;
}
/**
* {@inheritdoc}
*/
public function boot()
{
if (true === $this->booted) {
@@ -136,9 +130,6 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
$this->booted = true;
}
/**
* {@inheritdoc}
*/
public function reboot(?string $warmupDir)
{
$this->shutdown();
@@ -146,9 +137,6 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
$this->boot();
}
/**
* {@inheritdoc}
*/
public function terminate(Request $request, Response $response)
{
if (false === $this->booted) {
@@ -160,9 +148,6 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
}
}
/**
* {@inheritdoc}
*/
public function shutdown()
{
if (false === $this->booted) {
@@ -181,10 +166,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
$this->resetServices = false;
}
/**
* {@inheritdoc}
*/
public function handle(Request $request, int $type = HttpKernelInterface::MAIN_REQUEST, bool $catch = true)
public function handle(Request $request, int $type = HttpKernelInterface::MAIN_REQUEST, bool $catch = true): Response
{
if (!$this->booted) {
$container = $this->container ?? $this->preBoot();
@@ -207,26 +189,18 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
/**
* Gets an HTTP kernel from the container.
*
* @return HttpKernelInterface
*/
protected function getHttpKernel()
protected function getHttpKernel(): HttpKernelInterface
{
return $this->container->get('http_kernel');
}
/**
* {@inheritdoc}
*/
public function getBundles()
public function getBundles(): array
{
return $this->bundles;
}
/**
* {@inheritdoc}
*/
public function getBundle(string $name)
public function getBundle(string $name): BundleInterface
{
if (!isset($this->bundles[$name])) {
throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the "registerBundles()" method of your "%s.php" file?', $name, get_debug_type($this)));
@@ -235,10 +209,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
return $this->bundles[$name];
}
/**
* {@inheritdoc}
*/
public function locateResource(string $name)
public function locateResource(string $name): string
{
if ('@' !== $name[0]) {
throw new \InvalidArgumentException(sprintf('A resource name must start with @ ("%s" given).', $name));
@@ -262,30 +233,22 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
throw new \InvalidArgumentException(sprintf('Unable to find file "%s".', $name));
}
/**
* {@inheritdoc}
*/
public function getEnvironment()
public function getEnvironment(): string
{
return $this->environment;
}
/**
* {@inheritdoc}
*/
public function isDebug()
public function isDebug(): bool
{
return $this->debug;
}
/**
* Gets the application root dir (path of the project's composer file).
*
* @return string
*/
public function getProjectDir()
public function getProjectDir(): string
{
if (null === $this->projectDir) {
if (!isset($this->projectDir)) {
$r = new \ReflectionObject($this);
if (!is_file($dir = $r->getFileName())) {
@@ -305,10 +268,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
return $this->projectDir;
}
/**
* {@inheritdoc}
*/
public function getContainer()
public function getContainer(): ContainerInterface
{
if (!$this->container) {
throw new \LogicException('Cannot retrieve the container from a non-booted kernel.');
@@ -325,43 +285,28 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
file_put_contents(($this->warmupDir ?: $this->getBuildDir()).'/annotations.map', sprintf('<?php return %s;', var_export($annotatedClasses, true)));
}
/**
* {@inheritdoc}
*/
public function getStartTime()
public function getStartTime(): float
{
return $this->debug && null !== $this->startTime ? $this->startTime : -\INF;
}
/**
* {@inheritdoc}
*/
public function getCacheDir()
public function getCacheDir(): string
{
return $this->getProjectDir().'/var/cache/'.$this->environment;
}
/**
* {@inheritdoc}
*/
public function getBuildDir(): string
{
// Returns $this->getCacheDir() for backward compatibility
return $this->getCacheDir();
}
/**
* {@inheritdoc}
*/
public function getLogDir()
public function getLogDir(): string
{
return $this->getProjectDir().'/var/log';
}
/**
* {@inheritdoc}
*/
public function getCharset()
public function getCharset(): string
{
return 'UTF-8';
}
@@ -405,10 +350,8 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
* Gets the container class.
*
* @throws \InvalidArgumentException If the generated classname is invalid
*
* @return string
*/
protected function getContainerClass()
protected function getContainerClass(): string
{
$class = static::class;
$class = str_contains($class, "@anonymous\0") ? get_parent_class($class).str_replace('.', '_', ContainerBuilder::hash($class)) : $class;
@@ -425,10 +368,8 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
* Gets the container's base class.
*
* All names except Container must be fully qualified.
*
* @return string
*/
protected function getContainerBaseClass()
protected function getContainerBaseClass(): string
{
return 'Container';
}
@@ -521,7 +462,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
// Remove frames added by DebugClassLoader.
for ($i = \count($backtrace) - 2; 0 < $i; --$i) {
if (\in_array($backtrace[$i]['class'] ?? null, [DebugClassLoader::class, LegacyDebugClassLoader::class], true)) {
if (DebugClassLoader::class === ($backtrace[$i]['class'] ?? null)) {
$backtrace = [$backtrace[$i + 1]];
break;
}
@@ -592,16 +533,14 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
/**
* Returns the kernel parameters.
*
* @return array
*/
protected function getKernelParameters()
protected function getKernelParameters(): array
{
$bundles = [];
$bundlesMetadata = [];
foreach ($this->bundles as $name => $bundle) {
$bundles[$name] = \get_class($bundle);
$bundles[$name] = $bundle::class;
$bundlesMetadata[$name] = [
'path' => $bundle->getPath(),
'namespace' => $bundle->getNamespace(),
@@ -626,11 +565,9 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
/**
* Builds the service container.
*
* @return ContainerBuilder
*
* @throws \RuntimeException
*/
protected function buildContainer()
protected function buildContainer(): ContainerBuilder
{
foreach (['cache' => $this->getCacheDir(), 'build' => $this->warmupDir ?: $this->getBuildDir(), 'logs' => $this->getLogDir()] as $name => $dir) {
if (!is_dir($dir)) {
@@ -645,11 +582,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
$container = $this->getContainerBuilder();
$container->addObjectResource($this);
$this->prepareContainer($container);
if (null !== $cont = $this->registerContainerConfiguration($this->getContainerLoader($container))) {
trigger_deprecation('symfony/http-kernel', '5.3', 'Returning a ContainerBuilder from "%s::registerContainerConfiguration()" is deprecated.', get_debug_type($this));
$container->merge($cont);
}
$this->registerContainerConfiguration($this->getContainerLoader($container));
$container->addCompilerPass(new AddAnnotatedClassesToCachePass($this));
@@ -688,10 +621,8 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
/**
* Gets a new ContainerBuilder instance used to build the service container.
*
* @return ContainerBuilder
*/
protected function getContainerBuilder()
protected function getContainerBuilder(): ContainerBuilder
{
$container = new ContainerBuilder();
$container->getParameterBag()->add($this->getKernelParameters());
@@ -702,9 +633,6 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
if ($this instanceof CompilerPassInterface) {
$container->addCompilerPass($this, PassConfig::TYPE_BEFORE_OPTIMIZATION, -10000);
}
if (class_exists(\ProxyManager\Configuration::class) && class_exists(RuntimeInstantiator::class)) {
$container->setProxyInstantiator(new RuntimeInstantiator());
}
return $container;
}
@@ -720,10 +648,6 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
// cache the container
$dumper = new PhpDumper($container);
if (class_exists(\ProxyManager\Configuration::class) && class_exists(ProxyDumper::class)) {
$dumper->setProxyDumper(new ProxyDumper());
}
$content = $dumper->dump([
'class' => $class,
'base_class' => $baseClass,
@@ -752,10 +676,8 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
/**
* Returns a loader for the container.
*
* @return DelegatingLoader
*/
protected function getContainerLoader(ContainerInterface $container)
protected function getContainerLoader(ContainerInterface $container): DelegatingLoader
{
$env = $this->getEnvironment();
$locator = new FileLocator($this);
@@ -804,10 +726,8 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
*
* We don't use the PHP php_strip_whitespace() function
* as we want the content to be readable and well-formatted.
*
* @return string
*/
public static function stripComments(string $source)
public static function stripComments(string $source): string
{
if (!\function_exists('token_get_all')) {
return $source;
@@ -862,10 +782,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
return $output;
}
/**
* @return array
*/
public function __sleep()
public function __sleep(): array
{
return ['environment', 'debug'];
}