Skip to content

Commit 53a2b12

Browse files
committed
Update: php-cs-fixer, enable short array syntax
1 parent ccbef01 commit 53a2b12

File tree

575 files changed

+5752
-5190
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

575 files changed

+5752
-5190
lines changed

.php-cs-fixer.dist.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
->in(__DIR__.'/lib')
66
->in(__DIR__.'/data/bin')
77
->in(__DIR__.'/test')
8-
->append(array(__FILE__))
8+
->append([__FILE__])
99
// Exclude PHP classes templates/generators, which are not valid PHP files
1010
->exclude('task/generator/skeleton/')
1111
->exclude('plugins/sfDoctrinePlugin/data/generator/')
@@ -15,13 +15,12 @@
1515
;
1616

1717
$config = new PhpCsFixer\Config();
18-
$config->setRules(array(
19-
'@PhpCsFixer' => true,
20-
'@Symfony' => true,
21-
'array_syntax' => array(
22-
'syntax' => 'long',
23-
),
24-
))
18+
$config
19+
->setRules([
20+
'@PhpCsFixer' => true,
21+
'@Symfony' => true,
22+
'array_syntax' => ['syntax' => 'short'],
23+
])
2524
->setCacheFile('.php-cs-fixer.cache')
2625
->setFinder($finder)
2726
;

data/bin/changelog.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
list($out, $err) = $filesystem->execute('svn info --xml');
3737
$info = new SimpleXMLElement($out);
3838

39-
list($out, $err) = $filesystem->execute(vsprintf('svn log %s --xml %s', array_map('escapeshellarg', array(
39+
list($out, $err) = $filesystem->execute(vsprintf('svn log %s --xml %s', array_map('escapeshellarg', [
4040
$argv[1],
4141
(string) $info->entry->repository->root.$argv[2],
42-
))));
42+
])));
4343
$log = new SimpleXMLElement($out);
4444

4545
foreach ($log->logentry as $logentry) {

data/bin/release.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
// add class files
7474
$finder = sfFinder::type('file')->relative();
7575
$xml_classes = '';
76-
$dirs = array('lib' => 'php', 'data' => 'data');
76+
$dirs = ['lib' => 'php', 'data' => 'data'];
7777
foreach ($dirs as $dir => $role) {
7878
$class_files = $finder->in($dir);
7979
foreach ($class_files as $file) {
@@ -82,12 +82,12 @@
8282
}
8383

8484
// replace tokens
85-
$filesystem->replaceTokens(getcwd().DIRECTORY_SEPARATOR.'package.xml', '##', '##', array(
85+
$filesystem->replaceTokens(getcwd().DIRECTORY_SEPARATOR.'package.xml', '##', '##', [
8686
'SYMFONY_VERSION' => $version,
8787
'CURRENT_DATE' => date('Y-m-d'),
8888
'CLASS_FILES' => $xml_classes,
8989
'STABILITY' => $stability,
90-
));
90+
]);
9191

9292
list($results) = $filesystem->execute('pear package');
9393
echo $results;

data/bin/sandbox_installer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
chmod(sfConfig::get('sf_data_dir').'/sandbox.db', 0777);
2424

2525
$this->logSection('install', 'add an empty file in empty directories');
26-
$seen = array();
26+
$seen = [];
2727
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator(sfConfig::get('sf_root_dir')), RecursiveIteratorIterator::CHILD_FIRST) as $path => $item) {
2828
if (!isset($seen[$path]) && $item->isDir() && !$item->isLink()) {
2929
touch($item->getRealPath().'/.sf');

lib/action/sfAction.class.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
abstract class sfAction extends sfComponent
2222
{
23-
protected $security = array();
23+
protected $security = [];
2424

2525
/**
2626
* Initializes this action.
@@ -122,7 +122,7 @@ public function redirect404()
122122
public function forward($module, $action)
123123
{
124124
if (sfConfig::get('sf_logging_enabled')) {
125-
$this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Forward to action "%s/%s"', $module, $action))));
125+
$this->dispatcher->notify(new sfEvent($this, 'application.log', [sprintf('Forward to action "%s/%s"', $module, $action)]));
126126
}
127127

128128
$this->getController()->forward($module, $action);
@@ -184,7 +184,7 @@ public function redirect($url, $statusCode = 302)
184184
{
185185
// compatibility with url_for2() style signature
186186
if (is_object($statusCode) || is_array($statusCode)) {
187-
$url = array_merge(array('sf_route' => $url), is_object($statusCode) ? array('sf_subject' => $statusCode) : $statusCode);
187+
$url = array_merge(['sf_route' => $url], is_object($statusCode) ? ['sf_subject' => $statusCode] : $statusCode);
188188
$statusCode = func_num_args() >= 3 ? func_get_arg(2) : 302;
189189
}
190190

@@ -211,7 +211,7 @@ public function redirectIf($condition, $url, $statusCode = 302)
211211
if ($condition) {
212212
// compatibility with url_for2() style signature
213213
$arguments = func_get_args();
214-
call_user_func_array(array($this, 'redirect'), array_slice($arguments, 1));
214+
call_user_func_array([$this, 'redirect'], array_slice($arguments, 1));
215215
}
216216
}
217217

@@ -233,7 +233,7 @@ public function redirectUnless($condition, $url, $statusCode = 302)
233233
if (!$condition) {
234234
// compatibility with url_for2() style signature
235235
$arguments = func_get_args();
236-
call_user_func_array(array($this, 'redirect'), array_slice($arguments, 1));
236+
call_user_func_array([$this, 'redirect'], array_slice($arguments, 1));
237237
}
238238
}
239239

@@ -430,7 +430,7 @@ public function getCredential()
430430
public function setTemplate($name, $module = null)
431431
{
432432
if (sfConfig::get('sf_logging_enabled')) {
433-
$this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Change template to "%s/%s"', null === $module ? 'CURRENT' : $module, $name))));
433+
$this->dispatcher->notify(new sfEvent($this, 'application.log', [sprintf('Change template to "%s/%s"', null === $module ? 'CURRENT' : $module, $name)]));
434434
}
435435

436436
if (null !== $module) {
@@ -468,7 +468,7 @@ public function getTemplate()
468468
public function setLayout($name)
469469
{
470470
if (sfConfig::get('sf_logging_enabled')) {
471-
$this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Change layout to "%s"', $name))));
471+
$this->dispatcher->notify(new sfEvent($this, 'application.log', [sprintf('Change layout to "%s"', $name)]));
472472
}
473473

474474
sfConfig::set('symfony.view.'.$this->getModuleName().'_'.$this->getActionName().'_layout', $name);

lib/action/sfActionStack.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
class sfActionStack
2020
{
2121
/** @var sfActionStackEntry[] */
22-
protected $stack = array();
22+
protected $stack = [];
2323

2424
/**
2525
* Adds an entry to the action stack.

lib/action/sfActions.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ public function execute($request)
4141
throw new sfInitializationException(sprintf('sfAction initialization failed for module "%s". There was no action given.', $this->getModuleName()));
4242
}
4343

44-
if (!is_callable(array($this, $actionToRun))) {
44+
if (!is_callable([$this, $actionToRun])) {
4545
// action not found
4646
throw new sfInitializationException(sprintf('sfAction initialization failed for module "%s", action "%s". You must create a "%s" method.', $this->getModuleName(), $this->getActionName(), $actionToRun));
4747
}
4848

4949
if (sfConfig::get('sf_logging_enabled')) {
50-
$this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Call "%s->%s()"', get_class($this), $actionToRun))));
50+
$this->dispatcher->notify(new sfEvent($this, 'application.log', [sprintf('Call "%s->%s()"', get_class($this), $actionToRun)]));
5151
}
5252

5353
// run action

lib/action/sfComponent.class.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function __construct($context, $moduleName, $actionName)
6262
*
6363
* @return string The translated string
6464
*/
65-
public function __($string, $args = array(), $catalogue = 'messages')
65+
public function __($string, $args = [], $catalogue = 'messages')
6666
{
6767
return $this->context->getI18N()->__($string, $args, $catalogue);
6868
}
@@ -128,7 +128,7 @@ public function __unset($name)
128128
*/
129129
public function __call($method, $arguments)
130130
{
131-
$event = $this->dispatcher->notifyUntil(new sfEvent($this, 'component.method_not_found', array('method' => $method, 'arguments' => $arguments)));
131+
$event = $this->dispatcher->notifyUntil(new sfEvent($this, 'component.method_not_found', ['method' => $method, 'arguments' => $arguments]));
132132
if (!$event->isProcessed()) {
133133
throw new sfException(sprintf('Call to undefined method %s::%s.', get_class($this), $method));
134134
}
@@ -247,7 +247,7 @@ final public function getLogger()
247247
public function logMessage($message, $priority = 'info')
248248
{
249249
if (sfConfig::get('sf_logging_enabled')) {
250-
$this->dispatcher->notify(new sfEvent($this, 'application.log', array($message, 'priority' => constant('sfLogger::'.strtoupper($priority)))));
250+
$this->dispatcher->notify(new sfEvent($this, 'application.log', [$message, 'priority' => constant('sfLogger::'.strtoupper($priority))]));
251251
}
252252
}
253253

@@ -339,7 +339,7 @@ public function getController()
339339
*
340340
* @return string The URL
341341
*/
342-
public function generateUrl($route, $params = array(), $absolute = false)
342+
public function generateUrl($route, $params = [], $absolute = false)
343343
{
344344
return $this->context->getRouting()->generate($route, $params, $absolute);
345345
}

lib/addon/sfData.class.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
abstract class sfData
1818
{
1919
protected $deleteCurrentData = true;
20-
protected $object_references = array();
20+
protected $object_references = [];
2121

2222
/**
2323
* Sets a flag to indicate if the current data in the database
@@ -66,7 +66,7 @@ public function getFiles($element = null)
6666
$element = sfConfig::get('sf_data_dir').'/fixtures';
6767
}
6868

69-
$files = array();
69+
$files = [];
7070
if (is_array($element)) {
7171
foreach ($element as $e) {
7272
$files = array_merge($files, $this->getFiles($e));
@@ -106,8 +106,8 @@ protected function doLoadDataFromFile($file)
106106
*/
107107
protected function doLoadData(array $files)
108108
{
109-
$this->object_references = array();
110-
$this->maps = array();
109+
$this->object_references = [];
110+
$this->maps = [];
111111

112112
foreach ($files as $file) {
113113
$this->doLoadDataFromFile($file);

lib/addon/sfPager.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ abstract class sfPager implements Iterator, Countable
2323
protected $tableName = '';
2424
protected $objects;
2525
protected $cursor = 1;
26-
protected $parameters = array();
26+
protected $parameters = [];
2727
protected $currentMaxLink = 1;
2828
protected $parameterHolder;
2929
protected $maxRecordLimit = false;
@@ -97,7 +97,7 @@ public function setMaxRecordLimit($limit)
9797
*/
9898
public function getLinks($nb_links = 5)
9999
{
100-
$links = array();
100+
$links = [];
101101
$tmp = $this->page - floor($nb_links / 2);
102102
$check = $this->lastPage - $nb_links + 1;
103103
$limit = $check > 0 ? $check : 1;

0 commit comments

Comments
 (0)