{
$handle = fopen('php://temp,', 'w+');
- if (!is_array($data)) {
+ if (!\is_array($data)) {
$data = array(array($data));
} elseif (empty($data)) {
$data = array(array());
// Sequential arrays of arrays are considered as collections
$i = 0;
foreach ($data as $key => $value) {
- if ($i !== $key || !is_array($value)) {
+ if ($i !== $key || !\is_array($value)) {
$data = array($data);
break;
}
list($delimiter, $enclosure, $escapeChar, $keySeparator) = $this->getCsvOptions($context);
while (false !== ($cols = fgetcsv($handle, 0, $delimiter, $enclosure, $escapeChar))) {
- $nbCols = count($cols);
+ $nbCols = \count($cols);
if (null === $headers) {
$nbHeaders = $nbCols;
foreach ($cols as $col) {
$header = explode($keySeparator, $col);
$headers[] = $header;
- $headerCount[] = count($header);
+ $headerCount[] = \count($header);
}
continue;
private function flatten(array $array, array &$result, $keySeparator, $parentKey = '')
{
foreach ($array as $key => $value) {
- if (is_array($value)) {
+ if (\is_array($value)) {
$this->flatten($value, $result, $keySeparator, $parentKey.$key.$keySeparator);
} else {
$result[$parentKey.$key] = $value;
$keySeparator = isset($context[self::KEY_SEPARATOR_KEY]) ? $context[self::KEY_SEPARATOR_KEY] : $this->keySeparator;
$headers = isset($context[self::HEADERS_KEY]) ? $context[self::HEADERS_KEY] : array();
- if (!is_array($headers)) {
- throw new InvalidArgumentException(sprintf('The "%s" context variable must be an array or null, given "%s".', self::HEADERS_KEY, gettype($headers)));
+ if (!\is_array($headers)) {
+ throw new InvalidArgumentException(sprintf('The "%s" context variable must be an array or null, given "%s".', self::HEADERS_KEY, \gettype($headers)));
}
return array($delimiter, $enclosure, $escapeChar, $keySeparator, $headers);
}
if (null === $previousHeader) {
- $n = count($headers);
+ $n = \count($headers);
} else {
$n = $flippedHeaders[$previousHeader] + 1;
- for ($j = count($headers); $j > $n; --$j) {
+ for ($j = \count($headers); $j > $n; --$j) {
++$flippedHeaders[$headers[$j] = $headers[$j - 1]];
}
}