PageRenderTime 47ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/protected/vendor/fabpot/php-cs-fixer/Symfony/CS/Tests/Fixer/Symfony/PhpdocToCommentFixerTest.php

https://gitlab.com/I-NOZex/quiz
PHP | 472 lines | 422 code | 32 blank | 18 comment | 0 complexity | 14cee2583d6f21f39de31d35cd745749 MD5 | raw file
  1. <?php
  2. /*
  3. * This file is part of the PHP CS utility.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace Symfony\CS\Tests\Fixer\Symfony;
  11. use Symfony\CS\Tests\Fixer\AbstractFixerTestBase;
  12. /**
  13. * @author Ceeram <ceeram@cakephp.org>
  14. */
  15. class PhpdocToCommentFixerTest extends AbstractFixerTestBase
  16. {
  17. /**
  18. * @dataProvider provideDocblocks
  19. */
  20. public function testFix($expected, $input = null)
  21. {
  22. $this->makeTest($expected, $input);
  23. }
  24. /**
  25. * @requires PHP 5.4
  26. * @dataProvider provideTraits
  27. */
  28. public function testFixTraits($expected, $input = null)
  29. {
  30. $this->makeTest($expected, $input);
  31. }
  32. public function provideDocblocks()
  33. {
  34. $cases = array();
  35. $cases[] = array(
  36. '<?php
  37. /**
  38. * Do not convert this
  39. */
  40. namespace Docs;
  41. /**
  42. * Do not convert this
  43. */
  44. class DocBlocks
  45. {
  46. /**
  47. * Do not convert this
  48. */
  49. const STRUCTURAL = true;
  50. /**
  51. * Do not convert this
  52. */
  53. protected $indent = false;
  54. /**
  55. * Do not convert this
  56. */
  57. public function test() {}
  58. /**
  59. * Do not convert this
  60. */
  61. private function testPrivate() {}
  62. /**
  63. * Do not convert this
  64. */
  65. function testNoVisibility() {}
  66. }',
  67. );
  68. $cases[] = array(
  69. '<?php namespace Docs;
  70. /**
  71. * Do not convert this
  72. */
  73. /**
  74. * Do not convert this
  75. */
  76. class DocBlocks{}
  77. ',
  78. );
  79. $cases[] = array(
  80. '<?php
  81. /**
  82. * Do not convert this
  83. */
  84. namespace Foo;
  85. ',
  86. );
  87. $cases[] = array(
  88. '<?php
  89. $first = true;// needed because by default first docblock is never fixed.
  90. /**
  91. * Do not convert this
  92. */
  93. abstract class DocBlocks
  94. {
  95. /**
  96. * Do not convert this
  97. */
  98. abstract public function test();
  99. }',
  100. );
  101. $cases[] = array(
  102. '<?php
  103. $first = true;// needed because by default first docblock is never fixed.
  104. /**
  105. * Do not convert this
  106. */
  107. interface DocBlocks
  108. {
  109. public function test();
  110. }',
  111. );
  112. $cases[] = array(
  113. '<?php
  114. namespace NS;
  115. /**
  116. * Do not
  117. */
  118. final class Foo
  119. {
  120. }',
  121. );
  122. $cases[] = array(
  123. '<?php
  124. $first = true;// needed because by default first docblock is never fixed.
  125. /**
  126. * Do not convert this
  127. */
  128. require "require.php";
  129. /**
  130. * Do not convert this
  131. */
  132. require_once "require_once.php";
  133. /**
  134. * Do not convert this
  135. */
  136. include "include.php";
  137. /**
  138. * Do not convert this
  139. */
  140. include_once "include_once.php";
  141. ',
  142. );
  143. $cases[] = array(
  144. '<?php
  145. $first = true;// needed because by default first docblock is never fixed.
  146. /**
  147. * Do not convert this
  148. *
  149. * @var bool $local
  150. */
  151. $local = true;
  152. ',
  153. );
  154. $cases[] = array(
  155. '<?php
  156. $first = true;// needed because by default first docblock is never fixed.
  157. /*
  158. * This should be a normal comment
  159. */
  160. $local = true;
  161. ',
  162. '<?php
  163. $first = true;// needed because by default first docblock is never fixed.
  164. /**
  165. * This should be a normal comment
  166. */
  167. $local = true;
  168. ',
  169. );
  170. $cases[] = array(
  171. '<?php
  172. $first = true;// needed because by default first docblock is never fixed.
  173. /** @var \Sqlite3 $sqlite */
  174. foreach($connections as $sqlite) {
  175. $sqlite->open($path);
  176. }',
  177. );
  178. $cases[] = array(
  179. '<?php
  180. $first = true;// needed because by default first docblock is never fixed.
  181. /** @var \Sqlite3 $sqlite */
  182. foreach($connections as $key => $sqlite) {
  183. $sqlite->open($path);
  184. }',
  185. );
  186. $cases[] = array(
  187. '<?php
  188. $first = true;// needed because by default first docblock is never fixed.
  189. /** @var int $key */
  190. foreach($connections as $key => $sqlite) {
  191. $sqlite->open($path);
  192. }',
  193. );
  194. $cases[] = array(
  195. '<?php
  196. $first = true;// needed because by default first docblock is never fixed.
  197. /* This should not be a docblock */
  198. foreach($connections as $key => $sqlite) {
  199. $sqlite->open($path);
  200. }',
  201. '<?php
  202. $first = true;// needed because by default first docblock is never fixed.
  203. /** This should not be a docblock */
  204. foreach($connections as $key => $sqlite) {
  205. $sqlite->open($path);
  206. }',
  207. );
  208. $cases[] = array(
  209. '<?php
  210. $first = true;// needed because by default first docblock is never fixed.
  211. /* there should be no docblock here */
  212. $sqlite1->open($path);
  213. ',
  214. '<?php
  215. $first = true;// needed because by default first docblock is never fixed.
  216. /** there should be no docblock here */
  217. $sqlite1->open($path);
  218. ',
  219. );
  220. $cases[] = array(
  221. '<?php
  222. $first = true;// needed because by default first docblock is never fixed.
  223. /* there should be no docblock here */
  224. $i++;
  225. ',
  226. '<?php
  227. $first = true;// needed because by default first docblock is never fixed.
  228. /** there should be no docblock here */
  229. $i++;
  230. ',
  231. );
  232. $cases[] = array(
  233. '<?php
  234. $first = true;// needed because by default first docblock is never fixed.
  235. /** @var int $index */
  236. $index = $a[\'number\'];
  237. ',
  238. );
  239. $cases[] = array(
  240. '<?php
  241. $first = true;// needed because by default first docblock is never fixed.
  242. /** @var string $two */
  243. list($one, $two) = explode("," , $csvLines);
  244. ',
  245. );
  246. $cases[] = array(
  247. '<?php
  248. $first = true;// needed because by default first docblock is never fixed.
  249. /* This should be a comment */
  250. list($one, $two) = explode("," , $csvLines);
  251. ',
  252. '<?php
  253. $first = true;// needed because by default first docblock is never fixed.
  254. /** This should be a comment */
  255. list($one, $two) = explode("," , $csvLines);
  256. ',
  257. );
  258. $cases[] = array(
  259. '<?php
  260. $first = true;// needed because by default first docblock is never fixed.
  261. /** @var int $index */
  262. foreach ($foo->getPairs($c->bar(), $bar) as $index => list($a, $b)) {
  263. // Do something with $index, $a and $b
  264. }
  265. /** @var \Closure $value */
  266. if (!$value = $this->getValue()) {
  267. return false;
  268. }
  269. /** @var string $name */
  270. switch ($name = $this->getName()) {
  271. case "John":
  272. return false;
  273. case "Jane":
  274. return true;
  275. }
  276. /** @var string $content */
  277. while ($content = $this->getContent()) {
  278. $name .= $content;
  279. }
  280. /** @var int $size */
  281. for($i = 0, $size = count($people); $i < $size; ++$i) {
  282. $people[$i][\'salt\'] = mt_rand(000000, 999999);
  283. }',
  284. );
  285. $cases[] = array(
  286. '<?php
  287. $first = true;// needed because by default first docblock is never fixed.
  288. /* @var int $wrong */
  289. foreach ($foo->getPairs($c->bar(), $bar) as $index => list($a, $b)) {
  290. // Do something with $index, $a and $b
  291. }
  292. /* @var \Closure $notValue */
  293. if (!$value = $this->getValue()) {
  294. return false;
  295. }
  296. /* @var string $notName */
  297. switch ($name = $this->getName()) {
  298. case "John":
  299. return false;
  300. case "Jane":
  301. return true;
  302. }
  303. /* @var string $notContent */
  304. while ($content = $this->getContent()) {
  305. $name .= $content;
  306. }
  307. /* @var int $notSize */
  308. for($i = 0, $size = count($people); $i < $size; ++$i) {
  309. $people[$i][\'salt\'] = mt_rand(000000, 999999);
  310. }',
  311. '<?php
  312. $first = true;// needed because by default first docblock is never fixed.
  313. /** @var int $wrong */
  314. foreach ($foo->getPairs($c->bar(), $bar) as $index => list($a, $b)) {
  315. // Do something with $index, $a and $b
  316. }
  317. /** @var \Closure $notValue */
  318. if (!$value = $this->getValue()) {
  319. return false;
  320. }
  321. /** @var string $notName */
  322. switch ($name = $this->getName()) {
  323. case "John":
  324. return false;
  325. case "Jane":
  326. return true;
  327. }
  328. /** @var string $notContent */
  329. while ($content = $this->getContent()) {
  330. $name .= $content;
  331. }
  332. /** @var int $notSize */
  333. for($i = 0, $size = count($people); $i < $size; ++$i) {
  334. $people[$i][\'salt\'] = mt_rand(000000, 999999);
  335. }',
  336. );
  337. $cases[] = array(
  338. '<?php
  339. /* This should be a comment */
  340. ',
  341. '<?php
  342. /** This should be a comment */
  343. ',
  344. );
  345. $cases[] = array(
  346. '<?php
  347. /**
  348. * This is a page level docblock should stay untouched
  349. */
  350. echo "Some string";
  351. ',
  352. );
  353. $cases[] = array(
  354. '<?php
  355. $first = true;// needed because by default first docblock is never fixed.
  356. /** @var \NumberFormatter $formatter */
  357. static $formatter;
  358. ',
  359. );
  360. $cases[] = array(
  361. '<?php
  362. $first = true;// needed because by default first docblock is never fixed.
  363. function getNumberFormatter()
  364. {
  365. /** @var \NumberFormatter $formatter */
  366. static $formatter;
  367. }
  368. ',
  369. );
  370. return $cases;
  371. }
  372. public function provideTraits()
  373. {
  374. return array(
  375. array(
  376. '<?php
  377. $first = true;// needed because by default first docblock is never fixed.
  378. /**
  379. * Do not convert this
  380. */
  381. trait DocBlocks
  382. {
  383. public function test() {}
  384. }',
  385. ),
  386. );
  387. }
  388. }