Skip to content

Commit

Permalink
fix all seed
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Sep 2, 2022
1 parent 8f78702 commit f75cbbb
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 20 deletions.
10 changes: 6 additions & 4 deletions src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ class Model implements \IteratorAggregate
/** @var array<string, true> */
private static $_modelOnlyProperties;

/** @var array The seed used by addField() method. */
/** @var array<mixed> The seed used by addField() method. */
protected $_defaultSeedAddField = [Field::class];

/** @var array The seed used by addExpression() method. */
/** @var array<mixed> The seed used by addExpression() method. */
protected $_defaultSeedAddExpression = [CallbackField::class];

/** @var array<string, Field> */
Expand Down Expand Up @@ -525,13 +525,15 @@ public function validate(string $intent = null): array
return $errors;
}

/** @var array<string, array> */
/** @var array<string, array<mixed>> */
protected array $fieldSeedByType = [];

/**
* Given a field seed, return a field object.
*
* @param array<mixed> $seed
*/
public function fieldFactory(array $seed = null): Field
protected function fieldFactory(array $seed = []): Field
{
$seed = Factory::mergeSeeds(
$seed,
Expand Down
2 changes: 2 additions & 0 deletions src/Model/Join.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ private function getJoinNameFromShortName(): string
* Adding field into join will automatically associate that field
* with this join. That means it won't be loaded from $table, but
* form the join instead.
*
* @param array<mixed> $seed
*/
public function addField(string $name, array $seed = []): Field
{
Expand Down
2 changes: 1 addition & 1 deletion src/Model/JoinsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
trait JoinsTrait
{
/** @var array The class used by join() method. */
/** @var array<mixed> The class used by join() method. */
protected $_defaultSeedJoin = [Join::class];

/**
Expand Down
11 changes: 6 additions & 5 deletions src/Model/ReferencesTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,23 @@
*/
trait ReferencesTrait
{
/** @var array The seed used by addReference() method. */
/** @var array<mixed> The seed used by addReference() method. */
protected $_defaultSeedAddReference = [Reference::class];

/** @var array The seed used by hasOne() method. */
/** @var array<mixed> The seed used by hasOne() method. */
protected $_defaultSeedHasOne = [Reference\HasOne::class];

/** @var array The seed used by hasMany() method. */
/** @var array<mixed> The seed used by hasMany() method. */
protected $_defaultSeedHasMany = [Reference\HasMany::class];

/** @var array The seed used by containsOne() method. */
/** @var array<mixed> The seed used by containsOne() method. */
protected $_defaultSeedContainsOne = [Reference\ContainsOne::class];

/** @var array The seed used by containsMany() method. */
/** @var array<mixed> The seed used by containsMany() method. */
protected $_defaultSeedContainsMany = [Reference\ContainsMany::class];

/**
* @param array<mixed> $seed
* @param array<string, mixed> $defaults
*/
protected function _addReference(array $seed, string $link, array $defaults = []): Reference
Expand Down
2 changes: 1 addition & 1 deletion src/Model/UserActionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

trait UserActionsTrait
{
/** @var array The seed used by addUserAction() method. */
/** @var array<mixed> The seed used by addUserAction() method. */
protected $_defaultSeedUserAction = [UserAction::class];

/** @var array<string, UserAction> Collection of user actions - using key as action system name */
Expand Down
10 changes: 5 additions & 5 deletions src/Persistence/Sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ class Sql extends Persistence
/** @var Connection */
private $_connection;

/** @var array Default class when adding new field. */
/** @var array<mixed> Default class when adding new field. */
protected $_defaultSeedAddField; // no custom seed needed

/** @var array Default class when adding Expression field. */
/** @var array<mixed> Default class when adding Expression field. */
protected $_defaultSeedAddExpression = [SqlExpressionField::class];

/** @var array Default class when adding hasOne field. */
/** @var array<mixed> Default class when adding hasOne field. */
protected $_defaultSeedHasOne = [HasOneSql::class];

/** @var array Default class when adding hasMany field. */
/** @var array<mixed> Default class when adding hasMany field. */
protected $_defaultSeedHasMany; // no custom seed needed

/** @var array Default class when adding join. */
/** @var array<mixed> Default class when adding join. */
protected $_defaultSeedJoin = [Sql\Join::class];

/**
Expand Down
6 changes: 6 additions & 0 deletions src/Persistence/Sql/Postgresql/PlatformTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ trait PlatformTrait
// standard PostgreSQL character types are case sensitive, unify the behaviour with other databases
// with custom case insensitive types

/**
* @return array<int, string>
*/
private function getCreateCaseInsensitiveDomainsSql(): array
{
$sqls = [];
Expand Down Expand Up @@ -70,6 +73,9 @@ private function getPrimaryKeyColumn(Table $table): ?Column
return $table->getColumn($table->getPrimaryKey()->getColumns()[0]);
}

/**
* @return array<int, string>
*/
protected function getCreateAutoincrementSql(Table $table, Column $pkColumn): array
{
$sqls = [];
Expand Down
4 changes: 2 additions & 2 deletions tests/ModelNestedArrayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

class ModelNestedArrayTest extends TestCase
{
/** @var array */
public $hookLog = [];
/** @var array<array{string, string, 2?: array<int, mixed>}> */
public array $hookLog = [];

protected function setUp(): void
{
Expand Down
4 changes: 2 additions & 2 deletions tests/ModelNestedSqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

class ModelNestedSqlTest extends TestCase
{
/** @var array */
public $hookLog = [];
/** @var array<array{string, string, 2?: array<int, mixed>}> */
public array $hookLog = [];

protected function setUp(): void
{
Expand Down

0 comments on commit f75cbbb

Please sign in to comment.