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

convert to short array syntax #315

Closed
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 6 additions & 6 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
->in(__DIR__.'/lib')
->in(__DIR__.'/data/bin')
->in(__DIR__.'/test')
->append(array(__FILE__))
->append([__FILE__])
// Exclude PHP classes templates/generators, which are not valid PHP files
->exclude('task/generator/skeleton/')
->exclude('plugins/sfDoctrinePlugin/data/generator/')
Expand All @@ -15,13 +15,13 @@
;

$config = new PhpCsFixer\Config();
$config->setRules(array(
$config->setRules([
'@PhpCsFixer' => true,
'@Symfony' => true,
'array_syntax' => array(
'syntax' => 'long',
),
))
'array_syntax' => [
'syntax' => 'short',
],
])
->setCacheFile('.php-cs-fixer.cache')
->setFinder($finder)
;
Expand Down
4 changes: 2 additions & 2 deletions data/bin/changelog.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
list($out, $err) = $filesystem->execute('svn info --xml');
$info = new SimpleXMLElement($out);

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

foreach ($log->logentry as $logentry) {
Expand Down
5 changes: 5 additions & 0 deletions data/bin/check_configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ function is_cli()

/**
* Checks a configuration.
*
* @param mixed $boolean
* @param mixed $message
* @param mixed $help
* @param mixed $fatal
*/
function check($boolean, $message, $help = '', $fatal = false)
{
Expand Down
6 changes: 3 additions & 3 deletions data/bin/release.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
// add class files
$finder = sfFinder::type('file')->relative();
$xml_classes = '';
$dirs = array('lib' => 'php', 'data' => 'data');
$dirs = ['lib' => 'php', 'data' => 'data'];
foreach ($dirs as $dir => $role) {
$class_files = $finder->in($dir);
foreach ($class_files as $file) {
Expand All @@ -82,12 +82,12 @@
}

// replace tokens
$filesystem->replaceTokens(getcwd().DIRECTORY_SEPARATOR.'package.xml', '##', '##', array(
$filesystem->replaceTokens(getcwd().DIRECTORY_SEPARATOR.'package.xml', '##', '##', [
'SYMFONY_VERSION' => $version,
'CURRENT_DATE' => date('Y-m-d'),
'CLASS_FILES' => $xml_classes,
'STABILITY' => $stability,
));
]);

list($results) = $filesystem->execute('pear package');
echo $results;
Expand Down
2 changes: 1 addition & 1 deletion data/bin/sandbox_installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
chmod(sfConfig::get('sf_data_dir').'/sandbox.db', 0777);

$this->logSection('install', 'add an empty file in empty directories');
$seen = array();
$seen = [];
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator(sfConfig::get('sf_root_dir')), RecursiveIteratorIterator::CHILD_FIRST) as $path => $item) {
if (!isset($seen[$path]) && $item->isDir() && !$item->isLink()) {
touch($item->getRealPath().'/.sf');
Expand Down
14 changes: 7 additions & 7 deletions lib/action/sfAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
abstract class sfAction extends sfComponent
{
protected $security = array();
protected $security = [];

/**
* Initializes this action.
Expand Down Expand Up @@ -124,7 +124,7 @@ public function redirect404()
public function forward($module, $action)
{
if (sfConfig::get('sf_logging_enabled')) {
$this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Forward to action "%s/%s"', $module, $action))));
$this->dispatcher->notify(new sfEvent($this, 'application.log', [sprintf('Forward to action "%s/%s"', $module, $action)]));
}

$this->getController()->forward($module, $action);
Expand Down Expand Up @@ -186,7 +186,7 @@ public function redirect($url, $statusCode = 302)
{
// compatibility with url_for2() style signature
if (is_object($statusCode) || is_array($statusCode)) {
$url = array_merge(array('sf_route' => $url), is_object($statusCode) ? array('sf_subject' => $statusCode) : $statusCode);
$url = array_merge(['sf_route' => $url], is_object($statusCode) ? ['sf_subject' => $statusCode] : $statusCode);
$statusCode = func_num_args() >= 3 ? func_get_arg(2) : 302;
}

Expand All @@ -213,7 +213,7 @@ public function redirectIf($condition, $url, $statusCode = 302)
if ($condition) {
// compatibility with url_for2() style signature
$arguments = func_get_args();
call_user_func_array(array($this, 'redirect'), array_slice($arguments, 1));
call_user_func_array([$this, 'redirect'], array_slice($arguments, 1));
}
}

Expand All @@ -235,7 +235,7 @@ public function redirectUnless($condition, $url, $statusCode = 302)
if (!$condition) {
// compatibility with url_for2() style signature
$arguments = func_get_args();
call_user_func_array(array($this, 'redirect'), array_slice($arguments, 1));
call_user_func_array([$this, 'redirect'], array_slice($arguments, 1));
}
}

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

if (null !== $module) {
Expand Down Expand Up @@ -470,7 +470,7 @@ public function getTemplate()
public function setLayout($name)
{
if (sfConfig::get('sf_logging_enabled')) {
$this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Change layout to "%s"', $name))));
$this->dispatcher->notify(new sfEvent($this, 'application.log', [sprintf('Change layout to "%s"', $name)]));
}

sfConfig::set('symfony.view.'.$this->getModuleName().'_'.$this->getActionName().'_layout', $name);
Expand Down
2 changes: 1 addition & 1 deletion lib/action/sfActionStack.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
class sfActionStack
{
/** @var sfActionStackEntry[] */
protected $stack = array();
protected $stack = [];

/**
* Adds an entry to the action stack.
Expand Down
4 changes: 2 additions & 2 deletions lib/action/sfActions.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public function execute($request)
throw new sfInitializationException(sprintf('sfAction initialization failed for module "%s". There was no action given.', $this->getModuleName()));
}

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

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

// run action
Expand Down
8 changes: 4 additions & 4 deletions lib/action/sfComponent.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function __construct($context, $moduleName, $actionName)
*
* @return string The translated string
*/
public function __($string, $args = array(), $catalogue = 'messages')
public function __($string, $args = [], $catalogue = 'messages')
{
return $this->context->getI18N()->__($string, $args, $catalogue);
}
Expand Down Expand Up @@ -130,7 +130,7 @@ public function __unset($name)
*/
public function __call($method, $arguments)
{
$event = $this->dispatcher->notifyUntil(new sfEvent($this, 'component.method_not_found', array('method' => $method, 'arguments' => $arguments)));
$event = $this->dispatcher->notifyUntil(new sfEvent($this, 'component.method_not_found', ['method' => $method, 'arguments' => $arguments]));
if (!$event->isProcessed()) {
throw new sfException(sprintf('Call to undefined method %s::%s.', get_class($this), $method));
}
Expand Down Expand Up @@ -249,7 +249,7 @@ final public function getLogger()
public function logMessage($message, $priority = 'info')
{
if (sfConfig::get('sf_logging_enabled')) {
$this->dispatcher->notify(new sfEvent($this, 'application.log', array($message, 'priority' => constant('sfLogger::'.strtoupper($priority)))));
$this->dispatcher->notify(new sfEvent($this, 'application.log', [$message, 'priority' => constant('sfLogger::'.strtoupper($priority))]));
}
}

Expand Down Expand Up @@ -341,7 +341,7 @@ public function getController()
*
* @return string The URL
*/
public function generateUrl($route, $params = array(), $absolute = false)
public function generateUrl($route, $params = [], $absolute = false)
{
return $this->context->getRouting()->generate($route, $params, $absolute);
}
Expand Down
8 changes: 4 additions & 4 deletions lib/addon/sfData.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
abstract class sfData
{
protected $deleteCurrentData = true;
protected $object_references = array();
protected $object_references = [];

/**
* Sets a flag to indicate if the current data in the database
Expand Down Expand Up @@ -68,7 +68,7 @@ public function getFiles($element = null)
$element = sfConfig::get('sf_data_dir').'/fixtures';
}

$files = array();
$files = [];
if (is_array($element)) {
foreach ($element as $e) {
$files = array_merge($files, $this->getFiles($e));
Expand Down Expand Up @@ -108,8 +108,8 @@ protected function doLoadDataFromFile($file)
*/
protected function doLoadData(array $files)
{
$this->object_references = array();
$this->maps = array();
$this->object_references = [];
$this->maps = [];

foreach ($files as $file) {
$this->doLoadDataFromFile($file);
Expand Down
5 changes: 3 additions & 2 deletions lib/addon/sfPager.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ abstract class sfPager implements Iterator, Countable
protected $tableName = '';
protected $objects;
protected $cursor = 1;
protected $parameters = array();
protected $parameters = [];
protected $currentMaxLink = 1;
protected $parameterHolder;
protected $maxRecordLimit = false;
Expand Down Expand Up @@ -99,7 +99,7 @@ public function setMaxRecordLimit($limit)
*/
public function getLinks($nb_links = 5)
{
$links = array();
$links = [];
$tmp = $this->page - floor($nb_links / 2);
$check = $this->lastPage - $nb_links + 1;
$limit = $check > 0 ? $check : 1;
Expand Down Expand Up @@ -416,6 +416,7 @@ public function hasParameter($name)
* Sets a parameter.
*
* @param string $name
* @param mixed $value
*/
public function setParameter($name, $value)
{
Expand Down
8 changes: 4 additions & 4 deletions lib/autoload/sfAutoload.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class sfAutoload
protected static $freshCache = false;
protected static $instance;

protected $overriden = array();
protected $classes = array();
protected $overriden = [];
protected $classes = [];

protected function __construct()
{
Expand Down Expand Up @@ -53,7 +53,7 @@ public static function register()
{
ini_set('unserialize_callback_func', 'spl_autoload_call');

if (false === spl_autoload_register(array(self::getInstance(), 'autoload'))) {
if (false === spl_autoload_register([self::getInstance(), 'autoload'])) {
throw new sfException(sprintf('Unable to register %s::autoload as an autoloading method.', get_class(self::getInstance())));
}
}
Expand All @@ -63,7 +63,7 @@ public static function register()
*/
public static function unregister()
{
spl_autoload_unregister(array(self::getInstance(), 'autoload'));
spl_autoload_unregister([self::getInstance(), 'autoload']);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions lib/autoload/sfAutoloadAgain.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function autoload($class)
}
}
} else {
$position = array_search(array(__CLASS__, 'autoload'), $autoloads, true);
$position = array_search([__CLASS__, 'autoload'], $autoloads, true);
}

if (isset($autoloads[$position + 1])) {
Expand Down Expand Up @@ -104,7 +104,7 @@ public function isRegistered()
public function register()
{
if (!$this->isRegistered()) {
spl_autoload_register(array($this, 'autoload'));
spl_autoload_register([$this, 'autoload']);
$this->registered = true;
}
}
Expand All @@ -114,7 +114,7 @@ public function register()
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'autoload'));
spl_autoload_unregister([$this, 'autoload']);
$this->registered = false;
}
}
8 changes: 4 additions & 4 deletions lib/autoload/sfCoreAutoload.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class sfCoreAutoload

// Don't edit this property by hand.
// To update it, use sfCoreAutoload::make()
protected $classes = array(
protected $classes = [
'sfaction' => 'action/sfAction.class.php',
'sfactionstack' => 'action/sfActionStack.class.php',
'sfactionstackentry' => 'action/sfActionStackEntry.class.php',
Expand Down Expand Up @@ -394,7 +394,7 @@ class sfCoreAutoload
'sfyamldumper' => 'yaml/sfYamlDumper.class.php',
'sfyamlinline' => 'yaml/sfYamlInline.class.php',
'sfyamlparser' => 'yaml/sfYamlParser.class.php',
);
];

protected function __construct()
{
Expand Down Expand Up @@ -427,7 +427,7 @@ public static function register()
}

ini_set('unserialize_callback_func', 'spl_autoload_call');
if (false === spl_autoload_register(array(self::getInstance(), 'autoload'))) {
if (false === spl_autoload_register([self::getInstance(), 'autoload'])) {
throw new sfException(sprintf('Unable to register %s::autoload as an autoloading method.', get_class(self::getInstance())));
}

Expand All @@ -439,7 +439,7 @@ public static function register()
*/
public static function unregister()
{
spl_autoload_unregister(array(self::getInstance(), 'autoload'));
spl_autoload_unregister([self::getInstance(), 'autoload']);
self::$registered = false;
}

Expand Down
Loading
Loading