From 28f5b0ddc6bb3dd94837af87818a81e6d3fb037d Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Thu, 26 Nov 2015 06:18:19 +1100 Subject: [PATCH] Fix a compatibility issue with `ArcanistUnsafeDynamicStringXHPASTLinterRule` Summary: A user reported to me that `arc lint` was failing with an error message along the lines of "argument 1 passed to `idx` must be of type array, bool given". I suspect that the user is running an older version of PHP, which means that `array_combine(array(), array())` is returning `false` instead of the expected `array()`. Instead, avoid calling `array_combine` on an empty array. Test Plan: I don't have PHP 5.3 easily accessible to test this. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D14567 --- .../rules/ArcanistUnsafeDynamicStringXHPASTLinterRule.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lint/linter/xhpast/rules/ArcanistUnsafeDynamicStringXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistUnsafeDynamicStringXHPASTLinterRule.php index 2cd343bf..bf3c8e51 100644 --- a/src/lint/linter/xhpast/rules/ArcanistUnsafeDynamicStringXHPASTLinterRule.php +++ b/src/lint/linter/xhpast/rules/ArcanistUnsafeDynamicStringXHPASTLinterRule.php @@ -70,9 +70,11 @@ final class ArcanistUnsafeDynamicStringXHPASTLinterRule AASTNodeList $calls, array $safe) { - $safe = array_combine( - array_map('strtolower', array_keys($safe)), - $safe); + if ($safe) { + $safe = array_combine( + array_map('strtolower', array_keys($safe)), + $safe); + } foreach ($calls as $call) { $name = $call->getChildByIndex(0)->getConcreteString(); -- 2.43.0