Use short array syntax (#135)

This commit is contained in:
Simon Schaufelberger
2018-02-10 19:05:19 +01:00
committed by Kevin Papst
parent 4c6158c1ea
commit 5527f29caf
14 changed files with 33 additions and 34 deletions

View File

@@ -344,8 +344,8 @@ class KimaiImporterCommand extends Command
*/
protected function bytesHumanReadable($size)
{
$unit=array('b','kB','MB','GB');
return @round($size/pow(1024, ($i=floor(log($size, 1024)))), 2).' '.$unit[$i];
$unit = ['b', 'kB', 'MB', 'GB'];
return @round($size / pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $unit[$i];
}
/**

View File

@@ -270,7 +270,7 @@ class ProfileController extends AbstractController
UserPasswordType::class,
$user,
[
'validation_groups' => array('passwordUpdate'),
'validation_groups' => ['passwordUpdate'],
'action' => $this->generateUrl('user_profile_password', ['username' => $user->getUsername()]),
'method' => 'POST'
]

View File

@@ -114,13 +114,13 @@ class DoctrineCompilerPass implements CompilerPassInterface
$ormConfig = $container->getDefinition('doctrine.orm.default_configuration');
foreach ($sql['string_functions'] as $name => $function) {
$ormConfig->addMethodCall('addCustomStringFunction', array($name, $function));
$ormConfig->addMethodCall('addCustomStringFunction', [$name, $function]);
}
foreach ($sql['numeric_functions'] as $name => $function) {
$ormConfig->addMethodCall('addCustomNumericFunction', array($name, $function));
$ormConfig->addMethodCall('addCustomNumericFunction', [$name, $function]);
}
foreach ($sql['datetime_functions'] as $name => $function) {
$ormConfig->addMethodCall('addCustomDatetimeFunction', array($name, $function));
$ormConfig->addMethodCall('addCustomDatetimeFunction', [$name, $function]);
}
}
}

View File

@@ -52,7 +52,7 @@ class Configuration implements ConfigurationInterface
->end()
->end()
->end()
->defaultValue(array())
->defaultValue([])
->end()
->arrayNode('rates')
@@ -84,27 +84,27 @@ class Configuration implements ConfigurationInterface
->useAttributeAsKey('key')
->isRequired()
->prototype('scalar')->end()
->defaultValue(array(
->defaultValue([
'default' => 'App\Controller\InvoiceController::invoiceAction',
))
])
->end()
->arrayNode('calculator')
->requiresAtLeastOneElement()
->useAttributeAsKey('key')
->isRequired()
->prototype('scalar')->end()
->defaultValue(array(
->defaultValue([
'default' => 'App\Invoice\DefaultCalculator',
))
])
->end()
->arrayNode('number_generator')
->requiresAtLeastOneElement()
->useAttributeAsKey('key')
->isRequired()
->prototype('scalar')->end()
->defaultValue(array(
->defaultValue([
'default' => 'App\Invoice\DateNumberGenerator',
))
])
->end()
->end()
->end()

View File

@@ -26,7 +26,7 @@ class TablePrefixSubscriber implements EventSubscriber
public function getSubscribedEvents()
{
return array('loadClassMetadata');
return ['loadClassMetadata'];
}
public function loadClassMetadata(LoadClassMetadataEventArgs $args)

View File

@@ -47,10 +47,10 @@ class TimesheetSubscriber implements EventSubscriber
*/
public function getSubscribedEvents()
{
return array(
return [
'prePersist',
'preUpdate',
);
];
}
/**

View File

@@ -137,7 +137,7 @@ abstract class AbstractToolbarForm extends AbstractType
return;
}
$event->getForm()->add('project', ProjectType::class, array(
$event->getForm()->add('project', ProjectType::class, [
'group_by' => null,
'required' => false,
'query_builder' => function (ProjectRepository $repo) use ($data) {
@@ -145,7 +145,7 @@ abstract class AbstractToolbarForm extends AbstractType
$qb->where('p.customer = :customer')->setParameter('customer', $data['customer']);
return $qb;
},
));
]);
}
);
}
@@ -163,7 +163,7 @@ abstract class AbstractToolbarForm extends AbstractType
return;
}
$event->getForm()->add('activity', ActivityType::class, array(
$event->getForm()->add('activity', ActivityType::class, [
'group_by' => null,
'required' => false,
'query_builder' => function (ActivityRepository $repo) use ($data) {
@@ -171,7 +171,7 @@ abstract class AbstractToolbarForm extends AbstractType
$qb->where('a.project = :project')->setParameter('project', $data['project']);
return $qb;
},
));
]);
}
);
}

View File

@@ -26,10 +26,10 @@ class LanguageType extends AbstractType
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'choices' => array(
'choices' => [
Intl::getLocaleBundle()->getLocaleName('de', 'de') => 'de',
Intl::getLocaleBundle()->getLocaleName('en', 'en') => 'en',
)
]
]);
}

View File

@@ -26,7 +26,7 @@ class SkinType extends AbstractType
{
$resolver->setDefaults([
'required' => true,
'choices' => array(
'choices' => [
'blue' => 'blue',
'black' => 'black',
'green' => 'green',
@@ -39,7 +39,7 @@ class SkinType extends AbstractType
'purple-light' => 'purple-light',
'red-light' => 'red-light',
'yellow-light' => 'yellow-light',
)
]
]);
}

View File

@@ -60,8 +60,8 @@ class UserPreferenceType extends AbstractType
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
$resolver->setDefaults([
'data_class' => UserPreference::class,
));
]);
}
}

View File

@@ -33,8 +33,8 @@ class UserCreateType extends UserEditType
->add('plainPassword', RepeatedType::class, [
'required' => true,
'type' => PasswordType::class,
'first_options' => array('label' => 'label.password'),
'second_options' => array('label' => 'label.password_repeat'),
'first_options' => ['label' => 'label.password'],
'second_options' => ['label' => 'label.password_repeat'],
]);
parent::buildForm($builder, $options);

View File

@@ -30,8 +30,8 @@ class UserPasswordType extends AbstractType
$builder
->add('plainPassword', RepeatedType::class, [
'type' => PasswordType::class,
'first_options' => array('label' => 'label.password'),
'second_options' => array('label' => 'label.password_repeat'),
'first_options' => ['label' => 'label.password'],
'second_options' => ['label' => 'label.password_repeat'],
])
;
}

View File

@@ -29,7 +29,7 @@ class UserPreferencesForm extends AbstractType
{
$builder->add('preferences', CollectionType::class, [
'entry_type' => UserPreferenceType::class,
'entry_options' => array('label' => false),
'entry_options' => ['label' => false],
'allow_add' => false,
'allow_delete' => false,
'label' => false,
@@ -46,7 +46,6 @@ class UserPreferencesForm extends AbstractType
'csrf_protection' => true,
'csrf_field_name' => '_token',
'csrf_token_id' => 'edit_user_preferences',
]);
}
}

View File

@@ -19,9 +19,9 @@ class Role extends Constraint
{
const ROLE_ERROR = 'xd5hffg-dsfef3-426a-83d7-1f2d33hs5d84';
protected static $errorNames = array(
protected static $errorNames = [
self::ROLE_ERROR => 'ROLE_ERROR',
);
];
public $message = 'This value is not a valid role.';
}