Filesystem/CsvResource.php
protected function parseHeaders(array $headers = null): array
    {
        // If headers are not passed in the constructor but file is readable, try to read headers from file
        if (null === $headers) {
            $headers = fgetcsv($this->handler, 0, $this->delimiter, $this->enclosure, $this->escape);
            if (false === $headers || 0 === \count($headers)) {
                throw new \UnexpectedValueException("Unable to read headers for {$this->getResourceName()}");
            }
            // Remove BOM if any
            $bom = pack('H*', 'EFBBBF');
            $headers[0] = preg_replace("/^{$bom}/", '', $headers[0]);

            return $headers;
        }

        $this->manualHeaders = true;
        if (null === $headers || !\is_array($headers)) {
            throw new \UnexpectedValueException(
                "Invalid headers for {$this->getResourceName()}, you need to pass the headers manually"
            );
        }
        if (0 === \count($headers)) {
            throw new \UnexpectedValueException(
                "Empty headers for {$this->getResourceName()}, you need to pass the headers manually"
            );
        }

        return $headers;
    }
protected function parseHeaders(array $headers = null): array
    {
        // If headers are not passed in the constructor but file is readable, try to read headers from file
        if (null === $headers) {
            $headers = fgetcsv($this->handler, 0, $this->delimiter, $this->enclosure, $this->escape);
            if (false === $headers || 0 === \count($headers)) {
                throw new \UnexpectedValueException("Unable to read headers for {$this->getResourceName()}");
            }
            // Remove BOM if any
            $bom = pack('H*', 'EFBBBF');
            $headers[0] = preg_replace("/^{$bom}/", '', $headers[0]);

            return $headers;
        }

        $this->manualHeaders = true;
        if (null === $headers || !\is_array($headers)) {
            throw new \UnexpectedValueException(
                "Invalid headers for {$this->getResourceName()}, you need to pass the headers manually"
            );
        }
        if (0 === \count($headers)) {
            throw new \UnexpectedValueException(
                "Empty headers for {$this->getResourceName()}, you need to pass the headers manually"
            );
        }

        return $headers;
    }
@param array $headers

@throws \UnexpectedValueException

@return array