mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-24 02:38:50 +02:00
Fixed some more phpstan issues
This commit is contained in:
parent
2f46fbfc7a
commit
e8771ea118
77 changed files with 192 additions and 109 deletions
|
@ -27,6 +27,10 @@ use App\Entity\Base\PartsContainingRepositoryInterface;
|
|||
use App\Entity\Parts\Part;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* @template TEntityClass of AbstractPartsContainingDBElement
|
||||
* @extends StructuralDBElementRepository<TEntityClass>
|
||||
*/
|
||||
abstract class AbstractPartsContainingRepository extends StructuralDBElementRepository implements PartsContainingRepositoryInterface
|
||||
{
|
||||
/** @var int The maximum number of levels for which we can recurse before throwing an error */
|
||||
|
|
|
@ -41,9 +41,14 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use Doctrine\ORM\NonUniqueResultException;
|
||||
use Doctrine\ORM\NoResultException;
|
||||
|
||||
/**
|
||||
* @template TEntityClass of Attachment
|
||||
* @extends DBElementRepository<TEntityClass>
|
||||
*/
|
||||
class AttachmentRepository extends DBElementRepository
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -45,6 +45,10 @@ use App\Entity\Base\AbstractDBElement;
|
|||
use Doctrine\ORM\EntityRepository;
|
||||
use ReflectionClass;
|
||||
|
||||
/**
|
||||
* @template TEntityClass of AbstractDBElement
|
||||
* @extends EntityRepository<TEntityClass>
|
||||
*/
|
||||
class DBElementRepository extends EntityRepository
|
||||
{
|
||||
/**
|
||||
|
@ -53,7 +57,7 @@ class DBElementRepository extends EntityRepository
|
|||
*
|
||||
* @param AbstractDBElement $element The element whose ID should be changed
|
||||
* @phpstan-param TEntityClass $element
|
||||
* @param int $new_id The new ID
|
||||
* @param int $new_id The new ID
|
||||
*/
|
||||
public function changeID(AbstractDBElement $element, int $new_id): void
|
||||
{
|
||||
|
|
|
@ -47,6 +47,10 @@ use App\Entity\LabelSystem\LabelSupportedElement;
|
|||
use App\Helpers\Trees\TreeViewNode;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* @template TEntityClass of LabelProfile
|
||||
* @extends NamedDBElementRepository<TEntityClass>
|
||||
*/
|
||||
class LabelProfileRepository extends NamedDBElementRepository
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -32,6 +32,10 @@ use App\Entity\UserSystem\User;
|
|||
use DateTime;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* @template TEntityClass of AbstractLogEntry
|
||||
* @extends DBElementRepository<TEntityClass>
|
||||
*/
|
||||
class LogEntryRepository extends DBElementRepository
|
||||
{
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||
|
@ -60,7 +64,8 @@ class LogEntryRepository extends DBElementRepository
|
|||
*/
|
||||
public function getElementHistory(AbstractDBElement $element, string $order = 'DESC', ?int $limit = null, ?int $offset = null): array
|
||||
{
|
||||
return $this->findBy(['element' => $element], ['timestamp' => $order], $limit, $offset);
|
||||
//@phpstan-ignore-next-line Target is parsed dynamically in findBy
|
||||
return $this->findBy(['target' => $element], ['timestamp' => $order], $limit, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,7 +27,8 @@ use App\Entity\UserSystem\User;
|
|||
use App\Helpers\Trees\TreeViewNode;
|
||||
|
||||
/**
|
||||
* @see \App\Tests\Repository\NamedDBElementRepositoryTest
|
||||
* @template TEntityClass of AbstractNamedDBElement
|
||||
* @extends DBElementRepository<TEntityClass>
|
||||
*/
|
||||
class NamedDBElementRepository extends DBElementRepository
|
||||
{
|
||||
|
@ -66,6 +67,7 @@ class NamedDBElementRepository extends DBElementRepository
|
|||
/**
|
||||
* Returns the list of all nodes to use in a select box.
|
||||
* @return AbstractNamedDBElement[]
|
||||
* @phpstan-return array<int, AbstractNamedDBElement>
|
||||
*/
|
||||
public function toNodesList(): array
|
||||
{
|
||||
|
|
|
@ -22,12 +22,19 @@ declare(strict_types=1);
|
|||
*/
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Parameters\AbstractParameter;
|
||||
|
||||
/**
|
||||
* @template TEntityClass of AbstractParameter
|
||||
* @extends DBElementRepository<TEntityClass>
|
||||
*/
|
||||
class ParameterRepository extends DBElementRepository
|
||||
{
|
||||
/**
|
||||
* Find parameters using a parameter name
|
||||
* @param string $name The name to search for
|
||||
* @param bool $exact True, if only exact names should match. False, if the name just needs to be contained in the parameter name
|
||||
* @phpstan-return array<array{name: string, symbol: string, unit: string}>
|
||||
*/
|
||||
public function autocompleteParamName(string $name, bool $exact = false, int $max_results = 50): array
|
||||
{
|
||||
|
|
|
@ -22,11 +22,15 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Parts\Part;
|
||||
use App\Entity\Parts\PartLot;
|
||||
use Doctrine\ORM\NonUniqueResultException;
|
||||
use Doctrine\ORM\NoResultException;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
|
||||
/**
|
||||
* @extends NamedDBElementRepository<Part>
|
||||
*/
|
||||
class PartRepository extends NamedDBElementRepository
|
||||
{
|
||||
/**
|
||||
|
@ -67,6 +71,9 @@ class PartRepository extends NamedDBElementRepository
|
|||
return (int) ($query->getSingleScalarResult() ?? 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Part[]
|
||||
*/
|
||||
public function autocompleteSearch(string $query, int $max_limits = 50): array
|
||||
{
|
||||
$qb = $this->createQueryBuilder('part');
|
||||
|
|
|
@ -29,6 +29,8 @@ use RecursiveIteratorIterator;
|
|||
|
||||
/**
|
||||
* @see \App\Tests\Repository\StructuralDBElementRepositoryTest
|
||||
* @template TEntityClass of AbstractStructuralDBElement
|
||||
* @extends NamedDBElementRepository<TEntityClass>
|
||||
*/
|
||||
class StructuralDBElementRepository extends NamedDBElementRepository
|
||||
{
|
||||
|
@ -52,7 +54,8 @@ class StructuralDBElementRepository extends NamedDBElementRepository
|
|||
* Gets a tree of TreeViewNode elements. The root elements has $parent as parent.
|
||||
* The treeview is generic, that means the href are null and ID values are set.
|
||||
*
|
||||
* @param AbstractStructuralDBElement|null $parent the parent the root elements should have
|
||||
* @param AbstractStructuralDBElement|null $parent the parent the root elements should have
|
||||
* @phpstan-param TEntityClass|null $parent
|
||||
*
|
||||
* @return TreeViewNode[]
|
||||
*/
|
||||
|
@ -78,8 +81,9 @@ class StructuralDBElementRepository extends NamedDBElementRepository
|
|||
* Gets a flattened hierarchical tree. Useful for generating option lists.
|
||||
*
|
||||
* @param AbstractStructuralDBElement|null $parent This entity will be used as root element. Set to null, to use global root
|
||||
*
|
||||
* @phpstan-param TEntityClass|null $parent
|
||||
* @return AbstractStructuralDBElement[] a flattened list containing the tree elements
|
||||
* @phpstan-return array<int, TEntityClass>
|
||||
*/
|
||||
public function toNodesList(?AbstractStructuralDBElement $parent = null): array
|
||||
{
|
||||
|
@ -104,6 +108,7 @@ class StructuralDBElementRepository extends NamedDBElementRepository
|
|||
* This function will try to use existing elements, if they are already in the database. If not, they will be created.
|
||||
* An array of the created elements will be returned, with the last element being the deepest element.
|
||||
* @return AbstractStructuralDBElement[]
|
||||
* @phpstan-return array<int, TEntityClass>
|
||||
*/
|
||||
public function getNewEntityFromPath(string $path, string $separator = '->'): array
|
||||
{
|
||||
|
@ -156,6 +161,7 @@ class StructuralDBElementRepository extends NamedDBElementRepository
|
|||
* An array of the created elements will be returned, with the last element being the deepest element.
|
||||
* If no element was found, an empty array will be returned.
|
||||
* @return AbstractStructuralDBElement[]
|
||||
* @phpstan-return array<int, TEntityClass>
|
||||
*/
|
||||
public function getEntityByPath(string $path, string $separator = '->'): array
|
||||
{
|
||||
|
|
|
@ -33,6 +33,7 @@ use Symfony\Component\Security\Core\User\UserInterface;
|
|||
* @method User|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method User[] findAll()
|
||||
* @method User[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
* @extends NamedDBElementRepository<User>
|
||||
*/
|
||||
final class UserRepository extends NamedDBElementRepository implements PasswordUpgraderInterface
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue