Skip to content

Commit

Permalink
Change property Schema::$typeMap to constant Schema::TYPE_MAP (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov authored Nov 16, 2023
1 parent e3d9164 commit fd45a0b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 1.1.1 under development

- Enh #281: Remove unused code in `Command` class (@vjik)
- Enh #282: Change property `Schema::$typeMap` to constant `Schema::TYPE_MAP` (@Tigrov)

## 1.1.0 November 12, 2023

Expand Down
10 changes: 6 additions & 4 deletions src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@
final class Schema extends AbstractPdoSchema
{
/**
* @var string[] Mapping from physical column types (keys) to abstract column types (values).
* Mapping from physical column types (keys) to abstract column types (values).
*
* @var string[]
*/
private array $typeMap = [
private const TYPE_MAP = [
'tinyint' => self::TYPE_TINYINT,
'bit' => self::TYPE_SMALLINT,
'boolean' => self::TYPE_BOOLEAN,
Expand Down Expand Up @@ -481,8 +483,8 @@ protected function loadColumnSchema(array $info): ColumnSchemaInterface
if (preg_match('/^(\w+)(?:\(([^)]+)\))?/', $column->getDbType() ?? '', $matches)) {
$type = strtolower($matches[1]);

if (isset($this->typeMap[$type])) {
$column->type($this->typeMap[$type]);
if (isset(self::TYPE_MAP[$type])) {
$column->type(self::TYPE_MAP[$type]);
}

if (!empty($matches[2])) {
Expand Down

0 comments on commit fd45a0b

Please sign in to comment.