Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15402179
D9972.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
15 KB
Referenced Files
None
Subscribers
None
D9972.diff
View Options
diff --git a/scripts/__init_script__.php b/scripts/__init_script__.php
--- a/scripts/__init_script__.php
+++ b/scripts/__init_script__.php
@@ -37,7 +37,7 @@
// includes (and in other cases, like recursive filesystem operations
// applied to 100+ levels of directory nesting). Stop it from triggering:
// we explicitly limit recursive algorithms which should be limited.
-
+ //
// After Feb 2014, XDebug interprets a value of 0 to mean "do not allow any
// function calls". Previously, 0 effectively disabled this check. For
// context, see T5027.
@@ -92,7 +92,7 @@
function __phutil_signal_handler__($signal_number) {
$e = new Exception();
$pid = getmypid();
- // Some phabricator daemons may not be attached to a terminal.
+ // Some Phabricator daemons may not be attached to a terminal.
Filesystem::writeFile(
sys_get_temp_dir().'/phabricator_backtrace_'.$pid,
$e->getTraceAsString());
diff --git a/scripts/example/subworkflow.php b/scripts/example/subworkflow.php
--- a/scripts/example/subworkflow.php
+++ b/scripts/example/subworkflow.php
@@ -11,6 +11,7 @@
EOHELP
);
+
// This shows how to do manual parsing of raw arguments.
final class PhutilArgumentWorkflowEchoExample extends PhutilArgumentWorkflow {
@@ -27,6 +28,7 @@
echo implode(' ', $unconsumed)."\n";
return 0;
}
+
}
@@ -53,8 +55,10 @@
new PhutilHelpArgumentWorkflow(),
));
}
+
}
+
$do_workflow = id(new PhutilArgumentWorkflowDoExample())
->setName('do')
->setExamples('**do** __thing__ ...')
diff --git a/scripts/phutil_rebuild_map.php b/scripts/phutil_rebuild_map.php
--- a/scripts/phutil_rebuild_map.php
+++ b/scripts/phutil_rebuild_map.php
@@ -66,8 +66,7 @@
if ($args->getArg('ugly')) {
echo json_encode($library_map);
} else {
- $json = new PhutilJSON();
- echo $json->encodeFormatted($library_map);
+ echo id(new PhutilJSON())->encodeFormatted($library_map);
}
} else {
$builder->buildAndWriteMap();
diff --git a/scripts/phutil_symbols.php b/scripts/phutil_symbols.php
--- a/scripts/phutil_symbols.php
+++ b/scripts/phutil_symbols.php
@@ -74,15 +74,13 @@
}
$root = $tree->getRootNode();
-
$root->buildSelectCache();
// -( Unsupported Constructs )------------------------------------------------
$namespaces = $root->selectDescendantsOfType('n_NAMESPACE');
foreach ($namespaces as $namespace) {
- phutil_fail_on_unsupported_feature(
- $namespace, $path, pht('namespaces'));
+ phutil_fail_on_unsupported_feature($namespace, $path, pht('namespaces'));
}
$uses = $root->selectDescendantsOfType('n_USE');
@@ -94,11 +92,10 @@
$possible_traits = $root->selectDescendantsOfType('n_CLASS_DECLARATION');
foreach ($possible_traits as $possible_trait) {
$attributes = $possible_trait->getChildByIndex(0);
- // can't use getChildByIndex here because not all classes have attributes
+ // Can't use getChildByIndex here because not all classes have attributes
foreach ($attributes->getChildren() as $attribute) {
- if (strtolower($attribute->getConcreteString()) == 'trait') {
- phutil_fail_on_unsupported_feature(
- $possible_trait, $path, pht('traits'));
+ if (strtolower($attribute->getConcreteString()) === 'trait') {
+ phutil_fail_on_unsupported_feature($possible_trait, $path, pht('traits'));
}
}
}
@@ -113,7 +110,7 @@
$externals = array();
$doc_parser = new PhutilDocblockParser();
foreach ($root->getTokens() as $token) {
- if ($token->getTypeName() == 'T_DOC_COMMENT') {
+ if ($token->getTypeName() === 'T_DOC_COMMENT') {
list($block, $special) = $doc_parser->parse($token->getValue());
$ext_list = idx($special, 'phutil-external-symbol');
@@ -153,7 +150,7 @@
$functions = $root->selectDescendantsOfType('n_FUNCTION_DECLARATION');
foreach ($functions as $function) {
$name = $function->getChildByIndex(2);
- if ($name->getTypeName() == 'n_EMPTY') {
+ if ($name->getTypeName() === 'n_EMPTY') {
// This is an anonymous function; don't record it into the symbol
// index.
continue;
@@ -179,18 +176,18 @@
$calls = $root->selectDescendantsOfType('n_FUNCTION_CALL');
foreach ($calls as $call) {
$name = $call->getChildByIndex(0);
- if ($name->getTypeName() == 'n_VARIABLE' ||
- $name->getTypeName() == 'n_VARIABLE_VARIABLE') {
+ if ($name->getTypeName() === 'n_VARIABLE' ||
+ $name->getTypeName() === 'n_VARIABLE_VARIABLE') {
// Ignore these, we can't analyze them.
continue;
}
- if ($name->getTypeName() == 'n_CLASS_STATIC_ACCESS') {
+ if ($name->getTypeName() === 'n_CLASS_STATIC_ACCESS') {
// These are "C::f()", we'll pick this up later on.
continue;
}
$call_name = $name->getConcreteString();
- if ($call_name == 'call_user_func' ||
- $call_name == 'call_user_func_array') {
+ if ($call_name === 'call_user_func' ||
+ $call_name === 'call_user_func_array') {
$params = $call->getChildByIndex(1)->getChildren();
if (!count($params)) {
// This is a bare call_user_func() with no arguments; just ignore it.
@@ -203,12 +200,11 @@
if ($pos) {
$type = 'class';
$symbol_value = substr($symbol_value, 0, $pos);
- } else if ($symbol->getTypeName() == 'n_ARRAY_LITERAL') {
+ } else if ($symbol->getTypeName() === 'n_ARRAY_LITERAL') {
try {
$type = 'class';
$symbol_value = idx($symbol->evalStatic(), 0);
- } catch (Exception $ex) {
- }
+ } catch (Exception $ex) {}
}
if ($symbol_value && strpos($symbol_value, '$') === false) {
$need[] = array(
@@ -280,8 +276,8 @@
$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') {
+ if ($name->getTypeName() === 'n_VARIABLE' ||
+ $name->getTypeName() === 'n_VARIABLE_VARIABLE') {
continue;
}
$need[] = array(
@@ -294,7 +290,7 @@
$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') {
+ if ($name->getTypeName() !== 'n_CLASS_NAME') {
continue;
}
$need[] = array(
@@ -307,7 +303,7 @@
$parameters = $root->selectDescendantsOfType('n_DECLARATION_PARAMETER');
foreach ($parameters as $parameter) {
$hint = $parameter->getChildByIndex(0);
- if ($hint->getTypeName() != 'n_CLASS_NAME') {
+ if ($hint->getTypeName() !== 'n_CLASS_NAME') {
continue;
}
$need[] = array(
@@ -329,11 +325,11 @@
$instanceofs = $root->selectDescendantsOfType('n_BINARY_EXPRESSION');
foreach ($instanceofs as $instanceof) {
$operator = $instanceof->getChildOfType(1, 'n_OPERATOR');
- if ($operator->getConcreteString() != 'instanceof') {
+ if ($operator->getConcreteString() !== 'instanceof') {
continue;
}
$class = $instanceof->getChildByIndex(2);
- if ($class->getTypeName() != 'n_CLASS_NAME') {
+ if ($class->getTypeName() !== 'n_CLASS_NAME') {
continue;
}
$need[] = array(
@@ -346,7 +342,7 @@
$calls = $root->selectDescendantsOfType('n_FUNCTION_CALL');
foreach ($calls as $call) {
$call_name = $call->getChildByIndex(0)->getConcreteString();
- if ($call_name != 'newv') {
+ if ($call_name !== 'newv') {
continue;
}
$params = $call->getChildByIndex(1)->getChildren();
@@ -376,8 +372,8 @@
foreach ($interfaces as $interface) {
$interface_name = $interface->getChildByIndex(1);
$have[] = array(
- 'type' => 'interface',
- 'symbol' => $interface_name,
+ 'type' => 'interface',
+ 'symbol' => $interface_name,
);
}
@@ -509,7 +505,7 @@
$builtin['classes'] = get_declared_classes();
$builtin['interfaces'] = get_declared_interfaces();
- $funcs = get_defined_functions();
+ $funcs = get_defined_functions();
$builtin['functions'] = $funcs['internal'];
$compat = json_decode(
diff --git a/scripts/sandpit/harden_directory.php b/scripts/sandpit/harden_directory.php
--- a/scripts/sandpit/harden_directory.php
+++ b/scripts/sandpit/harden_directory.php
@@ -3,9 +3,7 @@
require_once dirname(__FILE__).'/../__init_script__.php';
-// PhutilServiceProfiler::installEchoListener();
-
-if ($argc != 4) {
+if ($argc !== 4) {
usage();
exit(1);
}
@@ -62,7 +60,7 @@
continue;
}
- if ($type == 'exec') {
+ if ($type === 'exec') {
// Multiple hardlinks share a single executable bit, so we need to keep
// executable versions separate from nonexecutable versions.
$obj .= '.x';
@@ -76,12 +74,11 @@
if (!$stat) {
break;
}
- if ($stat[3] < 32000) { // TODO: On NTFS, this needs to be 1023. It is
- // not apparently trivial to determine if a disk
- // is NTFS or not, or what the link limit for a
- // disk is. On linux "df -T /path/to/dir" may be
- // useful, but on OS X this does something totally
- // different...
+ if ($stat[3] < 32000) {
+ // TODO: On NTFS, this needs to be 1023. It is not apparently trivial to
+ // determine if a disk is NTFS or not, or what the link limit for a disk
+ // is. On linux "df -T /path/to/dir" may be useful, but on OS X this does
+ // something totally different...
break;
}
++$n;
@@ -98,7 +95,7 @@
if (!$ok) {
throw new Exception("Failed to copy file '{$soft}/{$path}'!");
}
- if ($type == 'exec') {
+ if ($type === 'exec') {
$ok = chmod($obj, 0755);
if (!$ok) {
throw new Exception("Failed to chmod file '{$obj}'!");
@@ -142,7 +139,7 @@
$type = $matches[2];
$hash = $matches[3];
$file = $matches[4];
- if ($type == 'commit') {
+ if ($type === 'commit') {
// Deal with Git submodules.
$submap = map_directory($dir.'/'.$file);
foreach ($submap as $subfile => $info) {
@@ -152,11 +149,9 @@
$mask = (int)base_convert($flag, 8, 10);
$type = 'file';
if ($mask & 0111) {
-
echo "EXEC: {$file}\n";
-
$type = 'exec';
- } else if (($mask & 0120000) == 0120000) {
+ } else if (($mask & 0120000) === 0120000) {
$type = 'link';
}
$map[$file] = array(
diff --git a/scripts/test/deferred_log.php b/scripts/test/deferred_log.php
--- a/scripts/test/deferred_log.php
+++ b/scripts/test/deferred_log.php
@@ -5,7 +5,5 @@
$logs = array();
for ($ii = 0; $ii < $argv[1]; $ii++) {
- $logs[] = new PhutilDeferredLog(
- $argv[2],
- 'abcdefghijklmnopqrstuvwxyz');
+ $logs[] = new PhutilDeferredLog($argv[2], 'abcdefghijklmnopqrstuvwxyz');
}
diff --git a/scripts/test/http.php b/scripts/test/http.php
--- a/scripts/test/http.php
+++ b/scripts/test/http.php
@@ -29,9 +29,9 @@
$data = '';
$timeout = 30;
-$future = new HTTPSFuture($uri, $data);
-$future->setMethod($method);
-$future->setTimeout($timeout);
+$future = id(new HTTPSFuture($uri, $data))
+ ->setMethod($method)
+ ->setTimeout($timeout);
$attach_file = $args->getArg('attach');
if ($attach_file !== null) {
diff --git a/scripts/test/paypal.php b/scripts/test/paypal.php
--- a/scripts/test/paypal.php
+++ b/scripts/test/paypal.php
@@ -5,13 +5,13 @@
// NOTE: These credentials are global test credentials provided by PayPal.
-$f = id(new PhutilPayPalAPIFuture())
+$future = id(new PhutilPayPalAPIFuture())
->setHost('https://api-3t.sandbox.paypal.com/nvp')
->setAPIUsername('sdk-three_api1.sdk.com')
->setAPIPassword('QFZCWN5HZM8VBG7Q')
->setAPISignature('A-IzJhZZjhg29XQ2qnhapuwxIDzyAZQ92FRP5dqBzVesOkzbdUONzmOU');
-$f->setRawPayPalQuery(
+$future->setRawPayPalQuery(
'SetExpressCheckout',
array(
'PAYMENTREQUEST_0_AMT' => '1.23',
@@ -21,4 +21,4 @@
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
));
-print_r($f->resolve());
+print_r($future->resolve());
diff --git a/scripts/test/progress_bar.php b/scripts/test/progress_bar.php
--- a/scripts/test/progress_bar.php
+++ b/scripts/test/progress_bar.php
@@ -43,8 +43,9 @@
function run_interrupt_bar() {
$bar = id(new PhutilConsoleProgressBar())
->setTotal(100);
+
for ($ii = 0; $ii < 100; $ii++) {
- if ($ii == 20) {
+ if ($ii === 20) {
throw new Exception('Boo!');
}
$bar->update(1);
diff --git a/scripts/test/service_profiler.php b/scripts/test/service_profiler.php
--- a/scripts/test/service_profiler.php
+++ b/scripts/test/service_profiler.php
@@ -8,9 +8,7 @@
PhutilServiceProfiler::installEchoListener();
execx('ls %s', '/tmp');
-
-exec_manual('sleep %s', 1);
-
+exec_manual('sleep %d', 1);
phutil_passthru('cat');
echo "\n\nSERVICE CALL LOG\n";
diff --git a/scripts/utils/directory_fixture.php b/scripts/utils/directory_fixture.php
--- a/scripts/utils/directory_fixture.php
+++ b/scripts/utils/directory_fixture.php
@@ -30,7 +30,7 @@
),
));
-$is_create = $args->getArg('create');
+$is_create = $args->getArg('create');
$is_read_only = $args->getArg('read-only');
$console = PhutilConsole::getConsole();
diff --git a/scripts/utils/lock.php b/scripts/utils/lock.php
--- a/scripts/utils/lock.php
+++ b/scripts/utils/lock.php
@@ -11,6 +11,7 @@
EOHELP
);
+
$args->parseStandardArguments();
$args->parse(array(
array(
@@ -35,7 +36,7 @@
$file = $args->getArg('file');
-if (count($file) != 1) {
+if (count($file) !== 1) {
$args->printHelpAndExit();
}
$file = head($file);
diff --git a/scripts/utils/utf8.php b/scripts/utils/utf8.php
--- a/scripts/utils/utf8.php
+++ b/scripts/utils/utf8.php
@@ -22,6 +22,7 @@
valid UTF-8.
EOHELP
);
+
$args->parseStandardArguments();
$args->parse(array(
array(
@@ -63,7 +64,7 @@
function read($file) {
- if ($file == '-') {
+ if ($file === '-') {
return file_get_contents('php://stdin');
} else {
return Filesystem::readFile($file);
@@ -71,7 +72,7 @@
}
function name($file) {
- if ($file == '-') {
+ if ($file === '-') {
return 'stdin';
} else {
return $file;
@@ -123,8 +124,8 @@
// the loop.
$last = -2;
foreach ($map as $idx => $ignored) {
- if ($idx != $last + 1) {
- printf("\n");
+ if ($idx !== $last + 1) {
+ echo "\n";
}
$last = $idx;
@@ -137,7 +138,6 @@
}
echo "\n";
}
-
}
return 0;
diff --git a/src/__phutil_library_init__.php b/src/__phutil_library_init__.php
--- a/src/__phutil_library_init__.php
+++ b/src/__phutil_library_init__.php
@@ -9,8 +9,8 @@
require_once $root.'/moduleutils/PhutilLibraryConflictException.php';
function __phutil_autoload($class_name) {
- // Occurs in PHP 5.2 with call_user_func(array($this, 'self::f')).
- if ($class_name == 'self' || $class_name == 'parent') {
+ // Occurs in PHP 5.2 with `call_user_func(array($this, 'self::f'))`.
+ if ($class_name === 'self' || $class_name === 'parent') {
return;
}
@@ -20,6 +20,7 @@
->setType('class')
->setName($class_name)
->selectAndLoadSymbols();
+
if (!$symbols) {
throw new PhutilMissingSymbolException(
$class_name,
diff --git a/support/parser/generate-type-parser.php b/support/parser/generate-type-parser.php
--- a/support/parser/generate-type-parser.php
+++ b/support/parser/generate-type-parser.php
@@ -66,5 +66,4 @@
->setRules($rules)
->processGrammar();
-echo $parser->generateParserFunction('phutil_type_spec_parser');
-echo "\n";
+echo $parser->generateParserFunction('phutil_type_spec_parser')."\n";
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Mar 18, 9:08 PM (2 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7483959
Default Alt Text
D9972.diff (15 KB)
Attached To
Mode
D9972: Minor changes to various scripts
Attached
Detach File
Event Timeline
Log In to Comment