-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
15 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,9 @@ | |
* @author Hans Lellelid <[email protected]> (Propel) | ||
* @author John D. McNally <[email protected]> (Torque) | ||
* @author Daniel Rall <[email protected]> (Torque) | ||
* | ||
* @psalm-type \Propel\Runtime\Map\MapType = 'tablesByName' | 'tablesByPhpName' | ||
* @psalm-type \Propel\Runtime\Map\TableMapDump array<\Propel\Runtime\Map\MapType, array<string, class-string<\Propel\Runtime\Map\TableMap>>> | ||
*/ | ||
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<string, \Propel\Runtime\Map\TableMap|class-string<\Propel\Runtime\Map\TableMap>> | ||
*/ | ||
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<string, \Propel\Runtime\Map\TableMap|class-string<\Propel\Runtime\Map\TableMap>> | ||
*/ | ||
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<class-string> $tableMapClasses | ||
* @param array<class-string<\Propel\Runtime\Map\TableMap>> $tableMapClasses | ||
* | ||
* @return void | ||
*/ | ||
|