apply more cs rules for php-cs

This commit is contained in:
2023-10-17 13:27:03 +02:00
parent 0b0cbed9db
commit bc2041cbdd
1485 changed files with 8169 additions and 9620 deletions

View File

@@ -16,10 +16,6 @@ use Generator;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use function array_key_exists;
use function count;
use function implode;
use function in_array;
/**
* This trait allow to add automatic configuration for widget inside your config.
@@ -141,10 +137,10 @@ trait AddWidgetConfigurationTrait
$treeBuilder = new TreeBuilder($place);
$root = $treeBuilder->getRootNode()
->canBeUnset()
->info('register widgets on place "' . $place . '"');
->info('register widgets on place "'.$place.'"');
// if no childen, return the root
if (count(iterator_to_array($this->filterWidgetByPlace($place))) === 0) {
if (0 === \count(iterator_to_array($this->filterWidgetByPlace($place)))) {
return $root;
}
@@ -162,8 +158,8 @@ trait AddWidgetConfigurationTrait
// is build, the services are avaialble => we add the possible aliases
// in the info.
->info('the widget alias (see your installed bundles config). '
. 'Possible values are (maybe incomplete) : ' .
implode(', ', $this->getWidgetAliasesbyPlace($place, $containerBuilder)))
.'Possible values are (maybe incomplete) : '.
\implode(', ', $this->getWidgetAliasesbyPlace($place, $containerBuilder)))
->isRequired()
->end();
@@ -188,12 +184,12 @@ trait AddWidgetConfigurationTrait
*
* @param string $place
*
* @return Generator a generator containing a widget factory
* @return \Generator a generator containing a widget factory
*/
protected function filterWidgetByPlace($place)
{
foreach ($this->widgetFactories as $factory) {
if (in_array($place, $factory->getAllowedPlaces(), true)) {
if (\in_array($place, $factory->getAllowedPlaces(), true)) {
yield $factory;
}
}
@@ -209,9 +205,9 @@ trait AddWidgetConfigurationTrait
*
* @param type $place
*
* @throws InvalidConfigurationException if a service's tag does not have the "alias" key
*
* @return array
*
* @throws InvalidConfigurationException if a service's tag does not have the "alias" key
*/
protected function getWidgetAliasesbyPlace($place, ContainerBuilder $containerBuilder)
{
@@ -223,16 +219,11 @@ trait AddWidgetConfigurationTrait
// append the aliases added without factory
foreach ($containerBuilder
->findTaggedServiceIds(WidgetsCompilerPass::WIDGET_SERVICE_TAG_NAME)
as $serviceId => $tags) {
->findTaggedServiceIds(WidgetsCompilerPass::WIDGET_SERVICE_TAG_NAME) as $serviceId => $tags) {
foreach ($tags as $tag) {
// throw an error if no alias in definition
if (!array_key_exists(WidgetsCompilerPass::WIDGET_SERVICE_TAG_ALIAS, $tag)) {
throw new InvalidConfigurationException(sprintf(
'The service with id %s does not have any %d key',
$serviceId,
WidgetsCompilerPass::WIDGET_SERVICE_TAG_ALIAS
));
if (!\array_key_exists(WidgetsCompilerPass::WIDGET_SERVICE_TAG_ALIAS, $tag)) {
throw new InvalidConfigurationException(sprintf('The service with id %s does not have any %d key', $serviceId, WidgetsCompilerPass::WIDGET_SERVICE_TAG_ALIAS));
}
// add the key to the possible results
$result[] = $tag[WidgetsCompilerPass::WIDGET_SERVICE_TAG_ALIAS];