diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dcc0b22..b7f5b62 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,9 +6,29 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: [ '8.2', '8.1', '8.0', '7.4', '7.3', '7.2' ] - console-versions: ['6.2', '6.0', '5.4', '5.3', '5.2', '5.1', '5.0', '4.4', '4.3', '4.2', '4.1', '4.0', '3.4'] + php-versions: [ '8.3', '8.2', '8.1', '8.0', '7.4', '7.3', '7.2' ] + console-versions: ['7.1', '7.0', '6.2', '6.0', '5.4', '5.3', '5.2', '5.1', '5.0', '4.4', '4.3', '4.2', '4.1', '4.0', '3.4'] exclude: + - php-versions: 8.3 + console-versions: 4.3 + - php-versions: 8.3 + console-versions: 4.2 + - php-versions: 8.3 + console-versions: 4.1 + - php-versions: 8.3 + console-versions: 4.0 + - php-versions: 8.3 + console-versions: 3.4 + - php-versions: 8.2 + console-versions: 4.3 + - php-versions: 8.2 + console-versions: 4.2 + - php-versions: 8.2 + console-versions: 4.1 + - php-versions: 8.2 + console-versions: 4.0 + - php-versions: 8.2 + console-versions: 3.4 - php-versions: 8.1 console-versions: 4.3 - php-versions: 8.1 @@ -33,18 +53,30 @@ jobs: console-versions: 4.0 - php-versions: 8.0 console-versions: 3.4 + - php-versions: 7.4 + console-versions: 7.1 + - php-versions: 7.4 + console-versions: 7.0 - php-versions: 7.4 console-versions: 6.2 - php-versions: 7.4 console-versions: 6.1 - php-versions: 7.4 console-versions: 6.0 + - php-versions: 7.3 + console-versions: 7.1 + - php-versions: 7.3 + console-versions: 7.0 - php-versions: 7.3 console-versions: 6.2 - php-versions: 7.3 console-versions: 6.1 - php-versions: 7.3 console-versions: 6.0 + - php-versions: 7.2 + console-versions: 7.1 + - php-versions: 7.2 + console-versions: 7.0 - php-versions: 7.2 console-versions: 6.2 - php-versions: 7.2 @@ -83,7 +115,7 @@ jobs: echo '::set-output name=compat::0' exit 0 fi - if [[ " 8.0 8.1 8.2 " =~ " ${{ matrix.php-versions }} " ]]; then + if [[ " 8.0 8.1 8.2 8.3 " =~ " ${{ matrix.php-versions }} " ]]; then if [[ " 4.4 4.3 " =~ " ${{ matrix.console-versions }} " ]]; then echo '::set-output name=compat::0' exit 0 diff --git a/.gitignore b/.gitignore index fbebd00..35ccf8a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /vendor .*.cache composer.lock +/cov diff --git a/composer.json b/composer.json index 10b2ee4..9da612e 100644 --- a/composer.json +++ b/composer.json @@ -32,16 +32,16 @@ ], "require": { "php": "^7.2|^8.0", - "fab2s/nodalflow": "^2.0.5", - "fab2s/opinhelpers": "^1.0" + "fab2s/nodalflow": "^2.0.6", + "fab2s/opinhelpers": "^1.0.1" }, "require-dev": { "ext-pdo": "*", - "phpunit/phpunit": "^9.0|^8.0|^7.5", - "symfony/console": "^6.0|^5.0|^4.0|^3.4|^2.8", - "symfony/event-dispatcher": "^6.0|^5.0|^4.0|^3.4|^2.8", - "orchestra/testbench": "^7.0|^6.0|^5.0|^4.0", - "friendsofphp/php-cs-fixer": "^3.0|^2.0" + "phpunit/phpunit": "^9.0.0|^8.0|^7.5", + "symfony/console": "^7.0|^6.0|^5.0|^4.0|^3.4|^2.8", + "symfony/event-dispatcher": "^7.0|^6.0|^5.0|^4.0|^3.4|^2.8", + "orchestra/testbench": "^9.0|^8.0|^7.0|^6.0|^5.0|^4.0", + "friendsofphp/php-cs-fixer": "^3.59" }, "suggest": { "symfony/console": "To use ProgressBarSubscriber", @@ -73,6 +73,8 @@ "post-install-cmd": [ "rm -f .*.cache" ], - "fix": "php-cs-fixer fix --config=./.php-cs-fixer.dist.php -vvv" + "fix": "php-cs-fixer fix --config=./.php-cs-fixer.dist.php -vvv", + "test": "@php vendor/bin/phpunit", + "cov": "@php vendor/bin/phpunit --coverage-html ./cov" } } diff --git a/src/Events/ProgressBarSubscriber.php b/src/Events/ProgressBarSubscriber.php index 380aecc..deaa08f 100644 --- a/src/Events/ProgressBarSubscriber.php +++ b/src/Events/ProgressBarSubscriber.php @@ -53,11 +53,10 @@ class ProgressBarSubscriber implements EventSubscriberInterface /** * ProgressBarSubscriber constructor. * - * @param YaEtl|null $flow * * @throws ReflectionException */ - public function __construct(YaEtl $flow = null) + public function __construct(?YaEtl $flow = null) { if ($flow !== null) { // auto register @@ -66,8 +65,6 @@ public function __construct(YaEtl $flow = null) } /** - * @param YaEtl $flow - * * @throws ReflectionException * * @return static @@ -92,8 +89,6 @@ public function getOutput() } /** - * @param OutputInterface $output - * * @return static */ public function setOutput(OutputInterface $output): self @@ -106,7 +101,6 @@ public function setOutput(OutputInterface $output): self /** * Set progress modulo * - * @param int $progressMod * * @return static */ @@ -120,7 +114,6 @@ public function setProgressMod(int $progressMod): self /** * Set the total number of records prior to FLow execution * - * @param int|null $numRecords * * @return static */ @@ -133,8 +126,6 @@ public function setNumRecords(?int $numRecords): self /** * Triggered when a Flow starts - * - * @param FlowEventInterface $event */ public function start(FlowEventInterface $event) { @@ -158,8 +149,6 @@ public function progress() /** * Triggered when a Flow succeeds - * - * @param FlowEventInterface $event */ public function success(FlowEventInterface $event) { @@ -178,8 +167,6 @@ public function success(FlowEventInterface $event) /** * Triggered when a Flow fails - * - * @param FlowEventInterface $event */ public function fail(FlowEventInterface $event) { @@ -189,9 +176,6 @@ public function fail(FlowEventInterface $event) $this->displayReport($event->getFlow()); } - /** - * @return array - */ public static function getSubscribedEvents(): array { return [ @@ -203,8 +187,6 @@ public static function getSubscribedEvents(): array } /** - * @param FlowInterface $flow - * * @return static */ protected function displayReport(FlowInterface $flow): self diff --git a/src/Events/YaEtlEvent.php b/src/Events/YaEtlEvent.php index f7778ce..6cb9610 100644 --- a/src/Events/YaEtlEvent.php +++ b/src/Events/YaEtlEvent.php @@ -21,9 +21,6 @@ class YaEtlEvent extends FlowEvent */ const FLOW_FLUSH = 'flow.flush'; - /** - * @return array - */ public static function getEventList(): array { if (!isset(static::$eventList)) { diff --git a/src/Extractors/AggregateExtractor.php b/src/Extractors/AggregateExtractor.php index 75a1a00..4e4fb4d 100644 --- a/src/Extractors/AggregateExtractor.php +++ b/src/Extractors/AggregateExtractor.php @@ -32,20 +32,17 @@ class AggregateExtractor extends AggregateNode /** * AggregateExtractor constructor. * - * @param bool $isAReturningVal * * @throws NodalFlowException */ public function __construct(bool $isAReturningVal) { // bypass parent, go to grand pa'. DRY won over KISS - PayloadNodeAbstract::/* @scrutinizer ignore-call */__construct(new YaEtl, $isAReturningVal); + PayloadNodeAbstract::/* @scrutinizer ignore-call */ __construct(new YaEtl, $isAReturningVal); $this->isATraversable = true; } /** - * @param TraversableNodeInterface $node - * * @throws NodalFlowException * @throws YaEtlException * diff --git a/src/Extractors/CallableExtractor.php b/src/Extractors/CallableExtractor.php index 96afbd8..31fca5e 100644 --- a/src/Extractors/CallableExtractor.php +++ b/src/Extractors/CallableExtractor.php @@ -11,6 +11,7 @@ use fab2s\NodalFlow\NodalFlowException; use fab2s\NodalFlow\Nodes\PayloadNodeAbstract; +use Generator; /** * Class CallableExtractor @@ -40,8 +41,6 @@ class CallableExtractor extends PayloadNodeAbstract implements ExtractorInterfac /** * CallableExtractorAbstract constructor. * - * @param callable $payload - * @param bool $isAReturningVal * * @throws NodalFlowException */ @@ -71,9 +70,10 @@ public function extract($param = null): bool /** * get the traversable to traverse within the Flow * - * @param mixed $param * - * @return \Generator + * @param null|mixed $param + * + * @return Generator */ public function getTraversable($param = null): iterable { diff --git a/src/Extractors/DbExtractorAbstract.php b/src/Extractors/DbExtractorAbstract.php index 7802217..8544109 100644 --- a/src/Extractors/DbExtractorAbstract.php +++ b/src/Extractors/DbExtractorAbstract.php @@ -18,8 +18,6 @@ abstract class DbExtractorAbstract extends ExtractorBatchLimitAbstract { /** * The SQL query - * - * @var mixed */ protected $extractQuery; @@ -31,7 +29,8 @@ abstract class DbExtractorAbstract extends ExtractorBatchLimitAbstract /** * Instantiate a DB extractor * - * @param mixed $extractQuery + * + * @param null|mixed $extractQuery * * @throws NodalFlowException */ @@ -47,9 +46,7 @@ public function __construct($extractQuery = null) /** * Trigger a batch extract * - * @param mixed $param - * - * @return bool + * @param null|mixed $param */ public function extract($param = null): bool { @@ -70,6 +67,7 @@ public function extract($param = null): bool /** * Set the Extract SQL query * + * * @param mixed $extractQuery * * @return static @@ -83,8 +81,6 @@ public function setExtractQuery($extractQuery): self /** * Build the LIMIT...OFFSET bit of the query - * - * @return string */ protected function getLimitOffsetBit(): string { diff --git a/src/Extractors/ExtractorAbstract.php b/src/Extractors/ExtractorAbstract.php index ba29273..76ff1ad 100644 --- a/src/Extractors/ExtractorAbstract.php +++ b/src/Extractors/ExtractorAbstract.php @@ -63,9 +63,7 @@ abstract class ExtractorAbstract extends NodeAbstract implements ExtractorInterf /** * get the traversable to traverse within the Flow * - * @param mixed $param - * - * @return iterable + * @param null|mixed $param */ public function getTraversable($param = null): iterable { @@ -81,8 +79,6 @@ public function getTraversable($param = null): iterable /** * Get number of records (at the end of the Flow's execution) - * - * @return int */ public function getNumRecords(): int { @@ -91,8 +87,6 @@ public function getNumRecords(): int /** * Get number of records (at the end of the Flow's execution) - * - * @return int */ public function getNumExtracts(): int { @@ -122,8 +116,6 @@ public function bootNumExtracts(): self * ` yield $record;` * rather than to: * ` return [$record];` - * - * @return iterable */ protected function getExtracted(): iterable { @@ -133,7 +125,6 @@ protected function getExtracted(): iterable /** * set current extraction result * - * @param iterable|null $extracted * * @return static */ diff --git a/src/Extractors/ExtractorBatchLimitAbstract.php b/src/Extractors/ExtractorBatchLimitAbstract.php index 0630fdf..6153238 100644 --- a/src/Extractors/ExtractorBatchLimitAbstract.php +++ b/src/Extractors/ExtractorBatchLimitAbstract.php @@ -53,7 +53,6 @@ public function enforceBatchSize(): ExtractorBatchLimitInterface /** * can be used to set a specific offset prior to start the scan * - * @param int $offset * * @return static */ @@ -66,8 +65,6 @@ public function setOffset(int $offset): ExtractorBatchLimitInterface /** * Get query offset - * - * @return int */ public function getOffset(): int { @@ -77,7 +74,6 @@ public function getOffset(): int /** * Set batch size * - * @param int $batchSize * * @return static */ @@ -90,8 +86,6 @@ public function setBatchSize(int $batchSize): ExtractorBatchLimitInterface /** * Get batch size - * - * @return int */ public function getBatchSize(): int { @@ -111,9 +105,6 @@ public function incrementOffset(): self return $this; } - /** - * @return ExtractorAbstract - */ public function bootNumExtracts(): ExtractorAbstract { // reset pagination each time we trigger diff --git a/src/Extractors/ExtractorBatchLimitInterface.php b/src/Extractors/ExtractorBatchLimitInterface.php index 8a60d23..2604a24 100644 --- a/src/Extractors/ExtractorBatchLimitInterface.php +++ b/src/Extractors/ExtractorBatchLimitInterface.php @@ -26,22 +26,17 @@ public function setOffset(int $offset): self; /** * Get current query offset - * - * @return int */ public function getOffset(): int; /** * Get current batch size - * - * @return int */ public function getBatchSize(): int; /** * Set batch size * - * @param int $batchSize * * @return static */ diff --git a/src/Extractors/ExtractorLimitAbstract.php b/src/Extractors/ExtractorLimitAbstract.php index aa44df7..b54102d 100644 --- a/src/Extractors/ExtractorLimitAbstract.php +++ b/src/Extractors/ExtractorLimitAbstract.php @@ -24,7 +24,6 @@ abstract class ExtractorLimitAbstract extends ExtractorAbstract implements Extra /** * Set extract limit * - * @param int|null $limit * * @return static */ @@ -37,10 +36,8 @@ public function setLimit(?int $limit): ExtractorLimitInterface /** * Get current limit - * - * @return int|null */ - public function getLimit(): ? int + public function getLimit(): ?int { return $this->limit; } diff --git a/src/Extractors/ExtractorLimitInterface.php b/src/Extractors/ExtractorLimitInterface.php index e74fc5c..f94fafe 100644 --- a/src/Extractors/ExtractorLimitInterface.php +++ b/src/Extractors/ExtractorLimitInterface.php @@ -17,7 +17,6 @@ interface ExtractorLimitInterface extends ExtractorInterface /** * Set extract limit * - * @param int|null $limit * * @return static */ @@ -25,8 +24,6 @@ public function setLimit(?int $limit): self; /** * Get current limit - * - * @return int */ public function getLimit(): ?int; diff --git a/src/Extractors/File/CsvExtractor.php b/src/Extractors/File/CsvExtractor.php index 13fb25f..9ab460f 100644 --- a/src/Extractors/File/CsvExtractor.php +++ b/src/Extractors/File/CsvExtractor.php @@ -24,9 +24,6 @@ class CsvExtractor extends FileExtractorAbstract * CsvExtractor constructor * * @param resource|string $input - * @param string $delimiter - * @param string $enclosure - * @param string $escape * * @throws NodalFlowException * @throws YaEtlException @@ -39,9 +36,6 @@ public function __construct($input, string $delimiter = ',', string $enclosure = $this->escape = $escape; } - /** - * @return iterable - */ protected function getExtracted(): iterable { if (!$this->readBom() || !$this->readSep() || false === ($firstRecord = $this->readHeader())) { @@ -56,19 +50,11 @@ protected function getExtracted(): iterable } } - /** - * @param array $record - * - * @return array - */ protected function bakeRecord(array $record): array { return isset($this->header) ? array_combine($this->header, $record) : $record; } - /** - * @return array|null - */ protected function readHeader(): ?array { if (null === ($firstRecord = $this->getNextNonEmptyRecord())) { @@ -84,9 +70,6 @@ protected function readHeader(): ?array return $firstRecord; } - /** - * @return bool - */ protected function readSep(): bool { if (null === ($firstChar = $this->getNextNonEmptyChars())) { @@ -113,10 +96,7 @@ protected function readSep(): bool return !fseek($this->handle, $firstCharPos - 1); } - /** - * @return array|null - */ - protected function getNextNonEmptyRecord(): ? array + protected function getNextNonEmptyRecord(): ?array { do { if (false === ($record = fgetcsv($this->handle, 0, $this->delimiter, $this->enclosure, $this->escape))) { diff --git a/src/Extractors/File/FileExtractorAbstract.php b/src/Extractors/File/FileExtractorAbstract.php index 449a051..cd16fdd 100644 --- a/src/Extractors/File/FileExtractorAbstract.php +++ b/src/Extractors/File/FileExtractorAbstract.php @@ -35,19 +35,11 @@ public function __construct($input) parent::__construct(); } - /** - * @param mixed $param - * - * @return bool - */ public function extract($param = null): bool { return !feof($this->handle); } - /** - * @return bool - */ protected function readBom(): bool { if (false === ($bomCandidate = fread($this->handle, 4))) { @@ -64,9 +56,6 @@ protected function readBom(): bool return rewind($this->handle); } - /** - * @return string|null - */ protected function getNextNonEmptyLine(): ?string { do { @@ -84,10 +73,7 @@ protected function getNextNonEmptyLine(): ?string return null; } - /** - * @return string|null - */ - protected function getNextNonEmptyChars(): ? string + protected function getNextNonEmptyChars(): ?string { do { if (false === ($char = fread($this->handle, 1))) { diff --git a/src/Extractors/File/LineExtractor.php b/src/Extractors/File/LineExtractor.php index 8ff0cf8..081ed9d 100644 --- a/src/Extractors/File/LineExtractor.php +++ b/src/Extractors/File/LineExtractor.php @@ -14,9 +14,6 @@ */ class LineExtractor extends FileExtractorAbstract { - /** - * @return iterable - */ protected function getExtracted(): iterable { if (!$this->readBom()) { diff --git a/src/Extractors/JoinableInterface.php b/src/Extractors/JoinableInterface.php index 7f5c8b4..870e163 100644 --- a/src/Extractors/JoinableInterface.php +++ b/src/Extractors/JoinableInterface.php @@ -16,7 +16,7 @@ * A joinable is an extractor that can be joined against * and / or can join against another joinable */ -interface JoinableInterface extends ExtractorInterface, ExecNodeInterface +interface JoinableInterface extends ExecNodeInterface, ExtractorInterface { /** * Generate record map, used to allow joiner to join @@ -35,7 +35,6 @@ public function getRecordMap(?string $fromKeyAlias = null); /** * Set the extractor to get record map from * - * @param JoinableInterface $joinFrom * * @return static */ @@ -44,7 +43,6 @@ public function setJoinFrom(self $joinFrom): self; /** * Set Joiner's ON clause. Only used in Join mode * - * @param OnClauseInterface $onClause * * @return static */ @@ -52,8 +50,6 @@ public function setOnClause(OnClauseInterface $onClause): self; /** * Get Joiner's ON clause. Only used in Join mode - * - * @return OnClauseInterface|null */ public function getOnClause(): ?OnClauseInterface; @@ -64,7 +60,8 @@ public function getOnClause(): ?OnClauseInterface; * action is to skip record in join mode and return the record with default * join values in left join mode * - * @param mixed $record + * + * @param null|mixed $record * * @return mixed the result of the join */ @@ -74,7 +71,6 @@ public function exec($record = null); * Register ON clause field mapping. Used by an eventual joiner to this * to build relevant recordMap * - * @param OnClauseInterface $onClause * * @return static */ diff --git a/src/Extractors/NullExtractor.php b/src/Extractors/NullExtractor.php index 0fd8bd9..e77f967 100644 --- a/src/Extractors/NullExtractor.php +++ b/src/Extractors/NullExtractor.php @@ -9,6 +9,8 @@ namespace fab2s\YaEtl\Extractors; +use Generator; + /** * Class NullExtractor */ @@ -24,9 +26,7 @@ class NullExtractor extends ExtractorBatchLimitAbstract /** * Triggers an extract * - * @param mixed $param - * - * @return bool + * @param null|mixed $param */ public function extract($param = null): bool { @@ -40,7 +40,7 @@ public function extract($param = null): bool /** * Return the dumbest Generator ever * - * @return \Generator + * @return Generator */ public function getExtracted(): iterable { diff --git a/src/Extractors/OnClause.php b/src/Extractors/OnClause.php index 5a7d715..1dd914c 100644 --- a/src/Extractors/OnClause.php +++ b/src/Extractors/OnClause.php @@ -48,8 +48,6 @@ class OnClause implements OnClauseInterface * The default record to return in left join mode * will be set to true in order to break the branch exec * in join mode or this value in left join mode - * - * @var mixed */ protected $defaultRecord; @@ -58,7 +56,6 @@ class OnClause implements OnClauseInterface * * @param string $fromKeyAlias The from unique key name in record * @param string $joinKeyAlias The join unique key name in record - * @param callable $merger * @param null|mixed $defaultRecord null for a regular join, * mixed a default record to be * used each time there is no match @@ -106,6 +103,7 @@ public function getJoinKeyAlias(): string /** * Merge Joined data into the original record * + * * @param mixed $upstreamRecord * @param mixed $record * @@ -119,8 +117,6 @@ public function merge($upstreamRecord, $record) /** * Indicate if we are left joining - * - * @return bool */ public function isLeftJoin(): bool { diff --git a/src/Extractors/OnClauseInterface.php b/src/Extractors/OnClauseInterface.php index fe62d14..70ee377 100644 --- a/src/Extractors/OnClauseInterface.php +++ b/src/Extractors/OnClauseInterface.php @@ -19,7 +19,6 @@ interface OnClauseInterface * * @param string $fromKeyAlias The from unique key name in record * @param string $joinKeyAlias The join unique key name in record - * @param callable $merger * @param null|mixed $defaultRecord null for a regular join, * mixed a default record to be * used each time there is no match @@ -44,6 +43,7 @@ public function getJoinKeyAlias(): string; /** * Merge Joined data into the original record * + * * @param mixed $upstreamRecord * @param mixed $record * @@ -53,8 +53,6 @@ public function merge($upstreamRecord, $record); /** * Indicate if we are left joining - * - * @return bool */ public function isLeftJoin(): bool; diff --git a/src/Extractors/PdoExtractor.php b/src/Extractors/PdoExtractor.php index 0285a94..01d34fd 100644 --- a/src/Extractors/PdoExtractor.php +++ b/src/Extractors/PdoExtractor.php @@ -11,6 +11,7 @@ use fab2s\NodalFlow\NodalFlowException; use fab2s\YaEtl\YaEtlException; +use PDO; /** * Class PdoExtractor @@ -22,13 +23,11 @@ class PdoExtractor extends DbExtractorAbstract /** * Instantiate PdoExtractor * - * @param \PDO $pdo - * @param string|null $extractQuery * * @throws NodalFlowException * @throws YaEtlException */ - public function __construct(\PDO $pdo, ?string $extractQuery = null) + public function __construct(PDO $pdo, ?string $extractQuery = null) { $this->configurePdo($pdo); @@ -43,7 +42,7 @@ public function __destruct() { if ($this->driverBufferedQuery) { // set driver state back to where we met - $this->pdo->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); + $this->pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); } } diff --git a/src/Extractors/PdoExtractorTrait.php b/src/Extractors/PdoExtractorTrait.php index cea8289..d1d778b 100644 --- a/src/Extractors/PdoExtractorTrait.php +++ b/src/Extractors/PdoExtractorTrait.php @@ -10,6 +10,8 @@ namespace fab2s\YaEtl\Extractors; use fab2s\YaEtl\YaEtlException; +use PDO; +use SplDoublyLinkedList; /** * trait PdoExtractorTrait @@ -19,7 +21,7 @@ trait PdoExtractorTrait /** * The PDO connection * - * @var \PDO + * @var PDO */ protected $pdo; @@ -62,23 +64,22 @@ public function __destruct() { if ($this->dbDriverName === 'mysql' && $this->driverBufferedQuery) { // set driver state back to where we met - $this->pdo->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); + $this->pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); } } /** * Properly set up PDO connection * - * @param \PDO $pdo * * @throws YaEtlException * * @return static */ - public function configurePdo(\PDO $pdo): self + public function configurePdo(PDO $pdo): self { $this->pdo = $pdo; - $this->dbDriverName = $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME); + $this->dbDriverName = $this->pdo->getAttribute(PDO::ATTR_DRIVER_NAME); if (!($this instanceof PaginatedQueryInterface) && !isset($this->supportedDrivers[$this->dbDriverName])) { throw new YaEtlException(\get_class($this) . ' does not implement PaginatedQueryInterface and does not uses a supported Pdo driver, supported drivers are: ' . \implode(', ', \array_keys($this->supportedDrivers))); @@ -87,11 +88,11 @@ public function configurePdo(\PDO $pdo): self if ($this->dbDriverName === 'mysql') { // buffered queries can have great performance impact // with large data sets - $this->driverBufferedQuery = $this->pdo->getAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY); + $this->driverBufferedQuery = $this->pdo->getAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY); if ($this->driverBufferedQuery) { // disable buffered queries as we should be querying by a lot - $this->pdo->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); + $this->pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); } } @@ -100,8 +101,6 @@ public function configurePdo(\PDO $pdo): self /** * Fetch records - * - * @return bool */ public function fetchRecords(): bool { @@ -114,8 +113,8 @@ public function fetchRecords(): bool // It is most likely better to proxy all records // as it also makes sure that we read from db as // fast as possible and release pressure asap - $collection = new \SplDoublyLinkedList; - while ($record = $statement->fetch(\PDO::FETCH_ASSOC)) { + $collection = new SplDoublyLinkedList; + while ($record = $statement->fetch(PDO::FETCH_ASSOC)) { $collection->push($record); } diff --git a/src/Extractors/PdoUniqueKeyExtractor.php b/src/Extractors/PdoUniqueKeyExtractor.php index b73a1fc..f741da4 100644 --- a/src/Extractors/PdoUniqueKeyExtractor.php +++ b/src/Extractors/PdoUniqueKeyExtractor.php @@ -11,6 +11,7 @@ use fab2s\NodalFlow\NodalFlowException; use fab2s\YaEtl\YaEtlException; +use PDO; /** * class PdoUniqueKeyExtractor @@ -22,11 +23,9 @@ class PdoUniqueKeyExtractor extends UniqueKeyExtractorAbstract /** * Generic extraction from tables with unique (composite) key * - * @param \PDO $pdo - * @param string|null $extractQuery - * @param array|string $uniqueKey can be either a unique key name as - * string - * `'(table.)compositeKeyName' // ('id' by default)` + * @param array|string $uniqueKey can be either a unique key name as + * string + * `'(table.)compositeKeyName' // ('id' by default)` * * or an array : * `['(table.)compositeKey1'] // single unique key` @@ -47,7 +46,7 @@ class PdoUniqueKeyExtractor extends UniqueKeyExtractorAbstract * @throws YaEtlException * @throws NodalFlowException */ - public function __construct(\PDO $pdo, ?string $extractQuery = null, $uniqueKey = 'id') + public function __construct(PDO $pdo, ?string $extractQuery = null, $uniqueKey = 'id') { $this->configurePdo($pdo); @@ -62,7 +61,7 @@ public function __destruct() { if ($this->driverBufferedQuery) { // set driver state back to where we met - $this->pdo->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); + $this->pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); } } @@ -86,9 +85,6 @@ public function getPaginatedQuery(): string return $this->extractQuery . $this->getLimitOffsetBit(); } - /** - * @return bool - */ protected function fetchJoinedRecords(): bool { $extractQuery = $this->getPaginatedQuery(); @@ -99,7 +95,7 @@ protected function fetchJoinedRecords(): bool $this->joinedRecords = []; $joinKey = $this->onClose->getJoinKeyAlias(); - while ($record = $statement->fetch(\PDO::FETCH_ASSOC)) { + while ($record = $statement->fetch(PDO::FETCH_ASSOC)) { $this->joinedRecords[$record[$joinKey]] = $record; } diff --git a/src/Extractors/UniqueKeyExtractorAbstract.php b/src/Extractors/UniqueKeyExtractorAbstract.php index fc0d577..01ec721 100644 --- a/src/Extractors/UniqueKeyExtractorAbstract.php +++ b/src/Extractors/UniqueKeyExtractorAbstract.php @@ -90,7 +90,6 @@ abstract class UniqueKeyExtractorAbstract extends DbExtractorAbstract implements /** * Generic extraction from tables with unique (composite) key * - * @param string|null $extractQuery * @param array|string $uniqueKeySetup can be either a unique key name as * string * `'(table.)compositeKeyName' // ('id' by default)` @@ -126,8 +125,6 @@ public function __construct(?string $extractQuery = null, $uniqueKeySetup = 'id' /** * Get this Joiner's ON clause. Only used in Join mode - * - * @return OnClauseInterface|null */ public function getOnClause(): ?OnClauseInterface { @@ -137,7 +134,6 @@ public function getOnClause(): ?OnClauseInterface /** * Set Joiner's ON clause. Only used in Join mode * - * @param OnClauseInterface $onClause * * @return $this */ @@ -151,7 +147,6 @@ public function setOnClause(OnClauseInterface $onClause): JoinableInterface /** * Register ON clause field mapping. Used by an eventual joiner to this * - * @param OnClauseInterface $onClause * * @return $this */ @@ -165,7 +160,6 @@ public function registerJoinerOnClause(OnClauseInterface $onClause): JoinableInt /** * Register the extractor we would be joining against * - * @param JoinableInterface $joinFrom * * @throws YaEtlException * @@ -204,11 +198,10 @@ public function getRecordMap(?string $fromKeyAlias = null) /** * Trigger extract * - * @param mixed $param * - * @throws YaEtlException + * @param null|mixed $param * - * @return bool + * @throws YaEtlException */ public function extract($param = null): bool { @@ -246,7 +239,7 @@ public function enforceBatchSize(): ExtractorBatchLimitInterface // append uniqueKeyValues to uniqueKeyValueBuffer $this->uniqueKeyValueBuffer = \array_replace($this->uniqueKeyValueBuffer, $this->uniqueKeyValues); // only keep batchSize - $this->uniqueKeyValues = \array_slice($this->uniqueKeyValueBuffer, 0, $this->batchSize, true); + $this->uniqueKeyValues = \array_slice($this->uniqueKeyValueBuffer, 0, $this->batchSize, true); // drop consumed keys $this->uniqueKeyValueBuffer = \array_slice($this->uniqueKeyValueBuffer, $this->batchSize, null, true); @@ -261,7 +254,9 @@ public function enforceBatchSize(): ExtractorBatchLimitInterface /** * Execute the Join * - * @param mixed $record + * + * + * @param null|mixed $record * * @throws YaEtlException * @@ -298,8 +293,6 @@ public function exec($record = null) * Trigger an extract in join mode * * @throws YaEtlException - * - * @return bool */ protected function joinExtract(): bool { @@ -350,10 +343,10 @@ protected function joinExtract(): bool */ protected function configureUniqueKey($uniqueKeySetup): self { - $uniqueKeySetup = \is_array($uniqueKeySetup) ? $uniqueKeySetup : [$uniqueKeySetup]; - $this->compositeKey = []; - $this->uniqueKeyName = null; - $this->uniqueKeyAlias = null; + $uniqueKeySetup = \is_array($uniqueKeySetup) ? $uniqueKeySetup : [$uniqueKeySetup]; + $this->compositeKey = []; + $this->uniqueKeyName = null; + $this->uniqueKeyAlias = null; foreach ($uniqueKeySetup as $key => $value) { if (\is_numeric($key)) { $compositeKeyName = $this->cleanUpKeyName($value); @@ -379,8 +372,6 @@ protected function configureUniqueKey($uniqueKeySetup): self * Clean up key names * * @param string $keyName - * - * @return string */ protected function cleanUpKeyName($keyName): string { @@ -451,8 +442,6 @@ protected function genRecordMap(): self * available in map generation for eventual joiners to * this joiner and also fill up joinedRecords as an * associative array indexed by the proper join key - * - * @return bool */ abstract protected function fetchJoinedRecords(): bool; } diff --git a/src/Laravel/Callbacks/ProgressCallback.php b/src/Laravel/Callbacks/ProgressCallback.php index ece7e2e..c25c46c 100644 --- a/src/Laravel/Callbacks/ProgressCallback.php +++ b/src/Laravel/Callbacks/ProgressCallback.php @@ -52,7 +52,6 @@ class ProgressCallback extends CallbackAbstract /** * Set progress modulo * - * @param int $progressMod * * @return static */ @@ -66,7 +65,6 @@ public function setProgressMod(int $progressMod): self /** * Set the total number of records prior to FLow execution * - * @param int $numRecords * * @return static */ @@ -80,7 +78,6 @@ public function setNumRecords(int $numRecords): self /** * Set Laravel's Command * - * @param Command $command * * @return static */ @@ -95,8 +92,6 @@ public function setCommand(Command $command): self /** * Triggered when a Flow starts - * - * @param FlowInterface $flow */ public function start(FlowInterface $flow) { @@ -107,9 +102,6 @@ public function start(FlowInterface $flow) /** * Triggered when a Flow progresses, * eg exec once or generates once - * - * @param FlowInterface $flow - * @param NodeInterface $node */ public function progress(FlowInterface $flow, NodeInterface $node) { @@ -118,8 +110,6 @@ public function progress(FlowInterface $flow, NodeInterface $node) /** * Triggered when a Flow succeeds - * - * @param FlowInterface $flow */ public function success(FlowInterface $flow) { @@ -135,8 +125,6 @@ public function success(FlowInterface $flow) /** * Triggered when a Flow fails - * - * @param FlowInterface $flow */ public function fail(FlowInterface $flow) { diff --git a/src/Laravel/Extractors/DbExtractor.php b/src/Laravel/Extractors/DbExtractor.php index a55422c..0d3eb4d 100644 --- a/src/Laravel/Extractors/DbExtractor.php +++ b/src/Laravel/Extractors/DbExtractor.php @@ -40,7 +40,6 @@ class DbExtractor extends PdoExtractor implements PaginatedQueryInterface /** * Instantiate the DbExtractor * - * @param Builder|null $extractQuery * * @throws NodalFlowException * @throws YaEtlException diff --git a/src/Laravel/Extractors/ModelQueryExtractor.php b/src/Laravel/Extractors/ModelQueryExtractor.php index 9bd1478..3c17832 100644 --- a/src/Laravel/Extractors/ModelQueryExtractor.php +++ b/src/Laravel/Extractors/ModelQueryExtractor.php @@ -22,7 +22,6 @@ class ModelQueryExtractor extends DbExtractor /** * Instantiate the ModelQueryExtractor * - * @param Builder|null $extractQuery * * @throws NodalFlowException * @throws YaEtlException diff --git a/src/Laravel/Loaders/DbLoader.php b/src/Laravel/Loaders/DbLoader.php index 80d4e6a..b915e81 100644 --- a/src/Laravel/Loaders/DbLoader.php +++ b/src/Laravel/Loaders/DbLoader.php @@ -36,7 +36,6 @@ class DbLoader extends LoaderAbstract /** * Instantiate the DbLoader * - * @param Builder|null $loadQuery * * @throws NodalFlowException */ @@ -52,7 +51,6 @@ public function __construct(?Builder $loadQuery = null) /** * Set the Load query * - * @param Builder $loadQuery * * @return static */ @@ -66,7 +64,6 @@ public function setLoadQuery(Builder $loadQuery): self /** * Set proper WHERE fields * - * @param array $whereFields * * @return static */ diff --git a/src/Loaders/ArrayLoader.php b/src/Loaders/ArrayLoader.php index 52117c7..2e6b52c 100644 --- a/src/Loaders/ArrayLoader.php +++ b/src/Loaders/ArrayLoader.php @@ -18,9 +18,6 @@ public function exec($param = null) $this->loadedData[] = $param; } - /** - * @return array - */ public function getLoadedData(): array { return $this->loadedData; diff --git a/src/Loaders/File/CsvLoader.php b/src/Loaders/File/CsvLoader.php index 9f4caf3..30de3d7 100644 --- a/src/Loaders/File/CsvLoader.php +++ b/src/Loaders/File/CsvLoader.php @@ -29,9 +29,6 @@ class CsvLoader extends FileLoaderAbstract * CsvLoader constructor. * * @param resource|string $destination - * @param string $delimiter - * @param string $enclosure - * @param string $escape * * @throws NodalFlowException * @throws YaEtlException @@ -68,8 +65,6 @@ public function writeSep(): self } /** - * @param array $param - * * @return static */ public function writeHeader(array $param): self @@ -86,8 +81,6 @@ public function writeHeader(array $param): self } /** - * @param array $record - * * @return bool|int */ public function writeCsvLine(array $record) diff --git a/src/Loaders/File/FileLoaderAbstract.php b/src/Loaders/File/FileLoaderAbstract.php index 63d6a8e..a6d989d 100644 --- a/src/Loaders/File/FileLoaderAbstract.php +++ b/src/Loaders/File/FileLoaderAbstract.php @@ -13,6 +13,7 @@ use fab2s\YaEtl\Loaders\LoaderAbstract; use fab2s\YaEtl\Traits\FileHandlerTrait; use fab2s\YaEtl\YaEtlException; +use ReflectionClass; /** * Class FileLoaderAbstract @@ -58,20 +59,20 @@ protected function checkHandle($input): self if (is_resource($input)) { $metaData = stream_get_meta_data($input); if (!is_writable($metaData['uri'])) { - throw new YaEtlException((new \ReflectionClass($this))->getShortName() . ' : destination cannot be opened in write mode'); + throw new YaEtlException((new ReflectionClass($this))->getShortName() . ' : destination cannot be opened in write mode'); } return $this; } if ( - !is_string($input) || - ( - !is_file($input) && - !touch($input) + !is_string($input) + || ( + !is_file($input) + && !touch($input) ) ) { - throw new YaEtlException((new \ReflectionClass($this))->getShortName() . ' : destination cannot be created'); + throw new YaEtlException((new ReflectionClass($this))->getShortName() . ' : destination cannot be created'); } return $this; diff --git a/src/Loaders/NoOpLoader.php b/src/Loaders/NoOpLoader.php index e5971ca..34ce738 100644 --- a/src/Loaders/NoOpLoader.php +++ b/src/Loaders/NoOpLoader.php @@ -17,7 +17,8 @@ class NoOpLoader extends LoaderAbstract /** * Execute the dumbest loader * - * @param mixed $record + * + * @param null|mixed $record * * @return bool */ diff --git a/src/Qualifiers/CallableQualifier.php b/src/Qualifiers/CallableQualifier.php index f8e64e9..67b1237 100644 --- a/src/Qualifiers/CallableQualifier.php +++ b/src/Qualifiers/CallableQualifier.php @@ -25,7 +25,6 @@ class CallableQualifier extends QualifierAbstract /** * Instantiate a CallableQualifier Node * - * @param callable $qualifier * * @throws NodalFlowException */ @@ -39,6 +38,7 @@ public function __construct(callable $qualifier) * Qualifies a record to either keep it, skip it or break the flow at the execution point * or at any upstream Node * + * * @param mixed $param * * @return InterrupterInterface|bool|null `true` to accept the record, eg let the Flow proceed untouched diff --git a/src/Qualifiers/LimitQualifier.php b/src/Qualifiers/LimitQualifier.php index 1358f70..85bbf99 100644 --- a/src/Qualifiers/LimitQualifier.php +++ b/src/Qualifiers/LimitQualifier.php @@ -40,11 +40,6 @@ public function __construct(?int $limit = null, string $target = InterrupterInte ->setTarget($target); } - /** - * @param int|null $limit - * - * @return LimitQualifier - */ public function setLimit(?int $limit): LimitQualifier { $this->limit = $limit; @@ -52,19 +47,11 @@ public function setLimit(?int $limit): LimitQualifier return $this; } - /** - * @return string - */ public function getTarget(): string { return $this->target; } - /** - * @param string $target - * - * @return LimitQualifier - */ public function setTarget(string $target): LimitQualifier { $this->target = $target === InterrupterInterface::TARGET_TOP ? InterrupterInterface::TARGET_TOP : InterrupterInterface::TARGET_SELF; diff --git a/src/Qualifiers/QualifierAbstract.php b/src/Qualifiers/QualifierAbstract.php index 27b8fde..a661475 100644 --- a/src/Qualifiers/QualifierAbstract.php +++ b/src/Qualifiers/QualifierAbstract.php @@ -52,7 +52,9 @@ abstract class QualifierAbstract extends NodeAbstract implements QualifierInterf * - return false|null|void to skip the record * - return InterrupterInterface to leverage complete interruption features * - * @param mixed $param + * + * + * @param null|mixed $param * * @throws YaEtlException * @@ -71,7 +73,7 @@ public function exec($param = null) return; } - if ($qualifies instanceof InterrupterInterface) { + if ($qualifies instanceof InterrupterInterface) { $this->carrier->interruptFlow($qualifies->getType(), $qualifies); return; diff --git a/src/Qualifiers/QualifierInterface.php b/src/Qualifiers/QualifierInterface.php index 16a4137..5c0c6f9 100644 --- a/src/Qualifiers/QualifierInterface.php +++ b/src/Qualifiers/QualifierInterface.php @@ -21,6 +21,7 @@ interface QualifierInterface extends ExecNodeInterface * Qualifies a record to either keep it, skip it or break the flow at the execution point * or at any upstream Node * + * * @param mixed $param * * @return InterrupterInterface|bool|null|void `true` to accept the record, eg let the Flow proceed untouched diff --git a/src/Traits/CsvHandlerTrait.php b/src/Traits/CsvHandlerTrait.php index 41b0f60..bb21085 100644 --- a/src/Traits/CsvHandlerTrait.php +++ b/src/Traits/CsvHandlerTrait.php @@ -46,29 +46,22 @@ trait CsvHandlerTrait */ protected $useSep = false; - /** - * @return array|null - */ public function getHeader(): ?array { return $this->header; } /** - * @param array $header - * * @return static */ public function setHeader(array $header): self { $this->header = $header; - return $this; + return $this; } /** - * @param bool $useHeader - * * @return static */ public function setUseHeader(bool $useHeader): self @@ -79,8 +72,6 @@ public function setUseHeader(bool $useHeader): self } /** - * @param bool $useSep - * * @return static */ public function setUseSep(bool $useSep): self diff --git a/src/Traits/FileHandlerTrait.php b/src/Traits/FileHandlerTrait.php index 3bd270a..ec083f3 100644 --- a/src/Traits/FileHandlerTrait.php +++ b/src/Traits/FileHandlerTrait.php @@ -40,17 +40,12 @@ public function __destruct() $this->releaseHandle(); } - /** - * @return string|null - */ public function getEncoding(): ?string { return $this->encoding; } /** - * @param string $encoding - * * @return static */ public function setEncoding(string $encoding): self @@ -61,8 +56,6 @@ public function setEncoding(string $encoding): self } /** - * @param bool $useBom - * * @return static */ public function setUseBom(bool $useBom): self @@ -72,11 +65,6 @@ public function setUseBom(bool $useBom): self return $this; } - /** - * @param string $string - * - * @return string - */ public function prependBom(string $string): string { if ($this->encoding && ($bom = Bom::getEncodingBom($this->encoding))) { @@ -104,7 +92,6 @@ public function releaseHandle(): self /** * @param resource|string $input - * @param string $mode * * @throws YaEtlException * diff --git a/src/Transformers/Arrays/ArrayKeyTransformer.php b/src/Transformers/Arrays/ArrayKeyTransformer.php index 8e68b75..1271475 100644 --- a/src/Transformers/Arrays/ArrayKeyTransformer.php +++ b/src/Transformers/Arrays/ArrayKeyTransformer.php @@ -22,8 +22,6 @@ class ArrayKeyTransformer extends TransformerAbstract protected $mapper; /** - * @param callable $mapper - * * @throws NodalFlowException */ public function __construct(callable $mapper) diff --git a/src/Transformers/Arrays/ArrayMapRecursiveTransformer.php b/src/Transformers/Arrays/ArrayMapRecursiveTransformer.php index 97e9722..c81f4ba 100644 --- a/src/Transformers/Arrays/ArrayMapRecursiveTransformer.php +++ b/src/Transformers/Arrays/ArrayMapRecursiveTransformer.php @@ -25,8 +25,6 @@ class ArrayMapRecursiveTransformer extends TransformerAbstract protected $mapper; /** - * @param callable $mapper - * * @throws NodalFlowException */ public function __construct(callable $mapper) diff --git a/src/Transformers/Arrays/ArrayMapTransformer.php b/src/Transformers/Arrays/ArrayMapTransformer.php index 05b5099..0a4f0b9 100644 --- a/src/Transformers/Arrays/ArrayMapTransformer.php +++ b/src/Transformers/Arrays/ArrayMapTransformer.php @@ -25,8 +25,6 @@ class ArrayMapTransformer extends TransformerAbstract protected $mapper; /** - * @param callable $mapper - * * @throws NodalFlowException */ public function __construct(callable $mapper) diff --git a/src/Transformers/Arrays/ArrayWalkRecursiveTransformer.php b/src/Transformers/Arrays/ArrayWalkRecursiveTransformer.php index d15f5f5..996373f 100644 --- a/src/Transformers/Arrays/ArrayWalkRecursiveTransformer.php +++ b/src/Transformers/Arrays/ArrayWalkRecursiveTransformer.php @@ -23,10 +23,6 @@ class ArrayWalkRecursiveTransformer extends TransformerAbstract * @var callable */ protected $callable; - - /** - * @var mixed - */ protected $userData; /** diff --git a/src/Transformers/Arrays/ArrayWalkTransformer.php b/src/Transformers/Arrays/ArrayWalkTransformer.php index 98bb602..eefd607 100644 --- a/src/Transformers/Arrays/ArrayWalkTransformer.php +++ b/src/Transformers/Arrays/ArrayWalkTransformer.php @@ -23,10 +23,6 @@ class ArrayWalkTransformer extends TransformerAbstract * @var callable */ protected $callable; - - /** - * @var mixed - */ protected $userData; /** diff --git a/src/Transformers/Arrays/CharsetTransformerTrait.php b/src/Transformers/Arrays/CharsetTransformerTrait.php index 36bc7d3..eaf2ff5 100644 --- a/src/Transformers/Arrays/CharsetTransformerTrait.php +++ b/src/Transformers/Arrays/CharsetTransformerTrait.php @@ -9,11 +9,12 @@ namespace fab2s\YaEtl\Transformers\Arrays; +use Closure; use fab2s\Strings\Strings; trait CharsetTransformerTrait { - public function getConvertClosure(?string $from = null, string $to = Strings::ENCODING): \Closure + public function getConvertClosure(?string $from = null, string $to = Strings::ENCODING): Closure { return function ($value) use ($from, $to) { return is_string($value) ? Strings::convert($value, $from, $to) : $value; diff --git a/src/Transformers/Arrays/DateFormatTransformer.php b/src/Transformers/Arrays/DateFormatTransformer.php index 9ece371..0d3021e 100644 --- a/src/Transformers/Arrays/DateFormatTransformer.php +++ b/src/Transformers/Arrays/DateFormatTransformer.php @@ -42,12 +42,9 @@ class DateFormatTransformer extends TransformerAbstract * or: * 'key_name' => ['from' => 'date_format', 'to' => 'date_format'] // to defaults to from * - * @param DateTimeZone|null $dateTimeZoneFrom - * @param DateTimeZone|null $dateTimeZoneTo - * * @throws NodalFlowException */ - public function __construct(array $setup, DateTimeZone $dateTimeZoneFrom = null, DateTimeZone $dateTimeZoneTo = null) + public function __construct(array $setup, ?DateTimeZone $dateTimeZoneFrom = null, ?DateTimeZone $dateTimeZoneTo = null) { parent::__construct(); diff --git a/src/Transformers/Arrays/KeyRenameTransformer.php b/src/Transformers/Arrays/KeyRenameTransformer.php index 13211de..217c607 100644 --- a/src/Transformers/Arrays/KeyRenameTransformer.php +++ b/src/Transformers/Arrays/KeyRenameTransformer.php @@ -25,8 +25,6 @@ class KeyRenameTransformer extends TransformerAbstract protected $aliases; /** - * @param array $aliases - * * @throws NodalFlowException */ public function __construct(array $aliases) diff --git a/src/Transformers/CallableTransformer.php b/src/Transformers/CallableTransformer.php index c519697..3aaf162 100644 --- a/src/Transformers/CallableTransformer.php +++ b/src/Transformers/CallableTransformer.php @@ -27,7 +27,6 @@ class CallableTransformer extends PayloadNodeAbstract implements TransformerInte /** * Instantiate the transformer * - * @param callable $payload * * @throws NodalFlowException */ @@ -40,8 +39,6 @@ public function __construct(callable $payload) * Execute the callable payload * * @param mixed $param the record - * - * @return mixed */ public function exec($param = null) { diff --git a/src/Transformers/NoOpTransformer.php b/src/Transformers/NoOpTransformer.php index f0c8e80..0089a9e 100644 --- a/src/Transformers/NoOpTransformer.php +++ b/src/Transformers/NoOpTransformer.php @@ -17,9 +17,7 @@ class NoOpTransformer extends TransformerAbstract /** * Execute the dumbest transformer ever * - * @param mixed $record - * - * @return mixed + * @param null|mixed $record */ public function exec($record = null) { diff --git a/src/YaEtl.php b/src/YaEtl.php index b972ef5..dfb5f39 100644 --- a/src/YaEtl.php +++ b/src/YaEtl.php @@ -27,6 +27,7 @@ use fab2s\YaEtl\Loaders\LoaderInterface; use fab2s\YaEtl\Qualifiers\QualifierInterface; use fab2s\YaEtl\Transformers\TransformerInterface; +use ReflectionException; /** * Class YaEtl @@ -68,7 +69,6 @@ class YaEtl extends NodalFlow /** * Adds an extractor to the Flow which may be aggregated with another one * - * @param ExtractorInterface $extractor * @param null|ExtractorInterface $aggregateWith Use the extractor instance you want to aggregate with * * @throws YaEtlException @@ -76,7 +76,7 @@ class YaEtl extends NodalFlow * * @return static */ - public function from(ExtractorInterface $extractor, ExtractorInterface $aggregateWith = null): self + public function from(ExtractorInterface $extractor, ?ExtractorInterface $aggregateWith = null): self { if ($aggregateWith !== null) { $this->aggregateTo($extractor, $aggregateWith); @@ -89,8 +89,6 @@ public function from(ExtractorInterface $extractor, ExtractorInterface $aggregat } /** - * @param QualifierInterface $qualifier - * * @throws NodalFlowException * * @return static @@ -106,11 +104,8 @@ public function qualify(QualifierInterface $qualifier): self /** * Override NodalFlow's add method to prohibit its direct usage * - * @param NodeInterface $node * * @throws YaEtlException - * - * @return FlowInterface */ public function add(NodeInterface $node): FlowInterface { @@ -133,7 +128,6 @@ public function add(NodeInterface $node): FlowInterface * Also note that the branch will also be flushed at the end * of its top most parent flow. * - * @param bool $forceFlush * * @return static */ @@ -147,9 +141,6 @@ public function forceFlush(bool $forceFlush): self /** * Adds a Joiner to a specific Extractor in the FLow * - * @param JoinableInterface $extractor - * @param JoinableInterface $joinFrom - * @param OnClauseInterface $onClause * * @throws NodalFlowException * @@ -170,7 +161,6 @@ public function join(JoinableInterface $extractor, JoinableInterface $joinFrom, /** * Adds a Transformer to the Flow * - * @param TransformerInterface $transformer * * @throws NodalFlowException * @@ -187,7 +177,6 @@ public function transform(TransformerInterface $transformer): self /** * Adds a Loader to the Flow * - * @param LoaderInterface $loader * * @throws NodalFlowException * @@ -237,7 +226,7 @@ public function flowEnd(): NodalFlow /** * KISS method to expose basic stats * - * @return array + * @return array */ public function getStats(): array { @@ -261,6 +250,7 @@ public function getStats(): array if (is_numeric($value)) { $vars['{' . strtoupper($varName) . '}'] = \number_format($stats[$varName], is_int($value) ? 0 : 2, '.', ' '); + continue; } @@ -275,8 +265,6 @@ public function getStats(): array /** * Tells if the flow is set to force flush * Only used when branched (to tell the parent) - * - * @return bool */ public function isForceFlush(): bool { @@ -284,9 +272,7 @@ public function isForceFlush(): bool } /** - * @param string $class - * - * @throws \ReflectionException + * @throws ReflectionException * * @return static */ @@ -301,8 +287,6 @@ protected function initDispatchArgs(string $class): FlowEventAbstract /** * Used internally to aggregate Extractors * - * @param ExtractorInterface $extractor - * @param ExtractorInterface $aggregateWith * * @throws YaEtlException * @throws NodalFlowException @@ -345,11 +329,10 @@ protected function aggregateTo(ExtractorInterface $extractor, ExtractorInterface /** * Calls each WorkFlow's loaders and branch flush method * - * @param FlowStatusInterface|null $flowStatus * * @return static */ - protected function flush(FlowStatusInterface $flowStatus = null): self + protected function flush(?FlowStatusInterface $flowStatus = null): self { if ($flowStatus === null) { if ($this->hasParent() && !$this->isForceFlush()) { @@ -368,7 +351,6 @@ protected function flush(FlowStatusInterface $flowStatus = null): self /** * Actually flush nodes * - * @param FlowStatusInterface $flowStatus * * @return static */ @@ -379,6 +361,7 @@ protected function flushNodes(FlowStatusInterface $flowStatus): self $node->flush($flowStatus); $this->flowMap->incrementFlow('num_flush'); $this->triggerEvent(YaEtlEvent::FLOW_FLUSH, $node); + continue; } diff --git a/src/support/deprecated.php b/src/support/deprecated.php index 3b5a8ca..e8a5a2a 100644 --- a/src/support/deprecated.php +++ b/src/support/deprecated.php @@ -8,8 +8,8 @@ */ namespace { - class_alias(\fab2s\YaEtl\YaEtlException::class, \fab2s\NodalFlow\YaEtlException::class); - class_alias(\fab2s\YaEtl\Events\ProgressBarSubscriber::class, \fab2s\YaEtl\Laravel\Callbacks\ProgressBarSubscriber::class); + class_alias(fab2s\YaEtl\YaEtlException::class, fab2s\NodalFlow\YaEtlException::class); + class_alias(fab2s\YaEtl\Events\ProgressBarSubscriber::class, fab2s\YaEtl\Laravel\Callbacks\ProgressBarSubscriber::class); } namespace fab2s\NodalFlow { diff --git a/tests/Laravel/DbExtractorTest.php b/tests/Laravel/DbExtractorTest.php index cdc8faf..b45de2b 100644 --- a/tests/Laravel/DbExtractorTest.php +++ b/tests/Laravel/DbExtractorTest.php @@ -17,13 +17,13 @@ class DbExtractorTest extends LaravelTestCase { use ExtractionTestTrait; - public function testDbExtractorException() + public function test_db_extractor_exception() { $this->expectException(YaEtlException::class); (new DbExtractor)->setExtractQuery(null); } - public function testDbExtractorExceptionType() + public function test_db_extractor_exception_type() { $this->expectException(YaEtlException::class); (new DbExtractor)->setExtractQuery(TestModel::query()); diff --git a/tests/Laravel/DbLoaderTest.php b/tests/Laravel/DbLoaderTest.php index 1fe95dc..498edbf 100644 --- a/tests/Laravel/DbLoaderTest.php +++ b/tests/Laravel/DbLoaderTest.php @@ -17,7 +17,7 @@ class DbLoaderTest extends LaravelTestCase { - public function testDbLoader() + public function test_db_loader() { $this->createTestJoinModelTable(); $loadQuery = TestJoinModel::getQuery(); diff --git a/tests/Laravel/LaravelTestCase.php b/tests/Laravel/LaravelTestCase.php index ae1d412..067a7ac 100644 --- a/tests/Laravel/LaravelTestCase.php +++ b/tests/Laravel/LaravelTestCase.php @@ -15,10 +15,12 @@ abstract class LaravelTestCase extends TestCase { + public static $latestResponse = null; + /** * @var int */ - protected $seedNum = 15; + protected $seedNum = 15; /** * @var array @@ -140,8 +142,8 @@ protected function getExpectedTestModelData(): array return array_map( function (array $value) use (&$counter) { return [ - 'id' => ++$counter, - 'name' => $value['name'], + 'id' => ++$counter, + 'name' => $value['name'], ]; }, $this->getTestModelSeedData() diff --git a/tests/Laravel/ModelExtractorTest.php b/tests/Laravel/ModelExtractorTest.php index f4d6358..0841510 100644 --- a/tests/Laravel/ModelExtractorTest.php +++ b/tests/Laravel/ModelExtractorTest.php @@ -17,13 +17,13 @@ class ModelExtractorTest extends LaravelTestCase { use ExtractionTestTrait; - public function testModelExtractorException() + public function test_model_extractor_exception() { $this->expectException(YaEtlException::class); (new ModelQueryExtractor)->setExtractQuery(null); } - public function testModelExtractorExceptionType() + public function test_model_extractor_exception_type() { $this->expectException(YaEtlException::class); (new ModelQueryExtractor)->setExtractQuery(TestModel::getQuery()); diff --git a/tests/Laravel/UniqueKeyExtractorTest.php b/tests/Laravel/UniqueKeyExtractorTest.php index 80c16b4..21a12b3 100644 --- a/tests/Laravel/UniqueKeyExtractorTest.php +++ b/tests/Laravel/UniqueKeyExtractorTest.php @@ -20,13 +20,13 @@ class UniqueKeyExtractorTest extends LaravelTestCase { use ExtractionTestTrait; - public function testDbExtractorException() + public function test_db_extractor_exception() { $this->expectException(YaEtlException::class); (new UniqueKeyExtractor)->setExtractQuery(null); } - public function testDbExtractorExceptionType() + public function test_db_extractor_exception_type() { $this->expectException(YaEtlException::class); (new UniqueKeyExtractor)->setExtractQuery(TestModel::query()); @@ -35,16 +35,14 @@ public function testDbExtractorExceptionType() /** * @dataProvider trueFalseProvider * - * @param bool $every - * * @throws YaEtlException * @throws \fab2s\NodalFlow\NodalFlowException */ - public function testJoin(bool $every) + public function test_join(bool $every) { $this->createTestJoinModelTable() ->seedTestJoinModelTable($every); - $joinOnClause = new OnClause('id', 'model_id', function ($upstreamRecord, $record) { + $joinOnClause = new OnClause('id', 'model_id', function ($upstreamRecord, $record) { unset($record['id']); return array_replace($upstreamRecord, $record); @@ -66,17 +64,15 @@ public function testJoin(bool $every) /** * @dataProvider trueFalseProvider * - * @param bool $every - * * @throws YaEtlException * @throws \fab2s\NodalFlow\NodalFlowException */ - public function testLeftJoin(bool $every) + public function test_left_join(bool $every) { $this->createTestJoinModelTable() ->seedTestJoinModelTable($every); - $leftJoinOnClause = new OnClause('id', 'model_id', function ($upstreamRecord, $record) { + $leftJoinOnClause = new OnClause('id', 'model_id', function ($upstreamRecord, $record) { unset($record['id']); return array_replace($upstreamRecord, $record); @@ -122,6 +118,7 @@ protected function getExpectedJoinedData(bool $every = true, bool $isLeft = fals 'join' => null, ]); } + continue; } $joinedModel = $expectedJoinedData[$modelId]; diff --git a/tests/Lib/Arrays/ArrayKeyTransformerTest.php b/tests/Lib/Arrays/ArrayKeyTransformerTest.php index 510b483..cef0574 100644 --- a/tests/Lib/Arrays/ArrayKeyTransformerTest.php +++ b/tests/Lib/Arrays/ArrayKeyTransformerTest.php @@ -18,13 +18,9 @@ class ArrayKeyTransformerTest extends TestBase /** * @dataProvider arrayKeyProvider * - * @param callable $callable - * @param array $data - * @param array $expected - * * @throws NodalFlowException */ - public function testArrayKeyTransformer(callable $callable, array $data, array $expected) + public function test_array_key_transformer(callable $callable, array $data, array $expected) { $transformer = new ArrayKeyTransformer($callable); diff --git a/tests/Lib/Arrays/ArrayMapRecursiveTransformerTest.php b/tests/Lib/Arrays/ArrayMapRecursiveTransformerTest.php index a585d03..b550a09 100644 --- a/tests/Lib/Arrays/ArrayMapRecursiveTransformerTest.php +++ b/tests/Lib/Arrays/ArrayMapRecursiveTransformerTest.php @@ -18,13 +18,9 @@ class ArrayMapRecursiveTransformerTest extends TestBase /** * @dataProvider arrayMapRecursiveProvider * - * @param callable $callable - * @param array $data - * @param array $expected - * * @throws NodalFlowException */ - public function testArrayMapRecursiveTransformer(callable $callable, array $data, array $expected) + public function test_array_map_recursive_transformer(callable $callable, array $data, array $expected) { $transformer = new ArrayMapRecursiveTransformer($callable); diff --git a/tests/Lib/Arrays/ArrayMapTransformerTest.php b/tests/Lib/Arrays/ArrayMapTransformerTest.php index 3943da7..5575517 100644 --- a/tests/Lib/Arrays/ArrayMapTransformerTest.php +++ b/tests/Lib/Arrays/ArrayMapTransformerTest.php @@ -18,12 +18,9 @@ class ArrayMapTransformerTest extends TestBase /** * @dataProvider arrayMapProvider * - * @param callable $callable - * @param array $data - * * @throws NodalFlowException */ - public function testArrayMapTransformer(callable $callable, array $data) + public function test_array_map_transformer(callable $callable, array $data) { $transformer = new ArrayMapTransformer($callable); diff --git a/tests/Lib/Arrays/ArrayReplaceRecursiveTransformerTest.php b/tests/Lib/Arrays/ArrayReplaceRecursiveTransformerTest.php index cecf5a9..3ef4af1 100644 --- a/tests/Lib/Arrays/ArrayReplaceRecursiveTransformerTest.php +++ b/tests/Lib/Arrays/ArrayReplaceRecursiveTransformerTest.php @@ -18,52 +18,48 @@ class ArrayReplaceRecursiveTransformerTest extends TestBase public function arrayReplaceRecursiveProvider() { return [ - [ - 'default' => [ - 'one' => 'onedefault', - 42 => [1, 3, 3, 7], - ], - 'override' => [ - '?' => ['no', 'maybe'], - ], - 'cases' => [ - [ - 'input' => [ - '?' => 'yes', - 42 => [7, 3, 3, 1], - ], - 'expected' => [ - 'one' => 'onedefault', - 42 => [7, 3, 3, 1], - '?' => ['no', 'maybe'], - ], - ], - [ - 'input' => [ - '?' => ['a', 'b', 'never'], - 42 => null, - ], - 'expected' => [ - 'one' => 'onedefault', - 42 => null, - '?' => ['no', 'maybe', 'never'], - ], - ], - ], - ], + [ + 'default' => [ + 'one' => 'onedefault', + 42 => [1, 3, 3, 7], + ], + 'override' => [ + '?' => ['no', 'maybe'], + ], + 'cases' => [ + [ + 'input' => [ + '?' => 'yes', + 42 => [7, 3, 3, 1], + ], + 'expected' => [ + 'one' => 'onedefault', + 42 => [7, 3, 3, 1], + '?' => ['no', 'maybe'], + ], + ], + [ + 'input' => [ + '?' => ['a', 'b', 'never'], + 42 => null, + ], + 'expected' => [ + 'one' => 'onedefault', + 42 => null, + '?' => ['no', 'maybe', 'never'], + ], + ], + ], + ], ]; } /** * @dataProvider arrayReplaceRecursiveProvider * - * @param array $default - * @param array $override - * @param array $cases - * * @throws NodalFlowException */ - public function testArrayReplaceRecursiveTransformer(array $default, array $override, array $cases) + public function test_array_replace_recursive_transformer(array $default, array $override, array $cases) { $transformer = new ArrayReplaceRecursiveTransformer($default, $override); diff --git a/tests/Lib/Arrays/ArrayReplaceTransformerTest.php b/tests/Lib/Arrays/ArrayReplaceTransformerTest.php index 11c66d8..1a8ffbb 100644 --- a/tests/Lib/Arrays/ArrayReplaceTransformerTest.php +++ b/tests/Lib/Arrays/ArrayReplaceTransformerTest.php @@ -18,53 +18,49 @@ class ArrayReplaceTransformerTest extends TestBase public function arrayReplaceProvider() { return [ - [ - 'default' => [ - 'one' => 'onedefault', - 42 => 1337, - ], - 'override' => [ - '?' => 'no', - ], - 'cases' => [ - [ - 'input' => [ - '?' => 'yes', - 'oh' => 'my', - ], - 'expected' => [ - 'one' => 'onedefault', - 42 => 1337, - '?' => 'no', - 'oh' => 'my', - ], - ], - [ - 'input' => [ - '?' => ['a', 'b', 'c'], - 42 => null, - ], - 'expected' => [ - 'one' => 'onedefault', - 42 => null, - '?' => 'no', - ], - ], - ], - ], + [ + 'default' => [ + 'one' => 'onedefault', + 42 => 1337, + ], + 'override' => [ + '?' => 'no', + ], + 'cases' => [ + [ + 'input' => [ + '?' => 'yes', + 'oh' => 'my', + ], + 'expected' => [ + 'one' => 'onedefault', + 42 => 1337, + '?' => 'no', + 'oh' => 'my', + ], + ], + [ + 'input' => [ + '?' => ['a', 'b', 'c'], + 42 => null, + ], + 'expected' => [ + 'one' => 'onedefault', + 42 => null, + '?' => 'no', + ], + ], + ], + ], ]; } /** * @dataProvider arrayReplaceProvider * - * @param array $default - * @param array $override - * @param array $cases - * * @throws NodalFlowException */ - public function testArrayReplaceTransformer(array $default, array $override, array $cases) + public function test_array_replace_transformer(array $default, array $override, array $cases) { $transformer = new ArrayReplaceTransformer($default, $override); diff --git a/tests/Lib/Arrays/ArrayWalkRecursiveTransformerTest.php b/tests/Lib/Arrays/ArrayWalkRecursiveTransformerTest.php index ed8caf0..b119d7a 100644 --- a/tests/Lib/Arrays/ArrayWalkRecursiveTransformerTest.php +++ b/tests/Lib/Arrays/ArrayWalkRecursiveTransformerTest.php @@ -19,15 +19,13 @@ class ArrayWalkRecursiveTransformerTest extends TestBase /** * @dataProvider arrayWalkRecursiveProvider * - * @param callable $callable - * @param array $data - * @param $expected - * @param null $arg + * @param null $arg + * @param mixed $expected * * @throws NodalFlowException * @throws YaEtlException */ - public function testArrayWalkRecursiveTransformer(callable $callable, array $data, $expected, $arg = null) + public function test_array_walk_recursive_transformer(callable $callable, array $data, $expected, $arg = null) { $transformer = new ArrayWalkRecursiveTransformer($callable, $arg); diff --git a/tests/Lib/Arrays/ArrayWalkTransformerTest.php b/tests/Lib/Arrays/ArrayWalkTransformerTest.php index c4b964f..316b94e 100644 --- a/tests/Lib/Arrays/ArrayWalkTransformerTest.php +++ b/tests/Lib/Arrays/ArrayWalkTransformerTest.php @@ -19,15 +19,13 @@ class ArrayWalkTransformerTest extends TestBase /** * @dataProvider arrayWalkProvider * - * @param callable $callable - * @param array $data - * @param $expected - * @param null $arg + * @param null $arg + * @param mixed $expected * * @throws NodalFlowException * @throws YaEtlException */ - public function testArrayWalkTransformer(callable $callable, array $data, $expected, $arg = null) + public function test_array_walk_transformer(callable $callable, array $data, $expected, $arg = null) { $transformer = new ArrayWalkTransformer($callable, $arg); diff --git a/tests/Lib/Arrays/CharsetRecursiveTransformerTest.php b/tests/Lib/Arrays/CharsetRecursiveTransformerTest.php index 25035bc..930d718 100644 --- a/tests/Lib/Arrays/CharsetRecursiveTransformerTest.php +++ b/tests/Lib/Arrays/CharsetRecursiveTransformerTest.php @@ -19,14 +19,9 @@ class CharsetRecursiveTransformerTest extends TestBase /** * @dataProvider charsetRecursiveProvider * - * @param string $from - * @param string $to - * @param array $data - * @param array $expected - * * @throws NodalFlowException */ - public function testCharsetRecursiveTransformer(string $from, string $to, array $data, array $expected) + public function test_charset_recursive_transformer(string $from, string $to, array $data, array $expected) { $transformer = new CharsetRecursiveTransformer($from, $to); @@ -40,20 +35,20 @@ public function charsetRecursiveProvider(): array 'ISO-8859-1', 'UTF-8', [ - 'key1' => Strings::convert('iñtërnâtiônàlizætiøn', 'UTF-8', 'ISO-8859-1'), - 'key2' => 1, - 'key3' => [], - 'array' => [ - 'key1' => Strings::convert('iñtërnâtiônàlizætiøn', 'UTF-8', 'ISO-8859-1'), - 'key2' => 1, - 'key3' => [], + 'key1' => Strings::convert('iñtërnâtiônàlizætiøn', 'UTF-8', 'ISO-8859-1'), + 'key2' => 1, + 'key3' => [], + 'array' => [ + 'key1' => Strings::convert('iñtërnâtiônàlizætiøn', 'UTF-8', 'ISO-8859-1'), + 'key2' => 1, + 'key3' => [], ], ], [ - 'key1' => 'iñtërnâtiônàlizætiøn', - 'key2' => 1, - 'key3' => [], - 'array' => [ + 'key1' => 'iñtërnâtiônàlizætiøn', + 'key2' => 1, + 'key3' => [], + 'array' => [ 'key1' => 'iñtërnâtiônàlizætiøn', 'key2' => 1, 'key3' => [], diff --git a/tests/Lib/Arrays/CharsetTransformerTest.php b/tests/Lib/Arrays/CharsetTransformerTest.php index 1d66b35..c40918e 100644 --- a/tests/Lib/Arrays/CharsetTransformerTest.php +++ b/tests/Lib/Arrays/CharsetTransformerTest.php @@ -19,14 +19,9 @@ class CharsetTransformerTest extends TestBase /** * @dataProvider charsetProvider * - * @param string $from - * @param string $to - * @param array $data - * @param array $expected - * * @throws NodalFlowException */ - public function testCharsetTransformer(string $from, string $to, array $data, array $expected) + public function test_charset_transformer(string $from, string $to, array $data, array $expected) { $transformer = new CharsetTransformer($from, $to); diff --git a/tests/Lib/Arrays/DateFormatTransformerTest.php b/tests/Lib/Arrays/DateFormatTransformerTest.php index ba37429..1f70846 100644 --- a/tests/Lib/Arrays/DateFormatTransformerTest.php +++ b/tests/Lib/Arrays/DateFormatTransformerTest.php @@ -21,13 +21,9 @@ class DateFormatTransformerTest extends TestBase /** * @dataProvider dateFormatProvider * - * @param array $setup - * @param array $data - * @param array $expected - * * @throws NodalFlowException */ - public function testDateFormatTransformer(array $setup, array $data, array $expected) + public function test_date_format_transformer(array $setup, array $data, array $expected) { $transformer = new DateFormatTransformer($setup); diff --git a/tests/Lib/Arrays/KeyRenameTransformerTest.php b/tests/Lib/Arrays/KeyRenameTransformerTest.php index 83d2f73..0ee2bd5 100644 --- a/tests/Lib/Arrays/KeyRenameTransformerTest.php +++ b/tests/Lib/Arrays/KeyRenameTransformerTest.php @@ -18,13 +18,9 @@ class KeyRenameTransformerTest extends TestBase /** * @dataProvider keyRenameProvider * - * @param array $aliases - * @param array $data - * @param array $expected - * * @throws NodalFlowException */ - public function testKeyRenameTransformer(array $aliases, array $data, array $expected) + public function test_key_rename_transformer(array $aliases, array $data, array $expected) { $transformer = new KeyRenameTransformer($aliases); diff --git a/tests/Lib/Arrays/KeyUnsetTransformerTest.php b/tests/Lib/Arrays/KeyUnsetTransformerTest.php index a314dd1..bb0ee40 100644 --- a/tests/Lib/Arrays/KeyUnsetTransformerTest.php +++ b/tests/Lib/Arrays/KeyUnsetTransformerTest.php @@ -18,13 +18,9 @@ class KeyUnsetTransformerTest extends TestBase /** * @dataProvider keyUnsetProvider * - * @param array $unsetList - * @param array $data - * @param array $expected - * * @throws NodalFlowException */ - public function testKeyUnsetTransformer(array $unsetList, array $data, array $expected) + public function test_key_unset_transformer(array $unsetList, array $data, array $expected) { $transformer = new KeyUnsetTransformer($unsetList); diff --git a/tests/Lib/Arrays/SetValuesTransformerTest.php b/tests/Lib/Arrays/SetValuesTransformerTest.php index 8191adf..ed0025d 100644 --- a/tests/Lib/Arrays/SetValuesTransformerTest.php +++ b/tests/Lib/Arrays/SetValuesTransformerTest.php @@ -18,13 +18,9 @@ class SetValuesTransformerTest extends TestBase /** * @dataProvider setValuesProvider * - * @param array $setup - * @param array $data - * @param array $expected - * * @throws NodalFlowException */ - public function testSetValuesTransformer(array $setup, array $data, array $expected) + public function test_set_values_transformer(array $setup, array $data, array $expected) { $transformer = new SetValuesTransformer($setup); diff --git a/tests/Lib/CallableExtractorTest.php b/tests/Lib/CallableExtractorTest.php index e54281a..a9b5b5e 100644 --- a/tests/Lib/CallableExtractorTest.php +++ b/tests/Lib/CallableExtractorTest.php @@ -22,12 +22,11 @@ class CallableExtractorTest extends TestBase /** * @dataProvider callableExtractorProvider * - * @param callable $callable - * @param $expected + * @param mixed $expected * * @throws NodalFlowException */ - public function testCallableExtractor(callable $callable, $expected) + public function test_callable_extractor(callable $callable, $expected) { $arrayLoader = new ArrayLoader; (new YaEtl) diff --git a/tests/Lib/FileTest.php b/tests/Lib/FileTest.php index 4e15272..2d206b5 100644 --- a/tests/Lib/FileTest.php +++ b/tests/Lib/FileTest.php @@ -48,12 +48,11 @@ class FileTest extends TestBase * @dataProvider lineExtractorProvider * * @param string $srcPath - * @param array $expected * * @throws NodalFlowException * @throws YaEtlException */ - public function testLineExtractor($srcPath, array $expected) + public function test_line_extractor($srcPath, array $expected) { $lineExtractor = new LineExtractor($srcPath); (new YaEtl)->from($lineExtractor) @@ -72,12 +71,11 @@ public function testLineExtractor($srcPath, array $expected) * * @param string $srcPath * @param bool $useHeader - * @param array $expected * * @throws NodalFlowException * @throws YaEtlException */ - public function testCsvExtractor($srcPath, $useHeader, array $expected) + public function test_csv_extractor($srcPath, $useHeader, array $expected) { $this->csvExtractorAssertions(new CsvExtractor($srcPath), $useHeader, $expected); } @@ -87,12 +85,11 @@ public function testCsvExtractor($srcPath, $useHeader, array $expected) * * @param string $srcPath * @param bool $useHeader - * @param array $expected * * @throws NodalFlowException * @throws YaEtlException */ - public function testCsvLoader($srcPath, $useHeader, array $expected) + public function test_csv_loader($srcPath, $useHeader, array $expected) { if (empty($expected['values'])) { // nothing to load in that case @@ -119,7 +116,7 @@ public function testCsvLoader($srcPath, $useHeader, array $expected) ->exec(); // check if what we just wrote passes the read test - $this->testCsvExtractor($srcPath, $useHeader, $expected); + $this->test_csv_extractor($srcPath, $useHeader, $expected); } /** @@ -263,9 +260,7 @@ public function lineExtractorProvider() } /** - * @param CsvExtractor $csvExtractor - * @param $useHeader - * @param array $expected + * @param mixed $useHeader * * @throws NodalFlowException * @throws YaEtlException diff --git a/tests/Lib/FromTest.php b/tests/Lib/FromTest.php index 813efa9..dab574e 100644 --- a/tests/Lib/FromTest.php +++ b/tests/Lib/FromTest.php @@ -32,11 +32,9 @@ public function setUp(): void /** * @dataProvider fromCasesProvider * - * @param YaEtl $flow - * * @throws NodalFlowException */ - public function testFrom(YaEtl $flow) + public function test_from(YaEtl $flow) { $this->resetResultTable(); $this->assertSame($this->numRecords, $this->getTableCount(self::FROM_TABLE), 'From table not initialized'); @@ -63,12 +61,12 @@ public function fromCasesProvider() $FirstHalfFrom = clone $fullFrom; $FirstHalfFrom->setLimit(floor($this->numRecords / 2)) - ->setBatchSize(10); + ->setBatchSize(10); $SecondHalfFrom = clone $FirstHalfFrom; $SecondHalfFrom->setLimit(ceil($this->numRecords / 2)) - ->setOffset(floor($this->numRecords / 2)) - ->setBatchSize(20); + ->setOffset(floor($this->numRecords / 2)) + ->setBatchSize(20); $FirstTenFrom = clone $fullFrom; $FirstTenFrom->setLimit(10); diff --git a/tests/Lib/JoinTest.php b/tests/Lib/JoinTest.php index 84975ef..615b8bf 100644 --- a/tests/Lib/JoinTest.php +++ b/tests/Lib/JoinTest.php @@ -31,12 +31,9 @@ public function setUp(): void /** * @dataProvider joinCasesProvider * - * @param YaEtl $flow - * @param bool $isLeft - * * @throws NodalFlowException */ - public function testJoin(YaEtl $flow, bool $isLeft) + public function test_join(YaEtl $flow, bool $isLeft) { $this->resetResultTable(); $this->assertSame($this->numRecords, $this->getTableCount(self::FROM_TABLE), 'From table not initialized'); @@ -87,11 +84,11 @@ public function joinCasesProvider() $joiner2 = clone $joiner1; $joiner2->setBatchSize(1337); - $joinOnClause = new OnClause('id', 'id', function ($upstreamRecord, $record) { + $joinOnClause = new OnClause('id', 'id', function ($upstreamRecord, $record) { return array_replace($upstreamRecord, $record); }); - $leftJoinOnClause = new OnClause('id', 'id', function ($upstreamRecord, $record) { + $leftJoinOnClause = new OnClause('id', 'id', function ($upstreamRecord, $record) { return array_replace($upstreamRecord, $record); }, [ 'join_id' => null, @@ -102,38 +99,38 @@ public function joinCasesProvider() // test a join : success means that the to table ends up // exactly like join table, that is, every join_id are set // and mismatch are skipped - 'flow' => (new YaEtl) + 'flow' => (new YaEtl) ->from($fullFrom1) ->join(new PdoUniqueKeyExtractor($this->getPdo(), $joinQuery, 'id'), $fullFrom1, $joinOnClause) ->to($this->getLoaderMock()), - 'isLeft' => false, + 'isLeft' => false, ], [ // test a left join : success means that the to table ends up // exactly like LEFT_JOIN_RESULT_TABLE where one record out of // two holds a null join_id - 'flow' => (new YaEtl) + 'flow' => (new YaEtl) ->from($fullFrom2) ->join(new PdoUniqueKeyExtractor($this->getPdo(), $joinQuery, 'id'), $fullFrom2, $leftJoinOnClause) ->to($this->getLoaderMock()), - 'isLeft' => true, + 'isLeft' => true, ], [ // test left joined join = join - 'flow' => (new YaEtl) + 'flow' => (new YaEtl) ->from($fullFrom3) ->join($joiner1, $fullFrom3, $joinOnClause) ->join(new PdoUniqueKeyExtractor($this->getPdo(), $joinQuery, 'id'), $joiner1, $leftJoinOnClause) ->to($this->getLoaderMock()), - 'isLeft' => false, + 'isLeft' => false, ], [ // same as left join test with unbalanced batchSizes - 'flow' => (new YaEtl) + 'flow' => (new YaEtl) ->from($fullFrom4) ->join($joiner2, $fullFrom4, $leftJoinOnClause) ->to($this->getLoaderMock()), - 'isLeft' => true, + 'isLeft' => true, ], ]; } diff --git a/tests/Lib/LimitQualifierTest.php b/tests/Lib/LimitQualifierTest.php index 5fbc74e..f7400b2 100644 --- a/tests/Lib/LimitQualifierTest.php +++ b/tests/Lib/LimitQualifierTest.php @@ -28,7 +28,7 @@ class LimitQualifierTest extends TestBase * @throws NodalFlowException * @throws YaEtlException */ - public function testLimitQualifier(array $expected, string $target) + public function test_limit_qualifier(array $expected, string $target) { $arrayLoader = new ArrayLoader; $yaEtl = new YaEtl; @@ -45,7 +45,7 @@ public function limitQualifierProvider(): array $expected = range(1, 5); return [ - InterrupterInterface::TARGET_TOP => [ + InterrupterInterface::TARGET_TOP => [ $expected, InterrupterInterface::TARGET_TOP, ], @@ -62,7 +62,7 @@ public function limitQualifierProvider(): array * @throws NodalFlowException * @throws YaEtlException */ - public function testBranchLimitQualifier(array $expected, array $expectedBranch, string $target) + public function test_branch_limit_qualifier(array $expected, array $expectedBranch, string $target) { $arrayLoader = new ArrayLoader; $branchArrayLoader = new ArrayLoader; @@ -86,7 +86,7 @@ public function branchLimitQualifierProvider(): array $expected = range(1, 10); return [ - InterrupterInterface::TARGET_TOP => [ + InterrupterInterface::TARGET_TOP => [ $expectedBranch, $expectedBranch, InterrupterInterface::TARGET_TOP, diff --git a/tests/Lib/NullExtractorTest.php b/tests/Lib/NullExtractorTest.php index ea5b232..2d3189f 100644 --- a/tests/Lib/NullExtractorTest.php +++ b/tests/Lib/NullExtractorTest.php @@ -18,11 +18,11 @@ */ class NullExtractorTest extends TestBase { - public function testNullExtractor() + public function test_null_extractor() { $arrayLoader = new ArrayLoader; $yaEtl = new YaEtl; - $nullExtractor = (new NullExtractor())->setLimit(10); + $nullExtractor = (new NullExtractor)->setLimit(10); $yaEtl->from(clone $nullExtractor) ->to($arrayLoader) ->exec(); diff --git a/tests/Lib/OnCloseTest.php b/tests/Lib/OnCloseTest.php index 4ede6e7..4edbf6b 100644 --- a/tests/Lib/OnCloseTest.php +++ b/tests/Lib/OnCloseTest.php @@ -17,7 +17,7 @@ */ class OnCloseTest extends TestBase { - public function testNewException() + public function test_new_exception() { $this->expectException(YaEtlException::class); new OnClause('', 'key', 'trim'); diff --git a/tests/Lib/ProgressTest.php b/tests/Lib/ProgressTest.php index 223e1d8..93e67fe 100644 --- a/tests/Lib/ProgressTest.php +++ b/tests/Lib/ProgressTest.php @@ -27,15 +27,10 @@ class ProgressTest extends TestBase /** * @dataProvider progressProvider * - * @param YaEtl $flow - * @param int|null $numRecords - * @param int $progressMod - * @param array $expected - * * @throws NodalFlowException * @throws ReflectionException */ - public function testProgress(YaEtl $flow, ?int $numRecords, int $progressMod, array $expected) + public function test_progress(YaEtl $flow, ?int $numRecords, int $progressMod, array $expected) { $flow->setProgressMod($progressMod); $progressSubscriber = new ProgressBarSubscriber($flow); @@ -55,14 +50,12 @@ public function testProgress(YaEtl $flow, ?int $numRecords, int $progressMod, ar /** * @throws NodalFlowException - * - * @return array */ public function progressProvider(): array { return [ [ - 'flow' => (new YaEtl)->from(new CallableExtractor($this->getTraversableClosure(10))) + 'flow' => (new YaEtl)->from(new CallableExtractor($this->getTraversableClosure(10))) ->qualify(new LimitQualifier(5)) ->transform(new NoOpTransformer), 'num_records' => 15, @@ -77,7 +70,7 @@ public function progressProvider(): array ], ], [ - 'flow' => (new YaEtl)->from(new CallableExtractor($this->getTraversableClosure(100))) + 'flow' => (new YaEtl)->from(new CallableExtractor($this->getTraversableClosure(100))) ->transform(new NoOpTransformer), 'num_records' => 100, 'progress_mod' => 10, @@ -91,7 +84,7 @@ public function progressProvider(): array ], ], [ - 'flow' => (new YaEtl)->from(new CallableExtractor($this->getTraversableClosure(100))) + 'flow' => (new YaEtl)->from(new CallableExtractor($this->getTraversableClosure(100))) ->transform(new NoOpTransformer), 'num_records' => null, 'progress_mod' => 10, @@ -105,7 +98,7 @@ public function progressProvider(): array ], ], [ - 'flow' => (new YaEtl)->from(new CallableExtractor($this->getTraversableClosure(100))) + 'flow' => (new YaEtl)->from(new CallableExtractor($this->getTraversableClosure(100))) ->transform(new NoOpTransformer), 'num_records' => 1337, 'progress_mod' => 1024, @@ -119,7 +112,7 @@ public function progressProvider(): array ], ], [ - 'flow' => (new YaEtl)->from(new CallableExtractor($this->getTraversableClosure(10))) + 'flow' => (new YaEtl)->from(new CallableExtractor($this->getTraversableClosure(10))) ->transform(new NoOpTransformer), 'num_records' => 15, 'progress_mod' => 10, @@ -154,9 +147,6 @@ protected function getStreamContent($stream, bool $normalize = false): string return $display; } - /** - * @return Closure - */ protected function getNoOpClosure(): Closure { return function ($record) { diff --git a/tests/Lib/QualifierTest.php b/tests/Lib/QualifierTest.php index f9a6ac2..463b7b7 100644 --- a/tests/Lib/QualifierTest.php +++ b/tests/Lib/QualifierTest.php @@ -25,7 +25,7 @@ */ class QualifierTest extends TestBase { - public function testQualifierException() + public function test_qualifier_exception() { $this->expectException(YaEtlException::class); (new CallableQualifier(function () { @@ -35,11 +35,8 @@ public function testQualifierException() /** * @dataProvider interruptProvider - * - * @param FlowInterface $flow - * @param array $expected */ - public function testInterrupt(FlowInterface $flow, array $expected) + public function test_interrupt(FlowInterface $flow, array $expected) { $flow->exec(); $this->interruptAssertions($flow->getNodeMap(), $expected); @@ -47,8 +44,6 @@ public function testInterrupt(FlowInterface $flow, array $expected) /** * @throws NodalFlowException - * - * @return array */ public function interruptProvider(): array { @@ -59,12 +54,12 @@ public function interruptProvider(): array $testCases = []; $testCases['flow1'] = [ - 'flow' => (new YaEtl)->from($extractor1) + 'flow' => (new YaEtl)->from($extractor1) ->transform($noOpTransformer1) ->qualify($breakAt5Node1) ->transform($noOpTransformer2), 'expected' => [ - $extractor1->getId() => [ + $extractor1->getId() => [ 'num_exec' => 1, 'num_iterate' => 5, 'num_break' => 1, @@ -76,7 +71,7 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $breakAt5Node1->getId() => [ + $breakAt5Node1->getId() => [ 'num_exec' => 5, 'num_iterate' => 0, 'num_break' => 1, @@ -96,12 +91,12 @@ public function interruptProvider(): array $noOpTransformer1 = new NoOpTransformer; $noOpTransformer2 = new NoOpTransformer; $testCases['flow2'] = [ - 'flow' => (new YaEtl)->from($extractor1) + 'flow' => (new YaEtl)->from($extractor1) ->transform($noOpTransformer1) ->qualify($continueAt5Node1) ->transform($noOpTransformer2), 'expected' => [ - $extractor1->getId() => [ + $extractor1->getId() => [ 'num_exec' => 1, 'num_iterate' => 10, 'num_break' => 0, @@ -141,7 +136,7 @@ public function interruptProvider(): array $noOpTransformer4 = new NoOpTransformer; $testCases['flow3'] = [ - 'flow' => (new YaEtl)->transform($noOpTransformer3) + 'flow' => (new YaEtl)->transform($noOpTransformer3) ->branch($branch1) ->transform($noOpTransformer4), 'expected' => [ @@ -151,13 +146,13 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $branch1->getId() => [ + $branch1->getId() => [ 'num_exec' => 1, 'num_iterate' => 0, 'num_break' => 0, 'num_continue' => 0, 'nodes' => [ - $extractor1->getId() => [ + $extractor1->getId() => [ 'num_exec' => 1, 'num_iterate' => 5, 'num_break' => 1, @@ -169,7 +164,7 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $breakAt5Node1->getId() => [ + $breakAt5Node1->getId() => [ 'num_exec' => 5, 'num_iterate' => 0, 'num_break' => 1, @@ -196,7 +191,7 @@ public function interruptProvider(): array $continueAt5Node1 = new CallableQualifier($this->getContinueAt5Closure()); $noOpTransformer1 = new NoOpTransformer; $noOpTransformer2 = new NoOpTransformer; - $branch1 = (new YaEtl())->from($extractor1) + $branch1 = (new YaEtl)->from($extractor1) ->transform($noOpTransformer1) ->qualify($continueAt5Node1) ->transform($noOpTransformer2); @@ -205,7 +200,7 @@ public function interruptProvider(): array $noOpTransformer4 = new NoOpTransformer; $testCases['flow4'] = [ - 'flow' => (new YaEtl)->transform($noOpTransformer3) + 'flow' => (new YaEtl)->transform($noOpTransformer3) ->branch($branch1) ->transform($noOpTransformer4), 'expected' => [ @@ -215,13 +210,13 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $branch1->getId() => [ + $branch1->getId() => [ 'num_exec' => 1, 'num_iterate' => 0, 'num_break' => 0, 'num_continue' => 0, 'nodes' => [ - $extractor1->getId() => [ + $extractor1->getId() => [ 'num_exec' => 1, 'num_iterate' => 10, 'num_break' => 0, @@ -273,7 +268,7 @@ public function interruptProvider(): array $noOpTransformer5 = new NoOpTransformer; $testCases['flow5'] = [ - 'flow' => (new YaEtl)->transform($noOpTransformer4) + 'flow' => (new YaEtl)->transform($noOpTransformer4) ->branch($branch1) ->transform($noOpTransformer5), 'expected' => [ @@ -283,13 +278,13 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $branch1->getId() => [ + $branch1->getId() => [ 'num_exec' => 1, 'num_iterate' => 0, 'num_break' => 0, 'num_continue' => 0, 'nodes' => [ - $extractor1->getId() => [ + $extractor1->getId() => [ 'num_exec' => 1, 'num_iterate' => 10, 'num_break' => 0, @@ -301,7 +296,7 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $extractor2->getId() => [ + $extractor2->getId() => [ 'num_exec' => 10, 'num_iterate' => 95, 'num_break' => 1, @@ -313,7 +308,7 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $breakAt5Node1->getId() => [ + $breakAt5Node1->getId() => [ 'num_exec' => 95, 'num_iterate' => 0, 'num_break' => 1, @@ -353,7 +348,7 @@ public function interruptProvider(): array $noOpTransformer5 = new NoOpTransformer; $testCases['flow6'] = [ - 'flow' => (new YaEtl)->transform($noOpTransformer4) + 'flow' => (new YaEtl)->transform($noOpTransformer4) ->branch($branch1) ->transform($noOpTransformer5), 'expected' => [ @@ -363,13 +358,13 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $branch1->getId() => [ + $branch1->getId() => [ 'num_exec' => 1, 'num_iterate' => 0, 'num_break' => 0, 'num_continue' => 0, 'nodes' => [ - $extractor1->getId() => [ + $extractor1->getId() => [ 'num_exec' => 1, 'num_iterate' => 10, 'num_break' => 0, @@ -381,7 +376,7 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $extractor2->getId() => [ + $extractor2->getId() => [ 'num_exec' => 10, 'num_iterate' => 100, 'num_break' => 0, @@ -433,7 +428,7 @@ public function interruptProvider(): array $noOpTransformer5 = new NoOpTransformer; $testCases['flow7'] = [ - 'flow' => (new YaEtl)->transform($noOpTransformer4) + 'flow' => (new YaEtl)->transform($noOpTransformer4) ->branch($branch1) ->transform($noOpTransformer5), 'expected' => [ @@ -443,13 +438,13 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $branch1->getId() => [ + $branch1->getId() => [ 'num_exec' => 1, 'num_iterate' => 0, 'num_break' => 0, 'num_continue' => 0, 'nodes' => [ - $extractor1->getId() => [ + $extractor1->getId() => [ 'num_exec' => 1, 'num_iterate' => 1, 'num_break' => 1, @@ -461,7 +456,7 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $extractor2->getId() => [ + $extractor2->getId() => [ 'num_exec' => 1, 'num_iterate' => 5, 'num_break' => 1, @@ -473,7 +468,7 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $breakAt5Node1->getId() => [ + $breakAt5Node1->getId() => [ 'num_exec' => 5, 'num_iterate' => 0, 'num_break' => 1, @@ -513,7 +508,7 @@ public function interruptProvider(): array $noOpTransformer5 = new NoOpTransformer; $testCases['flow8'] = [ - 'flow' => (new YaEtl)->transform($noOpTransformer4) + 'flow' => (new YaEtl)->transform($noOpTransformer4) ->branch($branch1) ->transform($noOpTransformer5), 'expected' => [ @@ -523,13 +518,13 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $branch1->getId() => [ + $branch1->getId() => [ 'num_exec' => 1, 'num_iterate' => 0, 'num_break' => 0, 'num_continue' => 0, 'nodes' => [ - $extractor1->getId() => [ + $extractor1->getId() => [ 'num_exec' => 1, 'num_iterate' => 10, 'num_break' => 0, @@ -541,7 +536,7 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $extractor2->getId() => [ + $extractor2->getId() => [ 'num_exec' => 10, 'num_iterate' => 95, 'num_break' => 1, @@ -606,13 +601,13 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $branch1->getId() => [ + $branch1->getId() => [ 'num_exec' => 1, 'num_iterate' => 0, 'num_break' => 1, 'num_continue' => 0, 'nodes' => [ - $extractor1->getId() => [ + $extractor1->getId() => [ 'num_exec' => 1, 'num_iterate' => 1, 'num_break' => 1, @@ -624,7 +619,7 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $extractor2->getId() => [ + $extractor2->getId() => [ 'num_exec' => 1, 'num_iterate' => 5, 'num_break' => 1, @@ -636,7 +631,7 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $breakAt5Node1->getId() => [ + $breakAt5Node1->getId() => [ 'num_exec' => 5, 'num_iterate' => 0, 'num_break' => 1, @@ -689,13 +684,13 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $branch1->getId() => [ + $branch1->getId() => [ 'num_exec' => 1, 'num_iterate' => 0, 'num_break' => 0, 'num_continue' => 1, 'nodes' => [ - $extractor1->getId() => [ + $extractor1->getId() => [ 'num_exec' => 1, 'num_iterate' => 1, 'num_break' => 1, @@ -707,7 +702,7 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $extractor2->getId() => [ + $extractor2->getId() => [ 'num_exec' => 1, 'num_iterate' => 5, 'num_break' => 1, @@ -772,7 +767,7 @@ public function interruptProvider(): array $testCases['flow11'] = [ 'flow' => $rootFlow, 'expected' => [ - $extractor3->getId() => [ + $extractor3->getId() => [ 'num_exec' => 1, 'num_iterate' => 10, 'num_break' => 0, @@ -784,8 +779,8 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $extractor4->getId() => [ - 'num_exec' => 10, + $extractor4->getId() => [ + 'num_exec' => 10, // the break signal is sent at rec n°5 // it is detected on the 1st records of // this traversable which breaks there @@ -801,13 +796,13 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $branch1->getId() => [ + $branch1->getId() => [ 'num_exec' => 91, 'num_iterate' => 0, 'num_break' => 1, 'num_continue' => 0, 'nodes' => [ - $extractor1->getId() => [ + $extractor1->getId() => [ 'num_exec' => 91, 'num_iterate' => 901, 'num_break' => 1, @@ -819,7 +814,7 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $extractor2->getId() => [ + $extractor2->getId() => [ 'num_exec' => 901, 'num_iterate' => 9005, 'num_break' => 1, @@ -831,7 +826,7 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $breakAt5Node1->getId() => [ + $breakAt5Node1->getId() => [ 'num_exec' => 9005, 'num_iterate' => 0, 'num_break' => 1, @@ -884,7 +879,7 @@ public function interruptProvider(): array $testCases['flow12'] = [ 'flow' => $rootFlow, 'expected' => [ - $extractor3->getId() => [ + $extractor3->getId() => [ 'num_exec' => 1, 'num_iterate' => 10, 'num_break' => 0, @@ -896,8 +891,8 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $extractor4->getId() => [ - 'num_exec' => 10, + $extractor4->getId() => [ + 'num_exec' => 10, // the break signal is sent at rec n°5 // it is detected on the 1st records of // this traversable which breaks there @@ -913,13 +908,13 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $branch1->getId() => [ + $branch1->getId() => [ 'num_exec' => 100, 'num_iterate' => 0, 'num_break' => 0, 'num_continue' => 1, 'nodes' => [ - $extractor1->getId() => [ + $extractor1->getId() => [ 'num_exec' => 100, 'num_iterate' => 991, 'num_break' => 1, @@ -931,7 +926,7 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $extractor2->getId() => [ + $extractor2->getId() => [ 'num_exec' => 991, 'num_iterate' => 9905, 'num_break' => 1, @@ -996,7 +991,7 @@ public function interruptProvider(): array $testCases['flow13'] = [ 'flow' => $rootFlow, 'expected' => [ - $extractor3->getId() => [ + $extractor3->getId() => [ 'num_exec' => 1, 'num_iterate' => 1, 'num_break' => 1, @@ -1008,7 +1003,7 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $extractor4->getId() => [ + $extractor4->getId() => [ 'num_exec' => 1, 'num_iterate' => 1, 'num_break' => 1, @@ -1020,13 +1015,13 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $branch1->getId() => [ + $branch1->getId() => [ 'num_exec' => 1, 'num_iterate' => 0, 'num_break' => 1, 'num_continue' => 0, 'nodes' => [ - $extractor1->getId() => [ + $extractor1->getId() => [ 'num_exec' => 1, 'num_iterate' => 1, 'num_break' => 1, @@ -1038,7 +1033,7 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $extractor2->getId() => [ + $extractor2->getId() => [ 'num_exec' => 1, 'num_iterate' => 5, 'num_break' => 1, @@ -1050,7 +1045,7 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $breakAt5Node1->getId() => [ + $breakAt5Node1->getId() => [ 'num_exec' => 5, 'num_iterate' => 0, 'num_break' => 1, @@ -1103,7 +1098,7 @@ public function interruptProvider(): array $testCases['flow14'] = [ 'flow' => $rootFlow, 'expected' => [ - $extractor3->getId() => [ + $extractor3->getId() => [ 'num_exec' => 1, 'num_iterate' => 10, 'num_break' => 0, @@ -1115,7 +1110,7 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $extractor4->getId() => [ + $extractor4->getId() => [ 'num_exec' => 10, 'num_iterate' => 91, 'num_break' => 1, @@ -1127,13 +1122,13 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $branch1->getId() => [ + $branch1->getId() => [ 'num_exec' => 91, 'num_iterate' => 0, 'num_break' => 0, 'num_continue' => 1, 'nodes' => [ - $extractor1->getId() => [ + $extractor1->getId() => [ 'num_exec' => 91, 'num_iterate' => 901, 'num_break' => 1, @@ -1145,7 +1140,7 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $extractor2->getId() => [ + $extractor2->getId() => [ 'num_exec' => 901, 'num_iterate' => 9005, 'num_break' => 1, @@ -1210,7 +1205,7 @@ public function interruptProvider(): array $testCases['flow15'] = [ 'flow' => $rootFlow, 'expected' => [ - $extractor3->getId() => [ + $extractor3->getId() => [ 'num_exec' => 1, 'num_iterate' => 10, 'num_break' => 0, @@ -1222,7 +1217,7 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $extractor4->getId() => [ + $extractor4->getId() => [ 'num_exec' => 10, 'num_iterate' => 91, 'num_break' => 1, @@ -1234,13 +1229,13 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $branch1->getId() => [ + $branch1->getId() => [ 'num_exec' => 91, 'num_iterate' => 0, 'num_break' => 1, 'num_continue' => 0, 'nodes' => [ - $extractor1->getId() => [ + $extractor1->getId() => [ 'num_exec' => 91, 'num_iterate' => 901, 'num_break' => 1, @@ -1252,7 +1247,7 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $extractor2->getId() => [ + $extractor2->getId() => [ 'num_exec' => 901, 'num_iterate' => 9005, 'num_break' => 1, @@ -1264,7 +1259,7 @@ public function interruptProvider(): array 'num_break' => 0, 'num_continue' => 0, ], - $breakAt5Node1->getId() => [ + $breakAt5Node1->getId() => [ 'num_exec' => 9005, 'num_iterate' => 0, 'num_break' => 1, @@ -1290,9 +1285,6 @@ public function interruptProvider(): array return $testCases; } - /** - * @return Closure - */ protected function getNoOpClosure(): Closure { return function ($record) { @@ -1300,9 +1292,6 @@ protected function getNoOpClosure(): Closure }; } - /** - * @return Closure - */ protected function getTraversable10Closure(): Closure { return $this->getTraversableClosure(10); @@ -1310,8 +1299,6 @@ protected function getTraversable10Closure(): Closure /** * @param bool|InterrupterInterface $return - * - * @return Closure */ protected function getBreakAt5Closure($return = null): Closure { @@ -1335,8 +1322,6 @@ protected function getBreakAt5Closure($return = null): Closure /** * @param bool|InterrupterInterface $return - * - * @return Closure */ protected function getContinueAt5Closure($return = null): Closure { @@ -1358,10 +1343,6 @@ protected function getContinueAt5Closure($return = null): Closure }; } - /** - * @param array $nodeMap - * @param array $expected - */ protected function interruptAssertions(array $nodeMap, array $expected) { foreach ($nodeMap as $nodeId => $data) { diff --git a/tests/Lib/TestBase.php b/tests/Lib/TestBase.php index 9cc5e50..981b8a5 100644 --- a/tests/Lib/TestBase.php +++ b/tests/Lib/TestBase.php @@ -11,16 +11,16 @@ use Closure; use fab2s\NodalFlow\Nodes\ExecNodeInterface; -use fab2s\NodalFlow\Nodes\NodeInterface; use fab2s\YaEtl\Loaders\LoaderInterface; use fab2s\YaEtl\Loaders\NoOpLoader; +use PDO; // we need these two for phpunit to mock NoOpLoader /** * Interface TestLoaderInterface */ -interface TestLoaderInterface extends NodeInterface, ExecNodeInterface, LoaderInterface +interface TestLoaderInterface extends ExecNodeInterface, LoaderInterface { } @@ -53,17 +53,17 @@ abstract class TestBase extends \PHPUnit\Framework\TestCase protected $expectedJoinRecords = []; /** - * @var \PDO + * @var PDO */ protected static $pdo; /** - * @return \PDO + * @return PDO */ public function getPdo() { if (static::$pdo === null) { - static::$pdo = new \PDO('sqlite::memory:'); + static::$pdo = new PDO('sqlite::memory:'); static::$pdo->query( 'CREATE TABLE ' . self::FROM_TABLE . '( @@ -103,8 +103,8 @@ public function getPdo() public function getLoaderMock() { $stub = $this->getMockBuilder(TestLoader::class) - ->setMethods(['exec']) - ->getMock(); + ->setMethods(['exec']) + ->getMock(); $stub->expects($spy = $this->any()) ->method('exec') @@ -123,8 +123,6 @@ function (array $param) { } /** - * @param string $table - * * @return static */ protected function populateTable(string $table): self @@ -170,32 +168,16 @@ protected function resetResultTable() return $this; } - /** - * @param string $table - * - * @return int - */ protected function getTableCount(string $table): int { return (int) $this->getPdo()->query("SELECT COUNT(*) FROM $table")->fetchColumn(); } - /** - * @param string $table - * - * @return array - */ protected function getTableAll(string $table): array { - return $this->getPdo()->query("SELECT * FROM $table ORDER BY id ASC")->fetchAll(\PDO::FETCH_ASSOC); + return $this->getPdo()->query("SELECT * FROM $table ORDER BY id ASC")->fetchAll(PDO::FETCH_ASSOC); } - /** - * @param int $count - * @param int $start - * - * @return Closure - */ protected function getTraversableClosure(int $count, int $start = 1): Closure { $start = max(1, $start); diff --git a/tests/Lib/YaEtlTest.php b/tests/Lib/YaEtlTest.php index f9d7f69..9ae849d 100644 --- a/tests/Lib/YaEtlTest.php +++ b/tests/Lib/YaEtlTest.php @@ -23,13 +23,13 @@ */ class YaEtlTest extends TestBase { - public function testAddException() + public function test_add_exception() { $this->expectException(YaEtlException::class); (new YaEtl)->add(new NoOpTransformer); } - public function testQualifyContinue() + public function test_qualify_continue() { $arrayLoader = new ArrayLoader; (new YaEtl) @@ -43,7 +43,7 @@ public function testQualifyContinue() $this->assertSame(range(1, 5), $arrayLoader->getLoadedData()); } - public function testQualifyBreakInterrupter() + public function test_qualify_break_interrupter() { $arrayLoader = new ArrayLoader; (new YaEtl)->from(new CallableExtractor($this->getTraversableClosure(10))) @@ -60,7 +60,7 @@ public function testQualifyBreakInterrupter() $this->assertSame(range(1, 5), $arrayLoader->getLoadedData()); } - public function testQualifyBreakFlow() + public function test_qualify_break_flow() { $arrayLoader = new ArrayLoader; $yaEtl = new YaEtl; @@ -68,6 +68,7 @@ public function testQualifyBreakFlow() ->qualify(new CallableQualifier(function ($value) use ($yaEtl) { if ($value > 5) { $yaEtl->breakFlow(); + // return value is of no consequences here return true; } @@ -80,7 +81,7 @@ public function testQualifyBreakFlow() $this->assertSame(range(1, 5), $arrayLoader->getLoadedData()); } - public function testQualifyBranch() + public function test_qualify_branch() { $branchLoader = new ArrayLoader; $arrayLoader = new ArrayLoader; @@ -99,7 +100,7 @@ public function testQualifyBranch() $this->assertSame(range(1, 10), $arrayLoader->getLoadedData()); } - public function testAggregateToException() + public function test_aggregate_to_exception() { $this->expectException(YaEtlException::class); $firstExtractor = new CallableExtractor($this->getTraversableClosure(5)); @@ -108,7 +109,7 @@ public function testAggregateToException() (new YaEtl)->from($firstExtractor, $secondExtractor); } - public function testAggregateToSingle() + public function test_aggregate_to_single() { $arrayLoader = new ArrayLoader; $firstExtractor = new CallableExtractor($this->getTraversableClosure(5)); @@ -122,7 +123,7 @@ public function testAggregateToSingle() $this->assertSame(range(1, 10), $arrayLoader->getLoadedData()); } - public function testAggregateToMultiple() + public function test_aggregate_to_multiple() { $arrayLoader = new ArrayLoader; $firstExtractor = new CallableExtractor($this->getTraversableClosure(5));