From ddfae0a3c4c24f5b90c2f548c6b6b5faac458454 Mon Sep 17 00:00:00 2001 From: Simon Mundy Date: Tue, 4 Aug 2026 13:17:17 +1000 Subject: [PATCH 1/2] Reformatting for linting, format and analysis with Mago --- src/Metadata/MetadataInterface.php | 32 +- src/Metadata/Object/AbstractTableObject.php | 15 +- src/Metadata/Object/ColumnObject.php | 59 ++-- src/Metadata/Object/ConstraintKeyObject.php | 18 +- src/Metadata/Object/ConstraintObject.php | 40 +-- src/Metadata/Object/TableObject.php | 2 +- src/Metadata/Object/TriggerObject.php | 35 ++- src/Metadata/Object/ViewObject.php | 2 +- src/Metadata/Source/AbstractSource.php | 324 ++++++++++++++------ 9 files changed, 339 insertions(+), 188 deletions(-) diff --git a/src/Metadata/MetadataInterface.php b/src/Metadata/MetadataInterface.php index ad3dba69..0e32c14e 100644 --- a/src/Metadata/MetadataInterface.php +++ b/src/Metadata/MetadataInterface.php @@ -11,14 +11,22 @@ use PhpDb\Metadata\Object\TriggerObject; use PhpDb\Metadata\Object\ViewObject; +/** + * @api + * + * @mago-expect lint:too-many-methods + */ interface MetadataInterface { public function getColumn(string $columnName, string $table, ?string $schema = null): ColumnObject; + /** + * @return list + */ public function getColumnNames(string $table, ?string $schema = null): array; /** - * @return ColumnObject[] + * @return list */ public function getColumns(string $table, ?string $schema = null): array; @@ -29,53 +37,57 @@ public function getConstraint( ): ConstraintObject; /** - * @return ConstraintKeyObject[] + * @return list */ public function getConstraintKeys(string $constraint, string $table, ?string $schema = null): array; /** - * @return ConstraintObject[] + * @return list */ public function getConstraints(string $table, ?string $schema = null): array; /** - * @return string[] + * @return list */ public function getSchemas(): array; public function getTable(string $tableName, ?string $schema = null): TableObject|ViewObject; /** - * @return string[] + * @return list + * + * @mago-expect lint:no-boolean-flag-parameter */ public function getTableNames(?string $schema = null, bool $includeViews = false): array; /** - * @return TableObject[] + * @return list + * + * @mago-expect lint:no-boolean-flag-parameter */ public function getTables(?string $schema = null, bool $includeViews = false): array; public function getTrigger(string $triggerName, ?string $schema = null): TriggerObject; /** - * @return string[] + * @return list */ public function getTriggerNames(?string $schema = null): array; /** - * @return TriggerObject[] + * @return list */ public function getTriggers(?string $schema = null): array; public function getView(string $viewName, ?string $schema = null): ViewObject|TableObject; /** - * @return string[] + * @return list */ public function getViewNames(?string $schema = null): array; /** - * @return ViewObject[] + * @return list */ public function getViews(?string $schema = null): array; } diff --git a/src/Metadata/Object/AbstractTableObject.php b/src/Metadata/Object/AbstractTableObject.php index 894f1ff8..8c57f78d 100644 --- a/src/Metadata/Object/AbstractTableObject.php +++ b/src/Metadata/Object/AbstractTableObject.php @@ -4,16 +4,19 @@ namespace PhpDb\Metadata\Object; +/** + * @api + */ abstract class AbstractTableObject { protected ?string $name = null; protected ?string $type = null; - /** @var array|null */ + /** @var list|null */ protected ?array $columns = null; - /** @var array|null */ + /** @var list|null */ protected ?array $constraints = null; /** @@ -29,7 +32,7 @@ public function __construct(?string $name = null) /** * Get columns * - * @return array|null + * @return list|null */ public function getColumns(): ?array { @@ -39,7 +42,7 @@ public function getColumns(): ?array /** * Get constraints * - * @return array|null + * @return list|null */ public function getConstraints(): ?array { @@ -56,6 +59,8 @@ public function getName(): ?string /** * Set columns + * + * @param list $columns */ public function setColumns(array $columns): void { @@ -64,6 +69,8 @@ public function setColumns(array $columns): void /** * Set constraints + * + * @param list $constraints */ public function setConstraints(array $constraints): void { diff --git a/src/Metadata/Object/ColumnObject.php b/src/Metadata/Object/ColumnObject.php index 286b0073..b648a2a3 100644 --- a/src/Metadata/Object/ColumnObject.php +++ b/src/Metadata/Object/ColumnObject.php @@ -6,46 +6,34 @@ use function array_key_exists; -class ColumnObject +final class ColumnObject { - protected string $name; + private ?int $ordinalPosition = null; - protected string $tableName; + private string|int|bool|null $columnDefault = null; - protected ?string $schemaName = null; + private ?bool $isNullable = null; - protected ?int $ordinalPosition = null; + private ?string $dataType = null; - protected string|int|bool|null $columnDefault = null; + private ?int $characterMaximumLength = null; - protected ?bool $isNullable = null; + private ?int $characterOctetLength = null; - protected ?string $dataType = null; + private ?int $numericPrecision = null; - protected ?int $characterMaximumLength = null; + private ?int $numericScale = null; - protected ?int $characterOctetLength = null; + private ?bool $numericUnsigned = null; - protected ?int $numericPrecision = null; + /** @var array */ + private array $errata = []; - protected ?int $numericScale = null; - - protected ?bool $numericUnsigned = null; - - protected array $errata = []; - - /** - * Constructor - */ - public function __construct(string $name, string $tableName, ?string $schemaName = null) - { - $this->setName($name); - $this->setTableName($tableName); - - if (null !== $schemaName) { - $this->setSchemaName($schemaName); - } - } + public function __construct( + private string $name, + private string $tableName, + private ?string $schemaName = null, + ) {} /** * @return int|null the $characterMaximumLength @@ -64,9 +52,9 @@ public function getCharacterOctetLength(): ?int } /** - * @return null|string the $columnDefault + * @return string|int|bool|null the $columnDefault */ - public function getColumnDefault(): ?string + public function getColumnDefault(): string|int|bool|null { return $this->columnDefault; } @@ -89,7 +77,7 @@ public function getErrata(string $errataName): mixed } /** - * @return array the $errata + * @return array the $errata */ public function getErratas(): array { @@ -192,11 +180,12 @@ public function setErrata(string $errataName, mixed $errataValue): static return $this; } + /** + * @param array $erratas + */ public function setErratas(array $erratas): static { - foreach ($erratas as $name => $value) { - $this->setErrata($name, $value); - } + $this->errata = [...$this->errata, ...$erratas]; return $this; } diff --git a/src/Metadata/Object/ConstraintKeyObject.php b/src/Metadata/Object/ConstraintKeyObject.php index f9aacf63..973e3de3 100644 --- a/src/Metadata/Object/ConstraintKeyObject.php +++ b/src/Metadata/Object/ConstraintKeyObject.php @@ -4,7 +4,7 @@ namespace PhpDb\Metadata\Object; -class ConstraintKeyObject +final class ConstraintKeyObject { final public const FK_CASCADE = 'CASCADE'; @@ -16,25 +16,25 @@ class ConstraintKeyObject final public const FK_SET_DEFAULT = 'SET DEFAULT'; - protected ?int $ordinalPosition = null; + private ?int $ordinalPosition = null; - protected ?bool $positionInUniqueConstraint = null; + private ?bool $positionInUniqueConstraint = null; - protected ?string $referencedTableSchema = null; + private ?string $referencedTableSchema = null; - protected ?string $referencedTableName = null; + private ?string $referencedTableName = null; - protected ?string $referencedColumnName = null; + private ?string $referencedColumnName = null; - protected ?string $foreignKeyUpdateRule = null; + private ?string $foreignKeyUpdateRule = null; - protected ?string $foreignKeyDeleteRule = null; + private ?string $foreignKeyDeleteRule = null; /** * Constructor */ public function __construct( - protected string $columnName, + private string $columnName, ) {} /** diff --git a/src/Metadata/Object/ConstraintObject.php b/src/Metadata/Object/ConstraintObject.php index 549c1891..9efd6934 100644 --- a/src/Metadata/Object/ConstraintObject.php +++ b/src/Metadata/Object/ConstraintObject.php @@ -4,49 +4,39 @@ namespace PhpDb\Metadata\Object; -class ConstraintObject +final class ConstraintObject { - protected string $name; - - protected string $tableName; - - protected ?string $schemaName = null; - /** * One of "PRIMARY KEY", "UNIQUE", "FOREIGN KEY", or "CHECK" */ - protected ?string $type = null; + private ?string $type = null; /** @var string[] */ - protected array $columns = []; + private array $columns = []; - protected ?string $referencedTableSchema = null; + private ?string $referencedTableSchema = null; - protected ?string $referencedTableName = null; + private ?string $referencedTableName = null; /** @var string[]|null */ - protected ?array $referencedColumns = null; + private ?array $referencedColumns = null; - protected ?string $matchOption = null; + private ?string $matchOption = null; - protected ?string $updateRule = null; + private ?string $updateRule = null; - protected ?string $deleteRule = null; + private ?string $deleteRule = null; - protected ?string $checkClause = null; + private ?string $checkClause = null; /** * Constructor */ - public function __construct(string $name, string $tableName, ?string $schemaName = null) - { - $this->setName($name); - $this->setTableName($tableName); - - if (null !== $schemaName) { - $this->setSchemaName($schemaName); - } - } + public function __construct( + private string $name, + private string $tableName, + private ?string $schemaName = null, + ) {} /** * Get Check Clause. diff --git a/src/Metadata/Object/TableObject.php b/src/Metadata/Object/TableObject.php index 0c767221..ccedbed6 100644 --- a/src/Metadata/Object/TableObject.php +++ b/src/Metadata/Object/TableObject.php @@ -4,4 +4,4 @@ namespace PhpDb\Metadata\Object; -class TableObject extends AbstractTableObject {} +final class TableObject extends AbstractTableObject {} diff --git a/src/Metadata/Object/TriggerObject.php b/src/Metadata/Object/TriggerObject.php index 20e7650e..7838f4ec 100644 --- a/src/Metadata/Object/TriggerObject.php +++ b/src/Metadata/Object/TriggerObject.php @@ -6,37 +6,40 @@ use DateTime; -class TriggerObject +/** + * @mago-expect lint:too-many-properties + */ +final class TriggerObject { - protected ?string $name = null; + private ?string $name = null; - protected ?string $eventManipulation = null; + private ?string $eventManipulation = null; - protected ?string $eventObjectCatalog = null; + private ?string $eventObjectCatalog = null; - protected ?string $eventObjectSchema = null; + private ?string $eventObjectSchema = null; - protected ?string $eventObjectTable = null; + private ?string $eventObjectTable = null; - protected ?string $actionOrder = null; + private ?string $actionOrder = null; - protected ?string $actionCondition = null; + private ?string $actionCondition = null; - protected ?string $actionStatement = null; + private ?string $actionStatement = null; - protected ?string $actionOrientation = null; + private ?string $actionOrientation = null; - protected ?string $actionTiming = null; + private ?string $actionTiming = null; - protected ?string $actionReferenceOldTable = null; + private ?string $actionReferenceOldTable = null; - protected ?string $actionReferenceNewTable = null; + private ?string $actionReferenceNewTable = null; - protected ?string $actionReferenceOldRow = null; + private ?string $actionReferenceOldRow = null; - protected ?string $actionReferenceNewRow = null; + private ?string $actionReferenceNewRow = null; - protected ?DateTime $created = null; + private ?DateTime $created = null; /** * Get Action Condition. diff --git a/src/Metadata/Object/ViewObject.php b/src/Metadata/Object/ViewObject.php index d561571b..5b61e0a1 100644 --- a/src/Metadata/Object/ViewObject.php +++ b/src/Metadata/Object/ViewObject.php @@ -4,7 +4,7 @@ namespace PhpDb\Metadata\Object; -class ViewObject extends AbstractTableObject +final class ViewObject extends AbstractTableObject { protected ?string $viewDefinition = null; diff --git a/src/Metadata/Source/AbstractSource.php b/src/Metadata/Source/AbstractSource.php index 9c730d90..1c6c333e 100644 --- a/src/Metadata/Source/AbstractSource.php +++ b/src/Metadata/Source/AbstractSource.php @@ -4,6 +4,7 @@ namespace PhpDb\Metadata\Source; +use DateTime; use Exception; use Override; use PhpDb\Adapter\AdapterInterface; @@ -17,37 +18,83 @@ use PhpDb\Metadata\Object\ViewObject; use function array_keys; -use function func_get_args; /** * AbstractSource * - * @psalm-type MetadataTableNames = array - * @psalm-type MetadataColumn = array, - * }> - * @psalm-type MetadataColumns = array> + * view_definition?: string|null, + * check_option?: string|null, + * is_updatable?: bool|null, + * } + * @psalm-type MetadataColumnInfo = array{ + * ordinal_position: int|string|null, + * column_default: string|int|bool|null, + * is_nullable: bool|null, + * data_type: string, + * character_maximum_length: int|string|null, + * character_octet_length: int|string|null, + * numeric_precision: int|string|null, + * numeric_scale: int|string|null, + * numeric_unsigned: bool|null, + * erratas: array, + * } + * @psalm-type MetadataConstraintInfo = array{ + * constraint_type?: string, + * match_option?: string, + * update_rule?: string, + * delete_rule?: string, + * columns?: list, + * referenced_table_schema?: string, + * referenced_table_name?: string, + * referenced_columns?: list, + * check_clause?: string, + * } + * @psalm-type MetadataConstraintKeyInfo = array{ + * table_name: string, + * constraint_name: string, + * column_name: string, + * ordinal_position: int, + * } + * @psalm-type MetadataConstraintReferenceInfo = array{ + * constraint_name: string, + * update_rule: string, + * delete_rule: string, + * referenced_table_name: string, + * referenced_column_name: string, + * } + * @psalm-type MetadataTriggerInfo = array{ + * event_manipulation: string, + * event_object_catalog: string, + * event_object_schema: string, + * event_object_table: string, + * action_order: string, + * action_condition: string|null, + * action_statement: string, + * action_orientation: string, + * action_timing: string, + * action_reference_old_table: string|null, + * action_reference_new_table: string|null, + * action_reference_old_row: string, + * action_reference_new_row: string, + * created: DateTime|null, + * } * @psalm-type MetadataData = array{ - * schemas?: , - * table_names?: MetadataTableNames, - * columns?: MetadataColumns, - * triggers?: , - * ... + * schemas?: list, + * table_names?: array>, + * columns?: array>>, + * constraints?: array>>, + * constraint_keys?: array>, + * constraint_references?: array>, + * triggers?: array>, * } + * + * @api + * + * @mago-expect lint:too-many-methods + * @mago-expect lint:kan-defect + * @mago-expect lint:cyclomatic-complexity */ abstract class AbstractSource implements MetadataInterface { @@ -55,14 +102,21 @@ abstract class AbstractSource implements MetadataInterface protected string $defaultSchema; + /** @var MetadataData */ protected array $data = []; public function __construct( protected AdapterInterface&SchemaAwareInterface $adapter, ) { - $this->defaultSchema = $this->adapter->getCurrentSchema() ?: self::DEFAULT_SCHEMA; + $currentSchema = $this->adapter->getCurrentSchema(); + $this->defaultSchema = false !== $currentSchema && '' !== $currentSchema + ? $currentSchema + : self::DEFAULT_SCHEMA; } + /** + * @throws Exception If the column does not exist. + */ #[Override] public function getColumn(string $columnName, string $table, ?string $schema = null): ColumnObject { @@ -72,14 +126,12 @@ public function getColumn(string $columnName, string $table, ?string $schema = n $this->loadColumnData($table, $schema); - if (! isset($this->data['columns'][$schema][$table][$columnName])) { + $info = $this->data['columns'][$schema][$table][$columnName] ?? null; + if (null === $info) { throw new Exception('A column by that name was not found.'); } - $info = $this->data['columns'][$schema][$table][$columnName]; - $column = new ColumnObject($columnName, $table, $schema); - $column->setOrdinalPosition($info['ordinal_position'] ? (int) $info['ordinal_position'] : null); $column->setColumnDefault($info['column_default']); $column->setIsNullable($info['is_nullable']); @@ -102,6 +154,11 @@ public function getColumn(string $columnName, string $table, ?string $schema = n return $column; } + /** + * @return list + * + * @throws Exception If the table does not exist. + */ #[Override] public function getColumnNames(string $table, ?string $schema = null): array { @@ -111,15 +168,20 @@ public function getColumnNames(string $table, ?string $schema = null): array $this->loadColumnData($table, $schema); - if (! isset($this->data['columns'][$schema][$table])) { - throw new Exception('"' . $table . '" does not exist'); + $columns = $this->data['columns'][$schema][$table] ?? null; + if (null === $columns) { + throw new Exception("\"{$table}\" does not exist"); } - return array_keys($this->data['columns'][$schema][$table]); + return array_keys($columns); } /** * {@inheritdoc} + * + * @return list + * + * @throws Exception If the table does not exist. */ #[Override] public function getColumns(string $table, ?string $schema = null): array @@ -138,6 +200,9 @@ public function getColumns(string $table, ?string $schema = null): array return $columns; } + /** + * @throws Exception If the constraint does not exist. + */ #[Override] public function getConstraint( string $constraintName, @@ -150,29 +215,56 @@ public function getConstraint( $this->loadConstraintData($table, $schema); - if (! isset($this->data['constraints'][$schema][$table][$constraintName])) { + $info = $this->data['constraints'][$schema][$table][$constraintName] ?? null; + if (null === $info) { throw new Exception('Cannot find a constraint by that name in this table'); } - $info = $this->data['constraints'][$schema][$table][$constraintName]; $constraint = new ConstraintObject($constraintName, $table, $schema); - foreach ([ - 'constraint_type' => 'setType', - 'match_option' => 'setMatchOption', - 'update_rule' => 'setUpdateRule', - 'delete_rule' => 'setDeleteRule', - 'columns' => 'setColumns', - 'referenced_table_schema' => 'setReferencedTableSchema', - 'referenced_table_name' => 'setReferencedTableName', - 'referenced_columns' => 'setReferencedColumns', - 'check_clause' => 'setCheckClause', - ] as $key => $setMethod) { - if (! isset($info[$key])) { - continue; - } + $constraintType = $info['constraint_type'] ?? null; + if (null !== $constraintType) { + $constraint->setType($constraintType); + } - $constraint->{$setMethod}($info[$key]); + $matchOption = $info['match_option'] ?? null; + if (null !== $matchOption) { + $constraint->setMatchOption($matchOption); + } + + $updateRule = $info['update_rule'] ?? null; + if (null !== $updateRule) { + $constraint->setUpdateRule($updateRule); + } + + $deleteRule = $info['delete_rule'] ?? null; + if (null !== $deleteRule) { + $constraint->setDeleteRule($deleteRule); + } + + $columns = $info['columns'] ?? null; + if (null !== $columns) { + $constraint->setColumns($columns); + } + + $referencedTableSchema = $info['referenced_table_schema'] ?? null; + if (null !== $referencedTableSchema) { + $constraint->setReferencedTableSchema($referencedTableSchema); + } + + $referencedTableName = $info['referenced_table_name'] ?? null; + if (null !== $referencedTableName) { + $constraint->setReferencedTableName($referencedTableName); + } + + $referencedColumns = $info['referenced_columns'] ?? null; + if (null !== $referencedColumns) { + $constraint->setReferencedColumns($referencedColumns); + } + + $checkClause = $info['check_clause'] ?? null; + if (null !== $checkClause) { + $constraint->setCheckClause($checkClause); } return $constraint; @@ -180,6 +272,8 @@ public function getConstraint( /** * {@inheritdoc} + * + * @return list */ #[Override] public function getConstraintKeys(string $constraint, string $table, ?string $schema = null): array @@ -192,7 +286,7 @@ public function getConstraintKeys(string $constraint, string $table, ?string $sc // organize references first $references = []; - foreach ($this->data['constraint_references'][$schema] as $refKeyInfo) { + foreach ($this->data['constraint_references'][$schema] ?? [] as $refKeyInfo) { if ($refKeyInfo['constraint_name'] !== $constraint) { continue; } @@ -203,7 +297,7 @@ public function getConstraintKeys(string $constraint, string $table, ?string $sc $this->loadConstraintDataKeys($schema); $keys = []; - foreach ($this->data['constraint_keys'][$schema] as $constraintKeyInfo) { + foreach ($this->data['constraint_keys'][$schema] ?? [] as $constraintKeyInfo) { if ( ! ( @@ -215,16 +309,18 @@ public function getConstraintKeys(string $constraint, string $table, ?string $sc continue; } - $keys[] = $key = new ConstraintKeyObject($constraintKeyInfo['column_name']); + $key = new ConstraintKeyObject($constraintKeyInfo['column_name']); $key->setOrdinalPosition($constraintKeyInfo['ordinal_position']); - if (isset($references[$constraint])) { - //$key->setReferencedTableSchema($constraintKeyInfo['referenced_table_schema']); - $key->setForeignKeyUpdateRule($references[$constraint]['update_rule']); - $key->setForeignKeyDeleteRule($references[$constraint]['delete_rule']); - //$key->setReferencedTableSchema($references[$constraint]['referenced_table_schema']); - $key->setReferencedTableName($references[$constraint]['referenced_table_name']); - $key->setReferencedColumnName($references[$constraint]['referenced_column_name']); + + $reference = $references[$constraint] ?? null; + if (null !== $reference) { + $key->setForeignKeyUpdateRule($reference['update_rule']); + $key->setForeignKeyDeleteRule($reference['delete_rule']); + $key->setReferencedTableName($reference['referenced_table_name']); + $key->setReferencedColumnName($reference['referenced_column_name']); } + + $keys[] = $key; } return $keys; @@ -232,6 +328,10 @@ public function getConstraintKeys(string $constraint, string $table, ?string $sc /** * {@inheritdoc} + * + * @return list + * + * @throws Exception If a constraint cannot be loaded. */ #[Override] public function getConstraints(string $table, ?string $schema = null): array @@ -243,7 +343,7 @@ public function getConstraints(string $table, ?string $schema = null): array $this->loadConstraintData($table, $schema); $constraints = []; - foreach (array_keys($this->data['constraints'][$schema][$table]) as $constraintName) { + foreach (array_keys($this->data['constraints'][$schema][$table] ?? []) as $constraintName) { $constraints[] = $this->getConstraint($constraintName, $table, $schema); } @@ -252,15 +352,20 @@ public function getConstraints(string $table, ?string $schema = null): array /** * {@inheritdoc} + * + * @return list */ #[Override] public function getSchemas(): array { $this->loadSchemaData(); - return $this->data['schemas']; + return $this->data['schemas'] ?? []; } + /** + * @throws Exception If the table does not exist or is of an unsupported type. + */ #[Override] public function getTable(string $tableName, ?string $schema = null): TableObject|ViewObject { @@ -270,24 +375,24 @@ public function getTable(string $tableName, ?string $schema = null): TableObject $this->loadTableNameData($schema); - if (! isset($this->data['table_names'][$schema][$tableName])) { - throw new Exception('Table "' . $tableName . '" does not exist'); + $data = $this->data['table_names'][$schema][$tableName] ?? null; + if (null === $data) { + throw new Exception("Table \"{$tableName}\" does not exist"); } - $data = $this->data['table_names'][$schema][$tableName]; switch ($data['table_type']) { case 'BASE TABLE': $table = new TableObject($tableName); break; case 'VIEW': $table = new ViewObject($tableName); - $table->setViewDefinition($data['view_definition']); - $table->setCheckOption($data['check_option']); - $table->setIsUpdatable($data['is_updatable']); + $table->setViewDefinition($data['view_definition'] ?? null); + $table->setCheckOption($data['check_option'] ?? null); + $table->setIsUpdatable($data['is_updatable'] ?? null); break; default: throw new Exception( - 'Table "' . $tableName . '" is of an unsupported type "' . $data['table_type'] . '"', + "Table \"{$tableName}\" is of an unsupported type \"{$data['table_type']}\"", ); } @@ -298,6 +403,10 @@ public function getTable(string $tableName, ?string $schema = null): TableObject /** * {@inheritdoc} + * + * @return list + * + * @mago-expect lint:no-boolean-flag-parameter */ #[Override] public function getTableNames(?string $schema = null, bool $includeViews = false): array @@ -308,12 +417,14 @@ public function getTableNames(?string $schema = null, bool $includeViews = false $this->loadTableNameData($schema); + $tableNamesData = $this->data['table_names'][$schema] ?? []; + if ($includeViews) { - return array_keys($this->data['table_names'][$schema]); + return array_keys($tableNamesData); } $tableNames = []; - foreach ($this->data['table_names'][$schema] as $tableName => $data) { + foreach ($tableNamesData as $tableName => $data) { if ('BASE TABLE' !== $data['table_type']) { continue; } @@ -326,6 +437,10 @@ public function getTableNames(?string $schema = null, bool $includeViews = false /** * {@inheritdoc} + * + * @return list + * + * @throws Exception If a table cannot be loaded. */ #[Override] public function getTables(?string $schema = null, bool $includeViews = false): array @@ -342,6 +457,9 @@ public function getTables(?string $schema = null, bool $includeViews = false): a return $tables; } + /** + * @throws Exception If the trigger does not exist. + */ #[Override] public function getTrigger(string $triggerName, ?string $schema = null): TriggerObject { @@ -351,12 +469,11 @@ public function getTrigger(string $triggerName, ?string $schema = null): Trigger $this->loadTriggerData($schema); - if (! isset($this->data['triggers'][$schema][$triggerName])) { - throw new Exception('Trigger "' . $triggerName . '" does not exist'); + $info = $this->data['triggers'][$schema][$triggerName] ?? null; + if (null === $info) { + throw new Exception("Trigger \"{$triggerName}\" does not exist"); } - $info = $this->data['triggers'][$schema][$triggerName]; - $trigger = new TriggerObject(); $trigger->setName($triggerName); @@ -380,6 +497,8 @@ public function getTrigger(string $triggerName, ?string $schema = null): Trigger /** * {@inheritdoc} + * + * @return list */ #[Override] public function getTriggerNames(?string $schema = null): array @@ -390,11 +509,15 @@ public function getTriggerNames(?string $schema = null): array $this->loadTriggerData($schema); - return array_keys($this->data['triggers'][$schema]); + return array_keys($this->data['triggers'][$schema] ?? []); } /** * {@inheritdoc} + * + * @return list + * + * @throws Exception If a trigger cannot be loaded. */ #[Override] public function getTriggers(?string $schema = null): array @@ -411,6 +534,9 @@ public function getTriggers(?string $schema = null): array return $triggers; } + /** + * @throws Exception If the view does not exist. + */ #[Override] public function getView(string $viewName, ?string $schema = null): ViewObject|TableObject { @@ -420,16 +546,18 @@ public function getView(string $viewName, ?string $schema = null): ViewObject|Ta $this->loadTableNameData($schema); - $tableNames = $this->data['table_names'][$schema]; - if (isset($tableNames[$viewName]) && 'VIEW' === $tableNames[$viewName]['table_type']) { + $viewInfo = $this->data['table_names'][$schema][$viewName] ?? null; + if (null !== $viewInfo && 'VIEW' === $viewInfo['table_type']) { return $this->getTable($viewName, $schema); } - throw new Exception('View "' . $viewName . '" does not exist'); + throw new Exception("View \"{$viewName}\" does not exist"); } /** * {@inheritdoc} + * + * @return list */ #[Override] public function getViewNames(?string $schema = null): array @@ -441,7 +569,7 @@ public function getViewNames(?string $schema = null): array $this->loadTableNameData($schema); $viewNames = []; - foreach ($this->data['table_names'][$schema] as $tableName => $data) { + foreach ($this->data['table_names'][$schema] ?? [] as $tableName => $data) { if ('VIEW' !== $data['table_type']) { continue; } @@ -454,6 +582,10 @@ public function getViewNames(?string $schema = null): array /** * {@inheritdoc} + * + * @return list + * + * @throws Exception If a view cannot be loaded. */ #[Override] public function getViews(?string $schema = null): array @@ -480,7 +612,7 @@ abstract protected function loadSchemaData(): void; */ protected function loadColumnData(string $table, string $schema): void { - if (isset($this->data['columns'][$schema][$table])) { + if (null !== ($this->data['columns'][$schema][$table] ?? null)) { return; } @@ -489,10 +621,15 @@ protected function loadColumnData(string $table, string $schema): void /** * Load constraint data + * + * $table is unused here but forms part of the signature that concrete + * sources override to load per-table constraint data. + * + * @mago-expect analysis:unused-parameter */ protected function loadConstraintData(string $table, string $schema): void { - if (isset($this->data['constraints'][$schema])) { + if (null !== ($this->data['constraints'][$schema] ?? null)) { return; } @@ -504,7 +641,7 @@ protected function loadConstraintData(string $table, string $schema): void */ protected function loadConstraintDataKeys(string $schema): void { - if (isset($this->data['constraint_keys'][$schema])) { + if (null !== ($this->data['constraint_keys'][$schema] ?? null)) { return; } @@ -513,10 +650,15 @@ protected function loadConstraintDataKeys(string $schema): void /** * Load constraint references + * + * $table is unused here but forms part of the signature that concrete + * sources override to load per-table constraint references. + * + * @mago-expect analysis:unused-parameter */ protected function loadConstraintReferences(string $table, string $schema): void { - if (isset($this->data['constraint_references'][$schema])) { + if (null !== ($this->data['constraint_references'][$schema] ?? null)) { return; } @@ -528,7 +670,7 @@ protected function loadConstraintReferences(string $table, string $schema): void */ protected function loadTableNameData(string $schema): void { - if (isset($this->data['table_names'][$schema])) { + if (null !== ($this->data['table_names'][$schema] ?? null)) { return; } @@ -540,7 +682,7 @@ protected function loadTableNameData(string $schema): void */ protected function loadTriggerData(string $schema): void { - if (isset($this->data['triggers'][$schema])) { + if (null !== ($this->data['triggers'][$schema] ?? null)) { return; } @@ -549,11 +691,19 @@ protected function loadTriggerData(string $schema): void /** * Prepare data hierarchy + * + * The by-reference walk builds arbitrary depths of the hierarchy, which + * cannot be expressed against the MetadataData shape. + * + * @mago-expect analysis:possibly-undefined-string-array-index + * @mago-expect analysis:possibly-undefined-int-array-index + * @mago-expect analysis:possibly-null-array-access + * @mago-expect lint:no-isset */ - protected function prepareDataHierarchy(string $type): void + protected function prepareDataHierarchy(string $type, string ...$keys): void { $data = &$this->data; - foreach (func_get_args() as $key) { + foreach ([$type, ...$keys] as $key) { if (! isset($data[$key])) { $data[$key] = []; } From f225145d7f596c40027dc14eb0321899024e2188 Mon Sep 17 00:00:00 2001 From: Simon Mundy Date: Tue, 4 Aug 2026 14:46:38 +1000 Subject: [PATCH 2/2] Remove resolved Metadata src findings from mago baselines --- analyzer-baseline.toml | 552 ----------------------------------------- lint-baseline.toml | 84 ------- 2 files changed, 636 deletions(-) diff --git a/analyzer-baseline.toml b/analyzer-baseline.toml index a6fca388..3e000633 100644 --- a/analyzer-baseline.toml +++ b/analyzer-baseline.toml @@ -1488,90 +1488,6 @@ code = "missing-api-or-internal" message = 'Interface `PhpDb\Feature\FeatureInterface` is missing an `@api` or `@internal` annotation.' count = 1 -[[issues]] -file = "src/Metadata/MetadataInterface.php" -code = "imprecise-type" -message = "Type `array` in return type of `getColumnNames` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Metadata/MetadataInterface.php" -code = "missing-api-or-internal" -message = 'Interface `PhpDb\Metadata\MetadataInterface` is missing an `@api` or `@internal` annotation.' -count = 1 - -[[issues]] -file = "src/Metadata/Object/AbstractTableObject.php" -code = "imprecise-type" -message = "Type `array` in parameter `$columns` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Metadata/Object/AbstractTableObject.php" -code = "imprecise-type" -message = "Type `array` in parameter `$constraints` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Metadata/Object/AbstractTableObject.php" -code = "missing-api-or-internal" -message = 'Abstract class `PhpDb\Metadata\Object\AbstractTableObject` is missing an `@api` or `@internal` annotation.' -count = 1 - -[[issues]] -file = "src/Metadata/Object/ColumnObject.php" -code = "class-must-be-final" -message = 'Class `PhpDb\Metadata\Object\ColumnObject` should be declared `final`.' -count = 1 - -[[issues]] -file = "src/Metadata/Object/ColumnObject.php" -code = "imprecise-type" -message = "Type `array` in parameter `$erratas` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Metadata/Object/ColumnObject.php" -code = "imprecise-type" -message = "Type `array` in property `$errata` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Metadata/Object/ColumnObject.php" -code = "invalid-return-statement" -message = 'Invalid return type for function `PhpDb\Metadata\Object\ColumnObject::getColumnDefault`: expected `null|string`, but found `bool|int|null|string`.' -count = 1 - -[[issues]] -file = "src/Metadata/Object/ColumnObject.php" -code = "less-specific-argument" -message = 'Argument type mismatch for argument #1 of `PhpDb\Metadata\Object\ColumnObject::setErrata`: expected `string`, but provided type `array-key` is less specific.' -count = 1 - -[[issues]] -file = "src/Metadata/Object/ColumnObject.php" -code = "mixed-assignment" -message = "Assigning `mixed` type to a variable may lead to unexpected behavior." -count = 1 - -[[issues]] -file = "src/Metadata/Object/ColumnObject.php" -code = "uninitialized-property" -message = 'Property `$name` is not initialized in the constructor of class `PhpDb\Metadata\Object\ColumnObject`.' -count = 1 - -[[issues]] -file = "src/Metadata/Object/ColumnObject.php" -code = "uninitialized-property" -message = 'Property `$tableName` is not initialized in the constructor of class `PhpDb\Metadata\Object\ColumnObject`.' -count = 1 - -[[issues]] -file = "src/Metadata/Object/ConstraintKeyObject.php" -code = "class-must-be-final" -message = 'Class `PhpDb\Metadata\Object\ConstraintKeyObject` should be declared `final`.' -count = 1 - [[issues]] file = "src/Metadata/Object/ConstraintKeyObject.php" code = "missing-constant-type" @@ -1602,480 +1518,12 @@ code = "missing-constant-type" message = "Class constant `FK_SET_NULL` is missing a type hint." count = 1 -[[issues]] -file = "src/Metadata/Object/ConstraintObject.php" -code = "class-must-be-final" -message = 'Class `PhpDb\Metadata\Object\ConstraintObject` should be declared `final`.' -count = 1 - -[[issues]] -file = "src/Metadata/Object/ConstraintObject.php" -code = "uninitialized-property" -message = 'Property `$name` is not initialized in the constructor of class `PhpDb\Metadata\Object\ConstraintObject`.' -count = 1 - -[[issues]] -file = "src/Metadata/Object/ConstraintObject.php" -code = "uninitialized-property" -message = 'Property `$tableName` is not initialized in the constructor of class `PhpDb\Metadata\Object\ConstraintObject`.' -count = 1 - -[[issues]] -file = "src/Metadata/Object/TableObject.php" -code = "class-must-be-final" -message = 'Class `PhpDb\Metadata\Object\TableObject` should be declared `final`.' -count = 1 - -[[issues]] -file = "src/Metadata/Object/TriggerObject.php" -code = "class-must-be-final" -message = 'Class `PhpDb\Metadata\Object\TriggerObject` should be declared `final`.' -count = 1 - -[[issues]] -file = "src/Metadata/Object/ViewObject.php" -code = "class-must-be-final" -message = 'Class `PhpDb\Metadata\Object\ViewObject` should be declared `final`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "imprecise-type" -message = "Type `array` in property `$data` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "imprecise-type" -message = "Type `array` in return type of `getColumnNames` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "invalid-docblock" -message = "Unexpected token in PHPDoc type" -count = 2 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "invalid-iterator" -message = "The expression provided to `foreach` is not iterable. It resolved to type `mixed`, which is not iterable." -count = 4 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "invalid-return-statement" -message = 'Invalid return type for function `PhpDb\Metadata\Source\AbstractSource::getTables`: expected `array`, but found `list`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "invalid-return-statement" -message = 'Invalid return type for function `PhpDb\Metadata\Source\AbstractSource::getViews`: expected `array`, but found `list`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "less-specific-argument" -message = 'Argument type mismatch for argument #1 of `PhpDb\Metadata\Source\AbstractSource::getConstraint`: expected `string`, but provided type `array-key` is less specific.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "less-specific-nested-return-statement" -message = '''Returned type `array{}|list` is less specific than the declared return type `array` for function `PhpDb\Metadata\Source\AbstractSource::getTableNames` due to nested 'mixed'.''' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "less-specific-nested-return-statement" -message = '''Returned type `array{}|list` is less specific than the declared return type `array` for function `PhpDb\Metadata\Source\AbstractSource::getViewNames` due to nested 'mixed'.''' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "less-specific-return-statement" -message = 'Returned type `list` is less specific than the declared return type `array` for function `PhpDb\Metadata\Source\AbstractSource::getTableNames`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "less-specific-return-statement" -message = 'Returned type `list` is less specific than the declared return type `array` for function `PhpDb\Metadata\Source\AbstractSource::getTriggerNames`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "malformed-docblock-comment" -message = "Failed to parse class-like docblock comment." -count = 2 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "missing-api-or-internal" -message = 'Abstract class `PhpDb\Metadata\Source\AbstractSource` is missing an `@api` or `@internal` annotation.' -count = 1 - [[issues]] file = "src/Metadata/Source/AbstractSource.php" code = "missing-constant-type" message = "Class constant `DEFAULT_SCHEMA` is missing a type hint." count = 1 -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\ColumnObject::setColumnDefault`: expected `bool|int|null|string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\ColumnObject::setDataType`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\ColumnObject::setErratas`: expected `array`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\ColumnObject::setIsNullable`: expected `bool|null`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\ColumnObject::setNumericUnsigned`: expected `bool|null`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\ConstraintKeyObject::__construct`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\ConstraintKeyObject::setForeignKeyDeleteRule`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\ConstraintKeyObject::setForeignKeyUpdateRule`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\ConstraintKeyObject::setOrdinalPosition`: expected `int`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\ConstraintKeyObject::setReferencedColumnName`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\ConstraintKeyObject::setReferencedTableName`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\ConstraintObject::setCheckClause`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\ConstraintObject::setColumns`: expected `array`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\ConstraintObject::setDeleteRule`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\ConstraintObject::setMatchOption`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\ConstraintObject::setReferencedColumns`: expected `array`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\ConstraintObject::setReferencedTableName`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\ConstraintObject::setReferencedTableSchema`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\ConstraintObject::setType`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\ConstraintObject::setUpdateRule`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\TriggerObject::setActionCondition`: expected `null|string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\TriggerObject::setActionOrder`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\TriggerObject::setActionOrientation`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\TriggerObject::setActionReferenceNewRow`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\TriggerObject::setActionReferenceNewTable`: expected `null|string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\TriggerObject::setActionReferenceOldRow`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\TriggerObject::setActionReferenceOldTable`: expected `null|string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\TriggerObject::setActionStatement`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\TriggerObject::setActionTiming`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\TriggerObject::setCreated`: expected `DateTime|null`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\TriggerObject::setEventManipulation`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\TriggerObject::setEventObjectCatalog`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\TriggerObject::setEventObjectSchema`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\TriggerObject::setEventObjectTable`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\ViewObject::setCheckOption`: expected `null|string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\ViewObject::setIsUpdatable`: expected `bool|null`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Object\ViewObject::setViewDefinition`: expected `null|string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Metadata\Source\AbstractSource::getColumn`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-argument" -message = "Invalid argument type for argument #1 of `array_keys`: expected `array<('K.array_keys() extends array-key), ('V.array_keys() extends mixed)>`, but found `mixed`." -count = 4 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-array-access" -message = "Unsafe array access on type `mixed`." -count = 47 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-array-access" -message = "Unsafe array access on type `nonnull`." -count = 4 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-assignment" -message = "Assigning `mixed` type to a variable may lead to unexpected behavior." -count = 13 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-assignment" -message = "Assigning `nonnull` type to a variable may lead to unexpected behavior." -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-operand" -message = "Invalid middle operand: type `mixed` cannot be reliably used in string concatenation." -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "mixed-return-statement" -message = 'Could not infer a precise return type for function `PhpDb\Metadata\Source\AbstractSource::getSchemas`. Saw type `mixed`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key `string('constraint_keys')` accessed on `array`." -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key `string('constraint_references')` accessed on `array`." -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key `string('constraints')` accessed on `array`." -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key `string('schemas')` accessed on `array`." -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key `string('table_names')` accessed on `array`." -count = 4 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key `string('triggers')` accessed on `array`." -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "too-many-arguments" -message = 'Too many arguments provided for method `PhpDb\Metadata\Source\AbstractSource::prepareDataHierarchy`.' -count = 6 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "unhandled-thrown-type" -message = 'Potentially unhandled exception `Exception` in `PhpDb\Metadata\Source\AbstractSource::getColumnNames`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "unhandled-thrown-type" -message = 'Potentially unhandled exception `Exception` in `PhpDb\Metadata\Source\AbstractSource::getColumn`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "unhandled-thrown-type" -message = 'Potentially unhandled exception `Exception` in `PhpDb\Metadata\Source\AbstractSource::getConstraint`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "unhandled-thrown-type" -message = 'Potentially unhandled exception `Exception` in `PhpDb\Metadata\Source\AbstractSource::getTable`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "unhandled-thrown-type" -message = 'Potentially unhandled exception `Exception` in `PhpDb\Metadata\Source\AbstractSource::getTrigger`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "unhandled-thrown-type" -message = 'Potentially unhandled exception `Exception` in `PhpDb\Metadata\Source\AbstractSource::getView`.' -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "unused-parameter" -message = "Parameter `$table` is never used." -count = 2 - [[issues]] file = "src/ResultSet/AbstractResultSet.php" code = "ambiguous-object-method-access" diff --git a/lint-baseline.toml b/lint-baseline.toml index d1758f9e..436380a8 100644 --- a/lint-baseline.toml +++ b/lint-baseline.toml @@ -246,90 +246,6 @@ code = "no-fully-qualified-global-class-like" message = "Fully-qualified class-like reference detected." count = 1 -[[issues]] -file = "src/Metadata/MetadataInterface.php" -code = "no-boolean-flag-parameter" -message = "Avoid boolean flag parameters." -count = 2 - -[[issues]] -file = "src/Metadata/MetadataInterface.php" -code = "too-many-methods" -message = "Interface has too many methods." -count = 1 - -[[issues]] -file = "src/Metadata/Object/ColumnObject.php" -code = "too-many-properties" -message = "Class has too many properties." -count = 1 - -[[issues]] -file = "src/Metadata/Object/ConstraintObject.php" -code = "too-many-properties" -message = "Class has too many properties." -count = 1 - -[[issues]] -file = "src/Metadata/Object/TriggerObject.php" -code = "too-many-properties" -message = "Class has too many properties." -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "cyclomatic-complexity" -message = "Class has high complexity." -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "kan-defect" -message = "Class has a high kan defect score." -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "no-boolean-flag-parameter" -message = "Avoid boolean flag parameters." -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "no-isset" -message = "Use of the `isset` construct." -count = 15 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "no-multi-assignments" -message = "Avoid multiple assignments in a single statement." -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "no-shorthand-ternary" -message = "Use of the shorthand ternary operator." -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "string-style" -message = "String concatenation can be replaced with interpolation." -count = 5 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "too-many-methods" -message = "Class has too many methods." -count = 1 - -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "valid-docblock" -message = "Unexpected token in PHPDoc type" -count = 2 - [[issues]] file = "src/ResultSet/AbstractResultSet.php" code = "cyclomatic-complexity"