Skip to content

Commit ba662a6

Browse files
committed
some automatic rector fixes
1 parent 8b7e143 commit ba662a6

File tree

8 files changed

+15
-15
lines changed

8 files changed

+15
-15
lines changed

action/migration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ protected function getFixedValues($row)
413413
}
414414
}
415415

416-
if (!empty($fixes)) {
416+
if ($fixes !== []) {
417417
$fixes = array_map(static fn($set, $key) => "$key = '$set'", $fixes, array_keys($fixes));
418418
}
419419

helper/config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class helper_plugin_struct_config extends Plugin
2020
*/
2121
public function parseSort($val)
2222
{
23-
if (substr($val, 0, 1) == '^') {
23+
if (str_starts_with($val, '^')) {
2424
return [substr($val, 1), false];
2525
}
2626
return [$val, true];

meta/Assignments.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,12 +291,12 @@ protected function matchPagePattern($pattern, $page, $pns = null)
291291
}
292292

293293
$ans = ':' . cleanID($pattern) . ':';
294-
if (substr($pattern, -2) == '**') {
294+
if (str_ends_with($pattern, '**')) {
295295
// upper namespaces match
296-
if (strpos($pns, $ans) === 0) {
296+
if (str_starts_with($pns, $ans)) {
297297
return true;
298298
}
299-
} elseif (substr($pattern, -1) == '*') {
299+
} elseif (str_ends_with($pattern, '*')) {
300300
// namespaces match exact
301301
if ($ans == $pns) {
302302
return true;

meta/Column.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ public static function allTypes($reload = false)
193193
$files = glob(DOKU_PLUGIN . 'struct/types/*.php');
194194
foreach ($files as $file) {
195195
$file = basename($file, '.php');
196-
if (substr($file, 0, 8) == 'Abstract') continue;
197-
if (substr($file, 0, 5) == 'Trait') continue;
198-
if (substr($file, 0, 4) == 'Auto') continue;
196+
if (str_starts_with($file, 'Abstract')) continue;
197+
if (str_starts_with($file, 'Trait')) continue;
198+
if (str_starts_with($file, 'Auto')) continue;
199199
$map[$file] = 'dokuwiki\\plugin\\struct\\types\\' . $file;
200200
}
201201

meta/SearchConfig.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ protected function determineCacheFlag($filters)
9595
foreach ($filters as $filter) {
9696
if (is_array($filter)) $filter = $filter[2]; // this is the format we get fro the config parser
9797

98-
if (strpos($filter, '$USER$') !== false) {
98+
if (str_contains($filter, '$USER$')) {
9999
$flags |= self::$CACHE_USER;
100-
} elseif (strpos($filter, '$TODAY$') !== false) {
100+
} elseif (str_contains($filter, '$TODAY$')) {
101101
$flags |= self::$CACHE_DATE;
102102
}
103103
}
@@ -145,7 +145,7 @@ protected function applyFilterVars($filter)
145145
$resolver = new PageResolver('');
146146

147147
$start = $resolver->resolveId($ns . ':');
148-
if($start === $INFO['id']) {
148+
if ($start === $INFO['id']) {
149149
// This is a start page, we return the namespace
150150
$val = $ns;
151151
} else {

renderer/csv.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public function emaillink($address, $name = null)
168168

169169
public function plugin($name, $args, $state = '', $match = '')
170170
{
171-
if (substr($name, 0, 7) == 'struct_') {
171+
if (str_starts_with($name, 'struct_')) {
172172
parent::plugin($name, $args, $state, $match);
173173
} else {
174174
$this->cdata($match);

types/Decimal.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function renderValue($value, \Doku_Renderer $R, $mode)
8181
$this->config['thousands']
8282
);
8383
}
84-
if ($this->config['trimzeros'] && (strpos($value, (string) $this->config['decpoint']) !== false)) {
84+
if ($this->config['trimzeros'] && (str_contains($value, (string) $this->config['decpoint']))) {
8585
$value = rtrim($value, '0');
8686
$value = rtrim($value, $this->config['decpoint']);
8787
}

types/Media.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function validate($rawvalue)
3131

3232
[, $mime, ] = mimetype($rawvalue, false);
3333
foreach ($allows as $allow) {
34-
if (strpos($mime, $allow) === 0) return $rawvalue;
34+
if (str_starts_with($mime, $allow)) return $rawvalue;
3535
}
3636

3737
throw new ValidationException('Media mime type', $mime, $this->config['mime']);
@@ -77,7 +77,7 @@ public function renderValue($value, \Doku_Renderer $R, $mode)
7777
// add gallery meta data in XHTML
7878
if ($mode == 'xhtml') {
7979
[, $mime, ] = mimetype($value, false);
80-
if (substr($mime, 0, 6) == 'image/') {
80+
if (str_starts_with($mime, 'image/')) {
8181
$hash = empty($R->info['struct_table_hash']) ? '' : "[gal-" . $R->info['struct_table_hash'] . "]";
8282
$html = str_replace('href', "rel=\"lightbox$hash\" href", $html);
8383
}

0 commit comments

Comments
 (0)