Skip to content

Commit a101587

Browse files
kamil-tekielaMauricioFauth
authored andcommitted
Remove useless Message::format() method
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
1 parent f7449dd commit a101587

File tree

4 files changed

+3
-65
lines changed

4 files changed

+3
-65
lines changed

libraries/classes/Message.php

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
use function __;
1010
use function _ngettext;
11-
use function array_unshift;
12-
use function count;
1311
use function htmlspecialchars;
1412
use function is_array;
1513
use function is_float;
@@ -584,23 +582,6 @@ public static function decodeBB(string $message): string
584582
return Sanitize::sanitizeMessage($message, false, true);
585583
}
586584

587-
/**
588-
* wrapper for sprintf()
589-
*
590-
* @param mixed[] ...$params Params
591-
*
592-
* @return string formatted
593-
*/
594-
public static function format(...$params): string
595-
{
596-
if (isset($params[1]) && is_array($params[1])) {
597-
array_unshift($params[1], $params[0]);
598-
$params = $params[1];
599-
}
600-
601-
return sprintf(...$params);
602-
}
603-
604585
/**
605586
* returns unique Message::$hash, if not exists it will be created
606587
*
@@ -636,8 +617,8 @@ public function getMessage(): string
636617
$message = $this->getMessageWithIcon($message);
637618
}
638619

639-
if (count($this->getParams()) > 0) {
640-
$message = self::format($message, $this->getParams());
620+
if ($this->params !== []) {
621+
$message = sprintf($message, ...$this->params);
641622
}
642623

643624
if ($this->useBBCode) {

phpstan-baseline.neon

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5590,11 +5590,6 @@ parameters:
55905590
count: 1
55915591
path: libraries/classes/Message.php
55925592

5593-
-
5594-
message: "#^Right side of && is always true\\.$#"
5595-
count: 1
5596-
path: libraries/classes/Message.php
5597-
55985593
-
55995594
message: "#^Method PhpMyAdmin\\\\Navigation\\\\Navigation\\:\\:getHiddenItems\\(\\) return type has no value type specified in iterable type array\\.$#"
56005595
count: 1

psalm-baseline.xml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8787,12 +8787,8 @@
87878787
</PossiblyFalseOperand>
87888788
</file>
87898789
<file src="libraries/classes/Message.php">
8790-
<InvalidArgument>
8791-
<code>$message</code>
8792-
</InvalidArgument>
87938790
<MixedArgument>
8794-
<code>$params</code>
8795-
<code>$params</code>
8791+
<code><![CDATA[$this->params]]></code>
87968792
</MixedArgument>
87978793
<MixedAssignment>
87988794
<code>$add_message</code>
@@ -8814,10 +8810,6 @@
88148810
<MixedReturnStatement>
88158811
<code><![CDATA[self::$level[$this->getNumber()]]]></code>
88168812
</MixedReturnStatement>
8817-
<RedundantConditionGivenDocblockType>
8818-
<code>is_array($params[1])</code>
8819-
<code><![CDATA[isset($params[1]) && is_array($params[1])]]></code>
8820-
</RedundantConditionGivenDocblockType>
88218813
</file>
88228814
<file src="libraries/classes/Navigation/Navigation.php">
88238815
<DeprecatedMethod>
@@ -16213,13 +16205,6 @@
1621316205
</InvalidArgument>
1621416206
</file>
1621516207
<file src="test/classes/MessageTest.php">
16216-
<InvalidArgument>
16217-
<code><![CDATA['%s string']]></code>
16218-
<code><![CDATA['a']]></code>
16219-
<code><![CDATA['test string']]></code>
16220-
<code><![CDATA['test string']]></code>
16221-
<code><![CDATA['test string']]></code>
16222-
</InvalidArgument>
1622316208
<MixedInferredReturnType>
1622416209
<code>array</code>
1622516210
<code>array</code>

test/classes/MessageTest.php

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -391,29 +391,6 @@ public function testDecodeBB(string $actual, string $expected): void
391391
$this->assertEquals($expected, Message::decodeBB($actual));
392392
}
393393

394-
/**
395-
* testing format method
396-
*/
397-
public function testFormat(): void
398-
{
399-
$this->assertEquals(
400-
'test string',
401-
Message::format('test string'),
402-
);
403-
$this->assertEquals(
404-
'test string',
405-
Message::format('test string', 'a'),
406-
);
407-
$this->assertEquals(
408-
'test string',
409-
Message::format('test string', []),
410-
);
411-
$this->assertEquals(
412-
'test string',
413-
Message::format('%s string', ['test']),
414-
);
415-
}
416-
417394
/**
418395
* testing getHash method
419396
*/

0 commit comments

Comments
 (0)