Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change $typeMap to constant #324

Merged
merged 3 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## 1.2.1 under development

- no changes in this release.
- Enh #324: Change property `Schema::$typeMap` to constant `Schema::TYPE_MAP` (@Tigrov)

## 1.2.0 November 12, 2023

Expand Down
10 changes: 5 additions & 5 deletions src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@
public const TYPE_BIT = 'bit';

/**
* @var array The mapping from physical column types (keys) to abstract column types (values).
* The mapping from physical column types (keys) to abstract column types (values).
*
* @link https://www.postgresql.org/docs/current/static/datatype.html#DATATYPE-TABLE
* @link https://www.postgresql.org/docs/current/datatype.html#DATATYPE-TABLE
*
* @psalm-var string[]
* @var string[]
*/
private array $typeMap = [
private const TYPE_MAP = [
'bit' => self::TYPE_BIT,
'bit varying' => self::TYPE_BIT,
'varbit' => self::TYPE_BIT,
Expand Down Expand Up @@ -807,7 +807,7 @@
$column->sequenceName($this->resolveTableName($info['sequence_name'])->getFullName());
}

$column->type($this->typeMap[(string) $column->getDbType()] ?? self::TYPE_STRING);
$column->type(self::TYPE_MAP[(string) $column->getDbType()] ?? self::TYPE_STRING);
$column->phpType($this->getColumnPhpType($column));
$column->defaultValue($this->normalizeDefaultValue($defaultValue, $column));

Expand Down Expand Up @@ -1033,6 +1033,6 @@
*/
protected function getCacheTag(): string
{
return md5(serialize(array_merge([self::class], $this->generateCacheKey())));

Check warning on line 1036 in src/Schema.php

View workflow job for this annotation

GitHub Actions / PHP 8-ubuntu-latest

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ */ protected function getCacheTag() : string { - return md5(serialize(array_merge([self::class], $this->generateCacheKey()))); + return md5(serialize(array_merge([], $this->generateCacheKey()))); } }
}
}
Loading