Restored some PHP 7.4 support
This commit is contained in:
parent
fd2767b642
commit
4b9e6f4c29
@ -116,11 +116,21 @@ class Dataset
|
||||
return $reader;
|
||||
}
|
||||
$ext = pathinfo($filename, PATHINFO_EXTENSION);
|
||||
|
||||
/*
|
||||
return match ($ext) {
|
||||
'json' => JsonReader::class,
|
||||
'csv' => CsvReader::class,
|
||||
default => throw new \RuntimeException("Unable to determine reader for dataset file")
|
||||
};
|
||||
*/
|
||||
|
||||
// PHP7.4 compat: use switch instead of match
|
||||
switch ($ext) {
|
||||
case 'json': return JsonReader::class;
|
||||
case 'csv': return CsvReader::class;
|
||||
default: throw new \RuntimeException("Unable to determine reader for dataset file");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -10,7 +10,11 @@ class FilteringReaderIterator implements Iterator
|
||||
|
||||
private $condition;
|
||||
|
||||
public function __construct(Iterator $reader, array|callable $condition)
|
||||
/**
|
||||
*
|
||||
* @note Removed support for callable in cond (php7.4 compat)
|
||||
*/
|
||||
public function __construct(Iterator $reader, array $condition)
|
||||
{
|
||||
$this->reader = $reader;
|
||||
$this->condition = $condition;
|
||||
|
@ -38,7 +38,7 @@ class JsonReader implements ReaderInterface
|
||||
|
||||
$flags = ($this->options['bigintAsString']??false)?JSON_BIGINT_AS_STRING:0;
|
||||
$file = $this->files[$this->currentFile];
|
||||
$json = @json_decode(@file_get_contents($file), true, flags:$flags);
|
||||
$json = @json_decode(@file_get_contents($file), true, 512, $flags);
|
||||
|
||||
$this->loadData($json);
|
||||
$this->loadedFile = $this->currentFile;
|
||||
|
Loading…
Reference in New Issue
Block a user