Skip to content

Commit 5d7c53a

Browse files
committed
Fix InvalidNullableReturnType
1 parent c15d69f commit 5d7c53a

File tree

6 files changed

+11
-12
lines changed

6 files changed

+11
-12
lines changed

.php-cs-fixer.dist.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
->include(__DIR__ . '/src')
99
->include(__DIR__ . '/tests')
1010
->include(__DIR__ . '/rector.php')
11-
->build();
11+
->build();

src/Lib/Variable/VariableReplacementProcessor.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function process(string $text): string
3434
);
3535

3636
// Replace {{VAR_NAME}} syntax
37-
return \preg_replace_callback(
37+
return (string) \preg_replace_callback(
3838
'/{{([a-zA-Z0-9_]+)}}/',
3939
fn(array $matches) => $this->replaceVariable($matches[1]),
4040
(string) $result,

src/McpServer/Routing/RouteRegistrar.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ private function registerMethodRoutes(Route $route, string $controllerClass): vo
8282
private function normalizePath(string $path): string
8383
{
8484
// Replace multiple slashes with a single slash
85-
$path = \preg_replace('#/+#', '/', $path);
85+
$path = (string) \preg_replace('#/+#', '/', $path);
8686

8787
// Ensure path starts with a slash
88-
if (!\str_starts_with((string) $path, '/')) {
88+
if (!\str_starts_with($path, '/')) {
8989
$path = '/' . $path;
9090
}
9191

src/Modifier/Sanitizer/Rule/CommentInsertionRule.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function apply(string $content): string
4545
// Add class comments
4646
if (!empty($this->classComment)) {
4747
$comment = $this->formatPhpComment($this->classComment);
48-
$content = \preg_replace(
48+
$content = (string) \preg_replace(
4949
'/(class|interface|trait|enum)\s+([a-zA-Z0-9_]+)/',
5050
PHP_EOL . $comment . PHP_EOL . '$1 $2',
5151
$content,
@@ -55,7 +55,7 @@ public function apply(string $content): string
5555
// Add method comments
5656
if (!empty($this->methodComment)) {
5757
$comment = $this->formatPhpComment($this->methodComment);
58-
$content = \preg_replace(
58+
$content = (string) \preg_replace(
5959
'/(\s+)public|private|protected\s+function/',
6060
'$1' . PHP_EOL . '$1' . $comment . PHP_EOL . '$1$0',
6161
(string) $content,

src/Modifier/Sanitizer/Rule/KeywordRemovalRule.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,9 @@ public function apply(string $content): string
7373
private function replaceKeywords(string $line): string
7474
{
7575
foreach ($this->keywords as $keyword) {
76-
if ($this->caseSensitive) {
77-
$line = \str_replace($keyword, $this->replacement, $line);
78-
} else {
79-
$line = \preg_replace('/' . \preg_quote($keyword, '/') . '/i', $this->replacement, (string) $line);
80-
}
76+
$line = $this->caseSensitive
77+
? \str_replace($keyword, $this->replacement, $line)
78+
: (string) \preg_replace('/' . \preg_quote($keyword, '/') . '/i', $this->replacement, $line);
8179
}
8280

8381
return $line;

src/Modifier/Sanitizer/Rule/RegexReplacementRule.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public function getName(): string
2626
public function apply(string $content): string
2727
{
2828
foreach ($this->patterns as $pattern => $replacement) {
29-
$content = \preg_replace($pattern, $replacement, (string) $content);
29+
/** @var string $content */
30+
$content = \preg_replace($pattern, $replacement, $content);
3031
}
3132

3233
return $content;

0 commit comments

Comments
 (0)