[TOOLS] Fix errors pointed out by PHPStan level 4
This commit is contained in:
@@ -50,6 +50,7 @@ use Functional as F;
|
||||
|
||||
/**
|
||||
* @mixin EntityManager
|
||||
*
|
||||
* @template T of Entity
|
||||
*
|
||||
* Finds an Entity by its identifier. You probably want to use DB::findBy instead.
|
||||
@@ -77,6 +78,9 @@ use Functional as F;
|
||||
*
|
||||
* Executes a function in a transaction. Warning: suppresses exceptions. Returns the result of the callable.
|
||||
* @method mixed wrapInTransaction(callable $func)
|
||||
*
|
||||
* Refetch the given entity
|
||||
* @method static T refetch(T $entity)
|
||||
*/
|
||||
class DB
|
||||
{
|
||||
@@ -272,17 +276,17 @@ class DB
|
||||
{
|
||||
$res = self::findBy($table, $criteria, $order_by, 2, $offset); // Use limit 2 to check for consistency
|
||||
switch (\count($res)) {
|
||||
case 0:
|
||||
if ($return_null) {
|
||||
return null;
|
||||
} else {
|
||||
throw new NotFoundException("No value in table {$table} matches the requested criteria");
|
||||
}
|
||||
// no break
|
||||
case 1:
|
||||
return $res[0];
|
||||
default:
|
||||
throw new DuplicateFoundException("Multiple values in table {$table} match the requested criteria");
|
||||
case 0:
|
||||
if ($return_null) {
|
||||
return null;
|
||||
} else {
|
||||
throw new NotFoundException("No value in table {$table} matches the requested criteria");
|
||||
}
|
||||
// no break
|
||||
case 1:
|
||||
return $res[0];
|
||||
default:
|
||||
throw new DuplicateFoundException("Multiple values in table {$table} match the requested criteria");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,7 +317,8 @@ class DB
|
||||
$seqName = $metadata->getSequenceName($conn->getDatabasePlatform());
|
||||
self::persist($owner);
|
||||
$id = (int) $conn->lastInsertId($seqName);
|
||||
F\map(\is_array($others) ? $others : [$others], function ($o) use ($id) { $o->setId($id); self::persist($o); });
|
||||
F\map(\is_array($others) ? $others : [$others], function ($o) use ($id) { $o->setId($id);
|
||||
self::persist($o); });
|
||||
if (!\is_null($extra)) {
|
||||
$extra($id);
|
||||
}
|
||||
|
Reference in New Issue
Block a user