final class Strings
Restricted visibility: declared "@visibility SqlSemantics". Code outside that scope must not name this declaration.

Decodes the spelling of a PostgreSQL string constant token into its value.

Rule: PG-LEX-STRING-001. Scope: the SCONST terminal in its four spellings and the BCONST and XCONST terminals. '...' reads a doubled quote as one quote and nothing else, because the profile fixes standard_conforming_strings = on. E'...' additionally reads the backslash escapes of the manual. $tag$...$tag$ is taken literally. U&'...' reads Unicode escapes with the escape character of its UESCAPE clause. Quoted segments separated by whitespace that contains a newline are one constant. An escape string that produces a zero byte or bytes that are not UTF-8 is rejected by the server scanner and is SQL outside the grammar. Source: https://www.postgresql.org/docs/17/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS. Termination: one pass over the token text. Status: Implemented.

Methods§

public function quoted(string $text, int $offset, bool $escapes): array{string, string}
public function continuation(string $text, int $offset): ?int

Finds the quote that continues a constant after whitespace and comments, or null.

Parameters

$textstring
$offsetint

Returns

?int
Test cases 1
Called from 2
Calls 2
public function escape(string $text, int $offset): array{string, int}

Decodes the backslash escape at an offset of an escape string.

Parameters

$textstring
$offsetint

Returns

array{string, int} The bytes it stands for and the offset after it

Throws

AnalysisException When the `xeunicode` rules of the scanner `scan.l` reject the escape
Test cases 2
Called from 1
Calls 9

Private surface 1§

Implementation details, listed for orientation only.

private const SINGLE = ['b' => "\x08", 'f' => "\f", 'n' => "\n", 'r' => "\r", 't' => "\t", 'v' => "\v"]

Test cases 13§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 13

Relations§

Instantiated in 5
Method calls 6