Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply fixes from StyleCI #241

Merged
merged 1 commit into from
Nov 5, 2017
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
2 changes: 1 addition & 1 deletion Admin/FieldDescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class FieldDescription extends BaseFieldDescription
*/
public function __construct()
{
$this->parentAssociationMappings = array();
$this->parentAssociationMappings = [];
}

/**
Expand Down
10 changes: 5 additions & 5 deletions Builder/DatagridBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function addFilter(DatagridInterface $datagrid, $type, FieldDescriptionIn

foreach ($options as $name => $value) {
if (is_array($value)) {
$fieldDescription->setOption($name, array_merge($value, $fieldDescription->getOption($name, array())));
$fieldDescription->setOption($name, array_merge($value, $fieldDescription->getOption($name, [])));
} else {
$fieldDescription->setOption($name, $fieldDescription->getOption($name, $value));
}
Expand All @@ -114,7 +114,7 @@ public function addFilter(DatagridInterface $datagrid, $type, FieldDescriptionIn
$this->fixFieldDescription($admin, $fieldDescription);
$admin->addFilterFieldDescription($fieldDescription->getName(), $fieldDescription);

$fieldDescription->mergeOption('field_options', array('required' => false));
$fieldDescription->mergeOption('field_options', ['required' => false]);
$filter = $this->filterFactory->create($fieldDescription->getName(), $type, $fieldDescription->getOptions());

if (false !== $filter->getLabel() && !$filter->getLabel()) {
Expand All @@ -130,17 +130,17 @@ public function addFilter(DatagridInterface $datagrid, $type, FieldDescriptionIn
*
* @return \Sonata\AdminBundle\Datagrid\DatagridInterface
*/
public function getBaseDatagrid(AdminInterface $admin, array $values = array())
public function getBaseDatagrid(AdminInterface $admin, array $values = [])
{
$pager = new Pager();
$pager->setCountColumn($admin->getModelManager()->getIdentifierFieldNames($admin->getClass()));

$defaultOptions = array();
$defaultOptions = [];
if ($this->csrfTokenEnabled) {
$defaultOptions['csrf_protection'] = false;
}

$formBuilder = $this->formFactory->createNamedBuilder('filter', 'form', array(), $defaultOptions);
$formBuilder = $this->formFactory->createNamedBuilder('filter', 'form', [], $defaultOptions);

return new Datagrid($admin->createQuery(), $admin->getList(), $pager, $formBuilder, $values);
}
Expand Down
20 changes: 10 additions & 10 deletions Builder/FormContractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter
$fieldDescription->setAdmin($admin);
$fieldDescription->setOption('edit', $fieldDescription->getOption('edit', 'standard'));

if (in_array($fieldDescription->getMappingType(), array(ClassMetadataInfo::ONE, ClassMetadataInfo::MANY))) {
if (in_array($fieldDescription->getMappingType(), [ClassMetadataInfo::ONE, ClassMetadataInfo::MANY])) {
$admin->attachAdminClass($fieldDescription);
}
}
Expand All @@ -76,7 +76,7 @@ public function getFormFactory()
/**
* {@inheritdoc}
*/
public function getFormBuilder($name, array $options = array())
public function getFormBuilder($name, array $options = [])
{
return $this->getFormFactory()->createNamedBuilder($name, 'form', null, $options);
}
Expand All @@ -86,33 +86,33 @@ public function getFormBuilder($name, array $options = array())
*/
public function getDefaultOptions($type, FieldDescriptionInterface $fieldDescription)
{
$options = array();
$options = [];
$options['sonata_field_description'] = $fieldDescription;

// NEXT_MAJOR: Check only against FQCNs when dropping support for Symfony <2.8
if ($this->checkFormType($type, array(
if ($this->checkFormType($type, [
'sonata_type_model',
'sonata_type_model_list',
)) || $this->checkFormClass($type, array(
]) || $this->checkFormClass($type, [
'Sonata\AdminBundle\Form\Type\ModelType',
'Sonata\AdminBundle\Form\Type\ModelListType',
))) {
])) {
if ('list' == $fieldDescription->getOption('edit')) {
throw new \LogicException('The ``sonata_type_model`` type does not accept an ``edit`` option anymore, please review the UPGRADE-2.1.md file from the SonataAdminBundle');
}

$options['class'] = $fieldDescription->getTargetEntity();
$options['model_manager'] = $fieldDescription->getAdmin()->getModelManager();
// NEXT_MAJOR: Check only against FQCNs when dropping support for Symfony <2.8
} elseif ($this->checkFormType($type, array('sonata_type_admin')) || $this->checkFormClass($type, array('Sonata\AdminBundle\Form\Type\AdminType'))) {
} elseif ($this->checkFormType($type, ['sonata_type_admin']) || $this->checkFormClass($type, ['Sonata\AdminBundle\Form\Type\AdminType'])) {
if (!$fieldDescription->getAssociationAdmin()) {
throw new \RuntimeException(sprintf('The current field `%s` is not linked to an admin. Please create one for the target entity : `%s`', $fieldDescription->getName(), $fieldDescription->getTargetEntity()));
}

$options['data_class'] = $fieldDescription->getAssociationAdmin()->getClass();
$fieldDescription->setOption('edit', $fieldDescription->getOption('edit', 'admin'));
// NEXT_MAJOR: Check only against FQCNs when dropping support for Symfony <2.8
} elseif ($this->checkFormType($type, array('sonata_type_collection')) || $this->checkFormClass($type, array('Sonata\CoreBundle\Form\Type\CollectionType'))) {
} elseif ($this->checkFormType($type, ['sonata_type_collection']) || $this->checkFormClass($type, ['Sonata\CoreBundle\Form\Type\CollectionType'])) {
if (!$fieldDescription->getAssociationAdmin()) {
throw new \RuntimeException(sprintf('The current field `%s` is not linked to an admin. Please create one for the target entity : `%s`', $fieldDescription->getName(), $fieldDescription->getTargetEntity()));
}
Expand All @@ -123,10 +123,10 @@ public function getDefaultOptions($type, FieldDescriptionInterface $fieldDescrip
'Sonata\AdminBundle\Form\Type\AdminType'
;
$options['modifiable'] = true;
$options['type_options'] = array(
$options['type_options'] = [
'sonata_field_description' => $fieldDescription,
'data_class' => $fieldDescription->getAssociationAdmin()->getClass(),
);
];
}

return $options;
Expand Down
8 changes: 4 additions & 4 deletions Builder/ListBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ class ListBuilder implements ListBuilderInterface
{
protected $guesser;

protected $templates = array();
protected $templates = [];

/**
* @param \Sonata\AdminBundle\Guesser\TypeGuesserInterface $guesser
* @param array $templates
*/
public function __construct(TypeGuesserInterface $guesser, array $templates = array())
public function __construct(TypeGuesserInterface $guesser, array $templates = [])
{
$this->guesser = $guesser;
$this->templates = $templates;
Expand All @@ -37,7 +37,7 @@ public function __construct(TypeGuesserInterface $guesser, array $templates = ar
/**
* {@inheritdoc}
*/
public function getBaseList(array $options = array())
public function getBaseList(array $options = [])
{
return new FieldDescriptionCollection();
}
Expand Down Expand Up @@ -130,7 +130,7 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter
$fieldDescription->setTemplate($template);
}

if (in_array($fieldDescription->getMappingType(), array(ClassMetadataInfo::ONE, ClassMetadataInfo::MANY))) {
if (in_array($fieldDescription->getMappingType(), [ClassMetadataInfo::ONE, ClassMetadataInfo::MANY])) {
$admin->attachAdminClass($fieldDescription);
}
}
Expand Down
4 changes: 2 additions & 2 deletions Builder/ShowBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(TypeGuesserInterface $guesser, array $templates)
*
* @return \Sonata\AdminBundle\Admin\FieldDescriptionCollection
*/
public function getBaseList(array $options = array())
public function getBaseList(array $options = [])
{
return new FieldDescriptionCollection();
}
Expand Down Expand Up @@ -121,7 +121,7 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter
$fieldDescription->setTemplate($template);
}

if (in_array($fieldDescription->getMappingType(), array(ClassMetadataInfo::ONE, ClassMetadataInfo::MANY))) {
if (in_array($fieldDescription->getMappingType(), [ClassMetadataInfo::ONE, ClassMetadataInfo::MANY])) {
$admin->attachAdminClass($fieldDescription);
}
}
Expand Down
4 changes: 2 additions & 2 deletions Datagrid/ProxyQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(Builder $queryBuilder)

public function __call($name, $args)
{
return call_user_func_array(array($this->queryBuilder, $name), $args);
return call_user_func_array([$this->queryBuilder, $name], $args);
}

public function __clone()
Expand All @@ -49,7 +49,7 @@ public function __clone()
*
* @return mixed
*/
public function execute(array $params = array(), $hydrationMode = null)
public function execute(array $params = [], $hydrationMode = null)
{
// always clone the original queryBuilder.
$queryBuilder = clone $this->queryBuilder;
Expand Down
6 changes: 3 additions & 3 deletions DependencyInjection/Compiler/AddGuesserCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function process(ContainerBuilder $container)
{
// ListBuilder
$definition = $container->getDefinition('sonata.admin.guesser.doctrine_mongodb_list_chain');
$services = array();
$services = [];
foreach ($container->findTaggedServiceIds('sonata.admin.guesser.doctrine_mongodb_list') as $id => $attributes) {
$services[] = new Reference($id);
}
Expand All @@ -36,7 +36,7 @@ public function process(ContainerBuilder $container)

// DatagridBuilder
$definition = $container->getDefinition('sonata.admin.guesser.doctrine_mongodb_datagrid_chain');
$services = array();
$services = [];
foreach ($container->findTaggedServiceIds('sonata.admin.guesser.doctrine_mongodb_datagrid') as $id => $attributes) {
$services[] = new Reference($id);
}
Expand All @@ -45,7 +45,7 @@ public function process(ContainerBuilder $container)

// ShowBuilder
$definition = $container->getDefinition('sonata.admin.guesser.doctrine_mongodb_show_chain');
$services = array();
$services = [];
foreach ($container->findTaggedServiceIds('sonata.admin.guesser.doctrine_mongodb_show') as $id => $attributes) {
$services[] = new Reference($id);
}
Expand Down
4 changes: 2 additions & 2 deletions DependencyInjection/Compiler/AddTemplatesCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ public function process(ContainerBuilder $container)
$templates = $container->getParameter('sonata_doctrine_mongodb_admin.templates');

if (!$definition->hasMethodCall('setFormTheme')) {
$definition->addMethodCall('setFormTheme', array($templates['form']));
$definition->addMethodCall('setFormTheme', [$templates['form']]);
}

if (!$definition->hasMethodCall('setFilterTheme')) {
$definition->addMethodCall('setFilterTheme', array($templates['filter']));
$definition->addMethodCall('setFilterTheme', [$templates['filter']]);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ public function getConfigTreeBuilder()
->children()
->arrayNode('form')
->prototype('scalar')->end()
->defaultValue(array('SonataDoctrineMongoDBAdminBundle:Form:form_admin_fields.html.twig'))
->defaultValue(['SonataDoctrineMongoDBAdminBundle:Form:form_admin_fields.html.twig'])
->end()
->arrayNode('filter')
->prototype('scalar')->end()
->defaultValue(array('SonataDoctrineMongoDBAdminBundle:Form:filter_admin_fields.html.twig'))
->defaultValue(['SonataDoctrineMongoDBAdminBundle:Form:filter_admin_fields.html.twig'])
->end()
->arrayNode('types')
->children()
Expand Down
14 changes: 7 additions & 7 deletions Filter/AbstractDateFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $data)
*/
public function getDefaultOptions()
{
return array('input_type' => 'datetime');
return ['input_type' => 'datetime'];
}

/**
Expand All @@ -99,11 +99,11 @@ public function getRenderSettings()
$name .= '_range';
}

return array($name, array(
return [$name, [
'field_type' => $this->getFieldType(),
'field_options' => $this->getFieldOptions(),
'label' => $this->getLabel(),
));
]];
}

/**
Expand All @@ -127,9 +127,9 @@ protected function applyType(ProxyQueryInterface $queryBuilder, $operation, $fie
*/
protected function typeRequiresValue($type)
{
return in_array($type, array(
return in_array($type, [
DateType::TYPE_NULL,
DateType::TYPE_NOT_NULL, )
DateType::TYPE_NOT_NULL, ]
);
}

Expand All @@ -142,15 +142,15 @@ protected function typeRequiresValue($type)
*/
protected function getOperator($type)
{
$choices = array(
$choices = [
DateType::TYPE_NULL => 'equals',
DateType::TYPE_NOT_NULL => 'notEqual',
DateType::TYPE_EQUAL => 'equals',
DateType::TYPE_GREATER_EQUAL => 'gte',
DateType::TYPE_GREATER_THAN => 'gt',
DateType::TYPE_LESS_EQUAL => 'lte',
DateType::TYPE_LESS_THAN => 'lt',
);
];

return $choices[intval($type)];
}
Expand Down
14 changes: 7 additions & 7 deletions Filter/BooleanFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $data)
}

if (is_array($data['value'])) {
$values = array();
$values = [];
foreach ($data['value'] as $v) {
if (!in_array($v, array(BooleanType::TYPE_NO, BooleanType::TYPE_YES))) {
if (!in_array($v, [BooleanType::TYPE_NO, BooleanType::TYPE_YES])) {
continue;
}

Expand All @@ -45,7 +45,7 @@ public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $data)
$queryBuilder->field($field)->in($values);
$this->active = true;
} else {
if (!in_array($data['value'], array(BooleanType::TYPE_NO, BooleanType::TYPE_YES))) {
if (!in_array($data['value'], [BooleanType::TYPE_NO, BooleanType::TYPE_YES])) {
return;
}

Expand All @@ -61,17 +61,17 @@ public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $data)
*/
public function getDefaultOptions()
{
return array();
return [];
}

public function getRenderSettings()
{
return array('sonata_type_filter_default', array(
return ['sonata_type_filter_default', [
'field_type' => $this->getFieldType(),
'field_options' => $this->getFieldOptions(),
'operator_type' => 'hidden',
'operator_options' => array(),
'operator_options' => [],
'label' => $this->getLabel(),
));
]];
}
}
10 changes: 5 additions & 5 deletions Filter/CallbackFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,25 @@ public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $data)
*/
public function getDefaultOptions()
{
return array(
return [
'callback' => null,
'active_callback' => function ($data) {
return isset($data['value']) && $data['value'];
},
'field_type' => 'text',
'operator_type' => 'hidden',
'operator_options' => array(),
);
'operator_options' => [],
];
}

public function getRenderSettings()
{
return array('sonata_type_filter_default', array(
return ['sonata_type_filter_default', [
'field_type' => $this->getFieldType(),
'field_options' => $this->getFieldOptions(),
'operator_type' => $this->getOption('operator_type'),
'operator_options' => $this->getOption('operator_options'),
'label' => $this->getLabel(),
));
]];
}
}
6 changes: 3 additions & 3 deletions Filter/ChoiceFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $data)
*/
public function getDefaultOptions()
{
return array();
return [];
}

public function getRenderSettings()
{
return array('sonata_type_filter_default', array(
return ['sonata_type_filter_default', [
'operator_type' => 'sonata_type_boolean',
'field_type' => $this->getFieldType(),
'field_options' => $this->getFieldOptions(),
'label' => $this->getLabel(),
));
]];
}
}
Loading