Applied rector suggestions

This commit is contained in:
Jan Böhmer 2024-06-22 00:31:43 +02:00
parent 4106bcef5f
commit 20f32c7f12
170 changed files with 808 additions and 761 deletions

View file

@ -30,6 +30,7 @@ use Doctrine\ORM\Mapping\ClassMetadata;
/**
* @template TEntityClass of AttachmentContainingDBElement
* @extends NamedDBElementRepository<TEntityClass>
* @see \App\Tests\Repository\AttachmentContainingDBElementRepositoryTest
*/
class AttachmentContainingDBElementRepository extends NamedDBElementRepository
{

View file

@ -49,6 +49,7 @@ use ReflectionClass;
/**
* @template TEntityClass of AbstractDBElement
* @extends EntityRepository<TEntityClass>
* @see \App\Tests\Repository\DBElementRepositoryTest
*/
class DBElementRepository extends EntityRepository
{
@ -143,9 +144,7 @@ class DBElementRepository extends EntityRepository
*/
protected function sortResultArrayByIDArray(array &$result_array, array $ids): void
{
usort($result_array, static function (AbstractDBElement $a, AbstractDBElement $b) use ($ids) {
return array_search($a->getID(), $ids, true) <=> array_search($b->getID(), $ids, true);
});
usort($result_array, static fn(AbstractDBElement $a, AbstractDBElement $b) => array_search($a->getID(), $ids, true) <=> array_search($b->getID(), $ids, true));
}
protected function setField(AbstractDBElement $element, string $field, int $new_value): void

View file

@ -29,6 +29,7 @@ use App\Helpers\Trees\TreeViewNode;
/**
* @template TEntityClass of AbstractNamedDBElement
* @extends DBElementRepository<TEntityClass>
* @see \App\Tests\Repository\NamedDBElementRepositoryTest
*/
class NamedDBElementRepository extends DBElementRepository
{

View file

@ -52,7 +52,7 @@ class StructuralDBElementRepository extends AttachmentContainingDBElementReposit
$qb->select('e')
->orderBy('NATSORT(e.name)', $nameOrdering);
if ($parent) {
if ($parent !== null) {
$qb->where('e.parent = :parent')
->setParameter('parent', $parent);
} else {
@ -260,7 +260,7 @@ class StructuralDBElementRepository extends AttachmentContainingDBElementReposit
//Try to find if we already have an element cached for this name
$entity = $this->getNewEntityFromCache($name, null);
if ($entity) {
if ($entity !== null) {
return $entity;
}

View file

@ -36,6 +36,7 @@ use Symfony\Component\Security\Core\User\UserInterface;
* @method User[] findAll()
* @method User[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
* @extends NamedDBElementRepository<User>
* @see \App\Tests\Repository\UserRepositoryTest
*/
final class UserRepository extends NamedDBElementRepository implements PasswordUpgraderInterface
{