mirror of
https://we.phorge.it/source/arcanist.git
synced 2025-02-02 09:58:23 +01:00
Add lint warnings about use of phutil_render_tag and javelin_render_tag
Summary: Raise deprecation warnings for these methods. I won't commit this until the phutil_tag branch merges. Test Plan: Unit tests. Reviewers: vrana Reviewed By: vrana CC: aran Maniphest Tasks: T2432 Differential Revision: https://secure.phabricator.com/D4770
This commit is contained in:
parent
ca37bfb2ab
commit
38d23516d1
2 changed files with 45 additions and 2 deletions
|
@ -7,6 +7,7 @@ final class ArcanistPhutilXHPASTLinter extends ArcanistBaseXHPASTLinter {
|
||||||
|
|
||||||
const LINT_PHT_WITH_DYNAMIC_STRING = 1;
|
const LINT_PHT_WITH_DYNAMIC_STRING = 1;
|
||||||
const LINT_ARRAY_COMBINE = 2;
|
const LINT_ARRAY_COMBINE = 2;
|
||||||
|
const LINT_DEPRECATED_FUNCTION = 3;
|
||||||
const LINT_UNSAFE_DYNAMIC_STRING = 4;
|
const LINT_UNSAFE_DYNAMIC_STRING = 4;
|
||||||
|
|
||||||
private $xhpastLinter;
|
private $xhpastLinter;
|
||||||
|
@ -29,15 +30,16 @@ final class ArcanistPhutilXHPASTLinter extends ArcanistBaseXHPASTLinter {
|
||||||
return array(
|
return array(
|
||||||
self::LINT_PHT_WITH_DYNAMIC_STRING => 'Use of pht() on Dynamic String',
|
self::LINT_PHT_WITH_DYNAMIC_STRING => 'Use of pht() on Dynamic String',
|
||||||
self::LINT_ARRAY_COMBINE => 'array_combine() Unreliable',
|
self::LINT_ARRAY_COMBINE => 'array_combine() Unreliable',
|
||||||
|
self::LINT_DEPRECATED_FUNCTION => 'Use of deprecated function',
|
||||||
self::LINT_UNSAFE_DYNAMIC_STRING => 'Unsafe Usage of Dynamic String',
|
self::LINT_UNSAFE_DYNAMIC_STRING => 'Unsafe Usage of Dynamic String',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLintSeverityMap() {
|
public function getLintSeverityMap() {
|
||||||
$warning = ArcanistLintSeverity::SEVERITY_WARNING;
|
$warning = ArcanistLintSeverity::SEVERITY_WARNING;
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
self::LINT_ARRAY_COMBINE => $warning,
|
self::LINT_ARRAY_COMBINE => $warning,
|
||||||
|
self::LINT_DEPRECATED_FUNCTION => $warning,
|
||||||
self::LINT_UNSAFE_DYNAMIC_STRING => $warning,
|
self::LINT_UNSAFE_DYNAMIC_STRING => $warning,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -47,7 +49,7 @@ final class ArcanistPhutilXHPASTLinter extends ArcanistBaseXHPASTLinter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCacheVersion() {
|
public function getCacheVersion() {
|
||||||
return 1;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function willLintPaths(array $paths) {
|
public function willLintPaths(array $paths) {
|
||||||
|
@ -65,6 +67,7 @@ final class ArcanistPhutilXHPASTLinter extends ArcanistBaseXHPASTLinter {
|
||||||
$this->lintPHT($root);
|
$this->lintPHT($root);
|
||||||
$this->lintArrayCombine($root);
|
$this->lintArrayCombine($root);
|
||||||
$this->lintUnsafeDynamicString($root);
|
$this->lintUnsafeDynamicString($root);
|
||||||
|
$this->lintDeprecatedFunctions($root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -179,4 +182,38 @@ final class ArcanistPhutilXHPASTLinter extends ArcanistBaseXHPASTLinter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function lintDeprecatedFunctions($root) {
|
||||||
|
$map = array(
|
||||||
|
// Silly; for unit testing.
|
||||||
|
'deprecated_function' => 'This function is most likely deprecated.',
|
||||||
|
|
||||||
|
'phutil_render_tag' =>
|
||||||
|
'The phutil_render_tag() function is deprecated and unsafe. '.
|
||||||
|
'Use phutil_tag() instead.',
|
||||||
|
|
||||||
|
'javelin_render_tag' =>
|
||||||
|
'The javelin_render_tag() function is deprecated and unsafe. '.
|
||||||
|
'Use javelin_tag() instead.',
|
||||||
|
|
||||||
|
'phabricator_render_form' =>
|
||||||
|
'The phabricator_render_form() function is deprecated and unsafe. '.
|
||||||
|
'Use phabricator_form() instead.',
|
||||||
|
);
|
||||||
|
|
||||||
|
$function_calls = $root->selectDescendantsOfType('n_FUNCTION_CALL');
|
||||||
|
foreach ($function_calls as $call) {
|
||||||
|
$name = $call->getChildByIndex(0)->getConcreteString();
|
||||||
|
|
||||||
|
$name = strtolower($name);
|
||||||
|
if (empty($map[$name])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->raiseLintAtNode(
|
||||||
|
$call,
|
||||||
|
self::LINT_DEPRECATED_FUNCTION,
|
||||||
|
$map[$name]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
deprecated_function();
|
||||||
|
modern_function();
|
||||||
|
~~~~~~~~~~
|
||||||
|
warning:3:1
|
Loading…
Add table
Reference in a new issue