]> khamidou — GitHub mirrors - arcanist.git/commit
Detect iterator reuse in for() and foreach() loops
authorepriestley <git@epriestley.com>
Tue, 21 Jun 2011 00:59:20 +0000 (17:59 -0700)
committerepriestley <git@epriestley.com>
Thu, 23 Jun 2011 20:15:57 +0000 (13:15 -0700)
commit7efe723ff54c41dc97fa802bd3d3cd47b7b70b78
treec0330a161e86d1108cbb1709ca6caae07184e325
parentb6fb0f7a6b155f54947b6e3d56c691340ecc3f55
Detect iterator reuse in for() and foreach() loops

Summary:
cpojer fixed a JS instance of this in D481, but we can catch it in PHP with
XHPAST. Add a lint rule to fail if nested loops use the same iterator.

Test Plan:
Ran unit test.

Reviewed By: tomo
Reviewers: aran, pad, cpojer, jungejason, tuomaspelkonen, tomo
Commenters: cpojer
CC: aran, cpojer, epriestley, tomo
Differential Revision: 489
src/lint/linter/xhpast/ArcanistXHPASTLinter.php
src/lint/linter/xhpast/__tests__/data/reused-iterators.lint-test [new file with mode: 0644]