diff --git a/psalm-baseline.xml b/psalm-baseline.xml
new file mode 100644
index 0000000..6804979
--- /dev/null
+++ b/psalm-baseline.xml
@@ -0,0 +1,412 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ getOuterKey()]]>
+
+
+
+
+
+
+
+
+
+
+
+
+ ]]>
+
+
+
+
+ column)]]>
+ type)]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ target === null]]>
+ target === null]]>
+ type === null]]>
+
+
+
+
+
+
+
+
+ entity->getFields()->getNames()]]>
+
+
+
+
+ entity->getFields()->getNames()]]>
+
+
+
+
+ entity->getFields()->getNames()]]>
+
+
+
+
+
+
+
+
+
+
+ getColumns()]]>
+ getColumns()]]>
+
+
+ getColumns()]]>
+ getColumns()]]>
+ getColumns()]]>
+ getColumns()]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ reflector->sortedTables()]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ relations[$entity][$name]]]>
+ tables[$entity]['database']]]>
+ tables[$entity]['schema']]]>
+ tables[$entity]['table']]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ children[$entity]]]>
+ relations[$entity]]]>
+ relations[$entity][$name]]]>
+ tables[$entity]['database']]]>
+ tables[$entity]['schema']]]>
+ tables[$entity]['table']]]>
+
+
+
+
+ options->get(self::INDEX_CREATE)]]>
+
+
+
+
+
+
+
+
+
+ options->get(self::INDEX_CREATE)]]>
+
+
+
+
+ options->get(self::INDEX_CREATE)]]>
+
+
+
+
+ options->get(Relation::THROUGH_ENTITY)]]>
+ options->get(self::INDEX_CREATE)]]>
+ options->get(self::INDEX_CREATE)]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ options->get(Relation::NULLABLE)]]>
+ options->get(Relation::NULLABLE)]]>
+ options->get(RelationSchema::MORPH_KEY_LENGTH)]]>
+
+
+
+
+
+
+
+
+
+
+
+
+ options->get(Relation::MORPH_KEY)]]>
+ options->get(Relation::NULLABLE)]]>
+ options->get(RelationSchema::MORPH_KEY_LENGTH)]]>
+
+
+
+
+ options->get(Relation::MORPH_KEY)]]>
+ options->get(Relation::NULLABLE)]]>
+ options->get(RelationSchema::MORPH_KEY_LENGTH)]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ options[$name]]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ options->get(self::INDEX_CREATE)]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ name]]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ getOptions()->get($field)]]>
+ getOptions()->get($field)]]>
+ options->get(Relation::NULLABLE)]]>
+ options->get(Relation::NULLABLE)]]>
+ options->get(Relation::NULLABLE)]]>
+ options->get(Relation::NULLABLE)]]>
+ options->get(Relation::NULLABLE)]]>
+ options->get(Relation::NULLABLE)]]>
+ options->get(Relation::NULLABLE)]]>
+ options->get(Relation::NULLABLE)]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ getFields($source, $sourceKey)->getColumnNames()]]>
+
+
+
+ $columns,
+ ]]]>
+
+
+
+
+
+
+
+
+
+
+
+
+ getOptions()->get(RelationSchema::FK_ON_DELETE) ?? $fkAction]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ field->getAttributes())]]>
+
+
+
+
+
+ getEnumValues()[0]]]>
+
+
+
+
+
+
diff --git a/src/Compiler.php b/src/Compiler.php
index 9fd5d5f..648b0d0 100644
--- a/src/Compiler.php
+++ b/src/Compiler.php
@@ -15,7 +15,6 @@
use Cycle\Schema\Exception\TableInheritance\DiscriminatorColumnNotPresentException;
use Cycle\Schema\Exception\TableInheritance\WrongDiscriminatorColumnException;
use Cycle\Schema\Exception\TableInheritance\WrongParentKeyColumnException;
-use Throwable;
final class Compiler
{
@@ -37,8 +36,8 @@ public function compile(Registry $registry, array $generators = [], array $defau
sprintf(
'Invalid generator `%s`. It should implement `%s` interface.',
\is_object($generator) ? $generator::class : \var_export($generator, true),
- GeneratorInterface::class
- )
+ GeneratorInterface::class,
+ ),
);
}
@@ -126,16 +125,16 @@ private function compute(Registry $registry, Entity $entity): void
\assert($modifier instanceof SchemaModifierInterface);
try {
$modifier->modifySchema($schema);
- } catch (Throwable $e) {
+ } catch (\Throwable $e) {
throw new SchemaModifierException(
sprintf(
'Unable to apply schema modifier `%s` for the `%s` role. %s',
$modifier::class,
$role,
- $e->getMessage()
+ $e->getMessage(),
),
- (int)$e->getCode(),
- $e
+ (int) $e->getCode(),
+ $e,
);
}
}
@@ -172,11 +171,11 @@ private function renderColumns(Entity $entity): array
}
try {
$comparator->compare();
- } catch (Throwable $e) {
+ } catch (\Throwable $e) {
throw new Exception\CompilerException(sprintf(
"Error compiling the `%s` role.\n\n%s",
$entity->getRole() ?? 'unknown',
- $e->getMessage()
+ $e->getMessage(),
), (int) $e->getCode());
}
}
diff --git a/src/Defaults.php b/src/Defaults.php
index 6bb4558..5fe357f 100644
--- a/src/Defaults.php
+++ b/src/Defaults.php
@@ -24,9 +24,8 @@ public function __construct(
SchemaInterface::SOURCE => Source::class,
SchemaInterface::SCOPE => null,
SchemaInterface::TYPECAST_HANDLER => null,
- ]
- ) {
- }
+ ],
+ ) {}
/**
* @param array $defaults
diff --git a/src/Definition/Comparator/FieldComparator.php b/src/Definition/Comparator/FieldComparator.php
index ee945a9..3d0f045 100644
--- a/src/Definition/Comparator/FieldComparator.php
+++ b/src/Definition/Comparator/FieldComparator.php
@@ -5,12 +5,11 @@
namespace Cycle\Schema\Definition\Comparator;
use Cycle\Schema\Definition\Field;
-use Exception;
-use InvalidArgumentException;
final class FieldComparator
{
private $columnName;
+
/** @var Field[] */
private $fields = [];
@@ -20,7 +19,7 @@ public function addField(string $key, Field $field): self
$this->columnName = $field->getColumn();
}
if ($this->columnName !== $field->getColumn()) {
- throw new InvalidArgumentException('The field comparator only accepts fields with the same column name.');
+ throw new \InvalidArgumentException('The field comparator only accepts fields with the same column name.');
}
$this->fields[$key] = $field;
return $this;
@@ -33,9 +32,9 @@ public function compare(): void
}
// Check options
if (!$this->compareOptions() || !$this->compareProperties()) {
- throw new Exception(
+ throw new \Exception(
"Different definitions are specified for the `$this->columnName` column:"
- . "\n\n{$this->generateErrorText()}"
+ . "\n\n{$this->generateErrorText()}",
);
}
}
diff --git a/src/Definition/Entity.php b/src/Definition/Entity.php
index fc60be6..d16e5f3 100644
--- a/src/Definition/Entity.php
+++ b/src/Definition/Entity.php
@@ -70,15 +70,15 @@ final class Entity
private array|string|null $typecast = null;
private array $schema = [];
-
private FieldMap $fields;
-
private RelationMap $relations;
private FieldMap $primaryFields;
private array $schemaModifiers = [];
private ?Inheritance $inheritance = null;
+
/** @var class-string|null */
private ?string $stiParent = null;
+
private ForeignKeyMap $foreignKeys;
public function __construct()
@@ -90,18 +90,6 @@ public function __construct()
$this->foreignKeys = new ForeignKeyMap();
}
- /**
- * Full entity copy.
- */
- public function __clone()
- {
- $this->options = clone $this->options;
- $this->fields = clone $this->fields;
- $this->primaryFields = clone $this->primaryFields;
- $this->relations = clone $this->relations;
- $this->foreignKeys = clone $this->foreignKeys;
- }
-
public function getOptions(): OptionMap
{
return $this->options;
@@ -253,7 +241,7 @@ public function getForeignKeys(): ForeignKeyMap
public function addSchemaModifier(SchemaModifierInterface $modifier): self
{
$this->schemaModifiers[] = $modifier->withRole($this->role ?? throw new EntityException(
- 'Entity must have a `role` to be able to add a modifier.'
+ 'Entity must have a `role` to be able to add a modifier.',
));
return $this;
@@ -364,25 +352,6 @@ public function getPrimaryFields(): FieldMap
return $this->primaryFields;
}
- /**
- * @template T of object
- *
- * @param class-string|null $class
- *
- * @return ($class is class-string ? class-string : null)
- */
- private function normalizeClass(string $class = null): ?string
- {
- if ($class === null) {
- return null;
- }
-
- /** @var class-string $class */
- $class = \ltrim($class, '\\');
-
- return $class;
- }
-
public function setInheritance(Inheritance $inheritance): void
{
$this->inheritance = $inheritance;
@@ -434,4 +403,35 @@ public function setTableName(string $tableName): void
{
$this->tableName = $tableName;
}
+
+ /**
+ * Full entity copy.
+ */
+ public function __clone()
+ {
+ $this->options = clone $this->options;
+ $this->fields = clone $this->fields;
+ $this->primaryFields = clone $this->primaryFields;
+ $this->relations = clone $this->relations;
+ $this->foreignKeys = clone $this->foreignKeys;
+ }
+
+ /**
+ * @template T of object
+ *
+ * @param class-string|null $class
+ *
+ * @return ($class is class-string ? class-string : null)
+ */
+ private function normalizeClass(?string $class = null): ?string
+ {
+ if ($class === null) {
+ return null;
+ }
+
+ /** @var class-string $class */
+ $class = \ltrim($class, '\\');
+
+ return $class;
+ }
}
diff --git a/src/Definition/Field.php b/src/Definition/Field.php
index 8cfd9fb..75d34cf 100644
--- a/src/Definition/Field.php
+++ b/src/Definition/Field.php
@@ -34,7 +34,6 @@ final class Field
private array|string|null $typecast = null;
private ?int $generated = null;
-
private bool $referenced = false;
private ?string $entityClass = null;
@@ -44,12 +43,6 @@ public function __construct()
$this->attributes = new OptionMap();
}
- public function __clone()
- {
- $this->options = clone $this->options;
- $this->attributes = clone $this->attributes;
- }
-
public function getOptions(): OptionMap
{
return $this->options;
@@ -105,9 +98,9 @@ public function setColumn(string $column): self
}
/**
+ * @return non-empty-string
* @throws FieldException
*
- * @return non-empty-string
*/
public function getColumn(): string
{
@@ -179,4 +172,10 @@ public function setEntityClass(?string $entityClass): self
return $this;
}
+
+ public function __clone()
+ {
+ $this->options = clone $this->options;
+ $this->attributes = clone $this->attributes;
+ }
}
diff --git a/src/Definition/Inheritance.php b/src/Definition/Inheritance.php
index 30d7aa0..f2f0fb2 100644
--- a/src/Definition/Inheritance.php
+++ b/src/Definition/Inheritance.php
@@ -4,6 +4,4 @@
namespace Cycle\Schema\Definition;
-abstract class Inheritance
-{
-}
+abstract class Inheritance {}
diff --git a/src/Definition/Inheritance/JoinedTable.php b/src/Definition/Inheritance/JoinedTable.php
index 383617f..2a70ef5 100644
--- a/src/Definition/Inheritance/JoinedTable.php
+++ b/src/Definition/Inheritance/JoinedTable.php
@@ -11,9 +11,8 @@ final class JoinedTable extends Inheritance
{
public function __construct(
private Entity $parent,
- private ?string $outerKey = null
- ) {
- }
+ private ?string $outerKey = null,
+ ) {}
public function getOuterKey(): ?string
{
diff --git a/src/Definition/Inheritance/SingleTable.php b/src/Definition/Inheritance/SingleTable.php
index d84698b..78a5f10 100644
--- a/src/Definition/Inheritance/SingleTable.php
+++ b/src/Definition/Inheritance/SingleTable.php
@@ -10,6 +10,7 @@ final class SingleTable extends Inheritance
{
/** @var array */
private array $children = [];
+
private ?string $discriminator = null;
/**
diff --git a/src/Definition/Map/FieldMap.php b/src/Definition/Map/FieldMap.php
index 84251cd..68caf57 100644
--- a/src/Definition/Map/FieldMap.php
+++ b/src/Definition/Map/FieldMap.php
@@ -6,7 +6,6 @@
use Cycle\Schema\Definition\Field;
use Cycle\Schema\Exception\FieldException;
-use Traversable;
/**
* Manage the set of fields associated with the entity.
@@ -18,19 +17,6 @@ final class FieldMap implements \IteratorAggregate, \Countable
/** @var Field[] */
private $fields = [];
- /**
- * Cloning.
- */
- public function __clone()
- {
- foreach ($this->fields as $name => $field) {
- $this->fields[$name] = clone $field;
- }
- }
-
- /**
- * @return int
- */
public function count(): int
{
return count($this->fields);
@@ -54,11 +40,6 @@ public function getNames(): array
return array_keys($this->fields);
}
- /**
- * @param string $name
- *
- * @return bool
- */
public function has(string $name): bool
{
return isset($this->fields[$name]);
@@ -118,12 +99,6 @@ public function getByColumnName(string $name): Field
throw new FieldException("Undefined field with column name `{$name}`.");
}
- /**
- * @param string $name
- * @param Field $field
- *
- * @return FieldMap
- */
public function set(string $name, Field $field): self
{
if ($this->has($name)) {
@@ -135,19 +110,24 @@ public function set(string $name, Field $field): self
return $this;
}
- /**
- * @param string $name
- *
- * @return FieldMap
- */
public function remove(string $name): self
{
unset($this->fields[$name]);
return $this;
}
- public function getIterator(): Traversable
+ public function getIterator(): \Traversable
{
return new \ArrayIterator($this->fields);
}
+
+ /**
+ * Cloning.
+ */
+ public function __clone()
+ {
+ foreach ($this->fields as $name => $field) {
+ $this->fields[$name] = clone $field;
+ }
+ }
}
diff --git a/src/Definition/Map/ForeignKeyMap.php b/src/Definition/Map/ForeignKeyMap.php
index 185a610..9af6e7b 100644
--- a/src/Definition/Map/ForeignKeyMap.php
+++ b/src/Definition/Map/ForeignKeyMap.php
@@ -18,16 +18,6 @@ final class ForeignKeyMap implements \IteratorAggregate, \Countable
*/
private array $foreignKeys = [];
- /**
- * Cloning.
- */
- public function __clone()
- {
- foreach ($this->foreignKeys as $index => $foreignKey) {
- $this->foreignKeys[$index] = clone $foreignKey;
- }
- }
-
public function has(ForeignKey $foreignKey): bool
{
return isset($this->foreignKeys[$this->generateIdentifier($foreignKey)]);
@@ -57,6 +47,16 @@ public function getIterator(): \Traversable
return new \ArrayIterator($this->foreignKeys);
}
+ /**
+ * Cloning.
+ */
+ public function __clone()
+ {
+ foreach ($this->foreignKeys as $index => $foreignKey) {
+ $this->foreignKeys[$index] = clone $foreignKey;
+ }
+ }
+
/**
* @return non-empty-string
*/
@@ -66,7 +66,7 @@ private function generateIdentifier(ForeignKey $foreignKey): string
'%s:%s:%s',
$foreignKey->getTarget(),
\implode(',', $foreignKey->getInnerColumns()),
- \implode(',', $foreignKey->getOuterColumns())
+ \implode(',', $foreignKey->getOuterColumns()),
);
}
}
diff --git a/src/Definition/Map/OptionMap.php b/src/Definition/Map/OptionMap.php
index 81de785..802a869 100644
--- a/src/Definition/Map/OptionMap.php
+++ b/src/Definition/Map/OptionMap.php
@@ -13,11 +13,6 @@ final class OptionMap implements \IteratorAggregate
{
private array $options = [];
- /**
- * @param string $name
- *
- * @return bool
- */
public function has(string $name): bool
{
return array_key_exists($name, $this->options);
diff --git a/src/Definition/Map/RelationMap.php b/src/Definition/Map/RelationMap.php
index 1e17256..9407685 100644
--- a/src/Definition/Map/RelationMap.php
+++ b/src/Definition/Map/RelationMap.php
@@ -6,7 +6,6 @@
use Cycle\Schema\Definition\Relation;
use Cycle\Schema\Exception\RelationException;
-use Traversable;
/**
* @implements \IteratorAggregate
@@ -16,13 +15,6 @@ final class RelationMap implements \IteratorAggregate
/** @var array */
private array $relations = [];
- public function __clone()
- {
- foreach ($this->relations as $name => $relation) {
- $this->relations[$name] = clone $relation;
- }
- }
-
public function has(string $name): bool
{
return isset($this->relations[$name]);
@@ -55,10 +47,17 @@ public function remove(string $name): self
}
/**
- * @return Traversable
+ * @return \Traversable
*/
- public function getIterator(): Traversable
+ public function getIterator(): \Traversable
{
return new \ArrayIterator($this->relations);
}
+
+ public function __clone()
+ {
+ foreach ($this->relations as $name => $relation) {
+ $this->relations[$name] = clone $relation;
+ }
+ }
}
diff --git a/src/Definition/Relation.php b/src/Definition/Relation.php
index f45eeb1..b8fc1a4 100644
--- a/src/Definition/Relation.php
+++ b/src/Definition/Relation.php
@@ -35,27 +35,11 @@ public function __construct()
$this->options = new OptionMap();
}
- /**
- * Cloning.
- */
- public function __clone()
- {
- $this->options = clone $this->options;
- }
-
- /**
- * @return OptionMap
- */
public function getOptions(): OptionMap
{
return $this->options;
}
- /**
- * @param string $type
- *
- * @return Relation
- */
public function setType(string $type): self
{
$this->type = $type;
@@ -63,9 +47,6 @@ public function setType(string $type): self
return $this;
}
- /**
- * @return string
- */
public function getType(): string
{
if ($this->type === null) {
@@ -78,7 +59,6 @@ public function getType(): string
/**
* @param non-empty-string $target
*
- * @return Relation
*/
public function setTarget(string $target): self
{
@@ -99,13 +79,6 @@ public function getTarget(): string
return $this->target;
}
- /**
- * @param string $into
- * @param string $as
- * @param int $load
- *
- * @return Relation
- */
public function setInverse(string $into, string $as, ?int $load = null): self
{
$this->inverse = $into;
@@ -115,35 +88,31 @@ public function setInverse(string $into, string $as, ?int $load = null): self
return $this;
}
- /**
- * @return bool
- */
public function isInversed(): bool
{
return $this->inverse !== null;
}
- /**
- * @return string|null
- */
public function getInverseName(): ?string
{
return $this->inverse;
}
- /**
- * @return string|null
- */
public function getInverseType(): ?string
{
return $this->inverseType;
}
- /**
- * @return int|null
- */
public function getInverseLoad(): ?int
{
return $this->inverseLoad;
}
+
+ /**
+ * Cloning.
+ */
+ public function __clone()
+ {
+ $this->options = clone $this->options;
+ }
}
diff --git a/src/Exception/ColumnException.php b/src/Exception/ColumnException.php
index f19d304..e8ba706 100644
--- a/src/Exception/ColumnException.php
+++ b/src/Exception/ColumnException.php
@@ -4,6 +4,4 @@
namespace Cycle\Schema\Exception;
-class ColumnException extends RegistryException
-{
-}
+class ColumnException extends RegistryException {}
diff --git a/src/Exception/CompilerException.php b/src/Exception/CompilerException.php
index 55e2c55..b7d2169 100644
--- a/src/Exception/CompilerException.php
+++ b/src/Exception/CompilerException.php
@@ -4,6 +4,4 @@
namespace Cycle\Schema\Exception;
-class CompilerException extends \RuntimeException
-{
-}
+class CompilerException extends \RuntimeException {}
diff --git a/src/Exception/EntityException.php b/src/Exception/EntityException.php
index 16d3a82..0398c86 100644
--- a/src/Exception/EntityException.php
+++ b/src/Exception/EntityException.php
@@ -4,6 +4,4 @@
namespace Cycle\Schema\Exception;
-class EntityException extends \RuntimeException
-{
-}
+class EntityException extends \RuntimeException {}
diff --git a/src/Exception/FieldException.php b/src/Exception/FieldException.php
index 9675f12..9b803ba 100644
--- a/src/Exception/FieldException.php
+++ b/src/Exception/FieldException.php
@@ -4,6 +4,4 @@
namespace Cycle\Schema\Exception;
-class FieldException extends RegistryException
-{
-}
+class FieldException extends RegistryException {}
diff --git a/src/Exception/OptionException.php b/src/Exception/OptionException.php
index b4c6c7a..aacbebc 100644
--- a/src/Exception/OptionException.php
+++ b/src/Exception/OptionException.php
@@ -4,6 +4,4 @@
namespace Cycle\Schema\Exception;
-class OptionException extends RegistryException
-{
-}
+class OptionException extends RegistryException {}
diff --git a/src/Exception/RegistryException.php b/src/Exception/RegistryException.php
index 0412450..e2cab0c 100644
--- a/src/Exception/RegistryException.php
+++ b/src/Exception/RegistryException.php
@@ -4,6 +4,4 @@
namespace Cycle\Schema\Exception;
-class RegistryException extends \RuntimeException
-{
-}
+class RegistryException extends \RuntimeException {}
diff --git a/src/Exception/RelationException.php b/src/Exception/RelationException.php
index 06bb082..e6caae9 100644
--- a/src/Exception/RelationException.php
+++ b/src/Exception/RelationException.php
@@ -4,6 +4,4 @@
namespace Cycle\Schema\Exception;
-class RelationException extends SchemaModifierException
-{
-}
+class RelationException extends SchemaModifierException {}
diff --git a/src/Exception/SchemaException.php b/src/Exception/SchemaException.php
index 0d23bac..528f0c3 100644
--- a/src/Exception/SchemaException.php
+++ b/src/Exception/SchemaException.php
@@ -4,6 +4,4 @@
namespace Cycle\Schema\Exception;
-class SchemaException extends \RuntimeException
-{
-}
+class SchemaException extends \RuntimeException {}
diff --git a/src/Exception/SchemaModifierException.php b/src/Exception/SchemaModifierException.php
index 778ad17..13eef4d 100644
--- a/src/Exception/SchemaModifierException.php
+++ b/src/Exception/SchemaModifierException.php
@@ -4,6 +4,4 @@
namespace Cycle\Schema\Exception;
-class SchemaModifierException extends RegistryException
-{
-}
+class SchemaModifierException extends RegistryException {}
diff --git a/src/Exception/SyncException.php b/src/Exception/SyncException.php
index 17090bc..4346f4f 100644
--- a/src/Exception/SyncException.php
+++ b/src/Exception/SyncException.php
@@ -4,6 +4,4 @@
namespace Cycle\Schema\Exception;
-class SyncException extends \RuntimeException
-{
-}
+class SyncException extends \RuntimeException {}
diff --git a/src/Exception/TableInheritance/DiscriminatorColumnNotPresentException.php b/src/Exception/TableInheritance/DiscriminatorColumnNotPresentException.php
index 5e1c39d..f9578ae 100644
--- a/src/Exception/TableInheritance/DiscriminatorColumnNotPresentException.php
+++ b/src/Exception/TableInheritance/DiscriminatorColumnNotPresentException.php
@@ -14,7 +14,7 @@ public function __construct(private Entity $entity)
{
parent::__construct(sprintf(
'Discriminator column for the `%s` role should be defined.',
- (string)($this->entity->getRole() ?? $this->entity->getClass())
+ (string) ($this->entity->getRole() ?? $this->entity->getClass()),
));
}
@@ -30,8 +30,8 @@ public function getSolution(): ?string
return sprintf(
"Discriminator column is required for Single Table Inheritance schema.\n" .
'You have to specify one of the defined fields of the `%s` role: `%s`',
- (string)($this->entity->getRole() ?? $this->entity->getClass()),
- $fields
+ (string) ($this->entity->getRole() ?? $this->entity->getClass()),
+ $fields,
);
}
}
diff --git a/src/Exception/TableInheritance/WrongDiscriminatorColumnException.php b/src/Exception/TableInheritance/WrongDiscriminatorColumnException.php
index 2b9860d..7aaa88e 100644
--- a/src/Exception/TableInheritance/WrongDiscriminatorColumnException.php
+++ b/src/Exception/TableInheritance/WrongDiscriminatorColumnException.php
@@ -15,7 +15,7 @@ public function __construct(private Entity $entity, string $discriminatorColumn)
parent::__construct(sprintf(
'Discriminator column `%s` is not found among fields of the `%s` role.',
$discriminatorColumn,
- (string)($this->entity->getRole() ?? $this->entity->getClass())
+ (string) ($this->entity->getRole() ?? $this->entity->getClass()),
));
}
@@ -30,8 +30,8 @@ public function getSolution(): ?string
return sprintf(
'You have to specify one of the defined fields of the `%s` role: `%s`',
- (string)($this->entity->getRole() ?? $this->entity->getClass()),
- $fields
+ (string) ($this->entity->getRole() ?? $this->entity->getClass()),
+ $fields,
);
}
}
diff --git a/src/Exception/TableInheritance/WrongParentKeyColumnException.php b/src/Exception/TableInheritance/WrongParentKeyColumnException.php
index ba14b34..e532209 100644
--- a/src/Exception/TableInheritance/WrongParentKeyColumnException.php
+++ b/src/Exception/TableInheritance/WrongParentKeyColumnException.php
@@ -15,7 +15,7 @@ public function __construct(private Entity $entity, string $outerKey)
parent::__construct(sprintf(
'Outer key column `%s` is not found among fields of the `%s` role.',
$outerKey,
- (string)($this->entity->getRole() ?? $this->entity->getClass())
+ (string) ($this->entity->getRole() ?? $this->entity->getClass()),
));
}
@@ -30,8 +30,8 @@ public function getSolution(): ?string
return sprintf(
'You have to specify one of the defined fields of the `%s` role: `%s`',
- (string)($this->entity->getRole() ?? $this->entity->getClass()),
- $fields
+ (string) ($this->entity->getRole() ?? $this->entity->getClass()),
+ $fields,
);
}
}
diff --git a/src/Exception/TableInheritanceException.php b/src/Exception/TableInheritanceException.php
index 853b35e..05d9a49 100644
--- a/src/Exception/TableInheritanceException.php
+++ b/src/Exception/TableInheritanceException.php
@@ -4,6 +4,4 @@
namespace Cycle\Schema\Exception;
-class TableInheritanceException extends CompilerException
-{
-}
+class TableInheritanceException extends CompilerException {}
diff --git a/src/Generator/GenerateModifiers.php b/src/Generator/GenerateModifiers.php
index 607b9e0..6090b23 100644
--- a/src/Generator/GenerateModifiers.php
+++ b/src/Generator/GenerateModifiers.php
@@ -37,7 +37,7 @@ protected function register(Registry $registry, Entity $entity): void
throw new SchemaException(
sprintf('Unable to compute modifier `%s` for the `%s` role.', $modifier::class, $role),
$e->getCode(),
- $e
+ $e,
);
}
}
diff --git a/src/Generator/GenerateRelations.php b/src/Generator/GenerateRelations.php
index e44e448..52bbc8a 100644
--- a/src/Generator/GenerateRelations.php
+++ b/src/Generator/GenerateRelations.php
@@ -57,11 +57,7 @@ final class GenerateRelations implements GeneratorInterface
/** @var RelationInterface[] */
private $relations = [];
- /**
- * @param array|null $relations
- * @param OptionSchema|null $optionSchema
- */
- public function __construct(array $relations = null, OptionSchema $optionSchema = null)
+ public function __construct(?array $relations = null, ?OptionSchema $optionSchema = null)
{
$relations = $relations ?? self::getDefaultRelations();
$this->options = $optionSchema ?? new OptionSchema(self::OPTION_MAP);
@@ -71,8 +67,8 @@ public function __construct(array $relations = null, OptionSchema $optionSchema
throw new \InvalidArgumentException(
sprintf(
'Invalid relation type, RelationInterface excepted, `%s` given',
- is_object($relation) ? get_class($relation) : gettype($relation)
- )
+ is_object($relation) ? get_class($relation) : gettype($relation),
+ ),
);
}
@@ -80,11 +76,6 @@ public function __construct(array $relations = null, OptionSchema $optionSchema
}
}
- /**
- * @param Registry $registry
- *
- * @return Registry
- */
public function run(Registry $registry): Registry
{
foreach ($registry as $entity) {
@@ -98,10 +89,21 @@ public function run(Registry $registry): Registry
return $registry;
}
- /**
- * @param Registry $registry
- * @param Entity $entity
- */
+ protected static function getDefaultRelations(): array
+ {
+ return [
+ 'embedded' => new Definition\Embedded(),
+ 'belongsTo' => new Definition\BelongsTo(),
+ 'hasOne' => new Definition\HasOne(),
+ 'hasMany' => new Definition\HasMany(),
+ 'refersTo' => new Definition\RefersTo(),
+ 'manyToMany' => new Definition\ManyToMany(),
+ 'belongsToMorphed' => new Definition\Morphed\BelongsToMorphed(),
+ 'morphedHasOne' => new Definition\Morphed\MorphedHasOne(),
+ 'morphedHasMany' => new Definition\Morphed\MorphedHasMany(),
+ ];
+ }
+
protected function register(Registry $registry, Entity $entity): void
{
$role = $entity->getRole();
@@ -112,7 +114,7 @@ protected function register(Registry $registry, Entity $entity): void
$name,
$role,
$r->getTarget(),
- $this->options->withOptions($r->getOptions())
+ $this->options->withOptions($r->getOptions()),
);
// compute relation values (field names, related entities and etc)
@@ -122,7 +124,7 @@ protected function register(Registry $registry, Entity $entity): void
throw new SchemaException(
"Unable to compute relation `{$role}`.`{$name}`",
$e->getCode(),
- $e
+ $e,
);
}
@@ -130,10 +132,6 @@ protected function register(Registry $registry, Entity $entity): void
}
}
- /**
- * @param Registry $registry
- * @param Entity $entity
- */
protected function inverse(Registry $registry, Entity $entity): void
{
foreach ($entity->getRelations() as $name => $r) {
@@ -155,7 +153,7 @@ protected function inverse(Registry $registry, Entity $entity): void
$inversed = $schema->inverseRelation(
$this->initRelation($inverseType),
$inverseName,
- $r->getInverseLoad()
+ $r->getInverseLoad(),
);
$registry->registerRelation($target, $inverseName, $inversed);
@@ -163,18 +161,13 @@ protected function inverse(Registry $registry, Entity $entity): void
throw new SchemaException(
"Unable to inverse relation `{$entity->getRole()}`.`{$name}`",
$e->getCode(),
- $e
+ $e,
);
}
}
}
}
- /**
- * @param string $type
- *
- * @return RelationInterface
- */
protected function initRelation(string $type): RelationInterface
{
if (!isset($this->relations[$type])) {
@@ -183,22 +176,4 @@ protected function initRelation(string $type): RelationInterface
return $this->relations[$type];
}
-
- /**
- * @return array
- */
- protected static function getDefaultRelations(): array
- {
- return [
- 'embedded' => new Definition\Embedded(),
- 'belongsTo' => new Definition\BelongsTo(),
- 'hasOne' => new Definition\HasOne(),
- 'hasMany' => new Definition\HasMany(),
- 'refersTo' => new Definition\RefersTo(),
- 'manyToMany' => new Definition\ManyToMany(),
- 'belongsToMorphed' => new Definition\Morphed\BelongsToMorphed(),
- 'morphedHasOne' => new Definition\Morphed\MorphedHasOne(),
- 'morphedHasMany' => new Definition\Morphed\MorphedHasMany(),
- ];
- }
}
diff --git a/src/Generator/GenerateTypecast.php b/src/Generator/GenerateTypecast.php
index 58a88fc..1d83069 100644
--- a/src/Generator/GenerateTypecast.php
+++ b/src/Generator/GenerateTypecast.php
@@ -14,11 +14,6 @@
*/
final class GenerateTypecast implements GeneratorInterface
{
- /**
- * @param Registry $registry
- *
- * @return Registry
- */
public function run(Registry $registry): Registry
{
foreach ($registry as $entity) {
@@ -31,8 +26,6 @@ public function run(Registry $registry): Registry
/**
* Automatically clarify column types based on table column types.
*
- * @param Registry $registry
- * @param Entity $entity
*/
protected function compute(Registry $registry, Entity $entity): void
{
@@ -54,7 +47,6 @@ protected function compute(Registry $registry, Entity $entity): void
}
/**
- * @param AbstractColumn $column
*
* @return callable-array|string|null
*/
diff --git a/src/Generator/PrintChanges.php b/src/Generator/PrintChanges.php
index 3c1227e..f3fa6c6 100644
--- a/src/Generator/PrintChanges.php
+++ b/src/Generator/PrintChanges.php
@@ -16,8 +16,7 @@ final class PrintChanges implements GeneratorInterface
public function __construct(
private OutputInterface $output,
- ) {
- }
+ ) {}
public function run(Registry $registry): Registry
{
diff --git a/src/Generator/RenderModifiers.php b/src/Generator/RenderModifiers.php
index e55c657..9f56155 100644
--- a/src/Generator/RenderModifiers.php
+++ b/src/Generator/RenderModifiers.php
@@ -37,7 +37,7 @@ protected function register(Registry $registry, Entity $entity): void
throw new SchemaException(
sprintf('Unable to render modifier `%s` for the `%s` role.', $modifier::class, $role),
$e->getCode(),
- $e
+ $e,
);
}
}
diff --git a/src/Generator/RenderRelations.php b/src/Generator/RenderRelations.php
index eb37f06..75f8bfb 100644
--- a/src/Generator/RenderRelations.php
+++ b/src/Generator/RenderRelations.php
@@ -13,11 +13,6 @@
*/
final class RenderRelations implements GeneratorInterface
{
- /**
- * @param Registry $registry
- *
- * @return Registry
- */
public function run(Registry $registry): Registry
{
foreach ($registry as $entity) {
@@ -27,10 +22,6 @@ public function run(Registry $registry): Registry
return $registry;
}
- /**
- * @param Registry $registry
- * @param Entity $entity
- */
protected function compute(Registry $registry, Entity $entity): void
{
foreach ($registry->getRelations($entity) as $relation) {
diff --git a/src/Generator/ResetTables.php b/src/Generator/ResetTables.php
index dfd8a30..95f92dc 100644
--- a/src/Generator/ResetTables.php
+++ b/src/Generator/ResetTables.php
@@ -12,11 +12,6 @@
*/
final class ResetTables implements GeneratorInterface
{
- /**
- * @param Registry $registry
- *
- * @return Registry
- */
public function run(Registry $registry): Registry
{
foreach ($registry as $entity) {
diff --git a/src/Generator/ResolveInterfaces.php b/src/Generator/ResolveInterfaces.php
index 6cc9d0c..2085cb2 100644
--- a/src/Generator/ResolveInterfaces.php
+++ b/src/Generator/ResolveInterfaces.php
@@ -15,11 +15,6 @@ final class ResolveInterfaces implements GeneratorInterface
// option to indicate that static link resolution is required
public const STATIC_LINK = 'staticLink';
- /**
- * @param Registry $registry
- *
- * @return Registry
- */
public function run(Registry $registry): Registry
{
foreach ($registry as $entity) {
@@ -30,8 +25,6 @@ public function run(Registry $registry): Registry
}
/**
- * @param Registry $registry
- * @param Entity $entity
*
* @throws RelationException
*/
@@ -54,8 +47,6 @@ protected function compute(Registry $registry, Entity $entity): void
}
/**
- * @param Registry $registry
- * @param string $target
*
* @return non-empty-string
*/
diff --git a/src/Generator/SyncTables.php b/src/Generator/SyncTables.php
index 354ba85..d1a3989 100644
--- a/src/Generator/SyncTables.php
+++ b/src/Generator/SyncTables.php
@@ -18,11 +18,9 @@ final class SyncTables implements GeneratorInterface
public const READONLY_SCHEMA = 'readonlySchema';
/**
- * @param Registry $registry
*
* @throws SyncException
*
- * @return Registry
*/
public function run(Registry $registry): Registry
{
@@ -51,11 +49,6 @@ public function run(Registry $registry): Registry
return $registry;
}
- /**
- * @param Registry $registry
- *
- * @return array
- */
private function getRegistryDbList(Registry $registry): array
{
$databases = [];
diff --git a/src/Generator/ValidateEntities.php b/src/Generator/ValidateEntities.php
index f4cf4c6..6743237 100644
--- a/src/Generator/ValidateEntities.php
+++ b/src/Generator/ValidateEntities.php
@@ -11,18 +11,16 @@
final class ValidateEntities implements GeneratorInterface
{
/**
- * @param Registry $registry
*
* @throws EntityException
*
- * @return Registry
*/
public function run(Registry $registry): Registry
{
foreach ($registry->getIterator() as $entity) {
if (count($entity->getFields()) === 0) {
throw new EntityException(
- "Entity `{$entity->getRole()}` is empty"
+ "Entity `{$entity->getRole()}` is empty",
);
}
}
diff --git a/src/GeneratorInterface.php b/src/GeneratorInterface.php
index ee3cb28..e7831bd 100644
--- a/src/GeneratorInterface.php
+++ b/src/GeneratorInterface.php
@@ -9,9 +9,6 @@ interface GeneratorInterface
/**
* Run generator over given registry.
*
- * @param Registry $registry
- *
- * @return Registry
*/
public function run(Registry $registry): Registry;
}
diff --git a/src/InversableInterface.php b/src/InversableInterface.php
index 258a105..3dcf448 100644
--- a/src/InversableInterface.php
+++ b/src/InversableInterface.php
@@ -14,8 +14,6 @@ interface InversableInterface extends RelationInterface
/**
* Return all targets to which relation must be inversed to.
*
- * @param Registry $registry
- *
* @return Entity[]
*/
public function inverseTargets(Registry $registry): array;
@@ -23,11 +21,9 @@ public function inverseTargets(Registry $registry): array;
/**
* Inverse relation options into given schema.
*
- * @param RelationInterface $relation
* @param string $into Target relation name.
* @param int|null $load Target relation pre-load method (null, EAGER, PROMISE)
*
- * @return RelationInterface
*/
public function inverseRelation(RelationInterface $relation, string $into, ?int $load = null): RelationInterface;
}
diff --git a/src/Registry.php b/src/Registry.php
index 5731aac..a65d7f4 100644
--- a/src/Registry.php
+++ b/src/Registry.php
@@ -10,7 +10,6 @@
use Cycle\Database\DatabaseProviderInterface;
use Cycle\Database\Exception\DBALException;
use Cycle\Database\Schema\AbstractTable;
-use Traversable;
/**
* @implements \IteratorAggregate
@@ -19,15 +18,13 @@ final class Registry implements \IteratorAggregate
{
/** @var Entity[] */
private array $entities = [];
+
private DatabaseProviderInterface $dbal;
private \SplObjectStorage $tables;
private \SplObjectStorage $children;
private \SplObjectStorage $relations;
private Defaults $defaults;
- /**
- * @param DatabaseProviderInterface $dbal
- */
public function __construct(DatabaseProviderInterface $dbal, ?Defaults $defaults = null)
{
$this->dbal = $dbal;
@@ -85,7 +82,7 @@ public function getEntity(string $role): Entity
throw new RegistryException("Undefined entity `{$role}`");
}
- public function getIterator(): Traversable
+ public function getIterator(): \Traversable
{
return new \ArrayIterator($this->entities);
}
@@ -161,7 +158,7 @@ public function linkTable(Entity $entity, ?string $database, string $table): sel
}
}
- if (null === $schema) {
+ if ($schema === null) {
$dbTable = $this->dbal->database($database)->table($table);
if (!\method_exists($dbTable, 'getSchema')) {
throw new RegistryException('Unable to retrieve table schema.');
@@ -203,9 +200,9 @@ public function getDatabase(Entity $entity): string
}
/**
+ * @return non-empty-string
* @throws RegistryException
*
- * @return non-empty-string
*/
public function getTable(Entity $entity): string
{
diff --git a/src/Relation/BelongsTo.php b/src/Relation/BelongsTo.php
index 0a5a36d..c78d15f 100644
--- a/src/Relation/BelongsTo.php
+++ b/src/Relation/BelongsTo.php
@@ -45,9 +45,6 @@ final class BelongsTo extends RelationSchema implements InversableInterface
RelationSchema::FK_ON_DELETE => null,
];
- /**
- * @param Registry $registry
- */
public function compute(Registry $registry): void
{
parent::compute($registry);
@@ -62,13 +59,10 @@ public function compute(Registry $registry): void
$target,
Relation::OUTER_KEY,
$source,
- Relation::INNER_KEY
+ Relation::INNER_KEY,
);
}
- /**
- * @param Registry $registry
- */
public function render(Registry $registry): void
{
$source = $registry->getEntity($this->source);
@@ -90,13 +84,12 @@ public function render(Registry $registry): void
$source,
$outerFields,
$innerFields,
- $this->options->get(self::INDEX_CREATE)
+ $this->options->get(self::INDEX_CREATE),
);
}
}
/**
- * @param Registry $registry
*
* @return Entity[]
*/
@@ -108,13 +101,9 @@ public function inverseTargets(Registry $registry): array
}
/**
- * @param RelationInterface $relation
- * @param string $into
- * @param int|null $load
*
* @throws RelationException
*
- * @return RelationInterface
*/
public function inverseRelation(RelationInterface $relation, string $into, ?int $load = null): RelationInterface
{
@@ -130,7 +119,7 @@ public function inverseRelation(RelationInterface $relation, string $into, ?int
Relation::LOAD => $load,
Relation::INNER_KEY => $this->options->get(Relation::OUTER_KEY),
Relation::OUTER_KEY => $this->options->get(Relation::INNER_KEY),
- ])
+ ]),
);
}
}
diff --git a/src/Relation/Embedded.php b/src/Relation/Embedded.php
index 0f2fad5..1b397bc 100644
--- a/src/Relation/Embedded.php
+++ b/src/Relation/Embedded.php
@@ -22,9 +22,6 @@ final class Embedded extends RelationSchema
self::EMBEDDED_PREFIX => '',
];
- /**
- * @param Registry $registry
- */
public function compute(Registry $registry): void
{
$source = $registry->getEntity($this->source);
@@ -68,9 +65,6 @@ public function compute(Registry $registry): void
parent::compute($registry);
}
- /**
- * @param Registry $registry
- */
public function render(Registry $registry): void
{
// relation does not require any column rendering besides actual tables
diff --git a/src/Relation/HasMany.php b/src/Relation/HasMany.php
index a041030..42ce59e 100644
--- a/src/Relation/HasMany.php
+++ b/src/Relation/HasMany.php
@@ -54,9 +54,6 @@ final class HasMany extends RelationSchema implements InversableInterface
RelationSchema::FK_ON_DELETE => null,
];
- /**
- * @param Registry $registry
- */
public function compute(Registry $registry): void
{
parent::compute($registry);
@@ -71,13 +68,10 @@ public function compute(Registry $registry): void
$source,
Relation::INNER_KEY,
$target,
- Relation::OUTER_KEY
+ Relation::OUTER_KEY,
);
}
- /**
- * @param Registry $registry
- */
public function render(Registry $registry): void
{
$source = $registry->getEntity($this->source);
@@ -99,13 +93,12 @@ public function render(Registry $registry): void
$target,
$innerFields,
$outerFields,
- $this->options->get(self::INDEX_CREATE)
+ $this->options->get(self::INDEX_CREATE),
);
}
}
/**
- * @param Registry $registry
*
* @return Entity[]
*/
@@ -117,13 +110,9 @@ public function inverseTargets(Registry $registry): array
}
/**
- * @param RelationInterface $relation
- * @param string $into
- * @param int|null $load
*
* @throws RelationException
*
- * @return RelationInterface
*/
public function inverseRelation(RelationInterface $relation, string $into, ?int $load = null): RelationInterface
{
@@ -143,7 +132,7 @@ public function inverseRelation(RelationInterface $relation, string $into, ?int
Relation::LOAD => $load,
Relation::INNER_KEY => $this->options->get(Relation::OUTER_KEY),
Relation::OUTER_KEY => $this->options->get(Relation::INNER_KEY),
- ])
+ ]),
);
}
}
diff --git a/src/Relation/HasOne.php b/src/Relation/HasOne.php
index f01fe70..9a94c46 100644
--- a/src/Relation/HasOne.php
+++ b/src/Relation/HasOne.php
@@ -45,9 +45,6 @@ final class HasOne extends RelationSchema implements InversableInterface
RelationSchema::FK_ON_DELETE => null,
];
- /**
- * @param Registry $registry
- */
public function compute(Registry $registry): void
{
parent::compute($registry);
@@ -66,9 +63,6 @@ public function compute(Registry $registry): void
);
}
- /**
- * @param Registry $registry
- */
public function render(Registry $registry): void
{
$source = $registry->getEntity($this->source);
@@ -90,13 +84,12 @@ public function render(Registry $registry): void
$target,
$innerFields,
$outerFields,
- $this->options->get(self::INDEX_CREATE)
+ $this->options->get(self::INDEX_CREATE),
);
}
}
/**
- * @param Registry $registry
*
* @return Entity[]
*/
@@ -108,13 +101,9 @@ public function inverseTargets(Registry $registry): array
}
/**
- * @param RelationInterface $relation
- * @param string $into
- * @param int|null $load
*
* @throws RelationException
*
- * @return RelationInterface
*/
public function inverseRelation(RelationInterface $relation, string $into, ?int $load = null): RelationInterface
{
@@ -130,7 +119,7 @@ public function inverseRelation(RelationInterface $relation, string $into, ?int
Relation::LOAD => $load,
Relation::INNER_KEY => $this->options->get(Relation::OUTER_KEY),
Relation::OUTER_KEY => $this->options->get(Relation::INNER_KEY),
- ])
+ ]),
);
}
}
diff --git a/src/Relation/ManyToMany.php b/src/Relation/ManyToMany.php
index 1efff53..c239d7e 100644
--- a/src/Relation/ManyToMany.php
+++ b/src/Relation/ManyToMany.php
@@ -84,7 +84,7 @@ public function compute(Registry $registry): void
throw new RelationException(sprintf(
'Relation ManyToMany must have the throughEntity declaration (%s => ? => %s).',
$source->getRole(),
- $target->getRole()
+ $target->getRole(),
));
}
@@ -94,7 +94,7 @@ public function compute(Registry $registry): void
throw new RelationException(sprintf(
'Relation ManyToMany can only link entities from same database (%s, %s).',
$source->getRole(),
- $target->getRole()
+ $target->getRole(),
));
}
@@ -102,7 +102,7 @@ public function compute(Registry $registry): void
throw new RelationException(sprintf(
'Relation ManyToMany can only link entities from same database (%s, %s)',
$source->getRole(),
- $through->getRole()
+ $through->getRole(),
));
}
@@ -113,20 +113,17 @@ public function compute(Registry $registry): void
$source,
Relation::INNER_KEY,
$through,
- Relation::THROUGH_INNER_KEY
+ Relation::THROUGH_INNER_KEY,
);
$this->createRelatedFields(
$target,
Relation::OUTER_KEY,
$through,
- Relation::THROUGH_OUTER_KEY
+ Relation::THROUGH_OUTER_KEY,
);
}
- /**
- * @param Registry $registry
- */
public function render(Registry $registry): void
{
$source = $registry->getEntity($this->source);
@@ -156,7 +153,7 @@ public function render(Registry $registry): void
$through,
$sourceFields,
$throughSourceFields,
- $this->options->get(self::INDEX_CREATE)
+ $this->options->get(self::INDEX_CREATE),
);
$this->createForeignCompositeKey(
$registry,
@@ -164,13 +161,12 @@ public function render(Registry $registry): void
$through,
$targetFields,
$throughTargetFields,
- $this->options->get(self::INDEX_CREATE)
+ $this->options->get(self::INDEX_CREATE),
);
}
}
/**
- * @param Registry $registry
*
* @return Entity[]
*/
@@ -182,13 +178,9 @@ public function inverseTargets(Registry $registry): array
}
/**
- * @param RelationInterface $relation
- * @param string $into
- * @param int|null $load
*
* @throws RelationException
*
- * @return RelationInterface
*/
public function inverseRelation(RelationInterface $relation, string $into, ?int $load = null): RelationInterface
{
@@ -210,7 +202,7 @@ public function inverseRelation(RelationInterface $relation, string $into, ?int
Relation::OUTER_KEY => $this->options->get(Relation::INNER_KEY),
Relation::THROUGH_INNER_KEY => $this->options->get(Relation::THROUGH_OUTER_KEY),
Relation::THROUGH_OUTER_KEY => $this->options->get(Relation::THROUGH_INNER_KEY),
- ])
+ ]),
);
}
}
diff --git a/src/Relation/Morphed/BelongsToMorphed.php b/src/Relation/Morphed/BelongsToMorphed.php
index 2c7a887..e42853b 100644
--- a/src/Relation/Morphed/BelongsToMorphed.php
+++ b/src/Relation/Morphed/BelongsToMorphed.php
@@ -47,9 +47,6 @@ final class BelongsToMorphed extends RelationSchema implements InversableInterfa
RelationSchema::MORPH_KEY_LENGTH => 32,
];
- /**
- * @param Registry $registry
- */
public function compute(Registry $registry): void
{
// compute local key
@@ -66,7 +63,7 @@ public function compute(Registry $registry): void
'target:primaryKey' => $outerKeys,
]);
- $outerKeys = array_combine($outerKeys, (array)$this->options->get(Relation::INNER_KEY));
+ $outerKeys = array_combine($outerKeys, (array) $this->options->get(Relation::INNER_KEY));
// create target outer field
foreach ($outerKeys as $key => $morphKey) {
@@ -76,16 +73,16 @@ public function compute(Registry $registry): void
$source,
$morphKey,
$outerField,
- $this->options->get(Relation::NULLABLE)
+ $this->options->get(Relation::NULLABLE),
);
}
- foreach ((array)$this->options->get(Relation::MORPH_KEY) as $key) {
+ foreach ((array) $this->options->get(Relation::MORPH_KEY) as $key) {
$this->ensureMorphField(
$source,
$key,
$this->options->get(RelationSchema::MORPH_KEY_LENGTH),
- $this->options->get(Relation::NULLABLE)
+ $this->options->get(Relation::NULLABLE),
);
}
}
@@ -100,7 +97,6 @@ public function render(Registry $registry): void
}
/**
- * @param Registry $registry
*
* @return Entity[]
*/
@@ -110,19 +106,15 @@ public function inverseTargets(Registry $registry): array
}
/**
- * @param RelationInterface $relation
- * @param string $into
- * @param int|null $load
*
* @throws RelationException
*
- * @return RelationInterface
*/
public function inverseRelation(RelationInterface $relation, string $into, ?int $load = null): RelationInterface
{
if (!$relation instanceof MorphedHasOne && !$relation instanceof MorphedHasMany) {
throw new RelationException(
- 'BelongsToMorphed relation can only be inversed into MorphedHasOne or MorphedHasMany'
+ 'BelongsToMorphed relation can only be inversed into MorphedHasOne or MorphedHasMany',
);
}
@@ -134,7 +126,7 @@ public function inverseRelation(RelationInterface $relation, string $into, ?int
Relation::LOAD => $load,
Relation::INNER_KEY => $this->options->get(Relation::OUTER_KEY),
Relation::OUTER_KEY => $this->options->get(Relation::INNER_KEY),
- ])
+ ]),
);
}
}
diff --git a/src/Relation/Morphed/MorphedHasMany.php b/src/Relation/Morphed/MorphedHasMany.php
index 2fd1943..6a8903d 100644
--- a/src/Relation/Morphed/MorphedHasMany.php
+++ b/src/Relation/Morphed/MorphedHasMany.php
@@ -46,9 +46,6 @@ final class MorphedHasMany extends RelationSchema
RelationSchema::MORPH_KEY_LENGTH => 32,
];
- /**
- * @param Registry $registry
- */
public function compute(Registry $registry): void
{
parent::compute($registry);
@@ -69,7 +66,7 @@ public function compute(Registry $registry): void
$target,
$this->options->get(Relation::MORPH_KEY),
$this->options->get(RelationSchema::MORPH_KEY_LENGTH),
- $this->options->get(Relation::NULLABLE)
+ $this->options->get(Relation::NULLABLE),
);
}
diff --git a/src/Relation/Morphed/MorphedHasOne.php b/src/Relation/Morphed/MorphedHasOne.php
index b45ea80..6c95d62 100644
--- a/src/Relation/Morphed/MorphedHasOne.php
+++ b/src/Relation/Morphed/MorphedHasOne.php
@@ -43,9 +43,6 @@ final class MorphedHasOne extends RelationSchema
RelationSchema::MORPH_KEY_LENGTH => 32,
];
- /**
- * @param Registry $registry
- */
public function compute(Registry $registry): void
{
parent::compute($registry);
@@ -66,7 +63,7 @@ public function compute(Registry $registry): void
$target,
$this->options->get(Relation::MORPH_KEY),
$this->options->get(RelationSchema::MORPH_KEY_LENGTH),
- $this->options->get(Relation::NULLABLE)
+ $this->options->get(Relation::NULLABLE),
);
}
diff --git a/src/Relation/OptionSchema.php b/src/Relation/OptionSchema.php
index c0b8b06..6fdeb4f 100644
--- a/src/Relation/OptionSchema.php
+++ b/src/Relation/OptionSchema.php
@@ -12,28 +12,10 @@
final class OptionSchema
{
private array $options = [];
-
private array $template = [];
-
private array $context = [];
- public function __construct(private array $aliases)
- {
- }
-
- public function __debugInfo(): array
- {
- $result = [];
-
- foreach ($this->template as $option => $value) {
- $value = $this->get($option);
-
- $alias = array_search($option, $this->aliases, true);
- $result[$alias] = $value;
- }
-
- return $result;
- }
+ public function __construct(private array $aliases) {}
/**
* Get available options
@@ -127,6 +109,20 @@ public function get(int $option): mixed
return $value;
}
+ public function __debugInfo(): array
+ {
+ $result = [];
+
+ foreach ($this->template as $option => $value) {
+ $value = $this->get($option);
+
+ $alias = array_search($option, $this->aliases, true);
+ $result[$alias] = $value;
+ }
+
+ return $result;
+ }
+
/**
* Calculate option value using templating.
*/
diff --git a/src/Relation/RefersTo.php b/src/Relation/RefersTo.php
index 6aa3ef9..8b1622c 100644
--- a/src/Relation/RefersTo.php
+++ b/src/Relation/RefersTo.php
@@ -58,7 +58,7 @@ public function compute(Registry $registry): void
$target,
Relation::OUTER_KEY,
$source,
- Relation::INNER_KEY
+ Relation::INNER_KEY,
);
}
@@ -83,7 +83,7 @@ public function render(Registry $registry): void
$source,
$outerFields,
$innerFields,
- $this->options->get(self::INDEX_CREATE)
+ $this->options->get(self::INDEX_CREATE),
);
}
}
diff --git a/src/Relation/RelationSchema.php b/src/Relation/RelationSchema.php
index 3a16ad4..2f27530 100644
--- a/src/Relation/RelationSchema.php
+++ b/src/Relation/RelationSchema.php
@@ -151,7 +151,7 @@ protected function hasIndex(
array $columns,
bool $strictOrder = true,
bool $withSorting = true,
- bool $unique = null
+ ?bool $unique = null,
): bool {
if ($strictOrder && $withSorting && $unique === null) {
return $table->hasIndex($columns);
diff --git a/src/Relation/Traits/FieldTrait.php b/src/Relation/Traits/FieldTrait.php
index fc443a4..c7efa24 100644
--- a/src/Relation/Traits/FieldTrait.php
+++ b/src/Relation/Traits/FieldTrait.php
@@ -26,10 +26,10 @@ protected function getField(Entity $entity, int $field): Field
'Field `%s`.`%s` does not exists, referenced by `%s`',
$entity->getRole() ?? 'unknown',
$this->getOptions()->get($field),
- $this->source
+ $this->source,
),
$e->getCode(),
- $e
+ $e,
);
}
}
@@ -37,7 +37,7 @@ protected function getField(Entity $entity, int $field): Field
protected function getFields(Entity $entity, int $option): FieldMap
{
$fields = new FieldMap();
- $keys = (array)$this->getOptions()->get($option);
+ $keys = (array) $this->getOptions()->get($option);
foreach ($keys as $key) {
try {
@@ -48,10 +48,10 @@ protected function getFields(Entity $entity, int $option): FieldMap
'Field `%s`.`%s` does not exists, referenced by `%s`.',
$entity->getRole() ?? 'unknown',
$key,
- $this->source
+ $this->source,
),
$e->getCode(),
- $e
+ $e,
);
}
}
@@ -63,10 +63,10 @@ protected function createRelatedFields(
Entity $source,
int $sourceKey,
Entity $target,
- int $targetKey
+ int $targetKey,
): void {
$sourceFields = $this->getFields($source, $sourceKey);
- $targetColumns = (array)$this->options->get($targetKey);
+ $targetColumns = (array) $this->options->get($targetKey);
$sourceFieldNames = $sourceFields->getNames();
@@ -78,8 +78,8 @@ protected function createRelatedFields(
$source->getRole() ?? 'unknown',
implode('`, `', $this->getFields($source, $sourceKey)->getColumnNames()),
$target->getRole() ?? 'unknown',
- implode('`, `', $targetColumns)
- )
+ implode('`, `', $targetColumns),
+ ),
);
}
@@ -91,7 +91,7 @@ protected function createRelatedFields(
$target,
$targetColumn,
$sourceField,
- $this->options->get(Relation::NULLABLE)
+ $this->options->get(Relation::NULLABLE),
);
}
}
@@ -102,7 +102,7 @@ protected function createRelatedFields(
protected function normalizeContextFields(
Entity $source,
Entity $target,
- array $keys = ['innerKey', 'outerKey']
+ array $keys = ['innerKey', 'outerKey'],
): void {
foreach ($keys as $key) {
$options = $this->options->getOptions();
@@ -111,7 +111,7 @@ protected function normalizeContextFields(
continue;
}
- $columns = (array)$options[$key];
+ $columns = (array) $options[$key];
foreach ($columns as $i => $column) {
$entity = $key === 'innerKey' ? $source : $target;
diff --git a/src/Relation/Traits/ForeignKeyTrait.php b/src/Relation/Traits/ForeignKeyTrait.php
index bba0869..4a618db 100644
--- a/src/Relation/Traits/ForeignKeyTrait.php
+++ b/src/Relation/Traits/ForeignKeyTrait.php
@@ -22,7 +22,7 @@ final protected function createForeignKey(
Entity $target,
Field $innerField,
Field $outerField,
- bool $indexCreate = true
+ bool $indexCreate = true,
): void {
if ($registry->getDatabase($source) !== $registry->getDatabase($target)) {
return;
@@ -44,7 +44,7 @@ final protected function createForeignCompositeKey(
Entity $target,
FieldMap $innerFields,
FieldMap $outerFields,
- bool $indexCreate = true
+ bool $indexCreate = true,
): void {
if ($registry->getDatabase($source) !== $registry->getDatabase($target)) {
return;
diff --git a/src/Relation/Traits/MorphTrait.php b/src/Relation/Traits/MorphTrait.php
index 34408a4..4df32dc 100644
--- a/src/Relation/Traits/MorphTrait.php
+++ b/src/Relation/Traits/MorphTrait.php
@@ -19,11 +19,11 @@ trait MorphTrait
*
* @psalm-assert class-string $interface
*
- * @return Entity[]|Generator
+ * @return Entity[]|\Generator
*
* @psalm-return Generator
*/
- protected function findTargets(Registry $registry, string $interface): Generator
+ protected function findTargets(Registry $registry, string $interface): \Generator
{
foreach ($registry as $entity) {
$class = $entity->getClass();
@@ -38,9 +38,9 @@ protected function findTargets(Registry $registry, string $interface): Generator
/**
* @param non-empty-string $interface
*
+ * @return array Tuple [name, Field]
* @throws RelationException
*
- * @return array Tuple [name, Field]
*/
protected function findOuterKey(Registry $registry, string $interface): array
{
@@ -52,7 +52,7 @@ protected function findOuterKey(Registry $registry, string $interface): array
$primaryFields = $entity->getPrimaryFields();
$primaryKeys = $this->getPrimaryColumns($entity);
- if (null === $keys) {
+ if ($keys === null) {
$keys = $primaryKeys;
$fields = $primaryFields;
$prevEntity = $entity;
@@ -62,12 +62,12 @@ protected function findOuterKey(Registry $registry, string $interface): array
$entity->getRole() ?? 'unknown',
implode(',', $primaryKeys),
$prevEntity->getRole() ?? 'unknown',
- implode(',', $keys)
+ implode(',', $keys),
));
}
}
- if (null === $fields) {
+ if ($fields === null) {
throw new RelationException('Unable to find morphed parent.');
}
@@ -106,7 +106,7 @@ protected function mergeIndex(Registry $registry, Entity $source, FieldMap ...$m
static function (FieldMap $map): array {
return $map->getColumnNames();
},
- $mergeMaps
+ $mergeMaps,
));
if (count($index) > 0) {
diff --git a/src/RelationInterface.php b/src/RelationInterface.php
index 0e303dc..959d518 100644
--- a/src/RelationInterface.php
+++ b/src/RelationInterface.php
@@ -25,6 +25,6 @@ public function withContext(
string $name,
string $source,
string $target,
- OptionSchema $options
+ OptionSchema $options,
): self;
}
diff --git a/src/SchemaModifierInterface.php b/src/SchemaModifierInterface.php
index 72801b2..83a39be 100644
--- a/src/SchemaModifierInterface.php
+++ b/src/SchemaModifierInterface.php
@@ -27,8 +27,6 @@ public function compute(Registry $registry): void;
/**
* Render needed indexes and foreign keys into table.
*
- * @param Registry $registry
- *
* @throws SchemaModifierException
* @throws DBALException
*/
diff --git a/src/Table/Column.php b/src/Table/Column.php
index 60cf933..65bd383 100644
--- a/src/Table/Column.php
+++ b/src/Table/Column.php
@@ -37,8 +37,28 @@ final class Column
private $typeOptions = [];
/**
- * @return string
+ * Parse field definition into table definition.
+ *
+ * @throws ColumnException
+ *
*/
+ public static function parse(Field $field): self
+ {
+ $column = new self();
+ $column->field = $field;
+
+ if (!preg_match(self::DEFINITION, $field->getType(), $type)) {
+ throw new ColumnException("Invalid column type declaration in `{$field->getType()}`");
+ }
+
+ $column->type = $type['type'];
+ if (!empty($type['options'])) {
+ $column->typeOptions = array_map('trim', explode(',', $type['options'] ?? ''));
+ }
+
+ return $column;
+ }
+
public function getName(): string
{
return $this->field->getColumn();
@@ -47,24 +67,17 @@ public function getName(): string
/**
* Get column type.
*
- * @return string
*/
public function getType(): string
{
return $this->type;
}
- /**
- * @return bool
- */
public function isPrimary(): bool
{
return $this->field->isPrimary() || in_array($this->type, ['primary', 'bigPrimary']);
}
- /**
- * @return bool
- */
public function isNullable(): bool
{
if ($this->hasDefault() && $this->getDefault() === null) {
@@ -74,9 +87,6 @@ public function isNullable(): bool
return $this->hasOption(self::OPT_NULLABLE) && !$this->isPrimary();
}
- /**
- * @return bool
- */
public function hasDefault(): bool
{
if ($this->isPrimary()) {
@@ -87,9 +97,9 @@ public function hasDefault(): bool
}
/**
+ * @return mixed
* @throws ColumnException
*
- * @return mixed
*/
public function getDefault()
{
@@ -103,8 +113,6 @@ public function getDefault()
/**
* Render column definition.
*
- * @param AbstractColumn $column
- *
* @throws ColumnException
*/
public function render(AbstractColumn $column): void
@@ -122,7 +130,7 @@ public function render(AbstractColumn $column): void
throw new ColumnException(
"Invalid column type definition in '{$column->getTable()}'.'{$column->getName()}'",
(int) $e->getCode(),
- $e
+ $e,
);
}
@@ -144,33 +152,6 @@ public function render(AbstractColumn $column): void
}
/**
- * Parse field definition into table definition.
- *
- * @param Field $field
- *
- * @throws ColumnException
- *
- * @return Column
- */
- public static function parse(Field $field): self
- {
- $column = new self();
- $column->field = $field;
-
- if (!preg_match(self::DEFINITION, $field->getType(), $type)) {
- throw new ColumnException("Invalid column type declaration in `{$field->getType()}`");
- }
-
- $column->type = $type['type'];
- if (!empty($type['options'])) {
- $column->typeOptions = array_map('trim', explode(',', $type['options'] ?? ''));
- }
-
- return $column;
- }
-
- /**
- * @param AbstractColumn $column
*
* @return bool|float|int|string
*/
@@ -197,11 +178,6 @@ private function castDefault(AbstractColumn $column)
return '';
}
- /**
- * @param string $option
- *
- * @return bool
- */
private function hasOption(string $option): bool
{
return $this->field->getOptions()->has($option);
diff --git a/tests/Schema/BaseTest.php b/tests/Schema/BaseTest.php
index fe19d50..df32add 100644
--- a/tests/Schema/BaseTest.php
+++ b/tests/Schema/BaseTest.php
@@ -28,12 +28,12 @@ abstract class BaseTest extends TestCase
{
// currently active driver
public const DRIVER = null;
+
// tests configuration
public static $config;
// cross test driver cache
public static $driverCache = [];
-
protected static $lastORM;
/** @var Driver */
@@ -48,6 +48,33 @@ abstract class BaseTest extends TestCase
/** @var TestLogger */
protected $logger;
+ /**
+ * Calculates missing parameters for typecasting.
+ *
+ * @return \Cycle\ORM\ORMInterface|ORM
+ */
+ public function withSchema(SchemaInterface $schema)
+ {
+ $this->orm = $this->orm->withSchema($schema);
+ return $this->orm;
+ }
+
+ public function getDriver(): Driver
+ {
+ if (isset(static::$driverCache[static::DRIVER])) {
+ return static::$driverCache[static::DRIVER];
+ }
+
+ $config = self::$config[static::DRIVER];
+ if (!isset($this->driver)) {
+ $this->driver = $config->driver::create($config);
+ }
+
+ $this->driver->setProfiling(true);
+
+ return static::$driverCache[static::DRIVER] = $this->driver;
+ }
+
/**
* Init all we need.
*/
@@ -60,16 +87,16 @@ public function setUp(): void
new Database(
'default',
'',
- $this->getDriver()
- )
+ $this->getDriver(),
+ ),
);
$this->dbal->addDatabase(
new Database(
'secondary',
'secondary_',
- $this->getDriver()
- )
+ $this->getDriver(),
+ ),
);
$this->logger = new TestLogger();
@@ -89,9 +116,9 @@ public function setUp(): void
$this->orm = new ORM(
new Factory(
$this->dbal,
- RelationConfig::getDefault()
+ RelationConfig::getDefault(),
),
- new Schema([])
+ new Schema([]),
);
}
@@ -106,50 +133,12 @@ public function tearDown(): void
$this->dbal = null;
}
- /**
- * Calculates missing parameters for typecasting.
- *
- * @param SchemaInterface $schema
- *
- * @return \Cycle\ORM\ORMInterface|ORM
- */
- public function withSchema(SchemaInterface $schema)
- {
- $this->orm = $this->orm->withSchema($schema);
- return $this->orm;
- }
-
- /**
- * @return Driver
- */
- public function getDriver(): Driver
- {
- if (isset(static::$driverCache[static::DRIVER])) {
- return static::$driverCache[static::DRIVER];
- }
-
- $config = self::$config[static::DRIVER];
- if (!isset($this->driver)) {
- $this->driver = $config->driver::create($config);
- }
-
- $this->driver->setProfiling(true);
-
- return static::$driverCache[static::DRIVER] = $this->driver;
- }
-
- /**
- * @return Database
- */
protected function getDatabase(): Database
{
return $this->dbal->database('default');
}
- /**
- * @param Database|null $database
- */
- protected function dropDatabase(Database $database = null): void
+ protected function dropDatabase(?Database $database = null): void
{
if (empty($database)) {
return;
@@ -177,7 +166,7 @@ protected function dropDatabase(Database $database = null): void
*/
protected function enableProfiling(): void
{
- if (null !== $this->logger) {
+ if ($this->logger !== null) {
$this->logger->display();
}
}
@@ -187,7 +176,7 @@ protected function enableProfiling(): void
*/
protected function disableProfiling(): void
{
- if (null !== $this->logger) {
+ if ($this->logger !== null) {
$this->logger->hide();
}
}
diff --git a/tests/Schema/ColumnTest.php b/tests/Schema/ColumnTest.php
index add4280..ff0c3b1 100644
--- a/tests/Schema/ColumnTest.php
+++ b/tests/Schema/ColumnTest.php
@@ -386,9 +386,6 @@ public function dataIsPrimary(): iterable
];
}
- /**
- * @return AbstractTable
- */
protected function getStub(): AbstractTable
{
return $this->dbal->database('default')->table('sample')->getSchema();
diff --git a/tests/Schema/CompilerTest.php b/tests/Schema/CompilerTest.php
index c55a815..f1a3ee2 100644
--- a/tests/Schema/CompilerTest.php
+++ b/tests/Schema/CompilerTest.php
@@ -21,16 +21,33 @@
final class CompilerTest extends TestCase
{
+ public static function renderTypecastDataProvider(): \Traversable
+ {
+ yield [null, []];
+ yield [Typecaster::class, [], Typecaster::class];
+ yield [[Typecaster::class], [SchemaInterface::TYPECAST_HANDLER => Typecaster::class]];
+ yield [
+ [Typecaster::class, Typecast::class],
+ [SchemaInterface::TYPECAST_HANDLER => Typecast::class],
+ Typecaster::class,
+ ];
+ yield [
+ [Typecaster::class, Typecast::class],
+ [SchemaInterface::TYPECAST_HANDLER => [Typecaster::class, Typecast::class]],
+ Typecaster::class,
+ ];
+ }
+
public function testWrongGeneratorShouldThrowAnException(): void
{
$this->expectException(CompilerException::class);
$this->expectExceptionMessage(
'Invalid generator `\'Cycle\\\\Schema\\\\Tests\\\\Fixtures\\\\Author\'`. '
- . 'It should implement `Cycle\Schema\GeneratorInterface` interface.'
+ . 'It should implement `Cycle\Schema\GeneratorInterface` interface.',
);
$r = new Registry(
- $this->createMock(DatabaseProviderInterface::class)
+ $this->createMock(DatabaseProviderInterface::class),
);
$author = new Entity();
@@ -49,11 +66,11 @@ public function testWrongEntitySchemaModifierShouldThrowAnException(): void
$this->expectException(SchemaModifierException::class);
$this->expectExceptionMessage(
'Unable to apply schema modifier `Cycle\Schema\Tests\Fixtures\BrokenSchemaModifier` '
- . 'for the `author` role. Something went wrong'
+ . 'for the `author` role. Something went wrong',
);
$r = new Registry(
- $this->createMock(DatabaseProviderInterface::class)
+ $this->createMock(DatabaseProviderInterface::class),
);
$author = new Entity();
@@ -96,23 +113,23 @@ public function testRenderGeneratedFields(): void
$entity->getFields()->set(
'createdAt',
(new Field())
- ->setType('datetime')
- ->setColumn('created_at')
- ->setGenerated(GeneratedField::BEFORE_INSERT)
+ ->setType('datetime')
+ ->setColumn('created_at')
+ ->setGenerated(GeneratedField::BEFORE_INSERT),
);
$entity->getFields()->set(
'updatedAt',
(new Field())
- ->setType('datetime')
- ->setColumn('created_at')
- ->setGenerated(GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE)
+ ->setType('datetime')
+ ->setColumn('created_at')
+ ->setGenerated(GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE),
);
$entity->getFields()->set(
'sequence',
(new Field())
- ->setType('serial')
- ->setColumn('some_sequence')
- ->setGenerated(GeneratedField::ON_INSERT)
+ ->setType('serial')
+ ->setColumn('some_sequence')
+ ->setGenerated(GeneratedField::ON_INSERT),
);
$r = new Registry($this->createMock(DatabaseProviderInterface::class));
@@ -126,21 +143,4 @@ public function testRenderGeneratedFields(): void
'sequence' => GeneratedField::ON_INSERT,
], $schema['author'][SchemaInterface::GENERATED_FIELDS]);
}
-
- public static function renderTypecastDataProvider(): \Traversable
- {
- yield [null, []];
- yield [Typecaster::class, [], Typecaster::class];
- yield [[Typecaster::class], [SchemaInterface::TYPECAST_HANDLER => Typecaster::class]];
- yield [
- [Typecaster::class, Typecast::class],
- [SchemaInterface::TYPECAST_HANDLER => Typecast::class],
- Typecaster::class,
- ];
- yield [
- [Typecaster::class, Typecast::class],
- [SchemaInterface::TYPECAST_HANDLER => [Typecaster::class, Typecast::class]],
- Typecaster::class,
- ];
- }
}
diff --git a/tests/Schema/DefaultsTest.php b/tests/Schema/DefaultsTest.php
index 0f82fde..5f3fb58 100644
--- a/tests/Schema/DefaultsTest.php
+++ b/tests/Schema/DefaultsTest.php
@@ -13,6 +13,57 @@
final class DefaultsTest extends TestCase
{
+ public static function mergeDataProvider(): \Traversable
+ {
+ yield [
+ [
+ SchemaInterface::MAPPER => Mapper::class,
+ SchemaInterface::REPOSITORY => Repository::class,
+ SchemaInterface::SOURCE => Source::class,
+ SchemaInterface::SCOPE => null,
+ SchemaInterface::TYPECAST_HANDLER => null,
+ ],
+ [],
+ ];
+ yield [
+ [
+ SchemaInterface::MAPPER => Mapper::class,
+ SchemaInterface::REPOSITORY => Repository::class,
+ SchemaInterface::SOURCE => Source::class,
+ SchemaInterface::SCOPE => null,
+ SchemaInterface::TYPECAST_HANDLER => null,
+ 'foo' => 'bar',
+ ],
+ [
+ 'foo' => 'bar',
+ ],
+ ];
+ yield [
+ [
+ SchemaInterface::MAPPER => Mapper::class,
+ SchemaInterface::REPOSITORY => Repository::class,
+ SchemaInterface::SOURCE => Source::class,
+ SchemaInterface::SCOPE => null,
+ SchemaInterface::TYPECAST_HANDLER => 'foo',
+ ],
+ [
+ SchemaInterface::TYPECAST_HANDLER => 'foo',
+ ],
+ ];
+ yield [
+ [
+ SchemaInterface::MAPPER => null,
+ SchemaInterface::REPOSITORY => Repository::class,
+ SchemaInterface::SOURCE => Source::class,
+ SchemaInterface::SCOPE => null,
+ SchemaInterface::TYPECAST_HANDLER => null,
+ ],
+ [
+ SchemaInterface::MAPPER => null,
+ ],
+ ];
+ }
+
public function testDefaultValues(): void
{
$defaults = new Defaults();
@@ -69,55 +120,4 @@ public function testOffsetUnset(): void
$defaults->offsetUnset(SchemaInterface::MAPPER);
$this->assertFalse($defaults->offsetExists(SchemaInterface::MAPPER));
}
-
- public static function mergeDataProvider(): \Traversable
- {
- yield [
- [
- SchemaInterface::MAPPER => Mapper::class,
- SchemaInterface::REPOSITORY => Repository::class,
- SchemaInterface::SOURCE => Source::class,
- SchemaInterface::SCOPE => null,
- SchemaInterface::TYPECAST_HANDLER => null,
- ],
- [],
- ];
- yield [
- [
- SchemaInterface::MAPPER => Mapper::class,
- SchemaInterface::REPOSITORY => Repository::class,
- SchemaInterface::SOURCE => Source::class,
- SchemaInterface::SCOPE => null,
- SchemaInterface::TYPECAST_HANDLER => null,
- 'foo' => 'bar',
- ],
- [
- 'foo' => 'bar',
- ],
- ];
- yield [
- [
- SchemaInterface::MAPPER => Mapper::class,
- SchemaInterface::REPOSITORY => Repository::class,
- SchemaInterface::SOURCE => Source::class,
- SchemaInterface::SCOPE => null,
- SchemaInterface::TYPECAST_HANDLER => 'foo',
- ],
- [
- SchemaInterface::TYPECAST_HANDLER => 'foo',
- ],
- ];
- yield [
- [
- SchemaInterface::MAPPER => null,
- SchemaInterface::REPOSITORY => Repository::class,
- SchemaInterface::SOURCE => Source::class,
- SchemaInterface::SCOPE => null,
- SchemaInterface::TYPECAST_HANDLER => null,
- ],
- [
- SchemaInterface::MAPPER => null,
- ],
- ];
- }
}
diff --git a/tests/Schema/Definition/Inheritance/JoinedTableInheritanceTest.php b/tests/Schema/Definition/Inheritance/JoinedTableInheritanceTest.php
index 5788f59..1df02df 100644
--- a/tests/Schema/Definition/Inheritance/JoinedTableInheritanceTest.php
+++ b/tests/Schema/Definition/Inheritance/JoinedTableInheritanceTest.php
@@ -21,7 +21,7 @@ class JoinedTableInheritanceTest extends TestCase
public function testJoinedTableShouldBeAddedToSchema()
{
$r = new Registry(
- $this->createMock(DatabaseProviderInterface::class)
+ $this->createMock(DatabaseProviderInterface::class),
);
$user = new Entity();
@@ -45,7 +45,7 @@ public function testJoinedTableShouldBeAddedToSchema()
public function testJoinedTableWithoutOuterKeyShouldBeAddedToSchema()
{
$r = new Registry(
- $this->createMock(DatabaseProviderInterface::class)
+ $this->createMock(DatabaseProviderInterface::class),
);
$user = new Entity();
@@ -72,7 +72,7 @@ public function testJoinedTableWithNonExistsOuterKeyShouldThrowAnException()
$this->expectExceptionMessage('Outer key column `foo_bar` is not found among fields of the `user` role.');
$r = new Registry(
- $this->createMock(DatabaseProviderInterface::class)
+ $this->createMock(DatabaseProviderInterface::class),
);
$user = new Entity();
diff --git a/tests/Schema/Definition/Inheritance/SingleTableInheritanceTest.php b/tests/Schema/Definition/Inheritance/SingleTableInheritanceTest.php
index 07f2c37..9550625 100644
--- a/tests/Schema/Definition/Inheritance/SingleTableInheritanceTest.php
+++ b/tests/Schema/Definition/Inheritance/SingleTableInheritanceTest.php
@@ -22,7 +22,7 @@ class SingleTableInheritanceTest extends TestCase
public function testSingleTableShouldBeAddedToSchema()
{
$r = new Registry(
- $this->createMock(DatabaseProviderInterface::class)
+ $this->createMock(DatabaseProviderInterface::class),
);
$author = new Entity();
@@ -54,7 +54,7 @@ public function testSingleTableShouldBeAddedToSchema()
public function testSingleTableWithExplicitPkShouldBeAddedToSchema()
{
$r = new Registry(
- $this->createMock(DatabaseProviderInterface::class)
+ $this->createMock(DatabaseProviderInterface::class),
);
$author = new Entity();
@@ -90,7 +90,7 @@ public function testSingleTableWithoutDiscriminatorColumnShouldThrowAnException(
$this->expectExceptionMessage('Discriminator column for the `user` role should be defined.');
$r = new Registry(
- $this->createMock(DatabaseProviderInterface::class)
+ $this->createMock(DatabaseProviderInterface::class),
);
$user = new Entity();
@@ -110,7 +110,7 @@ public function testSingleTableWithNonExistsDiscriminatorColumnShouldThrowAnExce
$this->expectExceptionMessage('Discriminator column `type` is not found among fields of the `user` role.');
$r = new Registry(
- $this->createMock(DatabaseProviderInterface::class)
+ $this->createMock(DatabaseProviderInterface::class),
);
$user = new Entity();
@@ -119,7 +119,7 @@ public function testSingleTableWithNonExistsDiscriminatorColumnShouldThrowAnExce
$inheritance->setDiscriminator('type');
$user->getFields()->set(
'id',
- (new Field())->setType('primary')->setColumn('id')
+ (new Field())->setType('primary')->setColumn('id'),
);
$r->register($user);
diff --git a/tests/Schema/Exception/TableInheritance/DiscriminatorColumnNotPresentExceptionTest.php b/tests/Schema/Exception/TableInheritance/DiscriminatorColumnNotPresentExceptionTest.php
index f8a63af..d206742 100644
--- a/tests/Schema/Exception/TableInheritance/DiscriminatorColumnNotPresentExceptionTest.php
+++ b/tests/Schema/Exception/TableInheritance/DiscriminatorColumnNotPresentExceptionTest.php
@@ -23,12 +23,12 @@ public function testGetsSolution()
$this->assertSame(
'Discriminator column is not present.',
- $e->getName()
+ $e->getName(),
);
$this->assertSame(
"Discriminator column is required for Single Table Inheritance schema.\n" .
'You have to specify one of the defined fields of the `author` role: `id`, `name`',
- $e->getSolution()
+ $e->getSolution(),
);
}
}
diff --git a/tests/Schema/Exception/TableInheritance/WrongDiscriminatorColumnExceptionTest.php b/tests/Schema/Exception/TableInheritance/WrongDiscriminatorColumnExceptionTest.php
index 056484a..0e0b516 100644
--- a/tests/Schema/Exception/TableInheritance/WrongDiscriminatorColumnExceptionTest.php
+++ b/tests/Schema/Exception/TableInheritance/WrongDiscriminatorColumnExceptionTest.php
@@ -23,11 +23,11 @@ public function testGetsSolution()
$this->assertSame(
'Discriminator column is not found among the entity fields.',
- $e->getName()
+ $e->getName(),
);
$this->assertSame(
'You have to specify one of the defined fields of the `author` role: `id`, `name`',
- $e->getSolution()
+ $e->getSolution(),
);
}
}
diff --git a/tests/Schema/Exception/TableInheritance/WrongParentKeyColumnExceptionTest.php b/tests/Schema/Exception/TableInheritance/WrongParentKeyColumnExceptionTest.php
index 0edbc62..49bfb59 100644
--- a/tests/Schema/Exception/TableInheritance/WrongParentKeyColumnExceptionTest.php
+++ b/tests/Schema/Exception/TableInheritance/WrongParentKeyColumnExceptionTest.php
@@ -23,11 +23,11 @@ public function testGetsSolution()
$this->assertSame(
'Outer key column is not found among parent entity fields.',
- $e->getName()
+ $e->getName(),
);
$this->assertSame(
'You have to specify one of the defined fields of the `author` role: `id`, `name`',
- $e->getSolution()
+ $e->getSolution(),
);
}
}
diff --git a/tests/Schema/Fixtures/Author.php b/tests/Schema/Fixtures/Author.php
index c8a8e67..2202939 100644
--- a/tests/Schema/Fixtures/Author.php
+++ b/tests/Schema/Fixtures/Author.php
@@ -17,12 +17,12 @@ public static function define(): Entity
$entity->getFields()->set(
'p_id',
- (new Field())->setType('primary')->setColumn('id')->setPrimary(true)
+ (new Field())->setType('primary')->setColumn('id')->setPrimary(true),
);
$entity->getFields()->set(
'p_name',
- (new Field())->setType('string(32)')->setColumn('author_name')
+ (new Field())->setType('string(32)')->setColumn('author_name'),
);
return $entity;
@@ -43,7 +43,7 @@ public static function defineWithUser(): Entity
$entity->getFields()->set(
'p_user_id',
- (new Field())->setType('int(11)')->setColumn('user_id')
+ (new Field())->setType('int(11)')->setColumn('user_id'),
);
return $entity;
@@ -55,7 +55,7 @@ public static function defineCompositePK(): Entity
$entity->getFields()->set(
'p_slug',
- (new Field())->setType('string')->setColumn('slug')->setPrimary(true)
+ (new Field())->setType('string')->setColumn('slug')->setPrimary(true),
);
return $entity;
diff --git a/tests/Schema/Fixtures/AuthorInterface.php b/tests/Schema/Fixtures/AuthorInterface.php
index 4a66346..4856b25 100644
--- a/tests/Schema/Fixtures/AuthorInterface.php
+++ b/tests/Schema/Fixtures/AuthorInterface.php
@@ -4,6 +4,4 @@
namespace Cycle\Schema\Tests\Fixtures;
-interface AuthorInterface
-{
-}
+interface AuthorInterface {}
diff --git a/tests/Schema/Fixtures/BrokenSchemaModifier.php b/tests/Schema/Fixtures/BrokenSchemaModifier.php
index df698b0..36ac2fc 100644
--- a/tests/Schema/Fixtures/BrokenSchemaModifier.php
+++ b/tests/Schema/Fixtures/BrokenSchemaModifier.php
@@ -10,9 +10,7 @@
class BrokenSchemaModifier implements SchemaModifierInterface
{
- public function __construct(private string $brokenMethod)
- {
- }
+ public function __construct(private string $brokenMethod) {}
public function withRole(string $role): static
{
diff --git a/tests/Schema/Fixtures/Composite.php b/tests/Schema/Fixtures/Composite.php
index 7d0ad27..f24643a 100644
--- a/tests/Schema/Fixtures/Composite.php
+++ b/tests/Schema/Fixtures/Composite.php
@@ -24,7 +24,7 @@ public static function define(): Entity
$entity->getFields()->set(
'p_id',
- (new Field())->setType('primary')->setColumn('id')->setPrimary(true)
+ (new Field())->setType('primary')->setColumn('id')->setPrimary(true),
);
return $entity;
@@ -38,7 +38,7 @@ public static function defineWithoutPk(): Entity
$entity->getFields()->set(
'p_id',
- (new Field())->setColumn('id')
+ (new Field())->setColumn('id'),
);
return $entity;
diff --git a/tests/Schema/Fixtures/EmbeddedEntity.php b/tests/Schema/Fixtures/EmbeddedEntity.php
index 67be7d2..7041d46 100644
--- a/tests/Schema/Fixtures/EmbeddedEntity.php
+++ b/tests/Schema/Fixtures/EmbeddedEntity.php
@@ -24,7 +24,7 @@ public static function define(): Entity
$entity->getFields()->set(
'p_embedded',
- (new Field())->setType('string')->setColumn('embedded_column')
+ (new Field())->setType('string')->setColumn('embedded_column'),
);
return $entity;
diff --git a/tests/Schema/Fixtures/In2.php b/tests/Schema/Fixtures/In2.php
index 0d92e2e..26dcdcd 100644
--- a/tests/Schema/Fixtures/In2.php
+++ b/tests/Schema/Fixtures/In2.php
@@ -17,7 +17,7 @@ public static function define(): Entity
$entity->getFields()->set(
'id',
- (new Field())->setType('primary')->setColumn('uuid')->setPrimary(true)
+ (new Field())->setType('primary')->setColumn('uuid')->setPrimary(true),
);
return $entity;
@@ -29,7 +29,7 @@ public static function defineCompositePK(): Entity
$entity->getFields()->set(
'p_slug',
- (new Field())->setType('string')->setColumn('slug')->setPrimary(true)
+ (new Field())->setType('string')->setColumn('slug')->setPrimary(true),
);
return $entity;
diff --git a/tests/Schema/Fixtures/MorphedTo.php b/tests/Schema/Fixtures/MorphedTo.php
index 26ae8a3..4622465 100644
--- a/tests/Schema/Fixtures/MorphedTo.php
+++ b/tests/Schema/Fixtures/MorphedTo.php
@@ -18,12 +18,12 @@ public static function define(): Entity
$entity->getFields()->set(
'p_id',
- (new Field())->setType('primary')->setColumn('id')->setPrimary(true)
+ (new Field())->setType('primary')->setColumn('id')->setPrimary(true),
);
$entity->getRelations()->set(
'parent',
- (new Relation())->setTarget(ParentInterface::class)->setType('belongsToMorphed')
+ (new Relation())->setTarget(ParentInterface::class)->setType('belongsToMorphed'),
);
return $entity;
diff --git a/tests/Schema/Fixtures/ParentInterface.php b/tests/Schema/Fixtures/ParentInterface.php
index 7177e27..b6fec87 100644
--- a/tests/Schema/Fixtures/ParentInterface.php
+++ b/tests/Schema/Fixtures/ParentInterface.php
@@ -4,6 +4,4 @@
namespace Cycle\Schema\Tests\Fixtures;
-interface ParentInterface
-{
-}
+interface ParentInterface {}
diff --git a/tests/Schema/Fixtures/Plain.php b/tests/Schema/Fixtures/Plain.php
index 71eac2a..8ac14e4 100644
--- a/tests/Schema/Fixtures/Plain.php
+++ b/tests/Schema/Fixtures/Plain.php
@@ -18,7 +18,7 @@ public static function define(): Entity
$entity->getFields()->set(
'p_id',
- (new Field())->setType('primary')->setColumn('id')->setPrimary(true)
+ (new Field())->setType('primary')->setColumn('id')->setPrimary(true),
);
return $entity;
@@ -32,7 +32,7 @@ public static function defineWithoutPK(): Entity
$entity->getFields()->set(
'p_id',
- (new Field())->setColumn('id')
+ (new Field())->setColumn('id'),
);
return $entity;
@@ -44,7 +44,7 @@ public static function defineCompositePK(): Entity
$entity->getFields()->set(
'p_slug',
- (new Field())->setType('string')->setColumn('slug')->setPrimary(true)
+ (new Field())->setType('string')->setColumn('slug')->setPrimary(true),
);
return $entity;
diff --git a/tests/Schema/Fixtures/Post.php b/tests/Schema/Fixtures/Post.php
index 92e96cc..bd21e43 100644
--- a/tests/Schema/Fixtures/Post.php
+++ b/tests/Schema/Fixtures/Post.php
@@ -18,12 +18,12 @@ public static function define(): Entity
$entity->getFields()->set(
'p_id',
- (new Field())->setType('primary')->setColumn('id')->setPrimary(true)
+ (new Field())->setType('primary')->setColumn('id')->setPrimary(true),
);
$entity->getRelations()->set(
'author',
- (new Relation())->setTarget(Author::class)->setType('belongsTo')
+ (new Relation())->setTarget(Author::class)->setType('belongsTo'),
);
return $entity;
@@ -37,7 +37,7 @@ public static function defineWithoutPK(): Entity
$entity->getFields()->set(
'p_id',
- (new Field())->setColumn('id')
+ (new Field())->setColumn('id'),
);
return $entity;
@@ -49,7 +49,7 @@ public static function defineCompositePK(): Entity
$entity->getFields()->set(
'p_slug',
- (new Field())->setType('string')->setColumn('slug')->setPrimary(true)
+ (new Field())->setType('string')->setColumn('slug')->setPrimary(true),
);
return $entity;
diff --git a/tests/Schema/Fixtures/Tag.php b/tests/Schema/Fixtures/Tag.php
index 95300dd..da5c138 100644
--- a/tests/Schema/Fixtures/Tag.php
+++ b/tests/Schema/Fixtures/Tag.php
@@ -17,12 +17,12 @@ public static function define(): Entity
$entity->getFields()->set(
'p_id',
- (new Field())->setType('bigPrimary')->setColumn('id')->setPrimary(true)
+ (new Field())->setType('bigPrimary')->setColumn('id')->setPrimary(true),
);
$entity->getFields()->set(
'p_name',
- (new Field())->setType('string(32)')->setColumn('name')
+ (new Field())->setType('string(32)')->setColumn('name'),
);
return $entity;
@@ -36,7 +36,7 @@ public static function defineWithoutPK(): Entity
$entity->getFields()->set(
'p_id',
- (new Field())->setColumn('id')
+ (new Field())->setColumn('id'),
);
return $entity;
@@ -48,7 +48,7 @@ public static function defineCompositePK(): Entity
$entity->getFields()->set(
'p_slug',
- (new Field())->setType('string')->setColumn('slug')->setPrimary(true)
+ (new Field())->setType('string')->setColumn('slug')->setPrimary(true),
);
return $entity;
diff --git a/tests/Schema/Fixtures/TagContext.php b/tests/Schema/Fixtures/TagContext.php
index 9466a67..85d0e66 100644
--- a/tests/Schema/Fixtures/TagContext.php
+++ b/tests/Schema/Fixtures/TagContext.php
@@ -17,7 +17,7 @@ public static function define(): Entity
$entity->getFields()->set(
'p_id',
- (new Field())->setType('bigPrimary')->setColumn('id')->setPrimary(true)
+ (new Field())->setType('bigPrimary')->setColumn('id')->setPrimary(true),
);
return $entity;
diff --git a/tests/Schema/Fixtures/TestLogger.php b/tests/Schema/Fixtures/TestLogger.php
index 0bd49b6..e4d578d 100644
--- a/tests/Schema/Fixtures/TestLogger.php
+++ b/tests/Schema/Fixtures/TestLogger.php
@@ -13,7 +13,6 @@ class TestLogger implements LoggerInterface
use LoggerTrait;
private $display;
-
private $countWrites;
private $countReads;
diff --git a/tests/Schema/Fixtures/Typecaster.php b/tests/Schema/Fixtures/Typecaster.php
index 2e0508d..0951118 100644
--- a/tests/Schema/Fixtures/Typecaster.php
+++ b/tests/Schema/Fixtures/Typecaster.php
@@ -8,11 +8,7 @@
class Typecaster implements TypecastInterface
{
- public function cast(array $values): array
- {
- }
+ public function cast(array $values): array {}
- public function setRules(array $rules): array
- {
- }
+ public function setRules(array $rules): array {}
}
diff --git a/tests/Schema/Fixtures/User.php b/tests/Schema/Fixtures/User.php
index 9bbc2e1..ba3d696 100644
--- a/tests/Schema/Fixtures/User.php
+++ b/tests/Schema/Fixtures/User.php
@@ -19,33 +19,33 @@ public static function define(): Entity
$entity->getFields()->set(
'p_id',
- (new Field())->setType('primary')->setColumn('id')->setPrimary(true)
+ (new Field())->setType('primary')->setColumn('id')->setPrimary(true),
);
$entity->getFields()->set(
'p_name',
- (new Field())->setType('string(32)')->setColumn('user_name')
+ (new Field())->setType('string(32)')->setColumn('user_name'),
);
$entity->getFields()->set(
'p_active',
- (new Field())->setType('bool')->setColumn('active')
+ (new Field())->setType('bool')->setColumn('active'),
);
$entity->getFields()->set(
'p_balance',
- (new Field())->setType('float')->setColumn('balance')
+ (new Field())->setType('float')->setColumn('balance'),
);
$entity->getFields()->set(
'p_created_at',
- (new Field())->setType('datetime')->setColumn('created_at')
+ (new Field())->setType('datetime')->setColumn('created_at'),
);
$entity->getRelations()->set(
'plain',
- (new Relation())->setTarget('plain')->setType('hasOne')
+ (new Relation())->setTarget('plain')->setType('hasOne'),
);
return $entity;
@@ -57,7 +57,7 @@ public static function defineCompositePK(): Entity
$entity->getFields()->set(
'p_slug',
- (new Field())->setType('string')->setColumn('slug')->setPrimary(true)
+ (new Field())->setType('string')->setColumn('slug')->setPrimary(true),
);
return $entity;
@@ -71,7 +71,7 @@ public static function defineWithoutPK(): Entity
$entity->getFields()->set(
'p_id',
- (new Field())->setColumn('id')
+ (new Field())->setColumn('id'),
);
return $entity;
diff --git a/tests/Schema/Generator/GenerateModifiersTest.php b/tests/Schema/Generator/GenerateModifiersTest.php
index f499d68..f45b15c 100644
--- a/tests/Schema/Generator/GenerateModifiersTest.php
+++ b/tests/Schema/Generator/GenerateModifiersTest.php
@@ -23,7 +23,7 @@ class GenerateModifiersTest extends TestCase
public function testEntityShouldBeModified()
{
$r = new Registry(
- $this->createMock(DatabaseProviderInterface::class)
+ $this->createMock(DatabaseProviderInterface::class),
);
$user = new Entity();
@@ -31,7 +31,7 @@ public function testEntityShouldBeModified()
$user->getFields()->set('foo_bar', (new Field())->setType('primary')->setColumn('id'));
$user->addSchemaModifier(
- new class () implements SchemaModifierInterface {
+ new class implements SchemaModifierInterface {
private string $role;
public function withRole(string $role): static
@@ -56,7 +56,7 @@ public function modifySchema(array &$schema): void
{
$schema[SchemaInterface::PARENT] = Author::class;
}
- }
+ },
);
$r->register($user);
@@ -67,7 +67,7 @@ public function modifySchema(array &$schema): void
$this->assertSame(Author::class, $schema['user'][SchemaInterface::PARENT]);
$this->assertSame(
['foo_bar' => 'id', 'type' => 'type'],
- $schema['user'][SchemaInterface::COLUMNS]
+ $schema['user'][SchemaInterface::COLUMNS],
);
}
@@ -78,11 +78,11 @@ public function testErrorInsideModifierShouldThrowAnException(string $method)
{
$this->expectException(SchemaException::class);
$this->expectExceptionMessage(
- 'Unable to compute modifier `Cycle\Schema\Tests\Fixtures\BrokenSchemaModifier` for the `user` role.'
+ 'Unable to compute modifier `Cycle\Schema\Tests\Fixtures\BrokenSchemaModifier` for the `user` role.',
);
$r = new Registry(
- $this->createMock(DatabaseProviderInterface::class)
+ $this->createMock(DatabaseProviderInterface::class),
);
$user = new Entity();
diff --git a/tests/Schema/Generator/GenerateRelationsTest.php b/tests/Schema/Generator/GenerateRelationsTest.php
index 2779efb..1d2389e 100644
--- a/tests/Schema/Generator/GenerateRelationsTest.php
+++ b/tests/Schema/Generator/GenerateRelationsTest.php
@@ -40,7 +40,7 @@ public function relationOptionsDataProvider(): array
public function testHasManyToManyRelationOptions(
string $optionKey,
array|string $optionValue,
- int $relationKey
+ int $relationKey,
): void {
$post = Post::define();
$tag = Tag::define();
@@ -53,8 +53,8 @@ public function testHasManyToManyRelationOptions(
->setType('manyToMany')
->setTarget('tag')
->getOptions()
- ->set('though', 'tagContext')
- ->set($optionKey, $optionValue);
+ ->set('though', 'tagContext')
+ ->set($optionKey, $optionValue);
$r = new Registry($this->dbal);
$r->register($post)->linkTable($post, 'default', 'post');
@@ -67,7 +67,7 @@ public function testHasManyToManyRelationOptions(
// phpcs:ignore
$this->assertSame(
$optionValue,
- $schema['post'][SchemaInterface::RELATIONS]['tags'][Relation::SCHEMA][$relationKey]
+ $schema['post'][SchemaInterface::RELATIONS]['tags'][Relation::SCHEMA][$relationKey],
);
}
@@ -93,7 +93,7 @@ public function testHasManyRelationOptions(string $optionKey, array|string $opti
// phpcs:ignore
$this->assertSame(
$optionValue,
- $schema['user'][SchemaInterface::RELATIONS]['plain'][Relation::SCHEMA][$relationKey]
+ $schema['user'][SchemaInterface::RELATIONS]['plain'][Relation::SCHEMA][$relationKey],
);
}
@@ -124,7 +124,7 @@ public function testHasManyToManyWithoutThroughEntity(): void
$this->assertInstanceOf(RelationException::class, $e->getPrevious());
$this->assertStringContainsString(
'Relation ManyToMany must have the throughEntity declaration',
- $e->getPrevious()->getMessage()
+ $e->getPrevious()->getMessage(),
);
throw $e;
}
diff --git a/tests/Schema/Generator/PrintChangesTest.php b/tests/Schema/Generator/PrintChangesTest.php
index 50cab90..71957db 100644
--- a/tests/Schema/Generator/PrintChangesTest.php
+++ b/tests/Schema/Generator/PrintChangesTest.php
@@ -22,22 +22,6 @@ abstract class PrintChangesTest extends BaseTest
private PrintChanges $generator;
private Compiler $compiler;
- public function setUp(): void
- {
- parent::setUp();
-
- $this->output = new BufferedOutput();
- $this->user = User::define();
-
- $this->registry = new Registry($this->dbal);
- $this->registry->register($this->user);
- $this->registry->linkTable($this->user, 'default', 'users');
-
- $this->generator = new PrintChanges($this->output);
-
- $this->compiler = new Compiler();
- }
-
public function testRunWithoutChanges(): void
{
$this->compiler->compile($this->registry, [new RenderTables()]);
@@ -247,4 +231,20 @@ public function testRunChangedFkVerbose(): void
$this->assertStringNotContainsString('default.users: 3 change(s) detected', $content);
}
+
+ public function setUp(): void
+ {
+ parent::setUp();
+
+ $this->output = new BufferedOutput();
+ $this->user = User::define();
+
+ $this->registry = new Registry($this->dbal);
+ $this->registry->register($this->user);
+ $this->registry->linkTable($this->user, 'default', 'users');
+
+ $this->generator = new PrintChanges($this->output);
+
+ $this->compiler = new Compiler();
+ }
}
diff --git a/tests/Schema/Generator/RenderModifiersTest.php b/tests/Schema/Generator/RenderModifiersTest.php
index c10c73c..5c218a5 100644
--- a/tests/Schema/Generator/RenderModifiersTest.php
+++ b/tests/Schema/Generator/RenderModifiersTest.php
@@ -21,7 +21,7 @@ class RenderModifiersTest extends TestCase
public function testEntityShouldBeRendered()
{
$r = new Registry(
- $this->createMock(DatabaseProviderInterface::class)
+ $this->createMock(DatabaseProviderInterface::class),
);
$user = new Entity();
@@ -51,11 +51,11 @@ public function testErrorInsideModifierShouldThrowAnException(string $method)
{
$this->expectException(SchemaException::class);
$this->expectExceptionMessage(
- 'Unable to render modifier `Cycle\Schema\Tests\Fixtures\BrokenSchemaModifier` for the `user` role.'
+ 'Unable to render modifier `Cycle\Schema\Tests\Fixtures\BrokenSchemaModifier` for the `user` role.',
);
$r = new Registry(
- $this->createMock(DatabaseProviderInterface::class)
+ $this->createMock(DatabaseProviderInterface::class),
);
$user = new Entity();
diff --git a/tests/Schema/Generator/RenderRelationsTest.php b/tests/Schema/Generator/RenderRelationsTest.php
index 5232712..bb78a00 100644
--- a/tests/Schema/Generator/RenderRelationsTest.php
+++ b/tests/Schema/Generator/RenderRelationsTest.php
@@ -31,7 +31,7 @@ public function testFkActionAndFkOnDelete(
null|false|string $fkActionOption,
null|false|string $onDeleteOption,
string $onUpdateExpected,
- string $onDeleteExpected
+ string $onDeleteExpected,
): void {
$plain = Plain::define();
$user = User::define();
diff --git a/tests/Schema/Generator/TableGeneratorTest.php b/tests/Schema/Generator/TableGeneratorTest.php
index e26af39..f04b51a 100644
--- a/tests/Schema/Generator/TableGeneratorTest.php
+++ b/tests/Schema/Generator/TableGeneratorTest.php
@@ -48,7 +48,7 @@ public function testCompiled(): void
(new RenderTables())->run($r),
defaults: [
Schema::TYPECAST_HANDLER => 'default_typecaster',
- ]
+ ],
);
$this->assertSame([
@@ -85,7 +85,7 @@ public function testCompiledWithPassedDefaultTypecastHandler(): void
(new RenderTables())->run($r),
defaults: [
Schema::TYPECAST_HANDLER => Typecaster::class,
- ]
+ ],
);
$this->assertSame([
diff --git a/tests/Schema/RegistryTest.php b/tests/Schema/RegistryTest.php
index e2977f6..1614c6a 100644
--- a/tests/Schema/RegistryTest.php
+++ b/tests/Schema/RegistryTest.php
@@ -121,7 +121,7 @@ public function testRegisterChildNoEntity(): void
$e->getFields()->set(
'id',
- (new Field())->setType('primary')->setColumn('id')
+ (new Field())->setType('primary')->setColumn('id'),
);
$r = new Registry($this->dbal);
@@ -132,12 +132,12 @@ public function testRegisterChildNoEntity(): void
$c->getFields()->set(
'id',
- (new Field())->setType('primary')->setColumn('id')
+ (new Field())->setType('primary')->setColumn('id'),
);
$c->getFields()->set(
'name',
- (new Field())->setType('string')->setColumn('name')
+ (new Field())->setType('string')->setColumn('name'),
);
$this->expectException(RegistryException::class);
@@ -153,7 +153,7 @@ public function testRegisterChild(): void
$e->getFields()->set(
'id',
- (new Field())->setType('primary')->setColumn('id')
+ (new Field())->setType('primary')->setColumn('id'),
);
$r = new Registry($this->dbal);
@@ -165,12 +165,12 @@ public function testRegisterChild(): void
$c->getFields()->set(
'id',
- (new Field())->setType('primary')->setColumn('id')
+ (new Field())->setType('primary')->setColumn('id'),
);
$c->getFields()->set(
'name',
- (new Field())->setType('string')->setColumn('name')
+ (new Field())->setType('string')->setColumn('name'),
);
$r->registerChild($e, $c);
diff --git a/tests/Schema/Relation/BelongsToRelationCompositePKTest.php b/tests/Schema/Relation/BelongsToRelationCompositePKTest.php
index 646f148..59fbefd 100644
--- a/tests/Schema/Relation/BelongsToRelationCompositePKTest.php
+++ b/tests/Schema/Relation/BelongsToRelationCompositePKTest.php
@@ -215,17 +215,17 @@ public function testInverseToHasOne(): void
$this->assertSame(
'post',
- $schema['author'][Schema::RELATIONS]['post'][Relation::TARGET]
+ $schema['author'][Schema::RELATIONS]['post'][Relation::TARGET],
);
$this->assertSame(
['author_p_id', 'author_p_slug'],
- $schema['author'][Schema::RELATIONS]['post'][Relation::SCHEMA][Relation::OUTER_KEY]
+ $schema['author'][Schema::RELATIONS]['post'][Relation::SCHEMA][Relation::OUTER_KEY],
);
$this->assertSame(
['p_id', 'p_slug'],
- $schema['author'][Schema::RELATIONS]['post'][Relation::SCHEMA][Relation::INNER_KEY]
+ $schema['author'][Schema::RELATIONS]['post'][Relation::SCHEMA][Relation::INNER_KEY],
);
}
@@ -252,17 +252,17 @@ public function testInverseToHasMany(): void
$this->assertSame(
'post',
- $schema['author'][Schema::RELATIONS]['post'][Relation::TARGET]
+ $schema['author'][Schema::RELATIONS]['post'][Relation::TARGET],
);
$this->assertSame(
['author_p_id', 'author_p_slug'],
- $schema['author'][Schema::RELATIONS]['post'][Relation::SCHEMA][Relation::OUTER_KEY]
+ $schema['author'][Schema::RELATIONS]['post'][Relation::SCHEMA][Relation::OUTER_KEY],
);
$this->assertSame(
['p_id', 'p_slug'],
- $schema['author'][Schema::RELATIONS]['post'][Relation::SCHEMA][Relation::INNER_KEY]
+ $schema['author'][Schema::RELATIONS]['post'][Relation::SCHEMA][Relation::INNER_KEY],
);
}
}
diff --git a/tests/Schema/Relation/BelongsToRelationTest.php b/tests/Schema/Relation/BelongsToRelationTest.php
index dfc1213..23fd236 100644
--- a/tests/Schema/Relation/BelongsToRelationTest.php
+++ b/tests/Schema/Relation/BelongsToRelationTest.php
@@ -224,17 +224,17 @@ public function testInverseToHasOne(): void
$this->assertSame(
'post',
- $schema['author'][Schema::RELATIONS]['post'][Relation::TARGET]
+ $schema['author'][Schema::RELATIONS]['post'][Relation::TARGET],
);
$this->assertSame(
'author_p_id',
- $schema['author'][Schema::RELATIONS]['post'][Relation::SCHEMA][Relation::OUTER_KEY]
+ $schema['author'][Schema::RELATIONS]['post'][Relation::SCHEMA][Relation::OUTER_KEY],
);
$this->assertSame(
['p_id'],
- $schema['author'][Schema::RELATIONS]['post'][Relation::SCHEMA][Relation::INNER_KEY]
+ $schema['author'][Schema::RELATIONS]['post'][Relation::SCHEMA][Relation::INNER_KEY],
);
}
@@ -261,17 +261,17 @@ public function testInverseToHasMany(): void
$this->assertSame(
'post',
- $schema['author'][Schema::RELATIONS]['post'][Relation::TARGET]
+ $schema['author'][Schema::RELATIONS]['post'][Relation::TARGET],
);
$this->assertSame(
'author_p_id',
- $schema['author'][Schema::RELATIONS]['post'][Relation::SCHEMA][Relation::OUTER_KEY]
+ $schema['author'][Schema::RELATIONS]['post'][Relation::SCHEMA][Relation::OUTER_KEY],
);
$this->assertSame(
['p_id'],
- $schema['author'][Schema::RELATIONS]['post'][Relation::SCHEMA][Relation::INNER_KEY]
+ $schema['author'][Schema::RELATIONS]['post'][Relation::SCHEMA][Relation::INNER_KEY],
);
}
diff --git a/tests/Schema/Relation/EmbeddedTest.php b/tests/Schema/Relation/EmbeddedTest.php
index d7b0a2b..b4c65da 100644
--- a/tests/Schema/Relation/EmbeddedTest.php
+++ b/tests/Schema/Relation/EmbeddedTest.php
@@ -28,7 +28,7 @@ public function testGenerate(): void
$c->getRelations()->set(
'embedded',
- (new Relation())->setTarget('embedded')->setType('embedded')
+ (new Relation())->setTarget('embedded')->setType('embedded'),
);
$r = new Registry($this->dbal);
@@ -50,7 +50,7 @@ public function testThrowAnExceptionWhenPkNotDefinedInSource(): void
$c->getRelations()->set(
'embedded',
- (new Relation())->setTarget('embedded')->setType('embedded')
+ (new Relation())->setTarget('embedded')->setType('embedded'),
);
$r = new Registry($this->dbal);
@@ -69,7 +69,7 @@ public function testPackSchema(): void
$c->getRelations()->set(
'embedded',
- (new Relation())->setTarget('embedded')->setType('embedded')
+ (new Relation())->setTarget('embedded')->setType('embedded'),
);
$r = new Registry($this->dbal);
@@ -83,12 +83,12 @@ public function testPackSchema(): void
$this->assertArrayHasKey('embedded', $schema['composite'][Schema::RELATIONS]);
$this->assertSame(
\Cycle\ORM\Relation::EMBEDDED,
- $schema['composite'][Schema::RELATIONS]['embedded'][\Cycle\ORM\Relation::TYPE]
+ $schema['composite'][Schema::RELATIONS]['embedded'][\Cycle\ORM\Relation::TYPE],
);
$this->assertSame(
\Cycle\ORM\Relation::LOAD_EAGER,
- $schema['composite'][Schema::RELATIONS]['embedded'][\Cycle\ORM\Relation::LOAD]
+ $schema['composite'][Schema::RELATIONS]['embedded'][\Cycle\ORM\Relation::LOAD],
);
$this->assertArrayHasKey('composite:embedded:embedded', $schema);
@@ -111,7 +111,7 @@ public function testPackSchemaLazyLoad(): void
$c->getRelations()->set(
'embedded',
- (new Relation())->setTarget('embedded')->setType('embedded')
+ (new Relation())->setTarget('embedded')->setType('embedded'),
);
$c->getRelations()->get('embedded')->getOptions()->set('load', 'lazy');
@@ -127,12 +127,12 @@ public function testPackSchemaLazyLoad(): void
$this->assertArrayHasKey('embedded', $schema['composite'][Schema::RELATIONS]);
$this->assertSame(
\Cycle\ORM\Relation::EMBEDDED,
- $schema['composite'][Schema::RELATIONS]['embedded'][\Cycle\ORM\Relation::TYPE]
+ $schema['composite'][Schema::RELATIONS]['embedded'][\Cycle\ORM\Relation::TYPE],
);
$this->assertSame(
\Cycle\ORM\Relation::LOAD_PROMISE,
- $schema['composite'][Schema::RELATIONS]['embedded'][\Cycle\ORM\Relation::LOAD]
+ $schema['composite'][Schema::RELATIONS]['embedded'][\Cycle\ORM\Relation::LOAD],
);
$this->assertArrayHasKey('composite:embedded:embedded', $schema);
@@ -153,7 +153,7 @@ public function testRenderTable(): void
$c->getRelations()->set(
'embedded',
- (new Relation())->setTarget('embedded')->setType('embedded')
+ (new Relation())->setTarget('embedded')->setType('embedded'),
);
$c->getRelations()->get('embedded')->getOptions()->set('load', 'lazy');
@@ -186,7 +186,7 @@ public function testEmbedIdFieldWithPrefix(): void
$c->getRelations()->set(
'embedded',
- (new Relation())->setTarget('embedded')->setType('embedded')
+ (new Relation())->setTarget('embedded')->setType('embedded'),
);
$r = new Registry($this->dbal);
@@ -202,7 +202,7 @@ public function testEmbedIdFieldWithPrefix(): void
new GenerateRelations(['embedded' => new Embedded()]),
$t = new RenderTables(),
new RenderRelations(),
- ]
+ ],
);
}
@@ -213,7 +213,7 @@ public function testEmbeddedPrefix(): void
$c->getRelations()->set(
'embedded',
- (new Relation())->setTarget('embedded')->setType('embedded')
+ (new Relation())->setTarget('embedded')->setType('embedded'),
);
$c->getRelations()->get('embedded')->getOptions()->set('embeddedPrefix', 'prefix_');
diff --git a/tests/Schema/Relation/HasManyRelationCompositePKTest.php b/tests/Schema/Relation/HasManyRelationCompositePKTest.php
index b5aee4a..79ecbb8 100644
--- a/tests/Schema/Relation/HasManyRelationCompositePKTest.php
+++ b/tests/Schema/Relation/HasManyRelationCompositePKTest.php
@@ -211,17 +211,17 @@ public function testInverseToBelongsTo(): void
$this->assertSame(
'user',
- $schema['plain'][Schema::RELATIONS]['user'][Relation::TARGET]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::TARGET],
);
$this->assertSame(
['p_id', 'p_slug'],
- $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::OUTER_KEY]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::OUTER_KEY],
);
$this->assertSame(
['user_p_id', 'user_p_slug'],
- $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::INNER_KEY]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::INNER_KEY],
);
}
@@ -249,17 +249,17 @@ public function testInverseToRefersTo(): void
$this->assertSame(
'user',
- $schema['plain'][Schema::RELATIONS]['user'][Relation::TARGET]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::TARGET],
);
$this->assertSame(
['p_id', 'p_slug'],
- $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::OUTER_KEY]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::OUTER_KEY],
);
$this->assertSame(
['user_p_id', 'user_p_slug'],
- $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::INNER_KEY]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::INNER_KEY],
);
}
}
diff --git a/tests/Schema/Relation/HasManyRelationTest.php b/tests/Schema/Relation/HasManyRelationTest.php
index 1bf4975..78910e1 100644
--- a/tests/Schema/Relation/HasManyRelationTest.php
+++ b/tests/Schema/Relation/HasManyRelationTest.php
@@ -103,7 +103,7 @@ public function testPackSchema(): void
$this->assertSame(
ArrayCollectionFactory::class,
- $schema['user'][Schema::RELATIONS]['plain'][Relation::SCHEMA][Relation::COLLECTION_TYPE]
+ $schema['user'][Schema::RELATIONS]['plain'][Relation::SCHEMA][Relation::COLLECTION_TYPE],
);
}
@@ -230,17 +230,17 @@ public function testInverseToBelongsTo(): void
$this->assertSame(
'user',
- $schema['plain'][Schema::RELATIONS]['user'][Relation::TARGET]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::TARGET],
);
$this->assertSame(
['p_id'],
- $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::OUTER_KEY]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::OUTER_KEY],
);
$this->assertSame(
'user_p_id',
- $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::INNER_KEY]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::INNER_KEY],
);
}
@@ -268,17 +268,17 @@ public function testInverseToRefersTo(): void
$this->assertSame(
'user',
- $schema['plain'][Schema::RELATIONS]['user'][Relation::TARGET]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::TARGET],
);
$this->assertSame(
['p_id'],
- $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::OUTER_KEY]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::OUTER_KEY],
);
$this->assertSame(
'user_p_id',
- $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::INNER_KEY]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::INNER_KEY],
);
}
diff --git a/tests/Schema/Relation/HasOneRelationCompositePKTest.php b/tests/Schema/Relation/HasOneRelationCompositePKTest.php
index e31abd0..29536f7 100644
--- a/tests/Schema/Relation/HasOneRelationCompositePKTest.php
+++ b/tests/Schema/Relation/HasOneRelationCompositePKTest.php
@@ -280,17 +280,17 @@ public function testInverseToBelongsTo(): void
$this->assertSame(
'user',
- $schema['plain'][Schema::RELATIONS]['user'][Relation::TARGET]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::TARGET],
);
$this->assertSame(
['p_id', 'p_slug'],
- $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::OUTER_KEY]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::OUTER_KEY],
);
$this->assertSame(
['user_p_id', 'user_p_slug'],
- $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::INNER_KEY]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::INNER_KEY],
);
}
@@ -320,17 +320,17 @@ public function testInverseToBelongsLoadEager(): void
$this->assertSame(
'user',
- $schema['plain'][Schema::RELATIONS]['user'][Relation::TARGET]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::TARGET],
);
$this->assertSame(
['p_id', 'p_slug'],
- $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::OUTER_KEY]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::OUTER_KEY],
);
$this->assertSame(
['user_p_id', 'user_p_slug'],
- $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::INNER_KEY]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::INNER_KEY],
);
}
@@ -358,17 +358,17 @@ public function testInverseToRefersTo(): void
$this->assertSame(
'user',
- $schema['plain'][Schema::RELATIONS]['user'][Relation::TARGET]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::TARGET],
);
$this->assertSame(
['p_id', 'p_slug'],
- $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::OUTER_KEY]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::OUTER_KEY],
);
$this->assertSame(
['user_p_id', 'user_p_slug'],
- $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::INNER_KEY]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::INNER_KEY],
);
}
}
diff --git a/tests/Schema/Relation/HasOneRelationTest.php b/tests/Schema/Relation/HasOneRelationTest.php
index 44e7331..08d5600 100644
--- a/tests/Schema/Relation/HasOneRelationTest.php
+++ b/tests/Schema/Relation/HasOneRelationTest.php
@@ -288,17 +288,17 @@ public function testInverseToBelongsTo(): void
$this->assertSame(
'user',
- $schema['plain'][Schema::RELATIONS]['user'][Relation::TARGET]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::TARGET],
);
$this->assertSame(
['p_id'],
- $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::OUTER_KEY]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::OUTER_KEY],
);
$this->assertSame(
'user_p_id',
- $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::INNER_KEY]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::INNER_KEY],
);
}
@@ -328,17 +328,17 @@ public function testInverseToBelongsLoadEager(): void
$this->assertSame(
'user',
- $schema['plain'][Schema::RELATIONS]['user'][Relation::TARGET]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::TARGET],
);
$this->assertSame(
['p_id'],
- $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::OUTER_KEY]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::OUTER_KEY],
);
$this->assertSame(
'user_p_id',
- $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::INNER_KEY]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::INNER_KEY],
);
}
@@ -366,17 +366,17 @@ public function testInverseToRefersTo(): void
$this->assertSame(
'user',
- $schema['plain'][Schema::RELATIONS]['user'][Relation::TARGET]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::TARGET],
);
$this->assertSame(
['p_id'],
- $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::OUTER_KEY]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::OUTER_KEY],
);
$this->assertSame(
'user_p_id',
- $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::INNER_KEY]
+ $schema['plain'][Schema::RELATIONS]['user'][Relation::SCHEMA][Relation::INNER_KEY],
);
}
diff --git a/tests/Schema/Relation/ManyToManyRelationCompositePKTest.php b/tests/Schema/Relation/ManyToManyRelationCompositePKTest.php
index edcbdb3..a5185d2 100644
--- a/tests/Schema/Relation/ManyToManyRelationCompositePKTest.php
+++ b/tests/Schema/Relation/ManyToManyRelationCompositePKTest.php
@@ -125,32 +125,32 @@ public function testPackSchema(): void
$this->assertSame('tag', $schema['post'][Schema::RELATIONS]['tags'][Relation::TARGET]);
$this->assertSame(
Relation::MANY_TO_MANY,
- $schema['post'][Schema::RELATIONS]['tags'][Relation::TYPE]
+ $schema['post'][Schema::RELATIONS]['tags'][Relation::TYPE],
);
$this->assertSame(
['p_id', 'p_slug'],
- $schema['post'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::INNER_KEY]
+ $schema['post'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::INNER_KEY],
);
$this->assertSame(
['p_id', 'p_slug'],
- $schema['post'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::OUTER_KEY]
+ $schema['post'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::OUTER_KEY],
);
$this->assertSame(
['post_p_id', 'post_p_slug'],
- $schema['post'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::THROUGH_INNER_KEY]
+ $schema['post'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::THROUGH_INNER_KEY],
);
$this->assertSame(
['tag_p_id', 'tag_p_slug'],
- $schema['post'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::THROUGH_OUTER_KEY]
+ $schema['post'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::THROUGH_OUTER_KEY],
);
$this->assertSame(
'tagContext',
- $schema['post'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::THROUGH_ENTITY]
+ $schema['post'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::THROUGH_ENTITY],
);
}
@@ -253,32 +253,32 @@ public function testInverse(): void
$this->assertSame('post', $schema['tag'][Schema::RELATIONS]['posts'][Relation::TARGET]);
$this->assertSame(
Relation::MANY_TO_MANY,
- $schema['tag'][Schema::RELATIONS]['posts'][Relation::TYPE]
+ $schema['tag'][Schema::RELATIONS]['posts'][Relation::TYPE],
);
$this->assertSame(
['p_id', 'p_slug'],
- $schema['tag'][Schema::RELATIONS]['posts'][Relation::SCHEMA][Relation::INNER_KEY]
+ $schema['tag'][Schema::RELATIONS]['posts'][Relation::SCHEMA][Relation::INNER_KEY],
);
$this->assertSame(
['p_id', 'p_slug'],
- $schema['tag'][Schema::RELATIONS]['posts'][Relation::SCHEMA][Relation::OUTER_KEY]
+ $schema['tag'][Schema::RELATIONS]['posts'][Relation::SCHEMA][Relation::OUTER_KEY],
);
$this->assertSame(
['tag_p_id', 'tag_p_slug'],
- $schema['tag'][Schema::RELATIONS]['posts'][Relation::SCHEMA][Relation::THROUGH_INNER_KEY]
+ $schema['tag'][Schema::RELATIONS]['posts'][Relation::SCHEMA][Relation::THROUGH_INNER_KEY],
);
$this->assertSame(
['post_p_id', 'post_p_slug'],
- $schema['tag'][Schema::RELATIONS]['posts'][Relation::SCHEMA][Relation::THROUGH_OUTER_KEY]
+ $schema['tag'][Schema::RELATIONS]['posts'][Relation::SCHEMA][Relation::THROUGH_OUTER_KEY],
);
$this->assertSame(
'tagContext',
- $schema['tag'][Schema::RELATIONS]['posts'][Relation::SCHEMA][Relation::THROUGH_ENTITY]
+ $schema['tag'][Schema::RELATIONS]['posts'][Relation::SCHEMA][Relation::THROUGH_ENTITY],
);
}
}
diff --git a/tests/Schema/Relation/ManyToManyRelationTest.php b/tests/Schema/Relation/ManyToManyRelationTest.php
index f20b792..c2304e1 100644
--- a/tests/Schema/Relation/ManyToManyRelationTest.php
+++ b/tests/Schema/Relation/ManyToManyRelationTest.php
@@ -181,37 +181,37 @@ public function testPackSchema(): void
$this->assertSame('tag', $schema['post'][Schema::RELATIONS]['tags'][Relation::TARGET]);
$this->assertSame(
Relation::MANY_TO_MANY,
- $schema['post'][Schema::RELATIONS]['tags'][Relation::TYPE]
+ $schema['post'][Schema::RELATIONS]['tags'][Relation::TYPE],
);
$this->assertSame(
ArrayCollectionFactory::class,
- $schema['post'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::COLLECTION_TYPE]
+ $schema['post'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::COLLECTION_TYPE],
);
$this->assertSame(
['p_id'],
- $schema['post'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::INNER_KEY]
+ $schema['post'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::INNER_KEY],
);
$this->assertSame(
['p_id'],
- $schema['post'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::OUTER_KEY]
+ $schema['post'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::OUTER_KEY],
);
$this->assertSame(
'post_p_id',
- $schema['post'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::THROUGH_INNER_KEY]
+ $schema['post'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::THROUGH_INNER_KEY],
);
$this->assertSame(
'tag_p_id',
- $schema['post'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::THROUGH_OUTER_KEY]
+ $schema['post'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::THROUGH_OUTER_KEY],
);
$this->assertSame(
'tagContext',
- $schema['post'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::THROUGH_ENTITY]
+ $schema['post'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::THROUGH_ENTITY],
);
}
@@ -295,7 +295,7 @@ public function testDuplicatedUniqueIndexes(): void
$table = $this->getDriver()->getSchema('tag_context');
assert($table instanceof AbstractTable);
- $uniques = array_filter($table->getIndexes(), static fn (AbstractIndex $index): bool => $index->isUnique());
+ $uniques = array_filter($table->getIndexes(), static fn(AbstractIndex $index): bool => $index->isUnique());
$this->assertTrue($table->hasColumn('id'));
$this->assertTrue($table->hasColumn('post_p_id'));
@@ -372,32 +372,32 @@ public function testInverse(): void
$this->assertSame('post', $schema['tag'][Schema::RELATIONS]['posts'][Relation::TARGET]);
$this->assertSame(
Relation::MANY_TO_MANY,
- $schema['tag'][Schema::RELATIONS]['posts'][Relation::TYPE]
+ $schema['tag'][Schema::RELATIONS]['posts'][Relation::TYPE],
);
$this->assertSame(
['p_id'],
- $schema['tag'][Schema::RELATIONS]['posts'][Relation::SCHEMA][Relation::INNER_KEY]
+ $schema['tag'][Schema::RELATIONS]['posts'][Relation::SCHEMA][Relation::INNER_KEY],
);
$this->assertSame(
['p_id'],
- $schema['tag'][Schema::RELATIONS]['posts'][Relation::SCHEMA][Relation::OUTER_KEY]
+ $schema['tag'][Schema::RELATIONS]['posts'][Relation::SCHEMA][Relation::OUTER_KEY],
);
$this->assertSame(
'tag_p_id',
- $schema['tag'][Schema::RELATIONS]['posts'][Relation::SCHEMA][Relation::THROUGH_INNER_KEY]
+ $schema['tag'][Schema::RELATIONS]['posts'][Relation::SCHEMA][Relation::THROUGH_INNER_KEY],
);
$this->assertSame(
'post_p_id',
- $schema['tag'][Schema::RELATIONS]['posts'][Relation::SCHEMA][Relation::THROUGH_OUTER_KEY]
+ $schema['tag'][Schema::RELATIONS]['posts'][Relation::SCHEMA][Relation::THROUGH_OUTER_KEY],
);
$this->assertSame(
'tagContext',
- $schema['tag'][Schema::RELATIONS]['posts'][Relation::SCHEMA][Relation::THROUGH_ENTITY]
+ $schema['tag'][Schema::RELATIONS]['posts'][Relation::SCHEMA][Relation::THROUGH_ENTITY],
);
}
diff --git a/tests/Schema/Relation/Morphed/BelongsToMorphedRelationCompositePKTest.php b/tests/Schema/Relation/Morphed/BelongsToMorphedRelationCompositePKTest.php
index d44ae78..5d706d9 100644
--- a/tests/Schema/Relation/Morphed/BelongsToMorphedRelationCompositePKTest.php
+++ b/tests/Schema/Relation/Morphed/BelongsToMorphedRelationCompositePKTest.php
@@ -80,7 +80,7 @@ public function testPackSchema(): void
$this->assertArrayHasKey('morphed', $schema);
$this->assertSame(
Relation::BELONGS_TO_MORPHED,
- $schema['morphed'][Schema::RELATIONS]['parent'][Relation::TYPE]
+ $schema['morphed'][Schema::RELATIONS]['parent'][Relation::TYPE],
);
$this->assertArrayHasKey('morphed', $schema);
@@ -175,33 +175,33 @@ public function testInverseHasOne(): void
$this->assertArrayHasKey('morphed', $schema['author'][Schema::RELATIONS]);
$this->assertSame(
Relation::MORPHED_HAS_ONE,
- $schema['author'][Schema::RELATIONS]['morphed'][Relation::TYPE]
+ $schema['author'][Schema::RELATIONS]['morphed'][Relation::TYPE],
);
$this->assertSame(
['p_id', 'p_slug'],
- $schema['author'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::INNER_KEY]
+ $schema['author'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::INNER_KEY],
);
$this->assertSame(
'parent_role',
- $schema['author'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::MORPH_KEY]
+ $schema['author'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::MORPH_KEY],
);
$this->assertArrayHasKey('morphed', $schema['post'][Schema::RELATIONS]);
$this->assertSame(
Relation::MORPHED_HAS_ONE,
- $schema['post'][Schema::RELATIONS]['morphed'][Relation::TYPE]
+ $schema['post'][Schema::RELATIONS]['morphed'][Relation::TYPE],
);
$this->assertSame(
['p_id', 'p_slug'],
- $schema['post'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::INNER_KEY]
+ $schema['post'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::INNER_KEY],
);
$this->assertSame(
['parent_p_id', 'parent_p_slug'],
- $schema['post'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::OUTER_KEY]
+ $schema['post'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::OUTER_KEY],
);
$this->assertSame(
'parent_role',
- $schema['post'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::MORPH_KEY]
+ $schema['post'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::MORPH_KEY],
);
}
@@ -230,29 +230,29 @@ public function testInverseHasMany(): void
$this->assertArrayHasKey('morphed', $schema['author'][Schema::RELATIONS]);
$this->assertSame(
Relation::MORPHED_HAS_MANY,
- $schema['author'][Schema::RELATIONS]['morphed'][Relation::TYPE]
+ $schema['author'][Schema::RELATIONS]['morphed'][Relation::TYPE],
);
$this->assertSame(
['p_id', 'p_slug'],
- $schema['author'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::INNER_KEY]
+ $schema['author'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::INNER_KEY],
);
$this->assertSame(
'parent_role',
- $schema['author'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::MORPH_KEY]
+ $schema['author'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::MORPH_KEY],
);
$this->assertArrayHasKey('morphed', $schema['post'][Schema::RELATIONS]);
$this->assertSame(
Relation::MORPHED_HAS_MANY,
- $schema['post'][Schema::RELATIONS]['morphed'][Relation::TYPE]
+ $schema['post'][Schema::RELATIONS]['morphed'][Relation::TYPE],
);
$this->assertSame(
['p_id', 'p_slug'],
- $schema['post'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::INNER_KEY]
+ $schema['post'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::INNER_KEY],
);
$this->assertSame(
'parent_role',
- $schema['post'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::MORPH_KEY]
+ $schema['post'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::MORPH_KEY],
);
}
}
diff --git a/tests/Schema/Relation/Morphed/BelongsToMorphedRelationTest.php b/tests/Schema/Relation/Morphed/BelongsToMorphedRelationTest.php
index d8f3454..d9cb6d5 100644
--- a/tests/Schema/Relation/Morphed/BelongsToMorphedRelationTest.php
+++ b/tests/Schema/Relation/Morphed/BelongsToMorphedRelationTest.php
@@ -81,7 +81,7 @@ public function testPackSchema(): void
$this->assertArrayHasKey('morphed', $schema);
$this->assertSame(
Relation::BELONGS_TO_MORPHED,
- $schema['morphed'][Schema::RELATIONS]['parent'][Relation::TYPE]
+ $schema['morphed'][Schema::RELATIONS]['parent'][Relation::TYPE],
);
$this->assertArrayHasKey('morphed', $schema);
@@ -174,29 +174,29 @@ public function testInverseHasOne(): void
$this->assertArrayHasKey('morphed', $schema['author'][Schema::RELATIONS]);
$this->assertSame(
Relation::MORPHED_HAS_ONE,
- $schema['author'][Schema::RELATIONS]['morphed'][Relation::TYPE]
+ $schema['author'][Schema::RELATIONS]['morphed'][Relation::TYPE],
);
$this->assertSame(
['p_id'],
- $schema['author'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::INNER_KEY]
+ $schema['author'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::INNER_KEY],
);
$this->assertSame(
'parent_role',
- $schema['author'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::MORPH_KEY]
+ $schema['author'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::MORPH_KEY],
);
$this->assertArrayHasKey('morphed', $schema['post'][Schema::RELATIONS]);
$this->assertSame(
Relation::MORPHED_HAS_ONE,
- $schema['post'][Schema::RELATIONS]['morphed'][Relation::TYPE]
+ $schema['post'][Schema::RELATIONS]['morphed'][Relation::TYPE],
);
$this->assertSame(
['p_id'],
- $schema['post'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::INNER_KEY]
+ $schema['post'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::INNER_KEY],
);
$this->assertSame(
'parent_role',
- $schema['post'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::MORPH_KEY]
+ $schema['post'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::MORPH_KEY],
);
}
@@ -225,29 +225,29 @@ public function testInverseHasMany(): void
$this->assertArrayHasKey('morphed', $schema['author'][Schema::RELATIONS]);
$this->assertSame(
Relation::MORPHED_HAS_MANY,
- $schema['author'][Schema::RELATIONS]['morphed'][Relation::TYPE]
+ $schema['author'][Schema::RELATIONS]['morphed'][Relation::TYPE],
);
$this->assertSame(
['p_id'],
- $schema['author'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::INNER_KEY]
+ $schema['author'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::INNER_KEY],
);
$this->assertSame(
'parent_role',
- $schema['author'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::MORPH_KEY]
+ $schema['author'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::MORPH_KEY],
);
$this->assertArrayHasKey('morphed', $schema['post'][Schema::RELATIONS]);
$this->assertSame(
Relation::MORPHED_HAS_MANY,
- $schema['post'][Schema::RELATIONS]['morphed'][Relation::TYPE]
+ $schema['post'][Schema::RELATIONS]['morphed'][Relation::TYPE],
);
$this->assertSame(
['p_id'],
- $schema['post'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::INNER_KEY]
+ $schema['post'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::INNER_KEY],
);
$this->assertSame(
'parent_role',
- $schema['post'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::MORPH_KEY]
+ $schema['post'][Schema::RELATIONS]['morphed'][Relation::SCHEMA][Relation::MORPH_KEY],
);
}
}
diff --git a/tests/Schema/Relation/Morphed/MorphedHasManyRelationTest.php b/tests/Schema/Relation/Morphed/MorphedHasManyRelationTest.php
index e0fe47e..5522a79 100644
--- a/tests/Schema/Relation/Morphed/MorphedHasManyRelationTest.php
+++ b/tests/Schema/Relation/Morphed/MorphedHasManyRelationTest.php
@@ -66,7 +66,7 @@ public function testPackSchema(): void
$this->assertSame(
ArrayCollectionFactory::class,
- $schema['user'][Schema::RELATIONS]['plain'][Relation::SCHEMA][Relation::COLLECTION_TYPE]
+ $schema['user'][Schema::RELATIONS]['plain'][Relation::SCHEMA][Relation::COLLECTION_TYPE],
);
}
diff --git a/tests/Schema/Relation/Traits/FieldTraitTest.php b/tests/Schema/Relation/Traits/FieldTraitTest.php
index 1526184..ba15a62 100644
--- a/tests/Schema/Relation/Traits/FieldTraitTest.php
+++ b/tests/Schema/Relation/Traits/FieldTraitTest.php
@@ -18,21 +18,10 @@ class FieldTraitTest extends TestCase
/** @var OptionSchema */
private $options;
+
/** @var string */
private $source;
- protected function setUp(): void
- {
- parent::setUp();
-
- $this->options = (new OptionSchema([]))->withTemplate([
- 123 => 'id',
- 234 => ['id', 'slug'],
- ]);
-
- $this->source = 'test';
- }
-
public function testGetsFieldShouldReturnFieldIfItExists(): void
{
$entity = new Entity();
@@ -111,7 +100,7 @@ public function testEnsureFieldIfFieldExistsItShouldNotBeCreated(): void
public function testEnsureFieldIfFieldNotExistsItShouldBeCreated(
string $originalType,
string $type,
- bool $nullable
+ bool $nullable,
): void {
$target = new Entity();
@@ -166,9 +155,18 @@ public function outerFieldTypes(): iterable
];
}
- /**
- * @return OptionSchema
- */
+ protected function setUp(): void
+ {
+ parent::setUp();
+
+ $this->options = (new OptionSchema([]))->withTemplate([
+ 123 => 'id',
+ 234 => ['id', 'slug'],
+ ]);
+
+ $this->source = 'test';
+ }
+
protected function getOptions(): OptionSchema
{
return $this->options;
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 42107df..59648d7 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -29,7 +29,7 @@
user: 'root',
password: 'root',
),
- queryCache: true
+ queryCache: true,
),
'postgres' => new Config\PostgresDriverConfig(
connection: new Config\Postgres\TcpConnectionConfig(
@@ -48,9 +48,9 @@
host: '127.0.0.1',
port: 11433,
user: 'SA',
- password: 'SSpaSS__1'
+ password: 'SSpaSS__1',
),
- queryCache: true
+ queryCache: true,
),
];
@@ -62,5 +62,5 @@
] + (
$db === null
? $drivers
- : array_intersect_key($drivers, array_flip((array)$db))
+ : array_intersect_key($drivers, array_flip((array) $db))
);
diff --git a/tests/generate.php b/tests/generate.php
index 88408d2..f98f3bf 100644
--- a/tests/generate.php
+++ b/tests/generate.php
@@ -75,8 +75,8 @@ class %s extends %s
$class->getName() . ' as ' . $baseTestName,
$class->getShortName(),
$baseTestName,
- $driver
- )
+ $driver,
+ ),
);
}
}