mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-30 05:58:46 +02:00
migration symfony 5 4 (#300)
* symfony 5.4 (diff dev) * symfony 5.4 (working) * symfony 5.4 (update autoload) * symfony 5.4 (remove swiftmailer mailer implementation) * symfony 5.4 (php doc and split Global accessor class) ### Impacted packages: composer require php:">=7.2.5 <8.0.0" symfony/console:5.4.* symfony/dotenv:5.4.* symfony/framework-bundle:5.4.* symfony/twig-bundle:5.4.* symfony/yaml:5.4.* --update-with-dependencies composer require symfony/stopwatch:5.4.* symfony/web-profiler-bundle:5.4.* --dev --update-with-dependencies
This commit is contained in:
@@ -17,6 +17,7 @@ use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Exception\BadMethodCallException;
|
||||
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\DependencyInjection\Exception\LogicException;
|
||||
|
||||
/**
|
||||
* Provides useful features shared by many extensions.
|
||||
@@ -59,14 +60,14 @@ abstract class Extension implements ExtensionInterface, ConfigurationExtensionIn
|
||||
*
|
||||
* This can be overridden in a sub-class to specify the alias manually.
|
||||
*
|
||||
* @return string The alias
|
||||
* @return string
|
||||
*
|
||||
* @throws BadMethodCallException When the extension name does not follow conventions
|
||||
*/
|
||||
public function getAlias()
|
||||
{
|
||||
$className = static::class;
|
||||
if ('Extension' != substr($className, -9)) {
|
||||
if (!str_ends_with($className, 'Extension')) {
|
||||
throw new BadMethodCallException('This extension does not follow the naming convention; you must overwrite the getAlias() method.');
|
||||
}
|
||||
$classBaseName = substr(strrchr($className, '\\'), 1, -9);
|
||||
@@ -81,21 +82,29 @@ abstract class Extension implements ExtensionInterface, ConfigurationExtensionIn
|
||||
{
|
||||
$class = static::class;
|
||||
|
||||
if (false !== strpos($class, "\0")) {
|
||||
if (str_contains($class, "\0")) {
|
||||
return null; // ignore anonymous classes
|
||||
}
|
||||
|
||||
$class = substr_replace($class, '\Configuration', strrpos($class, '\\'));
|
||||
$class = $container->getReflectionClass($class);
|
||||
$constructor = $class ? $class->getConstructor() : null;
|
||||
|
||||
return $class && (!$constructor || !$constructor->getNumberOfRequiredParameters()) ? $class->newInstance() : null;
|
||||
if (!$class) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!$class->implementsInterface(ConfigurationInterface::class)) {
|
||||
throw new LogicException(sprintf('The extension configuration class "%s" must implement "%s".', $class->getName(), ConfigurationInterface::class));
|
||||
}
|
||||
|
||||
if (!($constructor = $class->getConstructor()) || !$constructor->getNumberOfRequiredParameters()) {
|
||||
return $class->newInstance();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
final protected function processConfiguration(ConfigurationInterface $configuration, array $configs)
|
||||
final protected function processConfiguration(ConfigurationInterface $configuration, array $configs): array
|
||||
{
|
||||
$processor = new Processor();
|
||||
|
||||
@@ -105,7 +114,7 @@ abstract class Extension implements ExtensionInterface, ConfigurationExtensionIn
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final public function getProcessedConfigs()
|
||||
final public function getProcessedConfigs(): array
|
||||
{
|
||||
try {
|
||||
return $this->processedConfigs;
|
||||
@@ -115,7 +124,7 @@ abstract class Extension implements ExtensionInterface, ConfigurationExtensionIn
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool Whether the configuration is enabled
|
||||
* @return bool
|
||||
*
|
||||
* @throws InvalidArgumentException When the config is not enableable
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user