Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / infrastructure / storage / xsprintf / PhutilQueryString.php
blob64a7f55b9e4d5a8fb01ddbeea9d7949f0180d4da
1 <?php
3 final class PhutilQueryString extends Phobject {
5 private $maskedString;
6 private $unmaskedString;
8 public function __construct(PhutilQsprintfInterface $escaper, array $argv) {
9 // Immediately render the query into a static scalar value.
11 // This makes sure we throw immediately if there are errors in the
12 // parameters, which is much better than throwing later on.
14 // This also makes sure that later mutations to objects passed as
15 // parameters won't affect the outcome. Consider:
17 // $object->setTableName('X');
18 // $query = qsprintf($conn, '%R', $object);
19 // $object->setTableName('Y');
21 // We'd like "$query" to reference "X", reflecting the object as it
22 // existed when it was passed to "qsprintf(...)". It's surprising if the
23 // modification to the object after "qsprintf(...)" can affect "$query".
25 $masked_string = xsprintf(
26 'xsprintf_query',
27 array(
28 'escaper' => $escaper,
29 'unmasked' => false,
31 $argv);
33 $unmasked_string = xsprintf(
34 'xsprintf_query',
35 array(
36 'escaper' => $escaper,
37 'unmasked' => true,
39 $argv);
41 $this->maskedString = $masked_string;
42 $this->unmaskedString = $unmasked_string;
45 public function __toString() {
46 return $this->getMaskedString();
49 public function getUnmaskedString() {
50 return $this->unmaskedString;
53 public function getMaskedString() {
54 return $this->maskedString;