Skip to content

Commit

Permalink
More compensation for poor PHP 8.1 backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewdalpino committed Apr 3, 2022
1 parent 918d6db commit c8a2840
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
- 2.0.1
- Compensate for PHP 8.1 backward compatibility issues

- 2.0.0
- Gradient Boost now uses gradient-based subsampling
- Allow Token Hashing Vectorizer custom hash functions
Expand Down
4 changes: 2 additions & 2 deletions src/Extractors/CSV.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Rubix\ML\Exceptions\InvalidArgumentException;
use Rubix\ML\Exceptions\RuntimeException;
use Generator;
use Traversable;

use function Rubix\ML\iterator_first;
use function is_dir;
Expand Down Expand Up @@ -168,7 +168,7 @@ public function export(iterable $iterator) : void
* @throws \Rubix\ML\Exceptions\RuntimeException
* @return \Generator<mixed[]>
*/
public function getIterator() : Generator
public function getIterator() : Traversable
{
if (!is_file($this->path)) {
throw new RuntimeException("Path {$this->path} is not a file.");
Expand Down
4 changes: 2 additions & 2 deletions src/Extractors/ColumnPicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Rubix\ML\Extractors;

use Rubix\ML\Exceptions\RuntimeException;
use Generator;
use Traversable;

/**
* Column Picker
Expand Down Expand Up @@ -48,7 +48,7 @@ public function __construct(iterable $iterator, array $columns)
*
* @return \Generator<mixed[]>
*/
public function getIterator() : Generator
public function getIterator() : Traversable
{
foreach ($this->iterator as $i => $record) {
$picked = [];
Expand Down
4 changes: 2 additions & 2 deletions src/Extractors/Concatenator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Rubix\ML\Extractors;

use Generator;
use Traversable;

use function array_values;

Expand Down Expand Up @@ -37,7 +37,7 @@ public function __construct(array $iterators)
*
* @return \Generator<mixed[]>
*/
public function getIterator() : Generator
public function getIterator() : Traversable
{
foreach ($this->iterators as $iterator) {
foreach ($iterator as $record) {
Expand Down
4 changes: 2 additions & 2 deletions src/Extractors/Deduplicator.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Rubix\ML\Extractors;

use OkBloomer\BloomFilter;
use Generator;
use Traversable;

use function serialize;

Expand Down Expand Up @@ -71,7 +71,7 @@ public function dropped() : int
*
* @return \Generator<mixed[]>
*/
public function getIterator() : Generator
public function getIterator() : Traversable
{
foreach ($this->iterator as $record) {
$token = serialize($record);
Expand Down
4 changes: 2 additions & 2 deletions src/Extractors/NDJSON.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Rubix\ML\Helpers\JSON;
use Rubix\ML\Exceptions\InvalidArgumentException;
use Rubix\ML\Exceptions\RuntimeException;
use Generator;
use Traversable;

use function is_dir;
use function is_file;
Expand Down Expand Up @@ -99,7 +99,7 @@ public function export(iterable $iterator) : void
* @throws \Rubix\ML\Exceptions\RuntimeException
* @return \Generator<mixed[]>
*/
public function getIterator() : Generator
public function getIterator() : Traversable
{
if (!is_file($this->path)) {
throw new InvalidArgumentException("Path {$this->path} is not a file.");
Expand Down
4 changes: 2 additions & 2 deletions src/Extractors/SQLTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Rubix\ML\Specifications\ExtensionIsLoaded;
use Rubix\ML\Exceptions\InvalidArgumentException;
use Rubix\ML\Exceptions\RuntimeException;
use Generator;
use Traversable;
use PDO;

use function Rubix\ML\iterator_first;
Expand Down Expand Up @@ -85,7 +85,7 @@ public function header() : array
*
* @return \Generator<mixed[]>
*/
public function getIterator() : Generator
public function getIterator() : Traversable
{
$query = "SELECT * FROM {$this->table} LIMIT :offset, {$this->batchSize}";

Expand Down
3 changes: 2 additions & 1 deletion src/Graph/Trees/DecisionTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Rubix\ML\Exceptions\InvalidArgumentException;
use Rubix\ML\Exceptions\RuntimeException;
use IteratorAggregate;
use Traversable;
use Generator;

use function array_pop;
Expand Down Expand Up @@ -272,7 +273,7 @@ public function featureImportances() : array
*
* @return \Generator<\Rubix\ML\Graph\Nodes\Decision>
*/
public function getIterator() : Generator
public function getIterator() : Traversable
{
$stack = [$this->root];

Expand Down

0 comments on commit c8a2840

Please sign in to comment.