Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions Builder/Admin/BaseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ protected function getRowsFromFieldset(array $rows_or_fields): array
public function getColumnsFor(mixed $input): array
{
if (!is_array($input)) {
$input = array($input);
$input = [$input];
}

$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($input));
Expand Down Expand Up @@ -541,10 +541,10 @@ public function getStylesheets(): array
$parse_stylesheets = function ($params, $stylesheets) {
foreach ($params as $css) {
if (is_string($css)) {
$css = array(
$css = [
'path' => $css,
'media' => 'all',
);
];
}

$stylesheets[] = $css;
Expand All @@ -555,12 +555,12 @@ public function getStylesheets(): array

// From config.yml
$stylesheets = $parse_stylesheets(
$this->getGenerator()->getFromBundleConfig('stylesheets', array()), array()
$this->getGenerator()->getFromBundleConfig('stylesheets', []), []
);

// From generator.yml
return $parse_stylesheets(
$this->getVariable('stylesheets', array()), $stylesheets
$this->getVariable('stylesheets', []), $stylesheets
);
}

Expand All @@ -579,15 +579,15 @@ public function getJavascripts(): array
$parse_javascripts = function ($params, $javascripts) use ($self) {
foreach ($params as $js) {
if (is_string($js)) {
$js = array(
$js = [
'path' => $js,
);
];
} elseif (isset($js['route'])) {
$js = array(
$js = [
'path' => $self->getGenerator()
->getRouter()
->generate($js['route'], $js['routeparams']),
);
];
}

$javascripts[] = $js;
Expand All @@ -598,12 +598,12 @@ public function getJavascripts(): array

// From config.yml
$javascripts = $parse_javascripts(
$this->getGenerator()->getFromBundleConfig('javascripts', array()), array()
$this->getGenerator()->getFromBundleConfig('javascripts', []), []
);

// From generator.yml
return $parse_javascripts(
$this->getVariable('javascripts', array()), $javascripts
$this->getVariable('javascripts', []), $javascripts
);
}

Expand Down
2 changes: 1 addition & 1 deletion Builder/Admin/ExcelBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected function setUserExcelColumnConfiguration(Column $column, array $option
if (!count($optionsFields)) return;

$options = array_key_exists($column->getName(), $optionsFields) ?
$optionsFields[$column->getName()] : array();
$optionsFields[$column->getName()] : [];

foreach ($options as $option => $value) {
$column->setProperty($option, $value);
Expand Down
2 changes: 1 addition & 1 deletion Builder/Admin/ListBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ protected function findBatchActions(): void
public function getExcelActions(): array
{
if (null === $this->excelActions) {
$this->excelActions = array();
$this->excelActions = [];
$this->fillExportActions();
}

Expand Down
4 changes: 2 additions & 2 deletions Builder/BaseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ protected function getTwigEnvironment(): Environment
return $this->environment;
}
$loader = new FilesystemLoader($this->getTemplateDirs());
$twig = new Environment($loader, array(
$twig = new Environment($loader, [
'autoescape' => false,
'strict_variables' => true,
'debug' => true,
'cache' => $this->getGenerator()->getTempDir(),
));
]);

$this->loadTwigExtensions($twig);
$this->loadTwigFilters($twig);
Expand Down
4 changes: 2 additions & 2 deletions ClassLoader/AdmingeneratedClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ protected function generateEmptyController(string $class): void
$generator->addBuilder($builder);
$builder->setOutputName($fileName.'.php');

$builder->setVariables(array(
$builder->setVariables([
'controllerName' => $controllerName,
'namespace' => $namespace,
'require_pk' => 'ListController' != $controllerName // We don't care about ActionsController and filters
));
]);

$generator->writeOnDisk($this->basePath);
}
Expand Down
4 changes: 2 additions & 2 deletions Command/AssetsInstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ protected function configure(): void
$this
->setDescription('Fetch bower declared dependencies and push them into web root directory')
->setHelp('The <info>admin:assets-install</info> command fetch bower dependencies (CSS and JS files) to the web root dir.')
->setDefinition(array(
->setDefinition([
new InputOption('mode', 'm', InputOption::VALUE_OPTIONAL, 'Mode to fetch dependencies', 'install'),
new InputOption('bower-bin', 'b', InputOption::VALUE_REQUIRED, 'Path to the bower binary', 'bower')
))
])
;
}

Expand Down
2 changes: 1 addition & 1 deletion Composer/ScriptHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected static function getPhp($includeArgs = true)

protected static function getPhpArguments()
{
$arguments = array();
$arguments = [];
$phpFinder = new PhpExecutableFinder();
if (method_exists($phpFinder, 'findArguments')) {
$arguments = $phpFinder->findArguments();
Expand Down
2 changes: 1 addition & 1 deletion Generator/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(protected readonly string $name, protected readonly
public function setProperty($option, $value): void
{
$option = InflectorFactory::create()->build()->classify($option);
call_user_func_array(array($this, 'set'.$option), array($value));
call_user_func_array([$this, 'set'.$option], [$value]);
}

public function getName(): string
Expand Down
4 changes: 2 additions & 2 deletions Generator/Action/Object/EditAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public function __construct($name, BaseBuilder $builder)

$this->setRoute($builder->getBaseActionsRoute().'_edit');

$this->setParams(array(
$this->setParams([
'pk' => '{{ '.$builder->getModelClass().'.'.$builder->getModelPrimaryKeyName().' }}',
));
]);
}
}
4 changes: 2 additions & 2 deletions Generator/Action/Object/ShowAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public function __construct($name, BaseBuilder $builder)

$this->setRoute($builder->getBaseActionsRoute().'_show');

$this->setParams(array(
$this->setParams([
'pk' => '{{ '.$builder->getModelClass().'.'.$builder->getModelPrimaryKeyName().' }}',
));
]);
}
}
2 changes: 1 addition & 1 deletion Generator/DoctrineGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function doBuild(): void
);
$generator->setBaseGeneratorName($this->getBaseGeneratorName());

$builders = $generator->getFromYaml('builders', array());
$builders = $generator->getFromYaml('builders', []);

if (array_key_exists('list', $builders)) {
$generator->addBuilder(new ListBuilderAction($this->twig));
Expand Down
2 changes: 1 addition & 1 deletion Generator/DoctrineODMGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected function doBuild(): void
);
$generator->setBaseGeneratorName($this->getBaseGeneratorName());

$builders = $generator->getFromYaml('builders', array());
$builders = $generator->getFromYaml('builders', []);

if (array_key_exists('list', $builders)) {
$generator->addBuilder(new ListBuilderAction($this->twig));
Expand Down
2 changes: 1 addition & 1 deletion Generator/PropelGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected function doBuild(): void
$generator->setColumnClass('Admingenerator\GeneratorBundle\Generator\PropelColumn');
$generator->setBaseGeneratorName($this->getBaseGeneratorName());

$builders = $generator->getFromYaml('builders', array());
$builders = $generator->getFromYaml('builders', []);

if (array_key_exists('list', $builders)) {
$generator->addBuilder(new ListBuilderAction($this->twig));
Expand Down
14 changes: 7 additions & 7 deletions Guesser/DoctrineFieldGuesser.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(
private readonly bool $guessRequired,
private readonly bool $defaultRequired)
{
if (!in_array($objectModel = strtolower($objectModel), array('document', 'entity'))) {
if (!in_array($objectModel = strtolower($objectModel), ['document', 'entity'])) {
throw new \InvalidArgumentException('$objectModel must be Document or Entity');
}

Expand Down Expand Up @@ -214,21 +214,21 @@ protected function getOptions(string $type, string $dbType, string $model, strin
if (preg_match(sprintf('/%sType$/i', ucfirst($this->objectModel)), $type)) {
$mapping = $this->getMetadatas($class)->getAssociationMapping($columnName);

return array(
return [
'multiple' => ($mapping['type'] === ORMClassMetadata::MANY_TO_MANY || $mapping['type'] === ORMClassMetadata::ONE_TO_MANY),
'em' => $this->getObjectManagerName($mapping['target'.ucfirst($this->objectModel)]),
'class' => $mapping['target'.ucfirst($this->objectModel)],
'required' => !$filter && $this->isRequired($class, $columnName),
);
];
}

if (preg_match("/CollectionType$/i", $type)) {
$options = array(
$options = [
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
'entry_type' => $filter ? $this->filterTypes[$this->objectModel] : $this->formTypes[$this->objectModel],
);
];

if ($this->getMetadatas($class)->hasAssociation($columnName)) {
$mapping = $this->getMetadatas($class)->getAssociationMapping($columnName);
Expand All @@ -240,9 +240,9 @@ protected function getOptions(string $type, string $dbType, string $model, strin
return $options;
}

return array(
return [
'required' => !$filter && $this->isRequired($class, $columnName)
);
];
}

protected function isRequired(string $class, string $fieldName): bool
Expand Down
6 changes: 3 additions & 3 deletions Guesser/PropelORMFieldGuesser.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected function getMetadatas(string $class): mixed

public function getAllFields(string $class): array
{
$return = array();
$return = [];

foreach ($this->getMetadatas($class)->getColumns() as $column) {
$return[] = InflectorFactory::create()->build()->tableize($column->getPhpName());
Expand Down Expand Up @@ -137,7 +137,7 @@ public function getSortType(string $dbType): string

public function getFormType(string $dbType, string $class, string $columnName): string
{
$formTypes = array();
$formTypes = [];

foreach ($this->formTypes as $key => $value) {
// if config is all uppercase use it to retrieve \PropelColumnTypes
Expand Down Expand Up @@ -165,7 +165,7 @@ public function getFormType(string $dbType, string $class, string $columnName):

public function getFilterType(string $dbType, string $class, string $columnName): string
{
$filterTypes = array();
$filterTypes = [];

foreach ($this->filterTypes as $key => $value) {
// if config is all uppercase use it to retrieve \PropelColumnTypes
Expand Down
2 changes: 1 addition & 1 deletion Maker/MakeAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
$namespaceParts = explode('\\', $namespace);
$prefix = $input->getArgument('prefix');
$bundledNamespace = count($namespaceParts) > 1;
$bundleName = strtr($namespace, array('\\' => ''));
$bundleName = strtr($namespace, ['\\' => '']);
$parameters = [
'bundle' => $bundleName,
'bundleName' => $bundledNamespace ? end($namespaceParts) : $namespace,
Expand Down
8 changes: 4 additions & 4 deletions Menu/AdmingeneratorMenuBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(
*/
protected function addLinkURI(ItemInterface $menu, string $label, string $uri): ItemInterface
{
$item = $menu->addChild($label, array('uri' => $uri));
$item = $menu->addChild($label, ['uri' => $uri]);
$item->setExtra('translation_domain', $this->translation_domain);

if ($this->isCurrentUri($item->getUri())) {
Expand All @@ -40,7 +40,7 @@ protected function addLinkURI(ItemInterface $menu, string $label, string $uri):
*/
protected function addLinkRoute(ItemInterface $menu, string $label, string $route, array $routeParameters = []): ItemInterface
{
$item = $menu->addChild($label, array('route' => $route, 'routeParameters' => $routeParameters, 'routeAbsolute' => UrlGeneratorInterface::ABSOLUTE_PATH));
$item = $menu->addChild($label, ['route' => $route, 'routeParameters' => $routeParameters, 'routeAbsolute' => UrlGeneratorInterface::ABSOLUTE_PATH]);
$item->setExtra('translation_domain', $this->translation_domain);

if ($this->isCurrentUri($item->getUri())) {
Expand All @@ -67,8 +67,8 @@ protected function setActive(?ItemInterface $item = null): void
protected function addDropdown(ItemInterface $menu, string $label, bool $caret = true): ItemInterface
{
$item = $this->addLinkURI($menu, $label, '#');
$item->setChildrenAttributes(array('class' => 'treeview-menu'));
$item->setAttributes(array('class' => 'treeview'));
$item->setChildrenAttributes(['class' => 'treeview-menu']);
$item->setAttributes(['class' => 'treeview']);
$item->setExtra('caret', $caret);

return $item;
Expand Down
2 changes: 1 addition & 1 deletion Menu/DefaultMenuBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class DefaultMenuBuilder extends AdmingeneratorMenuBuilder
public function sidebarMenu(array $options): mixed
{
$menu = $this->factory->createItem('root');
$menu->setChildrenAttributes(array('class' => 'sidebar-menu'));
$menu->setChildrenAttributes(['class' => 'sidebar-menu']);

if ($dashboardRoute = $this->dashboardRoute) {
$this
Expand Down
2 changes: 1 addition & 1 deletion Pagerfanta/View/AdmingeneratorView.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function __construct(protected readonly TranslatorInterface $translator)
{
}

public function render(PagerfantaInterface $pagerfanta, callable $routeGenerator, array $options = array()): string
public function render(PagerfantaInterface $pagerfanta, callable $routeGenerator, array $options = []): string
{
$options = array_merge([
'proximity' => 2,
Expand Down
2 changes: 1 addition & 1 deletion QueryFilter/DoctrineQueryFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,6 @@ protected function addTablePathToField(string $field): array
$parentTableAlias = $joinAlias;
}

return array($parentTableAlias, $filteredField);
return [$parentTableAlias, $filteredField];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ class ActionsController extends BaseController
public function batchAction(Request $request)
{
$this->request = $request;
$action = $request->get('action');
$selected = $request->get('selected');
$action = $request->request->get('action');
$selected = $request->request->all('selected');

if (!$selected || !$action) {
$this->addFlash(
'warning',
$this->getTranslator()->trans(
"action.batch.warning",
array(),
[],
'Admingenerator'
)
);
Expand Down Expand Up @@ -129,7 +129,7 @@ class ActionsController extends BaseController
*/
protected function getAdditionalRenderParameters(\{{ model }} ${{ builder.ModelClass }}, $action)
{
return array();
return [];
}

/**
Expand All @@ -156,7 +156,7 @@ class ActionsController extends BaseController
if (count($exception->getErrors()) > 0) {
$html = '<dl class="dl-horizontal dl-actions-error">';
foreach ($exception->getErrors() as $error) {
$label = $this->getTranslator()->trans(ucfirst($error->getPropertyPath()), array(), $translationDomain);
$label = $this->getTranslator()->trans(ucfirst($error->getPropertyPath()), [], $translationDomain);

$html .= '<dt>'.$label.'</dt><dd>'.$error->getMessage().'</dd>';
}
Expand Down
Loading
Loading