Page MenuHomePhorge

D25030.1732331487.diff
No OneTemporary

D25030.1732331487.diff

This file is larger than 256 KB, so syntax highlighting was skipped.
diff --git a/externals/jsonlint/src/Seld/JsonLint/JsonParser.php b/externals/jsonlint/src/Seld/JsonLint/JsonParser.php
--- a/externals/jsonlint/src/Seld/JsonLint/JsonParser.php
+++ b/externals/jsonlint/src/Seld/JsonLint/JsonParser.php
@@ -193,13 +193,13 @@
}
$message = null;
- if (in_array("'STRING'", $expected) && in_array(substr($this->lexer->match, 0, 1), array('"', "'"))) {
+ if (in_array("'STRING'", $expected) && in_array(@substr($this->lexer->match, 0, 1), array('"', "'"))) {
$message = "Invalid string";
- if ("'" === substr($this->lexer->match, 0, 1)) {
+ if ("'" === @substr($this->lexer->match, 0, 1)) {
$message .= ", it appears you used single quotes instead of double quotes";
- } elseif (preg_match('{".+?(\\\\[^"bfnrt/\\\\u])}', $this->lexer->getUpcomingInput(), $match)) {
+ } elseif (@preg_match('{".+?(\\\\[^"bfnrt/\\\\u])}', $this->lexer->getUpcomingInput(), $match)) {
$message .= ", it appears you have an unescaped backslash at: ".$match[1];
- } elseif (preg_match('{"(?:[^"]+|\\\\")*$}m', $this->lexer->getUpcomingInput())) {
+ } elseif (@preg_match('{"(?:[^"]+|\\\\")*$}m', $this->lexer->getUpcomingInput())) {
$message .= ", it appears you forgot to terminate the string, or attempted to write a multiline string which is invalid";
}
}
@@ -213,7 +213,7 @@
$errStr .= implode(', ', $expected);
}
- if (',' === substr(trim($this->lexer->getPastInput()), -1)) {
+ if (',' === @substr(trim($this->lexer->getPastInput()), -1)) {
$errStr .= " - It appears you have an extra trailing comma";
}
@@ -342,10 +342,10 @@
$yyval->token = $yytext;
break;
case 2:
- if (strpos($yytext, 'e') !== false || strpos($yytext, 'E') !== false) {
+ if (@strpos($yytext, 'e') !== false || @strpos($yytext, 'E') !== false) {
$yyval->token = floatval($yytext);
} else {
- $yyval->token = strpos($yytext, '.') === false ? intval($yytext) : floatval($yytext);
+ $yyval->token = @strpos($yytext, '.') === false ? intval($yytext) : floatval($yytext);
}
break;
case 3:
@@ -451,7 +451,7 @@
case '\/':
return "/";
default:
- return html_entity_decode('&#x'.ltrim(substr($match[0], 2), '0').';', 0, 'UTF-8');
+ return html_entity_decode('&#x'.ltrim(@substr($match[0], 2), '0').';', 0, 'UTF-8');
}
}
@@ -481,7 +481,7 @@
// UTF-8 ByteOrderMark sequence
$bom = "\xEF\xBB\xBF";
- if (substr($input, 0, 3) === $bom) {
+ if (@substr($input, 0, 3) === $bom) {
$this->parseError("BOM detected, make sure your input does not include a Unicode Byte-Order-Mark", array());
}
}
diff --git a/externals/jsonlint/src/Seld/JsonLint/Lexer.php b/externals/jsonlint/src/Seld/JsonLint/Lexer.php
--- a/externals/jsonlint/src/Seld/JsonLint/Lexer.php
+++ b/externals/jsonlint/src/Seld/JsonLint/Lexer.php
@@ -79,26 +79,26 @@
public function showPosition()
{
$pre = str_replace("\n", '', $this->getPastInput());
- $c = str_repeat('-', max(0, strlen($pre) - 1)); // new Array(pre.length + 1).join("-");
+ $c = str_repeat('-', max(0, @strlen($pre) - 1)); // new Array(pre.length + 1).join("-");
return $pre . str_replace("\n", '', $this->getUpcomingInput()) . "\n" . $c . "^";
}
public function getPastInput()
{
- $past = substr($this->matched, 0, strlen($this->matched) - strlen($this->match));
+ $past = @substr($this->matched, 0, @strlen($this->matched) - @strlen($this->match));
- return (strlen($past) > 20 ? '...' : '') . substr($past, -20);
+ return (@strlen($past) > 20 ? '...' : '') . @substr($past, -20);
}
public function getUpcomingInput()
{
$next = $this->match;
- if (strlen($next) < 20) {
- $next .= substr($this->input, 0, 20 - strlen($next));
+ if (@strlen($next) < 20) {
+ $next .= @substr($this->input, 0, 20 - @strlen($next));
}
- return substr($next, 0, 20) . (strlen($next) > 20 ? '...' : '');
+ return @substr($next, 0, 20) . (@strlen($next) > 20 ? '...' : '');
}
protected function parseError($str, $hash)
@@ -129,7 +129,7 @@
$rulesLen = count($rules);
for ($i=0; $i < $rulesLen; $i++) {
- if (preg_match($this->rules[$rules[$i]], $this->input, $match)) {
+ if (@preg_match($this->rules[$rules[$i]], $this->input, $match)) {
preg_match_all('/\n.*/', $match[0], $lines);
$lines = $lines[0];
if ($lines) {
@@ -140,13 +140,13 @@
'first_line' => $this->yylloc['last_line'],
'last_line' => $this->yylineno+1,
'first_column' => $this->yylloc['last_column'],
- 'last_column' => $lines ? strlen($lines[count($lines) - 1]) - 1 : $this->yylloc['last_column'] + strlen($match[0]),
+ 'last_column' => $lines ? @strlen($lines[count($lines) - 1]) - 1 : $this->yylloc['last_column'] + @strlen($match[0]),
);
$this->yytext .= $match[0];
$this->match .= $match[0];
- $this->yyleng = strlen($this->yytext);
+ $this->yyleng = @strlen($this->yytext);
$this->more = false;
- $this->input = substr($this->input, strlen($match[0]));
+ $this->input = @substr($this->input, @strlen($match[0]));
$this->matched .= $match[0];
$token = $this->performAction($rules[$i], $this->conditionStack[count($this->conditionStack)-1]);
if ($token) {
@@ -185,7 +185,7 @@
return 6;
break;
case 2:
- $this->yytext = substr($this->yytext, 1, $this->yyleng-2);
+ $this->yytext = @substr($this->yytext, 1, $this->yyleng-2);
return 4;
case 3:
diff --git a/scripts/arcanist.php b/scripts/arcanist.php
--- a/scripts/arcanist.php
+++ b/scripts/arcanist.php
@@ -210,7 +210,7 @@
$user_config = $configuration_manager->readUserConfigurationFile();
$config = new ArcanistConfiguration();
- $command = strtolower($args[0]);
+ $command = @strtolower($args[0]);
$args = array_slice($args, 1);
$workflow = $config->selectWorkflow(
$command,
@@ -519,7 +519,7 @@
phpinfo(INFO_GENERAL);
$info = ob_get_clean();
$matches = null;
- if (preg_match('/^Configure Command =>\s*(.*?)$/m', $info, $matches)) {
+ if (@preg_match('/^Configure Command =>\s*(.*?)$/m', $info, $matches)) {
$config = $matches[1];
}
}
@@ -527,7 +527,7 @@
$generic = true;
list($what, $which) = $resolution;
- if ($what == 'flag' && strpos($config, $which) !== false) {
+ if ($what == 'flag' && @strpos($config, $which) !== false) {
$show_config = true;
$generic = false;
$problems[] =
diff --git a/src/browse/query/ArcanistBrowseObjectNameURIHardpointQuery.php b/src/browse/query/ArcanistBrowseObjectNameURIHardpointQuery.php
--- a/src/browse/query/ArcanistBrowseObjectNameURIHardpointQuery.php
+++ b/src/browse/query/ArcanistBrowseObjectNameURIHardpointQuery.php
@@ -15,7 +15,7 @@
$token_set = array();
foreach ($refs as $key => $ref) {
$token = $ref->getToken();
- if (!strlen($token)) {
+ if (!@strlen($token)) {
continue;
}
@@ -42,7 +42,7 @@
}
$uri = idx($object, 'uri');
- if (!strlen($uri)) {
+ if (!@strlen($uri)) {
continue;
}
diff --git a/src/browse/query/ArcanistBrowsePathURIHardpointQuery.php b/src/browse/query/ArcanistBrowsePathURIHardpointQuery.php
--- a/src/browse/query/ArcanistBrowsePathURIHardpointQuery.php
+++ b/src/browse/query/ArcanistBrowsePathURIHardpointQuery.php
@@ -35,7 +35,7 @@
}
$lines = null;
- $parts = explode(':', $path);
+ $parts = @explode(':', $path);
if (count($parts) > 1) {
$lines = array_pop($parts);
}
diff --git a/src/browse/workflow/ArcanistBrowseWorkflow.php b/src/browse/workflow/ArcanistBrowseWorkflow.php
--- a/src/browse/workflow/ArcanistBrowseWorkflow.php
+++ b/src/browse/workflow/ArcanistBrowseWorkflow.php
@@ -142,7 +142,7 @@
if ($many_hits) {
foreach ($many_hits as $ref) {
$token = $ref->getToken();
- if (strlen($token)) {
+ if (@strlen($token)) {
$message = pht('Argument "%s" is ambiguous.', $token);
} else {
$message = pht('Default behavior is ambiguous.');
@@ -167,7 +167,7 @@
foreach ($many_hits as $ref) {
$token_display = $ref->getToken();
- if (!strlen($token)) {
+ if (!@strlen($token)) {
$token_display = pht('<default>');
}
diff --git a/src/channel/PhutilChannel.php b/src/channel/PhutilChannel.php
--- a/src/channel/PhutilChannel.php
+++ b/src/channel/PhutilChannel.php
@@ -212,17 +212,17 @@
public function update() {
$maximum_read = PHP_INT_MAX;
if ($this->readBufferSize !== null) {
- $maximum_read = ($this->readBufferSize - strlen($this->ibuf));
+ $maximum_read = ($this->readBufferSize - @strlen($this->ibuf));
}
while ($maximum_read > 0) {
$in = $this->readBytes($maximum_read);
- if (!strlen($in)) {
+ if (!@strlen($in)) {
// Reading is blocked for now.
break;
}
$this->ibuf .= $in;
- $maximum_read -= strlen($in);
+ $maximum_read -= @strlen($in);
}
while ($this->obuf->getByteLength()) {
@@ -379,7 +379,7 @@
* @task impl
*/
public function isReadBufferEmpty() {
- return (strlen($this->ibuf) == 0);
+ return (@strlen($this->ibuf) == 0);
}
diff --git a/src/channel/PhutilExecChannel.php b/src/channel/PhutilExecChannel.php
--- a/src/channel/PhutilExecChannel.php
+++ b/src/channel/PhutilExecChannel.php
@@ -92,7 +92,7 @@
list($stdout, $stderr) = $this->future->read();
$this->future->discardBuffers();
- if (strlen($stderr)) {
+ if (@strlen($stderr)) {
if ($this->stderrHandler) {
call_user_func($this->stderrHandler, $this, $stderr);
} else {
diff --git a/src/channel/PhutilJSONProtocolChannel.php b/src/channel/PhutilJSONProtocolChannel.php
--- a/src/channel/PhutilJSONProtocolChannel.php
+++ b/src/channel/PhutilJSONProtocolChannel.php
@@ -55,7 +55,7 @@
$len = sprintf(
'%0'.self::SIZE_LENGTH.'.'.self::SIZE_LENGTH.'d',
- strlen($message));
+ @strlen($message));
return "{$len}{$message}";
}
@@ -70,15 +70,15 @@
$this->buf .= $data;
$objects = array();
- while (strlen($this->buf) >= $this->byteLengthOfNextChunk) {
+ while (@strlen($this->buf) >= $this->byteLengthOfNextChunk) {
switch ($this->mode) {
case self::MODE_LENGTH:
- $len = substr($this->buf, 0, self::SIZE_LENGTH);
- $this->buf = substr($this->buf, self::SIZE_LENGTH);
+ $len = @substr($this->buf, 0, self::SIZE_LENGTH);
+ $this->buf = @substr($this->buf, self::SIZE_LENGTH);
- if (!preg_match('/^\d+\z/', $len)) {
+ if (!@preg_match('/^\d+\z/', $len)) {
$full_buffer = $len.$this->buf;
- $full_length = strlen($full_buffer);
+ $full_length = @strlen($full_buffer);
throw new Exception(
pht(
@@ -88,15 +88,15 @@
new PhutilNumber(self::SIZE_LENGTH),
phutil_encode_log($len),
new PhutilNumber($full_length),
- phutil_encode_log(substr($len.$this->buf, 0, 128))));
+ phutil_encode_log(@substr($len.$this->buf, 0, 128))));
}
$this->mode = self::MODE_OBJECT;
$this->byteLengthOfNextChunk = (int)$len;
break;
case self::MODE_OBJECT:
- $data = substr($this->buf, 0, $this->byteLengthOfNextChunk);
- $this->buf = substr($this->buf, $this->byteLengthOfNextChunk);
+ $data = @substr($this->buf, 0, $this->byteLengthOfNextChunk);
+ $this->buf = @substr($this->buf, $this->byteLengthOfNextChunk);
try {
$objects[] = phutil_json_decode($data);
diff --git a/src/channel/PhutilLogFileChannel.php b/src/channel/PhutilLogFileChannel.php
--- a/src/channel/PhutilLogFileChannel.php
+++ b/src/channel/PhutilLogFileChannel.php
@@ -17,7 +17,7 @@
public function read() {
$buffer = parent::read();
- if (strlen($buffer)) {
+ if (@strlen($buffer)) {
$this->log('>>> '.phutil_loggable_string($buffer));
}
@@ -25,7 +25,7 @@
}
public function write($message) {
- if (strlen($message)) {
+ if (@strlen($message)) {
$this->log('<<< '.phutil_loggable_string($message));
}
diff --git a/src/channel/PhutilMetricsChannel.php b/src/channel/PhutilMetricsChannel.php
--- a/src/channel/PhutilMetricsChannel.php
+++ b/src/channel/PhutilMetricsChannel.php
@@ -69,7 +69,7 @@
*/
public function read() {
$buffer = parent::read();
- $this->bytesRead += strlen($buffer);
+ $this->bytesRead += @strlen($buffer);
return $buffer;
}
@@ -78,7 +78,7 @@
* @task impl
*/
public function write($message) {
- $this->bytesWritten += strlen($message);
+ $this->bytesWritten += @strlen($message);
return parent::write($message);
}
diff --git a/src/channel/PhutilPHPObjectProtocolChannel.php b/src/channel/PhutilPHPObjectProtocolChannel.php
--- a/src/channel/PhutilPHPObjectProtocolChannel.php
+++ b/src/channel/PhutilPHPObjectProtocolChannel.php
@@ -44,7 +44,7 @@
*/
protected function encodeMessage($message) {
$message = serialize($message);
- $len = pack('N', strlen($message));
+ $len = pack('N', @strlen($message));
return "{$len}{$message}";
}
@@ -58,18 +58,18 @@
$this->buf .= $data;
$objects = array();
- while (strlen($this->buf) >= $this->byteLengthOfNextChunk) {
+ while (@strlen($this->buf) >= $this->byteLengthOfNextChunk) {
switch ($this->mode) {
case self::MODE_LENGTH:
- $len = substr($this->buf, 0, self::SIZE_LENGTH);
- $this->buf = substr($this->buf, self::SIZE_LENGTH);
+ $len = @substr($this->buf, 0, self::SIZE_LENGTH);
+ $this->buf = @substr($this->buf, self::SIZE_LENGTH);
$this->mode = self::MODE_OBJECT;
$this->byteLengthOfNextChunk = head(unpack('N', $len));
break;
case self::MODE_OBJECT:
- $data = substr($this->buf, 0, $this->byteLengthOfNextChunk);
- $this->buf = substr($this->buf, $this->byteLengthOfNextChunk);
+ $data = @substr($this->buf, 0, $this->byteLengthOfNextChunk);
+ $this->buf = @substr($this->buf, $this->byteLengthOfNextChunk);
$obj = @unserialize($data);
if ($obj === false) {
diff --git a/src/channel/PhutilProtocolChannel.php b/src/channel/PhutilProtocolChannel.php
--- a/src/channel/PhutilProtocolChannel.php
+++ b/src/channel/PhutilProtocolChannel.php
@@ -28,7 +28,7 @@
public function read() {
$data = parent::read();
- if (strlen($data)) {
+ if (@strlen($data)) {
$messages = $this->decodeStream($data);
foreach ($messages as $message) {
$this->addMessage($message);
diff --git a/src/channel/__tests__/PhutilChannelTestCase.php b/src/channel/__tests__/PhutilChannelTestCase.php
--- a/src/channel/__tests__/PhutilChannelTestCase.php
+++ b/src/channel/__tests__/PhutilChannelTestCase.php
@@ -15,7 +15,7 @@
$x->update();
$y->update();
$read = $y->read();
- if (strlen($read)) {
+ if (@strlen($read)) {
break;
}
}
@@ -33,7 +33,7 @@
$x->update();
$y->update();
$read = $y->read();
- if (strlen($read)) {
+ if (@strlen($read)) {
break;
}
}
diff --git a/src/conduit/ConduitClient.php b/src/conduit/ConduitClient.php
--- a/src/conduit/ConduitClient.php
+++ b/src/conduit/ConduitClient.php
@@ -25,7 +25,7 @@
public function __construct($uri) {
$this->uri = new PhutilURI($uri);
- if (!strlen($this->uri->getDomain())) {
+ if (!@strlen($this->uri->getDomain())) {
throw new Exception(
pht("Conduit URI '%s' must include a valid host.", $uri));
}
@@ -285,7 +285,7 @@
}
$public_key = idx($meta, 'auth.key');
- if (!strlen($public_key)) {
+ if (!@strlen($public_key)) {
throw new Exception(
pht(
'Unable to verify request signature, no "%s" present in '.
@@ -294,7 +294,7 @@
}
$signature = idx($meta, 'auth.signature');
- if (!strlen($signature)) {
+ if (!@strlen($signature)) {
throw new Exception(
pht(
'Unable to verify request signature, no "%s" present '.
@@ -303,13 +303,13 @@
}
$prefix = self::SIGNATURE_CONSIGN_1;
- if (strncmp($signature, $prefix, strlen($prefix)) !== 0) {
+ if (strncmp($signature, $prefix, @strlen($prefix)) !== 0) {
throw new Exception(
pht(
'Unable to verify request signature, signature format is not '.
'known.'));
}
- $signature = substr($signature, strlen($prefix));
+ $signature = @substr($signature, @strlen($prefix));
$input = self::encodeRequestDataForSignature(
$method,
@@ -336,7 +336,7 @@
'Request signature verification failed: signature is not correct.'));
} else {
// Some kind of error.
- if (strlen($err)) {
+ if (@strlen($err)) {
throw new Exception(
pht(
'OpenSSL encountered an error verifying the request signature: %s',
@@ -389,12 +389,12 @@
}
} else if (is_string($data)) {
$out[] = 'S';
- $out[] = strlen($data);
+ $out[] = @strlen($data);
$out[] = ':';
$out[] = $data;
} else if (is_int($data)) {
$out[] = 'I';
- $out[] = strlen((string)$data);
+ $out[] = @strlen((string)$data);
$out[] = ':';
$out[] = (string)$data;
} else if (is_null($data)) {
diff --git a/src/conduit/ConduitFuture.php b/src/conduit/ConduitFuture.php
--- a/src/conduit/ConduitFuture.php
+++ b/src/conduit/ConduitFuture.php
@@ -34,7 +34,7 @@
foreach ($headers as $header) {
list($name, $value) = $header;
if (!strcasecmp($name, 'X-Conduit-Capabilities')) {
- $capabilities = explode(' ', $value);
+ $capabilities = @explode(' ', $value);
break;
}
}
@@ -46,8 +46,8 @@
$raw = $body;
$shield = 'for(;;);';
- if (!strncmp($raw, $shield, strlen($shield))) {
- $raw = substr($raw, strlen($shield));
+ if (!strncmp($raw, $shield, @strlen($shield))) {
+ $raw = @substr($raw, @strlen($shield));
}
$data = null;
diff --git a/src/config/ArcanistConfigurationEngine.php b/src/config/ArcanistConfigurationEngine.php
--- a/src/config/ArcanistConfigurationEngine.php
+++ b/src/config/ArcanistConfigurationEngine.php
@@ -194,7 +194,7 @@
$key));
}
- $is_ok = preg_match('(^[a-z][a-z0-9._-]{2,}\z)', $key);
+ $is_ok = @preg_match('(^[a-z][a-z0-9._-]{2,}\z)', $key);
if (!$is_ok) {
if ($is_alias_of === null) {
throw new Exception(
diff --git a/src/config/source/ArcanistFilesystemConfigurationSource.php b/src/config/source/ArcanistFilesystemConfigurationSource.php
--- a/src/config/source/ArcanistFilesystemConfigurationSource.php
+++ b/src/config/source/ArcanistFilesystemConfigurationSource.php
@@ -11,7 +11,7 @@
$values = array();
if (Filesystem::pathExists($path)) {
$contents = Filesystem::readFile($path);
- if (strlen(trim($contents))) {
+ if (@strlen(trim($contents))) {
$values = phutil_json_decode($contents);
}
}
diff --git a/src/config/source/ArcanistRuntimeConfigurationSource.php b/src/config/source/ArcanistRuntimeConfigurationSource.php
--- a/src/config/source/ArcanistRuntimeConfigurationSource.php
+++ b/src/config/source/ArcanistRuntimeConfigurationSource.php
@@ -6,7 +6,7 @@
public function __construct(array $argv) {
$map = array();
foreach ($argv as $raw) {
- $parts = explode('=', $raw, 2);
+ $parts = @explode('=', $raw, 2);
if (count($parts) !== 2) {
throw new PhutilArgumentUsageException(
pht(
diff --git a/src/configuration/ArcanistConfiguration.php b/src/configuration/ArcanistConfiguration.php
--- a/src/configuration/ArcanistConfiguration.php
+++ b/src/configuration/ArcanistConfiguration.php
@@ -126,7 +126,7 @@
private function expandCommandPrefix($command, array $options) {
$is_prefix = array();
foreach ($options as $option) {
- if (strncmp($option, $command, strlen($command)) == 0) {
+ if (strncmp($option, $command, @strlen($command)) == 0) {
$is_prefix[$option] = true;
}
}
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 (@strlen($this->customArcrcFilename)) {
return $this->customArcrcFilename;
}
diff --git a/src/configuration/ArcanistSettings.php b/src/configuration/ArcanistSettings.php
--- a/src/configuration/ArcanistSettings.php
+++ b/src/configuration/ArcanistSettings.php
@@ -180,17 +180,17 @@
$type = $this->getType($key);
switch ($type) {
case 'bool':
- if (strtolower($value) === 'false' ||
- strtolower($value) === 'no' ||
- strtolower($value) === 'off' ||
+ if (@strtolower($value) === 'false' ||
+ @strtolower($value) === 'no' ||
+ @strtolower($value) === 'off' ||
$value === '' ||
$value === '0' ||
$value === 0 ||
$value === false) {
$value = false;
- } else if (strtolower($value) === 'true' ||
- strtolower($value) === 'yes' ||
- strtolower($value) === 'on' ||
+ } else if (@strtolower($value) === 'true' ||
+ @strtolower($value) === 'yes' ||
+ @strtolower($value) === 'on' ||
$value === '1' ||
$value === 1 ||
$value === true) {
diff --git a/src/console/PhutilConsole.php b/src/console/PhutilConsole.php
--- a/src/console/PhutilConsole.php
+++ b/src/console/PhutilConsole.php
@@ -170,7 +170,7 @@
// Must be public because it is called from output buffering.
public function redirectOutCallback($string) {
- if (strlen($string)) {
+ if (@strlen($string)) {
$this->flushing = false;
$this->writeOut('%s', $string);
$this->flushing = true;
diff --git a/src/console/PhutilConsoleProgressBar.php b/src/console/PhutilConsoleProgressBar.php
--- a/src/console/PhutilConsoleProgressBar.php
+++ b/src/console/PhutilConsoleProgressBar.php
@@ -109,7 +109,7 @@
}
// Width of the stuff other than the progress bar itself.
- $chrome_width = strlen('[] 100.0% ');
+ $chrome_width = @strlen('[] 100.0% ');
$char_width = $this->getWidth();
if ($char_width < $chrome_width) {
diff --git a/src/console/PhutilInteractiveEditor.php b/src/console/PhutilInteractiveEditor.php
--- a/src/console/PhutilInteractiveEditor.php
+++ b/src/console/PhutilInteractiveEditor.php
@@ -132,7 +132,7 @@
$offset_flag = '';
if ($offset && !phutil_is_windows()) {
$offset = (int)$offset;
- if (preg_match('/^mate/', $editor)) {
+ if (@preg_match('/^mate/', $editor)) {
$offset_flag = csprintf('-l %d', $offset);
} else {
$offset_flag = csprintf('+%d', $offset);
@@ -204,7 +204,7 @@
* @task config
*/
public function getName() {
- if (!strlen($this->name)) {
+ if (!@strlen($this->name)) {
return 'untitled';
}
return $this->name;
diff --git a/src/console/__tests__/PhutilConsoleWrapTestCase.php b/src/console/__tests__/PhutilConsoleWrapTestCase.php
--- a/src/console/__tests__/PhutilConsoleWrapTestCase.php
+++ b/src/console/__tests__/PhutilConsoleWrapTestCase.php
@@ -6,7 +6,7 @@
$dir = dirname(__FILE__).'/wrap/';
$files = Filesystem::listDirectory($dir);
foreach ($files as $file) {
- if (preg_match('/.txt$/', $file)) {
+ if (@preg_match('/.txt$/', $file)) {
$this->assertEqual(
Filesystem::readFile($dir.$file.'.expect'),
phutil_console_wrap(Filesystem::readFile($dir.$file)),
diff --git a/src/console/format.php b/src/console/format.php
--- a/src/console/format.php
+++ b/src/console/format.php
@@ -13,7 +13,7 @@
do {
$response = phutil_console_prompt($prompt.' '.$prompt_options);
- $c = trim(strtolower($response));
+ $c = trim(@strtolower($response));
} while ($c != 'y' && $c != 'n' && $c != '');
echo "\n";
@@ -30,7 +30,7 @@
$response = phutil_console_prompt($prompt.' '.$select_options);
$selection = trim($response);
- if (preg_match('/^\d+\z/', $selection)) {
+ if (@preg_match('/^\d+\z/', $selection)) {
$selection = (int)$selection;
if ($selection >= $min && $selection <= $max) {
return $selection;
diff --git a/src/console/grid/ArcanistGridCell.php b/src/console/grid/ArcanistGridCell.php
--- a/src/console/grid/ArcanistGridCell.php
+++ b/src/console/grid/ArcanistGridCell.php
@@ -31,7 +31,7 @@
$width = 0;
foreach ($lines as $line) {
- $width = max($width, phutil_utf8_console_strlen($line));
+ $width = max($width, phutil_utf8_consolestrlen($line));
}
return $width;
diff --git a/src/console/grid/ArcanistGridView.php b/src/console/grid/ArcanistGridView.php
--- a/src/console/grid/ArcanistGridView.php
+++ b/src/console/grid/ArcanistGridView.php
@@ -155,7 +155,7 @@
}
foreach ($content as $line_key => $line) {
- $line_width = phutil_utf8_console_strlen($line);
+ $line_width = phutil_utf8_consolestrlen($line);
if ($line_width === $display_width) {
continue;
diff --git a/src/console/view/PhutilConsoleList.php b/src/console/view/PhutilConsoleList.php
--- a/src/console/view/PhutilConsoleList.php
+++ b/src/console/view/PhutilConsoleList.php
@@ -42,7 +42,7 @@
if ($this->bullet !== null) {
$bullet = $this->bullet.' ';
- $indent_depth = $indent_depth + phutil_utf8_console_strlen($bullet);
+ $indent_depth = $indent_depth + phutil_utf8_consolestrlen($bullet);
} else {
$bullet = '';
}
diff --git a/src/console/view/PhutilConsoleTable.php b/src/console/view/PhutilConsoleTable.php
--- a/src/console/view/PhutilConsoleTable.php
+++ b/src/console/view/PhutilConsoleTable.php
@@ -79,7 +79,7 @@
foreach ($data as $key => $value) {
$this->widths[$key] = max(
idx($this->widths, $key, 0),
- phutil_utf8_console_strlen($value));
+ phutil_utf8_consolestrlen($value));
}
return $this;
@@ -225,7 +225,7 @@
protected function getWidth($key) {
$width = max(
idx($this->widths, $key),
- phutil_utf8_console_strlen(
+ phutil_utf8_consolestrlen(
idx(idx($this->columns, $key, array()), 'title', '')));
return $width + 2 * $this->padding;
@@ -233,7 +233,7 @@
protected function alignString($string, $width, $align) {
$num_padding = $width -
- (2 * $this->padding) - phutil_utf8_console_strlen($string);
+ (2 * $this->padding) - phutil_utf8_consolestrlen($string);
switch ($align) {
case self::ALIGN_LEFT:
diff --git a/src/difference/ArcanistDiffUtils.php b/src/difference/ArcanistDiffUtils.php
--- a/src/difference/ArcanistDiffUtils.php
+++ b/src/difference/ArcanistDiffUtils.php
@@ -16,7 +16,7 @@
// presence of NULL ("\0") bytes. Git only examines the first "few" bytes of
// each file (8KB or so) as an optimization, but we don't have a reasonable
// equivalent in PHP, so just look at all of it.
- return (strpos($data, "\0") !== false);
+ return (@strpos($data, "\0") !== false);
}
public static function renderDifferences(
@@ -46,8 +46,8 @@
}
public static function generateIntralineDiff($o, $n) {
- $ol = strlen($o);
- $nl = strlen($n);
+ $ol = @strlen($o);
+ $nl = @strlen($n);
if (($o === $n) || !$ol || !$nl) {
return array(
@@ -60,8 +60,8 @@
// lines. Inputs take ~200x more memory to represent as lists than as
// strings, so we can run out of memory quickly if we try to split huge
// inputs. See T11744.
- $ol = strlen($o);
- $nl = strlen($n);
+ $ol = @strlen($o);
+ $nl = @strlen($n);
$max_glyphs = 100;
@@ -105,7 +105,7 @@
}
private static function computeIntralineEdits($o, $n, $max_glyphs) {
- if (preg_match('/[\x80-\xFF]/', $o.$n)) {
+ if (@preg_match('/[\x80-\xFF]/', $o.$n)) {
$ov = phutil_utf8v_combined($o);
$nv = phutil_utf8v_combined($n);
$multibyte = true;
@@ -124,7 +124,7 @@
$o_pos = 0;
$n_pos = 0;
- $result_len = strlen($result);
+ $result_len = @strlen($result);
$o_run = array();
$n_run = array();
@@ -135,8 +135,8 @@
$c = $result[$ii];
if ($multibyte) {
- $old_char_len = strlen($ov[$o_pos]);
- $new_char_len = strlen($nv[$n_pos]);
+ $old_char_len = @strlen($ov[$o_pos]);
+ $new_char_len = @strlen($nv[$n_pos]);
}
switch ($c) {
diff --git a/src/differential/ArcanistDifferentialCommitMessage.php b/src/differential/ArcanistDifferentialCommitMessage.php
--- a/src/differential/ArcanistDifferentialCommitMessage.php
+++ b/src/differential/ArcanistDifferentialCommitMessage.php
@@ -21,7 +21,7 @@
$pattern = '/^git-svn-id:\s*([^@]+)@(\d+)\s+(.*)$/m';
$match = null;
- if (preg_match($pattern, $corpus, $match)) {
+ if (@preg_match($pattern, $corpus, $match)) {
$obj->gitSVNBaseRevision = $match[1].'@'.$match[2];
$obj->gitSVNBasePath = $match[1];
$obj->gitSVNUUID = $match[3];
@@ -116,7 +116,7 @@
*/
private function parseRevisionIDFromRawCorpus($corpus) {
$match = null;
- if (!preg_match('/^Differential Revision:\s*(.+)/im', $corpus, $match)) {
+ if (!@preg_match('/^Differential Revision:\s*(.+)/im', $corpus, $match)) {
return null;
}
@@ -124,7 +124,7 @@
$revision_pattern = '/^[dD]([1-9]\d*)\z/';
// Accept a bare revision ID like "D123".
- if (preg_match($revision_pattern, $revision_value, $match)) {
+ if (@preg_match($revision_pattern, $revision_value, $match)) {
return (int)$match[1];
}
@@ -132,7 +132,7 @@
$uri = new PhutilURI($revision_value);
$path = $uri->getPath();
$path = trim($path, '/');
- if (preg_match($revision_pattern, $path, $match)) {
+ if (@preg_match($revision_pattern, $path, $match)) {
return (int)$match[1];
}
diff --git a/src/error/PhutilErrorHandler.php b/src/error/PhutilErrorHandler.php
--- a/src/error/PhutilErrorHandler.php
+++ b/src/error/PhutilErrorHandler.php
@@ -222,7 +222,7 @@
}
// Convert typehint failures into exceptions.
- if (preg_match('/^Argument (\d+) passed to (\S+) must be/', $str)) {
+ if (@preg_match('/^Argument (\d+) passed to (\S+) must be/', $str)) {
throw new InvalidArgumentException($str);
}
@@ -232,28 +232,28 @@
}
// Convert uses of undefined variables into exceptions.
- if (preg_match('/^Undefined variable: /', $str)) {
+ if (@preg_match('/^Undefined variable: /', $str)) {
throw new RuntimeException($str);
}
// Convert uses of undefined properties into exceptions.
- if (preg_match('/^Undefined property: /', $str)) {
+ if (@preg_match('/^Undefined property: /', $str)) {
throw new RuntimeException($str);
}
// Convert undefined constants into exceptions. Usually this means there
// is a missing `$` and the program is horribly broken.
- if (preg_match('/^Use of undefined constant /', $str)) {
+ if (@preg_match('/^Use of undefined constant /', $str)) {
throw new RuntimeException($str);
}
// Convert undefined indexes into exceptions.
- if (preg_match('/^Undefined index: /', $str)) {
+ if (@preg_match('/^Undefined index: /', $str)) {
throw new RuntimeException($str);
}
// Convert undefined offsets into exceptions.
- if (preg_match('/^Undefined offset: /', $str)) {
+ if (@preg_match('/^Undefined offset: /', $str)) {
throw new RuntimeException($str);
}
@@ -298,7 +298,7 @@
* @task internal
*/
public static function outputStacktrace($trace) {
- $lines = explode("\n", self::formatStacktrace($trace));
+ $lines = @explode("\n", self::formatStacktrace($trace));
foreach ($lines as $line) {
error_log($line);
}
@@ -378,7 +378,7 @@
* @task internal
*/
public static function dispatchErrorMessage($event, $value, $metadata) {
- $timestamp = strftime('%Y-%m-%d %H:%M:%S');
+ $timestamp = @strftime('%Y-%m-%d %H:%M:%S');
switch ($event) {
case self::ERROR:
@@ -402,8 +402,8 @@
} while ($current = self::getPreviousException($current));
$messages = implode(' {>} ', $messages);
- if (strlen($messages) > 4096) {
- $messages = substr($messages, 0, 4096).'...';
+ if (@strlen($messages) > 4096) {
+ $messages = @substr($messages, 0, 4096).'...';
}
$default_message = sprintf(
@@ -476,8 +476,8 @@
break;
}
- if (!strncmp($root, $path, strlen($root))) {
- return '<'.$library.'>'.substr($path, strlen($root));
+ if (!strncmp($root, $path, @strlen($root))) {
+ return '<'.$library.'>'.@substr($path, @strlen($root));
}
}
@@ -504,7 +504,7 @@
if (@file_exists($try_file)) {
$head = @file_get_contents($try_file);
$matches = null;
- if (preg_match('(^ref: refs/heads/(.*)$)', trim($head), $matches)) {
+ if (@preg_match('(^ref: refs/heads/(.*)$)', trim($head), $matches)) {
$libinfo[$library]['head'] = trim($matches[1]);
$get_refs[] = trim($matches[1]);
} else {
@@ -521,7 +521,7 @@
if (@file_exists($try_file)) {
$hash = @file_get_contents($try_file);
if ($hash) {
- $libinfo[$library]['ref.'.$ref] = substr(trim($hash), 0, 12);
+ $libinfo[$library]['ref.'.$ref] = @substr(trim($hash), 0, 12);
break;
}
}
@@ -533,7 +533,7 @@
if ($custom) {
$count = 0;
foreach ($custom as $custom_path) {
- if (preg_match('/\.php$/', $custom_path)) {
+ if (@preg_match('/\.php$/', $custom_path)) {
$count++;
}
}
diff --git a/src/error/PhutilOpaqueEnvelope.php b/src/error/PhutilOpaqueEnvelope.php
--- a/src/error/PhutilOpaqueEnvelope.php
+++ b/src/error/PhutilOpaqueEnvelope.php
@@ -60,9 +60,9 @@
*/
private function mask($string, $noise) {
$result = '';
- for ($ii = 0; $ii < strlen($string); $ii++) {
+ for ($ii = 0; $ii < @strlen($string); $ii++) {
$s = $string[$ii];
- $n = $noise[$ii % strlen($noise)];
+ $n = $noise[$ii % @strlen($noise)];
$result .= chr(ord($s) ^ ord($n));
}
diff --git a/src/error/__tests__/PhutilErrorHandlerTestCase.php b/src/error/__tests__/PhutilErrorHandlerTestCase.php
--- a/src/error/__tests__/PhutilErrorHandlerTestCase.php
+++ b/src/error/__tests__/PhutilErrorHandlerTestCase.php
@@ -17,7 +17,7 @@
public function testSilenceHandler() {
// Errors should normally be logged.
- $this->assertTrue(strlen($this->emitError()) > 0);
+ $this->assertTrue(@strlen($this->emitError()) > 0);
// The "@" operator should silence errors.
$this->assertTrue(@strlen($this->emitError()) === 0);
diff --git a/src/error/__tests__/PhutilOpaqueEnvelopeTestCase.php b/src/error/__tests__/PhutilOpaqueEnvelopeTestCase.php
--- a/src/error/__tests__/PhutilOpaqueEnvelopeTestCase.php
+++ b/src/error/__tests__/PhutilOpaqueEnvelopeTestCase.php
@@ -17,15 +17,15 @@
$envelope = new PhutilOpaqueEnvelope($secret);
- $this->assertFalse(strpos(var_export($envelope, true), $secret));
+ $this->assertFalse(@strpos(var_export($envelope, true), $secret));
- $this->assertFalse(strpos(print_r($envelope, true), $secret));
+ $this->assertFalse(@strpos(print_r($envelope, true), $secret));
ob_start();
var_dump($envelope);
$dump = ob_get_clean();
- $this->assertFalse(strpos($dump, $secret));
+ $this->assertFalse(@strpos($dump, $secret));
try {
$this->throwTrace($envelope, $signpost);
@@ -38,15 +38,15 @@
$trace = array_slice($trace, 0, 2);
$trace = print_r($trace, true);
- $this->assertTrue(strpos($trace, $signpost) !== false);
- $this->assertFalse(strpos($trace, $secret));
+ $this->assertTrue(@strpos($trace, $signpost) !== false);
+ $this->assertFalse(@strpos($trace, $secret));
}
$backtrace = $this->getBacktrace($envelope, $signpost);
$backtrace = array_slice($backtrace, 0, 2);
- $this->assertTrue(strpos($trace, $signpost) !== false);
- $this->assertFalse(strpos(print_r($backtrace, true), $secret));
+ $this->assertTrue(@strpos($trace, $signpost) !== false);
+ $this->assertFalse(@strpos(print_r($backtrace, true), $secret));
$this->assertEqual($secret, $envelope->openEnvelope());
}
diff --git a/src/filesystem/FileFinder.php b/src/filesystem/FileFinder.php
--- a/src/filesystem/FileFinder.php
+++ b/src/filesystem/FileFinder.php
@@ -194,7 +194,7 @@
private function getFiles($dir) {
$found = Filesystem::listDirectory($this->root.'/'.$dir, true);
$files = array();
- if (strlen($dir) > 0) {
+ if (@strlen($dir) > 0) {
$dir = rtrim($dir, '/').'/';
}
foreach ($found as $filename) {
@@ -296,11 +296,11 @@
->resolvex();
$stdout = trim($stdout);
- if (!strlen($stdout)) {
+ if (!@strlen($stdout)) {
return array();
}
- $files = explode("\0", $stdout);
+ $files = @explode("\0", $stdout);
// On OSX/BSD, find prepends a './' to each file.
foreach ($files as $key => $file) {
@@ -311,8 +311,8 @@
continue;
}
- if (substr($files[$key], 0, 2) == './') {
- $files[$key] = substr($files[$key], 2);
+ if (@substr($files[$key], 0, 2) == './') {
+ $files[$key] = @substr($files[$key], 2);
}
}
}
diff --git a/src/filesystem/FileList.php b/src/filesystem/FileList.php
--- a/src/filesystem/FileList.php
+++ b/src/filesystem/FileList.php
@@ -69,7 +69,7 @@
return true;
}
if ($allow_parent_directory) {
- $len = strlen($file);
+ $len = @strlen($file);
if (isset($this->dirs[$file]) && !strncmp($file, $path, $len)) {
return true;
}
diff --git a/src/filesystem/Filesystem.php b/src/filesystem/Filesystem.php
--- a/src/filesystem/Filesystem.php
+++ b/src/filesystem/Filesystem.php
@@ -236,7 +236,7 @@
$path,
pht("Failed to open file '%s'.", $path));
}
- $dlen = strlen($data);
+ $dlen = @strlen($data);
if (fwrite($fh, $data) !== $dlen) {
throw new FilesystemException(
$path,
@@ -275,7 +275,7 @@
$trap->destroy();
if (!$ok) {
- if (strlen($err)) {
+ if (@strlen($err)) {
throw new FilesystemException(
$to,
pht(
@@ -307,7 +307,7 @@
* @task file
*/
public static function remove($path) {
- if (!strlen($path)) {
+ if (!@strlen($path)) {
// Avoid removing PWD.
throw new Exception(
pht(
@@ -469,12 +469,12 @@
'openssl_random_pseudo_bytes()'));
}
- if (strlen($data) != $number_of_bytes) {
+ if (@strlen($data) != $number_of_bytes) {
throw new Exception(
pht(
'%s returned an unexpected number of bytes (got %s, expected %s)!',
'openssl_random_pseudo_bytes()',
- new PhutilNumber(strlen($data)),
+ new PhutilNumber(@strlen($data)),
new PhutilNumber($number_of_bytes)));
}
@@ -490,7 +490,7 @@
if ($urandom) {
$data = @fread($urandom, $number_of_bytes);
@fclose($urandom);
- if (strlen($data) != $number_of_bytes) {
+ if (@strlen($data) != $number_of_bytes) {
throw new FilesystemException(
'/dev/urandom',
pht('Failed to read random bytes!'));
@@ -673,8 +673,8 @@
}
// If we come back with an encoding, strip it off.
- if (strpos($mime_type, ';') !== false) {
- list($type, $encoding) = explode(';', $mime_type, 2);
+ if (@strpos($mime_type, ';') !== false) {
+ list($type, $encoding) = @explode(';', $mime_type, 2);
$mime_type = $type;
}
@@ -785,7 +785,7 @@
$tries = 3;
do {
- $dir = $base.substr(base_convert(md5(mt_rand()), 16, 36), 0, 16);
+ $dir = $base.@substr(base_convert(md5(mt_rand()), 16, 36), 0, 16);
try {
self::createDirectory($dir, $umask);
break;
@@ -888,9 +888,9 @@
}
$walk = array();
- $parts = explode(DIRECTORY_SEPARATOR, $path);
+ $parts = @explode(DIRECTORY_SEPARATOR, $path);
foreach ($parts as $k => $part) {
- if (!strlen($part)) {
+ if (!@strlen($part)) {
unset($parts[$k]);
}
}
@@ -929,7 +929,7 @@
*/
public static function isAbsolutePath($path) {
if (phutil_is_windows()) {
- return (bool)preg_match('/^[A-Za-z]+:/', $path);
+ return (bool)@preg_match('/^[A-Za-z]+:/', $path);
} else {
return !strncmp($path, DIRECTORY_SEPARATOR, 1);
}
@@ -984,7 +984,7 @@
$path = str_replace('/', '\\', $path);
} else {
$parts = trim($path, '/');
- $parts = explode('/', $parts);
+ $parts = @explode('/', $parts);
}
while ($parts) {
@@ -996,7 +996,7 @@
}
$realpath = realpath($attempt);
if ($realpath !== false) {
- $path = $realpath.substr($path, strlen($attempt));
+ $path = $realpath.@substr($path, @strlen($attempt));
break;
}
}
@@ -1045,9 +1045,9 @@
foreach (array($pwd, self::resolvePath($pwd)) as $parent) {
$parent = rtrim($parent, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
- $len = strlen($parent);
+ $len = @strlen($parent);
if (!strncmp($parent, $path, $len)) {
- $path = substr($path, $len);
+ $path = @substr($path, $len);
return $path;
}
}
diff --git a/src/filesystem/PhutilErrorLog.php b/src/filesystem/PhutilErrorLog.php
--- a/src/filesystem/PhutilErrorLog.php
+++ b/src/filesystem/PhutilErrorLog.php
@@ -92,7 +92,7 @@
$message = idx($metadata, 'default_message');
- if (strlen($message)) {
+ if (@strlen($message)) {
$message = tsprintf("%B\n", $message);
@fwrite(STDERR, $message);
}
diff --git a/src/filesystem/PhutilProcessQuery.php b/src/filesystem/PhutilProcessQuery.php
--- a/src/filesystem/PhutilProcessQuery.php
+++ b/src/filesystem/PhutilProcessQuery.php
@@ -47,7 +47,7 @@
$instance = null;
if ($ref->getIsOverseer()) {
$matches = null;
- if (preg_match('/-l (\S+)/', $command, $matches)) {
+ if (@preg_match('/-l (\S+)/', $command, $matches)) {
$instance = $matches[1];
}
}
@@ -105,7 +105,7 @@
$proc_cmdline = sprintf('/proc/%d/cmdline', $pid);
try {
$argv = Filesystem::readFile($proc_cmdline);
- $argv = explode("\0", $argv);
+ $argv = @explode("\0", $argv);
// The output itself is terminated with "\0", so remove the final empty
// argument.
diff --git a/src/filesystem/__tests__/FilesystemTestCase.php b/src/filesystem/__tests__/FilesystemTestCase.php
--- a/src/filesystem/__tests__/FilesystemTestCase.php
+++ b/src/filesystem/__tests__/FilesystemTestCase.php
@@ -58,7 +58,7 @@
public function testReadRandomBytes() {
$number_of_bytes = 1024;
$data = Filesystem::readRandomBytes($number_of_bytes);
- $this->assertTrue(strlen($data) == $number_of_bytes);
+ $this->assertTrue(@strlen($data) == $number_of_bytes);
$data1 = Filesystem::readRandomBytes(128);
$data2 = Filesystem::readRandomBytes(128);
diff --git a/src/filesystem/__tests__/PhutilFileLockTestCase.php b/src/filesystem/__tests__/PhutilFileLockTestCase.php
--- a/src/filesystem/__tests__/PhutilFileLockTestCase.php
+++ b/src/filesystem/__tests__/PhutilFileLockTestCase.php
@@ -162,7 +162,7 @@
while (!$future->isReady()) {
list($stdout) = $future->read();
$buf .= $stdout;
- if (strpos($buf, 'LOCK ACQUIRED') !== false) {
+ if (@strpos($buf, 'LOCK ACQUIRED') !== false) {
return $future;
}
}
diff --git a/src/filesystem/binary/PhutilDiffBinaryAnalyzer.php b/src/filesystem/binary/PhutilDiffBinaryAnalyzer.php
--- a/src/filesystem/binary/PhutilDiffBinaryAnalyzer.php
+++ b/src/filesystem/binary/PhutilDiffBinaryAnalyzer.php
@@ -18,10 +18,10 @@
public static function parseDiffBinaryVersion($stdout) {
$prefix = 'diff (GNU diffutils) ';
- if (preg_match('(^'.preg_quote($prefix).')', $stdout)) {
+ if (@preg_match('(^'.preg_quote($prefix).')', $stdout)) {
$lines = phutil_split_lines($stdout, false);
$line = head($lines);
- $version = substr($line, strlen($prefix));
+ $version = @substr($line, @strlen($prefix));
return $version;
}
diff --git a/src/filesystem/binary/PhutilGitBinaryAnalyzer.php b/src/filesystem/binary/PhutilGitBinaryAnalyzer.php
--- a/src/filesystem/binary/PhutilGitBinaryAnalyzer.php
+++ b/src/filesystem/binary/PhutilGitBinaryAnalyzer.php
@@ -16,8 +16,8 @@
}
public static function parseGitBinaryVersion($stdout) {
- if (preg_match('/^git version /', $stdout)) {
- $version = substr($stdout, strlen('git version '));
+ if (@preg_match('/^git version /', $stdout)) {
+ $version = @substr($stdout, @strlen('git version '));
$version = trim($version);
return $version;
}
diff --git a/src/filesystem/binary/PhutilMercurialBinaryAnalyzer.php b/src/filesystem/binary/PhutilMercurialBinaryAnalyzer.php
--- a/src/filesystem/binary/PhutilMercurialBinaryAnalyzer.php
+++ b/src/filesystem/binary/PhutilMercurialBinaryAnalyzer.php
@@ -32,7 +32,7 @@
$matches = null;
$pattern = '/^Mercurial Distributed SCM \(version ([\d.]+)/m';
- if (preg_match($pattern, $stdout, $matches)) {
+ if (@preg_match($pattern, $stdout, $matches)) {
return $matches[1];
}
diff --git a/src/filesystem/binary/PhutilPygmentizeBinaryAnalyzer.php b/src/filesystem/binary/PhutilPygmentizeBinaryAnalyzer.php
--- a/src/filesystem/binary/PhutilPygmentizeBinaryAnalyzer.php
+++ b/src/filesystem/binary/PhutilPygmentizeBinaryAnalyzer.php
@@ -21,7 +21,7 @@
$pattern = '(^Pygments version ([^,]+),)';
$matches = null;
- if (preg_match($pattern, $stdout, $matches)) {
+ if (@preg_match($pattern, $stdout, $matches)) {
return $matches[1];
}
diff --git a/src/filesystem/linesofalarge/LinesOfALarge.php b/src/filesystem/linesofalarge/LinesOfALarge.php
--- a/src/filesystem/linesofalarge/LinesOfALarge.php
+++ b/src/filesystem/linesofalarge/LinesOfALarge.php
@@ -9,7 +9,7 @@
*
* If your stream is not large, it is generally more efficient (and certainly
* simpler) to read the entire stream first and then process it (e.g., with
- * `explode()`).
+ * `@explode()`).
*
* This class is abstract. The concrete implementations available are:
*
@@ -61,7 +61,7 @@
* @task config
*/
final public function setDelimiter($character) {
- if (($character !== null) && (strlen($character) !== 1)) {
+ if (($character !== null) && (@strlen($character) !== 1)) {
throw new Exception(
pht('Delimiter character must be one byte in length or null.'));
}
@@ -150,12 +150,12 @@
// case the size of a line is very large compared to the chunk size we
// read.
while (true) {
- if (strlen($this->buf)) {
+ if (@strlen($this->buf)) {
// If we don't have a delimiter, return the entire buffer.
if ($this->delimiter === null) {
$this->num++;
- $this->line = substr($this->buf, $this->pos);
+ $this->line = @substr($this->buf, $this->pos);
$this->buf = '';
$this->pos = 0;
return;
@@ -164,7 +164,7 @@
// If we already have some data buffered, try to get the next line from
// the buffer. Search through the buffer for a delimiter. This should be
// the common case.
- $endl = strpos($this->buf, $this->delimiter, $this->pos);
+ $endl = @strpos($this->buf, $this->delimiter, $this->pos);
if ($endl !== false) {
// We found a delimiter, so return the line it delimits. We leave
@@ -172,7 +172,7 @@
// large relative to the size of a line. Instead, we move our cursor
// within the buffer forward.
$this->num++;
- $this->line = substr($this->buf, $this->pos, ($endl - $this->pos));
+ $this->line = @substr($this->buf, $this->pos, ($endl - $this->pos));
$this->pos = $endl + 1;
return;
}
@@ -180,7 +180,7 @@
// We only have part of a line left in the buffer (no delimiter in the
// remaining piece), so throw away the part we've already emitted and
// continue below.
- $this->buf = substr($this->buf, $this->pos);
+ $this->buf = @substr($this->buf, $this->pos);
$this->pos = 0;
}
@@ -199,7 +199,7 @@
$more = $this->readMore();
}
- if (strlen($more)) {
+ if (@strlen($more)) {
// We got some bytes, so add them to the buffer and then try again.
$this->buf .= $more;
continue;
@@ -209,7 +209,7 @@
// delimiter, but that currently seems reasonable as a default
// behavior. If we don't have a buffer, we're done.
$this->eof = true;
- if (strlen($this->buf)) {
+ if (@strlen($this->buf)) {
$this->num++;
$this->line = $this->buf;
$this->buf = null;
diff --git a/src/filesystem/linesofalarge/LinesOfALargeExecFuture.php b/src/filesystem/linesofalarge/LinesOfALargeExecFuture.php
--- a/src/filesystem/linesofalarge/LinesOfALargeExecFuture.php
+++ b/src/filesystem/linesofalarge/LinesOfALargeExecFuture.php
@@ -4,7 +4,7 @@
* Read the output stream of an @{class:ExecFuture} one line at a time. This
* abstraction allows you to process large inputs without holding them in
* memory. If you know your inputs fit in memory, it is generally more efficient
- * (and certainly simpler) to read the entire input and `explode()` it. For
+ * (and certainly simpler) to read the entire input and `@explode()` it. For
* more information, see @{class:LinesOfALarge}. See also
* @{class:LinesOfALargeFile} for a similar abstraction that works on files.
*
@@ -94,7 +94,7 @@
$stdout = $future->readStdout();
$future->discardStdoutBuffer();
- if (strlen($stdout)) {
+ if (@strlen($stdout)) {
return $stdout;
}
diff --git a/src/filesystem/linesofalarge/LinesOfALargeFile.php b/src/filesystem/linesofalarge/LinesOfALargeFile.php
--- a/src/filesystem/linesofalarge/LinesOfALargeFile.php
+++ b/src/filesystem/linesofalarge/LinesOfALargeFile.php
@@ -3,7 +3,7 @@
/**
* Read the lines of a file, one at a time. This allows you to process large
* files without holding them in memory. In most cases, it is more efficient
- * (and certainly simpler) to read the entire file and `explode()` it. For more
+ * (and certainly simpler) to read the entire file and `@explode()` it. For more
* information, see @{class:LinesOfALarge}. See also
* @{class:LinesOfALargeExecFuture}, for a similar abstraction that works on
* executed commands.
diff --git a/src/future/aws/PhutilAWSv4Signature.php b/src/future/aws/PhutilAWSv4Signature.php
--- a/src/future/aws/PhutilAWSv4Signature.php
+++ b/src/future/aws/PhutilAWSv4Signature.php
@@ -175,7 +175,7 @@
private function getScopeParts() {
return array(
- substr($this->getDate(), 0, 8),
+ @substr($this->getDate(), 0, 8),
$this->getRegion(),
$this->getService(),
'aws4_request',
@@ -252,7 +252,7 @@
private function getCredential() {
$access_key = $this->accessKey;
- if (!strlen($access_key)) {
+ if (!@strlen($access_key)) {
throw new PhutilInvalidStateException('setAccessKey');
}
diff --git a/src/future/aws/management/PhutilAWSManagementWorkflow.php b/src/future/aws/management/PhutilAWSManagementWorkflow.php
--- a/src/future/aws/management/PhutilAWSManagementWorkflow.php
+++ b/src/future/aws/management/PhutilAWSManagementWorkflow.php
@@ -13,9 +13,9 @@
$access_key = $argv->getArg('access-key');
$secret_key = $argv->getArg('secret-key');
- $has_root = (strlen($access_key) || strlen($secret_key));
+ $has_root = (@strlen($access_key) || @strlen($secret_key));
if ($has_root) {
- if (!strlen($access_key) || !strlen($secret_key)) {
+ if (!@strlen($access_key) || !@strlen($secret_key)) {
throw new PhutilArgumentUsageException(
pht(
'When specifying AWS credentials with --access-key and '.
@@ -35,7 +35,7 @@
}
$region = $argv->getArg('region');
- if (!strlen($region)) {
+ if (!@strlen($region)) {
throw new PhutilArgumentUsageException(
pht(
'You must specify an AWS region with --region.'));
@@ -44,7 +44,7 @@
$template->setRegion($region);
$endpoint = $argv->getArg('endpoint');
- if (!strlen($endpoint)) {
+ if (!@strlen($endpoint)) {
throw new PhutilArgumentUsageException(
pht(
'You must specify an AWS endpoint with --endpoint.'));
diff --git a/src/future/aws/management/PhutilAWSS3DeleteManagementWorkflow.php b/src/future/aws/management/PhutilAWSS3DeleteManagementWorkflow.php
--- a/src/future/aws/management/PhutilAWSS3DeleteManagementWorkflow.php
+++ b/src/future/aws/management/PhutilAWSS3DeleteManagementWorkflow.php
@@ -24,7 +24,7 @@
public function execute(PhutilArgumentParser $args) {
$key = $args->getArg('key');
- if (!strlen($key)) {
+ if (!@strlen($key)) {
throw new PhutilArgumentUsageException(
pht(
'Specify an AWS S3 object key to access with --key.'));
diff --git a/src/future/aws/management/PhutilAWSS3GetManagementWorkflow.php b/src/future/aws/management/PhutilAWSS3GetManagementWorkflow.php
--- a/src/future/aws/management/PhutilAWSS3GetManagementWorkflow.php
+++ b/src/future/aws/management/PhutilAWSS3GetManagementWorkflow.php
@@ -24,21 +24,21 @@
public function execute(PhutilArgumentParser $args) {
$bucket = $args->getArg('bucket');
- if (!strlen($bucket)) {
+ if (!@strlen($bucket)) {
throw new PhutilArgumentUsageException(
pht(
'Specify an AWS S3 bucket to access with --bucket.'));
}
$endpoint = $args->getArg('endpoint');
- if (!strlen($endpoint)) {
+ if (!@strlen($endpoint)) {
throw new PhutilArgumentUsageException(
pht(
'Specify an AWS S3 endpoint with --endpoint.'));
}
$key = $args->getArg('key');
- if (!strlen($key)) {
+ if (!@strlen($key)) {
throw new PhutilArgumentUsageException(
pht(
'Specify an AWS S3 object key to access with --key.'));
diff --git a/src/future/aws/management/PhutilAWSS3PutManagementWorkflow.php b/src/future/aws/management/PhutilAWSS3PutManagementWorkflow.php
--- a/src/future/aws/management/PhutilAWSS3PutManagementWorkflow.php
+++ b/src/future/aws/management/PhutilAWSS3PutManagementWorkflow.php
@@ -24,7 +24,7 @@
public function execute(PhutilArgumentParser $args) {
$key = $args->getArg('key');
- if (!strlen($key)) {
+ if (!@strlen($key)) {
throw new PhutilArgumentUsageException(
pht(
'Specify an AWS S3 object key to access with --key.'));
diff --git a/src/future/exec/CommandException.php b/src/future/exec/CommandException.php
--- a/src/future/exec/CommandException.php
+++ b/src/future/exec/CommandException.php
@@ -52,18 +52,18 @@
}
private function summarize($string) {
- if (!strlen($string)) {
+ if (!@strlen($string)) {
return '(empty)';
}
$limit = 1000;
- $len = strlen($string);
+ $len = @strlen($string);
if ($len > $limit) {
$cut = $len - $limit;
$suffix = pht('... (%s more byte(s)) ...', new PhutilNumber($cut));
- if ($cut > strlen($suffix)) {
- $string = substr($string, 0, $limit).$suffix;
+ if ($cut > @strlen($suffix)) {
+ $string = @substr($string, 0, $limit).$suffix;
}
}
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
@@ -196,10 +196,10 @@
$result = array(
$stdout,
- (string)substr($this->stderr, $this->stderrPos),
+ (string)@substr($this->stderr, $this->stderrPos),
);
- $this->stderrPos = strlen($this->stderr);
+ $this->stderrPos = @strlen($this->stderr);
return $result;
}
@@ -209,8 +209,8 @@
$this->updateFuture(); // Sync
}
- $result = (string)substr($this->stdout, $this->stdoutPos);
- $this->stdoutPos = strlen($this->stdout);
+ $result = (string)@substr($this->stdout, $this->stdoutPos);
+ $this->stdoutPos = @strlen($this->stdout);
return $result;
}
@@ -228,7 +228,7 @@
* @task interact
*/
public function write($data, $keep_pipe = false) {
- if (strlen($data)) {
+ if (@strlen($data)) {
if (!$this->stdin) {
throw new Exception(pht('Writing to a closed pipe!'));
}
@@ -337,7 +337,7 @@
*/
public function resolveJSON() {
list($stdout, $stderr) = $this->resolvex();
- if (strlen($stderr)) {
+ if (@strlen($stderr)) {
$cmd = $this->getCommand();
throw new CommandException(
pht(
@@ -475,7 +475,7 @@
* @task internal
*/
public function isReadBufferEmpty() {
- return !strlen($this->stdout);
+ return !@strlen($this->stdout);
}
@@ -531,17 +531,17 @@
throw new Exception(pht('Failed to read from %s', $description));
}
- $read_bytes = strlen($data);
+ $read_bytes = @strlen($data);
if ($read_bytes > 0 && $limit > 0) {
if ($read_bytes > $limit) {
- $data = substr($data, 0, $limit);
+ $data = @substr($data, 0, $limit);
}
$output .= $data;
- $limit -= strlen($data);
+ $limit -= @strlen($data);
}
- if (strlen($output) >= $length) {
+ if (@strlen($output) >= $length) {
break;
}
} while ($read_bytes > 0);
@@ -757,14 +757,14 @@
$max_stdout_read_bytes = PHP_INT_MAX;
$max_stderr_read_bytes = PHP_INT_MAX;
if ($read_buffer_size !== null) {
- $max_stdout_read_bytes = $read_buffer_size - strlen($this->stdout);
- $max_stderr_read_bytes = $read_buffer_size - strlen($this->stderr);
+ $max_stdout_read_bytes = $read_buffer_size - @strlen($this->stdout);
+ $max_stderr_read_bytes = $read_buffer_size - @strlen($this->stderr);
}
if ($max_stdout_read_bytes > 0) {
$this->stdout .= $this->readAndDiscard(
$stdout,
- $this->getStdoutSizeLimit() - strlen($this->stdout),
+ $this->getStdoutSizeLimit() - @strlen($this->stdout),
'stdout',
$max_stdout_read_bytes);
}
@@ -772,7 +772,7 @@
if ($max_stderr_read_bytes > 0) {
$this->stderr .= $this->readAndDiscard(
$stderr,
- $this->getStderrSizeLimit() - strlen($this->stderr),
+ $this->getStderrSizeLimit() - @strlen($this->stderr),
'stderr',
$max_stderr_read_bytes);
}
diff --git a/src/future/exec/PhutilExecutableFuture.php b/src/future/exec/PhutilExecutableFuture.php
--- a/src/future/exec/PhutilExecutableFuture.php
+++ b/src/future/exec/PhutilExecutableFuture.php
@@ -142,7 +142,7 @@
foreach ($known_keys as $known_key) {
$value = getenv($known_key);
- if (strlen($value)) {
+ if (@strlen($value)) {
$default_env[$known_key] = $value;
}
}
diff --git a/src/future/exec/__tests__/ExecFutureTestCase.php b/src/future/exec/__tests__/ExecFutureTestCase.php
--- a/src/future/exec/__tests__/ExecFutureTestCase.php
+++ b/src/future/exec/__tests__/ExecFutureTestCase.php
@@ -54,7 +54,7 @@
->write($data)
->resolvex();
- $this->assertEqual(substr($data, 0, 1024), $stdout);
+ $this->assertEqual(@substr($data, 0, 1024), $stdout);
}
public function testResolveTimeoutTestShouldRunLessThan1Sec() {
@@ -159,7 +159,7 @@
$bin,
$input);
- $stdout = explode("\n", $stdout);
+ $stdout = @explode("\n", $stdout);
$output = array();
foreach ($stdout as $line) {
$output[] = stripcslashes($line);
@@ -185,7 +185,7 @@
do {
$future->isReady();
list($read) = $future->read();
- if (strlen($read)) {
+ if (@strlen($read)) {
break;
}
} while (true);
@@ -204,7 +204,7 @@
do {
$future->isReady();
list($read) = $future->read();
- if (strlen($read)) {
+ if (@strlen($read)) {
break;
}
} while (true);
diff --git a/src/future/github/PhutilGitHubFuture.php b/src/future/github/PhutilGitHubFuture.php
--- a/src/future/github/PhutilGitHubFuture.php
+++ b/src/future/github/PhutilGitHubFuture.php
@@ -88,7 +88,7 @@
}
try {
- if (strlen($body)) {
+ if (@strlen($body)) {
$data = phutil_json_decode($body);
} else {
// This can happen for 304 responses.
diff --git a/src/future/http/BaseHTTPFuture.php b/src/future/http/BaseHTTPFuture.php
--- a/src/future/http/BaseHTTPFuture.php
+++ b/src/future/http/BaseHTTPFuture.php
@@ -206,12 +206,12 @@
* @task config
*/
public function getHeaders($filter = null) {
- $filter = strtolower($filter);
+ $filter = @strtolower($filter);
$result = array();
foreach ($this->headers as $header) {
list($name, $value) = $header;
- if (!$filter || ($filter == strtolower($name))) {
+ if (!$filter || ($filter == @strtolower($name))) {
$result[] = $header;
}
}
@@ -270,10 +270,10 @@
$data = $this->getData();
if (is_scalar($data)) {
- return strlen($data);
+ return @strlen($data);
}
- return strlen(phutil_build_http_querystring($data));
+ return @strlen(phutil_build_http_querystring($data));
}
public function setDisableContentDecoding($disable_decoding) {
@@ -329,19 +329,19 @@
$response = $raw_response;
while (true) {
$matches = null;
- if (!preg_match($rex_base, $response, $matches)) {
+ if (!@preg_match($rex_base, $response, $matches)) {
return $this->buildMalformedResult($raw_response);
}
$head = $matches['head'];
$body = $matches['body'];
- if (!preg_match($rex_head, $head, $matches)) {
+ if (!@preg_match($rex_head, $head, $matches)) {
return $this->buildMalformedResult($raw_response);
}
$response_code = (int)$matches['code'];
- $response_status = strtolower($matches['status']);
+ $response_status = @strtolower($matches['status']);
if ($response_code == 100) {
// This is HTTP/1.X 100 Continue, so this whole chunk is moot.
$response = $body;
@@ -407,7 +407,7 @@
$headers_raw = preg_split("/\r?\n/", $head_raw);
foreach ($headers_raw as $header) {
$m = null;
- if (preg_match($rex_header, $header, $m)) {
+ if (@preg_match($rex_header, $header, $m)) {
$headers[] = array($m['name'], $m['value']);
} else {
$headers[] = array($header, null);
diff --git a/src/future/http/HTTPFuture.php b/src/future/http/HTTPFuture.php
--- a/src/future/http/HTTPFuture.php
+++ b/src/future/http/HTTPFuture.php
@@ -98,7 +98,7 @@
}
public function getWriteSockets() {
- if (strlen($this->writeBuffer)) {
+ if (@strlen($this->writeBuffer)) {
return array($this->socket);
}
return array();
@@ -136,20 +136,20 @@
}
if ($this->stateConnected) {
- if (strlen($this->writeBuffer)) {
+ if (@strlen($this->writeBuffer)) {
$bytes = @fwrite($this->socket, $this->writeBuffer);
if ($bytes === false) {
throw new Exception(pht('Failed to write to buffer.'));
} else if ($bytes) {
- $this->writeBuffer = substr($this->writeBuffer, $bytes);
+ $this->writeBuffer = @substr($this->writeBuffer, $bytes);
}
}
- if (!strlen($this->writeBuffer)) {
+ if (!@strlen($this->writeBuffer)) {
$this->stateWriteComplete = true;
}
- while (($data = fread($this->socket, 32768)) || strlen($data)) {
+ while (($data = fread($this->socket, 32768)) || @strlen($data)) {
$this->response .= $data;
}
@@ -239,7 +239,7 @@
if ($this->getMethod() == 'GET') {
if (is_array($data)) {
$data = phutil_build_http_querystring($data);
- if (strpos($uri, '?') !== false) {
+ if (@strpos($uri, '?') !== false) {
$uri .= '&'.$data;
} else {
$uri .= '?'.$data;
@@ -256,7 +256,7 @@
}
}
- $length = strlen($data);
+ $length = @strlen($data);
$add_headers[] = array(
'Content-Length',
@@ -280,7 +280,7 @@
$headers = array_merge($this->getHeaders(), $add_headers);
foreach ($headers as $key => $header) {
list($name, $value) = $header;
- if (strlen($value)) {
+ if (@strlen($value)) {
$value = ': '.$value;
}
$headers[$key] = $name.$value."\r\n";
diff --git a/src/future/http/HTTPSFuture.php b/src/future/http/HTTPSFuture.php
--- a/src/future/http/HTTPSFuture.php
+++ b/src/future/http/HTTPSFuture.php
@@ -269,7 +269,7 @@
curl_setopt($curl, CURLOPT_REDIR_PROTOCOLS, $allowed_protocols);
}
- if (strlen($this->rawBody)) {
+ if (@strlen($this->rawBody)) {
if ($this->getData()) {
throw new Exception(
pht(
@@ -288,7 +288,7 @@
// a PUT request.
curl_setopt($curl, CURLOPT_PUT, true);
curl_setopt($curl, CURLOPT_INFILE, $this->fileHandle);
- curl_setopt($curl, CURLOPT_INFILESIZE, strlen($this->rawBody));
+ curl_setopt($curl, CURLOPT_INFILESIZE, @strlen($this->rawBody));
curl_setopt($curl, CURLOPT_READFUNCTION,
array($this, 'willWriteBody'));
} else {
@@ -587,7 +587,7 @@
$this->responseBuffer .= $data;
}
- return strlen($data);
+ return @strlen($data);
}
@@ -616,8 +616,8 @@
'parser.'));
}
- $result = substr($this->responseBuffer, $this->responseBufferPos);
- $this->responseBufferPos = strlen($this->responseBuffer);
+ $result = @substr($this->responseBuffer, $this->responseBufferPos);
+ $this->responseBufferPos = @strlen($this->responseBuffer);
return $result;
}
@@ -686,7 +686,7 @@
$data = $this->getData();
$files = $this->files;
- $any_data = ($data || (is_string($data) && strlen($data)));
+ $any_data = ($data || (is_string($data) && @strlen($data)));
$any_files = (bool)$this->files;
if (!$any_data && !$any_files) {
@@ -841,7 +841,7 @@
* Callback to pass data to cURL.
*/
public function willWriteBody($handle, $infile, $len) {
- $bytes = substr($this->rawBody, $this->rawBodyPos, $len);
+ $bytes = @substr($this->rawBody, $this->rawBodyPos, $len);
$this->rawBodyPos += $len;
return $bytes;
}
diff --git a/src/future/http/status/HTTPFutureCURLResponseStatus.php b/src/future/http/status/HTTPFutureCURLResponseStatus.php
--- a/src/future/http/status/HTTPFutureCURLResponseStatus.php
+++ b/src/future/http/status/HTTPFutureCURLResponseStatus.php
@@ -25,7 +25,7 @@
$constant_name = null;
foreach ($constants as $constant => $value) {
- if ($value == $code && preg_match('/^CURLE_/', $constant)) {
+ if ($value == $code && @preg_match('/^CURLE_/', $constant)) {
$constant_name = '<'.$constant.'> ';
break;
}
diff --git a/src/future/http/status/HTTPFutureHTTPResponseStatus.php b/src/future/http/status/HTTPFutureHTTPResponseStatus.php
--- a/src/future/http/status/HTTPFutureHTTPResponseStatus.php
+++ b/src/future/http/status/HTTPFutureHTTPResponseStatus.php
@@ -13,15 +13,15 @@
// NOTE: Avoiding PhutilUTF8StringTruncator here because this isn't lazy
// and responses may be large.
- if (strlen($body) > 512) {
- $excerpt = substr($body, 0, 512).'...';
+ if (@strlen($body) > 512) {
+ $excerpt = @substr($body, 0, 512).'...';
} else {
$excerpt = $body;
}
$content_type = BaseHTTPFuture::getHeader($headers, 'Content-Type');
$match = null;
- if (preg_match('/;\s*charset=([^;]+)/', $content_type, $match)) {
+ if (@preg_match('/;\s*charset=([^;]+)/', $content_type, $match)) {
$encoding = trim($match[1], "\"'");
try {
$excerpt = phutil_utf8_convert($excerpt, 'UTF-8', $encoding);
diff --git a/src/hardpoint/ArcanistHardpointList.php b/src/hardpoint/ArcanistHardpointList.php
--- a/src/hardpoint/ArcanistHardpointList.php
+++ b/src/hardpoint/ArcanistHardpointList.php
@@ -14,7 +14,7 @@
foreach ($hardpoints as $idx => $hardpoint) {
$key = $hardpoint->getHardpointKey();
- if (!strlen($key)) {
+ if (!@strlen($key)) {
throw new Exception(
pht(
'Hardpoint (at index "%s") has no hardpoint key. Each hardpoint '.
diff --git a/src/hgdaemon/ArcanistHgClientChannel.php b/src/hgdaemon/ArcanistHgClientChannel.php
--- a/src/hgdaemon/ArcanistHgClientChannel.php
+++ b/src/hgdaemon/ArcanistHgClientChannel.php
@@ -63,7 +63,7 @@
$channel = head($argv);
$data = last($argv);
- $len = strlen($data);
+ $len = @strlen($data);
$len = pack('N', $len);
return "{$channel}{$len}{$data}";
@@ -109,13 +109,13 @@
// We're looking for "\n", which indicates the end of the command
// name, like "runcommand". Next, we'll expect a length.
- $pos = strpos($this->buf, "\n");
+ $pos = @strpos($this->buf, "\n");
if ($pos === false) {
break;
}
- $this->command = substr($this->buf, 0, $pos);
- $this->buf = substr($this->buf, $pos + 1);
+ $this->command = @substr($this->buf, 0, $pos);
+ $this->buf = @substr($this->buf, $pos + 1);
$this->mode = self::MODE_LENGTH;
$continue_parsing = true;
@@ -124,15 +124,15 @@
// We're looking for a byte length, as a 4-byte big-endian unsigned
// integer. Next, we'll expect that many bytes of data.
- if (strlen($this->buf) < 4) {
+ if (@strlen($this->buf) < 4) {
break;
}
- $len = substr($this->buf, 0, 4);
+ $len = @substr($this->buf, 0, 4);
$len = unpack('N', $len);
$len = head($len);
- $this->buf = substr($this->buf, 4);
+ $this->buf = @substr($this->buf, 4);
$this->mode = self::MODE_ARGUMENTS;
$this->byteLengthOfNextChunk = $len;
@@ -144,14 +144,14 @@
// of the given length. These are arguments delimited by "\0". Next
// we'll expect another command.
- if (strlen($this->buf) < $this->byteLengthOfNextChunk) {
+ if (@strlen($this->buf) < $this->byteLengthOfNextChunk) {
break;
}
- $data = substr($this->buf, 0, $this->byteLengthOfNextChunk);
- $this->buf = substr($this->buf, $this->byteLengthOfNextChunk);
+ $data = @substr($this->buf, 0, $this->byteLengthOfNextChunk);
+ $this->buf = @substr($this->buf, $this->byteLengthOfNextChunk);
- $message = array_merge(array($this->command), explode("\0", $data));
+ $message = array_merge(array($this->command), @explode("\0", $data));
$this->mode = self::MODE_COMMAND;
$this->command = null;
diff --git a/src/hgdaemon/ArcanistHgServerChannel.php b/src/hgdaemon/ArcanistHgServerChannel.php
--- a/src/hgdaemon/ArcanistHgServerChannel.php
+++ b/src/hgdaemon/ArcanistHgServerChannel.php
@@ -96,7 +96,7 @@
$args = implode("\0", $args);
- $len = strlen($args);
+ $len = @strlen($args);
$len = pack('N', $len);
return "{$command}\n{$len}{$args}";
@@ -128,9 +128,9 @@
// easy to implement.
$messages = array();
- while ($this->byteLengthOfNextChunk <= strlen($this->buf)) {
- $chunk = substr($this->buf, 0, $this->byteLengthOfNextChunk);
- $this->buf = substr($this->buf, $this->byteLengthOfNextChunk);
+ while ($this->byteLengthOfNextChunk <= @strlen($this->buf)) {
+ $chunk = @substr($this->buf, 0, $this->byteLengthOfNextChunk);
+ $this->buf = @substr($this->buf, $this->byteLengthOfNextChunk);
switch ($this->mode) {
case self::MODE_CHANNEL:
diff --git a/src/ip/PhutilCIDRBlock.php b/src/ip/PhutilCIDRBlock.php
--- a/src/ip/PhutilCIDRBlock.php
+++ b/src/ip/PhutilCIDRBlock.php
@@ -23,7 +23,7 @@
}
private static function newFromString($str) {
- if (!preg_match('(^[\d.:a-fA-F]+/[\d]+\z)', $str)) {
+ if (!@preg_match('(^[\d.:a-fA-F]+/[\d]+\z)', $str)) {
throw new Exception(
pht(
'CIDR block "%s" is not formatted correctly. Expected an IP block '.
@@ -33,11 +33,11 @@
'23:45:67:89::/24'));
}
- list($ip, $mask) = explode('/', $str);
+ list($ip, $mask) = @explode('/', $str);
$ip = PhutilIPAddress::newAddress($ip);
- if (preg_match('/^0\d/', $mask)) {
+ if (@preg_match('/^0\d/', $mask)) {
throw new Exception(
pht(
'CIDR block "%s" is not formatted correctly. The IP block mask '.
diff --git a/src/ip/PhutilIPv4Address.php b/src/ip/PhutilIPv4Address.php
--- a/src/ip/PhutilIPv4Address.php
+++ b/src/ip/PhutilIPv4Address.php
@@ -22,7 +22,7 @@
protected static function newFromString($str) {
$matches = null;
- $ok = preg_match('(^(\d+)\.(\d+)\.(\d+).(\d+)\z)', $str, $matches);
+ $ok = @preg_match('(^(\d+)\.(\d+)\.(\d+).(\d+)\z)', $str, $matches);
if (!$ok) {
throw new Exception(
pht(
@@ -34,7 +34,7 @@
$parts = array_slice($matches, 1);
foreach ($parts as $part) {
- if (preg_match('/^0\d/', $part)) {
+ if (@preg_match('/^0\d/', $part)) {
throw new Exception(
pht(
'IP address "%s" is not properly formatted. Address segments '.
@@ -65,7 +65,7 @@
public function toBits() {
if ($this->bits === null) {
$bits = '';
- foreach (explode('.', $this->ip) as $part) {
+ foreach (@explode('.', $this->ip) as $part) {
$value = (int)$part;
for ($ii = 7; $ii >= 0; $ii--) {
$mask = (1 << $ii);
diff --git a/src/ip/PhutilIPv6Address.php b/src/ip/PhutilIPv6Address.php
--- a/src/ip/PhutilIPv6Address.php
+++ b/src/ip/PhutilIPv6Address.php
@@ -18,7 +18,7 @@
}
protected static function newFromString($str) {
- $parts = explode(':', $str);
+ $parts = @explode(':', $str);
if (count($parts) > 8) {
throw new Exception(
pht(
@@ -109,7 +109,7 @@
continue;
}
- if (!preg_match('/^[0-9a-fA-F]{1,4}\z/', $part)) {
+ if (!@preg_match('/^[0-9a-fA-F]{1,4}\z/', $part)) {
throw new Exception(
pht(
'IP address "%s" is not properly formatted: the segments of '.
diff --git a/src/land/engine/ArcanistGitLandEngine.php b/src/land/engine/ArcanistGitLandEngine.php
--- a/src/land/engine/ArcanistGitLandEngine.php
+++ b/src/land/engine/ArcanistGitLandEngine.php
@@ -72,12 +72,12 @@
$foreach_lines = phutil_split_lines($foreach_lines, false);
foreach ($foreach_lines as $line) {
- if (!strlen($line)) {
+ if (!@strlen($line)) {
continue;
}
$expect_parts = 2;
- $parts = explode(' ', $line, $expect_parts);
+ $parts = @explode(' ', $line, $expect_parts);
if (count($parts) !== $expect_parts) {
throw new Exception(
pht(
@@ -89,7 +89,7 @@
$ref_hash = $parts[1];
$matches = null;
- $ok = preg_match('(^refs/heads/(.*)\z)', $ref_name, $matches);
+ $ok = @preg_match('(^refs/heads/(.*)\z)', $ref_name, $matches);
if ($ok === false) {
throw new Exception(
pht(
@@ -280,7 +280,7 @@
$into_commit,
$max_hash));
$changes = trim($changes);
- if (!strlen($changes)) {
+ if (!@strlen($changes)) {
// TODO: We could make a more significant effort to identify the
// human-readable symbol which led us to try to land this ref.
@@ -877,7 +877,7 @@
gitsprintf('%s', $commit));
$info = trim($info);
- list($date, $author, $email) = explode("\n", $info, 3);
+ list($date, $author, $email) = @explode("\n", $info, 3);
return array(
"$author <{$email}>",
@@ -966,7 +966,7 @@
$api = $this->getRepositoryAPI();
foreach ($onto_refs as $onto_ref) {
- if (!strlen($onto_ref)) {
+ if (!@strlen($onto_ref)) {
throw new PhutilArgumentUsageException(
pht(
'Selected "onto" ref "%s" is invalid: the empty string is not '.
@@ -1563,11 +1563,11 @@
$commits = phutil_split_lines($commits, false);
$is_first = true;
foreach ($commits as $line) {
- if (!strlen($line)) {
+ if (!@strlen($line)) {
continue;
}
- $parts = explode("\0", $line, 4);
+ $parts = @explode("\0", $line, 4);
if (count($parts) < 3) {
throw new Exception(
pht(
@@ -1579,8 +1579,8 @@
if (!isset($commit_map[$hash])) {
$parents = $parts[1];
$parents = trim($parents);
- if (strlen($parents)) {
- $parents = explode(' ', $parents);
+ if (@strlen($parents)) {
+ $parents = @explode(' ', $parents);
} else {
$parents = array();
}
diff --git a/src/land/engine/ArcanistMercurialLandEngine.php b/src/land/engine/ArcanistMercurialLandEngine.php
--- a/src/land/engine/ArcanistMercurialLandEngine.php
+++ b/src/land/engine/ArcanistMercurialLandEngine.php
@@ -261,7 +261,7 @@
$api = $this->getRepositoryAPI();
foreach ($onto_refs as $onto_ref) {
- if (!strlen($onto_ref)) {
+ if (!@strlen($onto_ref)) {
throw new PhutilArgumentUsageException(
pht(
'Selected "onto" ref "%s" is invalid: the empty string is not '.
@@ -718,11 +718,11 @@
$commits = phutil_split_lines($commits, false);
$is_first = true;
foreach ($commits as $line) {
- if (!strlen($line)) {
+ if (!@strlen($line)) {
continue;
}
- $parts = explode('-', $line, 3);
+ $parts = @explode('-', $line, 3);
if (count($parts) < 3) {
throw new Exception(
pht(
@@ -734,8 +734,8 @@
if (!isset($commit_map[$hash])) {
$parents = $parts[1];
$parents = trim($parents);
- if (strlen($parents)) {
- $parents = explode(' ', $parents);
+ if (@strlen($parents)) {
+ $parents = @explode(' ', $parents);
} else {
$parents = array();
}
@@ -1007,7 +1007,7 @@
$child_hashes = phutil_split_lines($output, false);
foreach ($child_hashes as $child_hash) {
- if (!strlen($child_hash)) {
+ if (!@strlen($child_hash)) {
continue;
}
diff --git a/src/lexer/PhutilLexer.php b/src/lexer/PhutilLexer.php
--- a/src/lexer/PhutilLexer.php
+++ b/src/lexer/PhutilLexer.php
@@ -192,7 +192,7 @@
// NOTE: The "\G" assertion is an offset-aware version of "^".
$rule[0] = '(\\G'.$rule[0].')'.$flags;
- if (@preg_match($rule[0], '') === false) {
+ if (@@preg_match($rule[0], '') === false) {
$error = error_get_last();
throw new UnexpectedValueException(
pht(
@@ -247,7 +247,7 @@
$this->lastState = null;
$position = 0;
- $length = strlen($input);
+ $length = @strlen($input);
$tokens = array();
$states = array();
@@ -261,13 +261,13 @@
foreach ($state_rules as $rule) {
$matches = null;
- if (!preg_match($rule[0], $input, $matches, 0, $position)) {
+ if (!@preg_match($rule[0], $input, $matches, 0, $position)) {
continue;
}
list($regexp, $token_type, $next_state, $options) = $rule;
- $match_length = strlen($matches[0]);
+ $match_length = @strlen($matches[0]);
if (!$match_length) {
if ($next_state === null) {
throw new UnexpectedValueException(
diff --git a/src/lexer/PhutilShellLexer.php b/src/lexer/PhutilShellLexer.php
--- a/src/lexer/PhutilShellLexer.php
+++ b/src/lexer/PhutilShellLexer.php
@@ -39,7 +39,7 @@
break;
case 'esc':
$tokens[$key][0] = 'arg';
- $tokens[$key][1] = substr($token[1], 1);
+ $tokens[$key][1] = @substr($token[1], 1);
break;
default:
break;
diff --git a/src/lexer/PhutilSimpleOptionsLexer.php b/src/lexer/PhutilSimpleOptionsLexer.php
--- a/src/lexer/PhutilSimpleOptionsLexer.php
+++ b/src/lexer/PhutilSimpleOptionsLexer.php
@@ -19,7 +19,7 @@
switch ($type) {
case 'esc':
$tokens[$key][0] = 'word';
- $tokens[$key][1] = substr($value, 1);
+ $tokens[$key][1] = @substr($value, 1);
break;
}
}
diff --git a/src/lint/ArcanistLintMessage.php b/src/lint/ArcanistLintMessage.php
--- a/src/lint/ArcanistLintMessage.php
+++ b/src/lint/ArcanistLintMessage.php
@@ -101,7 +101,7 @@
$code = (string)$code;
$maximum_bytes = 128;
- $actual_bytes = strlen($code);
+ $actual_bytes = @strlen($code);
if ($actual_bytes > $maximum_bytes) {
throw new Exception(
@@ -134,7 +134,7 @@
public function setName($name) {
$maximum_bytes = 255;
- $actual_bytes = strlen($name);
+ $actual_bytes = @strlen($name);
if ($actual_bytes > $maximum_bytes) {
throw new Exception(
@@ -282,7 +282,7 @@
}
// Strings like "234" are fine, coerce them to integers.
- if (is_string($value) && preg_match('/^\d+\z/', $value)) {
+ if (is_string($value) && @preg_match('/^\d+\z/', $value)) {
$value = (int)$value;
}
@@ -307,8 +307,8 @@
$replacement = $this->getReplacementText();
$original = $this->getOriginalText();
- $replacement_length = strlen($replacement);
- $original_length = strlen($original);
+ $replacement_length = @strlen($replacement);
+ $original_length = @strlen($original);
$minimum_length = min($original_length, $replacement_length);
@@ -340,21 +340,21 @@
}
if ($suffix_length) {
- $original = substr($original, 0, -$suffix_length);
- $replacement = substr($replacement, 0, -$suffix_length);
+ $original = @substr($original, 0, -$suffix_length);
+ $replacement = @substr($replacement, 0, -$suffix_length);
}
$line = $this->getLine();
$char = $this->getChar();
if ($prefix_length) {
- $prefix = substr($original, 0, $prefix_length);
+ $prefix = @substr($original, 0, $prefix_length);
- // NOTE: Prior to PHP7, `substr("a", 1)` returned false instead of
+ // NOTE: Prior to PHP7, `@substr("a", 1)` returned false instead of
// the empty string. Cast these to force the PHP7-ish behavior we
// expect.
- $original = (string)substr($original, $prefix_length);
- $replacement = (string)substr($replacement, $prefix_length);
+ $original = (string)@substr($original, $prefix_length);
+ $replacement = (string)@substr($replacement, $prefix_length);
// If we've removed a prefix, we need to push the character and line
// number for the warning forward to account for the characters we threw
diff --git a/src/lint/ArcanistLintPatcher.php b/src/lint/ArcanistLintPatcher.php
--- a/src/lint/ArcanistLintPatcher.php
+++ b/src/lint/ArcanistLintPatcher.php
@@ -85,11 +85,11 @@
$working_offset = $orig_offset + $this->getCharacterDelta();
$old_str = $lint->getOriginalText();
- $old_len = strlen($old_str);
+ $old_len = @strlen($old_str);
$new_str = $lint->getReplacementText();
- $new_len = strlen($new_str);
+ $new_len = @strlen($new_str);
- if ($working_offset == strlen($data)) {
+ if ($working_offset == @strlen($data)) {
// Temporary hack to work around a destructive hphpi issue, see #451031.
$data .= $new_str;
} else {
@@ -107,12 +107,12 @@
private function getCharacterOffset($line_num) {
if ($this->lineOffsets === null) {
- $lines = explode("\n", $this->getUnmodifiedFileContent());
+ $lines = @explode("\n", $this->getUnmodifiedFileContent());
$this->lineOffsets = array(0);
$last = 0;
foreach ($lines as $line) {
- $this->lineOffsets[] = $last + strlen($line) + 1;
- $last += strlen($line) + 1;
+ $this->lineOffsets[] = $last + @strlen($line) + 1;
+ $last += @strlen($line) + 1;
}
}
diff --git a/src/lint/engine/ArcanistComprehensiveLintEngine.php b/src/lint/engine/ArcanistComprehensiveLintEngine.php
--- a/src/lint/engine/ArcanistComprehensiveLintEngine.php
+++ b/src/lint/engine/ArcanistComprehensiveLintEngine.php
@@ -11,7 +11,7 @@
$paths = $this->getPaths();
foreach ($paths as $key => $path) {
- if (preg_match('@^externals/@', $path)) {
+ if (@preg_match('@^externals/@', $path)) {
// Third-party stuff lives in /externals/; don't run lint engines
// against it.
unset($paths[$key]);
diff --git a/src/lint/engine/ArcanistConfigurationDrivenLintEngine.php b/src/lint/engine/ArcanistConfigurationDrivenLintEngine.php
--- a/src/lint/engine/ArcanistConfigurationDrivenLintEngine.php
+++ b/src/lint/engine/ArcanistConfigurationDrivenLintEngine.php
@@ -158,7 +158,7 @@
$keep = true;
} else {
foreach ($include as $rule) {
- if (preg_match($rule, $path)) {
+ if (@preg_match($rule, $path)) {
$keep = true;
break;
}
@@ -171,7 +171,7 @@
if ($exclude) {
foreach ($exclude as $rule) {
- if (preg_match($rule, $path)) {
+ if (@preg_match($rule, $path)) {
continue 2;
}
}
@@ -179,7 +179,7 @@
if ($global_exclude) {
foreach ($global_exclude as $rule) {
- if (preg_match($rule, $path)) {
+ if (@preg_match($rule, $path)) {
continue 2;
}
}
diff --git a/src/lint/engine/ArcanistLintEngine.php b/src/lint/engine/ArcanistLintEngine.php
--- a/src/lint/engine/ArcanistLintEngine.php
+++ b/src/lint/engine/ArcanistLintEngine.php
@@ -383,11 +383,11 @@
$char_to_line = array();
$line_to_first_char = array();
- $lines = explode("\n", $this->loadData($path));
+ $lines = @explode("\n", $this->loadData($path));
$line_number = 0;
$line_start = 0;
foreach ($lines as $line) {
- $len = strlen($line) + 1; // Account for "\n".
+ $len = @strlen($line) + 1; // Account for "\n".
$line_to_first_char[] = $line_start;
$line_start += $len;
for ($ii = 0; $ii < $len; $ii++) {
@@ -606,7 +606,7 @@
ArcanistLintMessage $message) {
$name = $message->getName();
- if (!strlen($name)) {
+ if (!@strlen($name)) {
throw new Exception(
pht(
'Linter "%s" generated a lint message that is invalid because it '.
diff --git a/src/lint/linter/ArcanistBaseXHPASTLinter.php b/src/lint/linter/ArcanistBaseXHPASTLinter.php
--- a/src/lint/linter/ArcanistBaseXHPASTLinter.php
+++ b/src/lint/linter/ArcanistBaseXHPASTLinter.php
@@ -219,7 +219,7 @@
foreach ($calls as $call) {
$node = $call->getChildByIndex(0);
- $name = strtolower($node->getConcreteString());
+ $name = @strtolower($node->getConcreteString());
if (in_array($name, $function_names)) {
$nodes[] = $call;
diff --git a/src/lint/linter/ArcanistCSSLintLinter.php b/src/lint/linter/ArcanistCSSLintLinter.php
--- a/src/lint/linter/ArcanistCSSLintLinter.php
+++ b/src/lint/linter/ArcanistCSSLintLinter.php
@@ -41,7 +41,7 @@
list($stdout) = execx('%C --version', $this->getExecutableCommand());
$matches = array();
- if (preg_match('/^v(?P<version>\d+\.\d+\.\d+)$/', $stdout, $matches)) {
+ if (@preg_match('/^v(?P<version>\d+\.\d+\.\d+)$/', $stdout, $matches)) {
return $matches['version'];
} else {
return false;
@@ -78,7 +78,7 @@
if ($char === '') {
$char = null;
} else {
- $original_text = substr($original_text, $char - 1);
+ $original_text = @substr($original_text, $char - 1);
}
$message = id(new ArcanistLintMessage())
diff --git a/src/lint/linter/ArcanistCSharpLinter.php b/src/lint/linter/ArcanistCSharpLinter.php
--- a/src/lint/linter/ArcanistCSharpLinter.php
+++ b/src/lint/linter/ArcanistCSharpLinter.php
@@ -60,7 +60,7 @@
public function setCustomSeverityMap(array $map) {
foreach ($map as $code => $severity) {
- if (substr($code, 0, 2) === 'SA' && $severity == 'disabled') {
+ if (@substr($code, 0, 2) === 'SA' && $severity == 'disabled') {
throw new Exception(
pht(
"In order to keep StyleCop integration with IDEs and other tools ".
@@ -157,9 +157,9 @@
// command line limit), then finalize this future and add it.
$total = 0;
foreach ($current_paths as $current_path) {
- $total += strlen($current_path) + 3; // Quotes and space.
+ $total += @strlen($current_path) + 3; // Quotes and space.
}
- if ($total + strlen($path) > 6000) {
+ if ($total + @strlen($path) > 6000) {
// %s won't pass through the JSON correctly
// under Windows. This is probably because not only
// does the JSON have quotation marks in the content,
diff --git a/src/lint/linter/ArcanistChmodLinter.php b/src/lint/linter/ArcanistChmodLinter.php
--- a/src/lint/linter/ArcanistChmodLinter.php
+++ b/src/lint/linter/ArcanistChmodLinter.php
@@ -124,7 +124,7 @@
$line = head(phutil_split_lines($this->getEngine()->loadData($path), true));
$matches = array();
- if (preg_match('/^#!(.*)$/', $line, $matches)) {
+ if (@preg_match('/^#!(.*)$/', $line, $matches)) {
return $matches[1];
} else {
return null;
diff --git a/src/lint/linter/ArcanistClosureLinter.php b/src/lint/linter/ArcanistClosureLinter.php
--- a/src/lint/linter/ArcanistClosureLinter.php
+++ b/src/lint/linter/ArcanistClosureLinter.php
@@ -42,7 +42,7 @@
foreach ($lines as $line) {
$matches = null;
- if (!preg_match('/^Line (\d+), E:(\d+): (.*)/', $line, $matches)) {
+ if (!@preg_match('/^Line (\d+), E:(\d+): (.*)/', $line, $matches)) {
continue;
}
diff --git a/src/lint/linter/ArcanistCoffeeLintLinter.php b/src/lint/linter/ArcanistCoffeeLintLinter.php
--- a/src/lint/linter/ArcanistCoffeeLintLinter.php
+++ b/src/lint/linter/ArcanistCoffeeLintLinter.php
@@ -34,7 +34,7 @@
list($stdout) = execx('%C --version', $this->getExecutableCommand());
$matches = array();
- if (preg_match('/^(?P<version>\d+\.\d+\.\d+)$/', $stdout, $matches)) {
+ if (@preg_match('/^(?P<version>\d+\.\d+\.\d+)$/', $stdout, $matches)) {
return $matches['version'];
} else {
return false;
diff --git a/src/lint/linter/ArcanistCppcheckLinter.php b/src/lint/linter/ArcanistCppcheckLinter.php
--- a/src/lint/linter/ArcanistCppcheckLinter.php
+++ b/src/lint/linter/ArcanistCppcheckLinter.php
@@ -36,7 +36,7 @@
$matches = array();
$regex = '/^Cppcheck (?P<version>\d+\.\d+)$/';
- if (preg_match($regex, $stdout, $matches)) {
+ if (@preg_match($regex, $stdout, $matches)) {
return $matches['version'];
} else {
return false;
diff --git a/src/lint/linter/ArcanistCpplintLinter.php b/src/lint/linter/ArcanistCpplintLinter.php
--- a/src/lint/linter/ArcanistCpplintLinter.php
+++ b/src/lint/linter/ArcanistCpplintLinter.php
@@ -30,14 +30,14 @@
}
protected function parseLinterOutput($path, $err, $stdout, $stderr) {
- $lines = explode("\n", $stderr);
+ $lines = @explode("\n", $stderr);
$messages = array();
foreach ($lines as $line) {
$line = trim($line);
$matches = null;
$regex = '/(\d+):\s*(.*)\s*\[(.*)\] \[(\d+)\]$/';
- if (!preg_match($regex, $line, $matches)) {
+ if (!@preg_match($regex, $line, $matches)) {
continue;
}
foreach ($matches as $key => $match) {
@@ -71,7 +71,7 @@
}
protected function getLintCodeFromLinterConfigurationKey($code) {
- if (!preg_match('@^[a-z_]+/[a-z0-9_+]+$@', $code)) {
+ if (!@preg_match('@^[a-z_]+/[a-z0-9_+]+$@', $code)) {
throw new Exception(
pht(
'Unrecognized lint message code "%s". Expected a valid cpplint '.
diff --git a/src/lint/linter/ArcanistExternalLinter.php b/src/lint/linter/ArcanistExternalLinter.php
--- a/src/lint/linter/ArcanistExternalLinter.php
+++ b/src/lint/linter/ArcanistExternalLinter.php
@@ -314,7 +314,7 @@
$compare_to = $this->versionRequirement;
$matches = null;
- if (preg_match('/^([<>]=?|=)\s*(.*)$/', $compare_to, $matches)) {
+ if (@preg_match('/^([<>]=?|=)\s*(.*)$/', $compare_to, $matches)) {
$operator = $matches[1];
$compare_to = $matches[2];
if ($operator === '=') {
diff --git a/src/lint/linter/ArcanistFilenameLinter.php b/src/lint/linter/ArcanistFilenameLinter.php
--- a/src/lint/linter/ArcanistFilenameLinter.php
+++ b/src/lint/linter/ArcanistFilenameLinter.php
@@ -36,7 +36,7 @@
}
public function lintPath($path) {
- if (!preg_match('@^[a-z0-9./\\\\_-]+$@i', $path)) {
+ if (!@preg_match('@^[a-z0-9./\\\\_-]+$@i', $path)) {
$this->raiseLintAtPath(
self::LINT_BAD_FILENAME,
pht(
diff --git a/src/lint/linter/ArcanistFlake8Linter.php b/src/lint/linter/ArcanistFlake8Linter.php
--- a/src/lint/linter/ArcanistFlake8Linter.php
+++ b/src/lint/linter/ArcanistFlake8Linter.php
@@ -37,7 +37,7 @@
list($stdout) = execx('%C --version', $this->getExecutableCommand());
$matches = array();
- if (preg_match('/^(?P<version>\d+\.\d+(?:\.\d+)?)\b/', $stdout, $matches)) {
+ if (@preg_match('/^(?P<version>\d+\.\d+(?:\.\d+)?)\b/', $stdout, $matches)) {
return $matches['version'];
} else {
return false;
@@ -59,7 +59,7 @@
$messages = array();
foreach ($lines as $line) {
$matches = null;
- if (!preg_match($regexp, $line, $matches)) {
+ if (!@preg_match($regexp, $line, $matches)) {
continue;
}
foreach ($matches as $key => $match) {
@@ -84,10 +84,10 @@
}
protected function getDefaultMessageSeverity($code) {
- if (preg_match('/^C/', $code)) {
+ if (@preg_match('/^C/', $code)) {
// "C": Cyclomatic complexity
return ArcanistLintSeverity::SEVERITY_ADVICE;
- } else if (preg_match('/^W/', $code)) {
+ } else if (@preg_match('/^W/', $code)) {
// "W": PEP8 Warning
return ArcanistLintSeverity::SEVERITY_WARNING;
} else {
@@ -99,7 +99,7 @@
}
protected function getLintCodeFromLinterConfigurationKey($code) {
- if (!preg_match('/^[A-Z]\d+$/', $code)) {
+ if (!@preg_match('/^[A-Z]\d+$/', $code)) {
throw new Exception(
pht(
'Unrecognized lint message code "%s". Expected a valid flake8 '.
diff --git a/src/lint/linter/ArcanistGeneratedLinter.php b/src/lint/linter/ArcanistGeneratedLinter.php
--- a/src/lint/linter/ArcanistGeneratedLinter.php
+++ b/src/lint/linter/ArcanistGeneratedLinter.php
@@ -34,7 +34,7 @@
public function lintPath($path) {
$data = $this->getData($path);
- if (preg_match('/@'.'generated/', $data)) {
+ if (@preg_match('/@'.'generated/', $data)) {
$this->stopAllLinters();
}
}
diff --git a/src/lint/linter/ArcanistGoLintLinter.php b/src/lint/linter/ArcanistGoLintLinter.php
--- a/src/lint/linter/ArcanistGoLintLinter.php
+++ b/src/lint/linter/ArcanistGoLintLinter.php
@@ -45,7 +45,7 @@
$messages = array();
foreach ($lines as $line) {
- $matches = explode(':', $line, 4);
+ $matches = @explode(':', $line, 4);
if (count($matches) === 4) {
$message = new ArcanistLintMessage();
diff --git a/src/lint/linter/ArcanistHLintLinter.php b/src/lint/linter/ArcanistHLintLinter.php
--- a/src/lint/linter/ArcanistHLintLinter.php
+++ b/src/lint/linter/ArcanistHLintLinter.php
@@ -42,7 +42,7 @@
'%C --version', $this->getExecutableCommand());
$matches = null;
- if (preg_match('@HLint v(.*),@', $stdout, $matches)) {
+ if (@preg_match('@HLint v(.*),@', $stdout, $matches)) {
return $matches[1];
}
diff --git a/src/lint/linter/ArcanistInlineHTMLXHPASTLinterRule.php b/src/lint/linter/ArcanistInlineHTMLXHPASTLinterRule.php
--- a/src/lint/linter/ArcanistInlineHTMLXHPASTLinterRule.php
+++ b/src/lint/linter/ArcanistInlineHTMLXHPASTLinterRule.php
@@ -17,12 +17,12 @@
$inline_html = $root->selectTokensOfType('T_INLINE_HTML');
foreach ($inline_html as $html) {
- if (substr($html->getValue(), 0, 2) == '#!') {
+ if (@substr($html->getValue(), 0, 2) == '#!') {
// Ignore shebang lines.
continue;
}
- if (preg_match('/^\s*$/', $html->getValue())) {
+ if (@preg_match('/^\s*$/', $html->getValue())) {
continue;
}
diff --git a/src/lint/linter/ArcanistJSHintLinter.php b/src/lint/linter/ArcanistJSHintLinter.php
--- a/src/lint/linter/ArcanistJSHintLinter.php
+++ b/src/lint/linter/ArcanistJSHintLinter.php
@@ -31,9 +31,9 @@
}
protected function getDefaultMessageSeverity($code) {
- if (preg_match('/^W/', $code)) {
+ if (@preg_match('/^W/', $code)) {
return ArcanistLintSeverity::SEVERITY_WARNING;
- } else if (preg_match('/^E043$/', $code)) {
+ } else if (@preg_match('/^E043$/', $code)) {
// TODO: If JSHint encounters a large number of errors, it will quit
// prematurely and add an additional "Too Many Errors" error. Ideally, we
// should be able to pass some sort of `--force` option to `jshint`.
@@ -57,7 +57,7 @@
$matches = array();
$regex = '/^jshint v(?P<version>\d+\.\d+\.\d+)$/';
- if (preg_match($regex, $stderr, $matches)) {
+ if (@preg_match($regex, $stderr, $matches)) {
return $matches['version'];
} else {
return false;
@@ -142,7 +142,7 @@
}
protected function getLintCodeFromLinterConfigurationKey($code) {
- if (!preg_match('/^(E|W)\d+$/', $code)) {
+ if (!@preg_match('/^(E|W)\d+$/', $code)) {
throw new Exception(
pht(
'Unrecognized lint message code "%s". Expected a valid JSHint '.
diff --git a/src/lint/linter/ArcanistJSONLintLinter.php b/src/lint/linter/ArcanistJSONLintLinter.php
--- a/src/lint/linter/ArcanistJSONLintLinter.php
+++ b/src/lint/linter/ArcanistJSONLintLinter.php
@@ -36,7 +36,7 @@
$this->getExecutableCommand());
$matches = array();
- if (preg_match('/^(?P<version>\d+\.\d+\.\d+)$/', $stdout, $matches)) {
+ if (@preg_match('/^(?P<version>\d+\.\d+\.\d+)$/', $stdout, $matches)) {
return $matches['version'];
} else {
return false;
@@ -59,7 +59,7 @@
$messages = array();
foreach ($lines as $line) {
$matches = null;
- $match = preg_match(
+ $match = @preg_match(
'/^(?:(?<path>.+): )?'.
'line (?<line>\d+), col (?<column>\d+), '.
'(?<description>.*)$/',
diff --git a/src/lint/linter/ArcanistJscsLinter.php b/src/lint/linter/ArcanistJscsLinter.php
--- a/src/lint/linter/ArcanistJscsLinter.php
+++ b/src/lint/linter/ArcanistJscsLinter.php
@@ -36,7 +36,7 @@
$matches = array();
$regex = '/^(?P<version>\d+\.\d+\.\d+)$/';
- if (preg_match($regex, $stdout, $matches)) {
+ if (@preg_match($regex, $stdout, $matches)) {
return $matches['version'];
} else {
return false;
diff --git a/src/lint/linter/ArcanistLesscLinter.php b/src/lint/linter/ArcanistLesscLinter.php
--- a/src/lint/linter/ArcanistLesscLinter.php
+++ b/src/lint/linter/ArcanistLesscLinter.php
@@ -92,7 +92,7 @@
$matches = array();
$regex = '/^lessc (?P<version>\d+\.\d+\.\d+)\b/';
- if (preg_match($regex, $stdout, $matches)) {
+ if (@preg_match($regex, $stdout, $matches)) {
$version = $matches['version'];
} else {
return false;
@@ -118,7 +118,7 @@
$messages = array();
foreach ($lines as $line) {
$matches = null;
- $match = preg_match(
+ $match = @preg_match(
'/^(?P<name>\w+): (?P<description>.+) '.
'in (?P<path>.+|-) '.
'on line (?P<line>\d+), column (?P<column>\d+):$/',
diff --git a/src/lint/linter/ArcanistLinter.php b/src/lint/linter/ArcanistLinter.php
--- a/src/lint/linter/ArcanistLinter.php
+++ b/src/lint/linter/ArcanistLinter.php
@@ -354,7 +354,7 @@
}
foreach ($this->customSeverityRules as $rule => $severity) {
- if (preg_match($rule, $code)) {
+ if (@preg_match($rule, $code)) {
return $severity;
}
}
@@ -550,7 +550,7 @@
}
foreach ($value as $rule => $severity) {
- if (@preg_match($rule, '') === false) {
+ if (@@preg_match($rule, '') === false) {
throw new Exception(
pht(
'Severity rule "%s" is not a valid regular expression.',
diff --git a/src/lint/linter/ArcanistMergeConflictLinter.php b/src/lint/linter/ArcanistMergeConflictLinter.php
--- a/src/lint/linter/ArcanistMergeConflictLinter.php
+++ b/src/lint/linter/ArcanistMergeConflictLinter.php
@@ -37,7 +37,7 @@
foreach ($lines as $lineno => $line) {
// An unresolved merge conflict will contain a series of seven
// '<', '=', or '>'.
- if (preg_match('/^(>{7}|<{7}|={7})$/', $line)) {
+ if (@preg_match('/^(>{7}|<{7}|={7})$/', $line)) {
$this->raiseLintAtLine(
$lineno + 1,
1,
diff --git a/src/lint/linter/ArcanistNoLintLinter.php b/src/lint/linter/ArcanistNoLintLinter.php
--- a/src/lint/linter/ArcanistNoLintLinter.php
+++ b/src/lint/linter/ArcanistNoLintLinter.php
@@ -34,7 +34,7 @@
public function lintPath($path) {
$data = $this->getData($path);
- if (preg_match('/@'.'nolint/', $data)) {
+ if (@preg_match('/@'.'nolint/', $data)) {
$this->stopAllLinters();
}
}
diff --git a/src/lint/linter/ArcanistPEP8Linter.php b/src/lint/linter/ArcanistPEP8Linter.php
--- a/src/lint/linter/ArcanistPEP8Linter.php
+++ b/src/lint/linter/ArcanistPEP8Linter.php
@@ -35,7 +35,7 @@
list($stdout) = execx('%C --version', $this->getExecutableCommand());
$matches = array();
- if (preg_match('/^(?P<version>\d+\.\d+(?:\.\d+)?)\b/', $stdout, $matches)) {
+ if (@preg_match('/^(?P<version>\d+\.\d+(?:\.\d+)?)\b/', $stdout, $matches)) {
return $matches['version'];
} else {
return false;
@@ -52,7 +52,7 @@
$messages = array();
foreach ($lines as $line) {
$matches = null;
- if (!preg_match('/^(.*?):(\d+):(\d+): (\S+) (.*)$/', $line, $matches)) {
+ if (!@preg_match('/^(.*?):(\d+):(\d+): (\S+) (.*)$/', $line, $matches)) {
continue;
}
foreach ($matches as $key => $match) {
@@ -74,7 +74,7 @@
}
protected function getDefaultMessageSeverity($code) {
- if (preg_match('/^W/', $code)) {
+ if (@preg_match('/^W/', $code)) {
return ArcanistLintSeverity::SEVERITY_WARNING;
} else {
return ArcanistLintSeverity::SEVERITY_ERROR;
@@ -82,7 +82,7 @@
}
protected function getLintCodeFromLinterConfigurationKey($code) {
- if (!preg_match('/^(E|W)\d+$/', $code)) {
+ if (!@preg_match('/^(E|W)\d+$/', $code)) {
throw new Exception(
pht(
'Unrecognized lint message code "%s". Expected a valid PEP8 '.
diff --git a/src/lint/linter/ArcanistPhpLinter.php b/src/lint/linter/ArcanistPhpLinter.php
--- a/src/lint/linter/ArcanistPhpLinter.php
+++ b/src/lint/linter/ArcanistPhpLinter.php
@@ -67,7 +67,7 @@
$regex = '/^(PHP )?(?<type>.+) error: +(?<error>.+) in (?<file>.+) '.
'on line (?<line>\d+)$/m';
- if (preg_match($regex, $stdout, $matches)) {
+ if (@preg_match($regex, $stdout, $matches)) {
$code = $this->getLintCodeFromLinterConfigurationKey($matches['type']);
$message = id(new ArcanistLintMessage())
diff --git a/src/lint/linter/ArcanistPhpcsLinter.php b/src/lint/linter/ArcanistPhpcsLinter.php
--- a/src/lint/linter/ArcanistPhpcsLinter.php
+++ b/src/lint/linter/ArcanistPhpcsLinter.php
@@ -74,7 +74,7 @@
$matches = array();
$regex = '/^PHP_CodeSniffer version (?P<version>\d+\.\d+\.\d+)\b/';
- if (preg_match($regex, $stdout, $matches)) {
+ if (@preg_match($regex, $stdout, $matches)) {
return $matches['version'];
} else {
return false;
@@ -129,7 +129,7 @@
}
protected function getDefaultMessageSeverity($code) {
- if (preg_match('/^PHPCS\\.W\\./', $code)) {
+ if (@preg_match('/^PHPCS\\.W\\./', $code)) {
return ArcanistLintSeverity::SEVERITY_WARNING;
} else {
return ArcanistLintSeverity::SEVERITY_ERROR;
@@ -137,7 +137,7 @@
}
protected function getLintCodeFromLinterConfigurationKey($code) {
- if (!preg_match('/^PHPCS\\.(E|W)\\./', $code)) {
+ if (!@preg_match('/^PHPCS\\.(E|W)\\./', $code)) {
throw new Exception(
pht(
"Invalid severity code '%s', should begin with '%s.'.",
diff --git a/src/lint/linter/ArcanistPuppetLintLinter.php b/src/lint/linter/ArcanistPuppetLintLinter.php
--- a/src/lint/linter/ArcanistPuppetLintLinter.php
+++ b/src/lint/linter/ArcanistPuppetLintLinter.php
@@ -39,7 +39,7 @@
$matches = array();
$regex = '/^puppet-lint (?P<version>\d+\.\d+\.\d+)$/';
- if (preg_match($regex, $stdout, $matches)) {
+ if (@preg_match($regex, $stdout, $matches)) {
return $matches['version'];
} else {
return false;
@@ -102,7 +102,7 @@
$messages = array();
foreach ($lines as $line) {
- $matches = explode('|', $line, 5);
+ $matches = @explode('|', $line, 5);
if (count($matches) < 5) {
continue;
diff --git a/src/lint/linter/ArcanistPyFlakesLinter.php b/src/lint/linter/ArcanistPyFlakesLinter.php
--- a/src/lint/linter/ArcanistPyFlakesLinter.php
+++ b/src/lint/linter/ArcanistPyFlakesLinter.php
@@ -36,7 +36,7 @@
$matches = array();
$pattern = '/^(?P<version>\d+\.\d+\.\d+)( Python.*)?$/';
- if (preg_match($pattern, $stdout, $matches)) {
+ if (@preg_match($pattern, $stdout, $matches)) {
return $matches['version'];
} else {
return false;
@@ -54,7 +54,7 @@
foreach ($lines as $line) {
$matches = null;
$pattern = '/^(?<path>.*?):(?<line>\d+):(?<column>\d*) (?<message>.*)$/';
- if (!preg_match($pattern, $line, $matches)) {
+ if (!@preg_match($pattern, $line, $matches)) {
continue;
}
foreach ($matches as $key => $match) {
@@ -65,7 +65,7 @@
$description = $matches['message'];
$error_regexp = '/(^undefined|^duplicate|before assignment$)/';
- if (preg_match($error_regexp, $description)) {
+ if (@preg_match($error_regexp, $description)) {
$severity = ArcanistLintSeverity::SEVERITY_ERROR;
}
diff --git a/src/lint/linter/ArcanistPyLintLinter.php b/src/lint/linter/ArcanistPyLintLinter.php
--- a/src/lint/linter/ArcanistPyLintLinter.php
+++ b/src/lint/linter/ArcanistPyLintLinter.php
@@ -39,7 +39,7 @@
$matches = array();
$regex = '/^pylint (?P<version>\d+\.\d+\.\d+)/';
- if (preg_match($regex, $stdout, $matches)) {
+ if (@preg_match($regex, $stdout, $matches)) {
return $matches['version'];
} else {
return false;
@@ -124,7 +124,7 @@
$messages = array();
foreach ($lines as $line) {
- $matches = explode('|', $line, 5);
+ $matches = @explode('|', $line, 5);
if (count($matches) < 5) {
continue;
@@ -151,7 +151,7 @@
}
protected function getDefaultMessageSeverity($code) {
- switch (substr($code, 0, 1)) {
+ switch (@substr($code, 0, 1)) {
case 'R':
case 'C':
return ArcanistLintSeverity::SEVERITY_ADVICE;
@@ -166,7 +166,7 @@
}
protected function getLintCodeFromLinterConfigurationKey($code) {
- if (!preg_match('/^(R|C|W|E|F)\d{4}$/', $code)) {
+ if (!@preg_match('/^(R|C|W|E|F)\d{4}$/', $code)) {
throw new Exception(
pht(
'Unrecognized lint message code "%s". Expected a valid Pylint '.
diff --git a/src/lint/linter/ArcanistRuboCopLinter.php b/src/lint/linter/ArcanistRuboCopLinter.php
--- a/src/lint/linter/ArcanistRuboCopLinter.php
+++ b/src/lint/linter/ArcanistRuboCopLinter.php
@@ -34,7 +34,7 @@
list($stdout) = execx('%C --version', $this->getExecutableCommand());
$matches = array();
- if (preg_match('/^(?P<version>\d+\.\d+\.\d+)$/', $stdout, $matches)) {
+ if (@preg_match('/^(?P<version>\d+\.\d+\.\d+)$/', $stdout, $matches)) {
return $matches['version'];
} else {
return false;
diff --git a/src/lint/linter/ArcanistRubyLinter.php b/src/lint/linter/ArcanistRubyLinter.php
--- a/src/lint/linter/ArcanistRubyLinter.php
+++ b/src/lint/linter/ArcanistRubyLinter.php
@@ -36,7 +36,7 @@
$matches = array();
$regex = '/^ruby (?P<version>\d+\.\d+\.\d+)+/';
- if (preg_match($regex, $stdout, $matches)) {
+ if (@preg_match($regex, $stdout, $matches)) {
return $matches['version'];
} else {
return false;
@@ -60,7 +60,7 @@
foreach ($lines as $line) {
$matches = null;
- if (!preg_match('/(.*?):(\d+): (.*?)$/', $line, $matches)) {
+ if (!@preg_match('/(.*?):(\d+): (.*?)$/', $line, $matches)) {
continue;
}
@@ -68,7 +68,7 @@
$matches[$key] = trim($match);
}
- $code = head(explode(',', $matches[3]));
+ $code = head(@explode(',', $matches[3]));
$message = new ArcanistLintMessage();
$message->setPath($path);
diff --git a/src/lint/linter/ArcanistScriptAndRegexLinter.php b/src/lint/linter/ArcanistScriptAndRegexLinter.php
--- a/src/lint/linter/ArcanistScriptAndRegexLinter.php
+++ b/src/lint/linter/ArcanistScriptAndRegexLinter.php
@@ -204,7 +204,7 @@
*/
public function lintPath($path) {
$output = idx($this->output, $path);
- if (!strlen($output)) {
+ if (!@strlen($output)) {
// No output, but it exited 0, so just move on.
return;
}
@@ -338,7 +338,7 @@
}
$line = idx($match, 'line');
- if (strlen($line)) {
+ if (@strlen($line)) {
$line = (int)$line;
if (!$line) {
$line = 1;
@@ -376,7 +376,7 @@
'disabled' => ArcanistLintSeverity::SEVERITY_DISABLED,
);
- $severity_name = strtolower(idx($match, 'severity'));
+ $severity_name = @strtolower(idx($match, 'severity'));
foreach ($map as $name => $severity) {
if (!empty($match[$name])) {
diff --git a/src/lint/linter/ArcanistSpellingLinter.php b/src/lint/linter/ArcanistSpellingLinter.php
--- a/src/lint/linter/ArcanistSpellingLinter.php
+++ b/src/lint/linter/ArcanistSpellingLinter.php
@@ -148,12 +148,12 @@
private function checkPartialWord($path, $word, $correction) {
$text = $this->getData($path);
$pos = 0;
- while ($pos < strlen($text)) {
+ while ($pos < @strlen($text)) {
$next = stripos($text, $word, $pos);
if ($next === false) {
return;
}
- $original = substr($text, $next, strlen($word));
+ $original = @substr($text, $next, @strlen($word));
$replacement = self::fixLetterCase($correction, $original);
$this->raiseLintAtOffset(
$next,
@@ -170,12 +170,12 @@
public static function fixLetterCase($string, $case) {
switch ($case) {
- case strtolower($case):
- return strtolower($string);
+ case @strtolower($case):
+ return @strtolower($string);
case strtoupper($case):
return strtoupper($string);
- case ucwords(strtolower($case)):
- return ucwords(strtolower($string));
+ case ucwords(@strtolower($case)):
+ return ucwords(@strtolower($string));
default:
return null;
}
diff --git a/src/lint/linter/ArcanistTextLinter.php b/src/lint/linter/ArcanistTextLinter.php
--- a/src/lint/linter/ArcanistTextLinter.php
+++ b/src/lint/linter/ArcanistTextLinter.php
@@ -93,7 +93,7 @@
public function lintPath($path) {
$this->lintEmptyFile($path);
- if (!strlen($this->getData($path))) {
+ if (!@strlen($this->getData($path))) {
// If the file is empty, don't bother; particularly, don't require
// the user to add a newline.
return;
@@ -134,12 +134,12 @@
return;
default:
- if (strlen($filename) && $filename[0] == '.') {
+ if (@strlen($filename) && $filename[0] == '.') {
return;
}
}
- if (preg_match('/^\s*$/', $data)) {
+ if (@preg_match('/^\s*$/', $data)) {
$this->raiseLintAtPath(
self::LINT_EMPTY_FILE,
pht("Empty files usually don't serve any useful purpose."));
@@ -149,7 +149,7 @@
protected function lintNewlines($path) {
$data = $this->getData($path);
- $pos = strpos($this->getData($path), "\r");
+ $pos = @strpos($this->getData($path), "\r");
if ($pos !== false) {
$this->raiseLintAtOffset(
@@ -166,7 +166,7 @@
}
protected function lintTabs($path) {
- $pos = strpos($this->getData($path), "\t");
+ $pos = @strpos($this->getData($path), "\t");
if ($pos !== false) {
$this->raiseLintAtOffset(
$pos,
@@ -177,11 +177,11 @@
}
protected function lintLineLength($path) {
- $lines = explode("\n", $this->getData($path));
+ $lines = @explode("\n", $this->getData($path));
$width = $this->maxLineLength;
foreach ($lines as $line_idx => $line) {
- if (strlen($line) > $width) {
+ if (@strlen($line) > $width) {
$this->raiseLintAtLine(
$line_idx + 1,
1,
@@ -189,7 +189,7 @@
pht(
'This line is %s characters long, but the '.
'convention is %s characters.',
- new PhutilNumber(strlen($line)),
+ new PhutilNumber(@strlen($line)),
$width),
$line);
}
@@ -198,9 +198,9 @@
protected function lintEOFNewline($path) {
$data = $this->getData($path);
- if (!strlen($data) || $data[strlen($data) - 1] != "\n") {
+ if (!@strlen($data) || $data[@strlen($data) - 1] != "\n") {
$this->raiseLintAtOffset(
- strlen($data),
+ @strlen($data),
self::LINT_EOF_NEWLINE,
pht('Files must end in a newline.'),
'',
@@ -271,7 +271,7 @@
$data = $this->getData($path);
$matches = null;
- $preg = preg_match(
+ $preg = @preg_match(
'/^\s*\n/',
$data,
$matches,
@@ -296,7 +296,7 @@
$data = $this->getData($path);
$matches = null;
- $preg = preg_match(
+ $preg = @preg_match(
'/(?<=\n)\s+$/',
$data,
$matches,
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
@@ -12,7 +12,7 @@
*/
protected function getLinter() {
$matches = null;
- if (!preg_match('/^(\w+Linter)TestCase$/', get_class($this), $matches) ||
+ if (!@preg_match('/^(\w+Linter)TestCase$/', get_class($this), $matches) ||
!is_subclass_of($matches[1], 'ArcanistLinter')) {
throw new Exception(pht('Unable to infer linter class name.'));
}
@@ -180,13 +180,13 @@
$expect = trim($expect);
if ($expect) {
- $expect = explode("\n", $expect);
+ $expect = @explode("\n", $expect);
} else {
$expect = array();
}
foreach ($expect as $result) {
- $parts = explode(':', $result);
+ $parts = @explode(':', $result);
$message = new ArcanistLintMessage();
@@ -283,7 +283,7 @@
}
private function compareTransform($expected, $actual) {
- if (!strlen($expected)) {
+ if (!@strlen($expected)) {
return;
}
$this->assertEqual(
diff --git a/src/lint/linter/__tests__/ArcanistTestXHPASTLintSwitchHook.php b/src/lint/linter/__tests__/ArcanistTestXHPASTLintSwitchHook.php
--- a/src/lint/linter/__tests__/ArcanistTestXHPASTLintSwitchHook.php
+++ b/src/lint/linter/__tests__/ArcanistTestXHPASTLintSwitchHook.php
@@ -5,7 +5,7 @@
public function checkSwitchToken(XHPASTToken $token) {
if ($token->getTypeName() == 'T_STRING') {
- switch (strtolower($token->getValue())) {
+ switch (@strtolower($token->getValue())) {
case 'throw_exception':
return true;
}
diff --git a/src/lint/linter/xhpast/ArcanistXHPASTLintNamingHook.php b/src/lint/linter/xhpast/ArcanistXHPASTLintNamingHook.php
--- a/src/lint/linter/xhpast/ArcanistXHPASTLintNamingHook.php
+++ b/src/lint/linter/xhpast/ArcanistXHPASTLintNamingHook.php
@@ -37,10 +37,10 @@
* otherwise accept all the defaults, except allow any naming convention for
* methods with "duck" in them, you might implement the method like this:
*
- * if (preg_match('/quack/i', $name)) {
+ * if (@preg_match('/quack/i', $name)) {
* return 'Symbol names containing "quack" are forbidden.';
* }
- * if ($type == 'method' && preg_match('/duck/i', $name)) {
+ * if ($type == 'method' && @preg_match('/duck/i', $name)) {
* return null; // Always accept.
* }
* return $default;
@@ -66,7 +66,7 @@
* @task util
*/
public static function isUpperCamelCase($symbol) {
- return preg_match('/^[A-Z][A-Za-z0-9]*$/', $symbol);
+ return @preg_match('/^[A-Z][A-Za-z0-9]*$/', $symbol);
}
/**
@@ -77,7 +77,7 @@
* @task util
*/
public static function isLowerCamelCase($symbol) {
- return preg_match('/^[a-z][A-Za-z0-9]*$/', $symbol);
+ return @preg_match('/^[a-z][A-Za-z0-9]*$/', $symbol);
}
/**
@@ -88,7 +88,7 @@
* @task util
*/
public static function isUppercaseWithUnderscores($symbol) {
- return preg_match('/^[A-Z0-9_]+$/', $symbol);
+ return @preg_match('/^[A-Z0-9_]+$/', $symbol);
}
/**
@@ -99,7 +99,7 @@
* @task util
*/
public static function isLowercaseWithUnderscores($symbol) {
- return preg_match('/^[a-z0-9_]+$/', $symbol);
+ return @preg_match('/^[a-z0-9_]+$/', $symbol);
}
/**
diff --git a/src/lint/linter/xhpast/ArcanistXHPASTLinterRule.php b/src/lint/linter/xhpast/ArcanistXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/ArcanistXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/ArcanistXHPASTLinterRule.php
@@ -149,7 +149,7 @@
* statically; `null` if static evaluation was not possible.
*/
protected function evaluateStaticBoolean($string) {
- switch (strtolower($string)) {
+ switch (@strtolower($string)) {
case '0':
case 'null':
case 'false':
@@ -215,7 +215,7 @@
foreach ($calls as $call) {
$node = $call->getChildByIndex(0);
- $name = strtolower($node->getConcreteString());
+ $name = @strtolower($node->getConcreteString());
if (in_array($name, $function_names)) {
$nodes[] = $call;
@@ -248,7 +248,7 @@
$modifiers = array();
foreach ($modifier_list->selectDescendantsOfType('n_STRING') as $modifier) {
- $modifiers[strtolower($modifier->getConcreteString())] = true;
+ $modifiers[@strtolower($modifier->getConcreteString())] = true;
}
return $modifiers;
diff --git a/src/lint/linter/xhpast/rules/ArcanistAbstractPrivateMethodXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistAbstractPrivateMethodXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistAbstractPrivateMethodXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistAbstractPrivateMethodXHPASTLinterRule.php
@@ -19,7 +19,7 @@
$modifiers = array();
foreach ($method_modifiers as $modifier) {
- $modifiers[strtolower($modifier->getConcreteString())] = true;
+ $modifiers[@strtolower($modifier->getConcreteString())] = true;
}
if (idx($modifiers, 'abstract') && idx($modifiers, 'private')) {
diff --git a/src/lint/linter/xhpast/rules/ArcanistArrayIndexSpacingXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistArrayIndexSpacingXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistArrayIndexSpacingXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistArrayIndexSpacingXHPASTLinterRule.php
@@ -22,9 +22,9 @@
$trailing = $last->getNonsemanticTokensAfter();
$trailing_text = implode('', mpull($trailing, 'getValue'));
- if (preg_match('/^ +$/', $trailing_text)) {
+ if (@preg_match('/^ +$/', $trailing_text)) {
$this->raiseLintAtOffset(
- $last->getOffset() + strlen($last->getValue()),
+ $last->getOffset() + @strlen($last->getValue()),
pht('Convention: no spaces before index access.'),
$trailing_text,
'');
diff --git a/src/lint/linter/xhpast/rules/ArcanistArraySeparatorXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistArraySeparatorXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistArraySeparatorXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistArraySeparatorXHPASTLinterRule.php
@@ -42,7 +42,7 @@
$original = $value->getConcreteString();
$replacement = $value->getConcreteString().',';
- if (strpos($after, "\n") === false) {
+ if (@strpos($after, "\n") === false) {
$original .= $after;
$replacement .= $after."\n".$array->getIndentation();
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistArrayValueXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistArrayValueXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistArrayValueXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistArrayValueXHPASTLinterRule.php
@@ -35,7 +35,7 @@
foreach ($array_values as $value) {
list($before, $after) = $value->getSurroundingNonsemanticTokens();
- if (strpos(implode('', mpull($before, 'getValue')), "\n") === false) {
+ if (@strpos(implode('', mpull($before, 'getValue')), "\n") === false) {
if (last($before) && last($before)->isAnyWhitespace()) {
$token = last($before);
$replacement = "\n".$value->getIndentation();
diff --git a/src/lint/linter/xhpast/rules/ArcanistBinaryNumericScalarCasingXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistBinaryNumericScalarCasingXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistBinaryNumericScalarCasingXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistBinaryNumericScalarCasingXHPASTLinterRule.php
@@ -17,9 +17,9 @@
$binaries = $this->getBinaryNumericScalars($root);
foreach ($binaries as $binary) {
- $value = substr($binary->getConcreteString(), 2);
+ $value = @substr($binary->getConcreteString(), 2);
- if (!preg_match('/^0b[01]+$/', $binary->getConcreteString())) {
+ if (!@preg_match('/^0b[01]+$/', $binary->getConcreteString())) {
$this->raiseLintAtNode(
$binary,
pht(
@@ -37,7 +37,7 @@
foreach ($numeric_scalars as $numeric_scalar) {
$number = $numeric_scalar->getConcreteString();
- if (preg_match('/^0b[01]+$/i', $number)) {
+ if (@preg_match('/^0b[01]+$/i', $number)) {
$binary_numeric_scalars[] = $numeric_scalar;
}
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistCallParenthesesXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistCallParenthesesXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistCallParenthesesXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistCallParenthesesXHPASTLinterRule.php
@@ -52,9 +52,9 @@
$leading = $first->getNonsemanticTokensBefore();
$leading_text = implode('', mpull($leading, 'getValue'));
- if (preg_match('/^\s+$/', $leading_text)) {
+ if (@preg_match('/^\s+$/', $leading_text)) {
$this->raiseLintAtOffset(
- $first->getOffset() - strlen($leading_text),
+ $first->getOffset() - @strlen($leading_text),
pht('Convention: no spaces before opening parentheses.'),
$leading_text,
'');
@@ -79,9 +79,9 @@
$trailing = $last->getNonsemanticTokensBefore();
$trailing_text = implode('', mpull($trailing, 'getValue'));
- if (preg_match('/^\s+$/', $trailing_text)) {
+ if (@preg_match('/^\s+$/', $trailing_text)) {
$this->raiseLintAtOffset(
- $last->getOffset() - strlen($trailing_text),
+ $last->getOffset() - @strlen($trailing_text),
pht('Convention: no spaces before closing parentheses.'),
$trailing_text,
'');
diff --git a/src/lint/linter/xhpast/rules/ArcanistClassFilenameMismatchXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistClassFilenameMismatchXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistClassFilenameMismatchXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistClassFilenameMismatchXHPASTLinterRule.php
@@ -30,7 +30,7 @@
$decl_string = $decl_name->getConcreteString();
// Exclude strangely named classes, e.g. XHP tags.
- if (!preg_match('/^\w+$/', $decl_string)) {
+ if (!@preg_match('/^\w+$/', $decl_string)) {
return;
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistClassNameLiteralXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistClassNameLiteralXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistClassNameLiteralXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistClassNameLiteralXHPASTLinterRule.php
@@ -27,7 +27,7 @@
$strings = $class_declaration->selectDescendantsOfType('n_STRING_SCALAR');
foreach ($strings as $string) {
- $contents = substr($string->getSemanticString(), 1, -1);
+ $contents = @substr($string->getSemanticString(), 1, -1);
$replacement = null;
if ($contents == $class_name) {
@@ -48,7 +48,7 @@
// clunky.
$regex = '(^'.preg_quote($class_name).'$)';
- if (!preg_match($regex, $contents)) {
+ if (!@preg_match($regex, $contents)) {
continue;
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistCommentSpacingXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistCommentSpacingXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistCommentSpacingXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistCommentSpacingXHPASTLinterRule.php
@@ -20,7 +20,7 @@
if ($value[0] !== '#') {
$match = null;
- if (preg_match('@^(/[/*]+)[^/*\s]@', $value, $match)) {
+ if (@preg_match('@^(/[/*]+)[^/*\s]@', $value, $match)) {
$this->raiseLintAtOffset(
$comment->getOffset(),
pht('Put space after comment start.'),
diff --git a/src/lint/linter/xhpast/rules/ArcanistCommentStyleXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistCommentStyleXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistCommentStyleXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistCommentStyleXHPASTLinterRule.php
@@ -24,7 +24,7 @@
'//',
'#'),
'#',
- preg_match('/^#\S/', $value) ? '// ' : '//');
+ @preg_match('/^#\S/', $value) ? '// ' : '//');
}
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistConcatenationOperatorXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistConcatenationOperatorXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistConcatenationOperatorXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistConcatenationOperatorXHPASTLinterRule.php
@@ -25,7 +25,7 @@
}
$value = $wtoken->getValue();
- if (strpos($value, "\n") !== false) {
+ if (@strpos($value, "\n") !== false) {
// If the whitespace has a newline, it's conventional.
continue;
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistDeclarationParenthesesXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistDeclarationParenthesesXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistDeclarationParenthesesXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistDeclarationParenthesesXHPASTLinterRule.php
@@ -36,7 +36,7 @@
// Anonymous functions.
if ($leading_text != ' ') {
$this->raiseLintAtOffset(
- $first->getOffset() - strlen($leading_text),
+ $first->getOffset() - @strlen($leading_text),
pht(
'Convention: space before opening parenthesis in '.
'anonymous function declarations.'),
@@ -44,9 +44,9 @@
' ');
}
} else {
- if (preg_match('/^\s+$/', $leading_text)) {
+ if (@preg_match('/^\s+$/', $leading_text)) {
$this->raiseLintAtOffset(
- $first->getOffset() - strlen($leading_text),
+ $first->getOffset() - @strlen($leading_text),
pht(
'Convention: no spaces before opening parenthesis in '.
'function and method declarations.'),
@@ -55,9 +55,9 @@
}
}
- if (preg_match('/^\s+$/', $trailing_text)) {
+ if (@preg_match('/^\s+$/', $trailing_text)) {
$this->raiseLintAtOffset(
- $last->getOffset() - strlen($trailing_text),
+ $last->getOffset() - @strlen($trailing_text),
pht(
'Convention: no spaces before closing parenthesis in '.
'function and method declarations.'),
@@ -87,7 +87,7 @@
if (!$after) {
$this->raiseLintAtOffset(
- $use->getOffset() + strlen($use->getValue()),
+ $use->getOffset() + @strlen($use->getValue()),
pht(
'Convention: space after `%s` token.',
'use'),
diff --git a/src/lint/linter/xhpast/rules/ArcanistDeprecationXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistDeprecationXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistDeprecationXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistDeprecationXHPASTLinterRule.php
@@ -45,7 +45,7 @@
->getChildByIndex(0)
->getConcreteString();
- $name = strtolower($name);
+ $name = @strtolower($name);
if (empty($map[$name])) {
continue;
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistDoubleQuoteXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistDoubleQuoteXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistDoubleQuoteXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistDoubleQuoteXHPASTLinterRule.php
@@ -39,7 +39,7 @@
foreach ($strings as $string) {
$concrete_string = $string->getConcreteString();
$single_quoted = ($concrete_string[0] === "'");
- $contents = substr($concrete_string, 1, -1);
+ $contents = @substr($concrete_string, 1, -1);
// Double quoted strings are allowed when the string contains the
// following characters.
@@ -64,7 +64,7 @@
$contains_special_chars = false;
foreach ($allowed_chars as $allowed_char) {
- if (strpos($contents, $allowed_char) !== false) {
+ if (@strpos($contents, $allowed_char) !== false) {
$contains_special_chars = true;
}
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistExitExpressionXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistExitExpressionXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistExitExpressionXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistExitExpressionXHPASTLinterRule.php
@@ -30,7 +30,7 @@
foreach ($unaries as $unary) {
$operator = $unary->getChildByIndex(0)->getConcreteString();
- if (strtolower($operator) === 'exit') {
+ if (@strtolower($operator) === 'exit') {
if ($unary->getParentNode()->getTypeName() !== 'n_STATEMENT') {
$this->raiseLintAtNode(
$unary,
diff --git a/src/lint/linter/xhpast/rules/ArcanistFormattedStringXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistFormattedStringXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistFormattedStringXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistFormattedStringXHPASTLinterRule.php
@@ -64,7 +64,7 @@
foreach ($function_calls as $call) {
$name = $call->getChildByIndex(0)->getConcreteString();
- $name = strtolower($name);
+ $name = @strtolower($name);
$start = idx($functions + $this->printfFunctions, $name);
if ($start === null) {
diff --git a/src/lint/linter/xhpast/rules/ArcanistFunctionCallShouldBeTypeCastXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistFunctionCallShouldBeTypeCastXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistFunctionCallShouldBeTypeCastXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistFunctionCallShouldBeTypeCastXHPASTLinterRule.php
@@ -50,7 +50,7 @@
}
}
- if (strtolower($function_name) == 'intval') {
+ if (@strtolower($function_name) == 'intval') {
if (count($parameters->getChildren()) >= 2) {
$base = $parameters->getChildByIndex(1);
diff --git a/src/lint/linter/xhpast/rules/ArcanistHexadecimalNumericScalarCasingXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistHexadecimalNumericScalarCasingXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistHexadecimalNumericScalarCasingXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistHexadecimalNumericScalarCasingXHPASTLinterRule.php
@@ -17,9 +17,9 @@
$hexadecimals = $this->getHexadecimalNumericScalars($root);
foreach ($hexadecimals as $hexadecimal) {
- $value = substr($hexadecimal->getConcreteString(), 2);
+ $value = @substr($hexadecimal->getConcreteString(), 2);
- if (!preg_match('/^0x[0-9A-F]+$/', $hexadecimal->getConcreteString())) {
+ if (!@preg_match('/^0x[0-9A-F]+$/', $hexadecimal->getConcreteString())) {
$this->raiseLintAtNode(
$hexadecimal,
pht(
@@ -38,7 +38,7 @@
foreach ($numeric_scalars as $numeric_scalar) {
$number = $numeric_scalar->getConcreteString();
- if (preg_match('/^0x[0-9A-F]+$/i', $number)) {
+ if (@preg_match('/^0x[0-9A-F]+$/i', $number)) {
$hexadecimal_numeric_scalars[] = $numeric_scalar;
}
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistImplicitConstructorXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistImplicitConstructorXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistImplicitConstructorXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistImplicitConstructorXHPASTLinterRule.php
@@ -20,7 +20,7 @@
$method_name_token = $method->getChildByIndex(2);
$method_name = $method_name_token->getConcreteString();
- if (strtolower($class_name) === strtolower($method_name)) {
+ if (@strtolower($class_name) === @strtolower($method_name)) {
$this->raiseLintAtNode(
$method_name_token,
pht(
diff --git a/src/lint/linter/xhpast/rules/ArcanistImplicitFallthroughXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistImplicitFallthroughXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistImplicitFallthroughXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistImplicitFallthroughXHPASTLinterRule.php
@@ -140,7 +140,7 @@
if (!$token->isSemantic()) {
// Liberally match "fall" in the comment text so that comments like
// "fallthru", "fall through", "fallthrough", etc., are accepted.
- if (preg_match('/fall/i', $token->getValue())) {
+ if (@preg_match('/fall/i', $token->getValue())) {
$block_ok = true;
break;
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistInstanceOfOperatorXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistInstanceOfOperatorXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistInstanceOfOperatorXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistInstanceOfOperatorXHPASTLinterRule.php
@@ -15,7 +15,7 @@
foreach ($expressions as $expression) {
$operator = $expression->getChildOfType(1, 'n_OPERATOR');
- if (strtolower($operator->getConcreteString()) != 'instanceof') {
+ if (@strtolower($operator->getConcreteString()) != 'instanceof') {
continue;
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistInvalidDefaultParameterXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistInvalidDefaultParameterXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistInvalidDefaultParameterXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistInvalidDefaultParameterXHPASTLinterRule.php
@@ -25,9 +25,9 @@
}
$default_is_null = $default->getTypeName() == 'n_SYMBOL_NAME' &&
- strtolower($default->getConcreteString()) == 'null';
+ @strtolower($default->getConcreteString()) == 'null';
- switch (strtolower($type->getConcreteString())) {
+ switch (@strtolower($type->getConcreteString())) {
case 'array':
if ($default->getTypeName() == 'n_ARRAY_LITERAL') {
break;
diff --git a/src/lint/linter/xhpast/rules/ArcanistInvalidOctalNumericScalarXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistInvalidOctalNumericScalarXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistInvalidOctalNumericScalarXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistInvalidOctalNumericScalarXHPASTLinterRule.php
@@ -13,7 +13,7 @@
$octals = $this->getOctalNumericScalars($root);
foreach ($octals as $octal) {
- if (!preg_match('/^0[0-7]*$/', $octal->getConcreteString())) {
+ if (!@preg_match('/^0[0-7]*$/', $octal->getConcreteString())) {
$this->raiseLintAtNode(
$octal,
pht(
@@ -32,7 +32,7 @@
foreach ($numeric_scalars as $numeric_scalar) {
$number = $numeric_scalar->getConcreteString();
- if (preg_match('/^0\d+$/', $number)) {
+ if (@preg_match('/^0\d+$/', $number)) {
$octal_numeric_scalars[] = $numeric_scalar;
}
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistIsAShouldBeInstanceOfXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistIsAShouldBeInstanceOfXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistIsAShouldBeInstanceOfXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistIsAShouldBeInstanceOfXHPASTLinterRule.php
@@ -26,7 +26,7 @@
// parameter is either absent or literally `false`.
$allow_string = $parameters->getChildByIndex(2);
- if (strtolower($allow_string->getConcreteString()) != 'false') {
+ if (@strtolower($allow_string->getConcreteString()) != 'false') {
continue;
}
}
@@ -37,7 +37,7 @@
switch ($class->getTypeName()) {
case 'n_STRING_SCALAR':
$replacement = stripslashes(
- substr($class->getConcreteString(), 1, -1));
+ @substr($class->getConcreteString(), 1, -1));
break;
case 'n_VARIABLE':
diff --git a/src/lint/linter/xhpast/rules/ArcanistKeywordCasingXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistKeywordCasingXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistKeywordCasingXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistKeywordCasingXHPASTLinterRule.php
@@ -90,7 +90,7 @@
foreach ($class_static_accesses as $class_static_access) {
$class_ref = $class_static_access->getChildByIndex(0);
- switch (strtolower($class_ref->getConcreteString())) {
+ switch (@strtolower($class_ref->getConcreteString())) {
case 'parent':
case 'self':
$tokens = $class_ref->getTokens();
@@ -110,14 +110,14 @@
foreach ($keywords as $keyword) {
$value = $keyword->getValue();
- if ($value != strtolower($value)) {
+ if ($value != @strtolower($value)) {
$this->raiseLintAtToken(
$keyword,
pht(
'Convention: spell keyword `%s` as `%s`.',
$value,
- strtolower($value)),
- strtolower($value));
+ @strtolower($value)),
+ @strtolower($value));
}
}
@@ -135,15 +135,15 @@
continue;
}
- if (idx($interesting_symbols, strtolower($symbol_name))) {
- if ($symbol_name != strtolower($symbol_name)) {
+ if (idx($interesting_symbols, @strtolower($symbol_name))) {
+ if ($symbol_name != @strtolower($symbol_name)) {
$this->raiseLintAtNode(
$symbol,
pht(
'Convention: spell keyword `%s` as `%s`.',
$symbol_name,
- strtolower($symbol_name)),
- strtolower($symbol_name));
+ @strtolower($symbol_name)),
+ @strtolower($symbol_name));
}
}
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistLowercaseFunctionsXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistLowercaseFunctionsXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistLowercaseFunctionsXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistLowercaseFunctionsXHPASTLinterRule.php
@@ -32,15 +32,15 @@
$function_name = $function->getConcreteString();
- if (!idx($builtin_functions, strtolower($function_name))) {
+ if (!idx($builtin_functions, @strtolower($function_name))) {
continue;
}
- if ($function_name != strtolower($function_name)) {
+ if ($function_name != @strtolower($function_name)) {
$this->raiseLintAtNode(
$function,
pht('Calls to built-in PHP functions should be lowercase.'),
- strtolower($function_name));
+ @strtolower($function_name));
}
}
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistNewlineAfterOpenTagXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistNewlineAfterOpenTagXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistNewlineAfterOpenTagXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistNewlineAfterOpenTagXHPASTLinterRule.php
@@ -22,7 +22,7 @@
$next = $next->getNextToken()) {
if ($next->getTypeName() == 'T_WHITESPACE' &&
- preg_match('/\n\s*\n/', $next->getValue())) {
+ @preg_match('/\n\s*\n/', $next->getValue())) {
continue 2;
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistObjectOperatorSpacingXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistObjectOperatorSpacingXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistObjectOperatorSpacingXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistObjectOperatorSpacingXHPASTLinterRule.php
@@ -23,7 +23,7 @@
if ($before) {
$value = implode('', mpull($before, 'getValue'));
- if (strpos($value, "\n") !== false) {
+ if (@strpos($value, "\n") !== false) {
continue;
}
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
@@ -354,7 +354,7 @@
$heredocs = $root->selectDescendantsOfType('n_HEREDOC');
foreach ($heredocs as $heredoc) {
- if (preg_match('/^<<<[\'"]/', $heredoc->getConcreteString())) {
+ if (@preg_match('/^<<<[\'"]/', $heredoc->getConcreteString())) {
$this->raiseLintAtNode(
$heredoc,
pht(
@@ -411,7 +411,7 @@
continue;
}
- if (strtolower($class->getConcreteString()) != 'self') {
+ if (@strtolower($class->getConcreteString()) != 'self') {
continue;
}
@@ -447,7 +447,7 @@
$numeric_scalars = $root->selectDescendantsOfType('n_NUMERIC_SCALAR');
foreach ($numeric_scalars as $numeric_scalar) {
- if (preg_match('/^0b[01]+$/i', $numeric_scalar->getConcreteString())) {
+ if (@preg_match('/^0b[01]+$/i', $numeric_scalar->getConcreteString())) {
$this->raiseLintAtNode(
$numeric_scalar,
pht(
diff --git a/src/lint/linter/xhpast/rules/ArcanistPHPOpenTagXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistPHPOpenTagXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistPHPOpenTagXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistPHPOpenTagXHPASTLinterRule.php
@@ -18,7 +18,7 @@
} else if ($token->getTypeName() === 'T_OPEN_TAG_WITH_ECHO') {
break;
} else {
- if (!preg_match('/^#!/', $token->getValue())) {
+ if (!@preg_match('/^#!/', $token->getValue())) {
$this->raiseLintAtToken(
$token,
pht(
diff --git a/src/lint/linter/xhpast/rules/ArcanistPaamayimNekudotayimSpacingXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistPaamayimNekudotayimSpacingXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistPaamayimNekudotayimSpacingXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistPaamayimNekudotayimSpacingXHPASTLinterRule.php
@@ -22,7 +22,7 @@
foreach ($tokens as $token) {
if ($token->isAnyWhitespace()) {
- if (strpos($token->getValue(), "\n") !== false) {
+ if (@strpos($token->getValue(), "\n") !== false) {
continue;
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistParentMemberReferenceXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistParentMemberReferenceXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistParentMemberReferenceXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistParentMemberReferenceXHPASTLinterRule.php
@@ -45,7 +45,7 @@
}
$class_ref_name = $class_ref->getConcreteString();
- if (strtolower($parent_class) == strtolower($class_ref_name)) {
+ if (@strtolower($parent_class) == @strtolower($class_ref_name)) {
$in_closure = false;
foreach ($closures as $closure) {
diff --git a/src/lint/linter/xhpast/rules/ArcanistParenthesesSpacingXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistParenthesesSpacingXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistParenthesesSpacingXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistParenthesesSpacingXHPASTLinterRule.php
@@ -40,13 +40,13 @@
$raise = array();
$string_o = implode('', mpull($nonsem_o, 'getValue'));
- if (preg_match('/^[ ]+$/', $string_o)) {
+ if (@preg_match('/^[ ]+$/', $string_o)) {
$raise[] = array($nonsem_o, $string_o);
}
if ($nonsem_o !== $nonsem_c) {
$string_c = implode('', mpull($nonsem_c, 'getValue'));
- if (preg_match('/^[ ]+$/', $string_c)) {
+ if (@preg_match('/^[ ]+$/', $string_c)) {
$raise[] = array($nonsem_c, $string_c);
}
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistReusedAsIteratorXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistReusedAsIteratorXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistReusedAsIteratorXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistReusedAsIteratorXHPASTLinterRule.php
@@ -108,7 +108,7 @@
$calls = $body->selectDescendantsOfType('n_FUNCTION_CALL');
foreach ($calls as $call) {
- $name = strtolower($call->getChildByIndex(0)->getConcreteString());
+ $name = @strtolower($call->getChildByIndex(0)->getConcreteString());
if ($name === 'empty' || $name === 'isset') {
$params = $call
diff --git a/src/lint/linter/xhpast/rules/ArcanistSelfClassReferenceXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistSelfClassReferenceXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistSelfClassReferenceXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistSelfClassReferenceXHPASTLinterRule.php
@@ -33,7 +33,7 @@
continue;
}
- if (strtolower($type->getConcreteString()) == strtolower($class_name)) {
+ if (@strtolower($type->getConcreteString()) == @strtolower($class_name)) {
$this->raiseLintAtNode(
$type,
pht(
diff --git a/src/lint/linter/xhpast/rules/ArcanistSelfMemberReferenceXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistSelfMemberReferenceXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistSelfMemberReferenceXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistSelfMemberReferenceXHPASTLinterRule.php
@@ -32,7 +32,7 @@
}
$class_ref_name = $class_ref->getConcreteString();
- if (strtolower($class_name) == strtolower($class_ref_name)) {
+ if (@strtolower($class_name) == @strtolower($class_ref_name)) {
$in_closure = false;
foreach ($closures as $closure) {
diff --git a/src/lint/linter/xhpast/rules/ArcanistSlownessXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistSlownessXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistSlownessXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistSlownessXHPASTLinterRule.php
@@ -46,7 +46,7 @@
continue;
}
- $name = strtolower($strstr->getChildByIndex(0)->getConcreteString());
+ $name = @strtolower($strstr->getChildByIndex(0)->getConcreteString());
if ($name === 'strstr' || $name === 'strchr') {
$this->raiseLintAtNode(
$strstr,
@@ -91,7 +91,7 @@
continue;
}
- $name = strtolower($strpos->getChildByIndex(0)->getConcreteString());
+ $name = @strtolower($strpos->getChildByIndex(0)->getConcreteString());
if ($name === 'strpos') {
$this->raiseLintAtNode(
$strpos,
diff --git a/src/lint/linter/xhpast/rules/ArcanistStaticThisXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistStaticThisXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistStaticThisXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistStaticThisXHPASTLinterRule.php
@@ -24,10 +24,10 @@
$method_is_abstract = false;
foreach ($attributes as $attribute) {
- if (strtolower($attribute->getConcreteString()) === 'static') {
+ if (@strtolower($attribute->getConcreteString()) === 'static') {
$method_is_static = true;
}
- if (strtolower($attribute->getConcreteString()) === 'abstract') {
+ if (@strtolower($attribute->getConcreteString()) === 'abstract') {
$method_is_abstract = true;
}
}
@@ -45,7 +45,7 @@
foreach ($variables as $variable) {
if ($method_is_static &&
- strtolower($variable->getConcreteString()) === '$this') {
+ @strtolower($variable->getConcreteString()) === '$this') {
$this->raiseLintAtNode(
$variable,
pht(
diff --git a/src/lint/linter/xhpast/rules/ArcanistUnaryPostfixExpressionSpacingXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistUnaryPostfixExpressionSpacingXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistUnaryPostfixExpressionSpacingXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistUnaryPostfixExpressionSpacingXHPASTLinterRule.php
@@ -25,7 +25,7 @@
$leading_text = implode('', mpull($before, 'getValue'));
$this->raiseLintAtOffset(
- $operator->getOffset() - strlen($leading_text),
+ $operator->getOffset() - @strlen($leading_text),
pht('Unary postfix operators should not be prefixed by whitespace.'),
$leading_text,
'');
diff --git a/src/lint/linter/xhpast/rules/ArcanistUnaryPrefixExpressionSpacingXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistUnaryPrefixExpressionSpacingXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistUnaryPrefixExpressionSpacingXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistUnaryPrefixExpressionSpacingXHPASTLinterRule.php
@@ -21,7 +21,7 @@
$operator_value = $operator->getConcreteString();
list($before, $after) = $operator->getSurroundingNonsemanticTokens();
- switch (strtolower($operator_value)) {
+ switch (@strtolower($operator_value)) {
case 'clone':
case 'echo':
case 'print':
@@ -30,7 +30,7 @@
default:
if (!empty($after)) {
$this->raiseLintAtOffset(
- $operator->getOffset() + strlen($operator->getConcreteString()),
+ $operator->getOffset() + @strlen($operator->getConcreteString()),
pht(
'Unary prefix operators should not be followed by whitespace.'),
implode('', mpull($after, 'getValue')),
diff --git a/src/lint/linter/xhpast/rules/ArcanistUndeclaredVariableXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistUndeclaredVariableXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistUndeclaredVariableXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistUndeclaredVariableXHPASTLinterRule.php
@@ -150,7 +150,7 @@
$calls = $body->selectDescendantsOfType('n_FUNCTION_CALL');
foreach ($calls as $call) {
- $name = strtolower($call->getChildByIndex(0)->getConcreteString());
+ $name = @strtolower($call->getChildByIndex(0)->getConcreteString());
if ($name === 'empty' || $name === 'isset') {
$params = $call
diff --git a/src/lint/linter/xhpast/rules/ArcanistUnexpectedReturnValueXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistUnexpectedReturnValueXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistUnexpectedReturnValueXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistUnexpectedReturnValueXHPASTLinterRule.php
@@ -21,7 +21,7 @@
->getChildOfType(2, 'n_STRING')
->getConcreteString();
- switch (strtolower($method_name)) {
+ switch (@strtolower($method_name)) {
case '__construct':
case '__destruct':
$returns = $method->selectDescendantsOfType('n_RETURN');
diff --git a/src/lint/linter/xhpast/rules/ArcanistUnnecessarySymbolAliasXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistUnnecessarySymbolAliasXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistUnnecessarySymbolAliasXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistUnnecessarySymbolAliasXHPASTLinterRule.php
@@ -24,7 +24,7 @@
continue;
}
- $symbol_name = last(explode('\\', $symbol->getConcreteString()));
+ $symbol_name = last(@explode('\\', $symbol->getConcreteString()));
$alias_name = $alias->getConcreteString();
if ($symbol_name == $alias_name) {
diff --git a/src/lint/linter/xhpast/rules/ArcanistUnsafeDynamicStringXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistUnsafeDynamicStringXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistUnsafeDynamicStringXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistUnsafeDynamicStringXHPASTLinterRule.php
@@ -78,7 +78,7 @@
foreach ($calls as $call) {
$name = $call->getChildByIndex(0)->getConcreteString();
- $param = idx($safe, strtolower($name));
+ $param = idx($safe, @strtolower($name));
if ($param === null) {
continue;
diff --git a/src/lint/linter/xhpast/rules/ArcanistUseStatementNamespacePrefixXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistUseStatementNamespacePrefixXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistUseStatementNamespacePrefixXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistUseStatementNamespacePrefixXHPASTLinterRule.php
@@ -29,7 +29,7 @@
pht(
'Imported symbols should not be prefixed with `%s`.',
'\\'),
- substr($symbol_name, 1));
+ @substr($symbol_name, 1));
}
}
}
diff --git a/src/lint/linter/xhpast/rules/__tests__/ArcanistXHPASTLinterRuleTestCase.php b/src/lint/linter/xhpast/rules/__tests__/ArcanistXHPASTLinterRuleTestCase.php
--- a/src/lint/linter/xhpast/rules/__tests__/ArcanistXHPASTLinterRuleTestCase.php
+++ b/src/lint/linter/xhpast/rules/__tests__/ArcanistXHPASTLinterRuleTestCase.php
@@ -34,7 +34,7 @@
$class = get_class($this);
$matches = null;
- if (!preg_match('/^(\w+XHPASTLinterRule)TestCase$/', $class, $matches) ||
+ if (!@preg_match('/^(\w+XHPASTLinterRule)TestCase$/', $class, $matches) ||
!is_subclass_of($matches[1], 'ArcanistXHPASTLinterRule')) {
throw new Exception(pht('Unable to infer linter rule class name.'));
}
diff --git a/src/lint/linter/xhpast/rules/__tests__/slowness/slowness.lint-test b/src/lint/linter/xhpast/rules/__tests__/slowness/slowness.lint-test
--- a/src/lint/linter/xhpast/rules/__tests__/slowness/slowness.lint-test
+++ b/src/lint/linter/xhpast/rules/__tests__/slowness/slowness.lint-test
@@ -1,9 +1,9 @@
<?php
-(strpos('a', 'b') === 0);
-(strpos('a', 'b') !== 0);
-(0 === strpos('a', 'b'));
-(1 + 0 === strpos('a', 'b'));
+(@strpos('a', 'b') === 0);
+(@strpos('a', 'b') !== 0);
+(0 === @strpos('a', 'b'));
+(1 + 0 === @strpos('a', 'b'));
(strstr('a', 'b') === false);
(strstr('a', 'b') === 'b');
diff --git a/src/lint/renderer/ArcanistConsoleLintRenderer.php b/src/lint/renderer/ArcanistConsoleLintRenderer.php
--- a/src/lint/renderer/ArcanistConsoleLintRenderer.php
+++ b/src/lint/renderer/ArcanistConsoleLintRenderer.php
@@ -136,7 +136,7 @@
if ($start > ($max_old + 1)) {
$invalid_position = true;
} else if ($start > $max_old) {
- if (strlen($original)) {
+ if (@strlen($original)) {
$invalid_position = true;
} else if ($char !== null && $char !== 1) {
$invalid_position = true;
@@ -164,7 +164,7 @@
$old,
$replacement,
$patch_offset,
- strlen($original));
+ @strlen($original));
$new_lines = phutil_split_lines($new);
// Figure out how many "-" and "+" lines we have by counting the newlines
@@ -179,7 +179,7 @@
$old_lines[$start - 1],
$this->highlightText($original),
$char - 1,
- strlen($original));
+ @strlen($original));
// See T13543. The message may have completely removed this line: for
// example, if it trimmed trailing spaces from the end of a file. If
@@ -189,7 +189,7 @@
$new_lines[$start - 1],
$this->highlightText($replacement),
$char - 1,
- strlen($replacement));
+ @strlen($replacement));
}
}
@@ -242,12 +242,12 @@
// If we have "original" text and it is contained on a single line,
// highlight the affected area. If we don't have any text, we'll mark
// the character with a caret (below, in rendering) instead.
- if ($old_impact == 1 && strlen($original)) {
+ if ($old_impact == 1 && @strlen($original)) {
$old_lines[$start - 1] = substr_replace(
$old_lines[$start - 1],
$this->highlightText($original),
$char - 1,
- strlen($original));
+ @strlen($original));
}
$old_impact = 0;
@@ -311,7 +311,7 @@
// doesn't mess up. This can happen when the last line of the old file
// didn't have a newline at the end.
$text = $spec['text'];
- if (!preg_match('/\n\z/', $spec['text'])) {
+ if (!@preg_match('/\n\z/', $spec['text'])) {
$text .= "\n";
}
@@ -324,7 +324,7 @@
// If this is just a message and does not have a patch, put a little
// caret underneath the line to point out where the issue is.
if ($chevron) {
- if (!$message->isPatchable() && !strlen($original)) {
+ if (!$message->isPatchable() && !@strlen($original)) {
$result[] = $this->renderCaret($char)."\n";
}
}
@@ -357,14 +357,14 @@
foreach ($lines as $line) {
$line_map[$number] = $offset;
$number++;
- $offset += strlen($line);
+ $offset += @strlen($line);
}
// If the last line ends in a newline, add a virtual offset for the final
// line with no characters on it. This allows lint messages to target the
// last line of the file at character 1.
if ($lines) {
- if (preg_match('/\n\z/', $line)) {
+ if (@preg_match('/\n\z/', $line)) {
$line_map[$number] = $offset;
}
}
diff --git a/src/lint/renderer/ArcanistJSONLintRenderer.php b/src/lint/renderer/ArcanistJSONLintRenderer.php
--- a/src/lint/renderer/ArcanistJSONLintRenderer.php
+++ b/src/lint/renderer/ArcanistJSONLintRenderer.php
@@ -9,7 +9,7 @@
public function renderLintResult(ArcanistLintResult $result) {
$messages = $result->getMessages();
$path = $result->getPath();
- $data = explode("\n", $result->getData());
+ $data = @explode("\n", $result->getData());
array_unshift($data, ''); // make the line numbers work as array indices
$output = array($path => array());
diff --git a/src/moduleutils/PhutilLibraryMapBuilder.php b/src/moduleutils/PhutilLibraryMapBuilder.php
--- a/src/moduleutils/PhutilLibraryMapBuilder.php
+++ b/src/moduleutils/PhutilLibraryMapBuilder.php
@@ -326,7 +326,7 @@
->find();
$extensions_dir = 'extensions/';
- $extensions_len = strlen($extensions_dir);
+ $extensions_len = @strlen($extensions_dir);
$map = array();
foreach ($files as $file => $hash) {
diff --git a/src/object/Phobject.php b/src/object/Phobject.php
--- a/src/object/Phobject.php
+++ b/src/object/Phobject.php
@@ -1,4 +1,4 @@
-<?php
+x<?php
/**
* Base class for libphutil objects. Enforces stricter object semantics than
@@ -33,22 +33,27 @@
get_class($this).'::'.$name));
}
+ #[\ReturnTypeWillChange]
public function current() {
$this->throwOnAttemptedIteration();
}
+ #[\ReturnTypeWillChange]
public function key() {
$this->throwOnAttemptedIteration();
}
+ #[\ReturnTypeWillChange]
public function next() {
$this->throwOnAttemptedIteration();
}
+ #[\ReturnTypeWillChange]
public function rewind() {
$this->throwOnAttemptedIteration();
}
+ #[\ReturnTypeWillChange]
public function valid() {
$this->throwOnAttemptedIteration();
}
@@ -86,7 +91,7 @@
}
if ($byte_limit !== null) {
- if (!is_string($const) || (strlen($const) > $byte_limit)) {
+ if (!is_string($const) || (@strlen($const) > $byte_limit)) {
throw new Exception(
pht(
'"%s" class "%s" has an invalid "%s" property. Field constants '.
diff --git a/src/parser/ArcanistBaseCommitParser.php b/src/parser/ArcanistBaseCommitParser.php
--- a/src/parser/ArcanistBaseCommitParser.php
+++ b/src/parser/ArcanistBaseCommitParser.php
@@ -19,7 +19,7 @@
$spec = array_filter($spec);
foreach ($spec as $rule) {
- if (strpos($rule, ':') === false) {
+ if (@strpos($rule, ':') === false) {
throw new ArcanistUsageException(
pht(
"Rule '%s' is invalid, it must have a type and name like '%s'.",
@@ -98,7 +98,7 @@
// NOTE: Returning `null` from this method means "no match".
// Returning `false` from this method means "stop current ruleset".
- list($type, $name) = explode(':', $rule, 2);
+ list($type, $name) = @explode(':', $rule, 2);
switch ($type) {
case 'literal':
return $name;
@@ -133,7 +133,7 @@
$reason = pht('it is what you typed when prompted.');
$this->api->setBaseCommitExplanation($reason);
$result = phutil_console_prompt(pht('Against which commit?'));
- if (!strlen($result)) {
+ if (!@strlen($result)) {
// Allow the user to continue to the next rule by entering no
// text.
return null;
@@ -169,7 +169,7 @@
return $this->api->resolveBaseCommitRule($rule, $source);
default:
$matches = null;
- if (preg_match('/^exec\((.*)\)$/', $name, $matches)) {
+ if (@preg_match('/^exec\((.*)\)$/', $name, $matches)) {
$root = $this->api->getWorkingCopyIdentity()->getProjectRoot();
$future = new ExecFuture('%C', $matches[1]);
$future->setCWD($root);
@@ -179,7 +179,7 @@
} else {
return null;
}
- } else if (preg_match('/^nodiff\((.*)\)$/', $name, $matches)) {
+ } else if (@preg_match('/^nodiff\((.*)\)$/', $name, $matches)) {
return $this->api->resolveBaseCommitRule($rule, $source);
}
diff --git a/src/parser/ArcanistBundle.php b/src/parser/ArcanistBundle.php
--- a/src/parser/ArcanistBundle.php
+++ b/src/parser/ArcanistBundle.php
@@ -136,7 +136,7 @@
'tar tfO %s',
$path);
list($stdout, $file_list) = $future->resolvex();
- $file_list = explode("\n", trim($file_list));
+ $file_list = @explode("\n", trim($file_list));
if (in_array('meta.json', $file_list)) {
$future = new ExecFuture(
@@ -414,7 +414,7 @@
// TODO: This is only relevant when patching old Differential diffs
// which were created prior to arc pruning TYPE_COPY_AWAY for files
// with no modifications.
- if (!strlen($change_body) && ($old_mode == $new_mode)) {
+ if (!@strlen($change_body) && ($old_mode == $new_mode)) {
continue;
}
}
@@ -627,7 +627,7 @@
//
// Everyone is at fault here and there are no winners.
- if (strpos($path, ' ') !== false) {
+ if (@strpos($path, ' ') !== false) {
$path = $path."\t";
}
@@ -639,7 +639,7 @@
$old_path = $change->getOldPath();
$type = $change->getType();
- if (!strlen($old_path) ||
+ if (!@strlen($old_path) ||
$type == ArcanistDiffChangeType::TYPE_ADD) {
$old_path = null;
}
@@ -651,7 +651,7 @@
$cur_path = $change->getCurrentPath();
$type = $change->getType();
- if (!strlen($cur_path) ||
+ if (!@strlen($cur_path) ||
$type == ArcanistDiffChangeType::TYPE_DELETE ||
$type == ArcanistDiffChangeType::TYPE_MULTICOPY) {
$cur_path = null;
@@ -672,7 +672,7 @@
$n_len = $small_hunk->getNewLength();
$corpus = $small_hunk->getCorpus();
- $this->reserveBytes(strlen($corpus));
+ $this->reserveBytes(@strlen($corpus));
// NOTE: If the length is 1 it can be omitted. Since git does this,
// we also do it so that "arc export --git" diffs are as similar to
@@ -693,7 +693,7 @@
$result[] = "@@ -{$o_head} +{$n_head} @@".$eol;
$result[] = $corpus;
- $last = substr($corpus, -1);
+ $last = @substr($corpus, -1);
if ($last !== false && $last != "\r" && $last != "\n") {
$result[] = $eol;
}
@@ -763,7 +763,7 @@
$old_data = $this->getBlob($old_phid, $name);
}
- $old_length = strlen($old_data);
+ $old_length = @strlen($old_data);
// Here, and below, the binary will be emitted with base85 encoding. This
// encoding encodes each 4 bytes of input in 5 bytes of output, so we may
@@ -796,7 +796,7 @@
$new_data = $this->getBlob($new_phid, $name);
}
- $new_length = strlen($new_data);
+ $new_length = @strlen($new_data);
$this->reserveBytes($new_length * 5 / 4);
if ($new_data === null) {
@@ -995,7 +995,7 @@
foreach ($lines as $idx => $line) {
if ($idx === $final) {
- $len = strlen($line);
+ $len = @strlen($line);
} else {
$len = 52;
}
diff --git a/src/parser/ArcanistCommentRemover.php b/src/parser/ArcanistCommentRemover.php
--- a/src/parser/ArcanistCommentRemover.php
+++ b/src/parser/ArcanistCommentRemover.php
@@ -14,7 +14,7 @@
$lines = array_reverse($lines);
foreach ($lines as $key => $line) {
- if (preg_match('/^#/', $line)) {
+ if (@preg_match('/^#/', $line)) {
unset($lines[$key]);
continue;
}
diff --git a/src/parser/ArcanistDiffParser.php b/src/parser/ArcanistDiffParser.php
--- a/src/parser/ArcanistDiffParser.php
+++ b/src/parser/ArcanistDiffParser.php
@@ -95,9 +95,9 @@
$root = $rinfo['URL'].'/';
}
$cpath = $info['Copied From URL'];
- $root_len = strlen($root);
+ $root_len = @strlen($root);
if (!strncmp($cpath, $root, $root_len)) {
- $cpath = substr($cpath, $root_len);
+ $cpath = @substr($cpath, $root_len);
// The user can "svn cp /path/to/file@12345 x", which pulls a file out
// of version history at a specific revision. If we just use the path,
// we'll collide with possible changes to that path in the working
@@ -187,7 +187,7 @@
}
public function parseDiff($diff) {
- if (!strlen(trim($diff))) {
+ if (!@strlen(trim($diff))) {
throw new Exception(pht("Can't parse an empty diff!"));
}
@@ -203,7 +203,7 @@
// lost in transit.
$detect_patch = '/^---$.*^-- ?[\s\d.]+\z/ms';
$message = null;
- if (preg_match($detect_patch, $diff)) {
+ if (@preg_match($detect_patch, $diff)) {
list($message, $diff) = $this->stripGitFormatPatch($diff);
}
@@ -213,11 +213,11 @@
// file, `git apply` is more strict. We get these comments in `hg export`
// diffs, and Eclipse can also produce them.
$line = $this->getLineTrimmed();
- while (preg_match('/^#/', $line)) {
+ while (@preg_match('/^#/', $line)) {
$line = $this->nextLine();
}
- if (strlen($message)) {
+ if (@strlen($message)) {
// If we found a message during pre-parse steps, add it to the resulting
// changes here.
$change = $this->buildChange(null)
@@ -334,7 +334,7 @@
$this->parseCommitMessage($change);
break;
case '---':
- $ok = preg_match(
+ $ok = @preg_match(
'@^(?:\+\+\+) (.*)\s+\d{4}-\d{2}-\d{2}.*$@',
$line,
$match);
@@ -370,7 +370,7 @@
protected function tryMatchHeader($patterns, $line, &$match) {
foreach ($patterns as $pattern) {
- if (preg_match('@^'.$pattern.'$@', $line, $match)) {
+ if (@preg_match('@^'.$pattern.'$@', $line, $match)) {
return true;
}
}
@@ -383,22 +383,22 @@
$message = array();
$line = $this->getLine();
- if (preg_match('/^Merge: /', $line)) {
+ if (@preg_match('/^Merge: /', $line)) {
$this->nextLine();
}
$line = $this->getLine();
- if (!preg_match('/^Author: /', $line)) {
+ if (!@preg_match('/^Author: /', $line)) {
$this->didFailParse(pht("Expected 'Author:'."));
}
$line = $this->nextLine();
- if (!preg_match('/^Date: /', $line)) {
+ if (!@preg_match('/^Date: /', $line)) {
$this->didFailParse(pht("Expected 'Date:'."));
}
while (($line = $this->nextLineTrimmed()) !== null) {
- if (strlen($line) && $line[0] != ' ') {
+ if (@strlen($line) && $line[0] != ' ') {
break;
}
@@ -418,13 +418,13 @@
*/
protected function parsePropertyHunk(ArcanistDiffChange $change) {
$line = $this->getLineTrimmed();
- if (!preg_match('/^_+$/', $line)) {
+ if (!@preg_match('/^_+$/', $line)) {
$this->didFailParse(pht("Expected '%s'.", '______________________'));
}
$line = $this->nextLine();
while ($line !== null) {
- $done = preg_match('/^(Index|Property changes on):/', $line);
+ $done = @preg_match('/^(Index|Property changes on):/', $line);
if ($done) {
break;
}
@@ -433,7 +433,7 @@
// "Modified", "Added" and "Deleted".
$matches = null;
- $ok = preg_match(
+ $ok = @preg_match(
'/^(Name|Modified|Added|Deleted): (.*)$/',
$line,
$matches);
@@ -468,7 +468,7 @@
$line = $this->nextLine();
$prop_index = 2;
while ($line !== null) {
- $done = preg_match(
+ $done = @preg_match(
'/^(Modified|Added|Deleted|Index|Property changes on):/',
$line);
if ($done) {
@@ -490,7 +490,7 @@
'+'));
}
$target = 'new';
- $line = substr($trimline, $prop_index);
+ $line = @substr($trimline, $prop_index);
} else if ($trimline && $trimline[0] == '-') {
if ($op == 'Added') {
$this->didFailParse(pht(
@@ -498,7 +498,7 @@
'-'));
}
$target = 'old';
- $line = substr($trimline, $prop_index);
+ $line = @substr($trimline, $prop_index);
} else if (!strncmp($trimline, 'Merged', 6)) {
if ($op == 'Added') {
$target = 'new';
@@ -523,11 +523,11 @@
$old = rtrim(implode('', $old));
$new = rtrim(implode('', $new));
- if (!strlen($old)) {
+ if (!@strlen($old)) {
$old = null;
}
- if (!strlen($new)) {
+ if (!@strlen($new)) {
$new = null;
}
@@ -583,7 +583,7 @@
$ok = false;
$match = null;
foreach ($patterns as $pattern) {
- $ok = preg_match('@^'.$pattern.'@', $line, $match);
+ $ok = @preg_match('@^'.$pattern.'@', $line, $match);
if ($ok) {
break;
}
@@ -591,7 +591,7 @@
if (!$ok) {
if ($line === null ||
- preg_match('/^(diff --git|commit) /', $line)) {
+ @preg_match('/^(diff --git|commit) /', $line)) {
// In this case, there are ONLY file mode changes, or this is a
// pure move. If it's a move, flag these changesets so we can build
// synthetic changes later, enabling us to show file contents in
@@ -693,7 +693,7 @@
$line = $this->getLine();
if ($is_svn) {
- $ok = preg_match('/^=+\s*$/', $line);
+ $ok = @preg_match('/^=+\s*$/', $line);
if (!$ok) {
$this->didFailParse(pht(
"Expected '%s' divider line.",
@@ -703,7 +703,7 @@
$line = $this->nextNonemptyLine();
}
} else if ($is_git) {
- $ok = preg_match('/^index .*$/', $line);
+ $ok = @preg_match('/^index .*$/', $line);
if (!$ok) {
// TODO: "hg diff -g" diffs ("mercurial git-style diffs") do not include
// this line, so we can't parse them if we fail on it. Maybe introduce
@@ -723,13 +723,13 @@
// supplied as command-line flags to `diff', svn and git both produce
// changes without any body.
if ($line === null ||
- preg_match(
+ @preg_match(
'/^(Index:|Property changes on:|diff --git|commit) /',
$line)) {
return;
}
- $is_binary_add = preg_match(
+ $is_binary_add = @preg_match(
'/^Cannot display: file marked as a binary type\.$/',
rtrim($line));
if ($is_binary_add) {
@@ -741,7 +741,7 @@
// We can get this in git, or in SVN when a file exists in the repository
// WITHOUT a binary mime-type and is changed and given a binary mime-type.
- $is_binary_diff = preg_match(
+ $is_binary_diff = @preg_match(
'/^(Binary files|Files) .* and .* differ$/',
rtrim($line));
if ($is_binary_diff) {
@@ -754,7 +754,7 @@
// test case "hg-binary-delete.hgdiff". (I believe it never occurs under
// git, which reports the "files X and /dev/null differ" string above. Git
// can not apply these patches.)
- $is_hg_binary_delete = preg_match(
+ $is_hg_binary_delete = @preg_match(
'/^Binary file .* has changed$/',
rtrim($line));
if ($is_hg_binary_delete) {
@@ -767,14 +767,14 @@
// invoke and then, e.g., copy-paste into the web console) or "hg diff
// --git" (normal under hg workflows), we may encounter a literal binary
// patch.
- $is_git_binary_patch = preg_match(
+ $is_git_binary_patch = @preg_match(
'/^GIT binary patch$/',
rtrim($line));
if ($is_git_binary_patch) {
$this->nextLine();
$this->parseGitBinaryPatch();
$line = $this->getLine();
- if (preg_match('/^literal/', $line)) {
+ if (@preg_match('/^literal/', $line)) {
// We may have old/new binaries (change) or just a new binary (hg add).
// If there are two blocks, parse both.
$this->parseGitBinaryPatch();
@@ -785,7 +785,7 @@
if ($is_git) {
// "git diff -b" ignores whitespace, but has an empty hunk target
- if (preg_match('@^diff --git .*$@', $line)) {
+ if (@preg_match('@^diff --git .*$@', $line)) {
$this->nextLine();
return null;
}
@@ -817,7 +817,7 @@
// case ("arc diff").
$line = $this->getLine();
- if (!preg_match('/^literal /', $line)) {
+ if (!@preg_match('/^literal /', $line)) {
$this->didFailParse(
pht("Expected '%s' to start git binary patch.", 'literal NNNN'));
}
@@ -829,7 +829,7 @@
// rely on the base85 check for sanity.
$this->nextNonemptyLine();
return;
- } else if (!preg_match('/^[a-zA-Z]/', $line)) {
+ } else if (!@preg_match('/^[a-zA-Z]/', $line)) {
$this->didFailParse(
pht('Expected base85 line length character (a-zA-Z).'));
}
@@ -853,7 +853,7 @@
$remainder = '(?:\t.*)?';
}
- $ok = preg_match(
+ $ok = @preg_match(
'@^[-+]{3} (?:[ab]/)?(?P<path>.*?)'.$remainder.'$@',
$line,
$matches);
@@ -893,7 +893,7 @@
// The final group is for git, which appends a guess at the function
// context to the diff.
$matches = null;
- $ok = preg_match(
+ $ok = @preg_match(
'/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(?: .*?)?$/U',
$line,
$matches);
@@ -904,7 +904,7 @@
// by a "Property changes on:" section similar to svn1.6.
if ($line == '') {
$line = $this->nextNonemptyLine();
- $ok = preg_match('/^Property changes on:/', $line);
+ $ok = @preg_match('/^Property changes on:/', $line);
if (!$ok) {
$this->didFailParse(pht('Confused by empty line'));
}
@@ -921,11 +921,11 @@
// Cover for the cases where length wasn't present (implying one line).
$old_len = idx($matches, 2);
- if (!strlen($old_len)) {
+ if (!@strlen($old_len)) {
$old_len = 1;
}
$new_len = idx($matches, 4);
- if (!strlen($new_len)) {
+ if (!@strlen($new_len)) {
$new_len = 1;
}
@@ -937,7 +937,7 @@
$hit_next_hunk = false;
while ((($line = $this->nextLine()) !== null)) {
- if (strlen(rtrim($line, "\r\n"))) {
+ if (@strlen(rtrim($line, "\r\n"))) {
$char = $line[0];
} else {
// Normally, we do not encouter empty lines in diffs, because
@@ -949,7 +949,7 @@
}
switch ($char) {
case '\\':
- if (!preg_match('@\\ No newline at end of file@', $line)) {
+ if (!@preg_match('@\\ No newline at end of file@', $line)) {
$this->didFailParse(
pht("Expected '\ No newline at end of file'."));
}
@@ -1041,7 +1041,7 @@
$line = $this->nextNonemptyLine();
}
- } while (preg_match('/^@@ /', $line));
+ } while (@preg_match('/^@@ /', $line));
}
protected function buildChange($path = null) {
@@ -1096,7 +1096,7 @@
// and you've dug your own grave.
$ansi_color_pattern = '\x1B\[[\d;]*m';
- if (preg_match('/^'.$ansi_color_pattern.'/m', $text)) {
+ if (@preg_match('/^'.$ansi_color_pattern.'/m', $text)) {
$text = preg_replace('/'.$ansi_color_pattern.'/', '', $text);
}
@@ -1137,7 +1137,7 @@
protected function nextNonemptyLine() {
while (($line = $this->nextLine()) !== null) {
- if (strlen(trim($line)) !== 0) {
+ if (@strlen(trim($line)) !== 0) {
break;
}
}
@@ -1146,7 +1146,7 @@
protected function nextLineThatLooksLikeDiffStart() {
while (($line = $this->nextLine()) !== null) {
- if (preg_match('/^\s*diff\s+-(?:r|-git)/', $line)) {
+ if (@preg_match('/^\s*diff\s+-(?:r|-git)/', $line)) {
break;
}
}
@@ -1166,12 +1166,12 @@
for ($ii = 0; $ii < $len; $ii++) {
$line = $this->text[$ii];
- if (!strlen(trim($line))) {
+ if (!@strlen(trim($line))) {
// This line is empty, skip it.
continue;
}
- if (preg_match('/^#/', $line)) {
+ if (@preg_match('/^#/', $line)) {
// This line is a comment, skip it.
continue;
}
@@ -1227,8 +1227,8 @@
* Unescape escaped filenames, e.g. from "git diff".
*/
private static function unescapeFilename($name) {
- if (preg_match('/^".+"$/', $name)) {
- return stripcslashes(substr($name, 1, -1));
+ if (@preg_match('/^".+"$/', $name)) {
+ return stripcslashes(@substr($name, 1, -1));
} else {
return $name;
}
@@ -1337,7 +1337,7 @@
." "
."(?P<new>(?P<newq>\"?){$prefix}\\k<common>\\k<newq>)$@";
- if (!preg_match($pattern, $paths, $matches)) {
+ if (!@preg_match($pattern, $paths, $matches)) {
// A rename or some form; return null for now, and let the
// "rename from" / "rename to" lines fix it up.
return null;
@@ -1379,15 +1379,15 @@
// 9. Patch footer.
list($head, $tail) = preg_split('/^---$/m', $diff, 2);
- list($mail_headers, $mail_body) = explode("\n\n", $head, 2);
+ list($mail_headers, $mail_body) = @explode("\n\n", $head, 2);
list($body, $foot) = preg_split('/^-- ?$/m', $tail, 2);
- list($stat, $diff) = explode("\n\n", $body, 2);
+ list($stat, $diff) = @explode("\n\n", $body, 2);
// Rebuild the commit message by putting the subject line back on top of it,
// if we can find one.
$matches = null;
$pattern = '/^Subject: (?:\[PATCH\] )?(.*)$/mi';
- if (preg_match($pattern, $mail_headers, $matches)) {
+ if (@preg_match($pattern, $mail_headers, $matches)) {
$mail_body = $matches[1]."\n\n".$mail_body;
$mail_body = rtrim($mail_body);
}
diff --git a/src/parser/PhutilBugtraqParser.php b/src/parser/PhutilBugtraqParser.php
--- a/src/parser/PhutilBugtraqParser.php
+++ b/src/parser/PhutilBugtraqParser.php
@@ -85,7 +85,7 @@
$captured_text = $capture['text'];
$captured_offset = $capture['at'];
- if (strlen($select_regexp)) {
+ if (@strlen($select_regexp)) {
$selections = null;
preg_match_all(
$select_regexp,
@@ -120,7 +120,7 @@
$corpus,
$new_text,
$bug['at'],
- strlen($bug['text']));
+ @strlen($bug['text']));
}
return $corpus;
diff --git a/src/parser/PhutilDocblockParser.php b/src/parser/PhutilDocblockParser.php
--- a/src/parser/PhutilDocblockParser.php
+++ b/src/parser/PhutilDocblockParser.php
@@ -22,10 +22,10 @@
// Build a map of character offset -> line number.
$map = array();
- $lines = explode("\n", $text);
+ $lines = @explode("\n", $text);
$num = 1;
foreach ($lines as $line) {
- $len = strlen($line) + 1;
+ $len = @strlen($line) + 1;
for ($jj = 0; $jj < $len; $jj++) {
$map[] = $num;
}
@@ -48,7 +48,7 @@
$docblock = preg_replace('@^\s*\*@m', '', $docblock);
// Normalize multi-line @specials.
- $lines = explode("\n", $docblock);
+ $lines = @explode("\n", $docblock);
$last = false;
foreach ($lines as $k => $line) {
@@ -66,10 +66,10 @@
// we allow that and one additional space before assuming something is
// a code block.
- if (preg_match('/^\s{0,2}@\w/i', $line)) {
+ if (@preg_match('/^\s{0,2}@\w/i', $line)) {
$last = $k;
$lines[$last] = trim($line);
- } else if (preg_match('/^\s*$/', $line)) {
+ } else if (@preg_match('/^\s*$/', $line)) {
$last = false;
} else if ($last !== false) {
$lines[$last] = $lines[$last].' '.trim($line);
@@ -100,7 +100,7 @@
// For flags like "@stable" which don't have any string data, set the
// value to true.
- if (!strlen($data)) {
+ if (!@strlen($data)) {
$data = true;
}
@@ -138,8 +138,8 @@
// Smush the whole docblock to the left edge.
$min_indent = 80;
$indent = 0;
- foreach (array_filter(explode("\n", $docblock)) as $line) {
- for ($ii = 0; $ii < strlen($line); $ii++) {
+ foreach (array_filter(@explode("\n", $docblock)) as $line) {
+ for ($ii = 0; $ii < @strlen($line); $ii++) {
if ($line[$ii] != ' ') {
break;
}
diff --git a/src/parser/PhutilEditorConfig.php b/src/parser/PhutilEditorConfig.php
--- a/src/parser/PhutilEditorConfig.php
+++ b/src/parser/PhutilEditorConfig.php
@@ -122,10 +122,10 @@
continue;
}
- if (strpos($glob, '/') === false) {
+ if (@strpos($glob, '/') === false) {
$glob = '**/'.$glob;
} else if (strncmp($glob, '/', 0)) {
- $glob = substr($glob, 1);
+ $glob = @substr($glob, 1);
}
$glob = $path_prefix.'/'.$glob;
@@ -139,7 +139,7 @@
}
foreach ($properties as $property => $value) {
- $property = strtolower($property);
+ $property = @strtolower($property);
if (!idx(self::$knownProperties, $property)) {
// Unknown property... ignore it.
@@ -147,7 +147,7 @@
}
if (is_string($value)) {
- $value = strtolower($value);
+ $value = @strtolower($value);
}
if ($value === '') {
$value = null;
diff --git a/src/parser/PhutilEmailAddress.php b/src/parser/PhutilEmailAddress.php
--- a/src/parser/PhutilEmailAddress.php
+++ b/src/parser/PhutilEmailAddress.php
@@ -16,15 +16,15 @@
$email_address = trim($email_address);
$matches = null;
- if (preg_match('/^(.*)<(.*?)>$/', $email_address, $matches)) {
+ if (@preg_match('/^(.*)<(.*?)>$/', $email_address, $matches)) {
$display_name = trim($matches[1], '\'" ');
- if (strpos($matches[2], '@') !== false) {
- list($local_part, $domain_name) = explode('@', $matches[2], 2);
+ if (@strpos($matches[2], '@') !== false) {
+ list($local_part, $domain_name) = @explode('@', $matches[2], 2);
} else {
$local_part = $matches[2];
$domain_name = null;
}
- } else if (preg_match('/^(.*)@(.*)$/', $email_address, $matches)) {
+ } else if (@preg_match('/^(.*)@(.*)$/', $email_address, $matches)) {
$display_name = null;
$local_part = $matches[1];
$domain_name = $matches[2];
@@ -41,7 +41,7 @@
public function __toString() {
$address = $this->getAddress();
- if (strlen($this->displayName)) {
+ if (@strlen($this->displayName)) {
$display_name = $this->encodeDisplayName($this->displayName);
return $display_name.' <'.$address.'>';
} else {
@@ -77,7 +77,7 @@
}
public function setAddress($address) {
- $parts = explode('@', $address, 2);
+ $parts = @explode('@', $address, 2);
$this->localPart = $parts[0];
if (isset($parts[1])) {
@@ -89,7 +89,7 @@
public function getAddress() {
$address = $this->localPart;
- if (strlen($this->domainName)) {
+ if (@strlen($this->domainName)) {
$address .= '@'.$this->domainName;
}
return $address;
diff --git a/src/parser/PhutilGitURI.php b/src/parser/PhutilGitURI.php
--- a/src/parser/PhutilGitURI.php
+++ b/src/parser/PhutilGitURI.php
@@ -42,7 +42,7 @@
$regexp = '/^'.$user.$domain.$path.'$/';
$matches = null;
- $ok = preg_match($regexp, $uri, $matches);
+ $ok = @preg_match($regexp, $uri, $matches);
if ($ok) {
return array_pad($matches, 4, '');
}
diff --git a/src/parser/PhutilJSON.php b/src/parser/PhutilJSON.php
--- a/src/parser/PhutilJSON.php
+++ b/src/parser/PhutilJSON.php
@@ -62,7 +62,7 @@
$max = 0;
foreach ($object as $key => $val) {
$ekey = $this->encodeFormattedValue((string)$key, 0);
- $max = max($max, strlen($ekey));
+ $max = max($max, @strlen($ekey));
$keys[] = $ekey;
$vals[] = $this->encodeFormattedValue($val, $depth + 1);
}
diff --git a/src/parser/PhutilLanguageGuesser.php b/src/parser/PhutilLanguageGuesser.php
--- a/src/parser/PhutilLanguageGuesser.php
+++ b/src/parser/PhutilLanguageGuesser.php
@@ -32,7 +32,7 @@
foreach ($patterns as $pattern => $language) {
$matches = null;
- if (preg_match($pattern, $source, $matches)) {
+ if (@preg_match($pattern, $source, $matches)) {
if (is_numeric($language)) {
return $matches[$language];
} else {
diff --git a/src/parser/PhutilQueryStringParser.php b/src/parser/PhutilQueryStringParser.php
--- a/src/parser/PhutilQueryStringParser.php
+++ b/src/parser/PhutilQueryStringParser.php
@@ -42,7 +42,7 @@
$list = $this->parseQueryStringToPairList($query_string);
foreach ($list as $parts) {
list($key, $value) = $parts;
- if (!strlen($key)) {
+ if (!@strlen($key)) {
continue;
}
$this->parseQueryKeyToArr($key, $value, $result);
@@ -74,16 +74,16 @@
public function parseQueryStringToPairList($query_string) {
$list = array();
- if (!strlen($query_string)) {
+ if (!@strlen($query_string)) {
return $list;
}
- $pairs = explode('&', $query_string);
+ $pairs = @explode('&', $query_string);
foreach ($pairs as $pair) {
- if (!strlen($pair)) {
+ if (!@strlen($pair)) {
continue;
}
- $parts = explode('=', $pair, 2);
+ $parts = @explode('=', $pair, 2);
if (count($parts) < 2) {
$parts[] = '';
}
@@ -113,12 +113,12 @@
* @param array $input_arr
*/
private function parseQueryKeyToArr($key, $val, array &$input_arr) {
- if (preg_match('/^[^\[\]]+(?:\[[^\[\]]*\])+$/', $key)) {
+ if (@preg_match('/^[^\[\]]+(?:\[[^\[\]]*\])+$/', $key)) {
$key_pieces = preg_split('/\]?\[/', rtrim($key, ']'));
if ($key_pieces) {
$cursor = &$input_arr;
foreach ($key_pieces as $piece) {
- if (strlen($piece)) {
+ if (@strlen($piece)) {
if (empty($cursor[$piece]) || !is_array($cursor[$piece])) {
$cursor[$piece] = array();
}
diff --git a/src/parser/PhutilSimpleOptions.php b/src/parser/PhutilSimpleOptions.php
--- a/src/parser/PhutilSimpleOptions.php
+++ b/src/parser/PhutilSimpleOptions.php
@@ -50,7 +50,7 @@
if ($type != 'word') {
return array();
}
- if (!strlen($value)) {
+ if (!@strlen($value)) {
return array();
}
$key = $this->normalizeKey($value);
@@ -138,7 +138,7 @@
$result = array();
foreach ($options as $name => $value) {
$name = $this->normalizeKey($name);
- if (!strlen($value)) {
+ if (!@strlen($value)) {
continue;
}
if ($value === true) {
@@ -176,17 +176,17 @@
private function normalizeKey($key) {
- if (!strlen($key)) {
+ if (!@strlen($key)) {
throw new Exception(pht('Empty key is invalid!'));
}
if (!$this->caseSensitive) {
- $key = strtolower($key);
+ $key = @strtolower($key);
}
return $key;
}
private function quoteString($string, $escape) {
- if (preg_match('/[^a-zA-Z0-9]/', $string)) {
+ if (@preg_match('/[^a-zA-Z0-9]/', $string)) {
$string = '"'.addcslashes($string, '\\\'"'.$escape).'"';
}
return $string;
diff --git a/src/parser/PhutilTypeSpec.php b/src/parser/PhutilTypeSpec.php
--- a/src/parser/PhutilTypeSpec.php
+++ b/src/parser/PhutilTypeSpec.php
@@ -80,7 +80,7 @@
}
$trap = new PhutilErrorTrap();
- $ok = @preg_match($value, '');
+ $ok = @@preg_match($value, '');
$err = $trap->getErrorsAsString();
$trap->destroy();
diff --git a/src/parser/PhutilURI.php b/src/parser/PhutilURI.php
--- a/src/parser/PhutilURI.php
+++ b/src/parser/PhutilURI.php
@@ -50,7 +50,7 @@
// Reject ambiguous URIs outright. Different versions of different clients
// parse these in different ways. See T12526 for discussion.
- if (preg_match('(^[^/:]*://[^/]*[#?].*:)', $uri)) {
+ if (@preg_match('(^[^/:]*://[^/]*[#?].*:)', $uri)) {
throw new Exception(
pht(
'Rejecting ambiguous URI "%s". This URI is not formatted or '.
@@ -59,7 +59,7 @@
}
$matches = null;
- if (preg_match('(^([^/:]*://[^/]*)(\\?.*)\z)', $uri, $matches)) {
+ if (@preg_match('(^([^/:]*://[^/]*)(\\?.*)\z)', $uri, $matches)) {
// If the URI is something like `idea://open?file=/path/to/file`, the
// `parse_url()` function will parse `open?file=` as the host. This is
// not the expected result. Break the URI into two pieces, stick a slash
@@ -74,7 +74,7 @@
$host = '(?P<host>[^/:]+)';
$path = ':(?P<path>.*)';
- $ok = preg_match('(^'.$user.$host.$path.'\z)', $uri, $matches);
+ $ok = @preg_match('(^'.$user.$host.$path.'\z)', $uri, $matches);
if (!$ok) {
throw new Exception(
pht(
@@ -105,8 +105,8 @@
// hosts beginning with "-".
if ($parts) {
$host = idx($parts, 'host', '');
- if (strlen($host)) {
- if (!preg_match('/^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-]*\z/', $host)) {
+ if (@strlen($host)) {
+ if (!@preg_match('/^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-]*\z/', $host)) {
$parts = false;
}
}
@@ -154,9 +154,9 @@
$user = $this->user;
$pass = $this->pass;
- if (strlen($user) && strlen($pass)) {
+ if (@strlen($user) && @strlen($pass)) {
$auth = rawurlencode($user).':'.rawurlencode($pass).'@';
- } else if (strlen($user)) {
+ } else if (@strlen($user)) {
$auth = rawurlencode($user).'@';
} else {
$auth = null;
@@ -166,19 +166,19 @@
if ($this->isGitURI()) {
$protocol = null;
} else {
- if (strlen($auth)) {
+ if (@strlen($auth)) {
$protocol = nonempty($this->protocol, 'http');
}
}
- if (strlen($protocol) || strlen($auth) || strlen($domain)) {
+ if (@strlen($protocol) || @strlen($auth) || @strlen($domain)) {
if ($this->isGitURI()) {
$prefix = "{$auth}{$domain}";
} else {
$prefix = "{$protocol}://{$auth}{$domain}";
}
- if (strlen($port)) {
+ if (@strlen($port)) {
$prefix .= ':'.$port;
}
}
@@ -189,7 +189,7 @@
$query = null;
}
- if (strlen($this->getFragment())) {
+ if (@strlen($this->getFragment())) {
$fragment = '#'.$this->getFragment();
} else {
$fragment = null;
@@ -197,7 +197,7 @@
$path = $this->getPath();
if ($this->isGitURI()) {
- if (strlen($path)) {
+ if (@strlen($path)) {
$path = ':'.$path;
}
}
@@ -428,7 +428,7 @@
if ($this->isGitURI()) {
// Git URIs use relative paths which do not need to begin with "/".
} else {
- if ($this->domain && strlen($path) && $path[0] !== '/') {
+ if ($this->domain && @strlen($path) && $path[0] !== '/') {
$path = '/'.$path;
}
}
@@ -438,13 +438,13 @@
}
public function appendPath($path) {
- $first = strlen($path) ? $path[0] : null;
- $last = strlen($this->path) ? $this->path[strlen($this->path) - 1] : null;
+ $first = @strlen($path) ? $path[0] : null;
+ $last = @strlen($this->path) ? $this->path[@strlen($this->path) - 1] : null;
if (!$this->path) {
return $this->setPath($path);
} else if ($first === '/' && $last === '/') {
- $path = substr($path, 1);
+ $path = @substr($path, 1);
} else if ($first !== '/' && $last !== '/') {
$path = '/'.$path;
}
@@ -498,7 +498,7 @@
if ($type == self::TYPE_URI) {
$path = $this->getPath();
- if (strlen($path) && ($path[0] !== '/')) {
+ if (@strlen($path) && ($path[0] !== '/')) {
// Try to catch this here because we are not allowed to throw from
// inside __toString() so we don't have a reasonable opportunity to
// react properly if we catch it later.
@@ -522,7 +522,7 @@
private function isGitURIPattern($uri) {
$matches = null;
- $ok = preg_match('(^(?P<head>[^/]+):(?P<last>(?!//).*)\z)', $uri, $matches);
+ $ok = @preg_match('(^(?P<head>[^/]+):(?P<last>(?!//).*)\z)', $uri, $matches);
if (!$ok) {
return false;
}
@@ -532,20 +532,20 @@
// If any part of this has spaces in it, it's not a Git URI. We fail here
// so we fall back and don't fail more abruptly later.
- if (preg_match('(\s)', $head.$last)) {
+ if (@preg_match('(\s)', $head.$last)) {
return false;
}
// If the second part only contains digits, assume we're looking at
// casually specified "domain.com:123" URI, not a Git URI pointed at an
// entirely numeric relative path.
- if (preg_match('(^\d+\z)', $last)) {
+ if (@preg_match('(^\d+\z)', $last)) {
return false;
}
// If the first part has a "." or an "@" in it, interpret it as a domain
// or a "user@host" string.
- if (preg_match('([.@])', $head)) {
+ if (@preg_match('([.@])', $head)) {
return true;
}
diff --git a/src/parser/__tests__/ArcanistBundleTestCase.php b/src/parser/__tests__/ArcanistBundleTestCase.php
--- a/src/parser/__tests__/ArcanistBundleTestCase.php
+++ b/src/parser/__tests__/ArcanistBundleTestCase.php
@@ -100,14 +100,14 @@
list($commits) = execx(
'git log --format=%s',
'%H %T %s');
- $commits = explode("\n", trim($commits));
+ $commits = @explode("\n", trim($commits));
// The very first commit doesn't have a meaningful parent, so don't examine
// it.
array_pop($commits);
foreach ($commits as $commit) {
- list($commit_hash, $tree_hash, $subject) = explode(' ', $commit, 3);
+ list($commit_hash, $tree_hash, $subject) = @explode(' ', $commit, 3);
execx('git reset --hard %s --', $commit_hash);
$fixture_path = $fixture->getPath();
@@ -158,7 +158,7 @@
->write($patch)
->resolvex();
} catch (CommandException $ex) {
- $temp = new TempFile(substr($commit_hash, 0, 8).'.patch');
+ $temp = new TempFile(@substr($commit_hash, 0, 8).'.patch');
$temp->setPreserveFile(true);
Filesystem::writeFile($temp, $patch);
diff --git a/src/parser/__tests__/ArcanistDiffParserTestCase.php b/src/parser/__tests__/ArcanistDiffParserTestCase.php
--- a/src/parser/__tests__/ArcanistDiffParserTestCase.php
+++ b/src/parser/__tests__/ArcanistDiffParserTestCase.php
@@ -29,9 +29,9 @@
case 'basic-missing-new-newline.udiff':
case 'basic-missing-old-newline-plus.udiff':
case 'basic-missing-old-newline.udiff':
- $expect_old = strpos($file, '-old-') || strpos($file, '-both-');
- $expect_new = strpos($file, '-new-') || strpos($file, '-both-');
- $expect_two = strpos($file, '-plus');
+ $expect_old = @strpos($file, '-old-') || @strpos($file, '-both-');
+ $expect_new = @strpos($file, '-new-') || @strpos($file, '-both-');
+ $expect_two = @strpos($file, '-plus');
$this->assertEqual(count($changes), $expect_two ? 2 : 1);
$change = reset($changes);
@@ -302,8 +302,8 @@
case 'git-move-edit.gitdiff':
case 'git-move-plus.gitdiff':
- $extra_changeset = (bool)strpos($file, '-plus');
- $has_hunk = (bool)strpos($file, '-edit');
+ $extra_changeset = (bool)@strpos($file, '-plus');
+ $has_hunk = (bool)@strpos($file, '-edit');
$this->assertEqual($extra_changeset ? 3 : 2, count($changes));
diff --git a/src/parser/__tests__/PhutilLanguageGuesserTestCase.php b/src/parser/__tests__/PhutilLanguageGuesserTestCase.php
--- a/src/parser/__tests__/PhutilLanguageGuesserTestCase.php
+++ b/src/parser/__tests__/PhutilLanguageGuesserTestCase.php
@@ -7,8 +7,8 @@
foreach (Filesystem::listDirectory($dir, $hidden = false) as $test) {
$source = Filesystem::readFile($dir.$test);
- if (strpos($test, '.') !== false) {
- $expect = head(explode('.', $test));
+ if (@strpos($test, '.') !== false) {
+ $expect = head(@explode('.', $test));
} else {
$expect = null;
}
diff --git a/src/parser/aast/api/AASTNode.php b/src/parser/aast/api/AASTNode.php
--- a/src/parser/aast/api/AASTNode.php
+++ b/src/parser/aast/api/AASTNode.php
@@ -289,7 +289,7 @@
while ($left &&
(!$left->isAnyWhitespace() ||
- strpos($left->getValue(), "\n") === false)) {
+ @strpos($left->getValue(), "\n") === false)) {
$left = $left->getPrevToken();
}
@@ -302,8 +302,8 @@
public function getDescription() {
$concrete = $this->getConcreteString();
- if (strlen($concrete) > 75) {
- $concrete = substr($concrete, 0, 36).'...'.substr($concrete, -36);
+ if (@strlen($concrete) > 75) {
+ $concrete = @substr($concrete, 0, 36).'...'.@substr($concrete, -36);
}
$concrete = addcslashes($concrete, "\\\n\"");
diff --git a/src/parser/aast/api/AASTTree.php b/src/parser/aast/api/AASTTree.php
--- a/src/parser/aast/api/AASTTree.php
+++ b/src/parser/aast/api/AASTTree.php
@@ -32,7 +32,7 @@
$this->stream[$ii] = $this->newToken(
$ii,
$token[0],
- substr($source, $offset, $token[1]),
+ @substr($source, $offset, $token[1]),
$offset,
$this);
$offset += $token[1];
@@ -177,7 +177,7 @@
public function getOffsetToLineNumberMap() {
if ($this->lineMap === null) {
$src = $this->rawSource;
- $len = strlen($src);
+ $len = @strlen($src);
$lno = 1;
$map = array();
for ($ii = 0; $ii < $len; ++$ii) {
diff --git a/src/parser/argument/PhutilArgumentParser.php b/src/parser/argument/PhutilArgumentParser.php
--- a/src/parser/argument/PhutilArgumentParser.php
+++ b/src/parser/argument/PhutilArgumentParser.php
@@ -166,12 +166,12 @@
continue;
} else if (!strncmp('--', $arg, 2)) {
$pre = '--';
- $arg = substr($arg, 2);
+ $arg = @substr($arg, 2);
$map = $specs_by_name;
$options = array_keys($specs_by_name);
- } else if (!strncmp('-', $arg, 1) && strlen($arg) > 1) {
+ } else if (!strncmp('-', $arg, 1) && @strlen($arg) > 1) {
$pre = '-';
- $arg = substr($arg, 1);
+ $arg = @substr($arg, 1);
$map = $specs_by_short;
} else {
$is_initial = false;
@@ -179,7 +179,7 @@
if ($map) {
$val = null;
- $parts = explode('=', $arg, 2);
+ $parts = @explode('=', $arg, 2);
if (count($parts) == 2) {
list($arg, $val) = $parts;
}
@@ -256,7 +256,7 @@
foreach ($conflicts as $conflict => $reason) {
if (array_key_exists($conflict, $this->results)) {
- if (!is_string($reason) || !strlen($reason)) {
+ if (!is_string($reason) || !@strlen($reason)) {
$reason = '.';
} else {
$reason = ': '.$reason.'.';
@@ -762,7 +762,7 @@
$workflows = $this->workflows;
}
- $workflow = idx($workflows, strtolower($workflow_name));
+ $workflow = idx($workflows, @strtolower($workflow_name));
if (!$workflow) {
$out[] = $this->indent(
$indent,
@@ -815,7 +815,7 @@
} else if (
is_string($value) &&
!strncmp($value, '-', 1) &&
- strlen($value) > 1) {
+ @strlen($value) > 1) {
throw new PhutilArgumentUsageException(
pht(
diff --git a/src/parser/argument/PhutilArgumentSpecification.php b/src/parser/argument/PhutilArgumentSpecification.php
--- a/src/parser/argument/PhutilArgumentSpecification.php
+++ b/src/parser/argument/PhutilArgumentSpecification.php
@@ -119,7 +119,7 @@
}
private static function validateName($name) {
- if (!preg_match('/^[a-z0-9][a-z0-9-]*$/', $name)) {
+ if (!@preg_match('/^[a-z0-9][a-z0-9-]*$/', $name)) {
throw new PhutilArgumentSpecificationException(
pht(
"Argument names may only contain a-z, 0-9 and -, and must be ".
@@ -148,14 +148,14 @@
}
private static function validateShortAlias($alias) {
- if (strlen($alias) !== 1) {
+ if (@strlen($alias) !== 1) {
throw new PhutilArgumentSpecificationException(
pht(
"Argument short aliases must be exactly one character long. ".
"'%s' is invalid.",
$alias));
}
- if (!preg_match('/^[a-zA-Z0-9]$/', $alias)) {
+ if (!@preg_match('/^[a-zA-Z0-9]$/', $alias)) {
throw new PhutilArgumentSpecificationException(
pht(
"Argument short aliases may only be in a-z, A-Z and 0-9. ".
diff --git a/src/parser/argument/PhutilArgumentSpellingCorrector.php b/src/parser/argument/PhutilArgumentSpellingCorrector.php
--- a/src/parser/argument/PhutilArgumentSpellingCorrector.php
+++ b/src/parser/argument/PhutilArgumentSpellingCorrector.php
@@ -105,7 +105,7 @@
// If we're correcting commands, never correct an input which begins
// with "-", since this is almost certainly intended to be a flag.
if ($this->getMode() === self::MODE_COMMANDS) {
- if (preg_match('/^-/', $input)) {
+ if (@preg_match('/^-/', $input)) {
return array();
}
}
@@ -120,7 +120,7 @@
if ($this->getMode() === self::MODE_COMMANDS) {
$prefixes = array();
foreach ($options as $option) {
- if (!strncmp($input, $option, strlen($input))) {
+ if (!strncmp($input, $option, @strlen($input))) {
$prefixes[] = $option;
}
}
@@ -155,7 +155,7 @@
}
foreach ($distances as $option => $distance) {
- if (phutil_utf8_strlen($option) < $distance) {
+ if (phutil_utf8strlen($option) < $distance) {
unset($distances[$option]);
}
}
diff --git a/src/parser/diff/ArcanistDiffChange.php b/src/parser/diff/ArcanistDiffChange.php
--- a/src/parser/diff/ArcanistDiffChange.php
+++ b/src/parser/diff/ArcanistDiffChange.php
@@ -216,9 +216,9 @@
$new = $hunk->getNewOffset();
$olds = array();
$news = array();
- $lines = explode("\n", $hunk->getCorpus());
+ $lines = @explode("\n", $hunk->getCorpus());
foreach ($lines as $line) {
- $type = substr($line, 0, 1);
+ $type = @substr($line, 0, 1);
if ($type == '-' || $type == ' ') {
$olds[] = $old;
$old++;
@@ -298,7 +298,7 @@
$hunk = reset($hunks);
$corpus = $hunk->getCorpus();
$match = null;
- if (!preg_match('/^\+(?:link )?(.*)$/m', $corpus, $match)) {
+ if (!@preg_match('/^\+(?:link )?(.*)$/m', $corpus, $match)) {
throw new Exception(pht('Failed to extract link target!'));
}
return trim($match[1]);
diff --git a/src/parser/diff/ArcanistDiffHunk.php b/src/parser/diff/ArcanistDiffHunk.php
--- a/src/parser/diff/ArcanistDiffHunk.php
+++ b/src/parser/diff/ArcanistDiffHunk.php
@@ -52,8 +52,8 @@
$oline = $this->getOldOffset();
$nline = $this->getNewOffset();
- foreach (explode("\n", $this->getCorpus()) as $line) {
- $char = strlen($line) ? $line[0] : '~';
+ foreach (@explode("\n", $this->getCorpus()) as $line) {
+ $char = @strlen($line) ? $line[0] : '~';
switch ($char) {
case '-':
$old_map[$oline] = true;
diff --git a/src/parser/html/PhutilDOMNode.php b/src/parser/html/PhutilDOMNode.php
--- a/src/parser/html/PhutilDOMNode.php
+++ b/src/parser/html/PhutilDOMNode.php
@@ -193,7 +193,7 @@
}
$parts = implode('', $parts);
- if (!strlen($parts)) {
+ if (!@strlen($parts)) {
continue;
}
diff --git a/src/parser/html/PhutilHTMLParser.php b/src/parser/html/PhutilHTMLParser.php
--- a/src/parser/html/PhutilHTMLParser.php
+++ b/src/parser/html/PhutilHTMLParser.php
@@ -13,7 +13,7 @@
$segments = array();
$in_tag = false;
- for ($ii = 0; $ii < strlen($corpus); $ii++) {
+ for ($ii = 0; $ii < @strlen($corpus); $ii++) {
$c = $corpus[$ii];
if ($in_tag && ($c === '>')) {
@@ -59,7 +59,7 @@
// "tag" strings and a list of "non-tag" strings.
$parts = array();
- $corpus_length = strlen($corpus);
+ $corpus_length = @strlen($corpus);
foreach ($segments as $segment) {
$tag = $segment['tag'];
$pos = $segment['pos'];
@@ -76,7 +76,7 @@
}
if (($slice_pos < $corpus_length) && ($slice_len > 0)) {
- $content = substr($corpus, $slice_pos, $slice_len);
+ $content = @substr($corpus, $slice_pos, $slice_len);
} else {
$content = '';
}
@@ -127,16 +127,16 @@
$content = $raw_content;
$content = trim($content);
- $content_len = strlen($content);
+ $content_len = @strlen($content);
// If the tag content begins with "/", like "</td>", strip the slash
// off and mark this as a closing tag.
$is_close = false;
if ($content_len > 0 && $content[0] === '/') {
$is_close = true;
- $content = substr($content, 1);
+ $content = @substr($content, 1);
$content = trim($content);
- $content_len = strlen($content);
+ $content_len = @strlen($content);
}
// If the tag content ends with "/", like "<td />", strip the slash off
@@ -144,9 +144,9 @@
$self_close = false;
if ($content_len > 0 && $content[$content_len - 1] === '/') {
$self_close = true;
- $content = substr($content, 0, $content_len - 1);
+ $content = @substr($content, 0, $content_len - 1);
$content = trim($content);
- $content_len = strlen($content);
+ $content_len = @strlen($content);
}
// If this tag is both a closing tag and a self-closing tag, it is
@@ -166,13 +166,13 @@
}
// If there's no tag name, this tag is not valid. Treat it as content.
- if (!strlen($tag_name)) {
+ if (!@strlen($tag_name)) {
return null;
}
// If this is a closing tag with attributes, it's not valid. Treat it
// as content.
- if ($is_close && strlen($attributes)) {
+ if ($is_close && @strlen($attributes)) {
return null;
}
@@ -200,7 +200,7 @@
return null;
}
- if (strlen($attributes)) {
+ if (@strlen($attributes)) {
$attribute_map = $this->parseAttributes($attributes);
// If the attributes can't be parsed, treat the tag as content.
if ($attribute_map === null) {
@@ -245,7 +245,7 @@
);
$map = array();
- $len = strlen($attributes);
+ $len = @strlen($attributes);
$key_pos = null;
for ($ii = 0; $ii < $len; $ii++) {
$c = $attributes[$ii];
@@ -283,7 +283,7 @@
// Finding a "=" or a space character ends the attribute name.
// Save it, then figure out what to do with the parser state.
if ($c === '=' || $is_space) {
- $name_value = substr($attributes, $name_pos, $ii - $name_pos);
+ $name_value = @substr($attributes, $name_pos, $ii - $name_pos);
$name_value = phutil_utf8_strtolower($name_value);
// If this attribute already exists, the tag is invalid. This means
@@ -362,7 +362,7 @@
// We found the closing quote, so pull out the actual value.
if ($c === '"') {
- $attr_value = substr($attributes, $value_pos, $ii - $value_pos);
+ $attr_value = @substr($attributes, $value_pos, $ii - $value_pos);
$map[$name_value] = $attr_value;
$state = 'key';
@@ -377,7 +377,7 @@
// We've found some whitespace, so pull out the actual value.
if ($is_space) {
- $attr_value = substr($attributes, $value_pos, $ii - $value_pos);
+ $attr_value = @substr($attributes, $value_pos, $ii - $value_pos);
$map[$name_value] = $attr_value;
$state = 'key';
@@ -397,7 +397,7 @@
case 'name':
// We were looking for the end of an attribute name. Treat whatever
// we found as a name.
- $name_value = substr($attributes, $name_pos, $len - $name_pos);
+ $name_value = @substr($attributes, $name_pos, $len - $name_pos);
if (isset($map[$name_value])) {
return null;
@@ -422,7 +422,7 @@
// the delimiter or closing quote. Treat whatever we found as a quoted
// value.
- $attr_value = substr($attributes, $value_pos, $len - $name_pos);
+ $attr_value = @substr($attributes, $value_pos, $len - $name_pos);
$map[$name_value] = $attr_value;
break;
diff --git a/src/parser/html/__tests__/PhutilHTMLParserTestCase.php b/src/parser/html/__tests__/PhutilHTMLParserTestCase.php
--- a/src/parser/html/__tests__/PhutilHTMLParserTestCase.php
+++ b/src/parser/html/__tests__/PhutilHTMLParserTestCase.php
@@ -12,7 +12,7 @@
$path = $root.$test;
$data = Filesystem::readFile($path);
- $parts = explode("\n~~~~~~~~~~\n", $data);
+ $parts = @explode("\n~~~~~~~~~~\n", $data);
if (count($parts) !== 2) {
throw new Exception(
pht(
diff --git a/src/parser/http/PhutilHTTPResponse.php b/src/parser/http/PhutilHTTPResponse.php
--- a/src/parser/http/PhutilHTTPResponse.php
+++ b/src/parser/http/PhutilHTTPResponse.php
@@ -33,7 +33,7 @@
public function appendBody($bytes) {
if ($this->writeHandle !== null) {
$result = @fwrite($this->writeHandle, $bytes);
- if ($result !== strlen($bytes)) {
+ if ($result !== @strlen($bytes)) {
throw new Exception(
pht('Failed to write response to disk. (Maybe the disk is full?)'));
}
diff --git a/src/parser/http/PhutilHTTPResponseParser.php b/src/parser/http/PhutilHTTPResponseParser.php
--- a/src/parser/http/PhutilHTTPResponseParser.php
+++ b/src/parser/http/PhutilHTTPResponseParser.php
@@ -48,7 +48,7 @@
if ($this->state == 'headers') {
$matches = null;
- $ok = preg_match(
+ $ok = @preg_match(
"/(\r?\n\r?\n)/",
$this->buffer,
$matches,
@@ -58,16 +58,16 @@
}
$headers_len = $matches[1][1];
- $boundary_len = strlen($matches[1][0]);
- $raw_headers = substr($this->buffer, 0, $headers_len);
- $this->buffer = substr($this->buffer, $headers_len + $boundary_len);
+ $boundary_len = @strlen($matches[1][0]);
+ $raw_headers = @substr($this->buffer, 0, $headers_len);
+ $this->buffer = @substr($this->buffer, $headers_len + $boundary_len);
$header_lines = phutil_split_lines($raw_headers);
$first_line = array_shift($header_lines);
$response_valid = true;
$matches = null;
- $ok = preg_match(
+ $ok = @preg_match(
'(^HTTP/\S+\s+(\d+)(?:\s+(.*))?$)i',
$first_line,
$matches);
@@ -82,14 +82,14 @@
$header_list = array();
$saw_location = false;
foreach ($header_lines as $header_line) {
- $pos = strpos($header_line, ':');
+ $pos = @strpos($header_line, ':');
if ($pos === false) {
$response_valid = false;
break;
}
- $name = substr($header_line, 0, $pos);
- $value = ltrim(substr($header_line, $pos + 1), ' ');
+ $name = @substr($header_line, 0, $pos);
+ $value = ltrim(@substr($header_line, $pos + 1), ' ');
if (phutil_utf8_strtolower($name) == 'location') {
$saw_location = true;
@@ -163,7 +163,7 @@
}
if ($this->state == 'body') {
- if (strlen($this->buffer)) {
+ if (@strlen($this->buffer)) {
$bytes = $this->buffer;
$this->buffer = '';
@@ -171,7 +171,7 @@
$sink = $this->getProgressSink();
if ($sink) {
- $sink->didMakeProgress(strlen($bytes));
+ $sink->didMakeProgress(@strlen($bytes));
}
}
break;
diff --git a/src/parser/http/__tests__/PhutilHTTPResponseParserTestCase.php b/src/parser/http/__tests__/PhutilHTTPResponseParserTestCase.php
--- a/src/parser/http/__tests__/PhutilHTTPResponseParserTestCase.php
+++ b/src/parser/http/__tests__/PhutilHTTPResponseParserTestCase.php
@@ -98,11 +98,11 @@
}
// Submit the input in little bits to try to catch any weird parser bugs.
- $length = strlen($input);
+ $length = @strlen($input);
$pos = 0;
while ($pos < $length) {
$next_len = mt_rand(1, 32);
- $piece = substr($input, $pos, $next_len);
+ $piece = @substr($input, $pos, $next_len);
$pos = $pos + $next_len;
$parser->readBytes($piece);
diff --git a/src/parser/xhpast/__tests__/PHPASTParserTestCase.php b/src/parser/xhpast/__tests__/PHPASTParserTestCase.php
--- a/src/parser/xhpast/__tests__/PHPASTParserTestCase.php
+++ b/src/parser/xhpast/__tests__/PHPASTParserTestCase.php
@@ -14,7 +14,7 @@
$dir = dirname(__FILE__).'/data/';
foreach (Filesystem::listDirectory($dir) as $file) {
- if (preg_match('/\.test$/', $file)) {
+ if (@preg_match('/\.test$/', $file)) {
$this->executeParserTest($file, $dir.$file);
}
}
@@ -82,7 +82,7 @@
case 'pass':
$this->assertEqual(0, $err, pht('Exit code for "%s".', $name));
- if (!strlen($expect)) {
+ if (!@strlen($expect)) {
// If there's no "expect" data in the test case, that's OK.
break;
}
@@ -107,7 +107,7 @@
case 'fail-syntax':
$this->assertEqual(1, $err, pht('Exit code for "%s".', $name));
$this->assertTrue(
- (bool)preg_match('/syntax error/', $stderr),
+ (bool)@preg_match('/syntax error/', $stderr),
pht('Expect "syntax error" in stderr or "%s".', $name));
break;
default:
@@ -244,17 +244,17 @@
$must_escape = false;
// We must escape the text if it isn't just simple printable characters.
- if (preg_match('/[ \\\\\\r\\n\\t\\"]/', $text)) {
+ if (@preg_match('/[ \\\\\\r\\n\\t\\"]/', $text)) {
$must_escape = true;
}
// We must escape the text if it has trailing whitespace.
- if (preg_match('/ \z/', $text)) {
+ if (@preg_match('/ \z/', $text)) {
$must_escape = true;
}
// We must escape the text if it won't fit on a single line.
- if (strlen($text) > $usable_width) {
+ if (@strlen($text) > $usable_width) {
$must_escape = true;
}
@@ -282,14 +282,14 @@
$line_l = '"';
$line_r = '"';
- $max_width = ($usable_width - strlen($line_l) - strlen($line_r));
+ $max_width = ($usable_width - @strlen($line_l) - @strlen($line_r));
$line = '';
$len = 0;
$lines = array();
foreach ($vector as $word) {
- $word_length = phutil_utf8_console_strlen($word);
+ $word_length = phutil_utf8_consolestrlen($word);
if ($len + $word_length > $max_width) {
$lines[] = $line_l.$line.$line_r;
diff --git a/src/parser/xhpast/api/XHPASTNode.php b/src/parser/xhpast/api/XHPASTNode.php
--- a/src/parser/xhpast/api/XHPASTNode.php
+++ b/src/parser/xhpast/api/XHPASTNode.php
@@ -38,12 +38,12 @@
return phutil_string_cast($this->getStringLiteralValue());
case 'n_NUMERIC_SCALAR':
$value = $this->getSemanticString();
- if (preg_match('/^0x/i', $value)) {
+ if (@preg_match('/^0x/i', $value)) {
// Hex
- $value = base_convert(substr($value, 2), 16, 10);
- } else if (preg_match('/^0\d+$/i', $value)) {
+ $value = base_convert(@substr($value, 2), 16, 10);
+ } else if (@preg_match('/^0\d+$/i', $value)) {
// Octal
- $value = base_convert(substr($value, 1), 8, 10);
+ $value = base_convert(@substr($value, 1), 8, 10);
}
return +$value;
case 'n_SYMBOL_NAME':
@@ -51,7 +51,7 @@
if ($value == 'INF') {
return INF;
}
- switch (strtolower($value)) {
+ switch (@strtolower($value)) {
case 'true':
return true;
case 'false':
@@ -146,7 +146,7 @@
switch ($this->getTypeName()) {
case 'n_HEREDOC':
- if (preg_match("/^<<<\s*'/", $value)) { // Nowdoc: <<<'EOT'
+ if (@preg_match("/^<<<\s*'/", $value)) { // Nowdoc: <<<'EOT'
return array();
}
break;
@@ -229,7 +229,7 @@
// literally "\q" and "\'". stripcslashes() is too aggressive, so find
// all these under-escaped backslashes and escape them.
- $len = strlen($value);
+ $len = @strlen($value);
$esc = false;
$out = '';
@@ -240,7 +240,7 @@
switch ($c) {
case 'x':
$u = isset($value[$ii + 1]) ? $value[$ii + 1] : null;
- if (!preg_match('/^[a-f0-9]/i', $u)) {
+ if (!@preg_match('/^[a-f0-9]/i', $u)) {
// PHP treats \x followed by anything which is not a hex digit
// as a literal \x.
$out .= '\\\\'.$c;
diff --git a/src/parser/xhpast/api/XHPASTTree.php b/src/parser/xhpast/api/XHPASTTree.php
--- a/src/parser/xhpast/api/XHPASTTree.php
+++ b/src/parser/xhpast/api/XHPASTTree.php
@@ -47,7 +47,7 @@
if ($err) {
if ($err == 1) {
$matches = null;
- $is_syntax = preg_match(
+ $is_syntax = @preg_match(
'/^XHPAST Parse Error: (.*) on line (\d+)/s',
$stderr,
$matches);
diff --git a/src/phage/action/PhageAgentAction.php b/src/phage/action/PhageAgentAction.php
--- a/src/phage/action/PhageAgentAction.php
+++ b/src/phage/action/PhageAgentAction.php
@@ -228,7 +228,7 @@
}
private function writeOutput($key, $kind, $text) {
- if (!strlen($text)) {
+ if (!@strlen($text)) {
return;
}
@@ -246,7 +246,7 @@
$command = $this->commands[$key]['command'];
$label = $command->getLabel();
- if (!strlen($label)) {
+ if (!@strlen($label)) {
$label = pht('Unknown Command');
}
diff --git a/src/phage/agent/PhagePHPAgent.php b/src/phage/agent/PhagePHPAgent.php
--- a/src/phage/agent/PhagePHPAgent.php
+++ b/src/phage/agent/PhagePHPAgent.php
@@ -112,7 +112,7 @@
list($stdout, $stderr) = $future->read();
$future->discardBuffers();
- if (strlen($stdout)) {
+ if (@strlen($stdout)) {
$master->write(
array(
'type' => 'TEXT',
@@ -122,7 +122,7 @@
));
}
- if (strlen($stderr)) {
+ if (@strlen($stderr)) {
$master->write(
array(
'type' => 'TEXT',
diff --git a/src/phage/bootloader/PhagePHPAgentBootloader.php b/src/phage/bootloader/PhagePHPAgentBootloader.php
--- a/src/phage/bootloader/PhagePHPAgentBootloader.php
+++ b/src/phage/bootloader/PhagePHPAgentBootloader.php
@@ -70,15 +70,15 @@
// what's going on here, but just sweep it under the rug for now.
$main_sequence->addText('$A = new PhagePHPAgent($I); $A->execute();');
- $main_length = strlen($main_sequence->toString());
+ $main_length = @strlen($main_sequence->toString());
$boot_sequence = new PhutilBallOfPHP();
$boot = '
$length = '.$main_length.';
$buffer = "";
- while (strlen($buffer) < $length) {
- $data = fread($I, $length - strlen($buffer));
- if (!strlen($data)) {
+ while (@strlen($buffer) < $length) {
+ $data = fread($I, $length - @strlen($buffer));
+ if (!@strlen($data)) {
exit(1);
}
$buffer .= $data;
@@ -86,10 +86,10 @@
eval($buffer);';
$boot_sequence->addText($boot);
- $boot_length = strlen($boot_sequence->toString());
+ $boot_length = @strlen($boot_sequence->toString());
$boot_sequence->addText($main_sequence->toString());
- if (strlen($boot_length) > 8192) {
+ if (@strlen($boot_length) > 8192) {
throw new Exception(pht('Stage 1 bootloader is too large!'));
}
diff --git a/src/phage/util/PhutilBallOfPHP.php b/src/phage/util/PhutilBallOfPHP.php
--- a/src/phage/util/PhutilBallOfPHP.php
+++ b/src/phage/util/PhutilBallOfPHP.php
@@ -17,7 +17,7 @@
$path,
'<?php\n'));
}
- $this->parts[] = substr($data, 6);
+ $this->parts[] = @substr($data, 6);
return $this;
}
diff --git a/src/progress/PhutilConsoleProgressSink.php b/src/progress/PhutilConsoleProgressSink.php
--- a/src/progress/PhutilConsoleProgressSink.php
+++ b/src/progress/PhutilConsoleProgressSink.php
@@ -97,13 +97,13 @@
$tail = '';
if ($this->lineWidth) {
- $line_len = strlen($line);
+ $line_len = @strlen($line);
if ($line_len < $this->lineWidth) {
$tail = str_repeat(' ', $this->lineWidth - $line_len);
}
- $this->lineWidth = strlen($line);
+ $this->lineWidth = @strlen($line);
}
$this->printLine($head.$line.$tail);
diff --git a/src/readableserializer/PhutilReadableSerializer.php b/src/readableserializer/PhutilReadableSerializer.php
--- a/src/readableserializer/PhutilReadableSerializer.php
+++ b/src/readableserializer/PhutilReadableSerializer.php
@@ -67,11 +67,11 @@
// yet.
$limit = 1024;
$str = self::printableValue($value);
- if (strlen($str) > $limit) {
+ if (@strlen($str) > $limit) {
if (is_string($value)) {
- $str = "'".substr($str, 1, $limit)."...'";
+ $str = "'".@substr($str, 1, $limit)."...'";
} else {
- $str = substr($str, 0, $limit).'...';
+ $str = @substr($str, 0, $limit).'...';
}
}
@@ -177,7 +177,7 @@
* @task internal
*/
private static function addIndentation($value, $indent, $first_line) {
- $lines = explode("\n", $value);
+ $lines = @explode("\n", $value);
$out = array();
foreach ($lines as $index => $line) {
$out[] = $index >= $first_line ? $indent.$line : $line;
diff --git a/src/ref/ArcanistRefView.php b/src/ref/ArcanistRefView.php
--- a/src/ref/ArcanistRefView.php
+++ b/src/ref/ArcanistRefView.php
@@ -73,7 +73,7 @@
$title = $this->getTitle();
if ($object_name !== null) {
- $reserve_width = phutil_utf8_console_strlen($object_name) + 1;
+ $reserve_width = phutil_utf8_consolestrlen($object_name) + 1;
} else {
$reserve_width = 0;
}
@@ -83,7 +83,7 @@
} else {
$indent_text = '';
}
- $indent_width = strlen($indent_text);
+ $indent_width = @strlen($indent_text);
$marker_width = 6;
$display_width = phutil_console_get_terminal_width();
@@ -103,7 +103,7 @@
->truncateString($title);
if ($object_name !== null) {
- if (strlen($title)) {
+ if (@strlen($title)) {
$display_text = tsprintf('**%s** %s', $object_name, $title);
} else {
$display_text = tsprintf('**%s**', $object_name);
diff --git a/src/ref/ArcanistRepositoryRef.php b/src/ref/ArcanistRepositoryRef.php
--- a/src/ref/ArcanistRepositoryRef.php
+++ b/src/ref/ArcanistRepositoryRef.php
@@ -66,7 +66,7 @@
));
foreach ($params as $key => $value) {
- if (!strlen($value)) {
+ if (!@strlen($value)) {
unset($params[$key]);
}
}
@@ -129,8 +129,8 @@
$ref_name = $ref->getName();
foreach ($rules as $rule) {
$matches = null;
- if (preg_match('(^regexp\\((.*)\\)\z)', $rule, $matches)) {
- if (preg_match($matches[1], $ref_name)) {
+ if (@preg_match('(^regexp\\((.*)\\)\z)', $rule, $matches)) {
+ if (@preg_match($matches[1], $ref_name)) {
return true;
}
} else {
diff --git a/src/ref/commit/ArcanistGitCommitSymbolCommitHardpointQuery.php b/src/ref/commit/ArcanistGitCommitSymbolCommitHardpointQuery.php
--- a/src/ref/commit/ArcanistGitCommitSymbolCommitHardpointQuery.php
+++ b/src/ref/commit/ArcanistGitCommitSymbolCommitHardpointQuery.php
@@ -48,7 +48,7 @@
$pairs = array_combine($symbol_set, $lines);
foreach ($pairs as $symbol => $line) {
- $parts = explode(' ', $line, 3);
+ $parts = @explode(' ', $line, 3);
if (count($parts) < 2) {
throw new Exception(
@@ -91,7 +91,7 @@
}
private function validateSymbol($symbol) {
- if (strpos($symbol, "\n") !== false) {
+ if (@strpos($symbol, "\n") !== false) {
throw new Exception(
pht(
'Commit symbol "%s" contains a newline. This is not a valid '.
diff --git a/src/ref/simple/ArcanistSimpleSymbolRef.php b/src/ref/simple/ArcanistSimpleSymbolRef.php
--- a/src/ref/simple/ArcanistSimpleSymbolRef.php
+++ b/src/ref/simple/ArcanistSimpleSymbolRef.php
@@ -28,7 +28,7 @@
$id_pattern = '(^'.$prefix_pattern.'([1-9]\d*)\z)';
- $is_id = preg_match($id_pattern, $symbol, $matches);
+ $is_id = @preg_match($id_pattern, $symbol, $matches);
if ($is_id) {
$this->type = self::TYPE_ID;
return (int)$matches[1];
@@ -37,7 +37,7 @@
$phid_type = $this->getSimpleSymbolPHIDType();
$phid_type = preg_quote($phid_type);
$phid_pattern = '(^PHID-'.$phid_type.'-\S+\z)';
- $is_phid = preg_match($phid_pattern, $symbol, $matches);
+ $is_phid = @preg_match($phid_pattern, $symbol, $matches);
if ($is_phid) {
$this->type = self::TYPE_PHID;
return $matches[0];
diff --git a/src/ref/user/ArcanistUserRef.php b/src/ref/user/ArcanistUserRef.php
--- a/src/ref/user/ArcanistUserRef.php
+++ b/src/ref/user/ArcanistUserRef.php
@@ -49,7 +49,7 @@
protected function buildRefView(ArcanistRefView $view) {
$real_name = $this->getRealName();
- if (strlen($real_name)) {
+ if (@strlen($real_name)) {
$real_name = sprintf('(%s)', $real_name);
}
diff --git a/src/ref/user/ArcanistUserSymbolRef.php b/src/ref/user/ArcanistUserSymbolRef.php
--- a/src/ref/user/ArcanistUserSymbolRef.php
+++ b/src/ref/user/ArcanistUserSymbolRef.php
@@ -27,25 +27,25 @@
protected function resolveSymbol($symbol) {
$matches = null;
- $is_id = preg_match('/^([1-9]\d*)\z/', $symbol, $matches);
+ $is_id = @preg_match('/^([1-9]\d*)\z/', $symbol, $matches);
if ($is_id) {
$this->type = self::TYPE_ID;
return (int)$matches[1];
}
- $is_phid = preg_match('/^PHID-USER-\S+\z/', $symbol, $matches);
+ $is_phid = @preg_match('/^PHID-USER-\S+\z/', $symbol, $matches);
if ($is_phid) {
$this->type = self::TYPE_PHID;
return $matches[0];
}
- $is_function = preg_match('/^\S+\(\s*\)\s*\z/', $symbol, $matches);
+ $is_function = @preg_match('/^\S+\(\s*\)\s*\z/', $symbol, $matches);
if ($is_function) {
$this->type = self::TYPE_FUNCTION;
return $matches[0];
}
- $is_username = preg_match('/^@?(\S+)\z/', $symbol, $matches);
+ $is_username = @preg_match('/^@?(\S+)\z/', $symbol, $matches);
if ($is_username) {
$this->type = self::TYPE_USERNAME;
return $matches[1];
diff --git a/src/repository/api/ArcanistGitAPI.php b/src/repository/api/ArcanistGitAPI.php
--- a/src/repository/api/ArcanistGitAPI.php
+++ b/src/repository/api/ArcanistGitAPI.php
@@ -163,7 +163,7 @@
}
// NOTE: Windows escaping of "%" symbols apparently is inherently broken;
- // when passed through escapeshellarg() they are replaced with spaces.
+ // when passed through @escapeshellarg() they are replaced with spaces.
// TODO: Learn how cmd.exe works and find some clever workaround?
@@ -180,20 +180,20 @@
$commits = array();
$info = trim($info, " \n\2");
- if (!strlen($info)) {
+ if (!@strlen($info)) {
return array();
}
- $info = explode("\2", $info);
+ $info = @explode("\2", $info);
foreach ($info as $line) {
list($commit, $tree, $parents, $time, $author, $author_email,
- $title, $message) = explode("\1", trim($line), 8);
+ $title, $message) = @explode("\1", trim($line), 8);
$message = rtrim($message);
$commits[$commit] = array(
'commit' => $commit,
'tree' => $tree,
- 'parents' => array_filter(explode(' ', $parents)),
+ 'parents' => array_filter(@explode(' ', $parents)),
'time' => $time,
'author' => $author,
'summary' => $title,
@@ -351,7 +351,7 @@
$prompt = pht('What default do you want to use? [origin/master]');
$default = phutil_console_prompt($prompt);
- if (!strlen(trim($default))) {
+ if (!@strlen(trim($default))) {
$default = 'origin/master';
}
@@ -512,7 +512,7 @@
return null;
}
- if (!strlen($branch)) {
+ if (!@strlen($branch)) {
return null;
}
@@ -600,7 +600,7 @@
public function getCanonicalRevisionName($string) {
$match = null;
- if (preg_match('/@([0-9]+)$/', $string, $match)) {
+ if (@preg_match('/@([0-9]+)$/', $string, $match)) {
$stdout = $this->getHashFromFromSVNRevisionNumber($match[1]);
} else {
list($stdout) = $this->execxLocal(
@@ -626,7 +626,7 @@
}
// When git performs a partial-rebuild during svn
// look-up, we need to parse the final line
- $lines = explode("\n", $stdout);
+ $lines = @explode("\n", $stdout);
$stdout = $lines[count($lines) - 2];
return rtrim($stdout);
}
@@ -650,28 +650,28 @@
list($stdout) = $status->resolvex();
$result = new PhutilArrayWithDefaultValue();
- $parts = explode("\0", $stdout);
+ $parts = @explode("\0", $stdout);
while (count($parts) > 1) {
$entry = array_shift($parts);
- $entry_parts = explode(' ', $entry, 2);
+ $entry_parts = @explode(' ', $entry, 2);
if ($entry_parts[0] == '1') {
- $entry_parts = explode(' ', $entry, 9);
+ $entry_parts = @explode(' ', $entry, 9);
$path = $entry_parts[8];
} else if ($entry_parts[0] == '2') {
- $entry_parts = explode(' ', $entry, 10);
+ $entry_parts = @explode(' ', $entry, 10);
$path = $entry_parts[9];
} else if ($entry_parts[0] == 'u') {
- $entry_parts = explode(' ', $entry, 11);
+ $entry_parts = @explode(' ', $entry, 11);
$path = $entry_parts[10];
} else if ($entry_parts[0] == '?') {
- $entry_parts = explode(' ', $entry, 2);
+ $entry_parts = @explode(' ', $entry, 2);
$result[$entry_parts[1]] = self::FLAG_UNTRACKED;
continue;
}
$result[$path] |= self::FLAG_UNCOMMITTED;
- $index_state = substr($entry_parts[1], 0, 1);
- $working_state = substr($entry_parts[1], 1, 1);
+ $index_state = @substr($entry_parts[1], 0, 1);
+ $working_state = @substr($entry_parts[1], 1, 1);
if ($index_state == 'A') {
$result[$path] |= self::FLAG_ADDED;
} else if ($index_state == 'M') {
@@ -691,8 +691,8 @@
}
}
}
- $submodule_tracked = substr($entry_parts[2], 2, 1);
- $submodule_untracked = substr($entry_parts[2], 3, 1);
+ $submodule_tracked = @substr($entry_parts[2], 2, 1);
+ $submodule_untracked = @substr($entry_parts[2], 3, 1);
if ($submodule_tracked == 'M' || $submodule_untracked == 'U') {
$result[$path] |= self::FLAG_EXTERNALS;
}
@@ -761,8 +761,8 @@
list($stdout) = $untracked_future->resolvex();
$stdout = rtrim($stdout, "\n");
- if (strlen($stdout)) {
- $stdout = explode("\n", $stdout);
+ if (@strlen($stdout)) {
+ $stdout = @explode("\n", $stdout);
foreach ($stdout as $path) {
$result[$path] |= self::FLAG_UNTRACKED;
}
@@ -770,8 +770,8 @@
list($stdout, $stderr) = $unstaged_future->resolvex();
$stdout = rtrim($stdout, "\n");
- if (strlen($stdout)) {
- $stdout = explode("\n", $stdout);
+ if (@strlen($stdout)) {
+ $stdout = @explode("\n", $stdout);
foreach ($stdout as $path) {
$result[$path] |= self::FLAG_UNSTAGED;
}
@@ -850,7 +850,7 @@
$status = trim($status);
$lines = array();
- foreach (explode("\n", $status) as $line) {
+ foreach (@explode("\n", $status) as $line) {
if ($line) {
$lines[] = preg_split("/[ \t]/", $line, 6);
}
@@ -899,7 +899,7 @@
} else if (isset($flags[$flag])) {
$mask |= $flags[$flag];
} else if ($flag[0] == 'R') {
- $both = explode("\t", $file);
+ $both = @explode("\t", $file);
if ($full) {
$files[$both[0]] = array(
'mask' => $mask | self::FLAG_DELETED,
@@ -911,7 +911,7 @@
$file = $both[1];
$mask |= self::FLAG_ADDED;
} else if ($flag[0] == 'C') {
- $both = explode("\t", $file);
+ $both = @explode("\t", $file);
$file = $both[1];
$mask |= self::FLAG_ADDED;
}
@@ -957,12 +957,12 @@
$blame = array();
foreach ($blame_info as $line_info) {
- $revision = substr($line_info, 0, 40);
+ $revision = @substr($line_info, 0, 40);
$data = idx($revision_data, $revision, array());
if (empty($data)) {
$matches = array();
- if (!preg_match('/^author (.*)$/m', $line_info, $matches)) {
+ if (!@preg_match('/^author (.*)$/m', $line_info, $matches)) {
throw new Exception(
pht(
'Unexpected output from %s: no author for commit %s',
@@ -970,7 +970,7 @@
$revision));
}
$data['author'] = $matches[1];
- $data['from_first_commit'] = preg_match('/^boundary$/m', $line_info);
+ $data['from_first_commit'] = @preg_match('/^boundary$/m', $line_info);
$revision_data[$revision] = $data;
}
@@ -996,14 +996,14 @@
$result = array();
$stdout = trim($stdout);
- if (!strlen($stdout)) {
+ if (!@strlen($stdout)) {
return $result;
}
- $lines = explode("\n", $stdout);
+ $lines = @explode("\n", $stdout);
foreach ($lines as $line) {
$matches = array();
- $ok = preg_match(
+ $ok = @preg_match(
'/^(\d{6}) (blob|tree|commit) ([a-z0-9]{40})[\t](.*)$/',
$line,
$matches);
@@ -1025,7 +1025,7 @@
// and treat it as though it as a file containing a list of other files,
// which is silly.
- if (!strlen($path)) {
+ if (!@strlen($path)) {
// No filename, so there's no content (Probably new/deleted file).
return null;
}
@@ -1076,14 +1076,14 @@
$current = $this->getBranchName();
$result = array();
- $lines = explode("\2", $stdout);
+ $lines = @explode("\2", $stdout);
foreach ($lines as $line) {
$line = trim($line);
- if (!strlen($line)) {
+ if (!@strlen($line)) {
continue;
}
- $fields = explode("\1", $line, 6);
+ $fields = @explode("\1", $line, 6);
list($ref, $hash, $epoch, $tree, $desc, $text) = $fields;
$branch = $this->getBranchNameFromRef($ref);
@@ -1154,7 +1154,7 @@
public function getAllLocalChanges() {
$diff = $this->getFullGitDiff($this->getBaseCommit());
- if (!strlen(trim($diff))) {
+ if (!@strlen(trim($diff))) {
return array();
}
$parser = new ArcanistDiffParser();
@@ -1182,7 +1182,7 @@
array $query) {
$messages = $this->getGitCommitLog();
- if (!strlen($messages)) {
+ if (!@strlen($messages)) {
return array();
}
@@ -1209,7 +1209,7 @@
));
foreach ($results as $key => $result) {
- $hash = substr($reason_map[$result['id']], 0, 16);
+ $hash = @substr($reason_map[$result['id']], 0, 16);
$results[$key]['why'] = pht(
"Commit message for '%s' has explicit 'Differential Revision'.",
$hash);
@@ -1263,12 +1263,12 @@
}
public function resolveBaseCommitRule($rule, $source) {
- list($type, $name) = explode(':', $rule, 2);
+ list($type, $name) = @explode(':', $rule, 2);
switch ($type) {
case 'git':
$matches = null;
- if (preg_match('/^merge-base\((.+)\)$/', $name, $matches)) {
+ if (@preg_match('/^merge-base\((.+)\)$/', $name, $matches)) {
list($err, $merge_base) = $this->execManualLocal(
'merge-base -- %s HEAD',
$matches[1]);
@@ -1282,7 +1282,7 @@
$source));
return trim($merge_base);
}
- } else if (preg_match('/^branch-unique\((.+)\)$/', $name, $matches)) {
+ } else if (@preg_match('/^branch-unique\((.+)\)$/', $name, $matches)) {
list($err, $merge_base) = $this->execManualLocal(
'merge-base -- %s HEAD',
$matches[1]);
@@ -1295,7 +1295,7 @@
'log --format=%C %s..HEAD --',
'%H',
$merge_base);
- $commits = array_filter(explode("\n", $commits));
+ $commits = array_filter(@explode("\n", $commits));
if (!$commits) {
return null;
@@ -1324,7 +1324,7 @@
'branch %Ls --contains %s',
$flags,
$commit);
- $branches = array_filter(explode("\n", $branches));
+ $branches = array_filter(@explode("\n", $branches));
// Filter the list, removing the "current" marker (*) and ignoring
// anything other than known branch names (mainly, any possible
@@ -1470,7 +1470,7 @@
$upstream = trim($upstream);
- if (preg_match('(^refs/heads/)', $upstream)) {
+ if (@preg_match('(^refs/heads/)', $upstream)) {
$upstream = preg_replace('(^refs/heads/)', '', $upstream);
$is_cycle = $path->getUpstream($upstream);
@@ -1493,9 +1493,9 @@
continue;
}
- if (preg_match('(^refs/remotes/)', $upstream)) {
+ if (@preg_match('(^refs/remotes/)', $upstream)) {
$upstream = preg_replace('(^refs/remotes/)', '', $upstream);
- list($remote, $branch) = explode('/', $upstream, 2);
+ list($remote, $branch) = @explode('/', $upstream, 2);
$path->addUpstream(
$cursor,
@@ -1562,7 +1562,7 @@
if ($remote_uri !== null) {
$remote_uri = rtrim($remote_uri);
- if (!strlen($remote_uri)) {
+ if (!@strlen($remote_uri)) {
$remote_uri = null;
}
}
diff --git a/src/repository/api/ArcanistMercurialAPI.php b/src/repository/api/ArcanistMercurialAPI.php
--- a/src/repository/api/ArcanistMercurialAPI.php
+++ b/src/repository/api/ArcanistMercurialAPI.php
@@ -190,7 +190,7 @@
"{date|rfc822date}\1{branch}\1{tag}\1{parents}\1{desc}\2",
hgsprintf('(%s::. - %s)', $base_commit, $base_commit),
$this->getBranchName());
- $logs = array_filter(explode("\2", $info));
+ $logs = array_filter(@explode("\2", $info));
$last_node = null;
@@ -199,7 +199,7 @@
$commits = array();
foreach ($logs as $log) {
list($node, $rev, $full_author, $date, $branch, $tag,
- $parents, $desc) = explode("\1", $log, 9);
+ $parents, $desc) = @explode("\1", $log, 9);
list($author, $author_email) = $this->parseFullAuthor($full_author);
@@ -232,7 +232,7 @@
'rev' => $node, // TODO: Remove eventually.
'local' => $rev,
'parents' => $commit_parents,
- 'summary' => head(explode("\n", $desc)),
+ 'summary' => head(@explode("\n", $desc)),
'message' => $desc,
'authorEmail' => $author_email,
);
@@ -244,7 +244,7 @@
->limit(4);
foreach ($futures as $node => $future) {
list($parents) = $future->resolvex();
- $parents = array_filter(explode("\n", $parents));
+ $parents = array_filter(@explode("\n", $parents));
$commits[$node]['parents'] = $parents;
}
@@ -282,12 +282,12 @@
$blame = array();
foreach ($lines as $line) {
- if (!strlen($line)) {
+ if (!@strlen($line)) {
continue;
}
$matches = null;
- $ok = preg_match('/^\s*([^:]+?) ([a-f0-9]{12}):/', $line, $matches);
+ $ok = @preg_match('/^\s*([^:]+?) ([a-f0-9]{12}):/', $line, $matches);
if (!$ok) {
throw new Exception(
@@ -461,7 +461,7 @@
if ($err) {
return false;
} else {
- return (strpos($stdout, 'amend') !== false);
+ return (@strpos($stdout, 'amend') !== false);
}
}
@@ -505,7 +505,7 @@
public function getAllLocalChanges() {
$diff = $this->getFullMercurialDiff();
- if (!strlen(trim($diff))) {
+ if (!@strlen(trim($diff))) {
return array();
}
$parser = new ArcanistDiffParser();
@@ -529,9 +529,9 @@
$map = array();
- $logs = explode("\2", trim($stdout));
+ $logs = @explode("\2", trim($stdout));
foreach (array_filter($logs) as $log) {
- list($node, $desc) = explode("\1", $log);
+ list($node, $desc) = @explode("\1", $log);
$map[$node] = $desc;
}
@@ -565,7 +565,7 @@
));
foreach ($results as $key => $result) {
- $hash = substr($reason_map[$result['id']], 0, 16);
+ $hash = @substr($reason_map[$result['id']], 0, 16);
$results[$key]['why'] =
pht(
"Commit message for '%s' has explicit 'Differential Revision'.",
@@ -633,7 +633,7 @@
* @return array
*/
protected function parseFullAuthor($full_author) {
- if (strpos($full_author, '@') === false) {
+ if (@strpos($full_author, '@') === false) {
$author = $full_author;
$author_email = null;
} else {
@@ -672,7 +672,7 @@
'commit --amend -l %s',
$tmp_file);
} catch (CommandException $ex) {
- if (preg_match('/nothing changed/', $ex->getStdout())) {
+ if (@preg_match('/nothing changed/', $ex->getStdout())) {
// NOTE: Mercurial considers it an error to make a no-op amend. Although
// we generally defer to the underlying VCS to dictate behavior, this
// one seems a little goofy, and we use amend as part of various
@@ -695,13 +695,13 @@
'log --template {desc} --limit 1 --rev %s',
$commit);
- $summary = head(explode("\n", $summary));
+ $summary = head(@explode("\n", $summary));
return trim($summary);
}
public function resolveBaseCommitRule($rule, $source) {
- list($type, $name) = explode(':', $rule, 2);
+ list($type, $name) = @explode(':', $rule, 2);
// NOTE: This function MUST return node hashes or symbolic commits (like
// branch names or the word "tip"), not revsets. This includes ".^" and
@@ -711,7 +711,7 @@
switch ($type) {
case 'hg':
$matches = null;
- if (preg_match('/^gca\((.+)\)$/', $name, $matches)) {
+ if (@preg_match('/^gca\((.+)\)$/', $name, $matches)) {
list($err, $merge_base) = $this->execManualLocal(
'log --template={node} --rev %s',
sprintf('ancestor(., %s)', $matches[1]));
@@ -817,19 +817,19 @@
$source));
return $this->getCanonicalRevisionName('.^');
default:
- if (preg_match('/^nodiff\((.+)\)$/', $name, $matches)) {
+ if (@preg_match('/^nodiff\((.+)\)$/', $name, $matches)) {
list($results) = $this->execxLocal(
'log --template %s --rev %s',
"{node}\1{desc}\2",
sprintf('ancestor(.,%s)::.^', $matches[1]));
- $results = array_reverse(explode("\2", trim($results)));
+ $results = array_reverse(@explode("\2", trim($results)));
foreach ($results as $result) {
if (empty($result)) {
continue;
}
- list($node, $desc) = explode("\1", $result, 2);
+ list($node, $desc) = @explode("\1", $result, 2);
$message = ArcanistDifferentialCommitMessage::newFromRawCorpus(
$desc);
@@ -864,8 +864,8 @@
$revision = null;
list($err, $raw_info) = $this->execManualLocal('svn info');
if (!$err) {
- foreach (explode("\n", trim($raw_info)) as $line) {
- list($key, $value) = explode(': ', $line, 2);
+ foreach (@explode("\n", trim($raw_info)) as $line) {
+ list($key, $value) = @explode(': ', $line, 2);
switch ($key) {
case 'URL':
$info['base_path'] = $value;
@@ -910,7 +910,7 @@
list($stdout) = $this->execxLocal('paths default');
$stdout = trim($stdout);
- if (strlen($stdout)) {
+ if (@strlen($stdout)) {
return $stdout;
}
@@ -1049,7 +1049,7 @@
$hashes = array();
foreach ($lines as $line) {
- if (!strlen(trim($line))) {
+ if (!@strlen(trim($line))) {
continue;
}
$hashes[] = $line;
diff --git a/src/repository/api/ArcanistRepositoryAPI.php b/src/repository/api/ArcanistRepositoryAPI.php
--- a/src/repository/api/ArcanistRepositoryAPI.php
+++ b/src/repository/api/ArcanistRepositoryAPI.php
@@ -804,7 +804,7 @@
}
final public function getDisplayHash($hash) {
- return substr($hash, 0, 12);
+ return @substr($hash, 0, 12);
}
diff --git a/src/repository/api/ArcanistSubversionAPI.php b/src/repository/api/ArcanistSubversionAPI.php
--- a/src/repository/api/ArcanistSubversionAPI.php
+++ b/src/repository/api/ArcanistSubversionAPI.php
@@ -127,7 +127,7 @@
foreach ($files as $path => $mask) {
foreach ($externals as $external) {
- if (!strncmp($path.'/', $external.'/', strlen($external) + 1)) {
+ if (!strncmp($path.'/', $external.'/', @strlen($external) + 1)) {
$files[$path] |= self::FLAG_EXTERNALS;
}
}
@@ -240,10 +240,10 @@
public function getBranchName() {
$info = $this->getSVNInfo('/');
$repo_root = idx($info, 'Repository Root');
- $repo_root_length = strlen($repo_root);
+ $repo_root_length = @strlen($repo_root);
$url = idx($info, 'URL');
- if (substr($url, 0, $repo_root_length) == $repo_root) {
- return substr($url, $repo_root_length);
+ if (@substr($url, 0, $repo_root_length) == $repo_root) {
+ return @substr($url, $repo_root_length);
}
return 'svn';
}
@@ -355,7 +355,7 @@
$result = array();
foreach ($patterns as $pattern) {
$matches = null;
- if (preg_match($pattern, $stdout, $matches)) {
+ if (@preg_match($pattern, $stdout, $matches)) {
$result[$matches[1]] = $matches[2];
}
}
@@ -400,7 +400,7 @@
// files. We just fix this inline since it's pretty unambiguous.
// TODO: Move this to configuration?
$matches = null;
- if (preg_match('/\.(gif|png|jpe?g|swf|pdf|ico)$/i', $path, $matches)) {
+ if (@preg_match('/\.(gif|png|jpe?g|swf|pdf|ico)$/i', $path, $matches)) {
// Check if the file is deleted first; SVN will complain if we try to
// get properties of a deleted file.
if ($status & parent::FLAG_DELETED) {
@@ -505,7 +505,7 @@
}
$data = Filesystem::readFile($full_path);
- $lines = explode("\n", $data);
+ $lines = @explode("\n", $data);
$len = count($lines);
foreach ($lines as $key => $line) {
$lines[$key] = ' '.$line;
@@ -533,7 +533,7 @@
public function getChangedFiles($since_commit) {
$url = '';
$match = null;
- if (preg_match('/(.*)@(.*)/', $since_commit, $match)) {
+ if (@preg_match('/(.*)@(.*)/', $since_commit, $match)) {
list(, $url, $since_commit) = $match;
}
// TODO: Handle paths with newlines.
@@ -552,7 +552,7 @@
public function filterFiles($path) {
// NOTE: SVN uses '/' also on Windows.
- if ($path == '' || substr($path, -1) == '/') {
+ if ($path == '' || @substr($path, -1) == '/') {
return null;
}
return $path;
@@ -564,14 +564,14 @@
list($stdout) = $this->execxLocal('blame %s', $path);
$stdout = trim($stdout);
- if (!strlen($stdout)) {
+ if (!@strlen($stdout)) {
// Empty file.
return $blame;
}
- foreach (explode("\n", $stdout) as $line) {
+ foreach (@explode("\n", $stdout) as $line) {
$m = array();
- if (!preg_match('/^\s*(\d+)\s+(\S+)/', $line, $m)) {
+ if (!@preg_match('/^\s*(\d+)\s+(\S+)/', $line, $m)) {
throw new Exception(pht("Bad blame? `%s'", $line));
}
$revision = $m[1];
@@ -678,7 +678,7 @@
// where ".@" means "fail with an error" instead of ". at the working copy
// revision", so avoid escaping "." into ".@".
- if (strpos($file, '@') !== false) {
+ if (@strpos($file, '@') !== false) {
$file = $file.'@';
}
diff --git a/src/repository/graph/query/ArcanistGitCommitGraphQuery.php b/src/repository/graph/query/ArcanistGitCommitGraphQuery.php
--- a/src/repository/graph/query/ArcanistGitCommitGraphQuery.php
+++ b/src/repository/graph/query/ArcanistGitCommitGraphQuery.php
@@ -151,7 +151,7 @@
continue;
}
- $fields = explode("\2", $line);
+ $fields = @explode("\2", $line);
if (count($fields) !== 5) {
throw new Exception(
@@ -175,8 +175,8 @@
->setCommitMessage($message)
->setCommitEpoch((int)$commit_epoch);
- if (strlen($parents)) {
- $parents = explode(' ', $parents);
+ if (@strlen($parents)) {
+ $parents = @explode(' ', $parents);
$parent_nodes = array();
foreach ($parents as $parent) {
diff --git a/src/repository/graph/query/ArcanistMercurialCommitGraphQuery.php b/src/repository/graph/query/ArcanistMercurialCommitGraphQuery.php
--- a/src/repository/graph/query/ArcanistMercurialCommitGraphQuery.php
+++ b/src/repository/graph/query/ArcanistMercurialCommitGraphQuery.php
@@ -138,7 +138,7 @@
continue;
}
- $fields = explode("\2", $line);
+ $fields = @explode("\2", $line);
if (count($fields) !== 5) {
throw new Exception(
@@ -160,8 +160,8 @@
->setCommitMessage($message)
->setCommitEpoch((int)strtotime($commit_epoch));
- if (strlen($parents)) {
- $parents = explode(' ', $parents);
+ if (@strlen($parents)) {
+ $parents = @explode(' ', $parents);
$parent_nodes = array();
foreach ($parents as $parent) {
if ($parent === $no_parent) {
diff --git a/src/repository/graph/query/ArcanistSimpleCommitGraphQuery.php b/src/repository/graph/query/ArcanistSimpleCommitGraphQuery.php
--- a/src/repository/graph/query/ArcanistSimpleCommitGraphQuery.php
+++ b/src/repository/graph/query/ArcanistSimpleCommitGraphQuery.php
@@ -21,7 +21,7 @@
$edges = preg_split('(\s+)', trim($corpus));
foreach ($edges as $edge) {
$matches = null;
- $ok = preg_match('(^(?P<parent>\S+)>(?P<child>\S+)\z)', $edge, $matches);
+ $ok = @preg_match('(^(?P<parent>\S+)>(?P<child>\S+)\z)', $edge, $matches);
if (!$ok) {
throw new Exception(
pht(
diff --git a/src/repository/graph/view/ArcanistCommitGraphSetView.php b/src/repository/graph/view/ArcanistCommitGraphSetView.php
--- a/src/repository/graph/view/ArcanistCommitGraphSetView.php
+++ b/src/repository/graph/view/ArcanistCommitGraphSetView.php
@@ -126,7 +126,7 @@
$merge_strings = array();
foreach ($revision_refs as $revision_ref) {
$summary = $revision_ref->getName();
- $merge_key = substr($summary, 0, 32);
+ $merge_key = @substr($summary, 0, 32);
$merge_key = phutil_utf8_strtolower($merge_key);
$merge_strings[$merge_key][] = $revision_ref;
@@ -140,7 +140,7 @@
if (count($revision_refs) === 1) {
$merge_with = head($revision_refs);
} else {
- $merge_key = substr($summary, 0, 32);
+ $merge_key = @substr($summary, 0, 32);
$merge_key = phutil_utf8_strtolower($merge_key);
if (isset($merge_strings[$merge_key])) {
$merge_refs = $merge_strings[$merge_key];
@@ -263,7 +263,7 @@
$commit_hash = $commit_ref->getCommitHash();
$commit_hash = tsprintf(
'%s',
- substr($commit_hash, 0, 7));
+ @substr($commit_hash, 0, 7));
$commit_label = $commit_hash;
} else {
@@ -271,8 +271,8 @@
$max = last($commit_refs);
$commit_label = tsprintf(
'%s..%s',
- substr($min->getCommitHash(), 0, 7),
- substr($max->getCommitHash(), 0, 7));
+ @substr($min->getCommitHash(), 0, 7),
+ @substr($max->getCommitHash(), 0, 7));
}
$member_views = $this->getMemberViews();
@@ -426,7 +426,7 @@
$api = $this->getRepositoryAPI();
$hash = $commit_ref->getCommitHash();
- $hash = substr($hash, 0, 7);
+ $hash = @substr($hash, 0, 7);
return tsprintf('%s', $hash);
}
diff --git a/src/repository/marker/ArcanistGitRepositoryMarkerQuery.php b/src/repository/marker/ArcanistGitRepositoryMarkerQuery.php
--- a/src/repository/marker/ArcanistGitRepositoryMarkerQuery.php
+++ b/src/repository/marker/ArcanistGitRepositoryMarkerQuery.php
@@ -21,10 +21,10 @@
$expect_count = count($field_list);
$branch_prefix = 'refs/heads/';
- $branch_length = strlen($branch_prefix);
+ $branch_length = @strlen($branch_prefix);
$remote_prefix = 'refs/remotes/';
- $remote_length = strlen($remote_prefix);
+ $remote_length = @strlen($remote_prefix);
list($stdout) = $api->newFuture(
'for-each-ref --format %s -- refs/',
@@ -32,14 +32,14 @@
$markers = array();
- $lines = explode("\2", $stdout);
+ $lines = @explode("\2", $stdout);
foreach ($lines as $line) {
$line = trim($line);
- if (!strlen($line)) {
+ if (!@strlen($line)) {
continue;
}
- $fields = explode("\1", $line, $expect_count);
+ $fields = @explode("\1", $line, $expect_count);
$actual_count = count($fields);
if ($actual_count !== $expect_count) {
throw new Exception(
@@ -57,13 +57,13 @@
if (!strncmp($ref, $branch_prefix, $branch_length)) {
$type = ArcanistMarkerRef::TYPE_BRANCH;
- $name = substr($ref, $branch_length);
+ $name = @substr($ref, $branch_length);
} else if (!strncmp($ref, $remote_prefix, $remote_length)) {
// This isn't entirely correct: the ref may be a tag, etc.
$type = ArcanistMarkerRef::TYPE_BRANCH;
- $label = substr($ref, $remote_length);
- $parts = explode('/', $label, 2);
+ $label = @substr($ref, $remote_length);
+ $parts = @explode('/', $label, 2);
$remote_name = $parts[0];
$name = $parts[1];
@@ -85,7 +85,7 @@
$marker->setRemoteName($remote_name);
}
- if (strlen($dst_hash)) {
+ if (@strlen($dst_hash)) {
$commit_hash = $dst_hash;
} else {
$commit_hash = $hash;
@@ -129,7 +129,7 @@
}
$matches = null;
- if (!preg_match('(^refs/heads/(.*)\z)', trim($stdout), $matches)) {
+ if (!@preg_match('(^refs/heads/(.*)\z)', trim($stdout), $matches)) {
return null;
}
@@ -148,7 +148,7 @@
list($stdout) = $future->resolve();
$branch_prefix = 'refs/heads/';
- $branch_length = strlen($branch_prefix);
+ $branch_length = @strlen($branch_prefix);
$pattern = '(^(?P<hash>\S+)\t(?P<ref>\S+)\z)';
$markers = array();
@@ -156,7 +156,7 @@
$lines = phutil_split_lines($stdout, false);
foreach ($lines as $line) {
$matches = null;
- $ok = preg_match($pattern, $line, $matches);
+ $ok = @preg_match($pattern, $line, $matches);
if (!$ok) {
throw new Exception(
pht(
@@ -169,7 +169,7 @@
if (!strncmp($ref, $branch_prefix, $branch_length)) {
$type = ArcanistMarkerRef::TYPE_BRANCH;
- $name = substr($ref, $branch_length);
+ $name = @substr($ref, $branch_length);
} else {
// For now, discard other refs.
continue;
diff --git a/src/repository/parser/ArcanistMercurialParser.php b/src/repository/parser/ArcanistMercurialParser.php
--- a/src/repository/parser/ArcanistMercurialParser.php
+++ b/src/repository/parser/ArcanistMercurialParser.php
@@ -25,12 +25,12 @@
$result = array();
$stdout = trim($stdout);
- if (!strlen($stdout)) {
+ if (!@strlen($stdout)) {
return $result;
}
$last_path = null;
- $lines = explode("\n", $stdout);
+ $lines = @explode("\n", $stdout);
foreach ($lines as $line) {
$flags = 0;
if ($line[1] !== ' ') {
@@ -40,7 +40,7 @@
$line));
}
$code = $line[0];
- $path = substr($line, 2);
+ $path = @substr($line, 2);
switch ($code) {
case 'A':
$flags |= ArcanistRepositoryAPI::FLAG_ADDED;
@@ -118,27 +118,27 @@
$result = array();
$stdout = trim($stdout);
- if (!strlen($stdout)) {
+ if (!@strlen($stdout)) {
return $result;
}
- $chunks = explode("\n\n", $stdout);
+ $chunks = @explode("\n\n", $stdout);
foreach ($chunks as $chunk) {
$commit = array();
- $lines = explode("\n", $chunk);
+ $lines = @explode("\n", $chunk);
foreach ($lines as $line) {
- if (preg_match('/^(comparing with|searching for changes)/', $line)) {
+ if (@preg_match('/^(comparing with|searching for changes)/', $line)) {
// These are sent to stdout when you run "hg outgoing" although the
// format is otherwise identical to "hg log".
continue;
}
- if (preg_match('/^remote:/', $line)) {
+ if (@preg_match('/^remote:/', $line)) {
// This indicates remote error in "hg outgoing".
continue;
}
- list($name, $value) = explode(':', $line, 2);
+ list($name, $value) = @explode(':', $line, 2);
$value = trim($value);
switch ($name) {
case 'user':
@@ -151,7 +151,7 @@
$commit['summary'] = $value;
break;
case 'changeset':
- list($local, $rev) = explode(':', $value, 2);
+ list($local, $rev) = @explode(':', $value, 2);
$commit['local'] = $local;
$commit['rev'] = $rev;
break;
@@ -159,7 +159,7 @@
if (empty($commit['parents'])) {
$commit['parents'] = array();
}
- list($local, $rev) = explode(':', $value, 2);
+ list($local, $rev) = @explode(':', $value, 2);
$commit['parents'][] = array(
'local' => $local,
'rev' => $rev,
@@ -200,12 +200,12 @@
*/
public static function parseMercurialBranches($stdout) {
$stdout = rtrim($stdout, "\n");
- if (!strlen($stdout)) {
+ if (!@strlen($stdout)) {
// No branches; commonly, this occurs in a newly initialized repository.
return array();
}
- $lines = explode("\n", $stdout);
+ $lines = @explode("\n", $stdout);
$branches = array();
foreach ($lines as $line) {
@@ -222,7 +222,7 @@
// See the unit tests for more examples.
$regexp = '/^(\S+(?:\s+\S+)*)\s+(\d+):([a-f0-9]+)(\s+\\(inactive\\))?$/';
- if (!preg_match($regexp, $line, $matches)) {
+ if (!@preg_match($regexp, $line, $matches)) {
throw new Exception(
pht(
"Failed to parse '%s' output: %s",
diff --git a/src/repository/raw/ArcanistGitRawCommit.php b/src/repository/raw/ArcanistGitRawCommit.php
--- a/src/repository/raw/ArcanistGitRawCommit.php
+++ b/src/repository/raw/ArcanistGitRawCommit.php
@@ -33,7 +33,7 @@
}
$matches = null;
- $ok = preg_match($pattern, $line, $matches);
+ $ok = @preg_match($pattern, $line, $matches);
if (!$ok) {
throw new Exception(
pht(
diff --git a/src/repository/remote/ArcanistGitRepositoryRemoteQuery.php b/src/repository/remote/ArcanistGitRepositoryRemoteQuery.php
--- a/src/repository/remote/ArcanistGitRepositoryRemoteQuery.php
+++ b/src/repository/remote/ArcanistGitRepositoryRemoteQuery.php
@@ -24,7 +24,7 @@
$lines = phutil_split_lines($lines, false);
foreach ($lines as $line) {
$matches = null;
- if (!preg_match($pattern, $line, $matches)) {
+ if (!@preg_match($pattern, $line, $matches)) {
throw new Exception(
pht(
'Failed to match remote pattern against line "%s".',
diff --git a/src/repository/remote/ArcanistMercurialRepositoryRemoteQuery.php b/src/repository/remote/ArcanistMercurialRepositoryRemoteQuery.php
--- a/src/repository/remote/ArcanistMercurialRepositoryRemoteQuery.php
+++ b/src/repository/remote/ArcanistMercurialRepositoryRemoteQuery.php
@@ -16,7 +16,7 @@
$lines = phutil_split_lines($lines, false);
foreach ($lines as $line) {
$matches = null;
- if (!preg_match($pattern, $line, $matches)) {
+ if (!@preg_match($pattern, $line, $matches)) {
throw new Exception(
pht(
'Failed to match remote pattern against line "%s".',
diff --git a/src/repository/remote/ArcanistRepositoryURINormalizer.php b/src/repository/remote/ArcanistRepositoryURINormalizer.php
--- a/src/repository/remote/ArcanistRepositoryURINormalizer.php
+++ b/src/repository/remote/ArcanistRepositoryURINormalizer.php
@@ -127,7 +127,7 @@
// example.
$matches = null;
- if (preg_match('@^(diffusion/(?:[A-Z]+|\d+))@', $path, $matches)) {
+ if (@preg_match('@^(diffusion/(?:[A-Z]+|\d+))@', $path, $matches)) {
$path = $matches[1];
}
@@ -140,7 +140,7 @@
$uri = new PhutilURI($this->uri);
$domain = $uri->getDomain();
- if (!strlen($domain)) {
+ if (!@strlen($domain)) {
return '<void>';
}
diff --git a/src/repository/state/ArcanistGitLocalState.php b/src/repository/state/ArcanistGitLocalState.php
--- a/src/repository/state/ArcanistGitLocalState.php
+++ b/src/repository/state/ArcanistGitLocalState.php
@@ -160,7 +160,7 @@
}
private function getDisplayStashRef($stash_ref) {
- return substr($stash_ref, 0, 12);
+ return @substr($stash_ref, 0, 12);
}
}
diff --git a/src/runtime/ArcanistRuntime.php b/src/runtime/ArcanistRuntime.php
--- a/src/runtime/ArcanistRuntime.php
+++ b/src/runtime/ArcanistRuntime.php
@@ -197,7 +197,7 @@
// TODO: This is very, very hacky; we're trying to let errors like
// "you passed the wrong arguments" through but fall back to classic
// mode if the workflow itself doesn't exist.
- if (!preg_match('/invalid command/i', $usage_exception->getMessage())) {
+ if (!@preg_match('/invalid command/i', $usage_exception->getMessage())) {
throw $usage_exception;
}
@@ -258,14 +258,14 @@
phpinfo(INFO_GENERAL);
$info = ob_get_clean();
$matches = null;
- if (preg_match('/^Configure Command =>\s*(.*?)$/m', $info, $matches)) {
+ if (@preg_match('/^Configure Command =>\s*(.*?)$/m', $info, $matches)) {
$config = $matches[1];
}
}
list($what, $which) = $resolution;
- if ($what == 'flag' && strpos($config, $which) !== false) {
+ if ($what == 'flag' && @strpos($config, $which) !== false) {
$show_config = true;
$problems[] = sprintf(
'The build of PHP you are running was compiled with the configure '.
diff --git a/src/serviceprofiler/PhutilServiceProfiler.php b/src/serviceprofiler/PhutilServiceProfiler.php
--- a/src/serviceprofiler/PhutilServiceProfiler.php
+++ b/src/serviceprofiler/PhutilServiceProfiler.php
@@ -108,12 +108,12 @@
$desc = $data['database'];
break;
case 'query':
- $desc = substr($data['query'], 0, 512);
+ $desc = @substr($data['query'], 0, 512);
break;
case 'multi-query':
$desc = array();
foreach ($data['queries'] as $query) {
- $desc[] = substr($query, 0, 256);
+ $desc[] = @substr($query, 0, 256);
}
$desc = implode('; ', $desc);
break;
@@ -137,7 +137,7 @@
$uri = phutil_censor_credentials($data['uri']);
- if (strlen($proxy)) {
+ if (@strlen($proxy)) {
$desc = "{$proxy} >> {$uri}";
} else {
$desc = $uri;
diff --git a/src/symbols/PhutilClassMapQuery.php b/src/symbols/PhutilClassMapQuery.php
--- a/src/symbols/PhutilClassMapQuery.php
+++ b/src/symbols/PhutilClassMapQuery.php
@@ -209,7 +209,7 @@
*/
private function loadMap() {
$ancestor = $this->ancestorClass;
- if (!strlen($ancestor)) {
+ if (!@strlen($ancestor)) {
throw new PhutilInvalidStateException('setAncestorClass');
}
@@ -226,8 +226,8 @@
$unique = $this->uniqueMethod;
$sort = $this->sortMethod;
- if (strlen($expand)) {
- if (!strlen($unique)) {
+ if (@strlen($expand)) {
+ if (!@strlen($unique)) {
throw new Exception(
pht(
'Trying to execute a class map query for descendants of class '.
@@ -245,7 +245,7 @@
->loadObjects();
// Apply the "expand" mechanism, if it is configured.
- if (strlen($expand)) {
+ if (@strlen($expand)) {
$list = array();
foreach ($objects as $object) {
foreach (call_user_func(array($object, $expand)) as $instance) {
@@ -257,7 +257,7 @@
}
// Apply the "unique" mechanism, if it is configured.
- if (strlen($unique)) {
+ if (@strlen($unique)) {
$map = array();
foreach ($list as $object) {
$key = call_user_func(array($object, $unique));
@@ -287,12 +287,12 @@
}
// Apply the "filter" mechanism, if it is configured.
- if (strlen($filter)) {
+ if (@strlen($filter)) {
$map = mfilter($map, $filter);
}
// Apply the "sort" mechanism, if it is configured.
- if (strlen($sort)) {
+ if (@strlen($sort)) {
if ($map) {
// The "sort" method may return scalars (which we want to sort with
// "msort()"), or may return PhutilSortVector objects (which we want
diff --git a/src/symbols/PhutilSymbolLoader.php b/src/symbols/PhutilSymbolLoader.php
--- a/src/symbols/PhutilSymbolLoader.php
+++ b/src/symbols/PhutilSymbolLoader.php
@@ -235,7 +235,7 @@
}
if ($this->pathPrefix) {
- $len = strlen($this->pathPrefix);
+ $len = @strlen($this->pathPrefix);
foreach ($filtered_map as $name => $where) {
if (strncmp($where, $this->pathPrefix, $len) !== 0) {
unset($filtered_map[$name]);
diff --git a/src/toolset/ArcanistAlias.php b/src/toolset/ArcanistAlias.php
--- a/src/toolset/ArcanistAlias.php
+++ b/src/toolset/ArcanistAlias.php
@@ -120,7 +120,7 @@
}
$head = head($command);
- return preg_match('/^!/', $head);
+ return @preg_match('/^!/', $head);
}
public function getStorageDictionary() {
diff --git a/src/toolset/ArcanistAliasEngine.php b/src/toolset/ArcanistAliasEngine.php
--- a/src/toolset/ArcanistAliasEngine.php
+++ b/src/toolset/ArcanistAliasEngine.php
@@ -203,7 +203,7 @@
$alias_command = array_shift($alias_argv);
if ($alias->isShellCommandAlias()) {
- $shell_command = substr($alias_command, 1);
+ $shell_command = @substr($alias_command, 1);
$shell_argv = array_merge(
array($shell_command),
diff --git a/src/toolset/ArcanistPrompt.php b/src/toolset/ArcanistPrompt.php
--- a/src/toolset/ArcanistPrompt.php
+++ b/src/toolset/ArcanistPrompt.php
@@ -63,7 +63,7 @@
}
$query = $this->getQuery();
- if (!strlen($query)) {
+ if (!@strlen($query)) {
throw new Exception(
pht(
'Prompt ("%s") has no query text!',
@@ -143,14 +143,14 @@
pht('fread() from stdin failed with an error.'));
}
- if (!strlen($bytes)) {
+ if (!@strlen($bytes)) {
break;
}
$response .= $bytes;
}
- if (!strlen($response)) {
+ if (!@strlen($response)) {
continue;
}
@@ -159,7 +159,7 @@
}
$response = trim($response);
- if (!strlen($response)) {
+ if (!@strlen($response)) {
$response = $default;
}
}
@@ -167,7 +167,7 @@
$save_scope = null;
if (!$is_saved) {
$matches = null;
- if (preg_match('(^(.*)([!*])\z)', $response, $matches)) {
+ if (@preg_match('(^(.*)([!*])\z)', $response, $matches)) {
$response = $matches[1];
if ($matches[2] === '*') {
diff --git a/src/toolset/workflow/ArcanistShellCompleteWorkflow.php b/src/toolset/workflow/ArcanistShellCompleteWorkflow.php
--- a/src/toolset/workflow/ArcanistShellCompleteWorkflow.php
+++ b/src/toolset/workflow/ArcanistShellCompleteWorkflow.php
@@ -92,7 +92,7 @@
$argv = $this->getArgument('argv');
$is_generate = $this->getArgument('generate');
- $is_shell = (bool)strlen($this->getArgument('shell'));
+ $is_shell = (bool)@strlen($this->getArgument('shell'));
$is_current = $this->getArgument('current');
if ($argv) {
@@ -194,7 +194,7 @@
$file = $spec['file'];
$home = getenv('HOME');
- if (!strlen($home)) {
+ if (!@strlen($home)) {
throw new PhutilArgumentUsageException(
pht(
'The "HOME" environment variable is not defined, so this workflow '.
@@ -218,7 +218,7 @@
$this->getShellPath($spec['source']));
$matches = null;
- $replace = preg_match(
+ $replace = @preg_match(
'/(\s*\n)?[^\n]+# arcanist-shell-complete\s*(\n\s*)?/',
$data,
$matches,
@@ -234,7 +234,7 @@
if ($replace) {
$replace_pos = $matches[0][1];
$replace_line = $matches[0][0];
- $replace_len = strlen($replace_line);
+ $replace_len = @strlen($replace_line);
$replace_display = trim($replace_line);
if ($replace_pos === 0) {
@@ -343,7 +343,7 @@
pht('Detecting current shell...'));
$shell_env = getenv('SHELL');
- if (!strlen($shell_env)) {
+ if (!@strlen($shell_env)) {
$log->writeWarning(
pht('SHELL'),
pht(
@@ -551,7 +551,7 @@
$argument = null;
$prev = idx($argv, $pos - 1, null);
if (!strncmp($prev, '--', 2)) {
- $prev = substr($prev, 2);
+ $prev = @substr($prev, 2);
$argument = idx($arguments, $prev);
}
@@ -559,7 +559,7 @@
// a parameterized argument. If it is, the next argument should be a
// parameter.
- if ($argument && strlen($argument->getParameter())) {
+ if ($argument && @strlen($argument->getParameter())) {
if ($argument->getIsPathArgument()) {
return $this->suggestPaths($current);
} else {
@@ -590,7 +590,7 @@
// READ<tab>" should autocomplete a file, and "arc lint <tab>" should
// suggest files in the current directory.
- if (!strlen($current) || !$matches) {
+ if (!@strlen($current) || !$matches) {
$try_paths = true;
} else {
$try_paths = false;
@@ -641,9 +641,9 @@
private function getMatches(array $candidates, $prefix) {
$matches = array();
- if (strlen($prefix)) {
+ if (@strlen($prefix)) {
foreach ($candidates as $possible) {
- if (!strncmp($possible, $prefix, strlen($prefix))) {
+ if (!strncmp($possible, $prefix, @strlen($prefix))) {
$matches[] = $possible;
}
}
@@ -651,7 +651,7 @@
// If we matched nothing, try a case-insensitive match.
if (!$matches) {
foreach ($candidates as $possible) {
- if (!strncasecmp($possible, $prefix, strlen($prefix))) {
+ if (!strncasecmp($possible, $prefix, @strlen($prefix))) {
$matches[] = $possible;
}
}
diff --git a/src/toolset/workflow/ArcanistVersionWorkflow.php b/src/toolset/workflow/ArcanistVersionWorkflow.php
--- a/src/toolset/workflow/ArcanistVersionWorkflow.php
+++ b/src/toolset/workflow/ArcanistVersionWorkflow.php
@@ -67,7 +67,7 @@
'%ct%x01%H');
$commit = trim($commit);
- list($timestamp, $commit) = explode("\1", $commit);
+ list($timestamp, $commit) = @explode("\1", $commit);
$console->writeOut(
"%s %s (%s)\n",
diff --git a/src/unit/ArcanistUnitTestResult.php b/src/unit/ArcanistUnitTestResult.php
--- a/src/unit/ArcanistUnitTestResult.php
+++ b/src/unit/ArcanistUnitTestResult.php
@@ -31,7 +31,7 @@
public function setName($name) {
$maximum_bytes = 255;
- $actual_bytes = strlen($name);
+ $actual_bytes = @strlen($name);
if ($actual_bytes > $maximum_bytes) {
throw new Exception(
@@ -142,8 +142,8 @@
$base = reset($coverage);
foreach ($coverage as $more_coverage) {
- $base_len = strlen($base);
- $more_len = strlen($more_coverage);
+ $base_len = @strlen($base);
+ $more_len = @strlen($more_coverage);
$len = min($base_len, $more_len);
for ($ii = 0; $ii < $len; $ii++) {
@@ -154,7 +154,7 @@
// If a secondary report has more data, copy all of it over.
if ($more_len > $base_len) {
- $base .= substr($more_coverage, $base_len);
+ $base .= @substr($more_coverage, $base_len);
}
}
diff --git a/src/unit/engine/ArcanistConfigurationDrivenUnitTestEngine.php b/src/unit/engine/ArcanistConfigurationDrivenUnitTestEngine.php
--- a/src/unit/engine/ArcanistConfigurationDrivenUnitTestEngine.php
+++ b/src/unit/engine/ArcanistConfigurationDrivenUnitTestEngine.php
@@ -192,7 +192,7 @@
$keep = true;
} else {
foreach ($include as $rule) {
- if (preg_match($rule, $path)) {
+ if (@preg_match($rule, $path)) {
$keep = true;
break;
}
@@ -205,7 +205,7 @@
if ($exclude) {
foreach ($exclude as $rule) {
- if (preg_match($rule, $path)) {
+ if (@preg_match($rule, $path)) {
continue 2;
}
}
diff --git a/src/unit/engine/CSharpToolsTestEngine.php b/src/unit/engine/CSharpToolsTestEngine.php
--- a/src/unit/engine/CSharpToolsTestEngine.php
+++ b/src/unit/engine/CSharpToolsTestEngine.php
@@ -68,7 +68,7 @@
}
}
if ($this->matchRegex !== null) {
- if (preg_match($this->matchRegex, $file) === 1) {
+ if (@preg_match($this->matchRegex, $file) === 1) {
return true;
} else {
return false;
@@ -117,7 +117,7 @@
$assembly_dir = dirname($test_assembly);
$assemblies_to_instrument = array();
foreach (Filesystem::listDirectory($assembly_dir) as $file) {
- if (substr($file, -4) == '.dll' || substr($file, -4) == '.exe') {
+ if (@substr($file, -4) == '.dll' || @substr($file, -4) == '.exe') {
if ($this->assemblyShouldBeInstrumented($file)) {
$assemblies_to_instrument[] = $assembly_dir.DIRECTORY_SEPARATOR.$file;
}
@@ -235,7 +235,7 @@
foreach ($instrumented as $instrument) {
$absolute_file = $instrument['file'];
- $relative_file = substr($absolute_file, strlen($this->projectRoot) + 1);
+ $relative_file = @substr($absolute_file, @strlen($this->projectRoot) + 1);
if (!in_array($relative_file, $files)) {
$files[] = $relative_file;
}
diff --git a/src/unit/engine/NoseTestEngine.php b/src/unit/engine/NoseTestEngine.php
--- a/src/unit/engine/NoseTestEngine.php
+++ b/src/unit/engine/NoseTestEngine.php
@@ -127,7 +127,7 @@
public function readCoverage($cover_file, $source_path) {
$coverage_xml = Filesystem::readFile($cover_file);
- if (strlen($coverage_xml) < 1) {
+ if (@strlen($coverage_xml) < 1) {
return array();
}
$coverage_dom = new DOMDocument();
diff --git a/src/unit/engine/PhpunitTestEngine.php b/src/unit/engine/PhpunitTestEngine.php
--- a/src/unit/engine/PhpunitTestEngine.php
+++ b/src/unit/engine/PhpunitTestEngine.php
@@ -25,11 +25,11 @@
// Not sure if it would make sense to go further if
// it is not a .php file
- if (substr($path, -4) != '.php') {
+ if (@substr($path, -4) != '.php') {
continue;
}
- if (substr($path, -8) == 'Test.php') {
+ if (@substr($path, -8) == 'Test.php') {
// Looks like a valid test file name.
$this->affectedTests[$path] = $path;
continue;
@@ -128,7 +128,7 @@
$file = basename($path);
$possible_files = array(
$file,
- substr($file, 0, -4).'Test.php',
+ @substr($file, 0, -4).'Test.php',
);
$search = self::getSearchLocationsForTests($path);
@@ -219,7 +219,7 @@
// Try replacing each directory component with 'tests/'.
$parts = trim($dir, DIRECTORY_SEPARATOR);
- $parts = explode(DIRECTORY_SEPARATOR, $parts);
+ $parts = @explode(DIRECTORY_SEPARATOR, $parts);
foreach (array_reverse(array_keys($parts)) as $key) {
foreach ($test_dir_names as $test_dir_name) {
$try = $parts;
diff --git a/src/unit/engine/PhutilUnitTestEngine.php b/src/unit/engine/PhutilUnitTestEngine.php
--- a/src/unit/engine/PhutilUnitTestEngine.php
+++ b/src/unit/engine/PhutilUnitTestEngine.php
@@ -90,7 +90,7 @@
$run_tests = array();
foreach ($symbols as $symbol) {
- if (!preg_match('@(?:^|/)__tests__/@', $symbol['where'])) {
+ if (!@preg_match('@(?:^|/)__tests__/@', $symbol['where'])) {
continue;
}
@@ -193,7 +193,7 @@
continue;
}
- if (is_file($path) && preg_match('@(?:^|/)__tests__/@', $path)) {
+ if (is_file($path) && @preg_match('@(?:^|/)__tests__/@', $path)) {
$paths[$library_name.':'.$library_path] = array(
'library' => $library_name,
'path' => $library_path,
diff --git a/src/unit/engine/PytestTestEngine.php b/src/unit/engine/PytestTestEngine.php
--- a/src/unit/engine/PytestTestEngine.php
+++ b/src/unit/engine/PytestTestEngine.php
@@ -79,7 +79,7 @@
foreach ($classes as $class) {
// filename is actually python module path with ".py" at the end,
// e.g.: tornado.web.py
- $relative_path = explode('.', $class->getAttribute('filename'));
+ $relative_path = @explode('.', $class->getAttribute('filename'));
array_pop($relative_path);
$relative_path = implode('/', $relative_path);
diff --git a/src/unit/engine/XUnitTestEngine.php b/src/unit/engine/XUnitTestEngine.php
--- a/src/unit/engine/XUnitTestEngine.php
+++ b/src/unit/engine/XUnitTestEngine.php
@@ -123,7 +123,7 @@
foreach ($this->discoveryRules as $regex => $targets) {
$regex = str_replace('/', '\\/', $regex);
foreach ($paths as $path) {
- if (preg_match('/'.$regex.'/', $path) === 1) {
+ if (@preg_match('/'.$regex.'/', $path) === 1) {
foreach ($targets as $target) {
// Index 0 is the test project (.csproj file)
// Index 1 is the output assembly (.dll file)
@@ -229,8 +229,8 @@
$platform = phutil_is_windows() ? 'Windows' : 'Linux';
$files = Filesystem::listDirectory($this->projectRoot);
foreach ($files as $file) {
- if (strtolower(substr($file, -4)) == '.sln') {
- $parts = explode('.', $file);
+ if (@strtolower(@substr($file, -4)) == '.sln') {
+ $parts = @explode('.', $file);
$platform = $parts[count($parts) - 2];
break;
}
diff --git a/src/unit/engine/phutil/PhutilTestCase.php b/src/unit/engine/phutil/PhutilTestCase.php
--- a/src/unit/engine/phutil/PhutilTestCase.php
+++ b/src/unit/engine/phutil/PhutilTestCase.php
@@ -111,7 +111,7 @@
$output .= "\n";
- if (strpos($expect, "\n") === false && strpos($result, "\n") === false) {
+ if (@strpos($expect, "\n") === false && @strpos($result, "\n") === false) {
$output .= pht("Expected: %s\n Actual: %s", $expect, $result);
} else {
$output .= pht(
@@ -477,7 +477,7 @@
$this->willRunTests();
foreach ($methods as $method) {
$name = $method->getName();
- if (preg_match('/^test/', $name)) {
+ if (@preg_match('/^test/', $name)) {
$this->runningTest = $name;
$this->assertions = 0;
$this->testStartTime = microtime(true);
@@ -579,7 +579,7 @@
foreach ($result as $file => $report) {
$project_root = $this->getProjectRoot();
- if (strncmp($file, $project_root, strlen($project_root))) {
+ if (strncmp($file, $project_root, @strlen($project_root))) {
continue;
}
@@ -605,7 +605,7 @@
$str .= 'N'; // Not executable.
}
}
- $coverage[substr($file, strlen($project_root) + 1)] = $str;
+ $coverage[@substr($file, @strlen($project_root) + 1)] = $str;
}
// Only keep coverage information for files modified by the change. In
@@ -683,10 +683,10 @@
foreach (array_slice(debug_backtrace(), 1) as $location) {
$function = idx($location, 'function');
- if (!$seen && preg_match('/^assert[A-Z]/', $function)) {
+ if (!$seen && @preg_match('/^assert[A-Z]/', $function)) {
$seen = true;
$caller = $location;
- } else if ($seen && !preg_match('/^assert[A-Z]/', $function)) {
+ } else if ($seen && !@preg_match('/^assert[A-Z]/', $function)) {
$callee = $location;
break;
}
diff --git a/src/unit/parser/ArcanistGoTestResultParser.php b/src/unit/parser/ArcanistGoTestResultParser.php
--- a/src/unit/parser/ArcanistGoTestResultParser.php
+++ b/src/unit/parser/ArcanistGoTestResultParser.php
@@ -17,7 +17,7 @@
* @return array
*/
public function parseTestResults($path, $test_results) {
- $test_results = explode("\n", $test_results);
+ $test_results = @explode("\n", $test_results);
$results = array();
// We'll get our full test case name at the end and add it back in
@@ -30,7 +30,7 @@
if (strncmp($line, '--- PASS', 8) === 0) {
// We have a passing test
$meta = array();
- preg_match(
+ @preg_match(
'/^--- PASS: (?P<test_name>.+) \((?P<time>.+)\s*s(?:econds?)?\).*/',
$line,
$meta);
@@ -49,7 +49,7 @@
// We have a failing test
$reason = trim($test_results[$i + 1]);
$meta = array();
- preg_match(
+ @preg_match(
'/^--- FAIL: (?P<test_name>.+) \((?P<time>.+)\s*s(?:econds?)?\).*/',
$line,
$meta);
@@ -67,7 +67,7 @@
if (strncmp($line, 'ok', 2) === 0) {
$meta = array();
- preg_match(
+ @preg_match(
'/^ok[\s]+(?P<test_name>\w.*)[\s]+(?:(?P<time>.*)s|\(cached\))/',
$line,
$meta);
@@ -103,7 +103,7 @@
if (strncmp($line, "FAIL\t", 5) === 0) {
$meta = array();
- preg_match(
+ @preg_match(
'/^FAIL[\s\t]+(?P<test_name>\w.*)[\s\t]+.*/',
$line,
$meta);
diff --git a/src/unit/parser/ArcanistPhpunitTestResultParser.php b/src/unit/parser/ArcanistPhpunitTestResultParser.php
--- a/src/unit/parser/ArcanistPhpunitTestResultParser.php
+++ b/src/unit/parser/ArcanistPhpunitTestResultParser.php
@@ -60,10 +60,10 @@
idx($trace, 'line'));
}
} else if ('error' == idx($event, 'status')) {
- if (strpos(idx($event, 'message'), 'Skipped Test') !== false) {
+ if (@strpos(idx($event, 'message'), 'Skipped Test') !== false) {
$status = ArcanistUnitTestResult::RESULT_SKIP;
$user_data .= idx($event, 'message');
- } else if (strpos(
+ } else if (@strpos(
idx($event, 'message'),
'Incomplete Test') !== false) {
$status = ArcanistUnitTestResult::RESULT_SKIP;
@@ -152,8 +152,8 @@
// when the file wasn't actually part of the test. This filters out files
// with no coverage which helps give more accurate overall results.
if ($any_line_covered) {
- $len = strlen($this->projectRoot.DIRECTORY_SEPARATOR);
- $class_path = substr($class_path, $len);
+ $len = @strlen($this->projectRoot.DIRECTORY_SEPARATOR);
+ $class_path = @substr($class_path, $len);
$reports[$class_path] = $coverage;
}
}
diff --git a/src/unit/parser/ArcanistXUnitTestResultParser.php b/src/unit/parser/ArcanistXUnitTestResultParser.php
--- a/src/unit/parser/ArcanistXUnitTestResultParser.php
+++ b/src/unit/parser/ArcanistXUnitTestResultParser.php
@@ -14,7 +14,7 @@
* @return array ArcanistUnitTestResult
*/
public function parseTestResults($test_results) {
- if (!strlen($test_results)) {
+ if (!@strlen($test_results)) {
throw new Exception(
pht(
'%s argument to %s must not be empty',
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
@@ -12,7 +12,7 @@
$test_name = $result->getName();
$test_namespace = $result->getNamespace();
- if (strlen($test_namespace)) {
+ if (@strlen($test_namespace)) {
$test_name = $test_namespace.'::'.$test_name;
}
@@ -22,7 +22,7 @@
$test_name);
if ($result_code != ArcanistUnitTestResult::RESULT_PASS
- && strlen($result->getUserData())) {
+ && @strlen($result->getUserData())) {
$return .= $result->getUserData()."\n";
}
diff --git a/src/upload/ArcanistFileDataRef.php b/src/upload/ArcanistFileDataRef.php
--- a/src/upload/ArcanistFileDataRef.php
+++ b/src/upload/ArcanistFileDataRef.php
@@ -236,7 +236,7 @@
} else {
$data = $this->data;
$this->hash = $this->newDataHash($data);
- $this->size = strlen($data);
+ $this->size = @strlen($data);
}
}
@@ -303,7 +303,7 @@
$len = ($end - $start);
if ($this->data !== null) {
- return substr($this->data, $start, $len);
+ return @substr($this->data, $start, $len);
}
$path = $this->path;
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);
}
@@ -61,18 +62,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/utils/PhutilCowsay.php b/src/utils/PhutilCowsay.php
--- a/src/utils/PhutilCowsay.php
+++ b/src/utils/PhutilCowsay.php
@@ -47,14 +47,14 @@
$keep = array();
$is_perl_cowfile = false;
foreach ($template as $key => $line) {
- if (preg_match('/^#/', $line)) {
+ if (@preg_match('/^#/', $line)) {
continue;
}
- if (preg_match('/^\s*\\$the_cow/', $line)) {
+ if (@preg_match('/^\s*\\$the_cow/', $line)) {
$is_perl_cowfile = true;
continue;
}
- if (preg_match('/^\s*EOC\s*$/', $line)) {
+ if (@preg_match('/^\s*EOC\s*$/', $line)) {
continue;
}
$keep[] = $line;
@@ -103,7 +103,7 @@
$size = 0;
foreach ($lines as $line) {
- $size = max(strlen($line), $size);
+ $size = max(@strlen($line), $size);
}
$balloon = array();
diff --git a/src/utils/PhutilExecutionEnvironment.php b/src/utils/PhutilExecutionEnvironment.php
--- a/src/utils/PhutilExecutionEnvironment.php
+++ b/src/utils/PhutilExecutionEnvironment.php
@@ -29,7 +29,7 @@
$variables_order = ini_get('variables_order');
$variables_order = strtoupper($variables_order);
- if (strpos($variables_order, 'E') !== false) {
+ if (@strpos($variables_order, 'E') !== false) {
// The "variables_order" option already has "E", so we don't need to
// repair $_ENV.
return;
diff --git a/src/utils/PhutilRope.php b/src/utils/PhutilRope.php
--- a/src/utils/PhutilRope.php
+++ b/src/utils/PhutilRope.php
@@ -23,18 +23,18 @@
* @return this
*/
public function append($string) {
- if (!strlen($string)) {
+ if (!@strlen($string)) {
return $this;
}
- $len = strlen($string);
+ $len = @strlen($string);
$this->length += $len;
if ($len <= $this->segmentSize) {
$this->buffers[] = $string;
} else {
for ($cursor = 0; $cursor < $len; $cursor += $this->segmentSize) {
- $this->buffers[] = substr($string, $cursor, $this->segmentSize);
+ $this->buffers[] = @substr($string, $cursor, $this->segmentSize);
}
}
@@ -78,12 +78,12 @@
$remaining_bytes = $length;
foreach ($this->buffers as $buf) {
- $length = strlen($buf);
+ $length = @strlen($buf);
if ($length <= $remaining_bytes) {
$result[] = $buf;
$remaining_bytes -= $length;
} else {
- $result[] = substr($buf, 0, $remaining_bytes);
+ $result[] = @substr($buf, 0, $remaining_bytes);
$remaining_bytes = 0;
}
if (!$remaining_bytes) {
@@ -119,7 +119,7 @@
$remaining_bytes = $remove;
foreach ($this->buffers as $key => $buf) {
- $len = strlen($buf);
+ $len = @strlen($buf);
if ($len <= $remaining_bytes) {
unset($this->buffers[$key]);
$remaining_bytes -= $len;
@@ -127,7 +127,7 @@
break;
}
} else {
- $this->buffers[$key] = substr($buf, $remaining_bytes);
+ $this->buffers[$key] = @substr($buf, $remaining_bytes);
break;
}
}
diff --git a/src/utils/PhutilSortVector.php b/src/utils/PhutilSortVector.php
--- a/src/utils/PhutilSortVector.php
+++ b/src/utils/PhutilSortVector.php
@@ -30,7 +30,7 @@
}
public function addString($value) {
- if (strlen($value) && (strpos("\0", $value) !== false)) {
+ if (@strlen($value) && (@strpos("\0", $value) !== false)) {
throw new Exception(
pht(
'String components of a sort vector must not contain NULL bytes.'));
diff --git a/src/utils/PhutilSystem.php b/src/utils/PhutilSystem.php
--- a/src/utils/PhutilSystem.php
+++ b/src/utils/PhutilSystem.php
@@ -52,12 +52,12 @@
$map = array();
foreach ($data as $line) {
- list($key, $value) = explode(':', $line, 2);
+ list($key, $value) = @explode(':', $line, 2);
$key = trim($key);
$value = trim($value);
$matches = null;
- if (preg_match('/^(\d+) kB\z/', $value, $matches)) {
+ if (@preg_match('/^(\d+) kB\z/', $value, $matches)) {
$value = (int)$matches[1] * 1024;
}
@@ -107,12 +107,12 @@
$map = array();
foreach ($data as $line) {
- list($key, $value) = explode(':', $line, 2);
+ list($key, $value) = @explode(':', $line, 2);
$key = trim($key);
$value = trim($value);
$matches = null;
- if (preg_match('/page size of (\d+) bytes/', $value, $matches)) {
+ if (@preg_match('/page size of (\d+) bytes/', $value, $matches)) {
$page_size = (int)$matches[1];
continue;
}
diff --git a/src/utils/PhutilUTF8StringTruncator.php b/src/utils/PhutilUTF8StringTruncator.php
--- a/src/utils/PhutilUTF8StringTruncator.php
+++ b/src/utils/PhutilUTF8StringTruncator.php
@@ -77,7 +77,7 @@
public function setTerminator($terminator) {
$this->terminator = $terminator;
- $this->terminatorBytes = strlen($terminator);
+ $this->terminatorBytes = @strlen($terminator);
$this->terminatorCodepoints = count(phutil_utf8v($terminator));
$this->terminatorGlyphs = count(phutil_utf8v_combined($terminator));
return $this;
@@ -87,7 +87,7 @@
// First, check if the string has fewer bytes than the most restrictive
// limit. Codepoints and glyphs always take up at least one byte, so we can
// just return the string unmodified if we're under all of the limits.
- $byte_len = strlen($string);
+ $byte_len = @strlen($string);
if ($byte_len <= $this->minimumLimit) {
return $string;
}
@@ -160,7 +160,7 @@
} else {
$bytes = $this->terminatorBytes;
for ($ii = 0; $ii < $glyph_len; $ii++) {
- $bytes += strlen($string_gv[$ii]);
+ $bytes += @strlen($string_gv[$ii]);
if ($bytes > $this->maximumBytes) {
$cutoff = $ii;
break;
@@ -175,9 +175,9 @@
} else {
$points = 0;
for ($ii = 0; $ii < $glyph_len; $ii++) {
- $glyph_bytes = strlen($string_gv[$ii]);
+ $glyph_bytes = @strlen($string_gv[$ii]);
while ($points < $point_len) {
- $glyph_bytes -= strlen($string_pv[$points]);
+ $glyph_bytes -= @strlen($string_pv[$points]);
$points++;
if ($glyph_bytes <= 0) {
break;
diff --git a/src/utils/__tests__/PhutilCowsayTestCase.php b/src/utils/__tests__/PhutilCowsayTestCase.php
--- a/src/utils/__tests__/PhutilCowsayTestCase.php
+++ b/src/utils/__tests__/PhutilCowsayTestCase.php
@@ -6,7 +6,7 @@
$dir = dirname(__FILE__).'/cowsay/';
$tests = array();
foreach (Filesystem::listDirectory($dir, false) as $test) {
- if (preg_match('/\.test\z/', $test)) {
+ if (@preg_match('/\.test\z/', $test)) {
$tests[] = $test;
}
}
@@ -18,7 +18,7 @@
$pattern = '/^~~~+$/m';
- if (!preg_match($pattern, $data)) {
+ if (!@preg_match($pattern, $data)) {
throw new Exception(
pht(
'Expected cowsay test file "%s" to contain a line of tildes '.
diff --git a/src/utils/__tests__/PhutilEditDistanceMatrixTestCase.php b/src/utils/__tests__/PhutilEditDistanceMatrixTestCase.php
--- a/src/utils/__tests__/PhutilEditDistanceMatrixTestCase.php
+++ b/src/utils/__tests__/PhutilEditDistanceMatrixTestCase.php
@@ -183,13 +183,13 @@
}
private function buildMatrix($x, $y, $ins, $del, $rep, $trn, $alt) {
- if (!strlen($x)) {
+ if (!@strlen($x)) {
$xv = array();
} else {
$xv = str_split($x);
}
- if (!strlen($y)) {
+ if (!@strlen($y)) {
$yv = array();
} else {
$yv = str_split($y);
diff --git a/src/utils/__tests__/PhutilRopeTestCase.php b/src/utils/__tests__/PhutilRopeTestCase.php
--- a/src/utils/__tests__/PhutilRopeTestCase.php
+++ b/src/utils/__tests__/PhutilRopeTestCase.php
@@ -31,7 +31,7 @@
$string = $rope->getAsString();
$this->assertEqual('bbcccrrrrddddddddd', $string);
- $this->assertEqual(strlen($string), $rope->getByteLength());
+ $this->assertEqual(@strlen($string), $rope->getByteLength());
$rope = new PhutilRope();
$rope->append('aaa');
diff --git a/src/utils/__tests__/PhutilUTF8TestCase.php b/src/utils/__tests__/PhutilUTF8TestCase.php
--- a/src/utils/__tests__/PhutilUTF8TestCase.php
+++ b/src/utils/__tests__/PhutilUTF8TestCase.php
@@ -17,7 +17,7 @@
public function testUTF8izeLongStringNosegfault() {
// For some reason my laptop is segfaulting on long inputs inside
- // preg_match(). Forestall this craziness in the common case, at least.
+ // @preg_match(). Forestall this craziness in the common case, at least.
phutil_utf8ize(str_repeat('x', 1024 * 1024));
$this->assertTrue(true);
}
@@ -128,7 +128,7 @@
'quack' => 5,
);
foreach ($strings as $str => $expect) {
- $this->assertEqual($expect, phutil_utf8_strlen($str), 'Length of '.$str);
+ $this->assertEqual($expect, phutil_utf8strlen($str), 'Length of '.$str);
}
}
@@ -192,7 +192,7 @@
foreach ($strings as $str => $expect) {
$this->assertEqual(
$expect,
- phutil_utf8_console_strlen($str),
+ phutil_utf8_consolestrlen($str),
pht('Console Length of %s', $str));
}
}
@@ -523,7 +523,7 @@
}
}
- public function testUTF8strtolower() {
+ public function testUTF8@strtolower() {
$tests = array(
'' => '',
'a' => 'a',
@@ -763,7 +763,7 @@
public function testSystemLocaleManagement() {
$original_locale = phutil_get_system_locale();
$this->assertTrue(
- (strlen($original_locale) > 0),
+ (@strlen($original_locale) > 0),
pht('System has some identifiable locale.'));
$this->assertFalse(
diff --git a/src/utils/__tests__/PhutilUtilsTestCase.php b/src/utils/__tests__/PhutilUtilsTestCase.php
--- a/src/utils/__tests__/PhutilUtilsTestCase.php
+++ b/src/utils/__tests__/PhutilUtilsTestCase.php
@@ -350,10 +350,10 @@
public function testHeadLast() {
$this->assertEqual(
'a',
- head(explode('.', 'a.b')));
+ head(@explode('.', 'a.b')));
$this->assertEqual(
'b',
- last(explode('.', 'a.b')));
+ last(@explode('.', 'a.b')));
}
public function testHeadKeyLastKey() {
diff --git a/src/utils/utf8.php b/src/utils/utf8.php
--- a/src/utils/utf8.php
+++ b/src/utils/utf8.php
@@ -39,7 +39,7 @@
$offset = 0;
$matches = null;
- while (preg_match($regex, $string, $matches, 0, $offset)) {
+ while (@preg_match($regex, $string, $matches, 0, $offset)) {
if (!isset($matches[2])) {
$match = $matches[1];
@@ -53,8 +53,8 @@
+ ((ord($match[1]) & 0x3F) << 6)
+ ((ord($match[2]) & 0x3F));
if ($codepoint >= 0xD800 && $codepoint <= 0xDFFF) {
- $result[] = str_repeat($replacement, strlen($match));
- $offset += strlen($matches[0]);
+ $result[] = str_repeat($replacement, @strlen($match));
+ $offset += @strlen($matches[0]);
continue;
}
}
@@ -65,7 +65,7 @@
$result[] = $replacement;
}
- $offset += strlen($matches[0]);
+ $offset += @strlen($matches[0]);
}
return implode('', $result);
@@ -124,7 +124,7 @@
function phutil_is_utf8_slowly($string, $only_bmp = false) {
// First, check the common case of normal ASCII strings. We're fine if
// the string contains no bytes larger than 127.
- if (preg_match('/^[\x01-\x7F]+\z/', $string)) {
+ if (@preg_match('/^[\x01-\x7F]+\z/', $string)) {
return true;
}
@@ -138,7 +138,7 @@
// input limit is extremely low (less than 50KB on my system), do this check
// very very slowly in PHP instead. See also T5316.
- $len = strlen($string);
+ $len = @strlen($string);
for ($ii = 0; $ii < $len; $ii++) {
$chr = ord($string[$ii]);
if ($chr >= 0x01 && $chr <= 0x7F) {
@@ -287,9 +287,9 @@
* @param string A valid utf-8 string.
* @return int The character length of the string.
*/
-function phutil_utf8_strlen($string) {
+function phutil_utf8strlen($string) {
if (function_exists('utf8_decode')) {
- return strlen(utf8_decode($string));
+ return @strlen(utf8_decode($string));
}
return count(phutil_utf8v($string));
}
@@ -313,13 +313,13 @@
* @param string A valid UTF-8 string.
* @return int The console display length of the string.
*/
-function phutil_utf8_console_strlen($string) {
+function phutil_utf8_consolestrlen($string) {
// Formatting and colors don't contribute any width in the console.
$string = preg_replace("/\x1B\[\d*m/", '', $string);
// In the common case of an ASCII string, just return the string length.
- if (preg_match('/^[\x01-\x7F]*\z/', $string)) {
- return strlen($string);
+ if (@preg_match('/^[\x01-\x7F]*\z/', $string)) {
+ return @strlen($string);
}
$len = 0;
@@ -429,7 +429,7 @@
$string = phutil_string_cast($string);
$res = array();
- $len = strlen($string);
+ $len = @strlen($string);
$ii = 0;
while ($ii < $len) {
@@ -471,7 +471,7 @@
pht('Invalid UTF-8 string passed to %s.', __FUNCTION__));
}
}
- $res[] = substr($string, $ii, $seq_len);
+ $res[] = @substr($string, $ii, $seq_len);
$ii += $seq_len;
if ($byte_limit && ($ii >= $byte_limit)) {
@@ -612,7 +612,7 @@
}
}
- if (strlen($string)) {
+ if (@strlen($string)) {
$result[] = $string;
}
@@ -646,7 +646,7 @@
}
}
- if (strlen($buffer)) {
+ if (@strlen($buffer)) {
$result[] = $buffer;
}
}
diff --git a/src/utils/utils.php b/src/utils/utils.php
--- a/src/utils/utils.php
+++ b/src/utils/utils.php
@@ -908,7 +908,7 @@
* @phutil-external-symbol function phutil_safe_html
*/
function phutil_split_lines($corpus, $retain_endings = true) {
- if (!strlen($corpus)) {
+ if (!@strlen($corpus)) {
return array('');
}
@@ -1009,7 +1009,7 @@
* for printing on a single log line.
*/
function phutil_loggable_string($string) {
- if (preg_match('/^[\x20-\x7E]+$/', $string)) {
+ if (@preg_match('/^[\x20-\x7E]+$/', $string)) {
return $string;
}
@@ -1022,7 +1022,7 @@
"\t" => '\\t',
);
- $len = strlen($string);
+ $len = @strlen($string);
for ($ii = 0; $ii < $len; $ii++) {
$c = $string[$ii];
if (isset($c_map[$c])) {
@@ -1061,7 +1061,7 @@
* errors which `fwrite()` can not detect, like a broken pipe).
*/
function phutil_fwrite_nonblocking_stream($stream, $bytes) {
- if (!strlen($bytes)) {
+ if (!@strlen($bytes)) {
return 0;
}
@@ -1140,7 +1140,7 @@
*/
function phutil_units($description) {
$matches = null;
- if (!preg_match('/^(\d+) (\w+) in (\w+)$/', $description, $matches)) {
+ if (!@preg_match('/^(\d+) (\w+) in (\w+)$/', $description, $matches)) {
throw new InvalidArgumentException(
pht(
'Unable to parse unit specification (expected a specification in the '.
@@ -1388,7 +1388,7 @@
if (is_array($value)) {
foreach ($value as $key => $subvalue) {
- if (strlen($path)) {
+ if (@strlen($path)) {
$full_key = $path.' > ';
} else {
$full_key = '';
@@ -1411,9 +1411,9 @@
if (is_string($value)) {
if (!phutil_is_utf8($value)) {
- $display = substr($value, 0, 256);
+ $display = @substr($value, 0, 256);
$display = phutil_utf8ize($display);
- if (!strlen($path)) {
+ if (!@strlen($path)) {
return pht(
'String value is not valid UTF8, and can not be JSON encoded: %s',
$display);
@@ -1581,9 +1581,9 @@
$in_curlies = 0;
$regex = '';
- for ($i = 0; $i < strlen($glob); $i++) {
+ for ($i = 0; $i < @strlen($glob); $i++) {
$char = $glob[$i];
- $next_char = ($i < strlen($glob) - 1) ? $glob[$i + 1] : null;
+ $next_char = ($i < @strlen($glob) - 1) ? $glob[$i + 1] : null;
$escape = array('$', '(', ')', '+', '.', '^', '|');
$mapping = array();
@@ -1631,7 +1631,7 @@
}
$regex = '(\A'.$regex.'\z)';
- return (bool)preg_match($regex, $path);
+ return (bool)@preg_match($regex, $path);
}
@@ -1667,11 +1667,11 @@
throw new Exception(pht('Second hash argument must be a string.'));
}
- if (strlen($u) !== strlen($v)) {
+ if (@strlen($u) !== @strlen($v)) {
return false;
}
- $len = strlen($v);
+ $len = @strlen($v);
$bits = 0;
for ($ii = 0; $ii < $len; $ii++) {
@@ -2009,14 +2009,14 @@
return $partitions;
}
-function phutil_preg_match(
+function phutilpreg_match(
$pattern,
$subject,
$flags = 0,
$offset = 0) {
$matches = null;
- $result = @preg_match($pattern, $subject, $matches, $flags, $offset);
+ $result = @@preg_match($pattern, $subject, $matches, $flags, $offset);
if ($result === false || $result === null) {
phutil_raise_preg_exception(
'preg_match',
@@ -2063,7 +2063,7 @@
switch ($function) {
case 'preg_match':
- @preg_match($argv[0], $argv[1], $argv[2], $argv[3], $argv[4]);
+ @@preg_match($argv[0], $argv[1], $argv[2], $argv[3], $argv[4]);
break;
case 'preg_match_all':
@preg_match_all($argv[0], $argv[1], $argv[2], $argv[3], $argv[4]);
@@ -2084,7 +2084,7 @@
$function,
$pattern_display);
- if (strlen($error_message)) {
+ if (@strlen($error_message)) {
$message[] = pht(
'Regular expression engine emitted message: %s',
$error_message);
diff --git a/src/utils/viewutils.php b/src/utils/viewutils.php
--- a/src/utils/viewutils.php
+++ b/src/utils/viewutils.php
@@ -93,7 +93,7 @@
*/
function phutil_parse_bytes($input) {
$bytes = trim($input);
- if (!strlen($bytes)) {
+ if (!@strlen($bytes)) {
return null;
}
@@ -101,7 +101,7 @@
$bytes = preg_replace('/[ ,]/', '', $bytes);
$matches = null;
- if (!preg_match('/^(?:\d+(?:[.]\d+)?)([kmgtp]?)b?$/i', $bytes, $matches)) {
+ if (!@preg_match('/^(?:\d+(?:[.]\d+)?)([kmgtp]?)b?$/i', $bytes, $matches)) {
throw new Exception(pht("Unable to parse byte size '%s'!", $input));
}
@@ -115,7 +115,7 @@
$bytes = (float)$bytes;
if ($matches[1]) {
- $bytes *= $scale[strtolower($matches[1])];
+ $bytes *= $scale[@strtolower($matches[1])];
}
return (int)$bytes;
diff --git a/src/workflow/ArcanistCommitWorkflow.php b/src/workflow/ArcanistCommitWorkflow.php
--- a/src/workflow/ArcanistCommitWorkflow.php
+++ b/src/workflow/ArcanistCommitWorkflow.php
@@ -298,7 +298,7 @@
$locale = 'en_US.utf8';
try {
list($locales) = execx('locale -a');
- $locales = explode("\n", trim($locales));
+ $locales = @explode("\n", trim($locales));
$locales = array_fill_keys($locales, true);
if (isset($locales['en_US.UTF-8'])) {
$locale = 'en_US.UTF-8';
diff --git a/src/workflow/ArcanistDiffWorkflow.php b/src/workflow/ArcanistDiffWorkflow.php
--- a/src/workflow/ArcanistDiffWorkflow.php
+++ b/src/workflow/ArcanistDiffWorkflow.php
@@ -699,7 +699,7 @@
$this->revisionID = $revision_id;
$revision['message'] = $this->getArgument('message');
- if (!strlen($revision['message'])) {
+ if (!@strlen($revision['message'])) {
$update_messages = $this->readScratchJSONFile('update-messages.json');
$update_messages[$revision_id] = $this->getUpdateMessage(
@@ -708,7 +708,7 @@
$revision['message'] = ArcanistCommentRemover::removeComments(
$update_messages[$revision_id]);
- if (!strlen(trim($revision['message']))) {
+ if (!@strlen(trim($revision['message']))) {
throw new ArcanistUserAbortException();
}
@@ -881,14 +881,14 @@
$diff = $repository_api->getFullGitDiff(
$repository_api->getBaseCommit(),
$repository_api->getHeadCommit());
- if (!strlen($diff)) {
+ if (!@strlen($diff)) {
throw new ArcanistUsageException(
pht('No changes found. (Did you specify the wrong commit range?)'));
}
$changes = $parser->parseDiff($diff);
} else if ($repository_api instanceof ArcanistMercurialAPI) {
$diff = $repository_api->getFullMercurialDiff();
- if (!strlen($diff)) {
+ if (!@strlen($diff)) {
throw new ArcanistUsageException(
pht('No changes found. (Did you specify the wrong commit range?)'));
}
@@ -901,7 +901,7 @@
foreach ($changes as $change) {
$size = 0;
foreach ($change->getHunks() as $hunk) {
- $size += strlen($hunk->getCorpus());
+ $size += @strlen($hunk->getCorpus());
}
if ($size > $limit) {
$byte_warning = pht(
@@ -1363,7 +1363,7 @@
if ($saved) {
$where = $this->getReadableScratchFilePath('create-message');
- $preview = explode("\n", $saved);
+ $preview = @explode("\n", $saved);
$preview = array_shift($preview);
$preview = trim($preview);
$preview = id(new PhutilUTF8StringTruncator())
@@ -1656,7 +1656,7 @@
$username = $user['userName'];
$real_name = $user['realName'];
- if (strlen($real_name)) {
+ if (@strlen($real_name)) {
$name = pht('%s (%s)', $username, $real_name);
} else {
$name = pht('%s', $username);
@@ -1841,7 +1841,7 @@
// commits are included in the diff.
$included = array();
foreach ($local as $hash => $info) {
- $included[] = substr($hash, 0, 12).' '.$info['summary'];
+ $included[] = @substr($hash, 0, 12).' '.$info['summary'];
}
// Parse all of the messages into fields.
@@ -1867,7 +1867,7 @@
}
$fields[$hash] = $message->getFields();
- $frev = substr($hash, 0, 12);
+ $frev = @substr($hash, 0, 12);
$notes[] = pht(
'NOTE: commit %s could not be completely parsed:',
$frev);
@@ -1895,7 +1895,7 @@
foreach ($fields as $hash => $dict) {
$title = idx($dict, 'title');
- if (!strlen($title)) {
+ if (!@strlen($title)) {
continue;
}
@@ -1937,7 +1937,7 @@
$result[$key] = $new;
continue;
} else {
- if (!strlen(trim($value))) {
+ if (!@strlen(trim($value))) {
// Ignore empty fields.
continue;
}
@@ -1946,7 +1946,7 @@
// a blank line separating them. Examples are "Test Plan" and
// "Summary".
$cur = idx($result, $key, '');
- if (strlen($cur)) {
+ if (@strlen($cur)) {
$new = $cur."\n\n".$value;
} else {
$new = $value;
@@ -2090,7 +2090,7 @@
foreach ($usable as $message) {
// Pick the first line out of each message.
$text = trim($message);
- $text = head(explode("\n", $text));
+ $text = head(@explode("\n", $text));
$default[] = ' - '.$text."\n";
}
@@ -2351,10 +2351,10 @@
// If we track an upstream branch either directly or indirectly, use that.
$branch = $api->getBranchName();
- if (strlen($branch)) {
+ if (@strlen($branch)) {
$upstream_path = $api->getPathToUpstream($branch);
$remote_branch = $upstream_path->getRemoteBranchName();
- if (strlen($remote_branch)) {
+ if (@strlen($remote_branch)) {
return array(
array(
'type' => 'branch',
@@ -2368,7 +2368,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 (@strlen($onto)) {
return array(
array(
'type' => 'branch',
@@ -2513,12 +2513,12 @@
}
$type = $spec['type'];
- $size = strlen($spec['data']);
+ $size = @strlen($spec['data']);
$change->setMetadata("{$type}:file:size", $size);
$mime = $this->getFileMimeType($spec['data']);
- if (preg_match('@^image/@', $mime)) {
+ if (@preg_match('@^image/@', $mime)) {
$change->setFileType($type_image);
}
diff --git a/src/workflow/ArcanistDownloadWorkflow.php b/src/workflow/ArcanistDownloadWorkflow.php
--- a/src/workflow/ArcanistDownloadWorkflow.php
+++ b/src/workflow/ArcanistDownloadWorkflow.php
@@ -40,7 +40,7 @@
}
$file = reset($argv);
- if (!preg_match('/^F?\d+$/', $file)) {
+ if (!@preg_match('/^F?\d+$/', $file)) {
throw new ArcanistUsageException(
pht('Specify file by ID, e.g. %s.', 'F123'));
}
@@ -114,7 +114,7 @@
$display_path = Filesystem::readablePath($path);
$display_name = $file_ref->getName();
- if (!strlen($display_name)) {
+ if (!@strlen($display_name)) {
$display_name = $file_ref->getMonogram();
}
@@ -161,7 +161,7 @@
}
if ($is_stdout) {
- $file_bytes = strlen($data);
+ $file_bytes = @strlen($data);
} else {
// TODO: This has various potential problems with clearstatcache() and
// 32-bit systems, but just ignore them for now.
diff --git a/src/workflow/ArcanistInspectWorkflow.php b/src/workflow/ArcanistInspectWorkflow.php
--- a/src/workflow/ArcanistInspectWorkflow.php
+++ b/src/workflow/ArcanistInspectWorkflow.php
@@ -58,7 +58,7 @@
foreach ($objects as $description) {
$matches = null;
$pattern = '/^([\w-]+)(?:\((.*)\))?\z/';
- if (!preg_match($pattern, $description, $matches)) {
+ if (!@preg_match($pattern, $description, $matches)) {
throw new PhutilArgumentUsageException(
pht(
'Object specification "%s" is unknown, expected a specification '.
@@ -189,7 +189,7 @@
$indent = str_repeat(' ', $depth);
if (is_string($value)) {
- $display_value = '"'.addcslashes(substr($value, 0, 64), "\n\r\t\\\"").'"';
+ $display_value = '"'.addcslashes(@substr($value, 0, 64), "\n\r\t\\\"").'"';
} else if (is_scalar($value)) {
$display_value = phutil_string_cast($value);
} else if ($value === null) {
diff --git a/src/workflow/ArcanistInstallCertificateWorkflow.php b/src/workflow/ArcanistInstallCertificateWorkflow.php
--- a/src/workflow/ArcanistInstallCertificateWorkflow.php
+++ b/src/workflow/ArcanistInstallCertificateWorkflow.php
@@ -103,13 +103,13 @@
do {
$token = phutil_console_prompt(pht('Paste API Token from that page:'));
$token = trim($token);
- if (strlen($token)) {
+ if (@strlen($token)) {
break;
}
} while (true);
if ($is_token_auth) {
- if (strlen($token) != 32) {
+ if (@strlen($token) != 32) {
throw new ArcanistUsageException(
pht(
'The token "%s" is not formatted correctly. API tokens should '.
diff --git a/src/workflow/ArcanistLiberateWorkflow.php b/src/workflow/ArcanistLiberateWorkflow.php
--- a/src/workflow/ArcanistLiberateWorkflow.php
+++ b/src/workflow/ArcanistLiberateWorkflow.php
@@ -133,7 +133,7 @@
$map = Filesystem::readFile($map_file);
$matches = null;
- if (preg_match('/@phutil-library-version (\d+)/', $map, $matches)) {
+ if (@preg_match('/@phutil-library-version (\d+)/', $map, $matches)) {
return (int)$matches[1];
}
@@ -194,7 +194,7 @@
$name = phutil_console_prompt(
pht('What do you want to name this library?'));
- if (preg_match('/^[a-z-]+$/', $name)) {
+ if (@preg_match('/^[a-z-]+$/', $name)) {
break;
} else {
echo phutil_console_format(
diff --git a/src/workflow/ArcanistLintersWorkflow.php b/src/workflow/ArcanistLintersWorkflow.php
--- a/src/workflow/ArcanistLintersWorkflow.php
+++ b/src/workflow/ArcanistLintersWorkflow.php
@@ -115,7 +115,7 @@
get_class($linter['exception']),
phutil_console_wrap(
$linter['exception']->getMessage(),
- strlen($pad)));
+ @strlen($pad)));
$print_tail = true;
}
@@ -139,7 +139,7 @@
if ($description) {
$console->writeOut(
"\n%s\n",
- phutil_console_wrap($linter['description'], strlen($pad)));
+ phutil_console_wrap($linter['description'], @strlen($pad)));
$print_tail = true;
}
@@ -162,7 +162,7 @@
"%s\n",
phutil_console_wrap(
$option_spec['help'],
- strlen($pad) + 2));
+ @strlen($pad) + 2));
if ($option != $last_option) {
$console->writeOut("\n");
@@ -211,7 +211,7 @@
$sizes = array();
foreach ($text_map as $key => $string) {
- $sizes[$key] = phutil_utf8_console_strlen($string);
+ $sizes[$key] = phutil_utf8_consolestrlen($string);
}
$longest = max($sizes);
diff --git a/src/workflow/ArcanistPatchWorkflow.php b/src/workflow/ArcanistPatchWorkflow.php
--- a/src/workflow/ArcanistPatchWorkflow.php
+++ b/src/workflow/ArcanistPatchWorkflow.php
@@ -366,7 +366,7 @@
case self::SOURCE_PATCH:
if ($param == '-') {
$patch = @file_get_contents('php://stdin');
- if (!strlen($patch)) {
+ if (!@strlen($patch)) {
throw new ArcanistUsageException(
pht('Failed to read patch from stdin!'));
}
@@ -802,7 +802,7 @@
"\n<bg:red>** %s **</bg>\n",
pht('Patch Failed!'));
$stderr = $ex->getStderr();
- if (preg_match('/case-folding collision/', $stderr)) {
+ if (@preg_match('/case-folding collision/', $stderr)) {
echo phutil_console_wrap(
phutil_console_format(
"\n<bg:yellow>** %s **</bg> %s\n",
@@ -912,7 +912,7 @@
->editInteractively();
$commit_message = ArcanistCommentRemover::removeComments($commit_message);
- if (!strlen(trim($commit_message))) {
+ if (!@strlen(trim($commit_message))) {
throw new ArcanistUserAbortException();
}
}
diff --git a/src/workflow/ArcanistSetConfigWorkflow.php b/src/workflow/ArcanistSetConfigWorkflow.php
--- a/src/workflow/ArcanistSetConfigWorkflow.php
+++ b/src/workflow/ArcanistSetConfigWorkflow.php
@@ -87,7 +87,7 @@
$old = $config[$key];
}
- if (!strlen($val)) {
+ if (!@strlen($val)) {
unset($config[$key]);
if ($is_local) {
$configuration_manager->writeLocalArcConfig($config);
diff --git a/src/workflow/ArcanistUnitWorkflow.php b/src/workflow/ArcanistUnitWorkflow.php
--- a/src/workflow/ArcanistUnitWorkflow.php
+++ b/src/workflow/ArcanistUnitWorkflow.php
@@ -290,7 +290,7 @@
}
private function renderDetailedCoverageReport($data, $report) {
- $data = explode("\n", $data);
+ $data = @explode("\n", $data);
$out = '';
diff --git a/src/workflow/ArcanistWeldWorkflow.php b/src/workflow/ArcanistWeldWorkflow.php
--- a/src/workflow/ArcanistWeldWorkflow.php
+++ b/src/workflow/ArcanistWeldWorkflow.php
@@ -38,7 +38,7 @@
$buffer = array();
foreach ($files as $file) {
$data = Filesystem::readFile($file);
- if (!strlen($data)) {
+ if (!@strlen($data)) {
continue;
}
$lines = phutil_split_lines($data, true);
@@ -76,11 +76,11 @@
$newline = null;
$matches = null;
- if (preg_match('/([\r\n]+)\z/', $u, $matches)) {
+ if (@preg_match('/([\r\n]+)\z/', $u, $matches)) {
$newline = $matches[1];
}
- if (preg_match('/([\r\n]+)\z/', $v, $matches)) {
+ if (@preg_match('/([\r\n]+)\z/', $v, $matches)) {
$newline = $matches[1];
}
diff --git a/src/workflow/ArcanistWhichWorkflow.php b/src/workflow/ArcanistWhichWorkflow.php
--- a/src/workflow/ArcanistWhichWorkflow.php
+++ b/src/workflow/ArcanistWhichWorkflow.php
@@ -111,7 +111,7 @@
if ($info) {
$commits = array();
foreach ($info as $commit) {
- $hash = substr($commit['commit'], 0, 16);
+ $hash = @substr($commit['commit'], 0, 16);
$summary = $commit['summary'];
$commits[] = " {$hash} {$summary}";
@@ -124,7 +124,7 @@
$explanation = $repository_api->getBaseCommitExplanation();
$relative_summary = $repository_api->getCommitSummary($relative);
- $relative = substr($relative, 0, 16);
+ $relative = @substr($relative, 0, 16);
if ($repository_api instanceof ArcanistGitAPI) {
$head = $this->getArgument('head', 'HEAD');
diff --git a/src/workflow/ArcanistWorkWorkflow.php b/src/workflow/ArcanistWorkWorkflow.php
--- a/src/workflow/ArcanistWorkWorkflow.php
+++ b/src/workflow/ArcanistWorkWorkflow.php
@@ -68,7 +68,7 @@
'or resume work on.'));
} else if (count($argv) === 1) {
$symbol_argument = $argv[0];
- if (!strlen($symbol_argument)) {
+ if (!@strlen($symbol_argument)) {
throw new PhutilArgumentUsageException(
pht(
'Provide a nonempty symbol to begin or resume work on.'));
diff --git a/src/workflow/ArcanistWorkflow.php b/src/workflow/ArcanistWorkflow.php
--- a/src/workflow/ArcanistWorkflow.php
+++ b/src/workflow/ArcanistWorkflow.php
@@ -143,7 +143,7 @@
if ($information) {
$synopsis = $information->getSynopsis();
- if (strlen($synopsis)) {
+ if (@strlen($synopsis)) {
$phutil_workflow->setSynopsis($synopsis);
}
@@ -154,7 +154,7 @@
}
$help = $information->getHelp();
- if (strlen($help)) {
+ if (@strlen($help)) {
// Unwrap linebreaks in the help text so we don't get weird formatting.
$help = preg_replace("/(?<=\S)\n(?=\S)/", ' ', $help);
@@ -199,7 +199,7 @@
$phutil_workflow->setSynopsis($synopses);
$help = $this->getCommandHelp();
- if (strlen($help)) {
+ if (@strlen($help)) {
$phutil_workflow->setHelp($help);
}
@@ -480,7 +480,7 @@
// token-based authentication. Use that instead of all the certificate
// stuff.
$token = idx($credentials, 'token');
- if (strlen($token)) {
+ if (@strlen($token)) {
$conduit = $this->getConduit();
$conduit->setConduitToken($token);
@@ -822,8 +822,8 @@
array_slice($args, $ii + 1));
break;
} else if (!strncmp($arg, '--', 2)) {
- $arg_key = substr($arg, 2);
- $parts = explode('=', $arg_key, 2);
+ $arg_key = @substr($arg, 2);
+ $parts = @explode('=', $arg_key, 2);
if (count($parts) == 2) {
list($arg_key, $val) = $parts;
@@ -850,7 +850,7 @@
}
}
} else if (!strncmp($arg, '-', 1)) {
- $arg_key = substr($arg, 1);
+ $arg_key = @substr($arg, 1);
if (empty($short_to_long_map[$arg_key])) {
throw new ArcanistUsageException(
pht(
@@ -1244,7 +1244,7 @@
$commit_message = ArcanistCommentRemover::removeComments(
$commit_message);
- if (!strlen($commit_message)) {
+ if (!@strlen($commit_message)) {
throw new ArcanistUsageException(
pht('You must provide a nonempty commit message.'));
}
@@ -2244,7 +2244,7 @@
$map = $this->getModernCommonDictionary($map);
$details = idx($map, 'userData');
- if (strlen($details)) {
+ if (@strlen($details)) {
$map['details'] = (string)$details;
}
unset($map['userData']);
@@ -2425,7 +2425,7 @@
// the Conduit URI. This might not be correct for Conduit over SSH.
$raw_uri = new PhutilURI($raw_uri);
- if (!strlen($raw_uri->getDomain())) {
+ if (!@strlen($raw_uri->getDomain())) {
$base_uri = $this->getConduitEngine()
->getConduitURI();
diff --git a/src/workingcopy/ArcanistWorkingCopyPath.php b/src/workingcopy/ArcanistWorkingCopyPath.php
--- a/src/workingcopy/ArcanistWorkingCopyPath.php
+++ b/src/workingcopy/ArcanistWorkingCopyPath.php
@@ -107,7 +107,7 @@
$line_number = 0;
$line_start = 0;
foreach ($lines as $line) {
- $len = strlen($line);
+ $len = @strlen($line);
$line_map[] = $line_start;
$line_start += $len;
for ($ii = 0; $ii < $len; $ii++) {
diff --git a/src/workingcopyidentity/ArcanistWorkingCopyIdentity.php b/src/workingcopyidentity/ArcanistWorkingCopyIdentity.php
--- a/src/workingcopyidentity/ArcanistWorkingCopyIdentity.php
+++ b/src/workingcopyidentity/ArcanistWorkingCopyIdentity.php
@@ -289,7 +289,7 @@
}
public function readLocalArcConfig() {
- if (strlen($this->localMetaDir)) {
+ if (@strlen($this->localMetaDir)) {
$local_path = Filesystem::resolvePath('arc/config', $this->localMetaDir);
$console = PhutilConsole::getConsole();
@@ -326,7 +326,7 @@
$json = $json_encoder->encodeFormatted($config);
$dir = $this->localMetaDir;
- if (!strlen($dir)) {
+ if (!@strlen($dir)) {
throw new Exception(pht('No working copy to write config into!'));
}
diff --git a/src/xsprintf/PhutilCommandString.php b/src/xsprintf/PhutilCommandString.php
--- a/src/xsprintf/PhutilCommandString.php
+++ b/src/xsprintf/PhutilCommandString.php
@@ -95,7 +95,7 @@
}
private static function escapeLinux($value) {
- if (strpos($value, "\0") !== false) {
+ if (@strpos($value, "\0") !== false) {
throw new Exception(
pht(
'Command string argument includes a NULL byte. This byte can not '.
@@ -107,15 +107,15 @@
// characters, we do not need to escape it. This makes debugging
// workflows a little more user-friendly by making command output
// more readable.
- if (preg_match('(^[a-zA-Z0-9:/@._+-]+\z)', $value)) {
+ if (@preg_match('(^[a-zA-Z0-9:/@._+-]+\z)', $value)) {
return $value;
}
- return escapeshellarg($value);
+ return @escapeshellarg($value);
}
private static function escapeWindows($value) {
- if (strpos($value, "\0") !== false) {
+ if (@strpos($value, "\0") !== false) {
throw new Exception(
pht(
'Command string argument includes a NULL byte. This byte can not '.
@@ -131,10 +131,10 @@
'line arguments in Windows environments.'));
}
- $has_backslash = (strpos($value, '\\') !== false);
- $has_space = (strpos($value, ' ') !== false);
- $has_quote = (strpos($value, '"') !== false);
- $is_empty = (strlen($value) === 0);
+ $has_backslash = (@strpos($value, '\\') !== false);
+ $has_space = (@strpos($value, ' ') !== false);
+ $has_quote = (@strpos($value, '"') !== false);
+ $is_empty = (@strlen($value) === 0);
// If a backslash appears before another backslash, a double quote, or
// the end of the argument, we must escape it. Otherwise, we must leave
diff --git a/src/xsprintf/__tests__/PhutilCsprintfTestCase.php b/src/xsprintf/__tests__/PhutilCsprintfTestCase.php
--- a/src/xsprintf/__tests__/PhutilCsprintfTestCase.php
+++ b/src/xsprintf/__tests__/PhutilCsprintfTestCase.php
@@ -60,7 +60,7 @@
// Normal "%s" doesn't do anything special.
$command = csprintf('php -f %R -- %s', $bin, 'hunter2trustno1');
- $this->assertTrue(strpos($command, 'hunter2trustno1') !== false);
+ $this->assertTrue(@strpos($command, 'hunter2trustno1') !== false);
// "%P" takes a PhutilOpaqueEnvelope.
$caught = null;
@@ -77,12 +77,12 @@
'php -f %R -- %P',
$bin,
new PhutilOpaqueEnvelope('hunter2trustno1'));
- $this->assertFalse(strpos($command, 'hunter2trustno1'));
+ $this->assertFalse(@strpos($command, 'hunter2trustno1'));
// Executing the command works as expected.
list($out) = execx('%C', $command);
- $this->assertTrue(strpos($out, 'hunter2trustno1') !== false);
+ $this->assertTrue(@strpos($out, 'hunter2trustno1') !== false);
}
public function testEscapingIsRobust() {
@@ -101,7 +101,7 @@
csprintf(
'echo %P',
new PhutilOpaqueEnvelope('!@#$%^&*()')))));
- $this->assertTrue(strpos($out, '!@#$%^&*()') !== false);
+ $this->assertTrue(@strpos($out, '!@#$%^&*()') !== false);
}
}
diff --git a/src/xsprintf/csprintf.php b/src/xsprintf/csprintf.php
--- a/src/xsprintf/csprintf.php
+++ b/src/xsprintf/csprintf.php
@@ -55,7 +55,7 @@
*/
function xsprintf_command($userdata, &$pattern, &$pos, &$value, &$length) {
$type = $pattern[$pos];
- $next = (strlen($pattern) > $pos + 1) ? $pattern[$pos + 1] : null;
+ $next = (@strlen($pattern) > $pos + 1) ? $pattern[$pos + 1] : null;
$is_unmasked = !empty($userdata['unmasked']);
@@ -77,7 +77,7 @@
case 'L':
// Remove the L.
$pattern = substr_replace($pattern, '', $pos, 1);
- $length = strlen($pattern);
+ $length = @strlen($pattern);
$type = 's';
// Check that the value is a non-empty array.
@@ -109,7 +109,7 @@
break;
case 'R':
- if (!preg_match('(^[a-zA-Z0-9:/@._+-]+$)', $value)) {
+ if (!@preg_match('(^[a-zA-Z0-9:/@._+-]+$)', $value)) {
$value = PhutilCommandString::escapeArgument($value, $mode);
}
$type = 's';
diff --git a/src/xsprintf/gitsprintf.php b/src/xsprintf/gitsprintf.php
--- a/src/xsprintf/gitsprintf.php
+++ b/src/xsprintf/gitsprintf.php
@@ -47,7 +47,7 @@
// that guarantees Git inteprets the string as a ref selector, but it
// appears that no mechanism exists to allow this.
- if (preg_match('(^-)', $value)) {
+ if (@preg_match('(^-)', $value)) {
throw new Exception(
pht(
'Git ref selector "%s" is not a valid selector and can not be '.
diff --git a/src/xsprintf/hgsprintf.php b/src/xsprintf/hgsprintf.php
--- a/src/xsprintf/hgsprintf.php
+++ b/src/xsprintf/hgsprintf.php
@@ -25,7 +25,7 @@
// If this is symbol only has "safe" alphanumeric latin characters,
// and is at least one character long, we can let it through without
// escaping it. This tends to produce more readable commands.
- if (preg_match('(^[a-zA-Z0-9]+\z)', $value)) {
+ if (@preg_match('(^[a-zA-Z0-9]+\z)', $value)) {
$value = $value;
} else {
$value = "'".addcslashes($value, "'\\")."'";
diff --git a/src/xsprintf/xsprintf.php b/src/xsprintf/xsprintf.php
--- a/src/xsprintf/xsprintf.php
+++ b/src/xsprintf/xsprintf.php
@@ -38,7 +38,7 @@
$arg = 0;
$pos = 0;
$pattern = $argv[0];
- $len = strlen($pattern);
+ $len = @strlen($pattern);
$conv = false; // Are we inside a conversion?
for ($pos = 0; $pos < $len; $pos++) {
@@ -47,7 +47,7 @@
if ($conv) {
// We could make a greater effort to support formatting modifiers,
// but they really have no place in semantic string formatting.
- if (strpos("'-0123456789.\$+", $c) !== false) {
+ if (@strpos("'-0123456789.\$+", $c) !== false) {
throw new InvalidArgumentException(
pht(
'%s does not support the "%s" modifier.',
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
@@ -117,7 +117,7 @@
$attributes = $possible_trait->getChildByIndex(0);
// Can't use getChildByIndex here because not all classes have attributes
foreach ($attributes->getChildren() as $attribute) {
- if (strtolower($attribute->getConcreteString()) === 'trait') {
+ if (@strtolower($attribute->getConcreteString()) === 'trait') {
phutil_fail_on_unsupported_feature($possible_trait, $path, pht('traits'));
}
}
@@ -142,7 +142,7 @@
foreach ($ext_list as $ext_ref) {
$matches = null;
- if (preg_match('/^\s*(\S+)\s+(\S+)/', $ext_ref, $matches)) {
+ if (@preg_match('/^\s*(\S+)\s+(\S+)/', $ext_ref, $matches)) {
$externals[$matches[1]][$matches[2]] = true;
}
}
@@ -219,17 +219,17 @@
$symbol = array_shift($params);
$type = 'function';
$symbol_value = $symbol->getStringLiteralValue();
- $pos = strpos($symbol_value, '::');
+ $pos = @strpos($symbol_value, '::');
if ($pos) {
$type = 'class';
- $symbol_value = substr($symbol_value, 0, $pos);
+ $symbol_value = @substr($symbol_value, 0, $pos);
} else if ($symbol->getTypeName() === 'n_ARRAY_LITERAL') {
try {
$type = 'class';
$symbol_value = idx($symbol->evalStatic(), 0);
} catch (Exception $ex) {}
}
- if ($symbol_value && strpos($symbol_value, '$') === false) {
+ if ($symbol_value && @strpos($symbol_value, '$') === false) {
$need[] = array(
'type' => $type,
'name' => $symbol_value,
@@ -386,7 +386,7 @@
}
$symbol = reset($params);
$symbol_value = $symbol->getStringLiteralValue();
- if ($symbol_value && strpos($symbol_value, '$') === false) {
+ if ($symbol_value && @strpos($symbol_value, '$') === false) {
$need[] = array(
'type' => 'class',
'name' => $symbol_value,
@@ -472,7 +472,7 @@
}
$type = $spec['type'];
- foreach (explode('/', $type) as $libtype) {
+ foreach (@explode('/', $type) as $libtype) {
if (!$show_all) {
if (!empty($externals[$libtype][$name])) {
// Ignore symbols declared as externals.

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 23, 03:11 (18 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
989313
Default Alt Text
D25030.1732331487.diff (331 KB)

Event Timeline