Skip to content

Commit

Permalink
🤖 Automatic code style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
solewniczak authored Nov 17, 2023
1 parent fc61ec9 commit 1f81197
Show file tree
Hide file tree
Showing 35 changed files with 87 additions and 128 deletions.
8 changes: 4 additions & 4 deletions action/aggregationeditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class action_plugin_struct_aggregationeditor extends ActionPlugin
/**
* Registers a callback function for a given event
*
* @param Doku_Event_Handler $controller DokuWiki's event controller object
* @param EventHandler $controller DokuWiki's event controller object
* @return void
*/
public function register(EventHandler $controller)
Expand All @@ -50,7 +50,7 @@ public function register(EventHandler $controller)
/**
* Add user's permissions to JSINFO
*
* @param Doku_Event $event
* @param Event $event
*/
public function addJsinfo(Event $event)
{
Expand All @@ -61,7 +61,7 @@ public function addJsinfo(Event $event)


/**
* @param Doku_Event $event
* @param Event $event
*/
public function handleAjax(Event $event)
{
Expand Down Expand Up @@ -132,7 +132,7 @@ protected function saveRow()
$helper = plugin_load('helper', 'struct');
$helper->saveLookupData($access, $data);

$config = json_decode($INPUT->str('searchconf'), true);
$config = json_decode($INPUT->str('searchconf'), true, 512, JSON_THROW_ON_ERROR);
// update row id
$this->rid = $access->getRid();
$config = $this->addTypeFilter($config);
Expand Down
6 changes: 3 additions & 3 deletions action/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class action_plugin_struct_ajax extends ActionPlugin
/**
* Registers a callback function for a given event
*
* @param Doku_Event_Handler $controller DokuWiki's event controller object
* @param EventHandler $controller DokuWiki's event controller object
* @return void
*/
public function register(EventHandler $controller)
Expand All @@ -29,7 +29,7 @@ public function register(EventHandler $controller)
/**
* Pass Ajax call to a type
*
* @param Doku_Event $event event object by reference
* @param Event $event event object by reference
*/
public function handleAjax(Event $event)
{
Expand All @@ -51,7 +51,7 @@ public function handleAjax(Event $event)
http_status(500);
}

echo json_encode($result);
echo json_encode($result, JSON_THROW_ON_ERROR);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions action/bureaucracy.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class action_plugin_struct_bureaucracy extends ActionPlugin
/**
* Registers a callback function for a given event
*
* @param Doku_Event_Handler $controller DokuWiki's event controller object
* @param EventHandler $controller DokuWiki's event controller object
* @return void
*/
public function register(EventHandler $controller)
Expand All @@ -45,7 +45,7 @@ public function register(EventHandler $controller)
/**
* Load a whole schema as fields
*
* @param Doku_Event $event event object by reference
* @param Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
* @return bool
Expand Down Expand Up @@ -82,7 +82,7 @@ public function handleSchema(Event $event, $param)
/**
* Replace lookup fields placeholder's values
*
* @param Doku_Event $event event object by reference
* @param Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
* @return bool
Expand Down Expand Up @@ -115,8 +115,8 @@ public function handleLookupFields(Event $event, $param)
// lookups can reference pages or global data, so check both pid and rid
// make sure not to double decode pid!
$originalPid = $pid;
$pid = json_decode($pid)[0] ?? $pid;
$rid = json_decode($originalPid)[1] ?? null;
$pid = json_decode($pid, null, 512, JSON_THROW_ON_ERROR)[0] ?? $pid;
$rid = json_decode($originalPid, null, 512, JSON_THROW_ON_ERROR)[1] ?? null;
if (($pid && $pids[$i] === $pid) || ($rid && $rids[$i] === (string)$rid)) {
$field->opt['struct_pids'][] = $pid;
$new_value[] = $result[$i][0]->getDisplayValue();
Expand All @@ -137,7 +137,7 @@ public function handleLookupFields(Event $event, $param)
/**
* Save the struct data
*
* @param Doku_Event $event event object by reference
* @param Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
* @return bool
Expand Down
8 changes: 4 additions & 4 deletions action/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class action_plugin_struct_cache extends ActionPlugin
/**
* Registers a callback function for a given event
*
* @param Doku_Event_Handler $controller DokuWiki's event controller object
* @param EventHandler $controller DokuWiki's event controller object
* @return void
*/
public function register(EventHandler $controller)
Expand All @@ -39,7 +39,7 @@ public static function getSchemaRefreshFile()
* For pages potentially containing schema data, refresh the cache when schema data has been
* updated
*
* @param Doku_Event $event event object by reference
* @param Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
* @return bool
Expand All @@ -62,7 +62,7 @@ public function handleCacheSchemachange(Event $event, $param)
* For pages containing an aggregation, add the last modified date of the database itself
* to the cache dependencies
*
* @param Doku_Event $event event object by reference
* @param Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
* @return bool
Expand Down Expand Up @@ -119,7 +119,7 @@ public function handleCacheAggregation(Event $event, $param)
/**
* Disable cache when dymanic parameters are present
*
* @param Doku_Event $event event object by reference
* @param Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
* @return bool
Expand Down
10 changes: 5 additions & 5 deletions action/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class action_plugin_struct_config extends ActionPlugin
/**
* Registers a callback function for a given event
*
* @param Doku_Event_Handler $controller DokuWiki's event controller object
* @param EventHandler $controller DokuWiki's event controller object
* @return void
*/
public function register(EventHandler $controller)
Expand All @@ -30,7 +30,7 @@ public function register(EventHandler $controller)
/**
* Reconfigure config for a given type
*
* @param Doku_Event $event event object by reference
* @param Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
*/
Expand All @@ -41,20 +41,20 @@ public function handleAjax(Event $event, $param)
$event->stopPropagation();
global $INPUT;

$conf = json_decode($INPUT->str('conf'), true);
$conf = json_decode($INPUT->str('conf'), true, 512, JSON_THROW_ON_ERROR);
$typeclasses = Column::allTypes();
$class = $typeclasses[$INPUT->str('type', 'Text')];
/** @var AbstractBaseType $type */
$type = new $class($conf);

header('Content-Type: text/plain'); // we need the encoded string, not decoded by jQuery
echo json_encode($type->getConfig());
echo json_encode($type->getConfig(), JSON_THROW_ON_ERROR);
}

/**
* Add config options to JSINFO
*
* @param Doku_Event $event
* @param Event $event
*/
public function addJsinfo(Event $event)
{
Expand Down
4 changes: 2 additions & 2 deletions action/diff.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class action_plugin_struct_diff extends ActionPlugin
/**
* Registers a callback function for a given event
*
* @param Doku_Event_Handler $controller DokuWiki's event controller object
* @param EventHandler $controller DokuWiki's event controller object
* @return void
*/
public function register(EventHandler $controller)
Expand All @@ -32,7 +32,7 @@ public function register(EventHandler $controller)
*
* This is done by adding pseudo syntax to the page source when it is loaded in diff context
*
* @param Doku_Event $event event object by reference
* @param Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
* @return bool
Expand Down
4 changes: 2 additions & 2 deletions action/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class action_plugin_struct_edit extends ActionPlugin
/**
* Registers a callback function for a given event
*
* @param Doku_Event_Handler $controller DokuWiki's event controller object
* @param EventHandler $controller DokuWiki's event controller object
* @return void
*/
public function register(EventHandler $controller)
Expand Down Expand Up @@ -64,7 +64,7 @@ public function addFromData(Event $event, $_param)
*
* TODO: Remove this after HTML_EDITFORM_OUTPUT is no longer released in DokuWiki stable
*
* @param Doku_Event $event event object by reference
* @param Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
* @return bool
Expand Down
8 changes: 4 additions & 4 deletions action/entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class action_plugin_struct_entry extends ActionPlugin
/**
* Registers a callback function for a given event
*
* @param Doku_Event_Handler $controller DokuWiki's event controller object
* @param EventHandler $controller DokuWiki's event controller object
* @return void
*/
public function register(EventHandler $controller)
Expand All @@ -54,7 +54,7 @@ public function register(EventHandler $controller)
/**
* Clean up and validate the input data
*
* @param Doku_Event $event event object by reference
* @param Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
* @return bool
Expand Down Expand Up @@ -92,7 +92,7 @@ public function handleValidation(Event $event, $param)
/**
* Check if the page has to be changed
*
* @param Doku_Event $event event object by reference
* @param Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
* @return bool
Expand Down Expand Up @@ -125,7 +125,7 @@ public function handlePagesaveBefore(Event $event, $param)
*
* When this is called, INPUT data has been validated already.
*
* @param Doku_Event $event event object by reference
* @param Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
* @return bool
Expand Down
6 changes: 3 additions & 3 deletions action/inline.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class action_plugin_struct_inline extends ActionPlugin
/**
* Registers a callback function for a given event
*
* @param Doku_Event_Handler $controller DokuWiki's event controller object
* @param EventHandler $controller DokuWiki's event controller object
* @return void
*/
public function register(EventHandler $controller)
Expand All @@ -48,7 +48,7 @@ public function register(EventHandler $controller)
}

/**
* @param Doku_Event $event
* @param Event $event
* @param $param
*/
public function handleAjax(Event $event, $param)
Expand Down Expand Up @@ -182,7 +182,7 @@ protected function inlineSave()
$value = $this->schemadata->getDataColumn($this->column);
$R = new Doku_Renderer_xhtml();
$value->render($R, 'xhtml'); // FIXME use configured default renderer
$data = json_encode(['value' => $R->doc, 'rev' => $this->schemadata->getTimestamp()]);
$data = json_encode(['value' => $R->doc, 'rev' => $this->schemadata->getTimestamp()], JSON_THROW_ON_ERROR);
echo $data;
}

Expand Down
10 changes: 3 additions & 7 deletions action/migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function register(EventHandler $controller)
/**
* Call our custom migrations when defined
*
* @param Doku_Event $event
* @param Event $event
* @param $param
*/
public function handleMigrations(Event $event, $param)
Expand Down Expand Up @@ -251,9 +251,7 @@ protected function migration17($sqlite)
$cols = $sqlite->queryAll($s);

if ($cols) {
$colnames = array_map(function ($c) {
return 'col' . $c['COL'];
}, $cols);
$colnames = array_map(static fn($c) => 'col' . $c['COL'], $cols);

// data_ tables
$s = 'SELECT pid, rid, rev, ' . implode(', ', $colnames) . " FROM data_$name";
Expand Down Expand Up @@ -389,9 +387,7 @@ protected function getFixedValues($row)
}

if (!empty($fixes)) {
$fixes = array_map(function ($set, $key) {
return "$key = '$set'";
}, $fixes, array_keys($fixes));
$fixes = array_map(static fn($set, $key) => "$key = '$set'", $fixes, array_keys($fixes));
}

return [$pid, $rid, $rev, $colref, $rowno, $fixes];
Expand Down
4 changes: 2 additions & 2 deletions action/move.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class action_plugin_struct_move extends ActionPlugin
/**
* Registers a callback function for a given event
*
* @param Doku_Event_Handler $controller DokuWiki's event controller object
* @param EventHandler $controller DokuWiki's event controller object
* @return void
*/
public function register(EventHandler $controller)
Expand All @@ -38,7 +38,7 @@ public function register(EventHandler $controller)
/**
* Renames all occurrences of a page ID in the database
*
* @param Doku_Event $event event object by reference
* @param Event $event event object by reference
* @param bool $ispage is this a page move operation?
* @return bool
*/
Expand Down
8 changes: 4 additions & 4 deletions action/output.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class action_plugin_struct_output extends ActionPlugin
/**
* Registers a callback function for a given event
*
* @param Doku_Event_Handler $controller DokuWiki's event controller object
* @param EventHandler $controller DokuWiki's event controller object
* @return void
*/
public function register(EventHandler $controller)
Expand All @@ -42,7 +42,7 @@ public function register(EventHandler $controller)
* Appends the instruction to render our syntax output component to each page
* after the first found headline or the very begining if no headline was found
*
* @param Doku_Event $event
* @param Event $event
* @param $param
*/
public function handleOutput(Event $event, $param)
Expand Down Expand Up @@ -94,7 +94,7 @@ public function handleOutput(Event $event, $param)
* If the page has a schema assigned, add its struct data
* to dw2pdf's template replacements
*
* @param Doku_Event $event
* @param Event $event
* @param $param
*/
public function replaceDw2pdf(Event $event, $param)
Expand Down Expand Up @@ -130,7 +130,7 @@ public function replaceDw2pdf(Event $event, $param)
* Remove struct placeholders still present after replacement.
* Requested data was not found.
*
* @param Doku_Event $event
* @param Event $event
* @param $param
*/
public function cleanupDw2pdf(Event $event, $param)
Expand Down
6 changes: 3 additions & 3 deletions action/revert.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class action_plugin_struct_revert extends ActionPlugin
/**
* Registers a callback function for a given event
*
* @param Doku_Event_Handler $controller DokuWiki's event controller object
* @param EventHandler $controller DokuWiki's event controller object
* @return void
*/
public function register(EventHandler $controller)
Expand All @@ -37,7 +37,7 @@ public function register(EventHandler $controller)
/**
* Check if the page has to be changed
*
* @param Doku_Event $event event object by reference
* @param Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
* @return bool
Expand All @@ -62,7 +62,7 @@ public function handlePagesaveBefore(Event $event, $param)
/**
* Save the data, by loading it from the old revision and storing it as a new revision
*
* @param Doku_Event $event event object by reference
* @param Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
* @return bool
Expand Down
Loading

0 comments on commit 1f81197

Please sign in to comment.