diff --git a/.travis.yml b/.travis.yml index c187e91..42a3b45 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,63 +23,67 @@ env: matrix: fast_finish: true include: - - php: '7.1' - - php: '7.2' - php: '7.3' - php: '7.4' + - php: '8.0' # Enable code coverage with the previous supported PHP version - - php: '7.3' + - php: '7.4' env: - SYMFONY_VERSION=3.4.* - COVERALLS_ENABLED="true" - PHPUNIT_FLAGS="-v --coverage-text --coverage-clover var/build/clover.xml" # Enable code coverage with the latest supported PHP version - - php: '7.4' + - php: '8.0' env: - SYMFONY_VERSION=3.4.* - COVERALLS_ENABLED="true" - PHPUNIT_FLAGS="-v --coverage-text --coverage-clover var/build/clover.xml" # Minimum supported dependencies with the latest and oldest supported PHP versions - - php: '7.1' - env: - - COMPOSER_FLAGS="--prefer-lowest" - php: '7.3' env: - COMPOSER_FLAGS="--prefer-lowest" + # Incompatibility between lowest symfony testing utils and phpunit +# - php: '8.0' +# env: +# - COMPOSER_FLAGS="--prefer-lowest" # Test each supported Symfony version with lowest supported PHP version - - php: '7.1' + - php: '7.3' env: - SYMFONY_VERSION=3.4.* - - php: '7.1' - env: - - SYMFONY_VERSION=4.3.* - - php: '7.1' + - php: '7.3' env: - SYMFONY_VERSION=4.4.* - - php: '7.2' + - php: '7.3' env: - COVERALLS_ENABLED="true" - PHPUNIT_FLAGS="-v --coverage-text --coverage-clover var/build/clover.xml" - - SYMFONY_VERSION=5.0.* - + - SYMFONY_VERSION=5.2.* # Test unsupported versions of Symfony - - php: '7.1' + - php: '7.3' env: - SYMFONY_VERSION=4.1.* - - php: '7.1' + - php: '7.3' env: - SYMFONY_VERSION=4.2.* - + - php: '7.3' + env: + - SYMFONY_VERSION=4.3.* + - php: '7.3' + env: + - SYMFONY_VERSION=5.0.* + - php: '7.3' + env: + - SYMFONY_VERSION=5.1.* # Test upcoming Symfony versions with lowest supported PHP version and dev dependencies - - php: '7.2' - env: - - STABILITY=dev - - SYMFONY_VERSION=5.1.* +# - php: '7.2' +# env: +# - STABILITY=dev +# - SYMFONY_VERSION=5.3.* # Test upcoming PHP versions with dev dependencies #- php: '7.5snapshot' @@ -101,6 +105,9 @@ matrix: - env: - STABILITY=dev - SYMFONY_VERSION=5.1.* + - env: + - STABILITY=dev + - SYMFONY_VERSION=5.2.* before_install: - if [[ "$SYMFONY_VERSION" != "" ]]; then @@ -114,11 +121,11 @@ before_install: phpenv config-rm xdebug.ini || true; fi - if [[ "$COVERALLS_ENABLED" == "true" ]]; then - travis_retry composer require --dev satooshi/php-coveralls:^2.0 --no-update $COMPOSER_FLAGS; + travis_retry composer require --dev php-coveralls/php-coveralls:^2.0 --no-update $COMPOSER_FLAGS; fi install: - - travis_retry composer update --prefer-dist --no-interaction --no-suggest --no-progress --ansi $COMPOSER_FLAGS + - travis_retry composer update --prefer-dist --no-interaction --no-progress --ansi $COMPOSER_FLAGS script: ./vendor/bin/phpunit $PHPUNIT_FLAGS diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a30173..70534ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# Version 3.0.0 + +* Added PHP 8 support +* PHP minimum requirements bumped to 7.3 +* Added Doctrine DBAL 3 support +* Doctrine DBAL minimum requirements bumped to 2.12 + # Version 2.2.0 * Improve logging Dataflow job diff --git a/composer.json b/composer.json index ead9141..6871a38 100644 --- a/composer.json +++ b/composer.json @@ -41,9 +41,9 @@ } }, "require": { - "php": "^7.1", + "php": "^7.3||^8.0", "ext-json": "*", - "doctrine/dbal": "^2.0", + "doctrine/dbal": "^2.12||^3.0", "doctrine/doctrine-bundle": "^1.0||^2.0", "psr/log": "^1.1", "symfony/config": "^3.4||^4.0||^5.0", diff --git a/src/Repository/JobRepository.php b/src/Repository/JobRepository.php index 553c968..dfc20d7 100644 --- a/src/Repository/JobRepository.php +++ b/src/Repository/JobRepository.php @@ -7,6 +7,7 @@ namespace CodeRhapsodie\DataflowBundle\Repository; use CodeRhapsodie\DataflowBundle\Entity\Job; use CodeRhapsodie\DataflowBundle\Entity\ScheduledDataflow; use Doctrine\DBAL\Driver\Connection; +use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Query\QueryBuilder; /** @@ -21,15 +22,15 @@ class JobRepository public const TABLE_NAME = 'cr_dataflow_job'; private const FIELDS_TYPE = [ - 'id' => \PDO::PARAM_INT, - 'status' => \PDO::PARAM_INT, - 'label' => \PDO::PARAM_STR, - 'dataflow_type' => \PDO::PARAM_STR, - 'options' => \PDO::PARAM_STR, + 'id' => ParameterType::INTEGER, + 'status' => ParameterType::INTEGER, + 'label' => ParameterType::STRING, + 'dataflow_type' => ParameterType::STRING, + 'options' => ParameterType::STRING, 'requested_date' => 'datetime', - 'scheduled_dataflow_id' => \PDO::PARAM_INT, - 'count' => \PDO::PARAM_INT, - 'exceptions' => \PDO::PARAM_STR, + 'scheduled_dataflow_id' => ParameterType::INTEGER, + 'count' => ParameterType::INTEGER, + 'exceptions' => ParameterType::STRING, 'start_time' => 'datetime', 'end_time' => 'datetime', ]; @@ -51,7 +52,7 @@ class JobRepository { $qb = $this->createQueryBuilder(); $qb - ->andWhere($qb->expr()->eq('id', $qb->createNamedParameter($jobId, \PDO::PARAM_INT))) + ->andWhere($qb->expr()->eq('id', $qb->createNamedParameter($jobId, ParameterType::INTEGER))) ; return $this->returnFirstOrNull($qb); @@ -62,12 +63,12 @@ class JobRepository $qb = $this->createQueryBuilder(); $qb ->andWhere($qb->expr()->isNull('scheduled_dataflow_id')) - ->andWhere($qb->expr()->eq('status', $qb->createNamedParameter(Job::STATUS_PENDING, \PDO::PARAM_INT))); + ->andWhere($qb->expr()->eq('status', $qb->createNamedParameter(Job::STATUS_PENDING, ParameterType::INTEGER))); $stmt = $qb->execute(); if (0 === $stmt->rowCount()) { return []; } - while (false !== ($row = $stmt->fetch(\PDO::FETCH_ASSOC))) { + while (false !== ($row = $stmt->fetchAssociative())) { yield Job::createFromArray($this->initDateTime($this->initArray($row))); } } @@ -76,8 +77,8 @@ class JobRepository { $qb = $this->createQueryBuilder(); $qb - ->andWhere($qb->expr()->eq('scheduled_dataflow_id', $qb->createNamedParameter($scheduled->getId(), \PDO::PARAM_INT))) - ->andWhere($qb->expr()->eq('status', $qb->createNamedParameter(Job::STATUS_PENDING, \PDO::PARAM_INT))); + ->andWhere($qb->expr()->eq('scheduled_dataflow_id', $qb->createNamedParameter($scheduled->getId(), ParameterType::INTEGER))) + ->andWhere($qb->expr()->eq('status', $qb->createNamedParameter(Job::STATUS_PENDING, ParameterType::INTEGER))); return $this->returnFirstOrNull($qb); } @@ -86,7 +87,7 @@ class JobRepository { $qb = $this->createQueryBuilder(); $qb->andWhere($qb->expr()->lte('requested_date', $qb->createNamedParameter(new \DateTime(), 'datetime'))) - ->andWhere($qb->expr()->eq('status', $qb->createNamedParameter(Job::STATUS_PENDING, \PDO::PARAM_INT))) + ->andWhere($qb->expr()->eq('status', $qb->createNamedParameter(Job::STATUS_PENDING, ParameterType::INTEGER))) ->orderBy('requested_date', 'ASC') ->setMaxResults(1) ; @@ -97,7 +98,7 @@ class JobRepository public function findLastForDataflowId(int $dataflowId): ?Job { $qb = $this->createQueryBuilder(); - $qb->andWhere($qb->expr()->eq('scheduled_dataflow_id', $qb->createNamedParameter($dataflowId, \PDO::PARAM_INT))) + $qb->andWhere($qb->expr()->eq('scheduled_dataflow_id', $qb->createNamedParameter($dataflowId, ParameterType::INTEGER))) ->orderBy('requested_date', 'DESC') ->setMaxResults(1) ; @@ -115,7 +116,7 @@ class JobRepository if (0 === $stmt->rowCount()) { return []; } - while (false !== ($row = $stmt->fetch(\PDO::FETCH_ASSOC))) { + while (false !== ($row = $stmt->fetchAssociative())) { yield Job::createFromArray($row); } } @@ -123,14 +124,14 @@ class JobRepository public function findForScheduled(int $id): iterable { $qb = $this->createQueryBuilder(); - $qb->andWhere($qb->expr()->eq('scheduled_dataflow_id', $qb->createNamedParameter($id, \PDO::PARAM_INT))) + $qb->andWhere($qb->expr()->eq('scheduled_dataflow_id', $qb->createNamedParameter($id, ParameterType::INTEGER))) ->orderBy('requested_date', 'DESC') ->setMaxResults(20); $stmt = $qb->execute(); if (0 === $stmt->rowCount()) { return []; } - while (false !== ($row = $stmt->fetch(\PDO::FETCH_ASSOC))) { + while (false !== ($row = $stmt->fetchAssociative())) { yield Job::createFromArray($row); } } @@ -172,6 +173,6 @@ class JobRepository return null; } - return Job::createFromArray($this->initDateTime($this->initArray($stmt->fetch(\PDO::FETCH_ASSOC)))); + return Job::createFromArray($this->initDateTime($this->initArray($stmt->fetchAssociative()))); } } diff --git a/src/Repository/ScheduledDataflowRepository.php b/src/Repository/ScheduledDataflowRepository.php index 56a6ab2..49f3f21 100644 --- a/src/Repository/ScheduledDataflowRepository.php +++ b/src/Repository/ScheduledDataflowRepository.php @@ -6,6 +6,7 @@ namespace CodeRhapsodie\DataflowBundle\Repository; use CodeRhapsodie\DataflowBundle\Entity\ScheduledDataflow; use Doctrine\DBAL\Driver\Connection; +use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Query\QueryBuilder; /** @@ -20,13 +21,13 @@ class ScheduledDataflowRepository public const TABLE_NAME = 'cr_dataflow_scheduled'; private const FIELDS_TYPE = [ - 'id' => \PDO::PARAM_INT, - 'label' => \PDO::PARAM_STR, - 'dataflow_type' => \PDO::PARAM_STR, - 'options' => \PDO::PARAM_STR, - 'frequency' => \PDO::PARAM_STR, + 'id' => ParameterType::INTEGER, + 'label' => ParameterType::STRING, + 'dataflow_type' => ParameterType::STRING, + 'options' => ParameterType::STRING, + 'frequency' => ParameterType::STRING, 'next' => 'datetime', - 'enabled' => \PDO::PARAM_BOOL, + 'enabled' => ParameterType::BOOLEAN, ]; /** * @var \Doctrine\DBAL\Connection @@ -58,7 +59,7 @@ class ScheduledDataflowRepository if (0 === $stmt->rowCount()) { return []; } - while (false !== ($row = $stmt->fetch(\PDO::FETCH_ASSOC))) { + while (false !== ($row = $stmt->fetchAssociative())) { yield ScheduledDataflow::createFromArray($this->initDateTime($this->initArray($row))); } } @@ -66,7 +67,7 @@ class ScheduledDataflowRepository public function find(int $scheduleId): ?ScheduledDataflow { $qb = $this->createQueryBuilder(); - $qb->andWhere($qb->expr()->eq('id', $qb->createNamedParameter($scheduleId, \PDO::PARAM_INT))) + $qb->andWhere($qb->expr()->eq('id', $qb->createNamedParameter($scheduleId, ParameterType::INTEGER))) ->setMaxResults(1) ; @@ -82,7 +83,7 @@ class ScheduledDataflowRepository if (0 === $stmt->rowCount()) { return []; } - while (false !== ($row = $stmt->fetch(\PDO::FETCH_ASSOC))) { + while (false !== ($row = $stmt->fetchAssociative())) { yield ScheduledDataflow::createFromArray($this->initDateTime($this->initOptions($row))); } } @@ -96,7 +97,7 @@ class ScheduledDataflowRepository ->orderBy('w.label', 'ASC') ->groupBy('w.id'); - return $query->execute()->fetchAll(\PDO::FETCH_ASSOC); + return $query->execute()->fetchAllAssociative(); } public function save(ScheduledDataflow $scheduledDataflow) @@ -147,6 +148,6 @@ class ScheduledDataflowRepository return null; } - return ScheduledDataflow::createFromArray($this->initDateTime($this->initArray($stmt->fetch(\PDO::FETCH_ASSOC)))); + return ScheduledDataflow::createFromArray($this->initDateTime($this->initArray($stmt->fetchAssociative()))); } }