Skip to content

Commit

Permalink
Applied fixes from StyleCI (#2919)
Browse files Browse the repository at this point in the history
[ci skip] [skip ci]
  • Loading branch information
cmfcmf committed Jul 12, 2016
1 parent 564ee8e commit 72fe8f5
Show file tree
Hide file tree
Showing 19 changed files with 48 additions and 48 deletions.
20 changes: 10 additions & 10 deletions build.php
Expand Up @@ -31,7 +31,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

$output->writeln('Generating output');

$typeOrder = array(
$typeOrder = [
'zikula-module' => 'Zikula Modules',
'zikula-theme' => 'Zikula Themes',
'zikula-plugin' => 'Zikula Plugins',
Expand All @@ -40,15 +40,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
'library' => 'Other PHP libraries',
'composer-installer' => 'Composer Installers',
'composer-plugin' => 'Composer Plugins'
);
];
$types = array_keys($typeOrder);
usort($packages, function ($a, $b) use ($types) {
return array_search($a['type'], $types) - array_search($b['type'], $types);
});

$content = '';
$currentType = '';
$authors = array();
$authors = [];
foreach ($packages as $package) {
if ($currentType != $package['type']) {
if ($currentType != '') {
Expand Down Expand Up @@ -76,7 +76,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$content .= "These are the main authors of all of the projects supporting Zikula\n";
$content .= "-------------------------------------------------------------------\n";

$tmp = array();
$tmp = [];
foreach ($authors as $k => $author) {
if (in_array($author['name'], $tmp)) {
unset($authors[$k]);
Expand Down Expand Up @@ -140,7 +140,7 @@ public static function cleanVendors($dir, ProgressHelper $progress)
->ignoreVCS(false);
$progress->advance();

$paths = array();
$paths = [];
/** @var SplFileInfo $file */
foreach ($finder as $file) {
$paths[] = $file->getRealPath();
Expand Down Expand Up @@ -185,13 +185,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
public static function fix($dir, ProgressHelper $progress)
{
// fix paths in composer autoloader files removing src/ from paths
$composerFiles = array(
$composerFiles = [
'autoload_classmap.php',
'autoload_namespaces.php',
'autoload_real.php',
'autoload_files.php',
'autoload_psr4.php'
);
];
foreach ($composerFiles as $file) {
$file = "$dir/composer/$file";
$content = file_get_contents($file);
Expand Down Expand Up @@ -254,7 +254,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
PurgeVendorsCommand::cleanVendors("$buildDir/$name/vendor", $progress);
FixAutoloaderCommand::fix("$buildDir/$name/vendor", $progress);

$writableArray = array(
$writableArray = [
"$buildDir/$name/app/cache",
"$buildDir/$name/app/logs",
"$buildDir/$name/userdata",
Expand All @@ -266,7 +266,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
"$buildDir/$name/ztemp/Theme_compiled",
"$buildDir/$name/ztemp/idsTmp",
"$buildDir/$name/ztemp/purifierCache",
);
];
$filesystem->chmod($writableArray, 0777);
$filesystem->chmod("$buildDir/$name/config/config.php", 0666);
$progress->advance();
Expand All @@ -278,7 +278,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
->files()
->ignoreDotFiles(false);

$allFiles = array();
$allFiles = [];
/** @var SplFileInfo $file */
foreach ($finder as $file) {
$allFiles[] = $file->getRelativePathname();
Expand Down
Expand Up @@ -35,7 +35,7 @@ public function getFunctions()
{
return [
new \Twig_SimpleFunction('pager', [$this, 'pager'], ['is_safe' => ['html']]),
new \Twig_SimpleFunction('pagerabc', [$this, 'pagerabc'], array('is_safe' => array('html')))
new \Twig_SimpleFunction('pagerabc', [$this, 'pagerabc'], ['is_safe' => ['html']])
];
}

Expand Down Expand Up @@ -348,7 +348,7 @@ public function pagerabc($params)
if (!isset($params['class_numon'])) {
$params['class_numon'] = ' ';
}
$pager = array();
$pager = [];
if (!empty($params['names'])) {
if (!is_array($params['names'])) {
$pager['names'] = explode(';', $params['names']);
Expand All @@ -371,7 +371,7 @@ public function pagerabc($params)
// predefined abc
if (strtolower($params['skin']) == 'hu') {
// Hungarian
$pager['names'] = $pager['values'] = array('A', '?', 'B', 'C', 'D', 'E', '?', 'F', 'G', 'H', 'I', '?', 'J', 'K', 'L', 'M', 'N', 'O', '?', '?', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', '?', '?', 'U', 'V', 'W', 'X', 'Y', 'Z');
$pager['names'] = $pager['values'] = ['A', '?', 'B', 'C', 'D', 'E', '?', 'F', 'G', 'H', 'I', '?', 'J', 'K', 'L', 'M', 'N', 'O', '?', '?', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', '?', '?', 'U', 'V', 'W', 'X', 'Y', 'Z'];
//$params['names'] = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U' ,'V','W','X','Y','Z');
//$params['values'] = array('A,?','B','C','D','E,?','F','G','H','I,?','J','K','L','M','N','O,?,?,O','P','Q','R','S','T','U,?,?,U','V','W','X','Y','Z');
} else {
Expand All @@ -388,8 +388,8 @@ public function pagerabc($params)
$pagerUrl = function ($pager) {
return $this->container->get('router')->generate($pager['route'], $pager['args']);
};
$allVars = array_merge($request->request->all(), $request->query->all(), $request->attributes->get('_route_params', array()));
$pager['args'] = array();
$allVars = array_merge($request->request->all(), $request->query->all(), $request->attributes->get('_route_params', []));
$pager['args'] = [];
// If $forwardvars set, add only listed vars to query string, else add all POST and GET vars
if (isset($params['forwardvars'])) {
if (!is_array($params['forwardvars'])) {
Expand Down
Expand Up @@ -48,9 +48,9 @@ public function buildView(FormView $view, FormInterface $form, array $options)
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
$resolver->setDefaults([
'icon' => null,
));
]);
}

/**
Expand Down
Expand Up @@ -53,11 +53,11 @@ public function buildView(FormView $view, FormInterface $form, array $options)
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
$resolver->setDefaults([
'help' => null,
'input_group' => null,
'alert' => null
));
]);
}

/**
Expand Down
Expand Up @@ -21,12 +21,12 @@ class LocaleType extends AbstractType
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
$resolver->setDefaults([
'choices' => \ZLanguage::getInstalledLanguageNames(),
'label' => __('Locale'),
'required' => false,
'placeholder' => __('All')
));
]);
}

public function getName()
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Zikula/Composer/LessGenerator.php
Expand Up @@ -26,7 +26,7 @@ public static function generateCombinedBootstrapFontAwesomeCSS($writeTo = null)
// Also change build.xml if you change the default writeTo path here!
$writeTo = is_string($writeTo) ? $writeTo : 'src/web/bootstrap-font-awesome.css';
$parser = new \Less_Parser();
$parser->setOptions(array('relativeUrls' => false, 'compress' => true));
$parser->setOptions(['relativeUrls' => false, 'compress' => true]);
$parser->parseFile('src/style/bootstrap-font-awesome.less');

file_put_contents($writeTo, $parser->getCss());
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Zikula/Core/Controller/AbstractController.php
Expand Up @@ -201,7 +201,7 @@ public function hasPermission($component = null, $instance = null, $level = null
*
* @return Response A Response instance
*/
public function forward($controller, array $path = array(), array $query = array(), array $request = array())
public function forward($controller, array $path = [], array $query = [], array $request = [])
{
$path['_controller'] = $controller;
$subRequest = $this->container->get('request_stack')->getCurrentRequest()->duplicate($query, $request, $path);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/legacy/Zikula/View.php
Expand Up @@ -214,7 +214,7 @@ public function __construct(Zikula_ServiceManager $serviceManager, $moduleName =
$moduleName = $this->toplevelmodule;
}
$this->modinfo = ModUtil::getInfoFromName($moduleName);
$this->module = array($moduleName => $this->modinfo);
$this->module = [$moduleName => $this->modinfo];

// initialise environment vars
$this->language = ZLanguage::getLanguageCode();
Expand Down
4 changes: 2 additions & 2 deletions src/system/BlocksModule/Controller/AdminController.php
Expand Up @@ -92,12 +92,12 @@ public function viewAction(Request $request)
$sortableColumns->addColumn(new Column('language'));
$sortableColumns->addColumn(new Column('state'));
$sortableColumns->setOrderBy($sortableColumns->getColumn($sortField), $currentSortDirection);
$sortableColumns->setAdditionalUrlParameters(array(
$sortableColumns->setAdditionalUrlParameters([
'position' => isset($filterData['position']) ? $filterData['position'] : null,
'module' => isset($filterData['module']) ? $filterData['module'] : null,
'language' => isset($filterData['language']) ? $filterData['language'] : null,
'status' => isset($filterData['status']) ? $filterData['status'] : null,
));
]);

$templateParameters = [];
$templateParameters['blocks'] = $this->getDoctrine()->getManager()->getRepository('ZikulaBlocksModule:BlockEntity')->getFilteredBlocks($filterData);
Expand Down
4 changes: 2 additions & 2 deletions src/system/UsersModule/Api/UserApi.php
Expand Up @@ -36,11 +36,11 @@ public function accountLinks()
return false;
}

$accountlinks = array();
$accountlinks = [];

foreach ($mods as $mod) {
// saves 17 system checks
if ($mod['type'] == 3 && !in_array($mod['name'], array('ZikulaAdminModule', 'ZikulaCategoriesModule', 'ZikulaGroupsModule', 'ZikulaThemeModule', $this->name))) {
if ($mod['type'] == 3 && !in_array($mod['name'], ['ZikulaAdminModule', 'ZikulaCategoriesModule', 'ZikulaGroupsModule', 'ZikulaThemeModule', $this->name])) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion src/system/UsersModule/Controller/ConfigController.php
Expand Up @@ -49,7 +49,7 @@ public function configAction(Request $request)
if ($form->get('save')->isClicked()) {
$data = $form->getData();
$this->setVars($data);
$this->get('event_dispatcher')->dispatch(UserEvents::CONFIG_UPDATED, new GenericEvent(null, array(), $data));
$this->get('event_dispatcher')->dispatch(UserEvents::CONFIG_UPDATED, new GenericEvent(null, [], $data));
$this->addFlash('status', $this->__('Done! Configuration updated.'));
}
if ($form->get('cancel')->isClicked()) {
Expand Down
6 changes: 3 additions & 3 deletions src/system/UsersModule/Listener/PendingContentListener.php
Expand Up @@ -44,9 +44,9 @@ public function __construct(PermissionApi $permissionApi, UserRepositoryInterfac

public static function getSubscribedEvents()
{
return array(
'get.pending_content' => array('pendingContent'),
);
return [
'get.pending_content' => ['pendingContent'],
];
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/system/UsersModule/Listener/UserEventListener.php
Expand Up @@ -38,10 +38,10 @@ class UserEventListener implements EventSubscriberInterface

public static function getSubscribedEvents()
{
return array(
AccessEvents::LOGOUT_SUCCESS => array('clearUsersNamespace'),
KernelEvents::EXCEPTION => array('clearUsersNamespace'),
);
return [
AccessEvents::LOGOUT_SUCCESS => ['clearUsersNamespace'],
KernelEvents::EXCEPTION => ['clearUsersNamespace'],
];
}

public function __construct(\Zikula_Session $session, RequestStack $requestStack, RouterInterface $router)
Expand Down
Expand Up @@ -64,8 +64,8 @@ public function validate($value, Constraint $constraint)

// ensure legal domain
$illegalDomains = $this->variableApi->get('ZikulaUsersModule', UsersConstant::MODVAR_REGISTRATION_ILLEGAL_DOMAINS, '');
$pattern = array('/^((\s*,)*\s*)+/D', '/\b(\s*,\s*)+\b/D', '/((\s*,)*\s*)+$/D');
$replace = array('', '|', '');
$pattern = ['/^((\s*,)*\s*)+/D', '/\b(\s*,\s*)+\b/D', '/((\s*,)*\s*)+$/D'];
$replace = ['', '|', ''];
$illegalDomains = preg_replace($pattern, $replace, preg_quote($illegalDomains, '/'));
if (!empty($illegalDomains)) {
$emailDomain = strstr($value, '@');
Expand Down
Expand Up @@ -77,8 +77,8 @@ public function validate($value, Constraint $constraint)
// ensure not reserved/illegal
$illegalUserNames = $this->variableApi->get('ZikulaUsersModule', UsersConstant::MODVAR_REGISTRATION_ILLEGAL_UNAMES, '');
if (!empty($illegalUserNames)) {
$pattern = array('/^(\s*,\s*|\s+)+/D', '/\b(\s*,\s*|\s+)+\b/D', '/(\s*,\s*|\s+)+$/D');
$replace = array('', '|', '');
$pattern = ['/^(\s*,\s*|\s+)+/D', '/\b(\s*,\s*|\s+)+\b/D', '/(\s*,\s*|\s+)+$/D'];
$replace = ['', '|', ''];
$illegalUserNames = preg_replace($pattern, $replace, preg_quote($illegalUserNames, '/'));
if (preg_match("/^({$illegalUserNames})/iD", $value)) {
$this->context->buildViolation($this->translator->__('The user name you entered is reserved. It cannot be used.'))
Expand Down
2 changes: 1 addition & 1 deletion src/system/ZAuthModule/Helper/FileIOHelper.php
Expand Up @@ -130,7 +130,7 @@ public function importUsersFromFile(UploadedFile $file, $delimiter = ',')
if (!$lines = file($file->getPathname())) {
return $this->__("Error! It has not been possible to read the import file.");
}
$expectedFields = array('uname', 'pass', 'email', 'activated', 'sendmail', 'groups');
$expectedFields = ['uname', 'pass', 'email', 'activated', 'sendmail', 'groups'];
$firstLineArray = explode($delimiter, str_replace('"', '', trim($lines[0])));
foreach ($firstLineArray as $field) {
if (!in_array(trim(strtolower($field)), $expectedFields)) {
Expand Down
6 changes: 3 additions & 3 deletions src/system/ZAuthModule/Listener/UserEventListener.php
Expand Up @@ -33,9 +33,9 @@ class UserEventListener implements EventSubscriberInterface

public static function getSubscribedEvents()
{
return array(
AccessEvents::LOGIN_VETO => array('forcedPasswordChange'),
);
return [
AccessEvents::LOGIN_VETO => ['forcedPasswordChange'],
];
}

public function __construct(\Zikula_Session $session, RouterInterface $router)
Expand Down
Expand Up @@ -64,8 +64,8 @@ public function validate($value, Constraint $constraint)

// ensure legal domain
$illegalDomains = $this->variableApi->get('ZikulaZAuthModule', UsersConstant::MODVAR_REGISTRATION_ILLEGAL_DOMAINS, '');
$pattern = array('/^((\s*,)*\s*)+/D', '/\b(\s*,\s*)+\b/D', '/((\s*,)*\s*)+$/D');
$replace = array('', '|', '');
$pattern = ['/^((\s*,)*\s*)+/D', '/\b(\s*,\s*)+\b/D', '/((\s*,)*\s*)+$/D'];
$replace = ['', '|', ''];
$illegalDomains = preg_replace($pattern, $replace, preg_quote($illegalDomains, '/'));
if (!empty($illegalDomains)) {
$emailDomain = strstr($value, '@');
Expand Down
Expand Up @@ -77,8 +77,8 @@ public function validate($value, Constraint $constraint)
// ensure not reserved/illegal
$illegalUserNames = $this->variableApi->get('ZikulaZAuthModule', UsersConstant::MODVAR_REGISTRATION_ILLEGAL_UNAMES, '');
if (!empty($illegalUserNames)) {
$pattern = array('/^(\s*,\s*|\s+)+/D', '/\b(\s*,\s*|\s+)+\b/D', '/(\s*,\s*|\s+)+$/D');
$replace = array('', '|', '');
$pattern = ['/^(\s*,\s*|\s+)+/D', '/\b(\s*,\s*|\s+)+\b/D', '/(\s*,\s*|\s+)+$/D'];
$replace = ['', '|', ''];
$illegalUserNames = preg_replace($pattern, $replace, preg_quote($illegalUserNames, '/'));
if (preg_match("/^({$illegalUserNames})/iD", $value)) {
$this->context->buildViolation($this->translator->__('The user name you entered is reserved. It cannot be used.'))
Expand Down

0 comments on commit 72fe8f5

Please sign in to comment.