Skip to content

Commit 48c2ce2

Browse files
RexStan und PHP-CS-FIXER (#174)
1 parent d1cc4f9 commit 48c2ce2

35 files changed

+236
-155
lines changed

docs/example/geolocation_div.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
$classes = array_merge($classes, $class);
4545
}
4646
}
47-
$classes = array_filter($classes, 'trim');
47+
$classes = array_filter($classes, trim(...));
4848
if (0 < \count($classes)) {
4949
$attributes['class'] = array_unique($classes);
5050
}

fragments/geolocation/geocoder.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* @var ?GeoCoder $geoCoder
3030
*/
3131
$geoCoder = $this->getVar('geo_coder', null);
32-
if( !is_a($geoCoder,GeoCoder::class) ) {
32+
if (!is_a($geoCoder, GeoCoder::class)) {
3333
return;
3434
}
3535
$addressFields = $this->getVar('address_fields', []);
@@ -43,11 +43,11 @@
4343
} else {
4444
$i18nId = 1 === \count($addressFields) ? 'geolocation_geocoder_adress_btn' : 'geolocation_geocoder_adresses_btn';
4545
$button = [
46-
'label' => sprintf('<span class="wide">%s</span><i class="rex-icon rex-icon-search"></i>',rex_i18n::msg($i18nId,'')),
46+
'label' => \sprintf('<span class="wide">%s</span><i class="rex-icon rex-icon-search"></i>', rex_i18n::msg($i18nId, '')),
4747
'attributes' => [
4848
'class' => ['btn btn-primary'],
4949
'type' => 'button',
50-
'title' => rex_i18n::msg('geolocation_geocoder_adr_title',implode(', ', $addressFields)),
50+
'title' => rex_i18n::msg('geolocation_geocoder_adr_title', implode(', ', $addressFields)),
5151
],
5252
];
5353

@@ -63,12 +63,12 @@
6363
'class' => 'form-control',
6464
'type' => 'text',
6565
'value' => '',
66-
'placeholder' => rex_i18n::rawMsg('geolocation_geocoder_placeholder',strip_tags($geoCoder->getCopyright())),
66+
'placeholder' => rex_i18n::rawMsg('geolocation_geocoder_placeholder', strip_tags($geoCoder->getCopyright())),
6767
'autocomplete' => 'off',
6868
];
6969

7070
/**
71-
* Aus den obigen Informationen die Input-Group mit dem Suchfeld unf ggf. Buttons zusammenschrauben
71+
* Aus den obigen Informationen die Input-Group mit dem Suchfeld unf ggf. Buttons zusammenschrauben.
7272
*/
7373
$fragment = new rex_fragment();
7474
$n = [

fragments/geolocation_modal.php

+10-19
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,41 @@
33
* Fragment zum Aufbau eines modalen Fensters (Bootstrap 3.4).
44
*
55
* Wird benötigt für das YForm-Value "geolocation_url"
6-
*
6+
*
77
* Es finden nur formale Prüfungen statt. Fehlende Werte werden nicht durch Defaults ersetzt.
88
* Hier wird aus Eingangsdaten HTML gebaut, mehr nicht.
9-
*
9+
*
1010
* $this->id optional; ID für das Modal an sich
1111
* $this->title optional: Titel für das Modal
1212
* $this->content optional: Inhalt
13-
*
1413
*/
1514

1615
namespace FriendsOfRedaxo\Geolocation;
1716

1817
use rex_fragment;
1918

20-
/**
21-
* @var rex_fragment $this
22-
*/
19+
/** @var rex_fragment $this */
2320

24-
/**
25-
* @var string $id
26-
*/
21+
/** @var string $id */
2722
$id = $this->id ?? '';
2823
if ('' === $id) {
2924
$modalIdAttr = '';
3025
$modalLabelId = md5(microtime());
3126
} else {
32-
$modalIdAttr = ' id="'.$id.'"';
33-
$modalLabelId = $id.'-label';
27+
$modalIdAttr = ' id="' . $id . '"';
28+
$modalLabelId = $id . '-label';
3429
}
3530

36-
/**
37-
* @var string $content
38-
*/
31+
/** @var string $content */
3932
$content = $this->content ?? '';
40-
$content = '<div class="modal-body" style="font-size:15px;">'.$content.'</div>';
33+
$content = '<div class="modal-body" style="font-size:15px;">' . $content . '</div>';
4134

42-
/**
43-
* @var string $title
44-
*/
35+
/** @var string $title */
4536
$title = $this->title ?? '';
4637
if ('' === $title) {
4738
$title = '';
4839
} else {
49-
$title = '<h4 class="modal-title" id="' . $modalLabelId.'">'.$title.'</h4>';
40+
$title = '<h4 class="modal-title" id="' . $modalLabelId . '">' . $title . '</h4>';
5041
}
5142

5243
?>

fragments/geolocation_rex_map.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Fragment zum Aufbau des rex-map-HTML.
45
*
@@ -17,9 +18,7 @@
1718
use function is_array;
1819
use function is_string;
1920

20-
/**
21-
* @var rex_fragment $this
22-
*/
21+
/** @var rex_fragment $this */
2322

2423
$classes = [];
2524
$attributes = [];
@@ -49,7 +48,7 @@
4948
$classes = array_merge($classes, $class);
5049
}
5150
}
52-
$classes = array_filter($classes, 'trim');
51+
$classes = array_filter($classes, trim(...));
5352
if (0 < count($classes)) {
5453
$attributes['class'] = array_unique($classes);
5554
}
@@ -59,7 +58,7 @@
5958
if (isset($this->attributes) && is_array($this->attributes) && 0 < count($this->attributes)) {
6059
$attributes = array_merge(
6160
$attributes,
62-
array_diff_key($this->attributes, ['mapset' => null, 'dataset' => null, 'map' => null, 'class' => null])
61+
array_diff_key($this->attributes, ['mapset' => null, 'dataset' => null, 'map' => null, 'class' => null]),
6362
);
6463
}
6564

lib/Cache.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Cache-Verwaltung.
45
*/
@@ -16,6 +17,8 @@
1617
use function is_array;
1718
use function is_bool;
1819

20+
use const GLOB_NOSORT;
21+
1922
class Cache
2023
{
2124
/**
@@ -46,7 +49,7 @@ public function sendCacheFile(string $filePath, string $contentType, int $ttl):
4649
$time2elapse = $timestamp + ($ttl * 60);
4750

4851
rex_response::cleanOutputBuffers();
49-
rex_response::setHeader('Expires', gmdate('D, d M Y H:i:s', $time2elapse) .' GMT');
52+
rex_response::setHeader('Expires', gmdate('D, d M Y H:i:s', $time2elapse) . ' GMT');
5053
rex_response::sendCacheControl('public, max-age=' . $ttl * 60);
5154
rex_response::sendFile($filePath, $contentType);
5255
exit;
@@ -93,7 +96,7 @@ public static function clearLayerCache(int $layer): int
9396
if (0 < $layer) {
9497
$targetDir = rex_path::addonCache(ADDON, (string) $layer);
9598
if (is_dir($targetDir)) {
96-
$files = glob($targetDir.'/*', GLOB_NOSORT);
99+
$files = glob($targetDir . '/*', GLOB_NOSORT);
97100
if (is_array($files)) {
98101
$deletedFiles = count($files);
99102
$deletedFiles = rex_dir::delete($targetDir, true) ? $deletedFiles : 0;
@@ -124,7 +127,7 @@ public static function clearCache(): int
124127
$layerCaches = preg_grep('/\d+/', $layerCaches);
125128
if (is_array($layerCaches)) {
126129
foreach ($layerCaches as $layer) {
127-
$liste = scandir($targetDir.$layer);
130+
$liste = scandir($targetDir . $layer);
128131
if (is_array($liste)) {
129132
$deletedFiles += (count($liste) - 2); // ohne . und ..
130133
}
@@ -198,7 +201,7 @@ public static function cleanupLayerCache(int $layer = 0, int $threshold = CFM_DE
198201
$threshold = max($threshold, CFM_MIN);
199202
$ttl = max($ttl, TTL_MIN);
200203

201-
$targetDir = rex_path::addonCache(ADDON, $layer.'/');
204+
$targetDir = rex_path::addonCache(ADDON, $layer . '/');
202205
$targetTime = time() - ($ttl * 60);
203206
$timeString = date('Y-m-d G-H-s', $targetTime);
204207

lib/Cronjob.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Cronjob-Klasse; ruft die Bereinigungs-Methode in Geolocation\Cache auf.
45
*/
@@ -8,8 +9,11 @@
89
use rex_cronjob;
910
use rex_i18n;
1011

12+
use const PHP_EOL;
13+
1114
class Cronjob extends rex_cronjob
1215
{
16+
/** @api */
1317
public const LABEL = 'Geolocation: Cleanup Cache';
1418

1519
/**
@@ -19,9 +23,7 @@ class Cronjob extends rex_cronjob
1923
*/
2024
public function execute(): bool
2125
{
22-
/**
23-
* @var null|list<string> $msg
24-
*/
26+
/** @var list<string> $msg */
2527
$msg = Cache::cleanupCache();
2628
$this->setMessage(implode(PHP_EOL, $msg));
2729
return true;

lib/DeveloperException.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22

33
namespace FriendsOfRedaxo\Geolocation;
44

5-
class DeveloperException extends Exception
6-
{
7-
}
5+
class DeveloperException extends Exception {}

lib/Exception.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Damit man weiß, dass die Exception aus Geolocation stammt
45
* => Geolocation\Exception.
@@ -8,6 +9,4 @@
89

910
use RuntimeException;
1011

11-
class Exception extends RuntimeException
12-
{
13-
}
12+
class Exception extends RuntimeException {}

lib/GeoCoder.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,12 @@ public function getValue(string $name)
192192
*
193193
* @api
194194
*/
195-
public function getRequestUrl(bool $escape=true): string
195+
public function getRequestUrl(bool $escape = true): string
196196
{
197197
return rex_url::frontendController([
198198
KEY_GEOCODER => $this->id,
199199
self::VALUE_PARAM => self::VALUE_PLACEHOLDER,
200-
],$escape);
200+
], $escape);
201201
}
202202

203203
/**

lib/InstallException.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22

33
namespace FriendsOfRedaxo\Geolocation;
44

5-
class InstallException extends Exception
6-
{
7-
}
5+
class InstallException extends Exception {}

lib/InvalidMapsetParameter.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22

33
namespace FriendsOfRedaxo\Geolocation;
44

5-
class InvalidMapsetParameter extends InvalidParameter
6-
{
7-
}
5+
class InvalidMapsetParameter extends InvalidParameter {}

lib/InvalidParameter.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Sammelt alle Exceptions wegen ungültiger Funktions-Parameter
45
* an einer Stelle.
@@ -8,7 +9,7 @@
89

910
use Throwable;
1011

11-
class InvalidParameter extends \FriendsOfRedaxo\Geolocation\Exception
12+
class InvalidParameter extends Exception
1213
{
1314
/** @api */
1415
public const KEY_LAT_LNG = 1;
@@ -51,9 +52,7 @@ class InvalidParameter extends \FriendsOfRedaxo\Geolocation\Exception
5152
/** @api */
5253
public const NOT_A_POINT = 20;
5354

54-
/**
55-
* @var array<int,string>
56-
*/
55+
/** @var array<int,string> */
5756
private array $msg = [
5857
self::KEY_LAT_LNG => 'Key-Error! Latitude/longitude-Key missing or equal. Given $lat="%s" and $lng="%s"',
5958
self::LAT_MISSING => 'Latitude value ($point[%s]) missing',

0 commit comments

Comments
 (0)