mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-23 02:09:03 +02:00
Applied rector suggestions
This commit is contained in:
parent
4106bcef5f
commit
20f32c7f12
170 changed files with 808 additions and 761 deletions
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\DataTables\Adapters;
|
||||
|
||||
use Doctrine\ORM\Query\Expr\From;
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Doctrine\ORM\Tools\Pagination\Paginator;
|
||||
|
@ -51,12 +52,12 @@ class TwoStepORMAdapter extends ORMAdapter
|
|||
|
||||
private bool $use_simple_total = false;
|
||||
|
||||
private \Closure|null $query_modifier;
|
||||
private \Closure|null $query_modifier = null;
|
||||
|
||||
public function __construct(ManagerRegistry $registry = null)
|
||||
{
|
||||
parent::__construct($registry);
|
||||
$this->detailQueryCallable = static function (QueryBuilder $qb, array $ids) {
|
||||
$this->detailQueryCallable = static function (QueryBuilder $qb, array $ids): never {
|
||||
throw new \RuntimeException('You need to set the detail_query option to use the TwoStepORMAdapter');
|
||||
};
|
||||
}
|
||||
|
@ -66,9 +67,7 @@ class TwoStepORMAdapter extends ORMAdapter
|
|||
parent::configureOptions($resolver);
|
||||
|
||||
$resolver->setRequired('filter_query');
|
||||
$resolver->setDefault('query', function (Options $options) {
|
||||
return $options['filter_query'];
|
||||
});
|
||||
$resolver->setDefault('query', fn(Options $options) => $options['filter_query']);
|
||||
|
||||
$resolver->setRequired('detail_query');
|
||||
$resolver->setAllowedTypes('detail_query', \Closure::class);
|
||||
|
@ -108,7 +107,7 @@ class TwoStepORMAdapter extends ORMAdapter
|
|||
}
|
||||
}
|
||||
|
||||
/** @var Query\Expr\From $fromClause */
|
||||
/** @var From $fromClause */
|
||||
$fromClause = $builder->getDQLPart('from')[0];
|
||||
$identifier = "{$fromClause->getAlias()}.{$this->metadata->getSingleIdentifierFieldName()}";
|
||||
|
||||
|
@ -201,7 +200,7 @@ class TwoStepORMAdapter extends ORMAdapter
|
|||
/** The paginator count queries can be rather slow, so when query for total count (100ms or longer),
|
||||
* just return the entity count.
|
||||
*/
|
||||
/** @var Query\Expr\From $from_expr */
|
||||
/** @var From $from_expr */
|
||||
$from_expr = $queryBuilder->getDQLPart('from')[0];
|
||||
|
||||
return $this->manager->getRepository($from_expr->getFrom())->count([]);
|
||||
|
|
|
@ -92,7 +92,7 @@ final class AttachmentDataTable implements DataTableTypeInterface
|
|||
if ($context->isExternal()) {
|
||||
return sprintf(
|
||||
'<a href="%s" class="link-external">%s</a>',
|
||||
htmlspecialchars($context->getURL()),
|
||||
htmlspecialchars((string) $context->getURL()),
|
||||
htmlspecialchars($value)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\DataTables\Column;
|
||||
|
||||
use Omines\DataTablesBundle\Column\AbstractColumn;
|
||||
|
|
|
@ -109,7 +109,7 @@ class ColumnSortHelper
|
|||
}
|
||||
|
||||
//and the remaining non-visible columns
|
||||
foreach ($this->columns as $col_id => $col_data) {
|
||||
foreach (array_keys($this->columns) as $col_id) {
|
||||
if (in_array($col_id, $processed_columns, true)) {
|
||||
// column already processed
|
||||
continue;
|
||||
|
|
|
@ -162,7 +162,7 @@ class LogDataTable implements DataTableTypeInterface
|
|||
if (!$user instanceof User) {
|
||||
if ($context->isCLIEntry()) {
|
||||
return sprintf('%s [%s]',
|
||||
htmlentities($context->getCLIUsername()),
|
||||
htmlentities((string) $context->getCLIUsername()),
|
||||
$this->translator->trans('log.cli_user')
|
||||
);
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ final class PartsDataTable implements DataTableTypeInterface
|
|||
'orderField' => 'NATSORT(_partUnit.name)',
|
||||
'render' => function($value, Part $context): string {
|
||||
$partUnit = $context->getPartUnit();
|
||||
if (!$partUnit) {
|
||||
if ($partUnit === null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ final class PartsDataTable implements DataTableTypeInterface
|
|||
'label' => $this->translator->trans('part.table.manufacturingStatus'),
|
||||
'class' => ManufacturingStatus::class,
|
||||
'render' => function (?ManufacturingStatus $status, Part $context): string {
|
||||
if (!$status) {
|
||||
if ($status === null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface
|
|||
'orderField' => 'NATSORT(part.name)',
|
||||
'render' => function ($value, ProjectBOMEntry $context) {
|
||||
if(!$context->getPart() instanceof Part) {
|
||||
return htmlspecialchars($context->getName());
|
||||
return htmlspecialchars((string) $context->getName());
|
||||
}
|
||||
if($context->getPart() instanceof Part) {
|
||||
$tmp = $this->partDataTableHelper->renderName($context->getPart());
|
||||
|
@ -154,7 +154,7 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface
|
|||
'label' => 'project.bom.instockAmount',
|
||||
'visible' => false,
|
||||
'render' => function ($value, ProjectBOMEntry $context) {
|
||||
if ($context->getPart()) {
|
||||
if ($context->getPart() !== null) {
|
||||
return $this->partDataTableHelper->renderAmount($context->getPart());
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface
|
|||
'label' => 'part.table.storeLocations',
|
||||
'visible' => false,
|
||||
'render' => function ($value, ProjectBOMEntry $context) {
|
||||
if ($context->getPart()) {
|
||||
if ($context->getPart() !== null) {
|
||||
return $this->partDataTableHelper->renderStorageLocations($context->getPart());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue