Skip to content

Commit a106296

Browse files
committed
Rename string escaping methods
1 parent 5e4dbbe commit a106296

File tree

8 files changed

+30
-30
lines changed

8 files changed

+30
-30
lines changed

src/Internal/AbstractHandle.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,16 @@ public function rollback(): void
106106

107107
public function createSavepoint(string $identifier): void
108108
{
109-
$this->query("SAVEPOINT " . $this->quoteName($identifier));
109+
$this->query("SAVEPOINT " . $this->quoteIdentifier($identifier));
110110
}
111111

112112
public function rollbackTo(string $identifier): void
113113
{
114-
$this->query("ROLLBACK TO " . $this->quoteName($identifier));
114+
$this->query("ROLLBACK TO " . $this->quoteIdentifier($identifier));
115115
}
116116

117117
public function releaseSavepoint(string $identifier): void
118118
{
119-
$this->query("RELEASE SAVEPOINT " . $this->quoteName($identifier));
119+
$this->query("RELEASE SAVEPOINT " . $this->quoteIdentifier($identifier));
120120
}
121121
}

src/Internal/PgSqlHandle.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -456,10 +456,10 @@ public function prepare(string $sql): PostgresStatement
456456
public function notify(string $channel, string $payload = ""): PostgresResult
457457
{
458458
if ($payload === "") {
459-
return $this->query(\sprintf("NOTIFY %s", $this->quoteName($channel)));
459+
return $this->query(\sprintf("NOTIFY %s", $this->quoteIdentifier($channel)));
460460
}
461461

462-
return $this->query(\sprintf("NOTIFY %s, %s", $this->quoteName($channel), $this->quoteString($payload)));
462+
return $this->query(\sprintf("NOTIFY %s, %s", $this->quoteIdentifier($channel), $this->quoteLiteral($payload)));
463463
}
464464

465465
public function listen(string $channel): PostgresListener
@@ -471,7 +471,7 @@ public function listen(string $channel): PostgresListener
471471
$this->listeners[$channel] = $source = new Queue();
472472

473473
try {
474-
$this->query(\sprintf("LISTEN %s", $this->quoteName($channel)));
474+
$this->query(\sprintf("LISTEN %s", $this->quoteIdentifier($channel)));
475475
} catch (\Throwable $exception) {
476476
unset($this->listeners[$channel]);
477477
throw $exception;
@@ -499,14 +499,14 @@ private function unlisten(string $channel): void
499499
}
500500

501501
try {
502-
$this->query(\sprintf("UNLISTEN %s", $this->quoteName($channel)));
502+
$this->query(\sprintf("UNLISTEN %s", $this->quoteIdentifier($channel)));
503503
$source->complete();
504504
} catch (\Throwable $exception) {
505505
$source->error($exception);
506506
}
507507
}
508508

509-
public function quoteString(string $data): string
509+
public function quoteLiteral(string $data): string
510510
{
511511
if ($this->handle === null) {
512512
throw new \Error("The connection to the database has been closed");
@@ -515,7 +515,7 @@ public function quoteString(string $data): string
515515
return \pg_escape_literal($this->handle, $data);
516516
}
517517

518-
public function quoteName(string $name): string
518+
public function quoteIdentifier(string $name): string
519519
{
520520
if ($this->handle === null) {
521521
throw new \Error("The connection to the database has been closed");

src/Internal/PostgresHandleConnection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,14 @@ final public function setTransactionIsolation(TransactionIsolation $isolation):
145145
$this->transactionIsolation = $isolation;
146146
}
147147

148-
final public function quoteString(string $data): string
148+
final public function quoteLiteral(string $data): string
149149
{
150-
return $this->handle->quoteString($data);
150+
return $this->handle->quoteLiteral($data);
151151
}
152152

153-
final public function quoteName(string $name): string
153+
final public function quoteIdentifier(string $name): string
154154
{
155-
return $this->handle->quoteName($name);
155+
return $this->handle->quoteIdentifier($name);
156156
}
157157

158158
final public function escapeByteA(string $data): string

src/Internal/PostgresTransactionDelegate.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ public function notify(string $channel, string $payload = ""): PostgresResult
7575
return $this->getExecutor()->notify($channel, $payload);
7676
}
7777

78-
public function quoteString(string $data): string
78+
public function quoteLiteral(string $data): string
7979
{
80-
return $this->getExecutor()->quoteString($data);
80+
return $this->getExecutor()->quoteLiteral($data);
8181
}
8282

83-
public function quoteName(string $name): string
83+
public function quoteIdentifier(string $name): string
8484
{
85-
return $this->getExecutor()->quoteName($name);
85+
return $this->getExecutor()->quoteIdentifier($name);
8686
}
8787

8888
public function escapeByteA(string $data): string

src/Internal/PqHandle.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ private function unlisten(string $channel): void
483483
}
484484
}
485485

486-
public function quoteString(string $data): string
486+
public function quoteLiteral(string $data): string
487487
{
488488
if (!$this->handle) {
489489
throw new \Error("The connection to the database has been closed");
@@ -492,7 +492,7 @@ public function quoteString(string $data): string
492492
return $this->handle->quote($data);
493493
}
494494

495-
public function quoteName(string $name): string
495+
public function quoteIdentifier(string $name): string
496496
{
497497
if (!$this->handle) {
498498
throw new \Error("The connection to the database has been closed");

src/PostgresConnectionPool.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,23 +151,23 @@ public function listen(string $channel): PostgresListener
151151
});
152152
}
153153

154-
public function quoteString(string $data): string
154+
public function quoteLiteral(string $data): string
155155
{
156156
$connection = $this->pop();
157157

158158
try {
159-
return $connection->quoteString($data);
159+
return $connection->quoteLiteral($data);
160160
} finally {
161161
$this->push($connection);
162162
}
163163
}
164164

165-
public function quoteName(string $name): string
165+
public function quoteIdentifier(string $name): string
166166
{
167167
$connection = $this->pop();
168168

169169
try {
170-
return $connection->quoteName($name);
170+
return $connection->quoteIdentifier($name);
171171
} finally {
172172
$this->push($connection);
173173
}

src/PostgresExecutor.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,27 @@ public function execute(string $sql, array $params = []): PostgresResult;
3636
public function notify(string $channel, string $payload = ""): PostgresResult;
3737

3838
/**
39-
* Quotes (escapes) the given string for use as a string literal or identifier in a query. This method wraps the
39+
* Quotes (escapes) the given string for use as a string literal in a query. This method wraps the
4040
* string in single quotes, so additional quotes should not be added in the query.
4141
*
4242
* @param string $data Unquoted data.
4343
*
44-
* @return string Quoted string wrapped in single quotes.
44+
* @return string Quoted string literal.
4545
*
4646
* @throws \Error If the connection to the database has been closed.
4747
*/
48-
public function quoteString(string $data): string;
48+
public function quoteLiteral(string $data): string;
4949

5050
/**
51-
* Quotes (escapes) the given string for use as a name or identifier in a query.
51+
* Quotes (escapes) the given string for use as an identifier in a query.
5252
*
5353
* @param string $name Unquoted identifier.
5454
*
5555
* @return string Quoted identifier.
5656
*
5757
* @throws \Error If the connection to the database has been closed.
5858
*/
59-
public function quoteName(string $name): string;
59+
public function quoteIdentifier(string $name): string;
6060

6161
/**
6262
* Escapes a binary string to be used as BYTEA data.

test/AbstractQuoteTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ public function testEscapeByteA(): void
2828

2929
public function testQuoteString(): void
3030
{
31-
$this->assertSame("'\"''test''\"'", $this->connection->quoteString("\"'test'\""));
31+
$this->assertSame("'\"''test''\"'", $this->connection->quoteLiteral("\"'test'\""));
3232
}
3333

3434
public function testQuoteName(): void
3535
{
36-
$this->assertSame("\"\"\"'test'\"\"\"", $this->connection->quoteName("\"'test'\""));
36+
$this->assertSame("\"\"\"'test'\"\"\"", $this->connection->quoteIdentifier("\"'test'\""));
3737
}
3838
}

0 commit comments

Comments
 (0)