summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorignace nyamagana butera <nyamsprod@gmail.com>2014-08-24 22:22:47 +0200
committerignace nyamagana butera <nyamsprod@gmail.com>2014-08-24 22:39:23 +0200
commitcf54169cc25fccdca20dd5945b5e6f13e7d12d22 (patch)
treefb9aab50b83e2b7c63637868391ad888f3e83d86 /src
parent9dfd08b2aa2c2243b4c03efcb92867948af69f4a (diff)
downloadcsv-cf54169cc25fccdca20dd5945b5e6f13e7d12d22.zip
csv-cf54169cc25fccdca20dd5945b5e6f13e7d12d22.tar.gz
csv-cf54169cc25fccdca20dd5945b5e6f13e7d12d22.tar.bz2
remove deprecated methods
Diffstat (limited to 'src')
-rw-r--r--src/AbstractCsv.php97
-rw-r--r--src/Config/Controls.php113
-rw-r--r--src/Config/StreamFilter.php2
-rw-r--r--src/Iterator/Filter.php22
-rw-r--r--src/Iterator/Interval.php6
-rw-r--r--src/Iterator/MapIterator.php2
-rw-r--r--src/Iterator/SortBy.php22
-rw-r--r--src/Reader.php35
-rw-r--r--src/Writer.php16
9 files changed, 97 insertions, 218 deletions
diff --git a/src/AbstractCsv.php b/src/AbstractCsv.php
index 13eb463..f20d21a 100644
--- a/src/AbstractCsv.php
+++ b/src/AbstractCsv.php
@@ -4,7 +4,7 @@
*
* @license http://opensource.org/licenses/MIT
* @link https://github.com/thephpleague/csv/
-* @version 5.5.0
+* @version 6.0.0
* @package League.csv
*
* For the full copyright and license information, please view the LICENSE
@@ -12,15 +12,12 @@
*/
namespace League\Csv;
-use CallbackFilterIterator;
use DomDocument;
use InvalidArgumentException;
use IteratorAggregate;
use JsonSerializable;
use League\Csv\Config\Controls;
use League\Csv\Config\StreamFilter;
-use LimitIterator;
-use RuntimeException;
use SplFileInfo;
use SplFileObject;
use SplTempFileObject;
@@ -244,86 +241,6 @@ abstract class AbstractCsv implements JsonSerializable, IteratorAggregate
}
/**
- * detect the actual number of row according to a delimiter
- *
- * @param string $delimiter a CSV delimiter
- * @param integer $nb_rows the number of row to consider
- *
- * @return integer
- */
- protected function fetchRowsCountByDelimiter($delimiter, $nb_rows = 1)
- {
- $iterator = $this->getIterator();
- $iterator->setCsvControl($delimiter, $this->enclosure, $this->escape);
- //"reduce" the csv length to a maximum of $nb_rows
- $iterator = new LimitIterator($iterator, 0, $nb_rows);
- //return the parse rows
- $iterator = new CallbackFilterIterator($iterator, function ($row) {
- return is_array($row) && count($row) > 1;
- });
-
- return count(iterator_to_array($iterator, false));
- }
-
- /**
- * Detect the CSV file delimiter
- *
- * @param integer $nb_rows
- * @param string[] $delimiters additional delimiters
- *
- * @return string[]
- *
- * @throws \InvalidArgumentException If $nb_rows value is invalid
- */
- public function detectDelimiters($nb_rows = 1, array $delimiters = [])
- {
- $nb_rows = filter_var($nb_rows, FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]);
- if (! $nb_rows) {
- throw new InvalidArgumentException('`$nb_rows` must be a valid positive integer');
- }
-
- $delimiters = array_filter($delimiters, function ($str) {
- return 1 == mb_strlen($str);
- });
- $delimiters = array_merge([$this->delimiter, ',', ';', "\t"], $delimiters);
- $delimiters = array_unique($delimiters);
- $res = array_fill_keys($delimiters, 0);
- array_walk($res, function (&$value, $delim) use ($nb_rows) {
- $value = $this->fetchRowsCountByDelimiter($delim, $nb_rows);
- });
-
- arsort($res, SORT_NUMERIC);
-
- return array_keys(array_filter($res));
- }
-
- /**
- * DEPRECATION WARNING! This method will be removed in the next major point release
- *
- * @deprecated deprecated since version 5.5
- *
- * Detect the CSV file delimiter
- *
- * @param integer $nb_rows
- * @param string[] $delimiters additional delimiters
- *
- * @return null|string
- *
- * @throws \InvalidArgumentException If $nb_rows value is invalid
- * @throws \RuntimeException If too many delimiters are found
- */
- public function detectDelimiter($nb_rows = 1, array $delimiters = [])
- {
- $res = $this->detectDelimiters($nb_rows, $delimiters);
- if (! $res) {
- return null;
- } elseif (1 == count($res)) {
- return $res[0];
- }
- throw new RuntimeException('too many delimiters were found: `'.implode('`,`', $res).'`');
- }
-
- /**
* Return the CSV Iterator
*
* @return \SplFileObject
@@ -430,4 +347,16 @@ abstract class AbstractCsv implements JsonSerializable, IteratorAggregate
return $doc->saveHTML($doc->documentElement);
}
+
+ /**
+ * Validate a variable to be stringable
+ *
+ * @param mixed $str
+ *
+ * @return boolean
+ */
+ public static function isValidString($str)
+ {
+ return is_scalar($str) || (is_object($str) && method_exists($str, '__toString'));
+ }
}
diff --git a/src/Config/Controls.php b/src/Config/Controls.php
index 50a5065..f1239bc 100644
--- a/src/Config/Controls.php
+++ b/src/Config/Controls.php
@@ -4,7 +4,7 @@
*
* @license http://opensource.org/licenses/MIT
* @link https://github.com/thephpleague/csv/
-* @version 5.5.0
+* @version 6.0.0
* @package League.csv
*
* For the full copyright and license information, please view the LICENSE
@@ -12,8 +12,10 @@
*/
namespace League\Csv\Config;
+use CallbackFilterIterator;
use InvalidArgumentException;
use League\Csv\Iterator\MapIterator;
+use LimitIterator;
use SplFileObject;
use Traversable;
@@ -66,7 +68,7 @@ trait Controls
*
* @param string $delimiter
*
- * @return self
+ * @return $this
*
* @throws \InvalidArgumentException If $delimeter is not a single character
*/
@@ -91,11 +93,72 @@ trait Controls
}
/**
+ * detect the actual number of row according to a delimiter
+ *
+ * @param string $delimiter a CSV delimiter
+ * @param integer $nb_rows the number of row to consider
+ *
+ * @return integer
+ */
+ protected function fetchRowsCountByDelimiter($delimiter, $nb_rows = 1)
+ {
+ $iterator = $this->getIterator();
+ $iterator->setCsvControl($delimiter, $this->enclosure, $this->escape);
+ //"reduce" the csv length to a maximum of $nb_rows
+ $iterator = new LimitIterator($iterator, 0, $nb_rows);
+ //return the parse rows
+ $iterator = new CallbackFilterIterator($iterator, function ($row) {
+ return is_array($row) && count($row) > 1;
+ });
+
+ return count(iterator_to_array($iterator, false));
+ }
+
+ /**
+ * Detect the CSV file delimiter
+ *
+ * @param integer $nb_rows
+ * @param string[] $delimiters additional delimiters
+ *
+ * @return string[]
+ *
+ * @throws \InvalidArgumentException If $nb_rows value is invalid
+ */
+ public function detectDelimiterList($nb_rows = 1, array $delimiters = [])
+ {
+ $nb_rows = filter_var($nb_rows, FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]);
+ if (! $nb_rows) {
+ throw new InvalidArgumentException('`$nb_rows` must be a valid positive integer');
+ }
+
+ $delimiters = array_filter($delimiters, function ($str) {
+ return 1 == mb_strlen($str);
+ });
+ $delimiters = array_merge([$this->delimiter, ',', ';', "\t"], $delimiters);
+ $delimiters = array_unique($delimiters);
+ $res = array_fill_keys($delimiters, 0);
+ array_walk($res, function (&$value, $delim) use ($nb_rows) {
+ $value = $this->fetchRowsCountByDelimiter($delim, $nb_rows);
+ });
+
+ arsort($res, SORT_NUMERIC);
+
+ return array_keys(array_filter($res));
+ }
+
+ /**
+ * return a SplFileOjbect
+ *
+ * @return \SplFileOjbect
+ */
+ abstract public function getIterator();
+
+ /**
* set the field enclosure
*
* @param string $enclosure
*
- * @return self
+ * @return $this
*
* @throws \InvalidArgumentException If $enclosure is not a single character
*/
@@ -124,7 +187,7 @@ trait Controls
*
* @param string $escape
*
- * @return self
+ * @return $this
*
* @throws \InvalidArgumentException If $escape is not a single character
*/
@@ -153,7 +216,7 @@ trait Controls
*
* @param integer $flags
*
- * @return self
+ * @return $this
*
* @throws \InvalidArgumentException If the argument is not a valid integer
*/
@@ -179,37 +242,11 @@ trait Controls
}
/**
- * DEPRECATION WARNING! This method will be removed in the next major point release
- *
- * @deprecated deprecated since version 5.5
- *
- * @param string $str
- *
- * @return static The invoked object
- */
- public function setEncoding($str)
- {
- return $this->setEncodingFrom($str);
- }
-
- /**
- * DEPRECATION WARNING! This method will be removed in the next major point release
- *
- * @deprecated deprecated since version 5.5
- *
- * @return string
- */
- public function getEncoding()
- {
- return $this->getEncodingFrom();
- }
-
- /**
* Set the CSV encoding charset
*
* @param string $str
*
- * @return self
+ * @return $this
*/
public function setEncodingFrom($str)
{
@@ -253,16 +290,4 @@ trait Controls
return $row;
});
}
-
- /**
- * Validate a variable to be stringable
- *
- * @param mixed $str
- *
- * @return boolean
- */
- public static function isValidString($str)
- {
- return is_scalar($str) || (is_object($str) && method_exists($str, '__toString'));
- }
}
diff --git a/src/Config/StreamFilter.php b/src/Config/StreamFilter.php
index 90c2cff..0514ad4 100644
--- a/src/Config/StreamFilter.php
+++ b/src/Config/StreamFilter.php
@@ -4,7 +4,7 @@
*
* @license http://opensource.org/licenses/MIT
* @link https://github.com/thephpleague/csv/
-* @version 5.5.0
+* @version 6.0.0
* @package League.csv
*
* For the full copyright and license information, please view the LICENSE
diff --git a/src/Iterator/Filter.php b/src/Iterator/Filter.php
index 3554f13..503a988 100644
--- a/src/Iterator/Filter.php
+++ b/src/Iterator/Filter.php
@@ -4,7 +4,7 @@
*
* @license http://opensource.org/licenses/MIT
* @link https://github.com/thephpleague/csv/
-* @version 5.5.0
+* @version 6.0.0
* @package League.csv
*
* For the full copyright and license information, please view the LICENSE
@@ -33,25 +33,11 @@ trait Filter
protected $iterator_filters = [];
/**
- * DEPRECATION WARNING! This method will be removed in the next major point release
- *
- * @deprecated deprecated since version 5.1
- *
- * @param callable $callable
- *
- * @return static The invoked object
- */
- public function setFilter(callable $callable)
- {
- return $this->addFilter($callable);
- }
-
- /**
* Set the Iterator filter method
*
* @param callable $callable
*
- * @return static The invoked object
+ * @return $this
*/
public function addFilter(callable $callable)
{
@@ -65,7 +51,7 @@ trait Filter
*
* @param callable $callable
*
- * @return static The invoked object
+ * @return $this
*/
public function removeFilter(callable $callable)
{
@@ -92,7 +78,7 @@ trait Filter
/**
* Remove all registered callable filter
*
- * @return static The invoked object
+ * @return $this
*/
public function clearFilter()
{
diff --git a/src/Iterator/Interval.php b/src/Iterator/Interval.php
index 50b49ec..e8c3b4b 100644
--- a/src/Iterator/Interval.php
+++ b/src/Iterator/Interval.php
@@ -3,7 +3,7 @@
* This file is part of the League.csv library
*
* @license http://opensource.org/licenses/MIT
-* @version 5.5.0
+* @version 6.0.0
* @package League.csv
*
* For the full copyright and license information, please view the LICENSE
@@ -43,7 +43,7 @@ trait Interval
*
* @param $offset
*
- * @return static The invoked object
+ * @return $this
*/
public function setOffset($offset = 0)
{
@@ -60,7 +60,7 @@ trait Interval
*
* @param integer $limit
*
- * @return static The invoked object
+ * @return $this
*/
public function setLimit($limit = -1)
{
diff --git a/src/Iterator/MapIterator.php b/src/Iterator/MapIterator.php
index 3239902..19e89f4 100644
--- a/src/Iterator/MapIterator.php
+++ b/src/Iterator/MapIterator.php
@@ -4,7 +4,7 @@
*
* @license http://opensource.org/licenses/MIT
* @link https://github.com/thephpleague/csv/
-* @version 5.5.0
+* @version 6.0.0
* @package League.csv
*
* For the full copyright and license information, please view the LICENSE
diff --git a/src/Iterator/SortBy.php b/src/Iterator/SortBy.php
index e05d53b..eb929c7 100644
--- a/src/Iterator/SortBy.php
+++ b/src/Iterator/SortBy.php
@@ -4,7 +4,7 @@
*
* @license http://opensource.org/licenses/MIT
* @link https://github.com/thephpleague/csv/
-* @version 5.5.0
+* @version 6.0.0
* @package League.csv
*
* For the full copyright and license information, please view the LICENSE
@@ -33,25 +33,11 @@ trait SortBy
protected $iterator_sort_by = [];
/**
- * DEPRECATION WARNING! This method will be removed in the next major point release
- *
- * @deprecated deprecated since version 5.2
- *
- * @param callable $callable
- *
- * @return static The invoked object
- */
- public function setSortBy(callable $callable)
- {
- return $this->addSortBy($callable);
- }
-
- /**
* Set an Iterator sorting callable function
*
* @param callable $callable
*
- * @return static The invoked object
+ * @return $this
*/
public function addSortBy(callable $callable)
{
@@ -65,7 +51,7 @@ trait SortBy
*
* @param callable $callable
*
- * @return static The invoked object
+ * @return $this
*/
public function removeSortBy(callable $callable)
{
@@ -92,7 +78,7 @@ trait SortBy
/**
* Remove all registered callable
*
- * @return static The invoked object
+ * @return $this
*/
public function clearSortBy()
{
diff --git a/src/Reader.php b/src/Reader.php
index d901725..13c478b 100644
--- a/src/Reader.php
+++ b/src/Reader.php
@@ -4,7 +4,7 @@
*
* @license http://opensource.org/licenses/MIT
* @link https://github.com/thephpleague/csv/
-* @version 5.5.0
+* @version 6.0.0
* @package League.csv
*
* For the full copyright and license information, please view the LICENSE
@@ -191,25 +191,6 @@ class Reader extends AbstractCsv
}
/**
- * DEPRECATION WARNING! This method will be removed in the next major point release
- *
- * @deprecated deprecated since version 5.4
- *
- * The callable function will be applied to each value to be return
- *
- * @param integer $column_index field Index
- * @param callable $callable a callable function
- *
- * @return array
- *
- * @throws \InvalidArgumentException If the column index is not a positive integer or 0
- */
- public function fetchCol($column_index = 0, callable $callable = null)
- {
- return $this->fetchColumn($column_index, $callable);
- }
-
- /**
* Return a single column from the CSV data
*
* The callable function will be applied to each value to be return
@@ -240,18 +221,4 @@ class Reader extends AbstractCsv
return iterator_to_array($iterator, false);
}
-
- /**
- * DEPRECATION WARNING! This method will be removed in the next major point release
- *
- * @deprecated deprecated since version 5.5
- *
- * @param string $open_mode the file open mode flag
- *
- * @return \League\Csv\Writer object
- */
- public function getWriter($open_mode = 'r+')
- {
- return $this->newWriter($open_mode);
- }
}
diff --git a/src/Writer.php b/src/Writer.php
index 0ae9154..49973c5 100644
--- a/src/Writer.php
+++ b/src/Writer.php
@@ -4,7 +4,7 @@
*
* @license http://opensource.org/licenses/MIT
* @link https://github.com/thephpleague/csv/
-* @version 5.5.0
+* @version 6.0.0
* @package League.csv
*
* For the full copyright and license information, please view the LICENSE
@@ -315,18 +315,4 @@ class Writer extends AbstractCsv
return $this;
}
-
- /**
- * DEPRECATION WARNING! This method will be removed in the next major point release
- *
- * @deprecated deprecated since version 5.5
- *
- * @param string $open_mode the file open mode flag
- *
- * @return \League\Csv\Reader object
- */
- public function getReader($open_mode = 'r+')
- {
- return $this->newReader($open_mode);
- }
}