Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14756766
D12804.id30780.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
16 KB
Referenced Files
None
Subscribers
None
D12804.id30780.diff
View Options
diff --git a/src/aphront/storage/connection/mysql/AphrontMySQLDatabaseConnection.php b/src/aphront/storage/connection/mysql/AphrontMySQLDatabaseConnection.php
--- a/src/aphront/storage/connection/mysql/AphrontMySQLDatabaseConnection.php
+++ b/src/aphront/storage/connection/mysql/AphrontMySQLDatabaseConnection.php
@@ -138,7 +138,7 @@
public function executeParallelQueries(
array $queries,
array $conns = array()) {
- assert_instances_of($conns, 'AphrontMySQLDatabaseConnection');
+ assert_instances_of($conns, __CLASS__);
$map = array();
$is_write = false;
diff --git a/src/aphront/storage/connection/mysql/AphrontMySQLiDatabaseConnection.php b/src/aphront/storage/connection/mysql/AphrontMySQLiDatabaseConnection.php
--- a/src/aphront/storage/connection/mysql/AphrontMySQLiDatabaseConnection.php
+++ b/src/aphront/storage/connection/mysql/AphrontMySQLiDatabaseConnection.php
@@ -145,7 +145,7 @@
}
public static function resolveAsyncQueries(array $conns, array $asyncs) {
- assert_instances_of($conns, 'AphrontMySQLiDatabaseConnection');
+ assert_instances_of($conns, __CLASS__);
assert_instances_of($asyncs, 'mysqli');
$read = $error = $reject = array();
diff --git a/src/aphront/writeguard/AphrontWriteGuard.php b/src/aphront/writeguard/AphrontWriteGuard.php
--- a/src/aphront/writeguard/AphrontWriteGuard.php
+++ b/src/aphront/writeguard/AphrontWriteGuard.php
@@ -65,14 +65,18 @@
public function __construct($callback) {
if (self::$instance) {
throw new Exception(
- 'An AphrontWriteGuard already exists. Dispose of the previous guard '.
- 'before creating a new one.');
+ pht(
+ 'An %s already exists. Dispose of the previous guard '.
+ 'before creating a new one.',
+ __CLASS__));
}
if (self::$allowUnguardedWrites) {
throw new Exception(
- 'An AphrontWriteGuard is being created in a context which permits '.
- 'unguarded writes unconditionally. This is not allowed and indicates '.
- 'a serious error.');
+ pht(
+ 'An %s is being created in a context which permits unguarded '.
+ 'writes unconditionally. This is not allowed and indicates '.
+ 'a serious error.',
+ __CLASS__));
}
if (!self::$abruptExitlistenerIsInstalled) {
self::$abruptExitlistenerIsInstalled = true;
@@ -94,13 +98,18 @@
public function dispose() {
if (!self::$instance) {
throw new Exception(
- 'Attempting to dispose of write guard, but no write guard is active!');
+ pht(
+ 'Attempting to dispose of write guard, '.
+ 'but no write guard is active!'));
}
if ($this->allowDepth > 0) {
throw new Exception(
- 'Imbalanced AphrontWriteGuard: more beginUnguardedWrites() calls than '.
- 'endUnguardedWrites() calls.');
+ pht(
+ 'Imbalanced %s: more %s calls than %s calls.',
+ __CLASS__,
+ 'beginUnguardedWrites()',
+ 'endUnguardedWrites()'));
}
self::$instance = null;
}
@@ -162,8 +171,9 @@
if (!self::$instance) {
if (!self::$allowUnguardedWrites) {
throw new Exception(
- 'Unguarded write! There must be an active AphrontWriteGuard to '.
- 'perform writes.');
+ pht(
+ 'Unguarded write! There must be an active %s to perform writes.',
+ __CLASS__));
} else {
// Unguarded writes are being allowed unconditionally.
return;
@@ -237,8 +247,11 @@
}
if (self::$instance->allowDepth <= 0) {
throw new Exception(
- 'Imbalanced AphrontWriteGuard: more endUnguardedWrites() calls than '.
- 'beginUnguardedWrites() calls.');
+ pht(
+ 'Imbalanced %s: more %s calls than %s calls.',
+ __CLASS__,
+ 'endUnguardedWrites()',
+ 'beginUnguardedWrites()'));
}
self::$instance->allowDepth--;
}
@@ -259,9 +272,12 @@
public static function allowDangerousUnguardedWrites($allow) {
if (self::$instance) {
throw new Exception(
- 'You can not unconditionally disable AphrontWriteGuard by calling '.
- 'allowDangerousUnguardedWrites() while a write guard is active. Use '.
- 'beginUnguardedWrites() to temporarily allow unguarded writes.');
+ pht(
+ 'You can not unconditionally disable %s by calling %s while a write '.
+ 'guard is active. Use %s to temporarily allow unguarded writes.',
+ __CLASS__,
+ 'allowDangerousUnguardedWrites()',
+ 'beginUnguardedWrites()'));
}
self::$allowUnguardedWrites = true;
}
@@ -278,9 +294,13 @@
public function __destruct() {
if (isset(self::$instance)) {
throw new Exception(
- 'AphrontWriteGuard was not properly disposed of! Call dispose() on '.
- 'every AphrontWriteGuard object you instantiate or use phutil_exit() '.
- 'to exit abruptly while debugging.');
+ pht(
+ '%s was not properly disposed of! Call %s on every %s object you '.
+ 'instantiate or use %s to exit abruptly while debugging.',
+ __CLASS__,
+ 'dispose()',
+ __CLASS__,
+ 'phutil_exit()'));
}
}
diff --git a/src/auth/PhutilGitHubAuthAdapter.php b/src/auth/PhutilGitHubAuthAdapter.php
--- a/src/auth/PhutilGitHubAuthAdapter.php
+++ b/src/auth/PhutilGitHubAuthAdapter.php
@@ -56,7 +56,7 @@
$future = new HTTPSFuture($uri);
// NOTE: GitHub requires a User-Agent string.
- $future->addHeader('User-Agent', 'PhutilGitHubAuthAdapter');
+ $future->addHeader('User-Agent', __CLASS__);
list($body) = $future->resolvex();
diff --git a/src/channel/PhutilChannel.php b/src/channel/PhutilChannel.php
--- a/src/channel/PhutilChannel.php
+++ b/src/channel/PhutilChannel.php
@@ -72,7 +72,10 @@
*/
public function write($bytes) {
if (!is_scalar($bytes)) {
- throw new Exception('PhutilChannel->write() may only write strings!');
+ throw new Exception(
+ pht(
+ '%s may only write strings!',
+ __CLASS__.'->'.__FUNCTION__.'()'));
}
$this->obuf->append($bytes);
@@ -127,8 +130,8 @@
array $writes,
array $options = array()) {
- assert_instances_of($reads, 'PhutilChannel');
- assert_instances_of($writes, 'PhutilChannel');
+ assert_instances_of($reads, __CLASS__);
+ assert_instances_of($writes, __CLASS__);
$read = idx($options, 'read', array());
$write = idx($options, 'write', array());
diff --git a/src/channel/PhutilChannelChannel.php b/src/channel/PhutilChannelChannel.php
--- a/src/channel/PhutilChannelChannel.php
+++ b/src/channel/PhutilChannelChannel.php
@@ -100,8 +100,13 @@
// protected.
throw new Exception(
- 'Do not call readBytes() or writeBytes() directly on a '.
- 'PhutilChannelChannel. Instead, call read() or write().');
+ pht(
+ 'Do not call %s or %s directly on a %s. Instead, call %s or %s.',
+ 'readBytes()',
+ 'writeBytes()',
+ 'read()',
+ 'write()',
+ __CLASS__));
}
}
diff --git a/src/console/PhutilConsoleFormatter.php b/src/console/PhutilConsoleFormatter.php
--- a/src/console/PhutilConsoleFormatter.php
+++ b/src/console/PhutilConsoleFormatter.php
@@ -69,7 +69,7 @@
$format = preg_replace($invert_re, $invert, $format);
$format = preg_replace_callback(
'@<(fg|bg):('.$colors.')>(.*)</\1>@sU',
- array('PhutilConsoleFormatter', 'replaceColorCode'),
+ array(__CLASS__, 'replaceColorCode'),
$format);
}
diff --git a/src/error/PhutilErrorHandler.php b/src/error/PhutilErrorHandler.php
--- a/src/error/PhutilErrorHandler.php
+++ b/src/error/PhutilErrorHandler.php
@@ -53,8 +53,8 @@
*/
public static function initialize() {
self::$initialized = true;
- set_error_handler(array('PhutilErrorHandler', 'handleError'));
- set_exception_handler(array('PhutilErrorHandler', 'handleException'));
+ set_error_handler(array(__CLASS__, 'handleError'));
+ set_exception_handler(array(__CLASS__, 'handleException'));
}
/**
diff --git a/src/filesystem/FileFinder.php b/src/filesystem/FileFinder.php
--- a/src/filesystem/FileFinder.php
+++ b/src/filesystem/FileFinder.php
@@ -187,9 +187,11 @@
if (!is_dir($this->root) || !is_readable($this->root)) {
throw new Exception(
- "Invalid FileFinder root directory specified ('{$this->root}'). ".
- "Root directory must be a directory, be readable, and be specified ".
- "with an absolute path.");
+ pht(
+ "Invalid %s root directory specified ('%s'). Root directory must be ".
+ "a directory, be readable, and be specified with an absolute path.",
+ __CLASS__,
+ $this->root));
}
if ($this->forceMode == 'shell') {
diff --git a/src/filesystem/Filesystem.php b/src/filesystem/Filesystem.php
--- a/src/filesystem/Filesystem.php
+++ b/src/filesystem/Filesystem.php
@@ -448,17 +448,18 @@
if (phutil_is_windows()) {
throw new Exception(
pht(
- 'Filesystem::readRandomBytes() requires the PHP OpenSSL extension '.
- 'to be installed and enabled to access an entropy source. On '.
- 'Windows, this extension is usually installed but not enabled by '.
- 'default. Enable it in your "php.ini".'));
+ '%s requires the PHP OpenSSL extension to be installed and enabled '.
+ 'to access an entropy source. On Windows, this extension is usually '.
+ 'installed but not enabled by default. Enable it in your "php.ini".',
+ __METHOD__));
}
throw new Exception(
pht(
- 'Filesystem::readRandomBytes() requires the PHP OpenSSL extension '.
- 'or access to "/dev/urandom". Install or enable the OpenSSL '.
- 'extension, or make sure "/dev/urandom" is accessible.'));
+ '%s requires the PHP OpenSSL extension or access to "/dev/urandom". '.
+ 'Install or enable the OpenSSL extension, or make sure "/dev/urandom" '.
+ 'is accessible.',
+ __METHOD__));
}
@@ -974,7 +975,7 @@
if (!self::pathExists($path)) {
throw new FilesystemException(
$path,
- "Filesystem entity `{$path}' does not exist.");
+ "File system entity `{$path}' does not exist.");
}
}
diff --git a/src/filesystem/PhutilLock.php b/src/filesystem/PhutilLock.php
--- a/src/filesystem/PhutilLock.php
+++ b/src/filesystem/PhutilLock.php
@@ -104,7 +104,7 @@
*/
protected static function registerLock(PhutilLock $lock) {
if (!self::$registeredShutdownFunction) {
- register_shutdown_function(array('PhutilLock', 'unlockAll'));
+ register_shutdown_function(array(__CLASS__, 'unlockAll'));
self::$registeredShutdownFunction = true;
}
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
@@ -69,9 +69,11 @@
protected function willRewind() {
if ($this->didRewind) {
throw new Exception(
- "You can not reiterate over a LinesOfALargeExecFuture object. The ".
- "entire goal of the construct is to avoid keeping output in memory. ".
- "What you are attempting to do is silly and doesn't make any sense.");
+ pht(
+ "You can not reiterate over a %s object. The entire goal of the ".
+ "construct is to avoid keeping output in memory. What you are ".
+ "attempting to do is silly and doesn't make any sense.",
+ __CLASS__));
}
$this->didRewind = true;
}
diff --git a/src/future/Future.php b/src/future/Future.php
--- a/src/future/Future.php
+++ b/src/future/Future.php
@@ -127,7 +127,7 @@
// anything because the SIGCHLD will interrupt the stream_select(), as
// long as we have a handler registered.
if (function_exists('pcntl_signal')) {
- if (!pcntl_signal(SIGCHLD, array('Future', 'handleSIGCHLD'))) {
+ if (!pcntl_signal(SIGCHLD, array(__CLASS__, 'handleSIGCHLD'))) {
throw new Exception('Failed to install signal handler!');
}
}
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
@@ -64,7 +64,9 @@
if (isset($parts['user']) || isset($parts['pass'])) {
throw new Exception(
- 'HTTP Basic Auth is not supported by HTTPFuture.');
+ pht(
+ 'HTTP Basic Auth is not supported by %s.',
+ __CLASS__));
}
if (isset($parts['path'])) {
@@ -106,7 +108,7 @@
}
private function getDefaultUserAgent() {
- return 'HTTPFuture/1.0';
+ return __CLASS__.'/1.0';
}
public function isReady() {
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
@@ -162,9 +162,10 @@
if (isset($this->files[$key])) {
throw new Exception(
pht(
- 'HTTPSFuture currently supports only one file attachment for each '.
+ '%s currently supports only one file attachment for each '.
'parameter name. You are trying to attach two different files with '.
'the same parameter, "%s".',
+ __CLASS__,
$key));
}
diff --git a/src/internationalization/PhutilLocale.php b/src/internationalization/PhutilLocale.php
--- a/src/internationalization/PhutilLocale.php
+++ b/src/internationalization/PhutilLocale.php
@@ -119,9 +119,10 @@
} else {
throw new Exception(
pht(
- 'Two subclasses of "PhutilLocale" ("%s" and "%s") define '.
+ 'Two subclasses of "%s" ("%s" and "%s") define '.
'locales with the same locale code ("%s"). Each locale must '.
'have a unique locale code.',
+ __CLASS__,
get_class($object),
get_class($locale_map[$locale_code]),
$locale_code));
diff --git a/src/parser/PhutilParserGenerator.php b/src/parser/PhutilParserGenerator.php
--- a/src/parser/PhutilParserGenerator.php
+++ b/src/parser/PhutilParserGenerator.php
@@ -769,7 +769,7 @@
public function generateParserFunction($name) {
$out = array();
$out[] = 'function '.$name.'(array $tokens, $callback) {';
- $out[] = ' return PhutilParserGenerator::parseTokensWithTables(';
+ $out[] = ' return '.__CLASS__.'::parseTokensWithTables(';
$out[] = ' '.$this->formatAndIndent($this->actionTable, 4).',';
$out[] = ' '.$this->formatAndIndent($this->gotoTable, 4).',';
$out[] = ' '.$this->formatAndIndent($this->getEOFSymbol(), 4).',';
diff --git a/src/serviceprofiler/PhutilServiceProfiler.php b/src/serviceprofiler/PhutilServiceProfiler.php
--- a/src/serviceprofiler/PhutilServiceProfiler.php
+++ b/src/serviceprofiler/PhutilServiceProfiler.php
@@ -58,7 +58,7 @@
public static function installEchoListener() {
$instance = self::getInstance();
- $instance->addListener(array('PhutilServiceProfiler', 'echoListener'));
+ $instance->addListener(array(__CLASS__, 'echoListener'));
}
public static function echoListener($type, $id, $data) {
diff --git a/src/utils/PhutilDirectedScalarGraph.php b/src/utils/PhutilDirectedScalarGraph.php
--- a/src/utils/PhutilDirectedScalarGraph.php
+++ b/src/utils/PhutilDirectedScalarGraph.php
@@ -8,8 +8,10 @@
protected function loadEdges(array $nodes) {
throw new Exception(
- 'PhutilDirectedScalarGraph can not load additional nodes at runtime. '.
- 'Tried to load: '.implode(', ', $nodes));
+ pht(
+ '%s can not load additional nodes at runtime. Tried to load: %s',
+ __CLASS__,
+ implode(', ', $nodes)));
}
}
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
@@ -213,7 +213,7 @@
$inputs = array(
'empty' => array(),
'stdClass' => array($object, $object),
- 'PhutilUtilsTestCase' => array($object, $this),
+ __CLASS__ => array($object, $this),
'array' => array(array(), array()),
'integer' => array($object, 1),
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jan 22, 8:29 PM (12 h, 28 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7035432
Default Alt Text
D12804.id30780.diff (16 KB)
Attached To
Mode
D12804: Use `__CLASS__` instead of hardcoding class names
Attached
Detach File
Event Timeline
Log In to Comment