Skip to content

Commit

Permalink
Remove deprecated code (#584)
Browse files Browse the repository at this point in the history
* Remove deprecated code

* Remove propel from composer.json
  • Loading branch information
VincentLanglet committed May 22, 2022
1 parent 7d42174 commit d7a0b3f
Show file tree
Hide file tree
Showing 17 changed files with 64 additions and 319 deletions.
9 changes: 9 additions & 0 deletions UPGRADE-3.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# UPGRADE 3.0

## Deprecations

All the deprecated code introduced on 2.x is removed on 3.0.

Please read [2.x](https://github.com/sonata-project/exporter/tree/2.x) upgrade guides for more information.

See also the [diff code](https://github.com/sonata-project/exporter/compare/2.x...3.0.0).
2 changes: 0 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"phpstan/phpstan-strict-rules": "^1.0",
"phpstan/phpstan-symfony": "^1.0",
"phpunit/phpunit": "^9.5",
"propel/propel1": "^1.6",
"psalm/plugin-phpunit": "^0.16",
"psalm/plugin-symfony": "^3.0",
"rector/rector": "^0.12",
Expand All @@ -58,7 +57,6 @@
},
"suggest": {
"phpoffice/phpspreadsheet": "To be able to export the data in XLSX",
"propel/propel1": "To export propel collections",
"symfony/property-access": "To be able to export from database entities",
"symfony/routing": "To be able to export the routes of a Symfony app"
},
Expand Down
1 change: 0 additions & 1 deletion docs/reference/sources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ You may export data from various sources:
* CSV
* Doctrine Query (ORM & ODM supported)
* PDO Statement
* Propel Collection
* PHP Iterator instance
* PHP Iterator with a callback on current
* XML
Expand Down
37 changes: 0 additions & 37 deletions src/Bridge/Symfony/Bundle/SonataExporterBundle.php

This file was deleted.

22 changes: 0 additions & 22 deletions src/Bridge/Symfony/SonataExporterSymfonyBundle.php

This file was deleted.

59 changes: 30 additions & 29 deletions src/Source/AbstractPropertySourceIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
use Symfony\Component\PropertyAccess\PropertyAccessor;
use Symfony\Component\PropertyAccess\PropertyPath;

abstract class AbstractPropertySourceIterator implements SourceIteratorInterface
/**
* @phpstan-implements \Iterator<array<mixed>>
*/
abstract class AbstractPropertySourceIterator implements \Iterator
{
private const DATE_PARTS = [
'y' => 'Y',
Expand Down Expand Up @@ -104,34 +107,6 @@ public function getDateTimeFormat(): string
return $this->dateTimeFormat;
}

/**
* NEXT_MAJOR: Change the method visibility to private.
*
* @return string An ISO8601 duration
*/
public function getDuration(\DateInterval $interval): string
{
$datePart = '';
foreach (self::DATE_PARTS as $datePartAttribute => $datePartAttributeString) {
if ($interval->$datePartAttribute !== 0) {
$datePart .= $interval->$datePartAttribute.$datePartAttributeString;
}
}

$timePart = '';
foreach (self::TIME_PARTS as $timePartAttribute => $timePartAttributeString) {
if ($interval->$timePartAttribute !== 0) {
$timePart .= $interval->$timePartAttribute.$timePartAttributeString;
}
}

if ('' === $datePart && '' === $timePart) {
return 'P0Y';
}

return 'P'.$datePart.('' !== $timePart ? 'T'.$timePart : '');
}

/**
* @param object|mixed[] $current
*
Expand Down Expand Up @@ -179,4 +154,30 @@ protected function getValue($value)
return $value;
}
}

/**
* @return string An ISO8601 duration
*/
private function getDuration(\DateInterval $interval): string
{
$datePart = '';
foreach (self::DATE_PARTS as $datePartAttribute => $datePartAttributeString) {
if ($interval->$datePartAttribute !== 0) {
$datePart .= $interval->$datePartAttribute.$datePartAttributeString;
}
}

$timePart = '';
foreach (self::TIME_PARTS as $timePartAttribute => $timePartAttributeString) {
if ($interval->$timePartAttribute !== 0) {
$timePart .= $interval->$timePartAttribute.$timePartAttributeString;
}
}

if ('' === $datePart && '' === $timePart) {
return 'P0Y';
}

return 'P'.$datePart.('' !== $timePart ? 'T'.$timePart : '');
}
}
4 changes: 3 additions & 1 deletion src/Source/AbstractXmlSourceIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
* Read data from a Xml file.
*
* @author Vincent Touzet <vincent.touzet@gmail.com>
*
* @phpstan-implements \Iterator<array<mixed>>
*/
abstract class AbstractXmlSourceIterator implements SourceIteratorInterface
abstract class AbstractXmlSourceIterator implements \Iterator
{
/**
* @var string
Expand Down
5 changes: 4 additions & 1 deletion src/Source/ChainSourceIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@

namespace Sonata\Exporter\Source;

final class ChainSourceIterator implements SourceIteratorInterface
/**
* @phpstan-implements \Iterator<array<mixed>>
*/
final class ChainSourceIterator implements \Iterator
{
/**
* @var \ArrayIterator<array-key, \Iterator>
Expand Down
4 changes: 3 additions & 1 deletion src/Source/CsvSourceIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
* Read data from a csv file.
*
* @author Vincent Touzet <vincent.touzet@gmail.com>
*
* @phpstan-implements \Iterator<array<mixed>>
*/
final class CsvSourceIterator implements SourceIteratorInterface
final class CsvSourceIterator implements \Iterator
{
private string $filename;

Expand Down
5 changes: 4 additions & 1 deletion src/Source/DoctrineDBALConnectionSourceIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Driver\Result;

final class DoctrineDBALConnectionSourceIterator implements SourceIteratorInterface
/**
* @phpstan-implements \Iterator<array<mixed>>
*/
final class DoctrineDBALConnectionSourceIterator implements \Iterator
{
private Connection $connection;

Expand Down
4 changes: 3 additions & 1 deletion src/Source/IteratorSourceIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@

/**
* SourceIterator implementation based on Iterator.
*
* @phpstan-implements \Iterator<array<mixed>>
*/
class IteratorSourceIterator implements SourceIteratorInterface
class IteratorSourceIterator implements \Iterator
{
/**
* @var \Iterator<mixed, array<mixed>>
Expand Down
5 changes: 4 additions & 1 deletion src/Source/PDOStatementSourceIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@

use Sonata\Exporter\Exception\InvalidMethodCallException;

final class PDOStatementSourceIterator implements SourceIteratorInterface
/**
* @phpstan-implements \Iterator<array<mixed>>
*/
final class PDOStatementSourceIterator implements \Iterator
{
private \PDOStatement $statement;

Expand Down
52 changes: 0 additions & 52 deletions src/Source/PropelCollectionSourceIterator.php

This file was deleted.

25 changes: 0 additions & 25 deletions src/Source/SourceIteratorInterface.php

This file was deleted.

5 changes: 4 additions & 1 deletion src/Source/SymfonySitemapSourceIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\RouterInterface;

final class SymfonySitemapSourceIterator implements SourceIteratorInterface
/**
* @phpstan-implements \Iterator<array<mixed>>
*/
final class SymfonySitemapSourceIterator implements \Iterator
{
private RouterInterface $router;

Expand Down
48 changes: 0 additions & 48 deletions src/Test/AbstractTypedWriterTestCase.php

This file was deleted.

0 comments on commit d7a0b3f

Please sign in to comment.