Skip to content

Commit 0cdbaf1

Browse files
committed
Refactoring
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
1 parent 830e09a commit 0cdbaf1

5 files changed

Lines changed: 3 additions & 153 deletions

File tree

phpstan-baseline.neon

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -5880,45 +5880,15 @@ parameters:
58805880
-
58815881
message: '#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\.$#'
58825882
identifier: foreach.nonIterable
5883-
count: 3
5884-
path: src/Error/Error.php
5885-
5886-
-
5887-
message: '#^Binary operation "\." between mixed and ''\('' results in an error\.$#'
5888-
identifier: binaryOp.invalid
5889-
count: 1
5890-
path: src/Error/Error.php
5891-
5892-
-
5893-
message: '#^Binary operation "\." between mixed and mixed results in an error\.$#'
5894-
identifier: binaryOp.invalid
5895-
count: 1
5896-
path: src/Error/Error.php
5897-
5898-
-
5899-
message: '#^Binary operation "\." between non\-falsy\-string and mixed results in an error\.$#'
5900-
identifier: binaryOp.invalid
59015883
count: 1
59025884
path: src/Error/Error.php
59035885

5904-
-
5905-
message: '#^Binary operation "\.\=" between non\-falsy\-string and mixed results in an error\.$#'
5906-
identifier: assignOp.invalid
5907-
count: 2
5908-
path: src/Error/Error.php
5909-
59105886
-
59115887
message: '#^Cannot access offset ''args'' on mixed\.$#'
59125888
identifier: offsetAccess.nonOffsetAccessible
59135889
count: 1
59145890
path: src/Error/Error.php
59155891

5916-
-
5917-
message: '#^Cannot access offset ''class'' on mixed\.$#'
5918-
identifier: offsetAccess.nonOffsetAccessible
5919-
count: 1
5920-
path: src/Error/Error.php
5921-
59225892
-
59235893
message: '#^Cannot access offset ''class''\|''function''\|''line''\|''type'' on mixed\.$#'
59245894
identifier: offsetAccess.nonOffsetAccessible
@@ -5928,23 +5898,11 @@ parameters:
59285898
-
59295899
message: '#^Cannot access offset ''file'' on mixed\.$#'
59305900
identifier: offsetAccess.nonOffsetAccessible
5931-
count: 2
5932-
path: src/Error/Error.php
5933-
5934-
-
5935-
message: '#^Cannot access offset ''function'' on mixed\.$#'
5936-
identifier: offsetAccess.nonOffsetAccessible
59375901
count: 1
59385902
path: src/Error/Error.php
59395903

59405904
-
5941-
message: '#^Cannot access offset ''line'' on mixed\.$#'
5942-
identifier: offsetAccess.nonOffsetAccessible
5943-
count: 1
5944-
path: src/Error/Error.php
5945-
5946-
-
5947-
message: '#^Cannot access offset ''type'' on mixed\.$#'
5905+
message: '#^Cannot access offset ''function'' on mixed\.$#'
59485906
identifier: offsetAccess.nonOffsetAccessible
59495907
count: 1
59505908
path: src/Error/Error.php
@@ -5964,21 +5922,9 @@ parameters:
59645922
-
59655923
message: '#^Parameter \#1 \$path of static method PhpMyAdmin\\Error\\Error\:\:relPath\(\) expects string, mixed given\.$#'
59665924
identifier: argument.type
5967-
count: 2
5968-
path: src/Error/Error.php
5969-
5970-
-
5971-
message: '#^Parameter \#1 \$step of static method PhpMyAdmin\\Error\\Error\:\:getFunctionCall\(\) expects array\<mixed\>, mixed given\.$#'
5972-
identifier: argument.type
59735925
count: 1
59745926
path: src/Error/Error.php
59755927

5976-
-
5977-
message: '#^Parameter \#1 \$value of function count expects array\|Countable, mixed given\.$#'
5978-
identifier: argument.type
5979-
count: 2
5980-
path: src/Error/Error.php
5981-
59825928
-
59835929
message: '#^Parameter \#2 \$function of static method PhpMyAdmin\\Error\\Error\:\:getArg\(\) expects string, mixed given\.$#'
59845930
identifier: argument.type
@@ -5997,7 +5943,7 @@ parameters:
59975943
Use dependency injection instead\.$#
59985944
'''
59995945
identifier: staticMethod.deprecated
6000-
count: 6
5946+
count: 5
60015947
path: src/Error/ErrorHandler.php
60025948

60035949
-

psalm-baseline.xml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4029,42 +4029,24 @@
40294029
</file>
40304030
<file src="src/Error/Error.php">
40314031
<MixedArgument>
4032-
<code><![CDATA[$step]]></code>
4033-
<code><![CDATA[$step['args']]]></code>
4034-
<code><![CDATA[$step['args']]]></code>
4035-
<code><![CDATA[$step['file']]]></code>
40364032
<code><![CDATA[$step['file']]]></code>
40374033
<code><![CDATA[$step['function']]]></code>
40384034
</MixedArgument>
40394035
<MixedArrayAccess>
40404036
<code><![CDATA[$step[$name]]]></code>
40414037
<code><![CDATA[$step['args']]]></code>
4042-
<code><![CDATA[$step['class']]]></code>
4043-
<code><![CDATA[$step['file']]]></code>
40444038
<code><![CDATA[$step['file']]]></code>
40454039
<code><![CDATA[$step['function']]]></code>
4046-
<code><![CDATA[$step['line']]]></code>
4047-
<code><![CDATA[$step['type']]]></code>
40484040
</MixedArrayAccess>
40494041
<MixedArrayOffset>
40504042
<code><![CDATA[$result[$idx]['args'][$key]]]></code>
40514043
</MixedArrayOffset>
40524044
<MixedAssignment>
4053-
<code><![CDATA[$arg]]></code>
4054-
<code><![CDATA[$arg]]></code>
40554045
<code><![CDATA[$arg]]></code>
40564046
<code><![CDATA[$key]]></code>
40574047
<code><![CDATA[$result[$idx][$name]]]></code>
40584048
<code><![CDATA[$step]]></code>
4059-
<code><![CDATA[$step]]></code>
40604049
</MixedAssignment>
4061-
<MixedOperand>
4062-
<code><![CDATA[$arg]]></code>
4063-
<code><![CDATA[$arg]]></code>
4064-
<code><![CDATA[$step['class']]]></code>
4065-
<code><![CDATA[$step['function']]]></code>
4066-
<code><![CDATA[$step['line']]]></code>
4067-
</MixedOperand>
40684050
</file>
40694051
<file src="src/Error/ErrorHandler.php">
40704052
<DeprecatedMethod>

src/Error/Error.php

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -309,72 +309,6 @@ public function getTitle(): string
309309
return $this->getType() . ': ' . $this->getMessage();
310310
}
311311

312-
/**
313-
* Get HTML backtrace
314-
*/
315-
public function getBacktraceDisplay(): string
316-
{
317-
return self::formatBacktrace($this->getBacktrace());
318-
}
319-
320-
/**
321-
* return formatted backtrace field
322-
*
323-
* @param mixed[] $backtrace Backtrace data
324-
*
325-
* @return string formatted backtrace
326-
*/
327-
public static function formatBacktrace(array $backtrace): string
328-
{
329-
if ($backtrace === []) {
330-
return '';
331-
}
332-
333-
$retval = '<ol class="list-group">';
334-
335-
foreach ($backtrace as $step) {
336-
$retval .= '<li class="list-group-item">';
337-
if (isset($step['file'], $step['line'])) {
338-
$retval .= self::relPath($step['file']) . '#' . $step['line'] . ': ';
339-
}
340-
341-
if (isset($step['class'])) {
342-
$retval .= $step['class'] . $step['type'];
343-
}
344-
345-
$retval .= self::getFunctionCall($step);
346-
$retval .= '</li>';
347-
}
348-
349-
return $retval . '</ol>';
350-
}
351-
352-
/**
353-
* Formats function call in a backtrace
354-
*
355-
* @param mixed[] $step backtrace step
356-
*/
357-
public static function getFunctionCall(array $step): string
358-
{
359-
$retval = $step['function'] . '(';
360-
if (isset($step['args'])) {
361-
if (count($step['args']) > 1) {
362-
$retval .= '<br>';
363-
foreach ($step['args'] as $arg) {
364-
$retval .= "\t";
365-
$retval .= $arg;
366-
$retval .= ',<br>';
367-
}
368-
} elseif (count($step['args']) > 0) {
369-
foreach ($step['args'] as $arg) {
370-
$retval .= $arg;
371-
}
372-
}
373-
}
374-
375-
return $retval . ')';
376-
}
377-
378312
/**
379313
* Get a single function argument
380314
*

src/Error/ErrorHandler.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,7 @@ public function handleError(
224224
*/
225225
public function handleException(Throwable $exception): void
226226
{
227-
$message = $exception::class;
228-
$message .= ': ' . $exception->getMessage();
227+
$message = $exception::class . ': ' . $exception->getMessage();
229228

230229
$this->addError(
231230
$message,

tests/unit/Error/ErrorTest.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,6 @@ public function testGetHash(): void
129129
);
130130
}
131131

132-
/**
133-
* Test for getBacktraceDisplay
134-
*/
135-
public function testGetBacktraceDisplay(): void
136-
{
137-
self::assertStringContainsString(
138-
'PHPUnit\Framework\TestRunner->run(<Class:PhpMyAdmin\Tests\Error\ErrorTest>)',
139-
$this->object->getBacktraceDisplay(),
140-
);
141-
}
142-
143132
/**
144133
* Test for getDisplay
145134
*/

0 commit comments

Comments
 (0)