Skip to content

Commit

Permalink
[CodingStyle] Skip EncapsedStringsToSprintfRector on heredoc (#3242)
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Dec 23, 2022
1 parent 3c168f0 commit 8862942
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/NodeTypeResolver/Node/AttributeKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,9 @@ final class AttributeKey
* @var string
*/
public const EXTRA_USE_IMPORT = 'extra_use_import';

/**
* @var string
*/
public const DOC_LABEL = 'docLabel';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Rector\Tests\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector\Fixture;

final class SkipInHeredoc
{
public function run(string $data)
{
$data = 'test';
$value = <<<CODE
Some {$data}
CODE;

echo $value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private function shouldSkip(Encapsed $encapsed): bool
}
}

return false;
return $encapsed->hasAttribute(AttributeKey::DOC_LABEL);
}

private function collectEncapsedStringPart(EncapsedStringPart $encapsedStringPart): void
Expand Down

0 comments on commit 8862942

Please sign in to comment.