Skip to content

Commit 7842f2e

Browse files
committed
Fix code style and tests
1 parent 92a06d6 commit 7842f2e

14 files changed

+39
-45
lines changed

CHANGELOG.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,21 @@ All notable changes to `omines\datatables-bundle` will be documented in this fil
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

55
## [Unreleased]
6+
Nothing yet.
7+
8+
## [0.5.0] - 2020-06-29
9+
### Added
10+
- Support for server-side exportsv (#83)
11+
- Support for per-column searches (#120)
12+
- ORM adapter supporting fetch joins (#121)
13+
- TwigStringColumn type for simple inline templating (#146)
14+
615
### Changed
716
- Fix contract dependency handling by upping Symfony requirement to 4.2+
817

18+
### Fixed
19+
- Use trans() for proper locale fallback when using CDN languages (#141)
20+
921
## [0.4.2] - 2020-04-08
1022
### Added
1123
- Update translations automatically with script (#130)
@@ -116,7 +128,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
116128
### Added
117129
- Basic functionality
118130

119-
[Unreleased]: https://github.com/omines/datatables-bundle/compare/0.4.2...master
131+
[Unreleased]: https://github.com/omines/datatables-bundle/compare/0.5.0...master
132+
[0.5.0]: https://github.com/omines/datatables-bundle/compare/0.4.2...0.5.0
120133
[0.4.2]: https://github.com/omines/datatables-bundle/compare/0.4.1...0.4.2
121134
[0.4.1]: https://github.com/omines/datatables-bundle/compare/0.4.0...0.4.1
122135
[0.4.0]: https://github.com/omines/datatables-bundle/compare/0.3.1...0.4.0

src/Adapter/Doctrine/FetchJoinORMAdapter.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?php
2+
23
/*
34
* Symfony DataTables Bundle
4-
* (c) Jan Böhmer 2020
5+
* (c) Omines Internetbureau B.V. - https://omines.nl/
56
*
67
* For the full copyright and license information, please view the LICENSE
78
* file that was distributed with this source code.

src/DataTable.php

-5
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,6 @@ class DataTable
112112

113113
/**
114114
* DataTable constructor.
115-
*
116-
* @param EventDispatcherInterface $eventDispatcher
117-
* @param DataTableExporterManager $exporterManager
118-
* @param array $options
119-
* @param Instantiator|null $instantiator
120115
*/
121116
public function __construct(EventDispatcherInterface $eventDispatcher, DataTableExporterManager $exporterManager, array $options = [], Instantiator $instantiator = null)
122117
{

src/Exporter/Csv/CsvExporter.php

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<?php
22

3+
/*
4+
* Symfony DataTables Bundle
5+
* (c) Omines Internetbureau B.V. - https://omines.nl/
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
311
declare(strict_types=1);
412

513
namespace Omines\DataTablesBundle\Exporter\Csv;

src/Exporter/DataTableExporterCollection.php

-6
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ class DataTableExporterCollection
2727

2828
/**
2929
* DataTableExporterCollection constructor.
30-
*
31-
* @param \Traversable $exporters
3230
*/
3331
public function __construct(\Traversable $exporters)
3432
{
@@ -38,10 +36,6 @@ public function __construct(\Traversable $exporters)
3836
/**
3937
* Finds a DataTable exporter that matches the given name.
4038
*
41-
* @param string $name
42-
*
43-
* @return DataTableExporterInterface
44-
*
4539
* @throws UnknownDataTableExporterException
4640
*/
4741
public function getByName(string $name): DataTableExporterInterface

src/Exporter/DataTableExporterInterface.php

-7
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,11 @@ interface DataTableExporterInterface
2121
{
2222
/**
2323
* Exports the data from the DataTable to a file.
24-
*
25-
* @param array $columnNames
26-
* @param \Iterator $data
27-
*
28-
* @return \SplFileInfo
2924
*/
3025
public function export(array $columnNames, \Iterator $data): \SplFileInfo;
3126

3227
/**
3328
* A unique name to identify the exporter.
34-
*
35-
* @return string
3629
*/
3730
public function getName(): string;
3831
}

src/Exporter/DataTableExporterManager.php

-10
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
namespace Omines\DataTablesBundle\Exporter;
1414

1515
use Omines\DataTablesBundle\DataTable;
16-
use Omines\DataTablesBundle\DataTableState;
1716
use Omines\DataTablesBundle\Exception\InvalidArgumentException;
1817
use Omines\DataTablesBundle\Exporter\Event\DataTableExporterResponseEvent;
1918
use Symfony\Component\HttpFoundation\BinaryFileResponse;
@@ -44,7 +43,6 @@ class DataTableExporterManager
4443
/**
4544
* DataTableExporterManager constructor.
4645
*
47-
* @param DataTableExporterCollection $exporterCollection
4846
* @param TranslatorInterface|LegacyTranslatorInterface $translator
4947
*/
5048
public function __construct(DataTableExporterCollection $exporterCollection, $translator)
@@ -58,8 +56,6 @@ public function __construct(DataTableExporterCollection $exporterCollection, $tr
5856
}
5957

6058
/**
61-
* @param string $exporterName
62-
*
6359
* @return DataTableExporterManager
6460
*/
6561
public function setExporterName(string $exporterName): self
@@ -70,8 +66,6 @@ public function setExporterName(string $exporterName): self
7066
}
7167

7268
/**
73-
* @param DataTable $dataTable
74-
*
7569
* @return DataTableExporterManager
7670
*/
7771
public function setDataTable(DataTable $dataTable): self
@@ -82,8 +76,6 @@ public function setDataTable(DataTable $dataTable): self
8276
}
8377

8478
/**
85-
* @return Response
86-
*
8779
* @throws \Omines\DataTablesBundle\Exception\UnknownDataTableExporterException
8880
*/
8981
public function getResponse(): Response
@@ -121,8 +113,6 @@ private function getColumnNames(): array
121113
*
122114
* A Generator is created in order to remove the 'DT_RowId' key
123115
* which is created by some adapters (e.g. ORMAdapter).
124-
*
125-
* @return \Iterator
126116
*/
127117
private function getAllData(): \Iterator
128118
{

src/Exporter/Event/DataTableExporterResponseEvent.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
namespace Omines\DataTablesBundle\Exporter\Event;
1414

15-
use Symfony\Contracts\EventDispatcher\Event;
1615
use Symfony\Component\HttpFoundation\BinaryFileResponse;
16+
use Symfony\Contracts\EventDispatcher\Event;
1717

1818
/**
1919
* DataTableExporterResponseEvent.
@@ -27,17 +27,12 @@ class DataTableExporterResponseEvent extends Event
2727

2828
/**
2929
* DataTableExporterResponseEvent constructor.
30-
*
31-
* @param BinaryFileResponse $response
3230
*/
3331
public function __construct(BinaryFileResponse $response)
3432
{
3533
$this->response = $response;
3634
}
3735

38-
/**
39-
* @return BinaryFileResponse
40-
*/
4136
public function getResponse(): BinaryFileResponse
4237
{
4338
return $this->response;

src/Exporter/Excel/ExcelExporter.php

-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ public function export(array $columnNames, \Iterator $data): \SplFileInfo
6262
/**
6363
* Sets the columns width to automatically fit the contents.
6464
*
65-
* @param Worksheet $sheet
66-
*
6765
* @throws \PhpOffice\PhpSpreadsheet\Exception
6866
*/
6967
private function autoSizeColumnWidth(Worksheet $sheet)

src/Twig/DataTablesExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function getFunctions()
5252
*/
5353
private function getLanguageSettings(DataTable $dataTable)
5454
{
55-
if ($dataTable->isLanguageFromCDN() && ($cdnFile = $this->getCDNLanguageFile()) !== null) {
55+
if ($dataTable->isLanguageFromCDN() && null !== ($cdnFile = $this->getCDNLanguageFile())) {
5656
return ['url' => '//cdn.datatables.net/plug-ins/1.10.15/i18n/' . $cdnFile];
5757
}
5858

@@ -98,7 +98,7 @@ private function getCDNLanguageFile()
9898
$file = $this->translator->trans('file', [], 'DataTablesCDN');
9999

100100
// CDN language file does not exists
101-
if ($file === 'file') {
101+
if ('file' === $file) {
102102
return null;
103103
}
104104

tests/Functional/Exporter/Csv/CsvExporterTest.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<?php
22

3+
/*
4+
* Symfony DataTables Bundle
5+
* (c) Omines Internetbureau B.V. - https://omines.nl/
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
311
declare(strict_types=1);
412

513
namespace Tests\Functional\Exporter\Csv;
@@ -37,7 +45,7 @@ public function testExport(): void
3745

3846
$i = 0;
3947
while (false !== ($row = fgetcsv($csvFile))) {
40-
self::assertEquals(['FirstName'.$i, 'LastName'.$i], $row);
48+
self::assertEquals(['FirstName' . $i, 'LastName' . $i], $row);
4149
++$i;
4250
}
4351
}

tests/Functional/FunctionalTest.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ public function testPlainDataTable()
6565
$this->assertEmpty($sample->employedSince);
6666
$this->assertSame('FirstName94 &lt;img src=&quot;https://symfony.com/images/v5/logos/sf-positive.svg&quot;&gt; LastName94', $sample->fullName);
6767
$this->assertSame('<a href="http://localhost/employee/95">FirstName94 LastName94</a>', $sample->link);
68-
$this->assertRegExp('#href="/employee/[0-9]+"#', $sample->buttons);
69-
68+
$this->assertMatchesRegularExpression('#href="/employee/[0-9]+"#', $sample->buttons);
7069
$this->assertSame('04-07-2016', $json->data[6]->employedSince);
7170
}
7271

tests/Unit/Adapter/DoctrineTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
use Omines\DataTablesBundle\Adapter\Doctrine\ORMAdapter;
2121
use Omines\DataTablesBundle\Column\TextColumn;
2222
use Omines\DataTablesBundle\DataTable;
23-
use Omines\DataTablesBundle\Exporter\DataTableExporterManager;
2423
use Omines\DataTablesBundle\Exception\InvalidConfigurationException;
24+
use Omines\DataTablesBundle\Exporter\DataTableExporterManager;
2525
use PHPUnit\Framework\TestCase;
2626
use Symfony\Component\EventDispatcher\EventDispatcher;
2727
use Symfony\Component\HttpFoundation\Request;

tests/Unit/DataTableTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
use Omines\DataTablesBundle\DataTablesBundle;
2121
use Omines\DataTablesBundle\DependencyInjection\DataTablesExtension;
2222
use Omines\DataTablesBundle\DependencyInjection\Instantiator;
23-
use Omines\DataTablesBundle\Exporter\DataTableExporterManager;
2423
use Omines\DataTablesBundle\Exception\InvalidArgumentException;
2524
use Omines\DataTablesBundle\Exception\InvalidConfigurationException;
2625
use Omines\DataTablesBundle\Exception\InvalidStateException;
26+
use Omines\DataTablesBundle\Exporter\DataTableExporterManager;
2727
use Omines\DataTablesBundle\Twig\TwigRenderer;
2828
use PHPUnit\Framework\TestCase;
2929
use Symfony\Component\DependencyInjection\ContainerBuilder;

0 commit comments

Comments
 (0)