File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
rules-tests/DeadCode/Rector/Assign/RemoveDoubleAssignRector/Fixture Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \Tests \DeadCode \Rector \Assign \RemoveDoubleAssignRector \Fixture ;
4+
5+ final class CompareInterpolatedString
6+ {
7+ public function run ()
8+ {
9+ $ markdown = 'a long string ' ;
10+
11+ $ markdown = preg_replace_callback (
12+ function (array $ matches ): string {
13+ $ match = $ matches [1 ];
14+ $ className = strtolower (Toolkit::toSlug ($ match ));
15+
16+ return "<span class='tag tag- {$ className }'> {$ match }</span> " ;
17+ },
18+ (string )$ markdown
19+ );
20+
21+ }
22+ }
Original file line number Diff line number Diff line change 2121use PhpParser \Node \Expr \MethodCall ;
2222use PhpParser \Node \Expr \Ternary ;
2323use PhpParser \Node \Expr \Yield_ ;
24+ use PhpParser \Node \InterpolatedStringPart ;
2425use PhpParser \Node \Scalar \InterpolatedString ;
2526use PhpParser \Node \Scalar \String_ ;
2627use PhpParser \Node \Stmt \Declare_ ;
@@ -112,6 +113,15 @@ public function pFileWithoutNamespace(FileWithoutNamespace $fileWithoutNamespace
112113 return $ this ->pStmts ($ fileWithoutNamespace ->stmts );
113114 }
114115
116+ /**
117+ * Use for standalone InterpolatedStringPart printing, that is not support by php-parser natively.
118+ * Used e.g. in \Rector\PhpParser\Comparing\NodeComparator::printWithoutComments
119+ */
120+ protected function pInterpolatedStringPart (InterpolatedStringPart $ interpolatedStringPart ): string
121+ {
122+ return $ interpolatedStringPart ->value ;
123+ }
124+
115125 protected function p (
116126 Node $ node ,
117127 int $ precedence = self ::MAX_PRECEDENCE ,
You can’t perform that action at this time.
0 commit comments