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

Update php cs fixer #338

Merged
merged 5 commits into from
Mar 18, 2024
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
24 changes: 18 additions & 6 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
name: "Code Linting"
on:
push:
paths:
- .php-cs-fixer.dist.php
- autoload.php
- lib/**
- data/**
- tests/**
branches:
- master
pull_request:
paths:
- .php-cs-fixer.dist.php
- autoload.php
- lib/**
- data/**
- tests/**

jobs:
php-cs-fixer:
Expand All @@ -15,17 +27,17 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
tools: php-cs-fixer:3.45, cs2pr
php-version: 7.4
tools: php-cs-fixer:3.51, cs2pr

- uses: actions/cache@v4
with:
path: '.php-cs-fixer.cache'
key: ${{ github.repository }}-8.2-phpcsfixer-${{ github.ref_name }}
key: ${{ github.repository }}-7.4-phpcsfixer-${{ github.ref_name }}
restore-keys: |
${{ github.repository }}-8.2-phpcsfixer-master
${{ github.repository }}-8.2-phpcsfixer-
${{ github.repository }}-7.4-phpcsfixer-master
${{ github.repository }}-7.4-phpcsfixer-

- name: Run PHP-CS-Fixer
# Using cs2pr settings, see: https://github.com/shivammathur/setup-php#tools-with-checkstyle-support
run: 'php-cs-fixer fix --dry-run --format checkstyle | cs2pr'
run: 'php-cs-fixer fix --dry-run --format=checkstyle | cs2pr'
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.cache/

/test/functional/fixtures/cache
/test/functional/fixtures/log
/lib/plugins/sfDoctrinePlugin/test/functional/fixtures/lib/*/doctrine/base/
Expand All @@ -6,4 +8,3 @@
lib/plugins/sfDoctrinePlugin/test/functional/fixtures/log/
/vendor
/composer.lock
.php-cs-fixer.cache
17 changes: 8 additions & 9 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,14 +15,13 @@
;

$config = new PhpCsFixer\Config();
$config->setRules(array(
'@PhpCsFixer' => true,
'@Symfony' => true,
'array_syntax' => array(
'syntax' => 'long',
),
))
->setCacheFile('.php-cs-fixer.cache')
$config
->setRules([
'@PhpCsFixer' => true,
'@Symfony' => true,
'array_syntax' => ['syntax' => 'short'],
])
->setCacheFile('.cache/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
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 @@ -20,7 +20,7 @@
*/
abstract class sfAction extends sfComponent
{
protected $security = array();
protected $security = [];

/**
* Initializes this action.
Expand Down Expand Up @@ -122,7 +122,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 @@ -184,7 +184,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 @@ -211,7 +211,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 @@ -233,7 +233,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 @@ -430,7 +430,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 @@ -468,7 +468,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 @@ -19,7 +19,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 @@ -41,13 +41,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 @@ -62,7 +62,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 @@ -128,7 +128,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 @@ -247,7 +247,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 @@ -339,7 +339,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 @@ -17,7 +17,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 @@ -66,7 +66,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 @@ -106,8 +106,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
4 changes: 2 additions & 2 deletions lib/addon/sfPager.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,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 @@ -97,7 +97,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
8 changes: 4 additions & 4 deletions lib/autoload/sfAutoload.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,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 @@ -51,7 +51,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 @@ -61,7 +61,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 @@ -65,7 +65,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 @@ -102,7 +102,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 @@ -112,7 +112,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 @@ -28,7 +28,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 @@ -389,7 +389,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 @@ -422,7 +422,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 @@ -434,7 +434,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