diff options
Diffstat (limited to 'src/Modifier')
-rw-r--r-- | src/Modifier/MapIterator.php | 3 | ||||
-rw-r--r-- | src/Modifier/QueryFilter.php | 4 | ||||
-rw-r--r-- | src/Modifier/RowFilter.php | 7 | ||||
-rw-r--r-- | src/Modifier/StreamFilter.php | 15 |
4 files changed, 16 insertions, 13 deletions
diff --git a/src/Modifier/MapIterator.php b/src/Modifier/MapIterator.php index 436cb99..cedc95b 100644 --- a/src/Modifier/MapIterator.php +++ b/src/Modifier/MapIterator.php @@ -50,8 +50,7 @@ class MapIterator extends IteratorIterator public function current() { $iterator = $this->getInnerIterator(); - $callable = $this->callable; - return $callable($iterator->current(), $iterator->key(), $iterator); + return call_user_func($this->callable, $iterator->current(), $iterator->key(), $iterator); } } diff --git a/src/Modifier/QueryFilter.php b/src/Modifier/QueryFilter.php index e11f589..eaceec8 100644 --- a/src/Modifier/QueryFilter.php +++ b/src/Modifier/QueryFilter.php @@ -268,7 +268,7 @@ trait QueryFilter * * @return Iterator */ - protected function getStripBomIterator($iterator) + protected function getStripBomIterator(Iterator $iterator) { $bom = $this->getInputBom(); @@ -344,7 +344,7 @@ trait QueryFilter $obj->uasort(function ($rowA, $rowB) { $sortRes = 0; foreach ($this->iterator_sort_by as $callable) { - if (0 !== ($sortRes = $callable($rowA, $rowB))) { + if (0 !== ($sortRes = call_user_func($callable, $rowA, $rowB))) { break; } } diff --git a/src/Modifier/RowFilter.php b/src/Modifier/RowFilter.php index 0205ee4..4728660 100644 --- a/src/Modifier/RowFilter.php +++ b/src/Modifier/RowFilter.php @@ -161,7 +161,7 @@ trait RowFilter protected function formatRow(array $row) { foreach ($this->formatters as $formatter) { - $row = $formatter($row); + $row = call_user_func($formatter, $row); } return $row; @@ -172,13 +172,12 @@ trait RowFilter * * @param array $row * - * @throws \League\Csv\Exception\InvalidRowException If the validation failed - * + * @throws InvalidRowException If the validation failed */ protected function validateRow(array $row) { foreach ($this->validators as $name => $validator) { - if (true !== $validator($row)) { + if (true !== call_user_func($validator, $row)) { throw new InvalidRowException($name, $row, 'row validation failed'); } } diff --git a/src/Modifier/StreamFilter.php b/src/Modifier/StreamFilter.php index 34b9b14..d3d717f 100644 --- a/src/Modifier/StreamFilter.php +++ b/src/Modifier/StreamFilter.php @@ -52,7 +52,12 @@ trait StreamFilter * * @var string */ - protected $stream_regex = ',^php://filter/(?P<mode>:?read=|write=)?(?P<filters>.*?)/resource=(?P<resource>.*)$,i'; + protected $stream_regex = ',^ + php://filter/ + (?P<mode>:?read=|write=)? # The resource open mode + (?P<filters>.*?) # The resource registered filters + /resource=(?P<resource>.*) # The resource path + $,ix'; /** * Internal path setter @@ -77,8 +82,8 @@ trait StreamFilter return; } - $this->stream_uri = $matches['resource']; - $this->stream_filters = explode('|', $matches['filters']); + $this->stream_uri = $matches['resource']; + $this->stream_filters = explode('|', $matches['filters']); $this->stream_filter_mode = $this->fetchStreamModeAsInt($matches['mode']); } @@ -111,7 +116,7 @@ trait StreamFilter */ protected function assertStreamable() { - if (! is_string($this->stream_uri)) { + if (!is_string($this->stream_uri)) { throw new LogicException('The stream filter API can not be used'); } } @@ -141,7 +146,7 @@ trait StreamFilter public function setStreamFilterMode($mode) { $this->assertStreamable(); - if (! in_array($mode, [STREAM_FILTER_ALL, STREAM_FILTER_READ, STREAM_FILTER_WRITE])) { + if (!in_array($mode, [STREAM_FILTER_ALL, STREAM_FILTER_READ, STREAM_FILTER_WRITE])) { throw new OutOfBoundsException('the $mode should be a valid `STREAM_FILTER_*` constant'); } |