Merge pull request #673 from cosmocode/bot/autofix

🤖 Automatic code style fixes
This commit is contained in:
Anna Dabrowska
2023-12-11 17:13:11 +01:00
committed by GitHub
35 changed files with 87 additions and 128 deletions

View File

@ -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)
@ -50,7 +50,7 @@ class action_plugin_struct_aggregationeditor extends ActionPlugin
/**
* Add user's permissions to JSINFO
*
* @param Doku_Event $event
* @param Event $event
*/
public function addJsinfo(Event $event)
{
@ -61,7 +61,7 @@ class action_plugin_struct_aggregationeditor extends ActionPlugin
/**
* @param Doku_Event $event
* @param Event $event
*/
public function handleAjax(Event $event)
{
@ -132,7 +132,7 @@ class action_plugin_struct_aggregationeditor extends ActionPlugin
$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);

View File

@ -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)
@ -29,7 +29,7 @@ class action_plugin_struct_ajax extends ActionPlugin
/**
* 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)
{
@ -51,7 +51,7 @@ class action_plugin_struct_ajax extends ActionPlugin
http_status(500);
}
echo json_encode($result);
echo json_encode($result, JSON_THROW_ON_ERROR);
}
/**

View File

@ -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)
@ -45,7 +45,7 @@ class action_plugin_struct_bureaucracy extends ActionPlugin
/**
* 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
@ -82,7 +82,7 @@ class action_plugin_struct_bureaucracy extends ActionPlugin
/**
* 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
@ -115,8 +115,8 @@ class action_plugin_struct_bureaucracy extends ActionPlugin
// 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();
@ -137,7 +137,7 @@ class action_plugin_struct_bureaucracy extends ActionPlugin
/**
* 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

View File

@ -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)
@ -39,7 +39,7 @@ class action_plugin_struct_cache extends ActionPlugin
* 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
@ -62,7 +62,7 @@ class action_plugin_struct_cache extends ActionPlugin
* 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
@ -119,7 +119,7 @@ class action_plugin_struct_cache extends ActionPlugin
/**
* 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

View File

@ -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)
@ -30,7 +30,7 @@ class action_plugin_struct_config extends ActionPlugin
/**
* 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]
*/
@ -41,20 +41,20 @@ class action_plugin_struct_config extends ActionPlugin
$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)
{

View File

@ -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)
@ -32,7 +32,7 @@ class action_plugin_struct_diff extends ActionPlugin
*
* 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

View File

@ -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)
@ -64,7 +64,7 @@ class action_plugin_struct_edit extends ActionPlugin
*
* 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

View File

@ -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)
@ -54,7 +54,7 @@ class action_plugin_struct_entry extends ActionPlugin
/**
* 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
@ -92,7 +92,7 @@ class action_plugin_struct_entry extends ActionPlugin
/**
* 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
@ -125,7 +125,7 @@ class action_plugin_struct_entry extends ActionPlugin
*
* 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

View File

@ -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)
@ -48,7 +48,7 @@ class action_plugin_struct_inline extends ActionPlugin
}
/**
* @param Doku_Event $event
* @param Event $event
* @param $param
*/
public function handleAjax(Event $event, $param)
@ -182,7 +182,7 @@ class action_plugin_struct_inline extends ActionPlugin
$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;
}

View File

@ -29,7 +29,7 @@ class action_plugin_struct_migration extends ActionPlugin
/**
* Call our custom migrations when defined
*
* @param Doku_Event $event
* @param Event $event
* @param $param
*/
public function handleMigrations(Event $event, $param)
@ -251,9 +251,7 @@ class action_plugin_struct_migration extends ActionPlugin
$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";
@ -389,9 +387,7 @@ class action_plugin_struct_migration extends ActionPlugin
}
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];

View File

@ -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)
@ -38,7 +38,7 @@ class action_plugin_struct_move extends ActionPlugin
/**
* 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
*/

View File

@ -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)
@ -42,7 +42,7 @@ class action_plugin_struct_output extends ActionPlugin
* 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)
@ -94,7 +94,7 @@ class action_plugin_struct_output extends ActionPlugin
* 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)
@ -130,7 +130,7 @@ class action_plugin_struct_output extends ActionPlugin
* 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)

View File

@ -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)
@ -37,7 +37,7 @@ class action_plugin_struct_revert extends ActionPlugin
/**
* 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
@ -62,7 +62,7 @@ class action_plugin_struct_revert extends ActionPlugin
/**
* 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

View File

@ -21,7 +21,7 @@ class action_plugin_struct_search 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)
@ -33,7 +33,7 @@ class action_plugin_struct_search extends ActionPlugin
/**
* Adds the structured data to the page body to be indexed
*
* @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
@ -54,7 +54,7 @@ class action_plugin_struct_search extends ActionPlugin
/**
* Adds the structured data to the page body to be snippeted
*
* @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

View File

@ -23,7 +23,7 @@ class action_plugin_struct_title 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)
@ -34,7 +34,7 @@ class action_plugin_struct_title extends ActionPlugin
/**
* Store the page's title
*
* @param Doku_Event $event
* @param Event $event
* @param $param
*/
public function handleMeta(Event $event, $param)

View File

@ -205,6 +205,6 @@ class helper_plugin_struct extends Plugin
public static function decodeJson($value)
{
if (!empty($value) && $value[0] !== '[') throw new StructException('Lookup expects JSON');
return json_decode($value);
return json_decode($value, null, 512, JSON_THROW_ON_ERROR);
}
}

View File

@ -80,7 +80,7 @@ class helper_plugin_struct_db extends Plugin
*/
public function STRUCT_JSON(...$args) // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
{
return json_encode($args);
return json_encode($args, JSON_THROW_ON_ERROR);
}
/**

View File

@ -141,9 +141,7 @@ class helper_plugin_struct_field extends helper_plugin_bureaucracy_field
}
if (!empty($value) && $this->column->getType() instanceof User) {
$value = array_map(function ($user) {
return userlink($user, true);
}, $value);
$value = array_map(static fn($user) => userlink($user, true), $value);
}
//check if matched string containts a pair of brackets
@ -167,7 +165,7 @@ class helper_plugin_struct_field extends helper_plugin_bureaucracy_field
$this->column->getType() instanceof Page
&& $this->column->getType()->getConfig()['usetitles']
) {
$preparedValue = json_encode([$preparedValue, null]);
$preparedValue = json_encode([$preparedValue, null], JSON_THROW_ON_ERROR);
}
$value = new Value($this->column, $preparedValue);

View File

@ -68,9 +68,7 @@ class helper_plugin_struct_imexport extends Plugin
$sql = 'SELECT pattern FROM schema_assignments_patterns WHERE tbl = ?';
$patterns = $this->sqlite->queryAll($sql, $schemaName);
return array_map(function ($elem) {
return $elem['pattern'];
}, $patterns);
return array_map(static fn($elem) => $elem['pattern'], $patterns);
}
/**

View File

@ -634,9 +634,7 @@ abstract class AccessTable
*/
protected function clearMulti()
{
$colrefs = array_unique(array_map(function ($val) {
return $val[0];
}, $this->multiValues));
$colrefs = array_unique(array_map(static fn($val) => $val[0], $this->multiValues));
return $this->sqlite->query(
"DELETE FROM $this->mtable WHERE pid = ? AND rid = $this->rid AND rev = 0 AND colref IN (" .
implode(',', $colrefs) . ")",

View File

@ -75,9 +75,7 @@ class AccessTableGlobal extends AccessTable
protected function validateTypeData($data)
{
// we do not store completely empty rows
$isempty = array_reduce($data, function ($isempty, $cell) {
return $isempty && ($cell === '' || $cell === [] || $cell === null);
}, true);
$isempty = array_reduce($data, static fn($isempty, $cell) => $isempty && ($cell === '' || $cell === [] || $cell === null), true);
return !$isempty;
}

View File

@ -37,7 +37,7 @@ class AggregationEditorTable extends AggregationTable
$config = $this->searchConfig->getConf();
if (isset($config['filter'])) unset($config['filter']);
$config = hsc(json_encode($config));
$config = hsc(json_encode($config, JSON_THROW_ON_ERROR));
// wrapping div
$classes = $this->getScopeClasses();

View File

@ -72,7 +72,7 @@ class AggregationFilter extends Aggregation
$colName = $value->getColumn()->getFullQualifiedLabel();
$colValues[$colName]['column'] = $value->getColumn();
$colValues[$colName]['label'] = $value->getColumn()->getTranslatedLabel();
$colValues[$colName]['values'] = $colValues[$colName]['values'] ?? [];
$colValues[$colName]['values'] ??= [];
if (empty($value->getDisplayValue())) continue;

View File

@ -70,12 +70,8 @@ class CSVPageImporter extends CSVImporter
$this->header
);
$keysAt = array_map(function ($key) {
return "@@$key@@";
}, $keys);
$keysHash = array_map(function ($key) {
return "##$key##";
}, $keys);
$keysAt = array_map(static fn($key) => "@@$key@@", $keys);
$keysHash = array_map(static fn($key) => "##$key##", $keys);
$flatValues = array_map(
function ($value) {
if (is_array($value)) {

View File

@ -131,16 +131,12 @@ class DateFormatConverter
$datekeys = array_keys(self::$date);
// create negative lookbehind regex to match all known date chars that are not a strtime pattern now
$from = array_map(
function ($in) {
return '/(?<!%)' . $in . '/';
},
static fn($in) => '/(?<!%)' . $in . '/',
$datekeys
);
// those need to be escaped
$to = array_map(
function ($in) {
return '\\' . $in;
},
static fn($in) => '\\' . $in,
$datekeys
);
// escape date chars
@ -172,9 +168,7 @@ class DateFormatConverter
// create negative lookbehind regex to match all unescaped known chars
$from = array_keys(self::$date);
$from = array_map(
function ($in) {
return '/(?<!\\\\)' . $in . '/';
},
static fn($in) => '/(?<!\\\\)' . $in . '/',
$from
);
$to = array_values(self::$date);
@ -191,9 +185,7 @@ class DateFormatConverter
{
$datekeys = array_keys(self::$date);
$from = array_map(
function ($in) {
return '/\\\\' . $in . '/';
},
static fn($in) => '/\\\\' . $in . '/',
$datekeys
);
$strftime = preg_replace($from, $datekeys, $strftime);

View File

@ -50,6 +50,7 @@ class InlineConfigParser extends ConfigParser
switch ($p) {
// Empty (due to extra spaces)
case '':
default:
// Move straight to next parameter
continue 2;
break;
@ -73,10 +74,6 @@ class InlineConfigParser extends ConfigParser
$lines[] = 'filteror: ' . trim($parameters[$i + 1]);
$i++;
break;
default:
// Move straight to next parameter
continue 2;
break;
}
}
}

View File

@ -114,9 +114,7 @@ class NestedValue
public function addResultRow($row)
{
// only add unique rows
$ident = md5(array_reduce($row, function ($carry, $value) {
return $carry . $value;
}, ''));
$ident = md5(array_reduce($row, static fn($carry, $value) => $carry . $value, ''));
$this->resultRows[$ident] = $row;
}

View File

@ -92,7 +92,7 @@ class Schema
$this->id = $result['id'];
$this->user = $result['user'];
$this->ts = $result['ts'];
$config = json_decode($result['config'], true);
$config = json_decode($result['config'], true, 512, JSON_THROW_ON_ERROR);
}
$this->config = array_merge($baseconfig, $config);
$this->initTransConfig(['label']);
@ -120,7 +120,7 @@ class Schema
$class = 'dokuwiki\\plugin\\struct\\types\\Text';
}
$config = json_decode($row['config'], true);
$config = json_decode($row['config'], true, 512, JSON_THROW_ON_ERROR);
/** @var AbstractBaseType $type */
$type = new $class($config, $row['label'], $row['ismulti'], $row['tid']);
$column = new Column(
@ -325,9 +325,7 @@ class Schema
if (!$withDisabled) {
return array_filter(
$this->columns,
function (Column $col) {
return $col->isEnabled();
}
static fn(Column $col) => $col->isEnabled()
);
}

View File

@ -229,10 +229,7 @@ class SchemaBuilder
continue;
}
$valueString[] = "(?, ?, ?, ?, ?, ?)";
$arguments = array_merge(
$arguments,
[$colref, $values['pid'], $values['rev'], $values['published'], 1, $values['value']]
);
$arguments = [...$arguments, $colref, $values['pid'], $values['rev'], $values['published'], 1, $values['value']];
}
if ($valueString === []) {
return;

View File

@ -293,9 +293,7 @@ class Search
*/
protected function filterWrapAsterisks($value)
{
$map = function ($input) {
return "*$input*";
};
$map = static fn($input) => "*$input*";
if (is_array($value)) {
$value = array_map($map, $value);
@ -313,9 +311,7 @@ class Search
*/
protected function filterChangeToLike($value)
{
$map = function ($input) {
return str_replace('*', '%', $input);
};
$map = static fn($input) => str_replace('*', '%', $input);
if (is_array($value)) {
$value = array_map($map, $value);
@ -464,9 +460,7 @@ class Search
$this->result_pids = [];
$result = [];
$cursor = -1;
$pageidAndRevOnly = array_reduce($this->columns, function ($pageidAndRevOnly, Column $col) {
return $pageidAndRevOnly && ($col->getTid() == 0);
}, true);
$pageidAndRevOnly = array_reduce($this->columns, static fn($pageidAndRevOnly, Column $col) => $pageidAndRevOnly && ($col->getTid() == 0), true);
while ($row = $res->fetch(\PDO::FETCH_ASSOC)) {
$cursor++;
if ($cursor < $this->range_begin) continue;

View File

@ -47,7 +47,7 @@ class ValueValidator
if (is_array($rawvalue)) {
$rawvalue = array_filter($rawvalue, [$this, 'filter']);
$rawvalue = array_values($rawvalue); // reset the array keys
if (empty($rawvalue)) {
if ($rawvalue === []) {
$rawvalue = [''];
}
}

View File

@ -8,6 +8,7 @@
*/
// must be run within Dokuwiki
use dokuwiki\Remote\RemoteException;
use dokuwiki\Extension\RemotePlugin;
use dokuwiki\Remote\AccessDeniedException;
use dokuwiki\plugin\struct\meta\Value;
@ -37,7 +38,7 @@ class remote_plugin_struct extends RemotePlugin
* @param string $schema The schema to use empty for all
* @param int $time A timestamp if you want historic data (0 for now)
* @return array ('schema' => ( 'fieldlabel' => 'value', ...))
* @throws RemoteAccessDeniedException
* @throws AccessDeniedException
* @throws RemoteException
*/
public function getData($page, $schema, $time)
@ -53,7 +54,7 @@ class remote_plugin_struct extends RemotePlugin
try {
return $this->hlp->getData($page, $schema, $time);
} catch (StructException $e) {
throw new \dokuwiki\Remote\RemoteException($e->getMessage(), 0, $e);
throw new RemoteException($e->getMessage(), 0, $e);
}
}
@ -70,7 +71,7 @@ class remote_plugin_struct extends RemotePlugin
* @param string $summary
* @param bool $minor
* @return bool returns always true
* @throws RemoteAccessDeniedException
* @throws AccessDeniedException
* @throws RemoteException
*/
public function saveData($page, $data, $summary, $minor = false)
@ -85,7 +86,7 @@ class remote_plugin_struct extends RemotePlugin
$this->hlp->saveData($page, $data, $summary, $minor);
return true;
} catch (StructException $e) {
throw new \dokuwiki\Remote\RemoteException($e->getMessage(), 0, $e);
throw new RemoteException($e->getMessage(), 0, $e);
}
}
@ -96,7 +97,7 @@ class remote_plugin_struct extends RemotePlugin
*
* @param string $schema the schema to query, empty for all
* @return array
* @throws RemoteAccessDeniedException
* @throws AccessDeniedException
* @throws RemoteException
*/
public function getSchema($schema = null)
@ -121,7 +122,7 @@ class remote_plugin_struct extends RemotePlugin
}
return $result;
} catch (StructException $e) {
throw new \dokuwiki\Remote\RemoteException($e->getMessage(), 0, $e);
throw new RemoteException($e->getMessage(), 0, $e);
}
}
@ -140,9 +141,7 @@ class remote_plugin_struct extends RemotePlugin
{
$schemaLine = 'schema: ' . implode(', ', $schemas);
$columnLine = 'cols: ' . implode(', ', $cols);
$filterLines = array_map(function ($filter) {
return 'filter' . $filter['logic'] . ': ' . $filter['condition'];
}, $filter);
$filterLines = array_map(static fn($filter) => 'filter' . $filter['logic'] . ': ' . $filter['condition'], $filter);
$sortLine = 'sort: ' . $sort;
// schemas, cols, REV?, filter, order
@ -162,7 +161,7 @@ class remote_plugin_struct extends RemotePlugin
}
return $data;
} catch (StructException $e) {
throw new \dokuwiki\Remote\RemoteException($e->getMessage(), 0, $e);
throw new RemoteException($e->getMessage(), 0, $e);
}
}
}

View File

@ -119,7 +119,7 @@ abstract class AbstractBaseType
public function getAsEntry()
{
return [
'config' => json_encode($this->config),
'config' => json_encode($this->config, JSON_THROW_ON_ERROR),
'label' => $this->label,
'ismulti' => $this->ismulti,
'class' => $this->getClass()

View File

@ -81,7 +81,7 @@ class Decimal extends AbstractMultiBaseType
$this->config['thousands']
);
}
if ($this->config['trimzeros'] && (strpos($value, $this->config['decpoint']) !== false)) {
if ($this->config['trimzeros'] && (strpos($value, (string) $this->config['decpoint']) !== false)) {
$value = rtrim($value, '0');
$value = rtrim($value, $this->config['decpoint']);
}

View File

@ -131,7 +131,7 @@ class Lookup extends Dropdown
$options = ['' => ''];
for ($i = 0; $i < $len; $i++) {
$val = json_encode([$pids[$i], (int)$rids[$i]]);
$val = json_encode([$pids[$i], (int)$rids[$i]], JSON_THROW_ON_ERROR);
$options[$val] = $result[$i][0]->getDisplayValue();
}
return $options;