Skip to content

Commit 0ff968e

Browse files
committed
Fix level 5 type errors
1 parent aceb9ba commit 0ff968e

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

phpstan.neon

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
parameters:
2-
level: 4
2+
level: 5
33
paths:
44
- src
55
- tests

src/Encoder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static function enc(array|string|int|bool|null $var): string
2424
*
2525
* @return string The htmlencoded value of the specified variable
2626
*/
27-
public static function encq(array|string|int|bool|null $var)
27+
public static function encq(array|string|int|bool|null $var): string
2828
{
2929
return str_replace(['=', '`', '''], ['=', '`', '''], self::enc($var));
3030
}

src/Expression.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ public static function analyze(array $var): array
6161
* Get normalized handlebars expression for a variable.
6262
*
6363
* @param int $levels trace N levels top parent scope
64-
* @param bool $spvar is the path start with @ or not
65-
* @param array<string|int> $var variable parsed path
64+
* @param bool $spvar whether the path starts with @
65+
* @param array<string|null> $var variable parsed path
6666
*
6767
* @return string normalized expression for debug display
6868
*/

src/Parser.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public static function isSubExp(array $var): bool
217217
/**
218218
* Analyze parsed token for advanced variables.
219219
*
220-
* @param array<bool|int|array> $vars parsed token
220+
* @param list<string> $vars parsed token
221221
* @param string $token original token
222222
*
223223
* @return array<bool|int|array> Return parsed result
@@ -368,7 +368,7 @@ protected static function analyze(string $token, Context $context): array
368368
$stack += strlen($m[2]);
369369
}
370370
// end an argument when token ends with expected character (ignoring whitespace + first instance)
371-
if (substr($t, -1, 1) === $expect && !preg_match('/^\s+' . preg_quote($expect) . '$/', $prev)) {
371+
if (substr($t, -1, 1) === $expect && !preg_match('/^\s+' . preg_quote($expect, '/') . '$/', $prev)) {
372372
if ($stack > 0 && !$quotes) {
373373
preg_match('/(\\)+)$/', $t, $matchedq);
374374
$stack -= isset($matchedq[0]) ? strlen($matchedq[0]) : 1;

src/Runtime.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ public static function encq($var): string
8080
* @param array<array|string|int>|string|int|bool|null $v value to be output
8181
* @param int $ex 1 to return untouched value, default is 0
8282
*
83-
* @return array<array|string|int>|string|int|null The raw value of the specified variable
83+
* @return array<array|string|int>|string The raw value of the specified variable
8484
*/
85-
public static function raw($v, int $ex = 0)
85+
public static function raw(array|string|int|bool|null $v, int $ex = 0): string|array
8686
{
8787
if ($ex) {
8888
return $v;
@@ -100,11 +100,11 @@ public static function raw($v, int $ex = 0)
100100
if (count(array_diff_key($v, array_keys(array_keys($v)))) > 0) {
101101
return '[object Object]';
102102
} else {
103-
$ret = [];
103+
$ret = '';
104104
foreach ($v as $vv) {
105-
$ret[] = static::raw($vv);
105+
$ret .= static::raw($vv) . ',';
106106
}
107-
return join(',', $ret);
107+
return substr($ret, 0, -1);
108108
}
109109
}
110110

tests/TokenTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ class TokenTest extends TestCase
99
{
1010
public function testToString(): void
1111
{
12-
$this->assertSame('c', Token::toString([0, 'a', 'b', 'c', 'd', 'e']));
13-
$this->assertSame('cd', Token::toString([0, 'a', 'b', 'c', 'd', 'e', 'f']));
14-
$this->assertSame('qd', Token::toString([0, 'a', 'b', 'c', 'd', 'e', 'f'], [3 => 'q']));
12+
$this->assertSame('c', Token::toString(['0', 'a', 'b', 'c', 'd', 'e']));
13+
$this->assertSame('cd', Token::toString(['0', 'a', 'b', 'c', 'd', 'e', 'f']));
14+
$this->assertSame('qd', Token::toString(['0', 'a', 'b', 'c', 'd', 'e', 'f'], [3 => 'q']));
1515
}
1616
}

0 commit comments

Comments
 (0)