Fixed code style.

This commit is contained in:
Jan Böhmer 2020-08-21 21:36:22 +02:00
parent 2853e471c4
commit d0b1024d80
212 changed files with 495 additions and 1005 deletions

View file

@ -20,28 +20,26 @@
namespace App\Repository;
use App\Entity\Base\AbstractPartsContainingDBElement;
use App\Entity\Base\PartsContainingRepositoryInterface;
use App\Entity\Parts\Part;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria;
abstract class AbstractPartsContainingRepository extends StructuralDBElementRepository
implements PartsContainingRepositoryInterface
abstract class AbstractPartsContainingRepository extends StructuralDBElementRepository implements PartsContainingRepositoryInterface
{
/**
* Returns all parts associated with this element.
* @param AbstractPartsContainingDBElement $element The element for which the parts should be determined.
* @param array $order_by The order of the parts. Format ['name' => 'ASC']
*
* @param AbstractPartsContainingDBElement $element the element for which the parts should be determined
* @param array $order_by The order of the parts. Format ['name' => 'ASC']
*
* @return Part[]
*/
abstract public function getParts(object $element, array $order_by = ['name' => 'ASC']): array;
/**
* Gets the count of the parts associated with this element.
* @param AbstractPartsContainingDBElement $element The element for which the parts should be determined.
* @return int
*
* @param AbstractPartsContainingDBElement $element the element for which the parts should be determined
*/
abstract public function getPartsCount(object $element): int;
@ -66,5 +64,4 @@ abstract class AbstractPartsContainingRepository extends StructuralDBElementRepo
return $repo->count([$field_name => $element]);
}
}
}

View file

@ -27,8 +27,6 @@ class AttachmentRepository extends DBElementRepository
{
/**
* Gets the count of all private/secure attachments.
*
* @return int
*/
public function getPrivateAttachmentsCount(): int
{
@ -44,8 +42,6 @@ class AttachmentRepository extends DBElementRepository
/**
* Gets the count of all external attachments (attachments only containing an URL).
*
* @return int
*
* @throws \Doctrine\ORM\NoResultException
* @throws \Doctrine\ORM\NonUniqueResultException
*/
@ -65,8 +61,6 @@ class AttachmentRepository extends DBElementRepository
/**
* Gets the count of all attachments where an user uploaded an file.
*
* @return int
*
* @throws \Doctrine\ORM\NoResultException
* @throws \Doctrine\ORM\NonUniqueResultException
*/

View file

@ -32,12 +32,10 @@ class LabelProfileRepository extends NamedDBElementRepository
/**
* Find the profiles that are shown in the dropdown for the given type.
* You should maybe use the cached version of this in LabelProfileDropdownHelper.
*
* @return array
*/
public function getDropdownProfiles(string $type): array
{
if (! in_array($type, LabelOptions::SUPPORTED_ELEMENTS, true)) {
if (!in_array($type, LabelOptions::SUPPORTED_ELEMENTS, true)) {
throw new \InvalidArgumentException('Invalid supported_element type given.');
}
@ -64,7 +62,7 @@ class LabelProfileRepository extends NamedDBElementRepository
$type_children[] = $node;
}
if (! empty($type_children)) {
if (!empty($type_children)) {
//Use default label e.g. 'part_label'. $$ marks that it will be translated in TreeViewGenerator
$tmp = new TreeViewNode('$$'.$type.'.label', null, $type_children);
@ -78,14 +76,12 @@ class LabelProfileRepository extends NamedDBElementRepository
/**
* Find all LabelProfiles that can be used with the given type.
*
* @param string $type See LabelOptions::SUPPORTED_ELEMENTS for valid values.
* @param string $type see LabelOptions::SUPPORTED_ELEMENTS for valid values
* @param array $order_by The way the results should be sorted. By default ordered by
*
* @return array
*/
public function findForSupportedElement(string $type, array $order_by = ['name' => 'ASC']): array
{
if (! in_array($type, LabelOptions::SUPPORTED_ELEMENTS, true)) {
if (!in_array($type, LabelOptions::SUPPORTED_ELEMENTS, true)) {
throw new \InvalidArgumentException('Invalid supported_element type given.');
}

View file

@ -86,8 +86,6 @@ class LogEntryRepository extends DBElementRepository
*
* @param string $class The class of the element that should be undeleted
* @param int $id The ID of the element that should be deleted
*
* @return ElementDeletedLogEntry
*/
public function getUndeleteDataForElement(string $class, int $id): ElementDeletedLogEntry
{
@ -171,7 +169,7 @@ class LogEntryRepository extends DBElementRepository
$query = $qb->getQuery();
$count = $query->getSingleScalarResult();
return ! ($count > 0);
return !($count > 0);
}
/**
@ -180,8 +178,6 @@ class LogEntryRepository extends DBElementRepository
* @param string $order
* @param null $limit
* @param null $offset
*
* @return array
*/
public function getLogsOrderedByTimestamp($order = 'DESC', $limit = null, $offset = null): array
{
@ -191,8 +187,8 @@ class LogEntryRepository extends DBElementRepository
/**
* Gets the target element associated with the logentry.
*
* @return AbstractDBElement|null Returns the associated DBElement or null if the log either has no target or the element
* was deleted from DB.
* @return AbstractDBElement|null returns the associated DBElement or null if the log either has no target or the element
* was deleted from DB
*
* @throws \Doctrine\ORM\ORMException
* @throws \Doctrine\ORM\OptimisticLockException
@ -213,7 +209,7 @@ class LogEntryRepository extends DBElementRepository
/**
* Returns the last user that has edited the given element.
*
* @return User|null A user object, or null if no user could be determined.
* @return User|null a user object, or null if no user could be determined
*/
public function getLastEditingUser(AbstractDBElement $element): ?User
{
@ -223,7 +219,7 @@ class LogEntryRepository extends DBElementRepository
/**
* Returns the user that has created the given element.
*
* @return User|null A user object, or null if no user could be determined.
* @return User|null a user object, or null if no user could be determined
*/
public function getCreatingUser(AbstractDBElement $element): ?User
{

View file

@ -50,8 +50,6 @@ class PartRepository extends NamedDBElementRepository
/**
* Gets the summed up instock of all parts (only parts without an measurent unit).
*
* @return float
*
* @throws \Doctrine\ORM\NoResultException
* @throws \Doctrine\ORM\NonUniqueResultException
*/
@ -71,8 +69,6 @@ class PartRepository extends NamedDBElementRepository
/**
* Gets the number of parts that has price informations.
*
* @return int
*
* @throws \Doctrine\ORM\NoResultException
* @throws \Doctrine\ORM\NonUniqueResultException
*/

View file

@ -21,12 +21,10 @@
namespace App\Repository\Parts;
use App\Entity\Parts\Category;
use App\Entity\Parts\Storelocation;
use App\Repository\AbstractPartsContainingRepository;
class CategoryRepository extends AbstractPartsContainingRepository
{
public function getParts(object $element, array $order_by = ['name' => 'ASC']): array
{
if (!$element instanceof Category) {
@ -44,4 +42,4 @@ class CategoryRepository extends AbstractPartsContainingRepository
return $this->getPartsCountByField($element, 'category');
}
}
}

View file

@ -21,14 +21,13 @@
namespace App\Repository\Parts;
use App\Entity\Parts\Footprint;
use App\Entity\Parts\Storelocation;
use App\Repository\AbstractPartsContainingRepository;
class FootprintRepository extends AbstractPartsContainingRepository
{
public function getParts(object $element, array $order_by = ['name' => 'ASC']): array
{
if(!$element instanceof Footprint) {
if (!$element instanceof Footprint) {
throw new \InvalidArgumentException('$element must be an Footprint!');
}
@ -37,10 +36,10 @@ class FootprintRepository extends AbstractPartsContainingRepository
public function getPartsCount(object $element): int
{
if(!$element instanceof Footprint) {
if (!$element instanceof Footprint) {
throw new \InvalidArgumentException('$element must be an Footprint!');
}
return $this->getPartsCountByField($element, 'footprint');
}
}
}

View file

@ -20,13 +20,11 @@
namespace App\Repository\Parts;
use App\Entity\Parts\Category;
use App\Entity\Parts\Manufacturer;
use App\Repository\AbstractPartsContainingRepository;
class ManufacturerRepository extends AbstractPartsContainingRepository
{
public function getParts(object $element, array $order_by = ['name' => 'ASC']): array
{
if (!$element instanceof Manufacturer) {
@ -44,4 +42,4 @@ class ManufacturerRepository extends AbstractPartsContainingRepository
return $this->getPartsCountByField($element, 'manufacturer');
}
}
}

View file

@ -20,13 +20,11 @@
namespace App\Repository\Parts;
use App\Entity\Parts\Manufacturer;
use App\Entity\Parts\MeasurementUnit;
use App\Repository\AbstractPartsContainingRepository;
class MeasurementUnitRepository extends AbstractPartsContainingRepository
{
public function getParts(object $element, array $order_by = ['name' => 'ASC']): array
{
if (!$element instanceof MeasurementUnit) {
@ -44,4 +42,4 @@ class MeasurementUnitRepository extends AbstractPartsContainingRepository
return $this->getPartsCountByField($element, 'partUnit');
}
}
}

View file

@ -21,20 +21,18 @@
namespace App\Repository\Parts;
use App\Entity\Parts\Part;
use App\Entity\Parts\PartLot;
use App\Entity\Parts\Storelocation;
use App\Repository\AbstractPartsContainingRepository;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\HttpKernel\HttpCache\Store;
class StorelocationRepository extends AbstractPartsContainingRepository
{
/**
* @param Storelocation $element
* @param Storelocation $element
*/
public function getParts(object $element, array $order_by = ['name' => 'ASC']): array
{
if(!$element instanceof Storelocation) {
if (!$element instanceof Storelocation) {
throw new \InvalidArgumentException('$element must be an Storelocation!');
}
@ -47,7 +45,7 @@ class StorelocationRepository extends AbstractPartsContainingRepository
->setParameter(1, $element);
foreach ($order_by as $field => $order) {
$qb->addOrderBy('part.' . $field, $order);
$qb->addOrderBy('part.'.$field, $order);
}
return $qb->getQuery()->getResult();
@ -55,7 +53,7 @@ class StorelocationRepository extends AbstractPartsContainingRepository
public function getPartsCount(object $element): int
{
if(!$element instanceof Storelocation) {
if (!$element instanceof Storelocation) {
throw new \InvalidArgumentException('$element must be an Storelocation!');
}
@ -67,7 +65,6 @@ class StorelocationRepository extends AbstractPartsContainingRepository
->where('lots.storage_location = ?1')
->setParameter(1, $element);
return (int) $qb->getQuery()->getSingleScalarResult();
}
}
}

View file

@ -21,7 +21,6 @@
namespace App\Repository\Parts;
use App\Entity\Parts\Part;
use App\Entity\Parts\Storelocation;
use App\Entity\Parts\Supplier;
use App\Repository\AbstractPartsContainingRepository;
use Doctrine\ORM\QueryBuilder;
@ -30,7 +29,7 @@ class SupplierRepository extends AbstractPartsContainingRepository
{
public function getParts(object $element, array $order_by = ['name' => 'ASC']): array
{
if(!$element instanceof Supplier) {
if (!$element instanceof Supplier) {
throw new \InvalidArgumentException('$element must be an Supplier!');
}
@ -43,7 +42,7 @@ class SupplierRepository extends AbstractPartsContainingRepository
->setParameter(1, $element);
foreach ($order_by as $field => $order) {
$qb->addOrderBy('part.' . $field, $order);
$qb->addOrderBy('part.'.$field, $order);
}
return $qb->getQuery()->getResult();
@ -51,7 +50,7 @@ class SupplierRepository extends AbstractPartsContainingRepository
public function getPartsCount(object $element): int
{
if(!$element instanceof Supplier) {
if (!$element instanceof Supplier) {
throw new \InvalidArgumentException('$element must be an Supplier!');
}
@ -63,7 +62,6 @@ class SupplierRepository extends AbstractPartsContainingRepository
->where('orderdetail.supplier = ?1')
->setParameter(1, $element);
return (int) $qb->getQuery()->getSingleScalarResult();
}
}
}

View file

@ -63,7 +63,7 @@ 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
*
* @return TreeViewNode[]
*/
@ -90,7 +90,7 @@ class StructuralDBElementRepository extends NamedDBElementRepository
*
* @param AbstractStructuralDBElement|null $parent This entity will be used as root element. Set to null, to use global root
*
* @return AbstractStructuralDBElement[] A flattened list containing the tree elements.
* @return AbstractStructuralDBElement[] a flattened list containing the tree elements
*/
public function toNodesList(?AbstractStructuralDBElement $parent = null): array
{

View file

@ -60,8 +60,6 @@ final class UserRepository extends NamedDBElementRepository implements PasswordU
/**
* Returns the anonymous user.
* The result is cached, so the database is only called once, after the anonymous user was found.
*
* @return User|null
*/
public function getAnonymousUser(): ?User
{