Skip to content

Commit 1fbb576

Browse files
committed
Update to new QA standards
1 parent cd7134b commit 1fbb576

14 files changed

+116
-20
lines changed

.php_cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,8 @@ return (function (): Config
1717
->append($paths)
1818
)
1919
->setUsingCache(false)
20-
;
20+
->setRules([
21+
'native_function_invocation' => false,
22+
])
23+
;
2124
})();

infection.json.dist

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@
5858
"WyriHaximus\\React\\SimpleORM\\Repository::buildTree",
5959
"WyriHaximus\\React\\SimpleORM\\Repository::buildJoins"
6060
]
61+
},
62+
"Continue_": {
63+
"ignore": [
64+
"WyriHaximus\\React\\SimpleORM\\Repository::buildJoins"
65+
]
6166
}
6267
}
6368
}

src/Annotation/Clause.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@ final class Clause
2929
/** @var string|null */
3030
private $foreign_function;
3131

32-
public function __construct(array $table)
32+
/**
33+
* @param array[] $clause
34+
*/
35+
public function __construct(array $clause)
3336
{
3437
/** @psalm-suppress RawObjectIteration */
3538
foreach ($this as $name => $value) {
36-
if (isset($table[$name])) {
37-
$this->$name = $table[$name];
39+
if (array_key_exists($name, $clause)) {
40+
$this->$name = $clause[$name];
3841
}
3942
}
4043
}

src/Annotation/InnerJoin.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@ final class InnerJoin implements JoinInterface
2323
/** @var bool */
2424
private $lazy = self::IS_NOT_LAZY;
2525

26-
public function __construct(array $table)
26+
/**
27+
* @param array[] $innerJoin
28+
*/
29+
public function __construct(array $innerJoin)
2730
{
2831
/** @psalm-suppress RawObjectIteration */
2932
foreach ($this as $name => $value) {
30-
if (isset($table[$name])) {
31-
$this->$name = $table[$name];
33+
if (array_key_exists($name, $innerJoin)) {
34+
$this->$name = $innerJoin[$name];
3235
}
3336
}
3437
}

src/Annotation/LeftJoin.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@ final class LeftJoin implements JoinInterface
2323
/** @var bool */
2424
private $lazy = self::IS_NOT_LAZY;
2525

26-
public function __construct(array $table)
26+
/**
27+
* @param array[] $leftJoin
28+
*/
29+
public function __construct(array $leftJoin)
2730
{
2831
/** @psalm-suppress RawObjectIteration */
2932
foreach ($this as $name => $value) {
30-
if (isset($table[$name])) {
31-
$this->$name = $table[$name];
33+
if (array_key_exists($name, $leftJoin)) {
34+
$this->$name = $leftJoin[$name];
3235
}
3336
}
3437
}

src/Annotation/Table.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ final class Table
1313
/** @var string */
1414
private $table;
1515

16+
/**
17+
* @param string[] $table
18+
*/
1619
public function __construct(array $table)
1720
{
1821
$this->table = \current($table);

src/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct(PgClient $client, ?Reader $annotationReader = null)
2828

2929
public function getRepository(string $entity): RepositoryInterface
3030
{
31-
if (!isset($this->repositories[$entity])) {
31+
if (!array_key_exists($entity, $this->repositories)) {
3232
$this->repositories[$entity] = new Repository($this->entityInspector->getEntity($entity), $this);
3333
}
3434

src/Entity/Join.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ final class Join
2222
/** @var Clause[] */
2323
private $clause;
2424

25+
/**
26+
* @param InspectedEntityInterface $entity
27+
* @param string $type
28+
* @param string $property
29+
* @param bool $lazy
30+
* @param array<int, Clause> $clause
31+
*/
2532
public function __construct(InspectedEntityInterface $entity, string $type, string $property, bool $lazy, Clause ...$clause)
2633
{
2734
$this->entity = $entity;

src/EntityInspector.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct(Reader $annotationReader)
2727

2828
public function getEntity(string $entity): InspectedEntityInterface
2929
{
30-
if (!isset($this->entities[$entity])) {
30+
if (!array_key_exists($entity, $this->entities)) {
3131
/** @psalm-suppress ArgumentTypeCoercion */
3232
$class = new ReflectionClass($entity);
3333
$tableAnnotation = $this->annotationReader->getClassAnnotation($class, Table::class);
@@ -48,11 +48,17 @@ public function getEntity(string $entity): InspectedEntityInterface
4848
return $this->entities[$entity];
4949
}
5050

51+
/**
52+
* @param ReflectionClass $class
53+
* @param Join[] $joins
54+
*
55+
* @return iterable
56+
*/
5157
private function getFields(ReflectionClass $class, array $joins): iterable
5258
{
5359
/** @var ReflectionProperty $property */
5460
foreach ($class->getProperties() as $property) {
55-
if (isset($joins[$property->getName()])) {
61+
if (array_key_exists($property->getName(), $joins)) {
5662
continue;
5763
}
5864

src/Hydrator.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@ final class Hydrator
1111
/** @var string[] */
1212
private $hydrators = [];
1313

14+
/**
15+
* @param InspectedEntityInterface $inspectedEntity
16+
* @param mixed[] $data
17+
*
18+
* @return EntityInterface
19+
*/
1420
public function hydrate(InspectedEntityInterface $inspectedEntity, array $data): EntityInterface
1521
{
1622
$class = $inspectedEntity->getClass();
17-
if (!isset($this->hydrators[$class])) {
23+
if (!array_key_exists($class, $this->hydrators)) {
1824
/**
1925
* @psalm-suppress MissingClosureReturnType
2026
* @psalm-suppress InvalidPropertyAssignmentValue
@@ -28,7 +34,7 @@ public function hydrate(InspectedEntityInterface $inspectedEntity, array $data):
2834
}
2935

3036
foreach ($data as $key => $value) {
31-
if (isset($inspectedEntity->getFields()[$key])) {
37+
if (array_key_exists($key, $inspectedEntity->getFields())) {
3238
$data[$key] = $this->castValueToCorrectType($inspectedEntity->getFields()[$key], $value);
3339
}
3440
}
@@ -49,6 +55,12 @@ public function hydrate(InspectedEntityInterface $inspectedEntity, array $data):
4955
return $this->hydrators[$class]->hydrate($data, new $class());
5056
}
5157

58+
/**
59+
* @param InspectedEntityInterface $inspectedEntity
60+
* @param EntityInterface $entity
61+
*
62+
* @return mixed[]
63+
*/
5264
public function extract(InspectedEntityInterface $inspectedEntity, EntityInterface $entity): array
5365
{
5466
$class = $inspectedEntity->getClass();

0 commit comments

Comments
 (0)