Page MenuHomePhabricator

D21742.id51822.diff
No OneTemporary

D21742.id51822.diff

diff --git a/src/configuration/ArcanistConfigurationManager.php b/src/configuration/ArcanistConfigurationManager.php
--- a/src/configuration/ArcanistConfigurationManager.php
+++ b/src/configuration/ArcanistConfigurationManager.php
@@ -258,7 +258,7 @@
}
public function getUserConfigurationFileLocation() {
- if (strlen($this->customArcrcFilename)) {
+ if ($this->customArcrcFilename !== null) {
return $this->customArcrcFilename;
}
diff --git a/src/future/exec/ExecFuture.php b/src/future/exec/ExecFuture.php
--- a/src/future/exec/ExecFuture.php
+++ b/src/future/exec/ExecFuture.php
@@ -192,11 +192,18 @@
* @task interact
*/
public function read() {
- $stdout = $this->readStdout();
+ $stdout_value = $this->readStdout();
+
+ $stderr = $this->stderr;
+ if ($stderr === null) {
+ $stderr_value = '';
+ } else {
+ $stderr_value = substr($stderr, $this->stderrPos);
+ }
$result = array(
- $stdout,
- (string)substr($this->stderr, $this->stderrPos),
+ $stdout_value,
+ $stderr_value,
);
$this->stderrPos = $this->getStderrBufferLength();
@@ -209,7 +216,14 @@
$this->updateFuture(); // Sync
}
- $result = (string)substr($this->stdout, $this->stdoutPos);
+ $stdout = $this->stdout;
+
+ if ($stdout === null) {
+ $result = '';
+ } else {
+ $result = substr($stdout, $this->stdoutPos);
+ }
+
$this->stdoutPos = $this->getStdoutBufferLength();
return $result;
diff --git a/src/lint/linter/ArcanistXMLLinter.php b/src/lint/linter/ArcanistXMLLinter.php
--- a/src/lint/linter/ArcanistXMLLinter.php
+++ b/src/lint/linter/ArcanistXMLLinter.php
@@ -27,7 +27,11 @@
}
public function getCacheVersion() {
- return LIBXML_VERSION;
+ if (defined('LIBXML_VERSION')) {
+ return LIBXML_VERSION;
+ } else {
+ return 'unavailable';
+ }
}
public function lintPath($path) {
diff --git a/src/lint/linter/__tests__/ArcanistLinterTestCase.php b/src/lint/linter/__tests__/ArcanistLinterTestCase.php
--- a/src/lint/linter/__tests__/ArcanistLinterTestCase.php
+++ b/src/lint/linter/__tests__/ArcanistLinterTestCase.php
@@ -51,6 +51,13 @@
private function lintFile($file, ArcanistLinter $linter) {
$linter = clone $linter;
+ if (!$linter->canRun()) {
+ $this->assertSkipped(
+ pht(
+ 'Linter "%s" can not run.',
+ get_class($linter)));
+ }
+
$contents = Filesystem::readFile($file);
$contents = preg_split('/^~{4,}\n/m', $contents);
if (count($contents) < 2) {
@@ -283,9 +290,12 @@
}
private function compareTransform($expected, $actual) {
+ $expected = phutil_string_cast($expected);
+
if (!strlen($expected)) {
return;
}
+
$this->assertEqual(
$expected,
$actual,
diff --git a/src/lint/linter/xhpast/rules/ArcanistPHPCompatibilityXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistPHPCompatibilityXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistPHPCompatibilityXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistPHPCompatibilityXHPASTLinterRule.php
@@ -155,7 +155,9 @@
if ($this->windowsVersion) {
$windows = idx($compat_info['functions_windows'], $name);
- if ($windows === false) {
+ if ($windows === null) {
+ // This function has no special Windows considerations.
+ } else if ($windows === false) {
$this->raiseLintAtNode(
$node,
pht(
diff --git a/src/parser/ArcanistDiffParser.php b/src/parser/ArcanistDiffParser.php
--- a/src/parser/ArcanistDiffParser.php
+++ b/src/parser/ArcanistDiffParser.php
@@ -217,7 +217,7 @@
$line = $this->nextLine();
}
- if (strlen($message)) {
+ if ($message !== null && strlen($message)) {
// If we found a message during pre-parse steps, add it to the resulting
// changes here.
$change = $this->buildChange(null)
@@ -1041,7 +1041,7 @@
$line = $this->nextNonemptyLine();
}
- } while (preg_match('/^@@ /', $line));
+ } while (($line !== null) && preg_match('/^@@ /', $line));
}
protected function buildChange($path = null) {
diff --git a/src/parser/PhutilEmailAddress.php b/src/parser/PhutilEmailAddress.php
--- a/src/parser/PhutilEmailAddress.php
+++ b/src/parser/PhutilEmailAddress.php
@@ -13,6 +13,7 @@
private $domainName;
public function __construct($email_address = null) {
+ $email_address = phutil_string_cast($email_address);
$email_address = trim($email_address);
$matches = null;
diff --git a/src/parser/PhutilURI.php b/src/parser/PhutilURI.php
--- a/src/parser/PhutilURI.php
+++ b/src/parser/PhutilURI.php
@@ -171,7 +171,11 @@
}
}
- if (strlen($protocol) || strlen($auth) || strlen($domain)) {
+ $has_protocol = ($protocol !== null) && strlen($protocol);
+ $has_auth = ($auth !== null);
+ $has_domain = ($domain !== null) && strlen($domain);
+
+ if ($has_protocol || $has_auth || $has_domain) {
if ($this->isGitURI()) {
$prefix = "{$auth}{$domain}";
} else {
diff --git a/src/parser/aast/api/AASTNodeList.php b/src/parser/aast/api/AASTNodeList.php
--- a/src/parser/aast/api/AASTNodeList.php
+++ b/src/parser/aast/api/AASTNodeList.php
@@ -80,6 +80,7 @@
/* -( Countable )---------------------------------------------------------- */
+ #[\ReturnTypeWillChange]
public function count() {
return count($this->ids);
}
@@ -87,22 +88,27 @@
/* -( Iterator )----------------------------------------------------------- */
+ #[\ReturnTypeWillChange]
public function current() {
return $this->list[$this->key()];
}
+ #[\ReturnTypeWillChange]
public function key() {
return $this->ids[$this->pos];
}
+ #[\ReturnTypeWillChange]
public function next() {
$this->pos++;
}
+ #[\ReturnTypeWillChange]
public function rewind() {
$this->pos = 0;
}
+ #[\ReturnTypeWillChange]
public function valid() {
return $this->pos < count($this->ids);
}
diff --git a/src/serviceprofiler/PhutilServiceProfiler.php b/src/serviceprofiler/PhutilServiceProfiler.php
--- a/src/serviceprofiler/PhutilServiceProfiler.php
+++ b/src/serviceprofiler/PhutilServiceProfiler.php
@@ -137,7 +137,7 @@
$uri = phutil_censor_credentials($data['uri']);
- if (strlen($proxy)) {
+ if ($proxy !== null) {
$desc = "{$proxy} >> {$uri}";
} else {
$desc = $uri;
diff --git a/src/unit/renderer/ArcanistUnitConsoleRenderer.php b/src/unit/renderer/ArcanistUnitConsoleRenderer.php
--- a/src/unit/renderer/ArcanistUnitConsoleRenderer.php
+++ b/src/unit/renderer/ArcanistUnitConsoleRenderer.php
@@ -65,9 +65,10 @@
50 => "<fg:green>%s</fg><fg:yellow>{$star}</fg> ",
200 => '<fg:green>%s</fg> ',
500 => '<fg:yellow>%s</fg> ',
- INF => '<fg:red>%s</fg> ',
);
+ $least_acceptable = '<fg:red>%s</fg> ';
+
$milliseconds = $seconds * 1000;
$duration = $this->formatTime($seconds);
foreach ($acceptableness as $upper_bound => $formatting) {
@@ -75,7 +76,8 @@
return phutil_console_format($formatting, $duration);
}
}
- return phutil_console_format(end($acceptableness), $duration);
+
+ return phutil_console_format($least_acceptable, $duration);
}
private function formatTime($seconds) {
diff --git a/src/utils/PhutilArray.php b/src/utils/PhutilArray.php
--- a/src/utils/PhutilArray.php
+++ b/src/utils/PhutilArray.php
@@ -29,6 +29,7 @@
/* -( Countable Interface )------------------------------------------------ */
+ #[\ReturnTypeWillChange]
public function count() {
return count($this->data);
}
@@ -37,22 +38,27 @@
/* -( Iterator Interface )------------------------------------------------- */
+ #[\ReturnTypeWillChange]
public function current() {
return current($this->data);
}
+ #[\ReturnTypeWillChange]
public function key() {
return key($this->data);
}
+ #[\ReturnTypeWillChange]
public function next() {
return next($this->data);
}
+ #[\ReturnTypeWillChange]
public function rewind() {
reset($this->data);
}
+ #[\ReturnTypeWillChange]
public function valid() {
return (key($this->data) !== null);
}
@@ -61,18 +67,22 @@
/* -( ArrayAccess Interface )---------------------------------------------- */
+ #[\ReturnTypeWillChange]
public function offsetExists($key) {
return array_key_exists($key, $this->data);
}
+ #[\ReturnTypeWillChange]
public function offsetGet($key) {
return $this->data[$key];
}
+ #[\ReturnTypeWillChange]
public function offsetSet($key, $value) {
$this->data[$key] = $value;
}
+ #[\ReturnTypeWillChange]
public function offsetUnset($key) {
unset($this->data[$key]);
}
diff --git a/src/utils/PhutilCallbackFilterIterator.php b/src/utils/PhutilCallbackFilterIterator.php
--- a/src/utils/PhutilCallbackFilterIterator.php
+++ b/src/utils/PhutilCallbackFilterIterator.php
@@ -18,6 +18,7 @@
$this->callback = $callback;
}
+ #[\ReturnTypeWillChange]
public function accept() {
return call_user_func($this->callback, $this->current());
}
diff --git a/src/workflow/ArcanistDiffWorkflow.php b/src/workflow/ArcanistDiffWorkflow.php
--- a/src/workflow/ArcanistDiffWorkflow.php
+++ b/src/workflow/ArcanistDiffWorkflow.php
@@ -2360,7 +2360,7 @@
if (strlen($branch)) {
$upstream_path = $api->getPathToUpstream($branch);
$remote_branch = $upstream_path->getRemoteBranchName();
- if (strlen($remote_branch)) {
+ if ($remote_branch !== null) {
return array(
array(
'type' => 'branch',
@@ -2374,7 +2374,7 @@
// If "arc.land.onto.default" is configured, use that.
$config_key = 'arc.land.onto.default';
$onto = $this->getConfigFromAnySource($config_key);
- if (strlen($onto)) {
+ if ($onto !== null) {
return array(
array(
'type' => 'branch',
diff --git a/src/workflow/ArcanistWorkflow.php b/src/workflow/ArcanistWorkflow.php
--- a/src/workflow/ArcanistWorkflow.php
+++ b/src/workflow/ArcanistWorkflow.php
@@ -154,7 +154,7 @@
}
$help = $information->getHelp();
- if (strlen($help)) {
+ if ($help !== null) {
// Unwrap linebreaks in the help text so we don't get weird formatting.
$help = preg_replace("/(?<=\S)\n(?=\S)/", ' ', $help);
diff --git a/support/lib/extract-symbols.php b/support/lib/extract-symbols.php
--- a/support/lib/extract-symbols.php
+++ b/support/lib/extract-symbols.php
@@ -219,7 +219,13 @@
$symbol = array_shift($params);
$type = 'function';
$symbol_value = $symbol->getStringLiteralValue();
- $pos = strpos($symbol_value, '::');
+
+ if ($symbol_value !== null) {
+ $pos = strpos($symbol_value, '::');
+ } else {
+ $pos = false;
+ }
+
if ($pos) {
$type = 'class';
$symbol_value = substr($symbol_value, 0, $pos);

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 16, 4:40 AM (2 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7626791
Default Alt Text
D21742.id51822.diff (10 KB)

Event Timeline