@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @param DB $db |
| 35 | 35 | * @param string $dir |
| 36 | 36 | */ |
| 37 | - public function __construct (DB $db, string $dir) { |
|
| 37 | + public function __construct(DB $db, string $dir) { |
|
| 38 | 38 | $this->db = $db; |
| 39 | 39 | $this->dir = $dir; |
| 40 | 40 | $this->table ??= $db['__migrations__'] ?? $db->getSchema()->createTable('__migrations__', [ |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * @param string $to Migration sequence identifier, or `null` to step down once. |
| 49 | 49 | * @return null|string The resulting current sequence identifier. |
| 50 | 50 | */ |
| 51 | - public function down (string $to = null): ?string { |
|
| 51 | + public function down(string $to = null): ?string { |
|
| 52 | 52 | return $this->db->transact(function() use ($to) { |
| 53 | 53 | $current = $this->getCurrent(); |
| 54 | 54 | // walk newest to oldest |
@@ -75,14 +75,14 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @return null|string |
| 77 | 77 | */ |
| 78 | - public function getCurrent (): ?string { |
|
| 78 | + public function getCurrent(): ?string { |
|
| 79 | 79 | return $this->table->select([$this->table['sequence']->max()])->getResult(); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | 83 | * @return string |
| 84 | 84 | */ |
| 85 | - final public function getDir (): string { |
|
| 85 | + final public function getDir(): string { |
|
| 86 | 86 | return $this->dir; |
| 87 | 87 | } |
| 88 | 88 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @param array $spec |
| 91 | 91 | * @return MigrationInterface |
| 92 | 92 | */ |
| 93 | - protected function getMigration (string $file) { |
|
| 93 | + protected function getMigration(string $file) { |
|
| 94 | 94 | $migration = include "{$file}"; |
| 95 | 95 | assert($migration instanceof MigrationInterface); |
| 96 | 96 | return $migration; |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * |
| 102 | 102 | * @return string[] [ sequence => file ] |
| 103 | 103 | */ |
| 104 | - protected function glob () { |
|
| 104 | + protected function glob() { |
|
| 105 | 105 | $files = []; |
| 106 | 106 | foreach (glob("{$this->dir}/*.php") as $file) { |
| 107 | 107 | $files[basename($file, '.php')] = $file; |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * @param null|string $to Migration sequence identifier, or `null` for all upgrades. |
| 116 | 116 | * @return null|string The resulting current sequence identifier. |
| 117 | 117 | */ |
| 118 | - public function up (string $to = null): ?string { |
|
| 118 | + public function up(string $to = null): ?string { |
|
| 119 | 119 | return $this->db->transact(function() use ($to) { |
| 120 | 120 | $current = $this->getCurrent(); |
| 121 | 121 | // walk oldest to newest |
@@ -31,11 +31,11 @@ |
||
| 31 | 31 | * @param Schema $schema |
| 32 | 32 | * @return void |
| 33 | 33 | */ |
| 34 | - public function down ($schema); |
|
| 34 | + public function down($schema); |
|
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * @param Schema $schema |
| 38 | 38 | * @return void |
| 39 | 39 | */ |
| 40 | - public function up ($schema); |
|
| 40 | + public function up($schema); |
|
| 41 | 41 | } |
| 42 | 42 | \ No newline at end of file |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * @param string|EntityInterface $class |
| 77 | 77 | * @return Record |
| 78 | 78 | */ |
| 79 | - public static function fromClass (DB $db, $class) { |
|
| 79 | + public static function fromClass(DB $db, $class) { |
|
| 80 | 80 | $rClass = new ReflectionClass($class); |
| 81 | 81 | assert($rClass->isInstantiable()); |
| 82 | 82 | $columns = []; |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * @param string[] $columns Property names. |
| 105 | 105 | * @param EAV[] $eav Keyed by property name. |
| 106 | 106 | */ |
| 107 | - public function __construct (DB $db, EntityInterface $proto, string $table, array $columns, array $eav = []) { |
|
| 107 | + public function __construct(DB $db, EntityInterface $proto, string $table, array $columns, array $eav = []) { |
|
| 108 | 108 | parent::__construct($db, $table, $columns); |
| 109 | 109 | $this->proto = $proto; |
| 110 | 110 | $rClass = new ReflectionClass($proto); |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @param array[] $eavMatch `[eav property => attribute => mixed]` |
| 158 | 158 | * @return Select|EntityInterface[] |
| 159 | 159 | */ |
| 160 | - public function find (array $match, array $eavMatch = []) { |
|
| 160 | + public function find(array $match, array $eavMatch = []) { |
|
| 161 | 161 | $select = $this->loadAll(); |
| 162 | 162 | foreach ($match as $a => $b) { |
| 163 | 163 | $select->where($this->db->match($this[$a] ?? $a, $b)); |
@@ -175,14 +175,14 @@ discard block |
||
| 175 | 175 | * @param Statement $statement |
| 176 | 176 | * @return EntityInterface[] Keyed by ID |
| 177 | 177 | */ |
| 178 | - public function getAll (Statement $statement): array { |
|
| 178 | + public function getAll(Statement $statement): array { |
|
| 179 | 179 | return iterator_to_array($this->getEach($statement)); |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
| 183 | 183 | * @return string |
| 184 | 184 | */ |
| 185 | - final public function getClass (): string { |
|
| 185 | + final public function getClass(): string { |
|
| 186 | 186 | return get_class($this->proto); |
| 187 | 187 | } |
| 188 | 188 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * @param Statement $statement |
| 194 | 194 | * @return Generator|EntityInterface[] Keyed by ID |
| 195 | 195 | */ |
| 196 | - public function getEach (Statement $statement) { |
|
| 196 | + public function getEach(Statement $statement) { |
|
| 197 | 197 | do { |
| 198 | 198 | $entities = []; |
| 199 | 199 | for ($i = 0; $i < 256 and false !== $row = $statement->fetch(); $i++) { |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | /** |
| 210 | 210 | * @return EAV[] |
| 211 | 211 | */ |
| 212 | - public function getEav () { |
|
| 212 | + public function getEav() { |
|
| 213 | 213 | return $this->eav; |
| 214 | 214 | } |
| 215 | 215 | |
@@ -218,14 +218,14 @@ discard block |
||
| 218 | 218 | * |
| 219 | 219 | * @return string[] |
| 220 | 220 | */ |
| 221 | - final public function getProperties (): array { |
|
| 221 | + final public function getProperties(): array { |
|
| 222 | 222 | return array_keys($this->properties); |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | /** |
| 226 | 226 | * @return EntityInterface |
| 227 | 227 | */ |
| 228 | - public function getProto () { |
|
| 228 | + public function getProto() { |
|
| 229 | 229 | return $this->proto; |
| 230 | 230 | } |
| 231 | 231 | |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | * |
| 237 | 237 | * @return string[] |
| 238 | 238 | */ |
| 239 | - final public function getTypes (): array { |
|
| 239 | + final public function getTypes(): array { |
|
| 240 | 240 | return $this->types; |
| 241 | 241 | } |
| 242 | 242 | |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | * @param EntityInterface $entity |
| 245 | 245 | * @return array |
| 246 | 246 | */ |
| 247 | - protected function getValues (EntityInterface $entity): array { |
|
| 247 | + protected function getValues(EntityInterface $entity): array { |
|
| 248 | 248 | $values = []; |
| 249 | 249 | foreach (array_keys($this->columns) as $name) { |
| 250 | 250 | $values[$name] = $this->properties[$name]->getValue($entity); |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | * @param string $property |
| 257 | 257 | * @return bool |
| 258 | 258 | */ |
| 259 | - final public function isNullable (string $property): bool { |
|
| 259 | + final public function isNullable(string $property): bool { |
|
| 260 | 260 | return $this->nullable[$property]; |
| 261 | 261 | } |
| 262 | 262 | |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | * @param int $id |
| 267 | 267 | * @return null|EntityInterface |
| 268 | 268 | */ |
| 269 | - public function load (int $id) { |
|
| 269 | + public function load(int $id) { |
|
| 270 | 270 | $statement = $this->cache(__FUNCTION__, function() { |
| 271 | 271 | return $this->select()->where('id = ?')->prepare(); |
| 272 | 272 | }); |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | * |
| 287 | 287 | * @return Select|EntityInterface[] |
| 288 | 288 | */ |
| 289 | - public function loadAll () { |
|
| 289 | + public function loadAll() { |
|
| 290 | 290 | return $this->select()->setFetcher(function(Statement $statement) { |
| 291 | 291 | yield from $this->getEach($statement); |
| 292 | 292 | }); |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | * |
| 298 | 298 | * @param EntityInterface[] $entities |
| 299 | 299 | */ |
| 300 | - protected function loadEav (array $entities): void { |
|
| 300 | + protected function loadEav(array $entities): void { |
|
| 301 | 301 | $ids = array_keys($entities); |
| 302 | 302 | foreach ($this->eav as $name => $eav) { |
| 303 | 303 | foreach ($eav->loadAll($ids) as $id => $values) { |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | * @param EntityInterface $entity |
| 313 | 313 | * @return int ID |
| 314 | 314 | */ |
| 315 | - public function save (EntityInterface $entity): int { |
|
| 315 | + public function save(EntityInterface $entity): int { |
|
| 316 | 316 | if (!$entity->getId()) { |
| 317 | 317 | $this->saveInsert($entity); |
| 318 | 318 | } |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | /** |
| 327 | 327 | * @param EntityInterface $entity |
| 328 | 328 | */ |
| 329 | - protected function saveEav (EntityInterface $entity): void { |
|
| 329 | + protected function saveEav(EntityInterface $entity): void { |
|
| 330 | 330 | $id = $entity->getId(); |
| 331 | 331 | foreach ($this->eav as $name => $eav) { |
| 332 | 332 | // may be null to skip |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | * |
| 343 | 343 | * @param EntityInterface $entity |
| 344 | 344 | */ |
| 345 | - protected function saveInsert (EntityInterface $entity): void { |
|
| 345 | + protected function saveInsert(EntityInterface $entity): void { |
|
| 346 | 346 | $statement = $this->cache(__FUNCTION__, function() { |
| 347 | 347 | $slots = $this->db->slots(array_keys($this->columns)); |
| 348 | 348 | unset($slots['id']); |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | * |
| 362 | 362 | * @param EntityInterface $entity |
| 363 | 363 | */ |
| 364 | - protected function saveUpdate (EntityInterface $entity): void { |
|
| 364 | + protected function saveUpdate(EntityInterface $entity): void { |
|
| 365 | 365 | $statement = $this->cache(__FUNCTION__, function() { |
| 366 | 366 | $slots = $this->db->slotsEqual(array_keys($this->columns)); |
| 367 | 367 | unset($slots['id']); |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | * @param EntityInterface $proto |
| 377 | 377 | * @return $this |
| 378 | 378 | */ |
| 379 | - public function setProto (EntityInterface $proto) { |
|
| 379 | + public function setProto(EntityInterface $proto) { |
|
| 380 | 380 | $this->proto = $proto; |
| 381 | 381 | return $this; |
| 382 | 382 | } |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | * @param EntityInterface $entity |
| 386 | 386 | * @param array $values |
| 387 | 387 | */ |
| 388 | - protected function setValues (EntityInterface $entity, array $values): void { |
|
| 388 | + protected function setValues(EntityInterface $entity, array $values): void { |
|
| 389 | 389 | foreach ($values as $name => $value) { |
| 390 | 390 | if (isset($this->properties[$name])) { |
| 391 | 391 | settype($value, $this->types[$name]); // doesn't care about letter case |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | /** |
| 197 | 197 | * @param DB $db |
| 198 | 198 | */ |
| 199 | - public function __construct (DB $db) { |
|
| 199 | + public function __construct(DB $db) { |
|
| 200 | 200 | $this->db = $db; |
| 201 | 201 | $this->colDefs ??= self::COLUMN_DEFINITIONS[$db->getDriver()]; |
| 202 | 202 | } |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | * @param int $type |
| 210 | 210 | * @return $this |
| 211 | 211 | */ |
| 212 | - public function addColumn (string $table, string $column, int $type = self::T_STRING) { |
|
| 212 | + public function addColumn(string $table, string $column, int $type = self::T_STRING) { |
|
| 213 | 213 | $type = $this->colDefs[$type & self::T_MASK]; |
| 214 | 214 | $this->db->exec("ALTER TABLE {$table} ADD COLUMN {$column} {$type}"); |
| 215 | 215 | unset($this->tables[$table]); |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | * @param array[] $constraints `[ <TABLE_CONST> => spec ]` |
| 236 | 236 | * @return $this |
| 237 | 237 | */ |
| 238 | - public function createTable (string $table, array $columns, array $constraints = []) { |
|
| 238 | + public function createTable(string $table, array $columns, array $constraints = []) { |
|
| 239 | 239 | $defs = $this->toColumnDefinitions($columns); |
| 240 | 240 | |
| 241 | 241 | /** @var string[] $pk */ |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | * @param string $column |
| 272 | 272 | * @return $this |
| 273 | 273 | */ |
| 274 | - public function dropColumn (string $table, string $column) { |
|
| 274 | + public function dropColumn(string $table, string $column) { |
|
| 275 | 275 | $this->db->exec("ALTER TABLE {$table} DROP COLUMN {$column}"); |
| 276 | 276 | unset($this->tables[$table]); |
| 277 | 277 | return $this; |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | * |
| 283 | 283 | * @param string $table |
| 284 | 284 | */ |
| 285 | - public function dropTable (string $table): void { |
|
| 285 | + public function dropTable(string $table): void { |
|
| 286 | 286 | $this->db->exec("DROP TABLE IF EXISTS {$table}"); |
| 287 | 287 | unset($this->tables[$table]); |
| 288 | 288 | } |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | /** |
| 291 | 291 | * @return DB |
| 292 | 292 | */ |
| 293 | - public function getDb () { |
|
| 293 | + public function getDb() { |
|
| 294 | 294 | return $this->db; |
| 295 | 295 | } |
| 296 | 296 | |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | * @param string $name |
| 299 | 299 | * @return null|Table |
| 300 | 300 | */ |
| 301 | - public function getTable (string $name) { |
|
| 301 | + public function getTable(string $name) { |
|
| 302 | 302 | if (!isset($this->tables[$name])) { |
| 303 | 303 | if ($this->db->isSQLite()) { |
| 304 | 304 | $info = $this->db->query("PRAGMA table_info({$name})")->fetchAll(); |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | * @param string $table |
| 324 | 324 | * @return bool |
| 325 | 325 | */ |
| 326 | - final public function offsetExists ($table): bool { |
|
| 326 | + final public function offsetExists($table): bool { |
|
| 327 | 327 | return (bool)$this->offsetGet($table); |
| 328 | 328 | } |
| 329 | 329 | |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | * @param string $table |
| 334 | 334 | * @return null|Table |
| 335 | 335 | */ |
| 336 | - public function offsetGet ($table) { |
|
| 336 | + public function offsetGet($table) { |
|
| 337 | 337 | return $this->getTable($table); |
| 338 | 338 | } |
| 339 | 339 | |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | * @param $value |
| 343 | 343 | * @throws LogicException |
| 344 | 344 | */ |
| 345 | - final public function offsetSet ($offset, $value) { |
|
| 345 | + final public function offsetSet($offset, $value) { |
|
| 346 | 346 | throw new LogicException('The schema cannot be altered this way.'); |
| 347 | 347 | } |
| 348 | 348 | |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | * @param $offset |
| 351 | 351 | * @throws LogicException |
| 352 | 352 | */ |
| 353 | - final public function offsetUnset ($offset) { |
|
| 353 | + final public function offsetUnset($offset) { |
|
| 354 | 354 | throw new LogicException('The schema cannot be altered this way.'); |
| 355 | 355 | } |
| 356 | 356 | |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | * @param string $newName |
| 363 | 363 | * @return $this |
| 364 | 364 | */ |
| 365 | - public function renameColumn (string $table, string $oldName, string $newName) { |
|
| 365 | + public function renameColumn(string $table, string $oldName, string $newName) { |
|
| 366 | 366 | $this->db->exec("ALTER TABLE {$table} RENAME COLUMN {$oldName} TO {$newName}"); |
| 367 | 367 | unset($this->tables[$table]); |
| 368 | 368 | return $this; |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | * @param string $newName |
| 376 | 376 | * @return $this |
| 377 | 377 | */ |
| 378 | - public function renameTable (string $oldName, string $newName) { |
|
| 378 | + public function renameTable(string $oldName, string $newName) { |
|
| 379 | 379 | $this->db->exec("ALTER TABLE {$oldName} RENAME TO {$newName}"); |
| 380 | 380 | unset($this->tables[$oldName]); |
| 381 | 381 | return $this; |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | * @param int[] $types |
| 388 | 388 | * @return int[] |
| 389 | 389 | */ |
| 390 | - protected function sortColumns (array $types): array { |
|
| 390 | + protected function sortColumns(array $types): array { |
|
| 391 | 391 | uksort($types, function(string $a, string $b) use ($types) { |
| 392 | 392 | // descending index priority, increasing size, name |
| 393 | 393 | return $types[$b] <=> $types[$a] ?: $a <=> $b; |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | * @param int[] $columns `[ name => <I_CONST> | <T_CONST> ]` |
| 400 | 400 | * @return string[] |
| 401 | 401 | */ |
| 402 | - protected function toColumnDefinitions (array $columns): array { |
|
| 402 | + protected function toColumnDefinitions(array $columns): array { |
|
| 403 | 403 | assert(count($columns) > 0); |
| 404 | 404 | $columns = $this->sortColumns($columns); |
| 405 | 405 | $defs = []; |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | * @param Column $foreign |
| 425 | 425 | * @return string |
| 426 | 426 | */ |
| 427 | - protected function toForeignKeyConstraint (string $table, string $local, Column $foreign): string { |
|
| 427 | + protected function toForeignKeyConstraint(string $table, string $local, Column $foreign): string { |
|
| 428 | 428 | return sprintf( |
| 429 | 429 | 'CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s(%s) ON DELETE CASCADE', |
| 430 | 430 | $this->toForeignKeyConstraint_name($table, $local), |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | * @param string $column |
| 442 | 442 | * @return string |
| 443 | 443 | */ |
| 444 | - protected function toForeignKeyConstraint_name (string $table, string $column): string { |
|
| 444 | + protected function toForeignKeyConstraint_name(string $table, string $column): string { |
|
| 445 | 445 | return 'FK_' . $table . '__' . $column; |
| 446 | 446 | } |
| 447 | 447 | |
@@ -450,7 +450,7 @@ discard block |
||
| 450 | 450 | * @param string[] $columns |
| 451 | 451 | * @return string |
| 452 | 452 | */ |
| 453 | - protected function toPrimaryKeyConstraint (string $table, array $columns): string { |
|
| 453 | + protected function toPrimaryKeyConstraint(string $table, array $columns): string { |
|
| 454 | 454 | return sprintf( |
| 455 | 455 | 'CONSTRAINT %s PRIMARY KEY (%s)', |
| 456 | 456 | $this->toPrimaryKeyConstraint_name($table, $columns), |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | * @param string[] $columns |
| 466 | 466 | * @return string |
| 467 | 467 | */ |
| 468 | - protected function toPrimaryKeyConstraint_name (string $table, array $columns): string { |
|
| 468 | + protected function toPrimaryKeyConstraint_name(string $table, array $columns): string { |
|
| 469 | 469 | sort($columns, SORT_STRING); |
| 470 | 470 | return 'PK_' . $table . '__' . implode('__', $columns); |
| 471 | 471 | } |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | * @param string[] $columns |
| 476 | 476 | * @return string |
| 477 | 477 | */ |
| 478 | - protected function toUniqueKeyConstraint (string $table, array $columns): string { |
|
| 478 | + protected function toUniqueKeyConstraint(string $table, array $columns): string { |
|
| 479 | 479 | return sprintf( |
| 480 | 480 | 'CONSTRAINT %s UNIQUE (%s)', |
| 481 | 481 | $this->toUniqueKeyConstraint_name($table, $columns), |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | * @param string[] $columns |
| 491 | 491 | * @return string |
| 492 | 492 | */ |
| 493 | - protected function toUniqueKeyConstraint_name (string $table, array $columns): string { |
|
| 493 | + protected function toUniqueKeyConstraint_name(string $table, array $columns): string { |
|
| 494 | 494 | sort($columns, SORT_STRING); |
| 495 | 495 | return 'UQ_' . $table . '__' . implode('__', $columns); |
| 496 | 496 | } |
@@ -271,6 +271,4 @@ |
||
| 271 | 271 | return; |
| 272 | 272 | |
| 273 | 273 | default: |
| 274 | - $usage(); |
|
| 275 | - exit(1); |
|
| 276 | -} |
|
| 277 | 274 | \ No newline at end of file |
| 275 | + $usage |
|
| 278 | 276 | \ No newline at end of file |
@@ -271,6 +271,4 @@ |
||
| 271 | 271 | return; |
| 272 | 272 | |
| 273 | 273 | default: |
| 274 | - $usage(); |
|
| 275 | - exit(1); |
|
| 276 | -} |
|
| 277 | 274 | \ No newline at end of file |
| 275 | + $usage |
|
| 278 | 276 | \ No newline at end of file |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | }; |
| 146 | 146 | if ($access instanceof Record) { |
| 147 | 147 | // create table |
| 148 | - if (!$db[$access->getName()]) { |
|
| 148 | + if (!$db[$access - >getName()]) { |
|
| 149 | 149 | $columns = []; |
| 150 | 150 | foreach ($access->getTypes() as $property => $type) { |
| 151 | 151 | $T_CONST = Schema::PHP_TYPE_NAMES[$type]; |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | // check each eav |
| 164 | 164 | foreach ($access->getEav() as $eav) { |
| 165 | 165 | // create table |
| 166 | - if (!$db[$eav->getName()]) { |
|
| 166 | + if (!$db[$eav - >getName()]) { |
|
| 167 | 167 | $T_CONST = Schema::PHP_TYPE_NAMES[$eav->getValueType()]; |
| 168 | 168 | $columns = [ |
| 169 | 169 | "'entity' => Schema::T_INT_STRICT", |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | } |
| 184 | 184 | elseif ($access instanceof Junction) { |
| 185 | 185 | // create table |
| 186 | - if (!$db[$access->getName()]) { |
|
| 186 | + if (!$db[$access - >getName()]) { |
|
| 187 | 187 | $records = $access->getRecords(); |
| 188 | 188 | $columns = array_map( |
| 189 | 189 | fn(string $column) => "'{$column}' => Schema::T_INT_STRICT", |
@@ -271,6 +271,4 @@ discard block |
||
| 271 | 271 | return; |
| 272 | 272 | |
| 273 | 273 | default: |
| 274 | - $usage(); |
|
| 275 | - exit(1); |
|
| 276 | -} |
|
| 277 | 274 | \ No newline at end of file |
| 275 | + $usage |
|
| 278 | 276 | \ No newline at end of file |
@@ -271,6 +271,4 @@ |
||
| 271 | 271 | return; |
| 272 | 272 | |
| 273 | 273 | default: |
| 274 | - $usage(); |
|
| 275 | - exit(1); |
|
| 276 | -} |
|
| 277 | 274 | \ No newline at end of file |
| 275 | + $usage |
|
| 278 | 276 | \ No newline at end of file |
@@ -271,6 +271,4 @@ |
||
| 271 | 271 | return; |
| 272 | 272 | |
| 273 | 273 | default: |
| 274 | - $usage(); |
|
| 275 | - exit(1); |
|
| 276 | -} |
|
| 277 | 274 | \ No newline at end of file |
| 275 | + $usage |
|
| 278 | 276 | \ No newline at end of file |