diff --git a/src/filesystem/Filesystem.php b/src/filesystem/Filesystem.php --- a/src/filesystem/Filesystem.php +++ b/src/filesystem/Filesystem.php @@ -1119,7 +1119,7 @@ } public static function concatenatePaths(array $components) { - $components = implode($components, DIRECTORY_SEPARATOR); + $components = implode(DIRECTORY_SEPARATOR, $components); // Replace any extra sequences of directory separators with a single // separator, so we don't end up with "path//to///thing.c". diff --git a/src/lint/linter/xhpast/rules/ArcanistImplodeArgumentOrderXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistImplodeArgumentOrderXHPASTLinterRule.php --- a/src/lint/linter/xhpast/rules/ArcanistImplodeArgumentOrderXHPASTLinterRule.php +++ b/src/lint/linter/xhpast/rules/ArcanistImplodeArgumentOrderXHPASTLinterRule.php @@ -23,7 +23,17 @@ } $parameter = $parameters->getChildByIndex(1); - if (!$parameter->isStaticScalar()) { + + // If the value is a static scalar, like a string literal, it's probably + // the glue. + $is_scalar = $parameter->isStaticScalar(); + + // If the value is a constant, like "DIRECTORY_SEPARATOR", it's probably + // the glue. + $is_constant = ($parameter->getTypeName() === 'n_SYMBOL_NAME'); + + $looks_like_glue = ($is_scalar || $is_constant); + if (!$looks_like_glue) { continue; } diff --git a/src/lint/linter/xhpast/rules/__tests__/implode-argument-order/implode.lint-test b/src/lint/linter/xhpast/rules/__tests__/implode-argument-order/implode.lint-test --- a/src/lint/linter/xhpast/rules/__tests__/implode-argument-order/implode.lint-test +++ b/src/lint/linter/xhpast/rules/__tests__/implode-argument-order/implode.lint-test @@ -14,5 +14,10 @@ implode($x); implode($x, $y, $z); +// This should raise a warning by guessing that "DIRECTORY_SEPARATOR" is +// glue. +implode($path_list, DIRECTORY_SEPARATOR); + ~~~~~~~~~~ error:7:1:XHP129:Implode With Glue First +error:19:1:XHP129:Implode With Glue First diff --git a/src/workflow/ArcanistCloseWorkflow.php b/src/workflow/ArcanistCloseWorkflow.php --- a/src/workflow/ArcanistCloseWorkflow.php +++ b/src/workflow/ArcanistCloseWorkflow.php @@ -90,7 +90,7 @@ "%s\n", pht( "Valid status options are:\n\t%s", - implode($this->getStatusOptions(), ', '))); + implode(', ', $this->getStatusOptions()))); return 0; } $ids = $this->getArgument('task_id');