Applied symplify rules to codebase.

This commit is contained in:
Jan Böhmer 2020-01-05 22:49:00 +01:00
parent 2f20d90041
commit 388e847b17
136 changed files with 1370 additions and 789 deletions

View file

@ -29,6 +29,7 @@ use Doctrine\ORM\QueryBuilder;
use Omines\DataTablesBundle\Adapter\AdapterQuery;
use Omines\DataTablesBundle\Adapter\Doctrine\ORMAdapter;
use Omines\DataTablesBundle\Column\AbstractColumn;
use Traversable;
/**
* Override default ORM Adapter, to allow fetch joins (allow addSelect with ManyToOne Collections).
@ -52,9 +53,9 @@ class CustomORMAdapter extends ORMAdapter
}
/**
* @return \Traversable
* @return Traversable
*/
protected function getResults(AdapterQuery $query): \Traversable
protected function getResults(AdapterQuery $query): Traversable
{
/** @var QueryBuilder $builder */
$builder = $query->get('qb');

View file

@ -38,7 +38,7 @@ use Omines\DataTablesBundle\DataTable;
use Omines\DataTablesBundle\DataTableTypeInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
class AttachmentDataTable implements DataTableTypeInterface
final class AttachmentDataTable implements DataTableTypeInterface
{
protected $translator;
protected $entityURLGenerator;

View file

@ -24,7 +24,10 @@ declare(strict_types=1);
namespace App\DataTables\Column;
use DateTime;
use DateTimeInterface;
use IntlDateFormatter;
use Locale;
use Omines\DataTablesBundle\Column\AbstractColumn;
use Symfony\Component\OptionsResolver\OptionsResolver;
@ -38,8 +41,8 @@ class LocaleDateTimeColumn extends AbstractColumn
{
if (null === $value) {
return $this->options['nullValue'];
} elseif (! $value instanceof \DateTimeInterface) {
$value = new \DateTime((string) $value);
} elseif (! $value instanceof DateTimeInterface) {
$value = new DateTime((string) $value);
}
$formatValues = [
@ -51,7 +54,7 @@ class LocaleDateTimeColumn extends AbstractColumn
];
$formatter = IntlDateFormatter::create(
\Locale::getDefault(),
Locale::getDefault(),
$formatValues[$this->options['dateFormat']],
$formatValues[$this->options['timeFormat']],
$value->getTimezone()

View file

@ -30,6 +30,7 @@ use App\Services\Attachments\AttachmentManager;
use App\Services\EntityURLGenerator;
use App\Services\FAIconGenerator;
use Omines\DataTablesBundle\Column\AbstractColumn;
use RuntimeException;
use Symfony\Component\OptionsResolver\OptionsResolver;
class PartAttachmentsColumn extends AbstractColumn
@ -60,7 +61,7 @@ class PartAttachmentsColumn extends AbstractColumn
public function render($value, $context)
{
if (! $context instanceof Part) {
throw new \RuntimeException('$context must be a Part object!');
throw new RuntimeException('$context must be a Part object!');
}
$tmp = '';
$attachments = $context->getAttachments()->filter(function (Attachment $attachment) {

View file

@ -50,17 +50,17 @@ use Omines\DataTablesBundle\DataTable;
use Omines\DataTablesBundle\DataTableTypeInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
class PartsDataTable implements DataTableTypeInterface
final class PartsDataTable implements DataTableTypeInterface
{
/**
* @var EntityURLGenerator
*/
protected $urlGenerator;
protected $translator;
protected $treeBuilder;
protected $amountFormatter;
protected $previewGenerator;
protected $attachmentURLGenerator;
/**
* @var EntityURLGenerator
*/
protected $urlGenerator;
public function __construct(EntityURLGenerator $urlGenerator, TranslatorInterface $translator,
NodesListBuilder $treeBuilder, AmountFormatter $amountFormatter,