]> khamidou — GitHub mirrors - arcanist.git/commit
Add a linter rule to prevent the __lambda_func function from being redeclared
authorJoshua Spence <josh@joshuaspence.com>
Sun, 17 May 2015 22:23:48 +0000 (08:23 +1000)
committerJoshua Spence <josh@joshuaspence.com>
Sun, 17 May 2015 22:24:49 +0000 (08:24 +1000)
commit2422202ba4298b3b53433954ae98cc22f5eb36de
tree88c5d5cd1ec6419b3396d7a7b28178f1c78ba4e5
parent1e3073a4f88e92159f797e34c716fd09ad17d7fa
Add a linter rule to prevent the __lambda_func function from being redeclared

Summary:
See http://phpsadness.com/sad/39. Declaring a function named `__lambda_func` prevents the `create_function` function from working. This is because `create_function` eval-declares the function `__lambda_func`, then modifies the symbol table so that the function is instead named `"\0lambda_".(++$i)`, and returns that name.

NOTE: Personally, I don't think that anyone should use `create_function`. However, despite this, I think it is reasonable that no function is named `__lambda_func` in case some external library relies on `create_function`.

Test Plan: Added test case.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D12870
src/lint/linter/ArcanistXHPASTLinter.php
src/lint/linter/__tests__/xhpast/lamba-func-function.lint-test [new file with mode: 0644]