PHP Code Beautifier fixes

This commit is contained in:
Jens Schuppe 2024-03-25 14:58:51 +01:00
parent fad228315d
commit 69843bc981
10 changed files with 389 additions and 292 deletions

View file

@ -9,7 +9,7 @@ use CRM_Twingle_ExtensionUtil as E;
class CRM_Twingle_Upgrader_Base {
/**
* @var varies, subclass of this
* @var variessubclassofthis
*/
static $instance;
@ -19,22 +19,22 @@ class CRM_Twingle_Upgrader_Base {
protected $ctx;
/**
* @var string, eg 'com.example.myextension'
* @var stringegcomexamplemyextension
*/
protected $extensionName;
/**
* @var string, full path to the extension's source tree
* @var stringfullpathtotheextensionssourcetree
*/
protected $extensionDir;
/**
* @var array(revisionNumber) sorted numerically
* @var arrayrevisionNumbersortednumerically
*/
private $revisions;
/**
* @var boolean
* @var bool
* Flag to clean up extension revision data in civicrm_setting
*/
private $revisionStorageIsDeprecated = FALSE;
@ -42,7 +42,7 @@ class CRM_Twingle_Upgrader_Base {
/**
* Obtain a reference to the active upgrade handler.
*/
static public function instance() {
public static function instance() {
if (!self::$instance) {
// FIXME auto-generate
self::$instance = new CRM_Twingle_Upgrader(
@ -63,13 +63,13 @@ class CRM_Twingle_Upgrader_Base {
* CRM_Twingle_Upgrader_Base::_queueAdapter($ctx, 'methodName', 'arg1', 'arg2');
* @endcode
*/
static public function _queueAdapter() {
public static function _queueAdapter() {
$instance = self::instance();
$args = func_get_args();
$instance->ctx = array_shift($args);
$instance->queue = $instance->ctx->queue;
$method = array_shift($args);
return call_user_func_array(array($instance, $method), $args);
return call_user_func_array([$instance, $method], $args);
}
public function __construct($extensionName, $extensionDir) {
@ -144,7 +144,7 @@ class CRM_Twingle_Upgrader_Base {
* provides syntatic sugar for queueing several tasks that
* run different queries
*/
public function executeSql($query, $params = array()) {
public function executeSql($query, $params = []) {
// FIXME verify that we raise an exception on error
CRM_Core_DAO::executeQuery($query, $params);
return TRUE;
@ -163,11 +163,11 @@ class CRM_Twingle_Upgrader_Base {
$args = func_get_args();
$title = array_shift($args);
$task = new CRM_Queue_Task(
array(get_class($this), '_queueAdapter'),
[get_class($this), '_queueAdapter'],
$args,
$title
);
return $this->queue->createItem($task, array('weight' => -1));
return $this->queue->createItem($task, ['weight' => -1]);
}
// ******** Revision-tracking helpers ********
@ -200,23 +200,23 @@ class CRM_Twingle_Upgrader_Base {
$currentRevision = $this->getCurrentRevision();
foreach ($this->getRevisions() as $revision) {
if ($revision > $currentRevision) {
$title = ts('Upgrade %1 to revision %2', array(
$title = ts('Upgrade %1 to revision %2', [
1 => $this->extensionName,
2 => $revision,
));
]);
// note: don't use addTask() because it sets weight=-1
$task = new CRM_Queue_Task(
array(get_class($this), '_queueAdapter'),
array('upgrade_' . $revision),
[get_class($this), '_queueAdapter'],
['upgrade_' . $revision],
$title
);
$this->queue->createItem($task);
$task = new CRM_Queue_Task(
array(get_class($this), '_queueAdapter'),
array('setCurrentRevision', $revision),
[get_class($this), '_queueAdapter'],
['setCurrentRevision', $revision],
$title
);
$this->queue->createItem($task);
@ -231,7 +231,7 @@ class CRM_Twingle_Upgrader_Base {
*/
public function getRevisions() {
if (!is_array($this->revisions)) {
$this->revisions = array();
$this->revisions = [];
$clazz = new ReflectionClass(get_class($this));
$methods = $clazz->getMethods();
@ -302,7 +302,7 @@ class CRM_Twingle_Upgrader_Base {
$this->executeCustomDataFileByAbsPath($file);
}
}
if (is_callable(array($this, 'install'))) {
if (is_callable([$this, 'install'])) {
$this->install();
}
}
@ -315,7 +315,7 @@ class CRM_Twingle_Upgrader_Base {
if (!empty($revisions)) {
$this->setCurrentRevision(max($revisions));
}
if (is_callable(array($this, 'postInstall'))) {
if (is_callable([$this, 'postInstall'])) {
$this->postInstall();
}
}
@ -330,7 +330,7 @@ class CRM_Twingle_Upgrader_Base {
$this->executeSqlTemplate($file);
}
}
if (is_callable(array($this, 'uninstall'))) {
if (is_callable([$this, 'uninstall'])) {
$this->uninstall();
}
$files = glob($this->extensionDir . '/sql/*_uninstall.sql');
@ -346,7 +346,7 @@ class CRM_Twingle_Upgrader_Base {
*/
public function onEnable() {
// stub for possible future use
if (is_callable(array($this, 'enable'))) {
if (is_callable([$this, 'enable'])) {
$this->enable();
}
}
@ -356,7 +356,7 @@ class CRM_Twingle_Upgrader_Base {
*/
public function onDisable() {
// stub for possible future use
if (is_callable(array($this, 'disable'))) {
if (is_callable([$this, 'disable'])) {
$this->disable();
}
}
@ -364,7 +364,7 @@ class CRM_Twingle_Upgrader_Base {
public function onUpgrade($op, CRM_Queue_Queue $queue = NULL) {
switch ($op) {
case 'check':
return array($this->hasPendingRevisions());
return [$this->hasPendingRevisions()];
case 'enqueue':
return $this->enqueuePendingRevisions($queue);