Skip to content

Commit

Permalink
Fix indentation
Browse files Browse the repository at this point in the history
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
  • Loading branch information
kamil-tekiela committed Oct 9, 2022
1 parent 23995b3 commit 99fb81b
Showing 1 changed file with 44 additions and 44 deletions.
88 changes: 44 additions & 44 deletions libraries/classes/FieldMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,50 +227,50 @@ final class FieldMetadata

public function __construct(int $fieldType, int $fieldFlags, object $field)
{
$this->mappedType = $this->getTypeMap()[$fieldType] ?? null;

$this->isMultipleKey = (bool) ($fieldFlags & MYSQLI_MULTIPLE_KEY_FLAG);
$this->isPrimaryKey = (bool) ($fieldFlags & MYSQLI_PRI_KEY_FLAG);
$this->isUniqueKey = (bool) ($fieldFlags & MYSQLI_UNIQUE_KEY_FLAG);
$this->isNotNull = (bool) ($fieldFlags & MYSQLI_NOT_NULL_FLAG);
$this->isUnsigned = (bool) ($fieldFlags & MYSQLI_UNSIGNED_FLAG);
$this->isZerofill = (bool) ($fieldFlags & MYSQLI_ZEROFILL_FLAG);

// as flags 32768 can be NUM_FLAG or GROUP_FLAG
// reference: https://www.php.net/manual/en/mysqli-result.fetch-fields.php
// so check field type instead of flags
// but if no or unknown field type then check flags
$this->isNumeric = $this->isType(self::TYPE_INT)
|| ($fieldType <= 0 && ($fieldFlags & MYSQLI_NUM_FLAG));

$this->isBlob = (bool) ($fieldFlags & MYSQLI_BLOB_FLAG);
$this->isEnum = (bool) ($fieldFlags & MYSQLI_ENUM_FLAG);
$this->isSet = (bool) ($fieldFlags & MYSQLI_SET_FLAG);

/*
MYSQLI_PART_KEY_FLAG => 'part_key',
MYSQLI_TIMESTAMP_FLAG => 'timestamp',
MYSQLI_AUTO_INCREMENT_FLAG => 'auto_increment',
*/

$this->isMappedTypeBit = $this->isType(self::TYPE_BIT);
$this->isMappedTypeGeometry = $this->isType(self::TYPE_GEOMETRY);
$this->isMappedTypeTimestamp = $this->isType(self::TYPE_TIMESTAMP);

$this->name = property_exists($field, 'name') ? $field->name : '';
$this->orgname = property_exists($field, 'orgname') ? $field->orgname : '';
$this->table = property_exists($field, 'table') ? $field->table : '';
$this->orgtable = property_exists($field, 'orgtable') ? $field->orgtable : '';
$this->charsetnr = property_exists($field, 'charsetnr') ? $field->charsetnr : -1;
$this->decimals = property_exists($field, 'decimals') ? $field->decimals : 0;
$this->length = property_exists($field, 'length') ? $field->length : 0;

// 63 is the number for the MySQL charset "binary"
$this->isBinary = (
$fieldType === MYSQLI_TYPE_TINY_BLOB || $fieldType === MYSQLI_TYPE_BLOB
|| $fieldType === MYSQLI_TYPE_MEDIUM_BLOB || $fieldType === MYSQLI_TYPE_LONG_BLOB
|| $fieldType === MYSQLI_TYPE_VAR_STRING || $fieldType === MYSQLI_TYPE_STRING
) && $this->charsetnr == 63;
$this->mappedType = $this->getTypeMap()[$fieldType] ?? null;

$this->isMultipleKey = (bool) ($fieldFlags & MYSQLI_MULTIPLE_KEY_FLAG);
$this->isPrimaryKey = (bool) ($fieldFlags & MYSQLI_PRI_KEY_FLAG);
$this->isUniqueKey = (bool) ($fieldFlags & MYSQLI_UNIQUE_KEY_FLAG);
$this->isNotNull = (bool) ($fieldFlags & MYSQLI_NOT_NULL_FLAG);
$this->isUnsigned = (bool) ($fieldFlags & MYSQLI_UNSIGNED_FLAG);
$this->isZerofill = (bool) ($fieldFlags & MYSQLI_ZEROFILL_FLAG);

// as flags 32768 can be NUM_FLAG or GROUP_FLAG
// reference: https://www.php.net/manual/en/mysqli-result.fetch-fields.php
// so check field type instead of flags
// but if no or unknown field type then check flags
$this->isNumeric = $this->isType(self::TYPE_INT)
|| ($fieldType <= 0 && ($fieldFlags & MYSQLI_NUM_FLAG));

$this->isBlob = (bool) ($fieldFlags & MYSQLI_BLOB_FLAG);
$this->isEnum = (bool) ($fieldFlags & MYSQLI_ENUM_FLAG);
$this->isSet = (bool) ($fieldFlags & MYSQLI_SET_FLAG);

/*
MYSQLI_PART_KEY_FLAG => 'part_key',
MYSQLI_TIMESTAMP_FLAG => 'timestamp',
MYSQLI_AUTO_INCREMENT_FLAG => 'auto_increment',
*/

$this->isMappedTypeBit = $this->isType(self::TYPE_BIT);
$this->isMappedTypeGeometry = $this->isType(self::TYPE_GEOMETRY);
$this->isMappedTypeTimestamp = $this->isType(self::TYPE_TIMESTAMP);

$this->name = property_exists($field, 'name') ? $field->name : '';
$this->orgname = property_exists($field, 'orgname') ? $field->orgname : '';
$this->table = property_exists($field, 'table') ? $field->table : '';
$this->orgtable = property_exists($field, 'orgtable') ? $field->orgtable : '';
$this->charsetnr = property_exists($field, 'charsetnr') ? $field->charsetnr : -1;
$this->decimals = property_exists($field, 'decimals') ? $field->decimals : 0;
$this->length = property_exists($field, 'length') ? $field->length : 0;

// 63 is the number for the MySQL charset "binary"
$this->isBinary = (
$fieldType === MYSQLI_TYPE_TINY_BLOB || $fieldType === MYSQLI_TYPE_BLOB
|| $fieldType === MYSQLI_TYPE_MEDIUM_BLOB || $fieldType === MYSQLI_TYPE_LONG_BLOB
|| $fieldType === MYSQLI_TYPE_VAR_STRING || $fieldType === MYSQLI_TYPE_STRING
) && $this->charsetnr == 63;
}

/**
Expand Down

0 comments on commit 99fb81b

Please sign in to comment.