updated-packages
This commit is contained in:
88
vendor/symfony/var-dumper/Caster/PgSqlCaster.php
vendored
88
vendor/symfony/var-dumper/Caster/PgSqlCaster.php
vendored
@@ -17,10 +17,12 @@ use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
* Casts pqsql resources to array representation.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class PgSqlCaster
|
||||
{
|
||||
private static $paramCodes = array(
|
||||
private const PARAM_CODES = [
|
||||
'server_encoding',
|
||||
'client_encoding',
|
||||
'is_superuser',
|
||||
@@ -31,41 +33,41 @@ class PgSqlCaster
|
||||
'integer_datetimes',
|
||||
'application_name',
|
||||
'standard_conforming_strings',
|
||||
);
|
||||
];
|
||||
|
||||
private static $transactionStatus = array(
|
||||
PGSQL_TRANSACTION_IDLE => 'PGSQL_TRANSACTION_IDLE',
|
||||
PGSQL_TRANSACTION_ACTIVE => 'PGSQL_TRANSACTION_ACTIVE',
|
||||
PGSQL_TRANSACTION_INTRANS => 'PGSQL_TRANSACTION_INTRANS',
|
||||
PGSQL_TRANSACTION_INERROR => 'PGSQL_TRANSACTION_INERROR',
|
||||
PGSQL_TRANSACTION_UNKNOWN => 'PGSQL_TRANSACTION_UNKNOWN',
|
||||
);
|
||||
private const TRANSACTION_STATUS = [
|
||||
\PGSQL_TRANSACTION_IDLE => 'PGSQL_TRANSACTION_IDLE',
|
||||
\PGSQL_TRANSACTION_ACTIVE => 'PGSQL_TRANSACTION_ACTIVE',
|
||||
\PGSQL_TRANSACTION_INTRANS => 'PGSQL_TRANSACTION_INTRANS',
|
||||
\PGSQL_TRANSACTION_INERROR => 'PGSQL_TRANSACTION_INERROR',
|
||||
\PGSQL_TRANSACTION_UNKNOWN => 'PGSQL_TRANSACTION_UNKNOWN',
|
||||
];
|
||||
|
||||
private static $resultStatus = array(
|
||||
PGSQL_EMPTY_QUERY => 'PGSQL_EMPTY_QUERY',
|
||||
PGSQL_COMMAND_OK => 'PGSQL_COMMAND_OK',
|
||||
PGSQL_TUPLES_OK => 'PGSQL_TUPLES_OK',
|
||||
PGSQL_COPY_OUT => 'PGSQL_COPY_OUT',
|
||||
PGSQL_COPY_IN => 'PGSQL_COPY_IN',
|
||||
PGSQL_BAD_RESPONSE => 'PGSQL_BAD_RESPONSE',
|
||||
PGSQL_NONFATAL_ERROR => 'PGSQL_NONFATAL_ERROR',
|
||||
PGSQL_FATAL_ERROR => 'PGSQL_FATAL_ERROR',
|
||||
);
|
||||
private const RESULT_STATUS = [
|
||||
\PGSQL_EMPTY_QUERY => 'PGSQL_EMPTY_QUERY',
|
||||
\PGSQL_COMMAND_OK => 'PGSQL_COMMAND_OK',
|
||||
\PGSQL_TUPLES_OK => 'PGSQL_TUPLES_OK',
|
||||
\PGSQL_COPY_OUT => 'PGSQL_COPY_OUT',
|
||||
\PGSQL_COPY_IN => 'PGSQL_COPY_IN',
|
||||
\PGSQL_BAD_RESPONSE => 'PGSQL_BAD_RESPONSE',
|
||||
\PGSQL_NONFATAL_ERROR => 'PGSQL_NONFATAL_ERROR',
|
||||
\PGSQL_FATAL_ERROR => 'PGSQL_FATAL_ERROR',
|
||||
];
|
||||
|
||||
private static $diagCodes = array(
|
||||
'severity' => PGSQL_DIAG_SEVERITY,
|
||||
'sqlstate' => PGSQL_DIAG_SQLSTATE,
|
||||
'message' => PGSQL_DIAG_MESSAGE_PRIMARY,
|
||||
'detail' => PGSQL_DIAG_MESSAGE_DETAIL,
|
||||
'hint' => PGSQL_DIAG_MESSAGE_HINT,
|
||||
'statement position' => PGSQL_DIAG_STATEMENT_POSITION,
|
||||
'internal position' => PGSQL_DIAG_INTERNAL_POSITION,
|
||||
'internal query' => PGSQL_DIAG_INTERNAL_QUERY,
|
||||
'context' => PGSQL_DIAG_CONTEXT,
|
||||
'file' => PGSQL_DIAG_SOURCE_FILE,
|
||||
'line' => PGSQL_DIAG_SOURCE_LINE,
|
||||
'function' => PGSQL_DIAG_SOURCE_FUNCTION,
|
||||
);
|
||||
private const DIAG_CODES = [
|
||||
'severity' => \PGSQL_DIAG_SEVERITY,
|
||||
'sqlstate' => \PGSQL_DIAG_SQLSTATE,
|
||||
'message' => \PGSQL_DIAG_MESSAGE_PRIMARY,
|
||||
'detail' => \PGSQL_DIAG_MESSAGE_DETAIL,
|
||||
'hint' => \PGSQL_DIAG_MESSAGE_HINT,
|
||||
'statement position' => \PGSQL_DIAG_STATEMENT_POSITION,
|
||||
'internal position' => \PGSQL_DIAG_INTERNAL_POSITION,
|
||||
'internal query' => \PGSQL_DIAG_INTERNAL_QUERY,
|
||||
'context' => \PGSQL_DIAG_CONTEXT,
|
||||
'file' => \PGSQL_DIAG_SOURCE_FILE,
|
||||
'line' => \PGSQL_DIAG_SOURCE_LINE,
|
||||
'function' => \PGSQL_DIAG_SOURCE_FUNCTION,
|
||||
];
|
||||
|
||||
public static function castLargeObject($lo, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
@@ -77,12 +79,12 @@ class PgSqlCaster
|
||||
public static function castLink($link, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$a['status'] = pg_connection_status($link);
|
||||
$a['status'] = new ConstStub(PGSQL_CONNECTION_OK === $a['status'] ? 'PGSQL_CONNECTION_OK' : 'PGSQL_CONNECTION_BAD', $a['status']);
|
||||
$a['status'] = new ConstStub(\PGSQL_CONNECTION_OK === $a['status'] ? 'PGSQL_CONNECTION_OK' : 'PGSQL_CONNECTION_BAD', $a['status']);
|
||||
$a['busy'] = pg_connection_busy($link);
|
||||
|
||||
$a['transaction'] = pg_transaction_status($link);
|
||||
if (isset(self::$transactionStatus[$a['transaction']])) {
|
||||
$a['transaction'] = new ConstStub(self::$transactionStatus[$a['transaction']], $a['transaction']);
|
||||
if (isset(self::TRANSACTION_STATUS[$a['transaction']])) {
|
||||
$a['transaction'] = new ConstStub(self::TRANSACTION_STATUS[$a['transaction']], $a['transaction']);
|
||||
}
|
||||
|
||||
$a['pid'] = pg_get_pid($link);
|
||||
@@ -94,7 +96,7 @@ class PgSqlCaster
|
||||
$a['options'] = pg_options($link);
|
||||
$a['version'] = pg_version($link);
|
||||
|
||||
foreach (self::$paramCodes as $v) {
|
||||
foreach (self::PARAM_CODES as $v) {
|
||||
if (false !== $s = pg_parameter_status($link, $v)) {
|
||||
$a['param'][$v] = $s;
|
||||
}
|
||||
@@ -110,13 +112,13 @@ class PgSqlCaster
|
||||
{
|
||||
$a['num rows'] = pg_num_rows($result);
|
||||
$a['status'] = pg_result_status($result);
|
||||
if (isset(self::$resultStatus[$a['status']])) {
|
||||
$a['status'] = new ConstStub(self::$resultStatus[$a['status']], $a['status']);
|
||||
if (isset(self::RESULT_STATUS[$a['status']])) {
|
||||
$a['status'] = new ConstStub(self::RESULT_STATUS[$a['status']], $a['status']);
|
||||
}
|
||||
$a['command-completion tag'] = pg_result_status($result, PGSQL_STATUS_STRING);
|
||||
$a['command-completion tag'] = pg_result_status($result, \PGSQL_STATUS_STRING);
|
||||
|
||||
if (-1 === $a['num rows']) {
|
||||
foreach (self::$diagCodes as $k => $v) {
|
||||
foreach (self::DIAG_CODES as $k => $v) {
|
||||
$a['error'][$k] = pg_result_error_field($result, $v);
|
||||
}
|
||||
}
|
||||
@@ -127,14 +129,14 @@ class PgSqlCaster
|
||||
$fields = pg_num_fields($result);
|
||||
|
||||
for ($i = 0; $i < $fields; ++$i) {
|
||||
$field = array(
|
||||
$field = [
|
||||
'name' => pg_field_name($result, $i),
|
||||
'table' => sprintf('%s (OID: %s)', pg_field_table($result, $i), pg_field_table($result, $i, true)),
|
||||
'type' => sprintf('%s (OID: %s)', pg_field_type($result, $i), pg_field_type_oid($result, $i)),
|
||||
'nullable' => (bool) pg_field_is_null($result, $i),
|
||||
'storage' => pg_field_size($result, $i).' bytes',
|
||||
'display' => pg_field_prtlen($result, $i).' chars',
|
||||
);
|
||||
];
|
||||
if (' (OID: )' === $field['table']) {
|
||||
$field['table'] = null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user