Skip to content

Commit 840c456

Browse files
committed
cs
1 parent c99059c commit 840c456

File tree

9 files changed

+18
-20
lines changed

9 files changed

+18
-20
lines changed

src/Utils/Arrays.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public static function getKeyOffset(array $array, string|int $key): ?int
106106
/**
107107
* @deprecated use getKeyOffset()
108108
*/
109-
public static function searchKey(array $array, $key): ?int
109+
public static function searchKey(array $array, string|int $key): ?int
110110
{
111111
return self::getKeyOffset($array, $key);
112112
}
@@ -117,7 +117,7 @@ public static function searchKey(array $array, $key): ?int
117117
*/
118118
public static function contains(array $array, mixed $value): bool
119119
{
120-
return in_array($value, $array, true);
120+
return in_array($value, $array, strict: true);
121121
}
122122

123123

src/Utils/Callback.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static function invokeSafe(string $function, array $args, callable $onErr
5353
* @return callable
5454
* @throws Nette\InvalidArgumentException
5555
*/
56-
public static function check(mixed $callable, bool $syntax = false)
56+
public static function check(mixed $callable, bool $syntax = false): mixed
5757
{
5858
if (!is_callable($callable, $syntax)) {
5959
throw new Nette\InvalidArgumentException(

src/Utils/FileInfo.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@
1919
*/
2020
final class FileInfo extends \SplFileInfo
2121
{
22-
private readonly string $relativePath;
23-
24-
25-
public function __construct(string $file, string $relativePath = '')
26-
{
22+
public function __construct(
23+
string $file,
24+
private readonly string $relativePath = '',
25+
) {
2726
parent::__construct($file);
28-
$this->setInfoClass(static::class);
29-
$this->relativePath = $relativePath;
27+
$this->setInfoClass(self::class);
3028
}
3129

3230

src/Utils/Html.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ final public function attributes(): string
780780
continue;
781781

782782
} elseif (is_array($value)) {
783-
if (strncmp($key, 'data-', 5) === 0) {
783+
if (str_starts_with($key, 'data-')) {
784784
$value = Json::encode($value);
785785

786786
} else {

src/Utils/Iterables.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public static function memoize(iterable $iterable): \IteratorAggregate
215215
{
216216
return new class (self::toIterator($iterable)) implements \IteratorAggregate {
217217
public function __construct(
218-
private \Iterator $iterator,
218+
private readonly \Iterator $iterator,
219219
private array $cache = [],
220220
) {
221221
}

src/Utils/ObjectHelpers.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ final class ObjectHelpers
2727
* @return never
2828
* @throws MemberAccessException
2929
*/
30-
public static function strictGet(string $class, string $name): void
30+
public static function strictGet(string $class, string $name): never
3131
{
3232
$rc = new \ReflectionClass($class);
3333
$hint = self::getSuggestion(array_merge(
@@ -42,7 +42,7 @@ public static function strictGet(string $class, string $name): void
4242
* @return never
4343
* @throws MemberAccessException
4444
*/
45-
public static function strictSet(string $class, string $name): void
45+
public static function strictSet(string $class, string $name): never
4646
{
4747
$rc = new \ReflectionClass($class);
4848
$hint = self::getSuggestion(array_merge(
@@ -222,7 +222,7 @@ public static function hasProperty(string $class, string $name): bool|string
222222
if ($rp->isPublic() && !$rp->isStatic()) {
223223
$prop = $name >= 'onA' && $name < 'on_' ? 'event' : true;
224224
}
225-
} catch (\ReflectionException $e) {
225+
} catch (\ReflectionException) {
226226
}
227227
}
228228

src/Utils/ReflectionMethod.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
final class ReflectionMethod extends \ReflectionMethod
2020
{
21-
private \ReflectionClass $originalClass;
21+
private readonly \ReflectionClass $originalClass;
2222

2323

2424
public function __construct(object|string $objectOrMethod, ?string $method = null)

src/Utils/Strings.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public static function substring(string $s, int $start, ?int $length = null): st
135135
public static function normalize(string $s): string
136136
{
137137
// convert to compressed normal form (NFC)
138-
if (class_exists('Normalizer', false) && ($n = \Normalizer::normalize($s, \Normalizer::FORM_C)) !== false) {
138+
if (class_exists('Normalizer', autoload: false) && ($n = \Normalizer::normalize($s, \Normalizer::FORM_C)) !== false) {
139139
$s = $n;
140140
}
141141

@@ -323,7 +323,7 @@ public static function capitalize(string $s): string
323323
*/
324324
public static function compare(string $left, string $right, ?int $length = null): bool
325325
{
326-
if (class_exists('Normalizer', false)) {
326+
if (class_exists('Normalizer', autoload: false)) {
327327
$left = \Normalizer::normalize($left, \Normalizer::FORM_D); // form NFD is faster
328328
$right = \Normalizer::normalize($right, \Normalizer::FORM_D); // form NFD is faster
329329
}
@@ -688,7 +688,7 @@ public static function pcre(string $func, array $args)
688688
});
689689

690690
if (($code = preg_last_error()) // run-time error, but preg_last_error & return code are liars
691-
&& ($res === null || !in_array($func, ['preg_filter', 'preg_replace_callback', 'preg_replace'], true))
691+
&& ($res === null || !in_array($func, ['preg_filter', 'preg_replace_callback', 'preg_replace'], strict: true))
692692
) {
693693
throw new RegexpException(preg_last_error_msg()
694694
. ' (pattern: ' . implode(' or ', (array) $args[0]) . ')', $code);

src/Utils/Validators.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public static function is(mixed $value, string $expected): bool
159159
if (!static::$validators[$type]($value)) {
160160
continue;
161161
}
162-
} catch (\TypeError $e) {
162+
} catch (\TypeError) {
163163
continue;
164164
}
165165
} elseif ($type === 'pattern') {

0 commit comments

Comments
 (0)