Skip to content

Commit 512846d

Browse files
committed
phan "PhanPluginNotFullyQualifiedFunctionCall"
1 parent 07ec172 commit 512846d

File tree

6 files changed

+79
-76
lines changed

6 files changed

+79
-76
lines changed

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@
3535
},
3636

3737
"config" : {
38-
"optimize-autoloader" : true
38+
"optimize-autoloader" : true,
39+
"allow-plugins": {
40+
"composer/package-versions-deprecated": true
41+
}
3942
},
4043

4144
"extra" : {

src/Config/Config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ abstract public function getRules();
7777
*/
7878
public static function registerDefault(string $type, Config $config): void
7979
{
80-
$type = strtolower(trim($type));
80+
$type = \strtolower(\trim($type));
8181
self::$configs[$type] = $config;
8282
}
8383

@@ -87,7 +87,7 @@ public static function registerDefault(string $type, Config $config): void
8787
*/
8888
public static function getDefault(string $type): ?Config
8989
{
90-
$type = strtolower(trim($type));
90+
$type = \strtolower(\trim($type));
9191
return self::$configs[$type] ?? null;
9292
}
9393
}

src/Formatter.php

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ public function __construct(array $rules = [], array $default = [], ?string $typ
5656
$this->default = $default;
5757

5858
// prepare rules
59-
$this->rules = array_change_key_case($rules, CASE_LOWER);
59+
$this->rules = \array_change_key_case($rules, \CASE_LOWER);
6060

6161
foreach ($this->rules as $key => $item) {
62-
$this->rules[$key] = array_merge($default, (array)$item);
62+
$this->rules[$key] = \array_merge($default, (array)$item);
6363
}
6464
}
6565

@@ -69,7 +69,7 @@ public function __construct(array $rules = [], array $default = [], ?string $typ
6969
*/
7070
public function get(string $rule): array
7171
{
72-
if (array_key_exists($rule, $this->rules)) {
72+
if (\array_key_exists($rule, $this->rules)) {
7373
return (array)$this->rules[$rule];
7474
}
7575

@@ -83,9 +83,9 @@ public function get(string $rule): array
8383
public function getList(bool $keysOnly = false): array
8484
{
8585
if ($keysOnly) {
86-
$keys = array_keys($this->rules);
87-
$values = array_keys($this->rules);
88-
return array_combine($keys, $values) ?: [];
86+
$keys = \array_keys($this->rules);
87+
$values = \array_keys($this->rules);
88+
return \array_combine($keys, $values) ?: [];
8989
}
9090

9191
return $this->rules;
@@ -103,13 +103,13 @@ public function text(float $value, string $rule, bool $showSymbol = true): strin
103103
$rData = $this->get($rule);
104104
$symbol = $showSymbol ? $rData['symbol'] : '';
105105

106-
$result = str_replace(
106+
$result = \str_replace(
107107
['%v', '%s'],
108108
[$data['value'], $symbol],
109109
$data['template']
110110
);
111111

112-
return trim($result);
112+
return \trim($result);
113113
}
114114

115115
/**
@@ -123,7 +123,7 @@ public function html(array $current, array $orig, array $params): string
123123
$data = $this->format($current['value'], $current['rule']);
124124
$rData = $this->get($current['rule']);
125125

126-
$result = str_replace(
126+
$result = \str_replace(
127127
['%v', '%s'],
128128
[
129129
"<span class=\"simpleType-value\">{$data['value']}</span>",
@@ -183,16 +183,16 @@ public static function htmlAttributes(array $attributes): string
183183
{
184184
$result = '';
185185

186-
if (count($attributes)) {
186+
if (\count($attributes)) {
187187
foreach ($attributes as $key => $param) {
188-
$value = implode(' ', (array)$param);
189-
$value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
190-
$value = trim($value);
188+
$value = \implode(' ', (array)$param);
189+
$value = \htmlspecialchars($value, \ENT_QUOTES, 'UTF-8');
190+
$value = \trim($value);
191191
$result .= " {$key}=\"{$value}\"";
192192
}
193193
}
194194

195-
return trim($result);
195+
return \trim($result);
196196
}
197197

198198
/**
@@ -206,32 +206,32 @@ public function round(float $value, string $rule, array $params = []): float
206206
$format = $this->get($rule);
207207

208208
// prepare params
209-
$params = array_merge(['roundType' => null, 'roundValue' => null], $params);
209+
$params = \array_merge(['roundType' => null, 'roundValue' => null], $params);
210210

211211
// get vars
212212
$roundType = $params['roundType'];
213213
$roundValue = $params['roundValue'];
214214

215215
if (!$roundType) {
216-
$roundType = array_key_exists('round_type', $format) ? $format['round_type'] : self::ROUND_NONE;
216+
$roundType = \array_key_exists('round_type', $format) ? $format['round_type'] : self::ROUND_NONE;
217217
}
218218

219219
if (null === $roundValue) {
220-
$roundValue = array_key_exists('round_value', $format) ? $format['round_value'] : self::ROUND_DEFAULT;
220+
$roundValue = \array_key_exists('round_value', $format) ? $format['round_value'] : self::ROUND_DEFAULT;
221221
}
222222

223223
$roundValue = (int)$roundValue;
224224

225225
if (self::ROUND_CEIL === $roundType) {
226226
$base = 10 ** $roundValue;
227-
$value = ceil($value * $base) / $base;
227+
$value = \ceil($value * $base) / $base;
228228
} elseif (self::ROUND_CLASSIC === $roundType) {
229-
$value = round($value, $roundValue);
229+
$value = \round($value, $roundValue);
230230
} elseif (self::ROUND_FLOOR === $roundType) {
231231
$base = 10 ** $roundValue;
232-
$value = floor($value * $base) / $base;
232+
$value = \floor($value * $base) / $base;
233233
} elseif (self::ROUND_NONE === $roundType) {
234-
$value = round($value, self::ROUND_DEFAULT); // hack, because 123.400000001 !== 123.4
234+
$value = \round($value, self::ROUND_DEFAULT); // hack, because 123.400000001 !== 123.4
235235
} else {
236236
throw new Exception("Undefined round mode: '{$roundType}'");
237237
}
@@ -251,8 +251,8 @@ protected function format(float $value, string $rule): array
251251

252252
$roundedValue = $this->round($value, $rule);
253253
$isPositive = ($value >= 0);
254-
$valueStr = number_format(
255-
abs($roundedValue),
254+
$valueStr = \number_format(
255+
\abs($roundedValue),
256256
(int)($format['num_decimals'] ?? 0),
257257
(string)($format['decimal_sep'] ?? '.'),
258258
(string)($format['thousands_sep'] ?? '')
@@ -275,7 +275,7 @@ public function changeRule(string $rule, array $newFormat): void
275275
{
276276
$oldFormat = $this->get($rule);
277277

278-
$this->rules[$rule] = array_merge($oldFormat, $newFormat);
278+
$this->rules[$rule] = \array_merge($oldFormat, $newFormat);
279279
}
280280

281281
/**
@@ -288,11 +288,11 @@ public function addRule(string $rule, array $newFormat = []): void
288288
throw new Exception('Empty rule name');
289289
}
290290

291-
if (array_key_exists($rule, $this->rules)) {
291+
if (\array_key_exists($rule, $this->rules)) {
292292
throw new Exception("Format '{$rule}' already exists");
293293
}
294294

295-
$this->rules[$rule] = array_merge($this->default, $newFormat);
295+
$this->rules[$rule] = \array_merge($this->default, $newFormat);
296296
}
297297

298298
/**
@@ -301,7 +301,7 @@ public function addRule(string $rule, array $newFormat = []): void
301301
*/
302302
public function removeRule(string $rule): bool
303303
{
304-
if (array_key_exists($rule, $this->rules)) {
304+
if (\array_key_exists($rule, $this->rules)) {
305305
unset($this->rules[$rule]);
306306
return true;
307307
}

src/Parser.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ public function __construct(string $default = '', array $ruleList = [])
4545
* @return int
4646
*/
4747
$sortFunction = static function (string $item1, string $item2): int {
48-
return strlen($item2) - strlen($item1);
48+
return \strlen($item2) - \strlen($item1);
4949
};
5050

51-
uksort($ruleList, $sortFunction);
51+
\uksort($ruleList, $sortFunction);
5252

5353
$this->rules = $ruleList;
5454
$this->default = $default;
@@ -63,19 +63,19 @@ public function parse($data = null, ?string $forceRule = null): array
6363
{
6464
$rule = null;
6565

66-
if (is_array($data)) {
66+
if (\is_array($data)) {
6767
$value = $data[0] ?? null;
6868
$rule = $data[1] ?? null;
6969
return $this->parse($value, $rule);
7070
}
7171

72-
$value = strtolower(trim((string)$data));
72+
$value = \strtolower(\trim((string)$data));
7373
$aliases = $this->getCodeList();
7474

7575
foreach ($aliases as $alias) {
76-
if (strpos($value, $alias) !== false) {
76+
if (\strpos($value, $alias) !== false) {
7777
$rule = $alias;
78-
$value = str_ireplace($rule, '', $value);
78+
$value = \str_ireplace($rule, '', $value);
7979
break;
8080
}
8181
}
@@ -96,7 +96,7 @@ public function parse($data = null, ?string $forceRule = null): array
9696
*/
9797
public function getCodeList(): array
9898
{
99-
return array_keys($this->rules);
99+
return \array_keys($this->rules);
100100
}
101101

102102
/**
@@ -105,16 +105,16 @@ public function getCodeList(): array
105105
*/
106106
public static function cleanValue($value): float
107107
{
108-
$result = trim((string)$value);
108+
$result = \trim((string)$value);
109109

110-
$result = (string)preg_replace('#[^0-9-+eE,.]#', '', $result);
110+
$result = (string)\preg_replace('#[^0-9-+eE,.]#', '', $result);
111111

112-
if (!preg_match('#\d[eE][-+]\d#', $result)) { // remove exponential format
113-
$result = str_replace(['e', 'E'], '', $result);
112+
if (!\preg_match('#\d[eE][-+]\d#', $result)) { // remove exponential format
113+
$result = \str_replace(['e', 'E'], '', $result);
114114
}
115115

116-
$result = (float)str_replace(',', '.', $result);
117-
return round($result, Formatter::ROUND_DEFAULT);
116+
$result = (float)\str_replace(',', '.', $result);
117+
return \round($result, Formatter::ROUND_DEFAULT);
118118
}
119119

120120
/**
@@ -123,7 +123,7 @@ public static function cleanValue($value): float
123123
*/
124124
public static function cleanRule(?string $rule): string
125125
{
126-
return strtolower(trim((string)$rule));
126+
return \strtolower(\trim((string)$rule));
127127
}
128128

129129
/**
@@ -138,7 +138,7 @@ public function checkRule(?string $rule): string
138138
return $this->default;
139139
}
140140

141-
if (array_key_exists($cleanRule, $this->rules)) {
141+
if (\array_key_exists($cleanRule, $this->rules)) {
142142
return $cleanRule;
143143
}
144144

@@ -159,7 +159,7 @@ public function addRule(string $newRule): void
159159
*/
160160
public function removeRule(string $rule): bool
161161
{
162-
if (array_key_exists($rule, $this->rules)) {
162+
if (\array_key_exists($rule, $this->rules)) {
163163
unset($this->rules[$rule]);
164164
return true;
165165
}

0 commit comments

Comments
 (0)