EscapeImplicitBackslashesFixerTest.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of PHP CS Fixer.
  5. *
  6. * (c) Fabien Potencier <fabien@symfony.com>
  7. * Dariusz Rumiński <dariusz.ruminski@gmail.com>
  8. *
  9. * This source file is subject to the MIT license that is bundled
  10. * with this source code in the file LICENSE.
  11. */
  12. namespace PhpCsFixer\Tests\Fixer\StringNotation;
  13. use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
  14. /**
  15. * @author Filippo Tessarotto <zoeslam@gmail.com>
  16. *
  17. * @internal
  18. *
  19. * @covers \PhpCsFixer\Fixer\StringNotation\EscapeImplicitBackslashesFixer
  20. *
  21. * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\StringNotation\EscapeImplicitBackslashesFixer>
  22. *
  23. * @phpstan-import-type _AutogeneratedInputConfiguration from \PhpCsFixer\Fixer\StringNotation\EscapeImplicitBackslashesFixer
  24. */
  25. final class EscapeImplicitBackslashesFixerTest extends AbstractFixerTestCase
  26. {
  27. /**
  28. * @param _AutogeneratedInputConfiguration $configuration
  29. *
  30. * @dataProvider provideFixCases
  31. */
  32. public function testFix(string $expected, ?string $input = null, array $configuration = []): void
  33. {
  34. $this->fixer->configure($configuration);
  35. $this->doTest($expected, $input);
  36. }
  37. public static function provideFixCases(): iterable
  38. {
  39. yield [
  40. <<<'EOF'
  41. <?php $var = 'String (\\\'\r\n\x0) for My\Prefix\\';
  42. EOF,
  43. ];
  44. yield [
  45. <<<'EOF'
  46. <?php $var = 'String (\\\'\\r\\n\\x0) for My\\Prefix\\';
  47. EOF,
  48. <<<'EOF'
  49. <?php $var = 'String (\\\'\r\n\x0) for My\Prefix\\';
  50. EOF,
  51. ['single_quoted' => true],
  52. ];
  53. yield [
  54. <<<'EOF'
  55. <?php
  56. $var = "\\A\\B\\C\\D\\E\\F\\G\\H\\I\\J\\K\\L\\M\\N\\O\\P\\Q\\R\\S\\T\\U\\V\\W\\X\\Y\\Z";
  57. $var = "\\a\\b\\c\\d\\g\\h\\i\\j\\k\\l\\m\\o\\p\\q\\s\\w\\y\\z \\' \\8\\9 \\xZ \\u";
  58. $var = "$foo \\A \\a \\' \\8\\9 \\xZ \\u ${bar}";
  59. $var = <<<HEREDOC_SYNTAX
  60. \\A\\B\\C\\D\\E\\F\\G\\H\\I\\J\\K\\L\\M\\N\\O\\P\\Q\\R\\S\\T\\U\\V\\W\\X\\Y\\Z
  61. \\a\\b\\c\\d\\g\\h\\i\\j\\k\\l\\m\\o\\p\\q\\s\\w\\y\\z
  62. \\"
  63. \\'
  64. \\8\\9
  65. \\xZ
  66. \\u
  67. HEREDOC_SYNTAX;
  68. $var = <<<HEREDOC_SYNTAX
  69. $foo \\A \\a \\" \\' \\8\\9 \\xZ \\u ${bar}
  70. HEREDOC_SYNTAX;
  71. $var = <<<'NOWDOC_SYNTAX'
  72. \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
  73. \a\b\c\d\g\h\i\j\k\l\m\o\p\q\s\w\y\z
  74. \'
  75. \8\9
  76. \xZ
  77. \u
  78. NOWDOC_SYNTAX;
  79. EOF,
  80. <<<'EOF'
  81. <?php
  82. $var = "\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z";
  83. $var = "\a\b\c\d\g\h\i\j\k\l\m\o\p\q\s\w\y\z \' \8\9 \xZ \u";
  84. $var = "$foo \A \a \' \8\9 \xZ \u ${bar}";
  85. $var = <<<HEREDOC_SYNTAX
  86. \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
  87. \a\b\c\d\g\h\i\j\k\l\m\o\p\q\s\w\y\z
  88. \"
  89. \'
  90. \8\9
  91. \xZ
  92. \u
  93. HEREDOC_SYNTAX;
  94. $var = <<<HEREDOC_SYNTAX
  95. $foo \A \a \" \' \8\9 \xZ \u ${bar}
  96. HEREDOC_SYNTAX;
  97. $var = <<<'NOWDOC_SYNTAX'
  98. \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
  99. \a\b\c\d\g\h\i\j\k\l\m\o\p\q\s\w\y\z
  100. \'
  101. \8\9
  102. \xZ
  103. \u
  104. NOWDOC_SYNTAX;
  105. EOF,
  106. ];
  107. yield [
  108. <<<'EOF'
  109. <?php
  110. $var = "\e\f\n\r\t\v \\ \$ \"";
  111. $var = "$foo \e\f\n\r\t\v \\ \$ \" ${bar}";
  112. $var = <<<HEREDOC_SYNTAX
  113. \e\f\n\r\t\v \\ \$
  114. HEREDOC_SYNTAX;
  115. $var = <<<HEREDOC_SYNTAX
  116. $foo \e\f\n\r\t\v \\ \$ ${bar}
  117. HEREDOC_SYNTAX;
  118. EOF,
  119. ];
  120. yield [
  121. <<<'EOF'
  122. <?php
  123. $var = "\0 \00 \000 \0000 \00000";
  124. $var = "$foo \0 \00 \000 \0000 \00000 ${bar}";
  125. $var = <<<HEREDOC_SYNTAX
  126. \0 \00 \000 \0000 \00000
  127. HEREDOC_SYNTAX;
  128. $var = <<<HEREDOC_SYNTAX
  129. $foo \0 \00 \000 \0000 \00000 ${bar}
  130. HEREDOC_SYNTAX;
  131. EOF,
  132. ];
  133. yield [
  134. <<<'EOF'
  135. <?php
  136. $var = "\xA \x99 \u{0}";
  137. $var = "$foo \xA \x99 \u{0} ${bar}";
  138. $var = <<<HEREDOC_SYNTAX
  139. \xA \x99 \u{0}
  140. HEREDOC_SYNTAX;
  141. $var = <<<HEREDOC_SYNTAX
  142. $foo \xA \x99 \u{0} ${bar}
  143. HEREDOC_SYNTAX;
  144. EOF,
  145. ];
  146. yield [
  147. <<<'EOF'
  148. <?php
  149. $var = 'backslash \\ already escaped';
  150. $var = 'code coverage';
  151. $var = "backslash \\ already escaped";
  152. $var = "code coverage";
  153. $var = <<<HEREDOC_SYNTAX
  154. backslash \\ already escaped
  155. HEREDOC_SYNTAX;
  156. $var = <<<HEREDOC_SYNTAX
  157. code coverage
  158. HEREDOC_SYNTAX;
  159. $var = <<<'NOWDOC_SYNTAX'
  160. backslash \\ already escaped
  161. NOWDOC_SYNTAX;
  162. $var = <<<'NOWDOC_SYNTAX'
  163. code coverage
  164. NOWDOC_SYNTAX;
  165. EOF,
  166. ];
  167. yield [
  168. <<<'EOF'
  169. <?php
  170. $var = "\A\a \' \8\9 \xZ \u";
  171. $var = "$foo \A\a \' \8\9 \xZ \u ${bar}";
  172. EOF,
  173. null,
  174. ['double_quoted' => false],
  175. ];
  176. yield [
  177. <<<'EOF'
  178. <?php
  179. $var = <<<HEREDOC_SYNTAX
  180. \A\Z
  181. \a\z
  182. \'
  183. \8\9
  184. \xZ
  185. \u
  186. HEREDOC_SYNTAX;
  187. $var = <<<HEREDOC_SYNTAX
  188. $foo
  189. \A\Z
  190. \a\z
  191. \'
  192. \8\9
  193. \xZ
  194. \u
  195. ${bar}
  196. HEREDOC_SYNTAX;
  197. EOF,
  198. null,
  199. ['heredoc_syntax' => false],
  200. ];
  201. yield [
  202. <<<'EOF'
  203. <?php $var = b'String (\\\'\r\n\x0) for My\Prefix\\';
  204. EOF,
  205. ];
  206. yield [
  207. <<<'EOF'
  208. <?php $var = b'String (\\\'\\r\\n\\x0) for My\\Prefix\\';
  209. EOF,
  210. <<<'EOF'
  211. <?php $var = b'String (\\\'\r\n\x0) for My\Prefix\\';
  212. EOF,
  213. ['single_quoted' => true],
  214. ];
  215. yield [
  216. <<<'EOF'
  217. <?php
  218. $var = b"\\A\\B\\C\\D\\E\\F\\G\\H\\I\\J\\K\\L\\M\\N\\O\\P\\Q\\R\\S\\T\\U\\V\\W\\X\\Y\\Z";
  219. $var = b"\\a\\b\\c\\d\\g\\h\\i\\j\\k\\l\\m\\o\\p\\q\\s\\w\\y\\z \\' \\8\\9 \\xZ \\u";
  220. $var = b"$foo \\A \\a \\' \\8\\9 \\xZ \\u ${bar}";
  221. $var = b<<<HEREDOC_SYNTAX
  222. \\A\\B\\C\\D\\E\\F\\G\\H\\I\\J\\K\\L\\M\\N\\O\\P\\Q\\R\\S\\T\\U\\V\\W\\X\\Y\\Z
  223. \\a\\b\\c\\d\\g\\h\\i\\j\\k\\l\\m\\o\\p\\q\\s\\w\\y\\z
  224. \\"
  225. \\'
  226. \\8\\9
  227. \\xZ
  228. \\u
  229. HEREDOC_SYNTAX;
  230. $var = b<<<HEREDOC_SYNTAX
  231. $foo \\A \\a \\" \\' \\8\\9 \\xZ \\u ${bar}
  232. HEREDOC_SYNTAX;
  233. $var = b<<<'NOWDOC_SYNTAX'
  234. \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
  235. \a\b\c\d\g\h\i\j\k\l\m\o\p\q\s\w\y\z
  236. \'
  237. \8\9
  238. \xZ
  239. \u
  240. NOWDOC_SYNTAX;
  241. EOF,
  242. <<<'EOF'
  243. <?php
  244. $var = b"\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z";
  245. $var = b"\a\b\c\d\g\h\i\j\k\l\m\o\p\q\s\w\y\z \' \8\9 \xZ \u";
  246. $var = b"$foo \A \a \' \8\9 \xZ \u ${bar}";
  247. $var = b<<<HEREDOC_SYNTAX
  248. \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
  249. \a\b\c\d\g\h\i\j\k\l\m\o\p\q\s\w\y\z
  250. \"
  251. \'
  252. \8\9
  253. \xZ
  254. \u
  255. HEREDOC_SYNTAX;
  256. $var = b<<<HEREDOC_SYNTAX
  257. $foo \A \a \" \' \8\9 \xZ \u ${bar}
  258. HEREDOC_SYNTAX;
  259. $var = b<<<'NOWDOC_SYNTAX'
  260. \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
  261. \a\b\c\d\g\h\i\j\k\l\m\o\p\q\s\w\y\z
  262. \'
  263. \8\9
  264. \xZ
  265. \u
  266. NOWDOC_SYNTAX;
  267. EOF,
  268. ];
  269. yield [
  270. <<<'EOF'
  271. <?php
  272. $var = b"\e\f\n\r\t\v \\ \$ \"";
  273. $var = b"$foo \e\f\n\r\t\v \\ \$ \" ${bar}";
  274. $var = b<<<HEREDOC_SYNTAX
  275. \e\f\n\r\t\v \\ \$
  276. HEREDOC_SYNTAX;
  277. $var = b<<<HEREDOC_SYNTAX
  278. $foo \e\f\n\r\t\v \\ \$ ${bar}
  279. HEREDOC_SYNTAX;
  280. EOF,
  281. ];
  282. yield [
  283. <<<'EOF'
  284. <?php
  285. $var = b"\0 \00 \000 \0000 \00000";
  286. $var = b"$foo \0 \00 \000 \0000 \00000 ${bar}";
  287. $var = b<<<HEREDOC_SYNTAX
  288. \0 \00 \000 \0000 \00000
  289. HEREDOC_SYNTAX;
  290. $var = b<<<HEREDOC_SYNTAX
  291. $foo \0 \00 \000 \0000 \00000 ${bar}
  292. HEREDOC_SYNTAX;
  293. EOF,
  294. ];
  295. yield [
  296. <<<'EOF'
  297. <?php
  298. $var = b"\xA \x99 \u{0}";
  299. $var = b"$foo \xA \x99 \u{0} ${bar}";
  300. $var = b<<<HEREDOC_SYNTAX
  301. \xA \x99 \u{0}
  302. HEREDOC_SYNTAX;
  303. $var = b<<<HEREDOC_SYNTAX
  304. $foo \xA \x99 \u{0} ${bar}
  305. HEREDOC_SYNTAX;
  306. EOF,
  307. ];
  308. yield [
  309. <<<'EOF'
  310. <?php
  311. $var = b'backslash \\ already escaped';
  312. $var = b'code coverage';
  313. $var = b"backslash \\ already escaped";
  314. $var = b"code coverage";
  315. $var = b<<<HEREDOC_SYNTAX
  316. backslash \\ already escaped
  317. HEREDOC_SYNTAX;
  318. $var = b<<<HEREDOC_SYNTAX
  319. code coverage
  320. HEREDOC_SYNTAX;
  321. $var = b<<<'NOWDOC_SYNTAX'
  322. backslash \\ already escaped
  323. NOWDOC_SYNTAX;
  324. $var = b<<<'NOWDOC_SYNTAX'
  325. code coverage
  326. NOWDOC_SYNTAX;
  327. EOF,
  328. ];
  329. yield [
  330. <<<'EOF'
  331. <?php
  332. $var = b"\A\a \' \8\9 \xZ \u";
  333. $var = b"$foo \A\a \' \8\9 \xZ \u ${bar}";
  334. EOF,
  335. null,
  336. ['double_quoted' => false],
  337. ];
  338. yield [
  339. <<<'EOF'
  340. <?php
  341. $var = b<<<HEREDOC_SYNTAX
  342. \A\Z
  343. \a\z
  344. \'
  345. \8\9
  346. \xZ
  347. \u
  348. HEREDOC_SYNTAX;
  349. $var = b<<<HEREDOC_SYNTAX
  350. $foo
  351. \A\Z
  352. \a\z
  353. \'
  354. \8\9
  355. \xZ
  356. \u
  357. ${bar}
  358. HEREDOC_SYNTAX;
  359. EOF,
  360. null,
  361. ['heredoc_syntax' => false],
  362. ];
  363. yield [
  364. <<<'EOF'
  365. <?php $var = B'String (\\\'\r\n\x0) for My\Prefix\\';
  366. EOF,
  367. ];
  368. yield [
  369. <<<'EOF'
  370. <?php $var = B'String (\\\'\\r\\n\\x0) for My\\Prefix\\';
  371. EOF,
  372. <<<'EOF'
  373. <?php $var = B'String (\\\'\r\n\x0) for My\Prefix\\';
  374. EOF,
  375. ['single_quoted' => true],
  376. ];
  377. yield [
  378. <<<'EOF'
  379. <?php
  380. $var = B"\\A\\B\\C\\D\\E\\F\\G\\H\\I\\J\\K\\L\\M\\N\\O\\P\\Q\\R\\S\\T\\U\\V\\W\\X\\Y\\Z";
  381. $var = B"\\a\\b\\c\\d\\g\\h\\i\\j\\k\\l\\m\\o\\p\\q\\s\\w\\y\\z \\' \\8\\9 \\xZ \\u";
  382. $var = B"$foo \\A \\a \\' \\8\\9 \\xZ \\u ${bar}";
  383. $var = B<<<HEREDOC_SYNTAX
  384. \\A\\B\\C\\D\\E\\F\\G\\H\\I\\J\\K\\L\\M\\N\\O\\P\\Q\\R\\S\\T\\U\\V\\W\\X\\Y\\Z
  385. \\a\\b\\c\\d\\g\\h\\i\\j\\k\\l\\m\\o\\p\\q\\s\\w\\y\\z
  386. \\"
  387. \\'
  388. \\8\\9
  389. \\xZ
  390. \\u
  391. HEREDOC_SYNTAX;
  392. $var = B<<<HEREDOC_SYNTAX
  393. $foo \\A \\a \\" \\' \\8\\9 \\xZ \\u ${bar}
  394. HEREDOC_SYNTAX;
  395. $var = B<<<'NOWDOC_SYNTAX'
  396. \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
  397. \a\b\c\d\g\h\i\j\k\l\m\o\p\q\s\w\y\z
  398. \'
  399. \8\9
  400. \xZ
  401. \u
  402. NOWDOC_SYNTAX;
  403. EOF,
  404. <<<'EOF'
  405. <?php
  406. $var = B"\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z";
  407. $var = B"\a\b\c\d\g\h\i\j\k\l\m\o\p\q\s\w\y\z \' \8\9 \xZ \u";
  408. $var = B"$foo \A \a \' \8\9 \xZ \u ${bar}";
  409. $var = B<<<HEREDOC_SYNTAX
  410. \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
  411. \a\b\c\d\g\h\i\j\k\l\m\o\p\q\s\w\y\z
  412. \"
  413. \'
  414. \8\9
  415. \xZ
  416. \u
  417. HEREDOC_SYNTAX;
  418. $var = B<<<HEREDOC_SYNTAX
  419. $foo \A \a \" \' \8\9 \xZ \u ${bar}
  420. HEREDOC_SYNTAX;
  421. $var = B<<<'NOWDOC_SYNTAX'
  422. \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
  423. \a\b\c\d\g\h\i\j\k\l\m\o\p\q\s\w\y\z
  424. \'
  425. \8\9
  426. \xZ
  427. \u
  428. NOWDOC_SYNTAX;
  429. EOF,
  430. ];
  431. yield [
  432. <<<'EOF'
  433. <?php
  434. $var = B"\e\f\n\r\t\v \\ \$ \"";
  435. $var = B"$foo \e\f\n\r\t\v \\ \$ \" ${bar}";
  436. $var = B<<<HEREDOC_SYNTAX
  437. \e\f\n\r\t\v \\ \$
  438. HEREDOC_SYNTAX;
  439. $var = B<<<HEREDOC_SYNTAX
  440. $foo \e\f\n\r\t\v \\ \$ ${bar}
  441. HEREDOC_SYNTAX;
  442. EOF,
  443. ];
  444. yield [
  445. <<<'EOF'
  446. <?php
  447. $var = B"\0 \00 \000 \0000 \00000";
  448. $var = B"$foo \0 \00 \000 \0000 \00000 ${bar}";
  449. $var = B<<<HEREDOC_SYNTAX
  450. \0 \00 \000 \0000 \00000
  451. HEREDOC_SYNTAX;
  452. $var = B<<<HEREDOC_SYNTAX
  453. $foo \0 \00 \000 \0000 \00000 ${bar}
  454. HEREDOC_SYNTAX;
  455. EOF,
  456. ];
  457. yield [
  458. <<<'EOF'
  459. <?php
  460. $var = B"\xA \x99 \u{0}";
  461. $var = B"$foo \xA \x99 \u{0} ${bar}";
  462. $var = B<<<HEREDOC_SYNTAX
  463. \xA \x99 \u{0}
  464. HEREDOC_SYNTAX;
  465. $var = B<<<HEREDOC_SYNTAX
  466. $foo \xA \x99 \u{0} ${bar}
  467. HEREDOC_SYNTAX;
  468. EOF,
  469. ];
  470. yield [
  471. <<<'EOF'
  472. <?php
  473. $var = B'backslash \\ already escaped';
  474. $var = B'code coverage';
  475. $var = B"backslash \\ already escaped";
  476. $var = B"code coverage";
  477. $var = B<<<HEREDOC_SYNTAX
  478. backslash \\ already escaped
  479. HEREDOC_SYNTAX;
  480. $var = B<<<HEREDOC_SYNTAX
  481. code coverage
  482. HEREDOC_SYNTAX;
  483. $var = B<<<'NOWDOC_SYNTAX'
  484. backslash \\ already escaped
  485. NOWDOC_SYNTAX;
  486. $var = B<<<'NOWDOC_SYNTAX'
  487. code coverage
  488. NOWDOC_SYNTAX;
  489. EOF,
  490. ];
  491. yield [
  492. <<<'EOF'
  493. <?php
  494. $var = B"\A\a \' \8\9 \xZ \u";
  495. $var = B"$foo \A\a \' \8\9 \xZ \u ${bar}";
  496. EOF,
  497. null,
  498. ['double_quoted' => false],
  499. ];
  500. yield [
  501. <<<'EOF'
  502. <?php
  503. $var = B<<<HEREDOC_SYNTAX
  504. \A\Z
  505. \a\z
  506. \'
  507. \8\9
  508. \xZ
  509. \u
  510. HEREDOC_SYNTAX;
  511. $var = B<<<HEREDOC_SYNTAX
  512. $foo
  513. \A\Z
  514. \a\z
  515. \'
  516. \8\9
  517. \xZ
  518. \u
  519. ${bar}
  520. HEREDOC_SYNTAX;
  521. EOF,
  522. null,
  523. ['heredoc_syntax' => false],
  524. ];
  525. yield [
  526. <<<'EOF'
  527. <?php
  528. $var = "\\bar";
  529. $var = "\\bar";
  530. $var = "\\\\bar";
  531. $var = "\\\\bar";
  532. $var = "\\\\\\bar";
  533. $var = "\\\\\\bar";
  534. EOF,
  535. <<<'EOF'
  536. <?php
  537. $var = "\bar";
  538. $var = "\\bar";
  539. $var = "\\\bar";
  540. $var = "\\\\bar";
  541. $var = "\\\\\bar";
  542. $var = "\\\\\\bar";
  543. EOF,
  544. ];
  545. yield [
  546. <<<'EOF'
  547. <?php
  548. $var = '\\bar';
  549. $var = '\\bar';
  550. $var = '\\\\bar';
  551. $var = '\\\\bar';
  552. $var = '\\\\\\bar';
  553. $var = '\\\\\\bar';
  554. EOF,
  555. <<<'EOF'
  556. <?php
  557. $var = '\bar';
  558. $var = '\\bar';
  559. $var = '\\\bar';
  560. $var = '\\\\bar';
  561. $var = '\\\\\bar';
  562. $var = '\\\\\\bar';
  563. EOF,
  564. ['single_quoted' => true],
  565. ];
  566. yield [
  567. <<<'EOF'
  568. <?php
  569. $var = <<<TXT
  570. \\bar
  571. \\bar
  572. \\\\bar
  573. \\\\bar
  574. \\\\\\bar
  575. \\\\\\bar
  576. TXT;
  577. EOF,
  578. <<<'EOF'
  579. <?php
  580. $var = <<<TXT
  581. \bar
  582. \\bar
  583. \\\bar
  584. \\\\bar
  585. \\\\\bar
  586. \\\\\\bar
  587. TXT;
  588. EOF,
  589. ];
  590. yield [
  591. <<<'EOF'
  592. <?php
  593. $var = <<<'TXT'
  594. \bar
  595. \\bar
  596. \\\bar
  597. \\\\bar
  598. \\\\\bar
  599. \\\\\\bar
  600. TXT;
  601. EOF,
  602. ];
  603. }
  604. }