2011-01-10 00:22:25 +01:00
|
|
|
#!/usr/bin/env php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
2012-01-12 22:51:35 +01:00
|
|
|
* Copyright 2012 Facebook, Inc.
|
2011-01-10 00:22:25 +01:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
$builtin_classes = get_declared_classes();
|
|
|
|
$builtin_interfaces = get_declared_interfaces();
|
|
|
|
$builtin_functions = get_defined_functions();
|
|
|
|
$builtin_functions = $builtin_functions['internal'];
|
|
|
|
|
|
|
|
$builtin = array(
|
2011-01-13 00:45:17 +01:00
|
|
|
'class' => array_fill_keys($builtin_classes, true) + array(
|
|
|
|
'PhutilBootloader' => true,
|
|
|
|
),
|
Make sure 'id' and 'idx' are not marked as builtin functions?
Summary:
This is sort of a guess. In D357, arc has gone crazy and removed a bunch of
'utils' dependencies for gc3. I think this is because his HPHP/i has them marked
as builtins.
However, I don't have an HPHP/i build (and probably don't have the fortitude to
build it outside of a Facebook environment, I spent about two hours on it at one
point and got maybe 25% of the way through the build process before running into
things I didn't know how to resolve) so I'm not sure this is the issue. No one
else's diffs have exhibited this problem eitehr, so I'm not confident this is
actually the problem or solution.
gc3, can you apply this locally to a copy of arcanist and then run 'arc lint'
(or 'arc lint --apply-patches') on your commit and see if it restores all the
libphutil/utils requirements?
Test Plan:
unable, see summary
Added 'array_keys' to this blacklist and verified the technical behavior of the
patch is correct by var_dump()'ing builtins.
Reviewed By: gc3
Reviewers: gc3, tuomaspelkonen, jungejason, aran
CC: aran, gc3, epriestley
Differential Revision: 361
2011-05-28 17:15:00 +02:00
|
|
|
'function' => array_filter(
|
|
|
|
array(
|
|
|
|
'empty' => true,
|
|
|
|
'isset' => true,
|
|
|
|
'echo' => true,
|
|
|
|
'print' => true,
|
|
|
|
'exit' => true,
|
|
|
|
'die' => true,
|
2012-03-09 17:57:24 +01:00
|
|
|
|
|
|
|
// These are provided by libphutil but not visible in the map.
|
|
|
|
|
2012-03-05 19:02:37 +01:00
|
|
|
'phutil_is_windows' => true,
|
2012-03-09 17:57:24 +01:00
|
|
|
'phutil_load_library' => true,
|
Make sure 'id' and 'idx' are not marked as builtin functions?
Summary:
This is sort of a guess. In D357, arc has gone crazy and removed a bunch of
'utils' dependencies for gc3. I think this is because his HPHP/i has them marked
as builtins.
However, I don't have an HPHP/i build (and probably don't have the fortitude to
build it outside of a Facebook environment, I spent about two hours on it at one
point and got maybe 25% of the way through the build process before running into
things I didn't know how to resolve) so I'm not sure this is the issue. No one
else's diffs have exhibited this problem eitehr, so I'm not confident this is
actually the problem or solution.
gc3, can you apply this locally to a copy of arcanist and then run 'arc lint'
(or 'arc lint --apply-patches') on your commit and see if it restores all the
libphutil/utils requirements?
Test Plan:
unable, see summary
Added 'array_keys' to this blacklist and verified the technical behavior of the
patch is correct by var_dump()'ing builtins.
Reviewed By: gc3
Reviewers: gc3, tuomaspelkonen, jungejason, aran
CC: aran, gc3, epriestley
Differential Revision: 361
2011-05-28 17:15:00 +02:00
|
|
|
|
|
|
|
// HPHP/i defines these functions as 'internal', but they are NOT
|
|
|
|
// builtins and do not exist in vanilla PHP. Make sure we don't mark them
|
|
|
|
// as builtin since we need to add dependencies for them.
|
|
|
|
'idx' => false,
|
|
|
|
'id' => false,
|
|
|
|
) + array_fill_keys($builtin_functions, true)),
|
2011-01-10 00:22:25 +01:00
|
|
|
'interface' => array_fill_keys($builtin_interfaces, true),
|
|
|
|
);
|
|
|
|
|
|
|
|
require_once dirname(__FILE__).'/__init_script__.php';
|
|
|
|
|
|
|
|
if ($argc != 2) {
|
|
|
|
$self = basename($argv[0]);
|
|
|
|
echo "usage: {$self} <module>\n";
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
phutil_require_module('phutil', 'filesystem');
|
|
|
|
$dir = Filesystem::resolvePath($argv[1]);
|
|
|
|
|
2012-01-12 22:51:35 +01:00
|
|
|
phutil_require_module('phutil', 'parser/docblock');
|
2011-01-10 07:11:31 +01:00
|
|
|
phutil_require_module('phutil', 'parser/xhpast/bin');
|
|
|
|
phutil_require_module('phutil', 'parser/xhpast/api/tree');
|
|
|
|
|
2011-01-10 00:22:25 +01:00
|
|
|
phutil_require_module('arcanist', 'lint/linter/phutilmodule');
|
|
|
|
phutil_require_module('arcanist', 'lint/message');
|
2011-02-19 20:36:08 +01:00
|
|
|
phutil_require_module('arcanist', 'parser/phutilmodule');
|
2011-01-10 07:11:31 +01:00
|
|
|
|
2011-01-10 00:22:25 +01:00
|
|
|
|
|
|
|
$data = array();
|
|
|
|
$futures = array();
|
|
|
|
foreach (Filesystem::listDirectory($dir, $hidden_files = false) as $file) {
|
|
|
|
if (!preg_match('/.php$/', $file)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$data[$file] = Filesystem::readFile($dir.'/'.$file);
|
|
|
|
$futures[$file] = xhpast_get_parser_future($data[$file]);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$requirements = new PhutilModuleRequirements();
|
|
|
|
$requirements->addBuiltins($builtin);
|
|
|
|
|
2012-01-12 22:51:35 +01:00
|
|
|
$doc_parser = new PhutilDocblockParser();
|
|
|
|
|
2011-01-10 00:22:25 +01:00
|
|
|
$has_init = false;
|
|
|
|
$has_files = false;
|
|
|
|
foreach (Futures($futures) as $file => $future) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
$tree = XHPASTTree::newFromDataAndResolvedExecFuture(
|
|
|
|
$data[$file],
|
|
|
|
$future->resolve());
|
|
|
|
} catch (XHPASTSyntaxErrorException $ex) {
|
|
|
|
echo "Syntax Error! In '{$file}': ".$ex->getMessage()."\n";
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
$root = $tree->getRootNode();
|
|
|
|
$requirements->setCurrentFile($file);
|
|
|
|
|
|
|
|
if ($file == '__init__.php') {
|
|
|
|
$has_init = true;
|
|
|
|
$calls = $root->selectDescendantsOfType('n_FUNCTION_CALL');
|
|
|
|
foreach ($calls as $call) {
|
|
|
|
$name = $call->getChildByIndex(0);
|
|
|
|
$call_name = $name->getConcreteString();
|
|
|
|
if ($call_name == 'phutil_require_source') {
|
|
|
|
$params = $call->getChildByIndex(1)->getChildren();
|
|
|
|
if (count($params) !== 1) {
|
|
|
|
$requirements->addLint(
|
|
|
|
$call,
|
|
|
|
$call->getConcreteString(),
|
|
|
|
ArcanistPhutilModuleLinter::LINT_ANALYZER_SIGNATURE,
|
|
|
|
"Call to phutil_require_source() must have exactly one argument.");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$param = reset($params);
|
|
|
|
$value = $param->getStringLiteralValue();
|
|
|
|
if ($value === null) {
|
|
|
|
$requirements->addLint(
|
|
|
|
$param,
|
|
|
|
$param->getConcreteString(),
|
|
|
|
ArcanistPhutilModuleLinter::LINT_ANALYZER_SIGNATURE,
|
|
|
|
"phutil_require_source() parameter must be a string literal.");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$requirements->addSourceDependency($name, $value);
|
|
|
|
} else if ($call_name == 'phutil_require_module') {
|
Fix an obscure dependency issue in Arcanist + libphutil
Summary:
The module analyzer reads "phutil_require_module" in the source of a module as a
dependency, and tries to regenerate __init__.php if symbols from that module
aren't actually used. This creates patches which don't actually resolve the
problem, since changing __init__.php won't change the dependency.
Instead, trust that anyone using phutil_require_module in the source of a module
knows what they're doing and don't mark it as a dependency.
We currently have an issue with this in phabricator's Setup process since I load
some other libraries' modules just to test if they can be loaded
@lesha, this might be the issue you reported a while ago.
Test Plan: Ran "arc lint" on a module which pulls in another module explicitly
in the source, didn't get a no-op lint error.
Reviewed By: jungejason
Reviewers: jungejason, tuomaspelkonen, aran, lesha
CC: aran, epriestley, jungejason
Differential Revision: 770
2011-07-29 18:12:24 +02:00
|
|
|
analyze_phutil_require_module($call, $requirements, true);
|
2011-01-10 00:22:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$has_files = true;
|
|
|
|
|
|
|
|
$requirements->addSourceDeclaration(basename($file));
|
|
|
|
|
2012-01-12 22:51:35 +01:00
|
|
|
// Find symbols declared as "@phutil-external-symbol function example",
|
|
|
|
// and ignore these in building dependency lists.
|
|
|
|
|
|
|
|
$externals = array();
|
|
|
|
foreach ($root->getTokens() as $token) {
|
|
|
|
if ($token->getTypeName() == 'T_DOC_COMMENT') {
|
|
|
|
list($block, $special) = $doc_parser->parse($token->getValue());
|
|
|
|
|
|
|
|
$ext_list = idx($special, 'phutil-external-symbol');
|
|
|
|
$ext_list = explode("\n", $ext_list);
|
|
|
|
$ext_list = array_filter($ext_list);
|
|
|
|
|
|
|
|
foreach ($ext_list as $ext_ref) {
|
|
|
|
$matches = null;
|
|
|
|
if (preg_match('/^\s*(\S+)\s+(\S+)/', $ext_ref, $matches)) {
|
|
|
|
$externals[$matches[1]][$matches[2]] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-10 00:22:25 +01:00
|
|
|
// Function uses:
|
|
|
|
// - Explicit call
|
|
|
|
// TODO?: String literal in ReflectionFunction().
|
|
|
|
|
|
|
|
$calls = $root->selectDescendantsOfType('n_FUNCTION_CALL');
|
|
|
|
foreach ($calls as $call) {
|
|
|
|
$name = $call->getChildByIndex(0);
|
|
|
|
if ($name->getTypeName() == 'n_VARIABLE' ||
|
|
|
|
$name->getTypeName() == 'n_VARIABLE_VARIABLE') {
|
|
|
|
$requirements->addLint(
|
|
|
|
$name,
|
|
|
|
$name->getConcreteString(),
|
|
|
|
ArcanistPhutilModuleLinter::LINT_ANALYZER_DYNAMIC,
|
|
|
|
"Use of variable function calls prevents dependencies from being ".
|
|
|
|
"checked statically. This module may have undetectable errors.");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ($name->getTypeName() == 'n_CLASS_STATIC_ACCESS') {
|
|
|
|
// We'll pick this up later.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$call_name = $name->getConcreteString();
|
|
|
|
if ($call_name == 'phutil_require_module') {
|
Fix an obscure dependency issue in Arcanist + libphutil
Summary:
The module analyzer reads "phutil_require_module" in the source of a module as a
dependency, and tries to regenerate __init__.php if symbols from that module
aren't actually used. This creates patches which don't actually resolve the
problem, since changing __init__.php won't change the dependency.
Instead, trust that anyone using phutil_require_module in the source of a module
knows what they're doing and don't mark it as a dependency.
We currently have an issue with this in phabricator's Setup process since I load
some other libraries' modules just to test if they can be loaded
@lesha, this might be the issue you reported a while ago.
Test Plan: Ran "arc lint" on a module which pulls in another module explicitly
in the source, didn't get a no-op lint error.
Reviewed By: jungejason
Reviewers: jungejason, tuomaspelkonen, aran, lesha
CC: aran, epriestley, jungejason
Differential Revision: 770
2011-07-29 18:12:24 +02:00
|
|
|
analyze_phutil_require_module($call, $requirements, false);
|
2011-01-10 00:22:25 +01:00
|
|
|
} else if ($call_name == 'call_user_func' ||
|
|
|
|
$call_name == 'call_user_func_array') {
|
|
|
|
$params = $call->getChildByIndex(1)->getChildren();
|
|
|
|
if (count($params) == 0) {
|
|
|
|
$requirements->addLint(
|
|
|
|
$call,
|
|
|
|
$call->getConcreteString(),
|
|
|
|
ArcanistPhutilModuleLinter::LINT_ANALYZER_SIGNATURE,
|
|
|
|
"Call to {$call_name}() must have at least one argument.");
|
|
|
|
}
|
|
|
|
$symbol = array_shift($params);
|
|
|
|
$symbol_value = $symbol->getStringLiteralValue();
|
|
|
|
if ($symbol_value) {
|
|
|
|
$requirements->addFunctionDependency(
|
|
|
|
$symbol,
|
|
|
|
$symbol_value);
|
|
|
|
} else {
|
|
|
|
$requirements->addLint(
|
|
|
|
$symbol,
|
|
|
|
$symbol->getConcreteString(),
|
|
|
|
ArcanistPhutilModuleLinter::LINT_ANALYZER_DYNAMIC,
|
|
|
|
"Use of variable arguments to {$call_name} prevents dependencies ".
|
|
|
|
"from being checked statically. This module may have undetectable ".
|
|
|
|
"errors.");
|
|
|
|
}
|
2012-01-12 22:51:35 +01:00
|
|
|
} else if (empty($externals['function'][$name->getConcreteString()])) {
|
2011-01-10 00:22:25 +01:00
|
|
|
$requirements->addFunctionDependency(
|
|
|
|
$name,
|
|
|
|
$name->getConcreteString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$functions = $root->selectDescendantsOfType('n_FUNCTION_DECLARATION');
|
|
|
|
foreach ($functions as $function) {
|
|
|
|
$name = $function->getChildByIndex(2);
|
|
|
|
$requirements->addFunctionDeclaration(
|
|
|
|
$name,
|
|
|
|
$name->getConcreteString());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Class uses:
|
|
|
|
// - new
|
|
|
|
// - extends (in class declaration)
|
|
|
|
// - Static method call
|
|
|
|
// - Static property access
|
|
|
|
// - Constant use
|
|
|
|
// TODO?: String literal in ReflectionClass().
|
|
|
|
// TODO?: String literal in array literal in call_user_func /
|
|
|
|
// call_user_func_array().
|
|
|
|
|
2011-02-27 05:53:24 +01:00
|
|
|
// TODO: Raise a soft warning for use of an unknown class in:
|
|
|
|
// - Typehints
|
|
|
|
// - instanceof
|
|
|
|
// - catch
|
|
|
|
|
2011-01-10 00:22:25 +01:00
|
|
|
$classes = $root->selectDescendantsOfType('n_CLASS_DECLARATION');
|
|
|
|
foreach ($classes as $class) {
|
|
|
|
$class_name = $class->getChildByIndex(1);
|
|
|
|
$requirements->addClassDeclaration(
|
|
|
|
$class_name,
|
|
|
|
$class_name->getConcreteString());
|
|
|
|
$extends = $class->getChildByIndex(2);
|
|
|
|
foreach ($extends->selectDescendantsOfType('n_CLASS_NAME') as $parent) {
|
2012-01-12 22:51:35 +01:00
|
|
|
if (empty($externals['class'][$parent->getConcreteString()])) {
|
|
|
|
$requirements->addClassDependency(
|
|
|
|
$class_name->getConcreteString(),
|
|
|
|
$parent,
|
|
|
|
$parent->getConcreteString());
|
|
|
|
}
|
2011-01-10 00:22:25 +01:00
|
|
|
}
|
|
|
|
$implements = $class->getChildByIndex(3);
|
|
|
|
$interfaces = $implements->selectDescendantsOfType('n_CLASS_NAME');
|
|
|
|
foreach ($interfaces as $interface) {
|
2012-01-12 22:51:35 +01:00
|
|
|
if (empty($externals['interface'][$interface->getConcreteString()])) {
|
|
|
|
$requirements->addInterfaceDependency(
|
|
|
|
$class_name->getConcreteString(),
|
|
|
|
$interface,
|
|
|
|
$interface->getConcreteString());
|
|
|
|
}
|
2011-01-10 00:22:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count($classes) > 1) {
|
|
|
|
foreach ($classes as $class) {
|
|
|
|
$class_name = $class->getChildByIndex(1);
|
|
|
|
$class_string = $class_name->getConcreteString();
|
|
|
|
$requirements->addLint(
|
|
|
|
$class_name,
|
|
|
|
$class_string,
|
|
|
|
ArcanistPhutilModuleLinter::LINT_ANALYZER_MULTIPLE_CLASSES,
|
|
|
|
"This file declares more than one class. Declare only one class per ".
|
|
|
|
"file.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$uses_of_new = $root->selectDescendantsOfType('n_NEW');
|
|
|
|
foreach ($uses_of_new as $new_operator) {
|
|
|
|
$name = $new_operator->getChildByIndex(0);
|
|
|
|
if ($name->getTypeName() == 'n_VARIABLE' ||
|
|
|
|
$name->getTypeName() == 'n_VARIABLE_VARIABLE') {
|
|
|
|
$requirements->addLint(
|
|
|
|
$name,
|
|
|
|
$name->getConcreteString(),
|
|
|
|
ArcanistPhutilModuleLinter::LINT_ANALYZER_DYNAMIC,
|
|
|
|
"Use of variable class instantiation prevents dependencies from ".
|
|
|
|
"being checked statically. This module may have undetectable ".
|
|
|
|
"errors.");
|
|
|
|
continue;
|
|
|
|
}
|
2012-01-12 22:51:35 +01:00
|
|
|
if (empty($externals['class'][$name->getConcreteString()])) {
|
|
|
|
$requirements->addClassDependency(
|
|
|
|
null,
|
|
|
|
$name,
|
|
|
|
$name->getConcreteString());
|
|
|
|
}
|
2011-01-10 00:22:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$static_uses = $root->selectDescendantsOfType('n_CLASS_STATIC_ACCESS');
|
|
|
|
foreach ($static_uses as $static_use) {
|
|
|
|
$name = $static_use->getChildByIndex(0);
|
|
|
|
if ($name->getTypeName() != 'n_CLASS_NAME') {
|
|
|
|
echo "WARNING UNLINTABLE\n";
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$name_concrete = $name->getConcreteString();
|
|
|
|
$magic_names = array(
|
|
|
|
'static' => true,
|
|
|
|
'parent' => true,
|
|
|
|
'self' => true,
|
|
|
|
);
|
|
|
|
if (isset($magic_names[$name_concrete])) {
|
|
|
|
continue;
|
|
|
|
}
|
2012-01-12 22:51:35 +01:00
|
|
|
if (empty($externals['class'][$name_concrete])) {
|
|
|
|
$requirements->addClassDependency(
|
|
|
|
null,
|
|
|
|
$name,
|
|
|
|
$name_concrete);
|
|
|
|
}
|
2011-01-10 00:22:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Interface uses:
|
|
|
|
// - implements
|
|
|
|
// - extends (in interface declaration)
|
|
|
|
|
|
|
|
$interfaces = $root->selectDescendantsOfType('n_INTERFACE_DECLARATION');
|
|
|
|
foreach ($interfaces as $interface) {
|
|
|
|
$interface_name = $interface->getChildByIndex(1);
|
|
|
|
$requirements->addInterfaceDeclaration(
|
|
|
|
$interface_name,
|
|
|
|
$interface_name->getConcreteString());
|
|
|
|
$extends = $interface->getChildByIndex(2);
|
|
|
|
foreach ($extends->selectDescendantsOfType('n_CLASS_NAME') as $parent) {
|
2012-01-12 22:51:35 +01:00
|
|
|
if (empty($externals['interface'][$parent->getConcreteString()])) {
|
|
|
|
$requirements->addInterfaceDependency(
|
|
|
|
$interface_name->getConcreteString(),
|
|
|
|
$parent,
|
|
|
|
$parent->getConcreteString());
|
|
|
|
}
|
2011-01-10 00:22:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$has_init && $has_files) {
|
|
|
|
$requirements->addRawLint(
|
|
|
|
ArcanistPhutilModuleLinter::LINT_ANALYZER_NO_INIT,
|
|
|
|
"Create an __init__.php file in this module.");
|
|
|
|
}
|
|
|
|
|
|
|
|
echo json_encode($requirements->toDictionary());
|
|
|
|
|
2011-02-19 20:36:08 +01:00
|
|
|
/**
|
|
|
|
* Parses meaning from calls to phutil_require_module() in __init__.php files.
|
|
|
|
*
|
|
|
|
* @group module
|
|
|
|
*/
|
|
|
|
function analyze_phutil_require_module(
|
2011-01-10 00:22:25 +01:00
|
|
|
XHPASTNode $call,
|
Fix an obscure dependency issue in Arcanist + libphutil
Summary:
The module analyzer reads "phutil_require_module" in the source of a module as a
dependency, and tries to regenerate __init__.php if symbols from that module
aren't actually used. This creates patches which don't actually resolve the
problem, since changing __init__.php won't change the dependency.
Instead, trust that anyone using phutil_require_module in the source of a module
knows what they're doing and don't mark it as a dependency.
We currently have an issue with this in phabricator's Setup process since I load
some other libraries' modules just to test if they can be loaded
@lesha, this might be the issue you reported a while ago.
Test Plan: Ran "arc lint" on a module which pulls in another module explicitly
in the source, didn't get a no-op lint error.
Reviewed By: jungejason
Reviewers: jungejason, tuomaspelkonen, aran, lesha
CC: aran, epriestley, jungejason
Differential Revision: 770
2011-07-29 18:12:24 +02:00
|
|
|
PhutilModuleRequirements $requirements,
|
|
|
|
$create_dependency) {
|
2011-01-10 00:22:25 +01:00
|
|
|
|
|
|
|
$name = $call->getChildByIndex(0);
|
|
|
|
$params = $call->getChildByIndex(1)->getChildren();
|
|
|
|
if (count($params) !== 2) {
|
|
|
|
$requirements->addLint(
|
|
|
|
$call,
|
|
|
|
$call->getConcreteString(),
|
|
|
|
ArcanistPhutilModuleLinter::LINT_ANALYZER_SIGNATURE,
|
|
|
|
"Call to phutil_require_module() must have exactly two arguments.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$module_param = array_pop($params);
|
|
|
|
$library_param = array_pop($params);
|
|
|
|
|
|
|
|
$library_value = $library_param->getStringLiteralValue();
|
|
|
|
if ($library_value === null) {
|
|
|
|
$requirements->addLint(
|
|
|
|
$library_param,
|
|
|
|
$library_param->getConcreteString(),
|
|
|
|
ArcanistPhutilModuleLinter::LINT_ANALYZER_SIGNATURE,
|
|
|
|
"phutil_require_module() parameters must be string literals.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$module_value = $module_param->getStringLiteralValue();
|
|
|
|
if ($module_value === null) {
|
|
|
|
$requirements->addLint(
|
|
|
|
$module_param,
|
|
|
|
$module_param->getConcreteString(),
|
|
|
|
ArcanistPhutilModuleLinter::LINT_ANALYZER_SIGNATURE,
|
|
|
|
"phutil_require_module() parameters must be string literals.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Fix an obscure dependency issue in Arcanist + libphutil
Summary:
The module analyzer reads "phutil_require_module" in the source of a module as a
dependency, and tries to regenerate __init__.php if symbols from that module
aren't actually used. This creates patches which don't actually resolve the
problem, since changing __init__.php won't change the dependency.
Instead, trust that anyone using phutil_require_module in the source of a module
knows what they're doing and don't mark it as a dependency.
We currently have an issue with this in phabricator's Setup process since I load
some other libraries' modules just to test if they can be loaded
@lesha, this might be the issue you reported a while ago.
Test Plan: Ran "arc lint" on a module which pulls in another module explicitly
in the source, didn't get a no-op lint error.
Reviewed By: jungejason
Reviewers: jungejason, tuomaspelkonen, aran, lesha
CC: aran, epriestley, jungejason
Differential Revision: 770
2011-07-29 18:12:24 +02:00
|
|
|
if ($create_dependency) {
|
|
|
|
$requirements->addModuleDependency(
|
|
|
|
$name,
|
|
|
|
$library_value.':'.$module_value);
|
|
|
|
}
|
2011-01-10 00:22:25 +01:00
|
|
|
}
|