Skip to content

Commit c7636d3

Browse files
committed
Fix errors reported by psalm.
1 parent 1f23d40 commit c7636d3

8 files changed

+21
-19
lines changed

Association/Loader/SelectLoader.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ protected function _assertFieldsPresent(Query $fetchQuery, array $key): void
267267
throw new InvalidArgumentException(
268268
sprintf(
269269
'You are required to select the "%s" field(s)',
270-
implode(', ', (array)$key)
270+
implode(', ', $key)
271271
)
272272
);
273273
}

AssociationCollection.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ protected function _save(
311311
return true;
312312
}
313313
if (!empty($nested)) {
314-
$options = (array)$nested + $options;
314+
$options = $nested + $options;
315315
}
316316

317317
return (bool)$association->saveAssociated($entity, $options);

AssociationsNormalizerTrait.php

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ protected function _normalizeAssociations($associations): array
4747

4848
$path = explode('.', $table);
4949
$table = array_pop($path);
50+
/** @var string $first */
5051
$first = array_shift($path);
5152
$pointer += [$first => []];
5253
$pointer = &$pointer[$first];

EagerLoadable.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public function propertyPath(): ?string
217217
*/
218218
public function setCanBeJoined(bool $possible)
219219
{
220-
$this->_canBeJoined = (bool)$possible;
220+
$this->_canBeJoined = $possible;
221221

222222
return $this;
223223
}

EagerLoader.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ public function normalized(Table $repository): array
308308
$contain = [];
309309
foreach ($this->_containments as $alias => $options) {
310310
if (!empty($options['instance'])) {
311-
$contain = (array)$this->_containments;
311+
$contain = $this->_containments;
312312
break;
313313
}
314314
$contain[$alias] = $this->_normalizeContain(
@@ -336,7 +336,7 @@ protected function _reformatContain(array $associations, array $original): array
336336
{
337337
$result = $original;
338338

339-
foreach ((array)$associations as $table => $options) {
339+
foreach ($associations as $table => $options) {
340340
$pointer = &$result;
341341
if (is_int($table)) {
342342
$table = $options;
@@ -388,6 +388,7 @@ protected function _reformatContain(array $associations, array $original): array
388388
}
389389

390390
if (!is_array($options)) {
391+
/** @psalm-suppress InvalidArrayOffset */
391392
$options = [$options => []];
392393
}
393394

Marshaller.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ protected function _marshalAssociation(Association $assoc, $value, array $option
314314
$types = [Association::ONE_TO_ONE, Association::MANY_TO_ONE];
315315
$type = $assoc->type();
316316
if (in_array($type, $types, true)) {
317-
return $marshaller->one($value, (array)$options);
317+
return $marshaller->one($value, $options);
318318
}
319319
if ($type === Association::ONE_TO_MANY || $type === Association::MANY_TO_MANY) {
320320
$hasIds = array_key_exists('_ids', $value);
@@ -328,10 +328,10 @@ protected function _marshalAssociation(Association $assoc, $value, array $option
328328
}
329329
}
330330
if ($type === Association::MANY_TO_MANY) {
331-
return $marshaller->_belongsToMany($assoc, $value, (array)$options);
331+
return $marshaller->_belongsToMany($assoc, $value, $options);
332332
}
333333

334-
return $marshaller->many($value, (array)$options);
334+
return $marshaller->many($value, $options);
335335
}
336336

337337
/**
@@ -748,11 +748,11 @@ protected function _mergeAssociation($original, Association $assoc, $value, arra
748748
$type = $assoc->type();
749749
if (in_array($type, $types, true)) {
750750
/** @psalm-suppress PossiblyInvalidArgument */
751-
return $marshaller->merge($original, $value, (array)$options);
751+
return $marshaller->merge($original, $value, $options);
752752
}
753753
if ($type === Association::MANY_TO_MANY) {
754754
/** @psalm-suppress PossiblyInvalidArgument */
755-
return $marshaller->_mergeBelongsToMany($original, $assoc, $value, (array)$options);
755+
return $marshaller->_mergeBelongsToMany($original, $assoc, $value, $options);
756756
}
757757

758758
if ($type === Association::ONE_TO_MANY) {
@@ -767,7 +767,7 @@ protected function _mergeAssociation($original, Association $assoc, $value, arra
767767
}
768768

769769
/** @psalm-suppress PossiblyInvalidArgument */
770-
return $marshaller->mergeMany($original, $value, (array)$options);
770+
return $marshaller->mergeMany($original, $value, $options);
771771
}
772772

773773
/**

SaveOptionsBuilder.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ protected function _checkAssociation(Table $table, string $association): void
141141
*/
142142
public function guard(bool $guard)
143143
{
144-
$this->_options['guard'] = (bool)$guard;
144+
$this->_options['guard'] = $guard;
145145

146146
return $this;
147147
}
@@ -168,7 +168,7 @@ public function validate(string $validate)
168168
*/
169169
public function checkExisting(bool $checkExisting)
170170
{
171-
$this->_options['checkExisting'] = (bool)$checkExisting;
171+
$this->_options['checkExisting'] = $checkExisting;
172172

173173
return $this;
174174
}
@@ -181,7 +181,7 @@ public function checkExisting(bool $checkExisting)
181181
*/
182182
public function checkRules(bool $checkRules)
183183
{
184-
$this->_options['checkRules'] = (bool)$checkRules;
184+
$this->_options['checkRules'] = $checkRules;
185185

186186
return $this;
187187
}
@@ -194,7 +194,7 @@ public function checkRules(bool $checkRules)
194194
*/
195195
public function atomic(bool $atomic)
196196
{
197-
$this->_options['atomic'] = (bool)$atomic;
197+
$this->_options['atomic'] = $atomic;
198198

199199
return $this;
200200
}

Table.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ public function getAlias(): string
420420
if ($this->_alias === null) {
421421
$alias = namespaceSplit(static::class);
422422
$alias = substr(end($alias), 0, -5) ?: $this->_table;
423-
$this->_alias = (string)$alias;
423+
$this->_alias = $alias;
424424
}
425425

426426
return $this->_alias;
@@ -650,7 +650,7 @@ public function setPrimaryKey($key)
650650
public function getPrimaryKey()
651651
{
652652
if ($this->_primaryKey === null) {
653-
$key = (array)$this->getSchema()->getPrimaryKey();
653+
$key = $this->getSchema()->getPrimaryKey();
654654
if (count($key) === 1) {
655655
$key = $key[0];
656656
}
@@ -2091,7 +2091,7 @@ protected function _insert(EntityInterface $entity, array $data)
20912091
*/
20922092
protected function _newId(array $primary)
20932093
{
2094-
if (!$primary || count((array)$primary) > 1) {
2094+
if (!$primary || count($primary) > 1) {
20952095
return null;
20962096
}
20972097
/** @var string $typeName */
@@ -2451,7 +2451,7 @@ protected function _processDelete(EntityInterface $entity, ArrayObject $options)
24512451
}
24522452

24532453
$query = $this->query();
2454-
$conditions = (array)$entity->extract($primaryKey);
2454+
$conditions = $entity->extract($primaryKey);
24552455
$statement = $query->delete()
24562456
->where($conditions)
24572457
->execute();

0 commit comments

Comments
 (0)