Skip to content

Commit

Permalink
Merge pull request #1141: Apply php8.1 in Rector preset
Browse files Browse the repository at this point in the history
  • Loading branch information
spiralbot committed Sep 10, 2024
1 parent 87ebe49 commit 16f2653
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/Compiler/Renderer/DynamicRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ private function directive(Compiler\Result $source, Directive $directive): void
private function output(Compiler\Result $source, Output $output): void
{
if ($output->rawOutput) {
$source->push(\sprintf('<?php echo %s; ?>', \trim($output->body)), $output->getContext());
$source->push(\sprintf('<?php echo %s; ?>', \trim((string) $output->body)), $output->getContext());
return;
}

$filter = $output->filter ?? $this->defaultFilter;

$source->push(
\sprintf(\sprintf('<?php echo %s; ?>', $filter), \trim($output->body)),
\sprintf(\sprintf('<?php echo %s; ?>', $filter), \trim((string) $output->body)),
$output->getContext()
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Lexer/Grammar/DynamicGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private function declare(?string $body): void
}

foreach ($this->fetchOptions($body) as $option => $value) {
$value = \trim($value, '\'" ');
$value = \trim((string) $value, '\'" ');
switch ($option) {
case 'syntax':
$this->echo->setActive($value !== 'off');
Expand Down
6 changes: 3 additions & 3 deletions src/Transform/Finalizer/DynamicToPHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,17 @@ private function output(Output $node, VisitorContext $ctx): PHP
*/

if ($node->rawOutput) {
$result = \sprintf('<?php echo %s; ?>', \trim($node->body));
$result = \sprintf('<?php echo %s; ?>', \trim((string) $node->body));
} else {
$filter = $node->filter ?? $this->getFilterContext($ctx);

$result = \sprintf(\sprintf('<?php echo %s; ?>', $filter), \trim($node->body));
$result = \sprintf(\sprintf('<?php echo %s; ?>', $filter), \trim((string) $node->body));
}

return new PHP(
$result,
\token_get_all($result),
$node->getContext()->withValue(PHP::ORIGINAL_BODY, \trim($node->body))
$node->getContext()->withValue(PHP::ORIGINAL_BODY, \trim((string) $node->body))
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Transform/Import/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(

public function resolve(Builder $builder, string $name): ?Template
{
$path = \substr($name, \strlen($this->prefix) + 1);
$path = \substr($name, \strlen((string) $this->prefix) + 1);
$path = \str_replace('.', DIRECTORY_SEPARATOR, $path);

return $builder->load($this->path . DIRECTORY_SEPARATOR . $path);
Expand Down
2 changes: 1 addition & 1 deletion src/Transform/Merge/Inject/InjectPHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private function trimPHP(mixed $node): string
return $this->exportValue($node);

case $node instanceof Output:
return \trim($node->body);
return \trim((string) $node->body);

case $node instanceof PHP:
return $node->getContext()?->getValue(PHP::ORIGINAL_BODY)
Expand Down
2 changes: 1 addition & 1 deletion src/Transform/Merge/Inject/PHPMixin.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private function parse(string $func): void
}

if ($name === null) {
$name = \stripcslashes(\substr($token[1], 1, -1));
$name = \stripcslashes(\substr((string) $token[1], 1, -1));
}
$value .= $token[1];
break;
Expand Down
4 changes: 2 additions & 2 deletions src/Transform/Visitor/DefineBlocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ private function makeBlock(Tag $node): ?NodeInterface
{
$name = null;
foreach ($this->prefix as $prefix) {
if (\str_starts_with($node->name, $prefix)) {
$name = \substr($node->name, \strlen($prefix));
if (\str_starts_with($node->name, (string) $prefix)) {
$name = \substr($node->name, \strlen((string) $prefix));
break;
}
}
Expand Down

0 comments on commit 16f2653

Please sign in to comment.