Fix various problems
This commit is contained in:
parent
86a4c3790a
commit
37d87a8a27
@ -12,7 +12,7 @@ install:
|
|||||||
|
|
||||||
script:
|
script:
|
||||||
- mkdir -p build/logs
|
- mkdir -p build/logs
|
||||||
- php vendor/bin/phpunit --coverage-clover build/logs/clover.xml --coverage-text
|
- php vendor/bin/phpunit --coverage-clover build/logs/clover.xml
|
||||||
|
|
||||||
after_script:
|
after_script:
|
||||||
- if [[ $TRAVIS_PHP_VERSION != 'hhvm' && $TRAVIS_PHP_VERSION != '7.0' ]]; then php vendor/bin/ocular code-coverage:upload --format=php-clover build/logs/clover.xml; fi
|
- if [[ $TRAVIS_PHP_VERSION != 'hhvm' && $TRAVIS_PHP_VERSION != '7.0' ]]; then php vendor/bin/ocular code-coverage:upload --format=php-clover build/logs/clover.xml; fi
|
||||||
|
@ -160,7 +160,7 @@ class GlobalFunctionsHelper
|
|||||||
* @see file_get_contents()
|
* @see file_get_contents()
|
||||||
*
|
*
|
||||||
* @param string $filePath
|
* @param string $filePath
|
||||||
* @return bool
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function file_get_contents($filePath)
|
public function file_get_contents($filePath)
|
||||||
{
|
{
|
||||||
|
@ -111,9 +111,9 @@ class RowIterator implements IteratorInterface
|
|||||||
if (!$this->hasReachedEndOfFile) {
|
if (!$this->hasReachedEndOfFile) {
|
||||||
do {
|
do {
|
||||||
$lineData = $this->globalFunctionsHelper->fgetcsv($this->filePointer, 0, $this->fieldDelimiter, $this->fieldEnclosure);
|
$lineData = $this->globalFunctionsHelper->fgetcsv($this->filePointer, 0, $this->fieldDelimiter, $this->fieldEnclosure);
|
||||||
} while ($lineData && $this->isEmptyLine($lineData));
|
} while ($lineData === false || ($lineData !== null && $this->isEmptyLine($lineData)));
|
||||||
|
|
||||||
if ($lineData !== null) {
|
if ($lineData !== false && $lineData !== null) {
|
||||||
$this->rowDataBuffer = $lineData;
|
$this->rowDataBuffer = $lineData;
|
||||||
$this->numReadRows++;
|
$this->numReadRows++;
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ class RowIterator implements IteratorInterface
|
|||||||
* Return the current element from the buffer
|
* Return the current element from the buffer
|
||||||
* @link http://php.net/manual/en/iterator.current.php
|
* @link http://php.net/manual/en/iterator.current.php
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
public function current()
|
public function current()
|
||||||
{
|
{
|
||||||
|
@ -26,6 +26,9 @@ class FileBasedStrategy implements CachingStrategyInterface
|
|||||||
/** @var \Box\Spout\Common\Helper\FileSystemHelper Helper to perform file system operations */
|
/** @var \Box\Spout\Common\Helper\FileSystemHelper Helper to perform file system operations */
|
||||||
protected $fileSystemHelper;
|
protected $fileSystemHelper;
|
||||||
|
|
||||||
|
/** @var string Temporary folder where the temporary files will be created */
|
||||||
|
protected $tempFolder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int Maximum number of strings that can be stored in one temp file
|
* @var int Maximum number of strings that can be stored in one temp file
|
||||||
* @see CachingStrategyFactory::MAX_NUM_STRINGS_PER_TEMP_FILE
|
* @see CachingStrategyFactory::MAX_NUM_STRINGS_PER_TEMP_FILE
|
||||||
@ -42,7 +45,7 @@ class FileBasedStrategy implements CachingStrategyInterface
|
|||||||
protected $inMemoryTempFilePath;
|
protected $inMemoryTempFilePath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string Contents of the temporary file that was last read
|
* @var array Contents of the temporary file that was last read
|
||||||
* @see CachingStrategyFactory::MAX_NUM_STRINGS_PER_TEMP_FILE
|
* @see CachingStrategyFactory::MAX_NUM_STRINGS_PER_TEMP_FILE
|
||||||
*/
|
*/
|
||||||
protected $inMemoryTempFileContents;
|
protected $inMemoryTempFileContents;
|
||||||
|
@ -72,8 +72,9 @@ class SheetHelper
|
|||||||
|
|
||||||
// find all nodes defining a sheet
|
// find all nodes defining a sheet
|
||||||
$sheetNodes = $contentTypesAsXMLElement->xpath('//ns:Override[@ContentType="' . self::OVERRIDE_CONTENT_TYPES_ATTRIBUTE . '"]');
|
$sheetNodes = $contentTypesAsXMLElement->xpath('//ns:Override[@ContentType="' . self::OVERRIDE_CONTENT_TYPES_ATTRIBUTE . '"]');
|
||||||
|
$numSheetNodes = count($sheetNodes);
|
||||||
|
|
||||||
for ($i = 0; $i < count($sheetNodes); $i++) {
|
for ($i = 0; $i < $numSheetNodes; $i++) {
|
||||||
$sheetNode = $sheetNodes[$i];
|
$sheetNode = $sheetNodes[$i];
|
||||||
$sheetDataXMLFilePath = (string) $sheetNode->attributes()->PartName;
|
$sheetDataXMLFilePath = (string) $sheetNode->attributes()->PartName;
|
||||||
|
|
||||||
@ -95,7 +96,7 @@ class SheetHelper
|
|||||||
*
|
*
|
||||||
* @param string $sheetDataXMLFilePath Path of the sheet data XML file as in [Content_Types].xml
|
* @param string $sheetDataXMLFilePath Path of the sheet data XML file as in [Content_Types].xml
|
||||||
* @param int $sheetIndexZeroBased Index of the sheet, based on order in [Content_Types].xml (zero-based)
|
* @param int $sheetIndexZeroBased Index of the sheet, based on order in [Content_Types].xml (zero-based)
|
||||||
* @return \Box\Spout\Reader\Sheet Sheet instance
|
* @return \Box\Spout\Reader\XLSX\Sheet Sheet instance
|
||||||
*/
|
*/
|
||||||
protected function getSheetFromXML($sheetDataXMLFilePath, $sheetIndexZeroBased)
|
protected function getSheetFromXML($sheetDataXMLFilePath, $sheetIndexZeroBased)
|
||||||
{
|
{
|
||||||
@ -136,7 +137,7 @@ class SheetHelper
|
|||||||
* Returns the default name of the sheet whose data is located
|
* Returns the default name of the sheet whose data is located
|
||||||
* at the given path.
|
* at the given path.
|
||||||
*
|
*
|
||||||
* @param $sheetDataXMLFilePath
|
* @param string $sheetDataXMLFilePath Path of the sheet data XML file
|
||||||
* @return string The default sheet name
|
* @return string The default sheet name
|
||||||
*/
|
*/
|
||||||
protected function getDefaultSheetName($sheetDataXMLFilePath)
|
protected function getDefaultSheetName($sheetDataXMLFilePath)
|
||||||
|
@ -32,7 +32,7 @@ class Sheet implements SheetInterface
|
|||||||
* @param int $sheetIndex Index of the sheet, based on order of creation (zero-based)
|
* @param int $sheetIndex Index of the sheet, based on order of creation (zero-based)
|
||||||
* @param string $sheetName Name of the sheet
|
* @param string $sheetName Name of the sheet
|
||||||
*/
|
*/
|
||||||
function __construct($filePath, $sheetDataXMLFilePath, $sharedStringsHelper, $sheetId, $sheetIndex, $sheetName)
|
public function __construct($filePath, $sheetDataXMLFilePath, $sharedStringsHelper, $sheetId, $sheetIndex, $sheetName)
|
||||||
{
|
{
|
||||||
$this->rowIterator = new RowIterator($filePath, $sheetDataXMLFilePath, $sharedStringsHelper);
|
$this->rowIterator = new RowIterator($filePath, $sheetDataXMLFilePath, $sharedStringsHelper);
|
||||||
$this->id = $sheetId;
|
$this->id = $sheetId;
|
||||||
|
@ -25,6 +25,9 @@ EOD;
|
|||||||
*/
|
*/
|
||||||
const DEFAULT_STRINGS_COUNT_PART = 'count="9999999999999" uniqueCount="9999999999999"';
|
const DEFAULT_STRINGS_COUNT_PART = 'count="9999999999999" uniqueCount="9999999999999"';
|
||||||
|
|
||||||
|
/** @var resource Pointer to the sharedStrings.xml file */
|
||||||
|
protected $sharedStringsFilePointer;
|
||||||
|
|
||||||
/** @var int Number of shared strings already written */
|
/** @var int Number of shared strings already written */
|
||||||
protected $numSharedStrings = 0;
|
protected $numSharedStrings = 0;
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ class Sheet
|
|||||||
/**
|
/**
|
||||||
* @param int $sheetIndex Index of the sheet, based on order of creation (zero-based)
|
* @param int $sheetIndex Index of the sheet, based on order of creation (zero-based)
|
||||||
*/
|
*/
|
||||||
function __construct($sheetIndex)
|
public function __construct($sheetIndex)
|
||||||
{
|
{
|
||||||
$this->index = $sheetIndex;
|
$this->index = $sheetIndex;
|
||||||
$this->name = self::DEFAULT_SHEET_NAME_PREFIX . ($sheetIndex + 1);
|
$this->name = self::DEFAULT_SHEET_NAME_PREFIX . ($sheetIndex + 1);
|
||||||
|
@ -93,6 +93,9 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testReadShouldSupportAllCellTypes()
|
public function testReadShouldSupportAllCellTypes()
|
||||||
{
|
{
|
||||||
|
// make sure dates are always created with the same timezone
|
||||||
|
date_default_timezone_set('UTC');
|
||||||
|
|
||||||
$allRows = $this->getAllRowsForFile('sheet_with_all_cell_types.xlsx');
|
$allRows = $this->getAllRowsForFile('sheet_with_all_cell_types.xlsx');
|
||||||
|
|
||||||
$expectedRows = [
|
$expectedRows = [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user