diff --git a/src/Propel/Runtime/Map/DatabaseMap.php b/src/Propel/Runtime/Map/DatabaseMap.php index d1ac4fef5d..1d99262ef0 100644 --- a/src/Propel/Runtime/Map/DatabaseMap.php +++ b/src/Propel/Runtime/Map/DatabaseMap.php @@ -25,6 +25,9 @@ * @author Hans Lellelid (Propel) * @author John D. McNally (Torque) * @author Daniel Rall (Torque) + * + * @psalm-type \Propel\Runtime\Map\MapType = 'tablesByName' | 'tablesByPhpName' + * @psalm-type \Propel\Runtime\Map\TableMapDump array<\Propel\Runtime\Map\MapType, array>> */ class DatabaseMap { @@ -38,14 +41,14 @@ class DatabaseMap /** * Tables in the database, using table name as key * - * @var array<\Propel\Runtime\Map\TableMap|class-string<\Propel\Runtime\Map\TableMap>> + * @var array> */ protected $tables = []; /** * Tables in the database, using table phpName as key * - * @var array<\Propel\Runtime\Map\TableMap|class-string<\Propel\Runtime\Map\TableMap>> + * @var array> */ protected $tablesByPhpName = []; @@ -121,7 +124,7 @@ protected function addTableByPhpName(?string $phpName, $tableOrClassMap): void /** * Add a new table to the database, using the tablemap class name. * - * @param string $tableMapClass The name of the table map to add + * @param class-string<\Propel\Runtime\Map\TableMap> $tableMapClass The name of the table map to add * * @return \Propel\Runtime\Map\TableMap The TableMap object */ @@ -137,23 +140,26 @@ public function addTableFromMapClass(string $tableMapClass): TableMap /** * Dump table maps. Used during configuration generation. * - * @return array A dump that can be loaded again with {@link DatabaseMap::loadMapsFromDump()} + * @return \Propel\Runtime\Map\TableMapDump A dump that can be loaded again with {@link DatabaseMap::loadMapsFromDump()} */ public function dumpMaps(): array { + /** + * @param $tableMap class-string<\Propel\Runtime\Map\TableMap>|\Propel\Runtime\Map\TableMap + * @return class-string<\Propel\Runtime\Map\TableMap> + */ $toClassString = fn ($tableMap) => is_string($tableMap) ? $tableMap : get_class($tableMap); - $maps = [ + + return [ 'tablesByName' => array_map($toClassString, $this->tables), 'tablesByPhpName' => array_map($toClassString, $this->tablesByPhpName), ]; - - return $maps; } /** * Load internal table maps from dump. Used during Propel initialization. * - * @param $mapsDump Table map dump as created by {@link DatabaseMap::dumpMaps()} + * @param \Propel\Runtime\Map\TableMapDump|array $mapsDump Table map dump as created by {@link DatabaseMap::dumpMaps()} * * @return void */ @@ -208,7 +214,7 @@ public function registerTableMapClassByName(string $tableName, ?string $tablePhp * Registers a list of table map classes (by qualified name) as table maps * belonging to this database. * - * @param array $tableMapClasses + * @param array> $tableMapClasses * * @return void */