Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15365801
D21500.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D21500.id.diff
View Options
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
@@ -94,7 +94,10 @@
$argv = array($format->evalStatic()) + array_fill(0, $argc, null);
try {
- xsprintf(null, null, $argv);
+ xsprintf(
+ 'ArcanistFormattedStringXHPASTLinterRule::processXsprintfCallback',
+ null,
+ $argv);
} catch (BadFunctionCallException $ex) {
$this->raiseLintAtNode(
$call,
@@ -105,4 +108,23 @@
}
}
+ public static function processXsprintfCallback(
+ $userdata,
+ &$pattern,
+ &$pos,
+ &$value,
+ &$length) {
+
+ if ($value !== null) {
+ throw new Exception('Expected dummy value to be null');
+ }
+
+ // Turn format "%$pattern" with argument null into format "%s" with
+ // argument "%$pattern". This ensures we always provide valid input for
+ // sprintf to avoid getting a ValueError when using custom format
+ // specifiers.
+ $value = '%'.$pattern[$pos];
+ $pattern[$pos] = 's';
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 12, 2:08 PM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7375991
Default Alt Text
D21500.id.diff (1 KB)
Attached To
Mode
D21500: Fix ArcanistFormattedStringXHPASTLinterRule for PHP 8
Attached
Detach File
Event Timeline
Log In to Comment