Skip to content

Commit

Permalink
- PSR-12 codestyle fix
Browse files Browse the repository at this point in the history
- always force default values
  • Loading branch information
wolfy-j committed Dec 26, 2019
1 parent 5dd8145 commit 0a9124f
Show file tree
Hide file tree
Showing 129 changed files with 788 additions and 458 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -12,7 +12,7 @@
"mockery/mockery": "^1.1",
"spiral/tokenizer": "^2.1",
"spiral/debug": "^1.3",
"squizlabs/php_codesniffer": "^3.4"
"spiral/code-style": "^1.0"
},
"autoload": {
"psr-4": {
Expand Down
6 changes: 4 additions & 2 deletions src/Compiler.php
@@ -1,10 +1,12 @@
<?php

/**
* Cycle ORM Schema Builder.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/

declare(strict_types=1);

namespace Cycle\Schema;
Expand Down Expand Up @@ -33,7 +35,7 @@ public function compile(Registry $registry, array $generators = []): array
foreach ($generators as $generator) {
if (!$generator instanceof GeneratorInterface) {
throw new CompilerException(sprintf(
"Invalid generator `%s`",
'Invalid generator `%s`',
is_object($generator) ? get_class($generator) : gettype($generator)
));
}
Expand Down Expand Up @@ -69,7 +71,7 @@ public function getSchema(): array
* @param Registry $registry
* @param Entity $entity
*/
protected function compute(Registry $registry, Entity $entity)
protected function compute(Registry $registry, Entity $entity): void
{
$schema = [
Schema::ENTITY => $entity->getClass(),
Expand Down
24 changes: 13 additions & 11 deletions src/Definition/Entity.php
@@ -1,10 +1,12 @@
<?php

/**
* Cycle ORM Schema Builder.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/

declare(strict_types=1);

namespace Cycle\Schema\Definition;
Expand Down Expand Up @@ -61,6 +63,16 @@ public function __construct()
$this->relations = new RelationMap();
}

/**
* Full entity copy.
*/
public function __clone()
{
$this->options = clone $this->options;
$this->fields = clone $this->fields;
$this->relations = clone $this->relations;
}

/**
* @return OptionMap
*/
Expand Down Expand Up @@ -223,7 +235,7 @@ public function getSchema(): array
*
* @param Entity $entity
*/
public function merge(Entity $entity)
public function merge(Entity $entity): void
{
foreach ($entity->getRelations() as $name => $relation) {
if (!$this->relations->has($name)) {
Expand All @@ -237,14 +249,4 @@ public function merge(Entity $entity)
}
}
}

/**
* Full entity copy.
*/
public function __clone()
{
$this->options = clone $this->options;
$this->fields = clone $this->fields;
$this->relations = clone $this->relations;
}
}
22 changes: 12 additions & 10 deletions src/Definition/Field.php
@@ -1,10 +1,12 @@
<?php

/**
* Cycle ORM Schema Builder.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/

declare(strict_types=1);

namespace Cycle\Schema\Definition;
Expand Down Expand Up @@ -43,6 +45,14 @@ public function __construct()
$this->options = new OptionMap();
}

/**
* Cloning.
*/
public function __clone()
{
$this->options = clone $this->options;
}

/**
* @return OptionMap
*/
Expand All @@ -57,7 +67,7 @@ public function getOptions(): OptionMap
public function getType(): string
{
if (empty($this->column)) {
throw new FieldException("Field type must be set");
throw new FieldException('Field type must be set');
}

return $this->type;
Expand Down Expand Up @@ -112,7 +122,7 @@ public function setColumn(string $column): Field
public function getColumn(): string
{
if (empty($this->column)) {
throw new FieldException("Column mapping must be set");
throw new FieldException('Column mapping must be set');
}

return $this->column;
Expand Down Expand Up @@ -163,12 +173,4 @@ public function isReferenced(): bool
{
return $this->referenced;
}

/**
* Cloning.
*/
public function __clone()
{
$this->options = clone $this->options;
}
}
22 changes: 12 additions & 10 deletions src/Definition/Map/FieldMap.php
@@ -1,10 +1,12 @@
<?php

/**
* Cycle ORM Schema Builder.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/

declare(strict_types=1);

namespace Cycle\Schema\Definition\Map;
Expand All @@ -20,6 +22,16 @@ 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
*/
Expand Down Expand Up @@ -83,14 +95,4 @@ public function getIterator()
{
return new \ArrayIterator($this->fields);
}

/**
* Cloning.
*/
public function __clone()
{
foreach ($this->fields as $name => $field) {
$this->fields[$name] = clone $field;
}
}
}
2 changes: 2 additions & 0 deletions src/Definition/Map/OptionMap.php
@@ -1,10 +1,12 @@
<?php

/**
* Cycle ORM Schema Builder.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/

declare(strict_types=1);

namespace Cycle\Schema\Definition\Map;
Expand Down
22 changes: 12 additions & 10 deletions src/Definition/Map/RelationMap.php
@@ -1,10 +1,12 @@
<?php

/**
* Cycle ORM Schema Builder.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/

declare(strict_types=1);

namespace Cycle\Schema\Definition\Map;
Expand All @@ -17,6 +19,16 @@ final class RelationMap implements \IteratorAggregate
/** @var Relation[] */
private $relations = [];

/**
* Cloning.
*/
public function __clone()
{
foreach ($this->relations as $name => $relation) {
$this->relations[$name] = clone $relation;
}
}

/**
* @param string $name
* @return bool
Expand Down Expand Up @@ -72,14 +84,4 @@ public function getIterator()
{
return new \ArrayIterator($this->relations);
}

/**
* Cloning.
*/
public function __clone()
{
foreach ($this->relations as $name => $relation) {
$this->relations[$name] = clone $relation;
}
}
}
22 changes: 12 additions & 10 deletions src/Definition/Relation.php
@@ -1,10 +1,12 @@
<?php

/**
* Cycle ORM Schema Builder.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/

declare(strict_types=1);

namespace Cycle\Schema\Definition;
Expand Down Expand Up @@ -40,6 +42,14 @@ public function __construct()
$this->options = new OptionMap();
}

/**
* Cloning.
*/
public function __clone()
{
$this->options = clone $this->options;
}

/**
* @return OptionMap
*/
Expand All @@ -65,7 +75,7 @@ public function setType(string $type): Relation
public function getType(): string
{
if ($this->type === null) {
throw new RelationException("Relation type must be set");
throw new RelationException('Relation type must be set');
}

return $this->type;
Expand All @@ -88,7 +98,7 @@ public function setTarget(string $target): Relation
public function getTarget(): string
{
if ($this->target === null) {
throw new RelationException("Relation target must be set");
throw new RelationException('Relation target must be set');
}

return $this->target;
Expand Down Expand Up @@ -140,12 +150,4 @@ public function getInverseLoad(): ?int
{
return $this->inverseLoad;
}

/**
* Cloning.
*/
public function __clone()
{
$this->options = clone $this->options;
}
}
2 changes: 2 additions & 0 deletions src/Exception/ColumnException.php
@@ -1,10 +1,12 @@
<?php

/**
* Cycle ORM Schema Builder.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/

declare(strict_types=1);

namespace Cycle\Schema\Exception;
Expand Down
2 changes: 2 additions & 0 deletions src/Exception/CompilerException.php
@@ -1,10 +1,12 @@
<?php

/**
* Cycle ORM Schema Builder.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/

declare(strict_types=1);

namespace Cycle\Schema\Exception;
Expand Down
2 changes: 2 additions & 0 deletions src/Exception/EntityException.php
@@ -1,10 +1,12 @@
<?php

/**
* Cycle ORM Schema Builder.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/

declare(strict_types=1);

namespace Cycle\Schema\Exception;
Expand Down
2 changes: 2 additions & 0 deletions src/Exception/FieldException.php
@@ -1,10 +1,12 @@
<?php

/**
* Cycle ORM Schema Builder.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/

declare(strict_types=1);

namespace Cycle\Schema\Exception;
Expand Down
2 changes: 2 additions & 0 deletions src/Exception/OptionException.php
@@ -1,10 +1,12 @@
<?php

/**
* Cycle ORM Schema Builder.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/

declare(strict_types=1);

namespace Cycle\Schema\Exception;
Expand Down
2 changes: 2 additions & 0 deletions src/Exception/RegistryException.php
@@ -1,10 +1,12 @@
<?php

/**
* Cycle ORM Schema Builder.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/

declare(strict_types=1);

namespace Cycle\Schema\Exception;
Expand Down

0 comments on commit 0a9124f

Please sign in to comment.