]> khamidou — GitHub mirrors - arcanist.git/commit
Raise a lint warning on array_combine(x, x)
authorepriestley <git@epriestley.com>
Sat, 26 Jan 2013 01:06:49 +0000 (17:06 -0800)
committerepriestley <git@epriestley.com>
Sat, 26 Jan 2013 01:06:49 +0000 (17:06 -0800)
commit44e25495ca9125b72e9e0287c2ed1cfed8b26bf7
tree9ee8a143594a98a0f1b06ca436ce41c81330b84c
parent9946e23f9ea7a545efa8285c2d2e5a1e3e51b7fc
Raise a lint warning on array_combine(x, x)

Summary: Suggest array_fuse().

Test Plan:
Unit tests, and:

  $ arc lint --lintall src/unit/engine/phutil/ArcanistPhutilTestCase.php
  >>> Lint for src/unit/engine/phutil/ArcanistPhutilTestCase.php:

     Warning  (XHP37) array_combine() Unreliable
      Prior to PHP 5.4, array_combine() fails when given empty arrays. Prefer
      to write array_combine(x, x) as array_fuse(x).

               252     $callable,
               253     $exception_class = 'Exception') {
               254     return $this->tryTestCases(
      >>>      255       array_combine(array_keys($map), array_keys($map)),
               256       array_values($map),
               257       $callable,
               258       $exception_class);

Reviewers: btrahan, vrana, chad

Reviewed By: btrahan

CC: aran
Differential Revision: https://secure.phabricator.com/D4659
src/lint/engine/PhutilLintEngine.php
src/lint/linter/ArcanistXHPASTLinter.php
src/lint/linter/__tests__/xhpast/array-combine.lint-test [new file with mode: 0644]
src/unit/engine/phutil/ArcanistPhutilTestCase.php