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

@@ -29,25 +29,17 @@ abstract class Bundle implements BundleInterface
protected $name;
protected $extension;
protected $path;
private $namespace;
private string $namespace;
/**
* {@inheritdoc}
*/
public function boot()
{
}
/**
* {@inheritdoc}
*/
public function shutdown()
{
}
/**
* {@inheritdoc}
*
* This method can be overridden to register compilation passes,
* other extensions, ...
*/
@@ -58,11 +50,9 @@ abstract class Bundle implements BundleInterface
/**
* Returns the bundle's container extension.
*
* @return ExtensionInterface|null
*
* @throws \LogicException
*/
public function getContainerExtension()
public function getContainerExtension(): ?ExtensionInterface
{
if (null === $this->extension) {
$extension = $this->createContainerExtension();
@@ -89,22 +79,16 @@ abstract class Bundle implements BundleInterface
return $this->extension ?: null;
}
/**
* {@inheritdoc}
*/
public function getNamespace()
public function getNamespace(): string
{
if (null === $this->namespace) {
if (!isset($this->namespace)) {
$this->parseClassName();
}
return $this->namespace;
}
/**
* {@inheritdoc}
*/
public function getPath()
public function getPath(): string
{
if (null === $this->path) {
$reflected = new \ReflectionObject($this);
@@ -132,10 +116,8 @@ abstract class Bundle implements BundleInterface
/**
* Returns the bundle's container extension class.
*
* @return string
*/
protected function getContainerExtensionClass()
protected function getContainerExtensionClass(): string
{
$basename = preg_replace('/Bundle$/', '', $this->getName());
@@ -144,10 +126,8 @@ abstract class Bundle implements BundleInterface
/**
* Creates the bundle's container extension.
*
* @return ExtensionInterface|null
*/
protected function createContainerExtension()
protected function createContainerExtension(): ?ExtensionInterface
{
return class_exists($class = $this->getContainerExtensionClass()) ? new $class() : null;
}
@@ -156,8 +136,6 @@ abstract class Bundle implements BundleInterface
{
$pos = strrpos(static::class, '\\');
$this->namespace = false === $pos ? '' : substr(static::class, 0, $pos);
if (null === $this->name) {
$this->name = false === $pos ? static::class : substr(static::class, $pos + 1);
}
$this->name ??= false === $pos ? static::class : substr(static::class, $pos + 1);
}
}