From 3c3154c4a3901b708206fb83a504a87865d0e390 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Tue, 5 May 2015 19:40:34 +0100 Subject: [PATCH] PSR-2 variable naming for caching classes, remove leading underscores --- Classes/PHPExcel/CachedObjectStorage/APC.php | 90 +++++----- .../CachedObjectStorage/CacheBase.php | 64 +++---- .../PHPExcel/CachedObjectStorage/DiscISAM.php | 94 +++++----- .../PHPExcel/CachedObjectStorage/Igbinary.php | 52 +++--- .../PHPExcel/CachedObjectStorage/Memcache.php | 96 +++++------ .../PHPExcel/CachedObjectStorage/Memory.php | 26 +-- .../CachedObjectStorage/MemoryGZip.php | 52 +++--- .../CachedObjectStorage/MemorySerialized.php | 52 +++--- .../PHPExcel/CachedObjectStorage/PHPTemp.php | 86 +++++----- .../PHPExcel/CachedObjectStorage/SQLite.php | 138 +++++++-------- .../PHPExcel/CachedObjectStorage/SQLite3.php | 162 +++++++++--------- .../PHPExcel/CachedObjectStorage/Wincache.php | 94 +++++----- .../PHPExcel/CachedObjectStorageFactory.php | 44 ++--- .../CalcEngine/CyclicReferenceStack.php | 14 +- Classes/PHPExcel/CalcEngine/Logger.php | 34 ++-- changelog.txt | 1 + 16 files changed, 550 insertions(+), 549 deletions(-) diff --git a/Classes/PHPExcel/CachedObjectStorage/APC.php b/Classes/PHPExcel/CachedObjectStorage/APC.php index d2ad6e37..c74b07fe 100644 --- a/Classes/PHPExcel/CachedObjectStorage/APC.php +++ b/Classes/PHPExcel/CachedObjectStorage/APC.php @@ -33,7 +33,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach * @access private * @var string */ - private $_cachePrefix = null; + private $cachePrefix = null; /** * Cache timeout @@ -41,7 +41,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach * @access private * @var integer */ - private $_cacheTime = 600; + private $cacheTime = 600; /** * Store cell data in cache for the current cell object if it's "dirty", @@ -51,22 +51,22 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach * @return void * @throws PHPExcel_Exception */ - protected function _storeData() + protected function storeData() { - if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { - $this->_currentObject->detach(); + if ($this->currentCellIsDirty && !empty($this->currentObjectID)) { + $this->currentObject->detach(); if (!apc_store( - $this->_cachePrefix . $this->_currentObjectID . '.cache', - serialize($this->_currentObject), - $this->_cacheTime + $this->cachePrefix . $this->currentObjectID . '.cache', + serialize($this->currentObject), + $this->cacheTime )) { $this->__destruct(); - throw new PHPExcel_Exception('Failed to store cell ' . $this->_currentObjectID . ' in APC'); + throw new PHPExcel_Exception('Failed to store cell ' . $this->currentObjectID . ' in APC'); } - $this->_currentCellIsDirty = false; + $this->currentCellIsDirty = false; } - $this->_currentObjectID = $this->_currentObject = null; + $this->currentObjectID = $this->currentObject = null; } /** @@ -80,14 +80,14 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { - if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { - $this->_storeData(); + if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) { + $this->storeData(); } - $this->_cellCache[$pCoord] = true; + $this->cellCache[$pCoord] = true; - $this->_currentObjectID = $pCoord; - $this->_currentObject = $cell; - $this->_currentCellIsDirty = true; + $this->currentObjectID = $pCoord; + $this->currentObject = $cell; + $this->currentCellIsDirty = true; return $cell; } @@ -104,11 +104,11 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach { // Check if the requested entry is the current object, or exists in the cache if (parent::isDataSet($pCoord)) { - if ($this->_currentObjectID == $pCoord) { + if ($this->currentObjectID == $pCoord) { return true; } // Check if the requested entry still exists in apc - $success = apc_fetch($this->_cachePrefix.$pCoord.'.cache'); + $success = apc_fetch($this->cachePrefix.$pCoord.'.cache'); if ($success === false) { // Entry no longer exists in APC, so clear it from the cache array parent::deleteCacheData($pCoord); @@ -129,14 +129,14 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach */ public function getCacheData($pCoord) { - if ($pCoord === $this->_currentObjectID) { - return $this->_currentObject; + if ($pCoord === $this->currentObjectID) { + return $this->currentObject; } - $this->_storeData(); + $this->storeData(); // Check if the entry that has been requested actually exists if (parent::isDataSet($pCoord)) { - $obj = apc_fetch($this->_cachePrefix . $pCoord . '.cache'); + $obj = apc_fetch($this->cachePrefix . $pCoord . '.cache'); if ($obj === false) { // Entry no longer exists in APC, so clear it from the cache array parent::deleteCacheData($pCoord); @@ -148,13 +148,13 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach } // Set current entry to the requested entry - $this->_currentObjectID = $pCoord; - $this->_currentObject = unserialize($obj); + $this->currentObjectID = $pCoord; + $this->currentObject = unserialize($obj); // Re-attach this as the cell's parent - $this->_currentObject->attach($this); + $this->currentObject->attach($this); // Return requested entry - return $this->_currentObject; + return $this->currentObject; } /** @@ -164,8 +164,8 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach */ public function getCellList() { - if ($this->_currentObjectID !== null) { - $this->_storeData(); + if ($this->currentObjectID !== null) { + $this->storeData(); } return parent::getCellList(); @@ -181,7 +181,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach public function deleteCacheData($pCoord) { // Delete the entry from APC - apc_delete($this->_cachePrefix.$pCoord.'.cache'); + apc_delete($this->cachePrefix.$pCoord.'.cache'); // Delete the entry from our cell address array parent::deleteCacheData($pCoord); @@ -199,24 +199,24 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach { parent::copyCellCollection($parent); // Get a new id for the new file name - $baseUnique = $this->_getUniqueID(); + $baseUnique = $this->getUniqueID(); $newCachePrefix = substr(md5($baseUnique), 0, 8) . '.'; $cacheList = $this->getCellList(); foreach ($cacheList as $cellID) { - if ($cellID != $this->_currentObjectID) { - $obj = apc_fetch($this->_cachePrefix . $cellID . '.cache'); + if ($cellID != $this->currentObjectID) { + $obj = apc_fetch($this->cachePrefix . $cellID . '.cache'); if ($obj === false) { // Entry no longer exists in APC, so clear it from the cache array parent::deleteCacheData($cellID); throw new PHPExcel_Exception('Cell entry ' . $cellID . ' no longer exists in APC'); } - if (!apc_store($newCachePrefix . $cellID . '.cache', $obj, $this->_cacheTime)) { + if (!apc_store($newCachePrefix . $cellID . '.cache', $obj, $this->cacheTime)) { $this->__destruct(); throw new PHPExcel_Exception('Failed to store cell ' . $cellID . ' in APC'); } } } - $this->_cachePrefix = $newCachePrefix; + $this->cachePrefix = $newCachePrefix; } /** @@ -226,18 +226,18 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach */ public function unsetWorksheetCells() { - if ($this->_currentObject !== null) { - $this->_currentObject->detach(); - $this->_currentObject = $this->_currentObjectID = null; + if ($this->currentObject !== null) { + $this->currentObject->detach(); + $this->currentObject = $this->currentObjectID = null; } // Flush the APC cache $this->__destruct(); - $this->_cellCache = array(); + $this->cellCache = array(); // detach ourself from the worksheet, so that it can then delete this object successfully - $this->_parent = null; + $this->parent = null; } /** @@ -250,10 +250,10 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach { $cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600; - if ($this->_cachePrefix === null) { - $baseUnique = $this->_getUniqueID(); - $this->_cachePrefix = substr(md5($baseUnique), 0, 8) . '.'; - $this->_cacheTime = $cacheTime; + if ($this->cachePrefix === null) { + $baseUnique = $this->getUniqueID(); + $this->cachePrefix = substr(md5($baseUnique), 0, 8) . '.'; + $this->cacheTime = $cacheTime; parent::__construct($parent); } @@ -266,7 +266,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach { $cacheList = $this->getCellList(); foreach ($cacheList as $cellID) { - apc_delete($this->_cachePrefix . $cellID . '.cache'); + apc_delete($this->cachePrefix . $cellID . '.cache'); } } diff --git a/Classes/PHPExcel/CachedObjectStorage/CacheBase.php b/Classes/PHPExcel/CachedObjectStorage/CacheBase.php index a7c25ed2..9a12ec86 100644 --- a/Classes/PHPExcel/CachedObjectStorage/CacheBase.php +++ b/Classes/PHPExcel/CachedObjectStorage/CacheBase.php @@ -32,28 +32,28 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase * * @var PHPExcel_Worksheet */ - protected $_parent; + protected $parent; /** * The currently active Cell * * @var PHPExcel_Cell */ - protected $_currentObject = null; + protected $currentObject = null; /** * Coordinate address of the currently active Cell * * @var string */ - protected $_currentObjectID = null; + protected $currentObjectID = null; /** * Flag indicating whether the currently active Cell requires saving * * @var boolean */ - protected $_currentCellIsDirty = true; + protected $currentCellIsDirty = true; /** * An array of cells or cell pointers for the worksheet cells held in this cache, @@ -61,7 +61,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase * * @var array of mixed */ - protected $_cellCache = array(); + protected $cellCache = array(); /** * Initialise this new cell collection @@ -73,7 +73,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase // Set our parent worksheet. // This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when // they are woken from a serialized state - $this->_parent = $parent; + $this->parent = $parent; } /** @@ -83,7 +83,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase */ public function getParent() { - return $this->_parent; + return $this->parent; } /** @@ -94,11 +94,11 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase */ public function isDataSet($pCoord) { - if ($pCoord === $this->_currentObjectID) { + if ($pCoord === $this->currentObjectID) { return true; } // Check if the requested entry exists in the cache - return isset($this->_cellCache[$pCoord]); + return isset($this->cellCache[$pCoord]); } /** @@ -110,13 +110,13 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase */ public function moveCell($fromAddress, $toAddress) { - if ($fromAddress === $this->_currentObjectID) { - $this->_currentObjectID = $toAddress; + if ($fromAddress === $this->currentObjectID) { + $this->currentObjectID = $toAddress; } - $this->_currentCellIsDirty = true; - if (isset($this->_cellCache[$fromAddress])) { - $this->_cellCache[$toAddress] = &$this->_cellCache[$fromAddress]; - unset($this->_cellCache[$fromAddress]); + $this->currentCellIsDirty = true; + if (isset($this->cellCache[$fromAddress])) { + $this->cellCache[$toAddress] = &$this->cellCache[$fromAddress]; + unset($this->cellCache[$fromAddress]); } return true; @@ -142,16 +142,16 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase */ public function deleteCacheData($pCoord) { - if ($pCoord === $this->_currentObjectID && !is_null($this->_currentObject)) { - $this->_currentObject->detach(); - $this->_currentObjectID = $this->_currentObject = null; + if ($pCoord === $this->currentObjectID && !is_null($this->currentObject)) { + $this->currentObject->detach(); + $this->currentObjectID = $this->currentObject = null; } - if (is_object($this->_cellCache[$pCoord])) { - $this->_cellCache[$pCoord]->detach(); - unset($this->_cellCache[$pCoord]); + if (is_object($this->cellCache[$pCoord])) { + $this->cellCache[$pCoord]->detach(); + unset($this->cellCache[$pCoord]); } - $this->_currentCellIsDirty = false; + $this->currentCellIsDirty = false; } /** @@ -161,7 +161,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase */ public function getCellList() { - return array_keys($this->_cellCache); + return array_keys($this->cellCache); } /** @@ -215,7 +215,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase */ public function getCurrentAddress() { - return $this->_currentObjectID; + return $this->currentObjectID; } /** @@ -225,7 +225,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase */ public function getCurrentColumn() { - sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row); + sscanf($this->currentObjectID, '%[A-Z]%d', $column, $row); return $column; } @@ -236,7 +236,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase */ public function getCurrentRow() { - sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row); + sscanf($this->currentObjectID, '%[A-Z]%d', $column, $row); return (integer) $row; } @@ -296,7 +296,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase * * @return string Unique Reference */ - protected function _getUniqueID() + protected function getUniqueID() { if (function_exists('posix_getpid')) { $baseUnique = posix_getpid(); @@ -314,12 +314,12 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase */ public function copyCellCollection(PHPExcel_Worksheet $parent) { - $this->_currentCellIsDirty; - $this->_storeData(); + $this->currentCellIsDirty; + $this->storeData(); - $this->_parent = $parent; - if (($this->_currentObject !== null) && (is_object($this->_currentObject))) { - $this->_currentObject->attach($this); + $this->parent = $parent; + if (($this->currentObject !== null) && (is_object($this->currentObject))) { + $this->currentObject->attach($this); } } // function copyCellCollection() diff --git a/Classes/PHPExcel/CachedObjectStorage/DiscISAM.php b/Classes/PHPExcel/CachedObjectStorage/DiscISAM.php index 65afa3cf..13bc0337 100644 --- a/Classes/PHPExcel/CachedObjectStorage/DiscISAM.php +++ b/Classes/PHPExcel/CachedObjectStorage/DiscISAM.php @@ -32,21 +32,21 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage * * @var string */ - private $_fileName = null; + private $fileName = null; /** * File handle for this cache file * * @var resource */ - private $_fileHandle = null; + private $fileHandle = null; /** * Directory/Folder where the cache file is located * * @var string */ - private $_cacheDirectory = null; + private $cacheDirectory = null; /** * Store cell data in cache for the current cell object if it's "dirty", @@ -55,20 +55,20 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage * @return void * @throws PHPExcel_Exception */ - protected function _storeData() + protected function storeData() { - if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { - $this->_currentObject->detach(); + if ($this->currentCellIsDirty && !empty($this->currentObjectID)) { + $this->currentObject->detach(); - fseek($this->_fileHandle, 0, SEEK_END); + fseek($this->fileHandle, 0, SEEK_END); - $this->_cellCache[$this->_currentObjectID] = array( - 'ptr' => ftell($this->_fileHandle), - 'sz' => fwrite($this->_fileHandle, serialize($this->_currentObject)) + $this->cellCache[$this->currentObjectID] = array( + 'ptr' => ftell($this->fileHandle), + 'sz' => fwrite($this->fileHandle, serialize($this->currentObject)) ); - $this->_currentCellIsDirty = false; + $this->currentCellIsDirty = false; } - $this->_currentObjectID = $this->_currentObject = null; + $this->currentObjectID = $this->currentObject = null; } /** @@ -81,13 +81,13 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { - if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { - $this->_storeData(); + if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) { + $this->storeData(); } - $this->_currentObjectID = $pCoord; - $this->_currentObject = $cell; - $this->_currentCellIsDirty = true; + $this->currentObjectID = $pCoord; + $this->currentObject = $cell; + $this->currentCellIsDirty = true; return $cell; } @@ -101,26 +101,26 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage */ public function getCacheData($pCoord) { - if ($pCoord === $this->_currentObjectID) { - return $this->_currentObject; + if ($pCoord === $this->currentObjectID) { + return $this->currentObject; } - $this->_storeData(); + $this->storeData(); // Check if the entry that has been requested actually exists - if (!isset($this->_cellCache[$pCoord])) { + if (!isset($this->cellCache[$pCoord])) { // Return null if requested entry doesn't exist in cache return null; } // Set current entry to the requested entry - $this->_currentObjectID = $pCoord; - fseek($this->_fileHandle, $this->_cellCache[$pCoord]['ptr']); - $this->_currentObject = unserialize(fread($this->_fileHandle, $this->_cellCache[$pCoord]['sz'])); + $this->currentObjectID = $pCoord; + fseek($this->fileHandle, $this->cellCache[$pCoord]['ptr']); + $this->currentObject = unserialize(fread($this->fileHandle, $this->cellCache[$pCoord]['sz'])); // Re-attach this as the cell's parent - $this->_currentObject->attach($this); + $this->currentObject->attach($this); // Return requested entry - return $this->_currentObject; + return $this->currentObject; } /** @@ -130,8 +130,8 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage */ public function getCellList() { - if ($this->_currentObjectID !== null) { - $this->_storeData(); + if ($this->currentObjectID !== null) { + $this->storeData(); } return parent::getCellList(); @@ -146,13 +146,13 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage { parent::copyCellCollection($parent); // Get a new id for the new file name - $baseUnique = $this->_getUniqueID(); - $newFileName = $this->_cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache'; + $baseUnique = $this->getUniqueID(); + $newFileName = $this->cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache'; // Copy the existing cell cache file - copy($this->_fileName, $newFileName); - $this->_fileName = $newFileName; + copy($this->fileName, $newFileName); + $this->fileName = $newFileName; // Open the copied cell cache file - $this->_fileHandle = fopen($this->_fileName, 'a+'); + $this->fileHandle = fopen($this->fileName, 'a+'); } /** @@ -161,14 +161,14 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage */ public function unsetWorksheetCells() { - if (!is_null($this->_currentObject)) { - $this->_currentObject->detach(); - $this->_currentObject = $this->_currentObjectID = null; + if (!is_null($this->currentObject)) { + $this->currentObject->detach(); + $this->currentObject = $this->currentObjectID = null; } - $this->_cellCache = array(); + $this->cellCache = array(); // detach ourself from the worksheet, so that it can then delete this object successfully - $this->_parent = null; + $this->parent = null; // Close down the temporary cache file $this->__destruct(); @@ -182,15 +182,15 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage */ public function __construct(PHPExcel_Worksheet $parent, $arguments) { - $this->_cacheDirectory = ((isset($arguments['dir'])) && ($arguments['dir'] !== null)) + $this->cacheDirectory = ((isset($arguments['dir'])) && ($arguments['dir'] !== null)) ? $arguments['dir'] : PHPExcel_Shared_File::sys_get_temp_dir(); parent::__construct($parent); - if (is_null($this->_fileHandle)) { - $baseUnique = $this->_getUniqueID(); - $this->_fileName = $this->_cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache'; - $this->_fileHandle = fopen($this->_fileName, 'a+'); + if (is_null($this->fileHandle)) { + $baseUnique = $this->getUniqueID(); + $this->fileName = $this->cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache'; + $this->fileHandle = fopen($this->fileName, 'a+'); } } @@ -199,10 +199,10 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage */ public function __destruct() { - if (!is_null($this->_fileHandle)) { - fclose($this->_fileHandle); - unlink($this->_fileName); + if (!is_null($this->fileHandle)) { + fclose($this->fileHandle); + unlink($this->fileName); } - $this->_fileHandle = null; + $this->fileHandle = null; } } diff --git a/Classes/PHPExcel/CachedObjectStorage/Igbinary.php b/Classes/PHPExcel/CachedObjectStorage/Igbinary.php index e49f3fca..5f3527b5 100644 --- a/Classes/PHPExcel/CachedObjectStorage/Igbinary.php +++ b/Classes/PHPExcel/CachedObjectStorage/Igbinary.php @@ -34,15 +34,15 @@ class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage * @return void * @throws PHPExcel_Exception */ - protected function _storeData() + protected function storeData() { - if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { - $this->_currentObject->detach(); + if ($this->currentCellIsDirty && !empty($this->currentObjectID)) { + $this->currentObject->detach(); - $this->_cellCache[$this->_currentObjectID] = igbinary_serialize($this->_currentObject); - $this->_currentCellIsDirty = false; + $this->cellCache[$this->currentObjectID] = igbinary_serialize($this->currentObject); + $this->currentCellIsDirty = false; } - $this->_currentObjectID = $this->_currentObject = null; + $this->currentObjectID = $this->currentObject = null; } // function _storeData() @@ -56,13 +56,13 @@ class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { - if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { - $this->_storeData(); + if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) { + $this->storeData(); } - $this->_currentObjectID = $pCoord; - $this->_currentObject = $cell; - $this->_currentCellIsDirty = true; + $this->currentObjectID = $pCoord; + $this->currentObject = $cell; + $this->currentCellIsDirty = true; return $cell; } // function addCacheData() @@ -77,25 +77,25 @@ class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage */ public function getCacheData($pCoord) { - if ($pCoord === $this->_currentObjectID) { - return $this->_currentObject; + if ($pCoord === $this->currentObjectID) { + return $this->currentObject; } - $this->_storeData(); + $this->storeData(); // Check if the entry that has been requested actually exists - if (!isset($this->_cellCache[$pCoord])) { + if (!isset($this->cellCache[$pCoord])) { // Return null if requested entry doesn't exist in cache return null; } // Set current entry to the requested entry - $this->_currentObjectID = $pCoord; - $this->_currentObject = igbinary_unserialize($this->_cellCache[$pCoord]); + $this->currentObjectID = $pCoord; + $this->currentObject = igbinary_unserialize($this->cellCache[$pCoord]); // Re-attach this as the cell's parent - $this->_currentObject->attach($this); + $this->currentObject->attach($this); // Return requested entry - return $this->_currentObject; + return $this->currentObject; } // function getCacheData() @@ -106,8 +106,8 @@ class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage */ public function getCellList() { - if ($this->_currentObjectID !== null) { - $this->_storeData(); + if ($this->currentObjectID !== null) { + $this->storeData(); } return parent::getCellList(); @@ -121,14 +121,14 @@ class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage */ public function unsetWorksheetCells() { - if (!is_null($this->_currentObject)) { - $this->_currentObject->detach(); - $this->_currentObject = $this->_currentObjectID = null; + if (!is_null($this->currentObject)) { + $this->currentObject->detach(); + $this->currentObject = $this->currentObjectID = null; } - $this->_cellCache = array(); + $this->cellCache = array(); // detach ourself from the worksheet, so that it can then delete this object successfully - $this->_parent = null; + $this->parent = null; } // function unsetWorksheetCells() diff --git a/Classes/PHPExcel/CachedObjectStorage/Memcache.php b/Classes/PHPExcel/CachedObjectStorage/Memcache.php index f3c3e1f0..07942cc3 100644 --- a/Classes/PHPExcel/CachedObjectStorage/Memcache.php +++ b/Classes/PHPExcel/CachedObjectStorage/Memcache.php @@ -32,21 +32,21 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage * * @var string */ - private $_cachePrefix = null; + private $cachePrefix = null; /** * Cache timeout * * @var integer */ - private $_cacheTime = 600; + private $cacheTime = 600; /** * Memcache interface * * @var resource */ - private $_memcache = null; + private $memcache = null; /** @@ -56,21 +56,21 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage * @return void * @throws PHPExcel_Exception */ - protected function _storeData() + protected function storeData() { - if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { - $this->_currentObject->detach(); + if ($this->currentCellIsDirty && !empty($this->currentObjectID)) { + $this->currentObject->detach(); - $obj = serialize($this->_currentObject); - if (!$this->_memcache->replace($this->_cachePrefix . $this->_currentObjectID . '.cache', $obj, null, $this->_cacheTime)) { - if (!$this->_memcache->add($this->_cachePrefix . $this->_currentObjectID . '.cache', $obj, null, $this->_cacheTime)) { + $obj = serialize($this->currentObject); + if (!$this->memcache->replace($this->cachePrefix . $this->currentObjectID . '.cache', $obj, null, $this->cacheTime)) { + if (!$this->memcache->add($this->cachePrefix . $this->currentObjectID . '.cache', $obj, null, $this->cacheTime)) { $this->__destruct(); - throw new PHPExcel_Exception("Failed to store cell {$this->_currentObjectID} in MemCache"); + throw new PHPExcel_Exception("Failed to store cell {$this->currentObjectID} in MemCache"); } } - $this->_currentCellIsDirty = false; + $this->currentCellIsDirty = false; } - $this->_currentObjectID = $this->_currentObject = null; + $this->currentObjectID = $this->currentObject = null; } // function _storeData() @@ -84,14 +84,14 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { - if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { - $this->_storeData(); + if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) { + $this->storeData(); } - $this->_cellCache[$pCoord] = true; + $this->cellCache[$pCoord] = true; - $this->_currentObjectID = $pCoord; - $this->_currentObject = $cell; - $this->_currentCellIsDirty = true; + $this->currentObjectID = $pCoord; + $this->currentObject = $cell; + $this->currentCellIsDirty = true; return $cell; } // function addCacheData() @@ -108,11 +108,11 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage { // Check if the requested entry is the current object, or exists in the cache if (parent::isDataSet($pCoord)) { - if ($this->_currentObjectID == $pCoord) { + if ($this->currentObjectID == $pCoord) { return true; } // Check if the requested entry still exists in Memcache - $success = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache'); + $success = $this->memcache->get($this->cachePrefix.$pCoord.'.cache'); if ($success === false) { // Entry no longer exists in Memcache, so clear it from the cache array parent::deleteCacheData($pCoord); @@ -133,14 +133,14 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage */ public function getCacheData($pCoord) { - if ($pCoord === $this->_currentObjectID) { - return $this->_currentObject; + if ($pCoord === $this->currentObjectID) { + return $this->currentObject; } - $this->_storeData(); + $this->storeData(); // Check if the entry that has been requested actually exists if (parent::isDataSet($pCoord)) { - $obj = $this->_memcache->get($this->_cachePrefix . $pCoord . '.cache'); + $obj = $this->memcache->get($this->cachePrefix . $pCoord . '.cache'); if ($obj === false) { // Entry no longer exists in Memcache, so clear it from the cache array parent::deleteCacheData($pCoord); @@ -152,13 +152,13 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage } // Set current entry to the requested entry - $this->_currentObjectID = $pCoord; - $this->_currentObject = unserialize($obj); + $this->currentObjectID = $pCoord; + $this->currentObject = unserialize($obj); // Re-attach this as the cell's parent - $this->_currentObject->attach($this); + $this->currentObject->attach($this); // Return requested entry - return $this->_currentObject; + return $this->currentObject; } /** @@ -168,8 +168,8 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage */ public function getCellList() { - if ($this->_currentObjectID !== null) { - $this->_storeData(); + if ($this->currentObjectID !== null) { + $this->storeData(); } return parent::getCellList(); @@ -184,7 +184,7 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage public function deleteCacheData($pCoord) { // Delete the entry from Memcache - $this->_memcache->delete($this->_cachePrefix . $pCoord . '.cache'); + $this->memcache->delete($this->cachePrefix . $pCoord . '.cache'); // Delete the entry from our cell address array parent::deleteCacheData($pCoord); @@ -200,24 +200,24 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage { parent::copyCellCollection($parent); // Get a new id for the new file name - $baseUnique = $this->_getUniqueID(); + $baseUnique = $this->getUniqueID(); $newCachePrefix = substr(md5($baseUnique), 0, 8) . '.'; $cacheList = $this->getCellList(); foreach ($cacheList as $cellID) { - if ($cellID != $this->_currentObjectID) { - $obj = $this->_memcache->get($this->_cachePrefix.$cellID.'.cache'); + if ($cellID != $this->currentObjectID) { + $obj = $this->memcache->get($this->cachePrefix.$cellID.'.cache'); if ($obj === false) { // Entry no longer exists in Memcache, so clear it from the cache array parent::deleteCacheData($cellID); throw new PHPExcel_Exception("Cell entry {$cellID} no longer exists in MemCache"); } - if (!$this->_memcache->add($newCachePrefix . $cellID . '.cache', $obj, null, $this->_cacheTime)) { + if (!$this->memcache->add($newCachePrefix . $cellID . '.cache', $obj, null, $this->cacheTime)) { $this->__destruct(); throw new PHPExcel_Exception("Failed to store cell {$cellID} in MemCache"); } } } - $this->_cachePrefix = $newCachePrefix; + $this->cachePrefix = $newCachePrefix; } /** @@ -227,18 +227,18 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage */ public function unsetWorksheetCells() { - if (!is_null($this->_currentObject)) { - $this->_currentObject->detach(); - $this->_currentObject = $this->_currentObjectID = null; + if (!is_null($this->currentObject)) { + $this->currentObject->detach(); + $this->currentObject = $this->currentObjectID = null; } // Flush the Memcache cache $this->__destruct(); - $this->_cellCache = array(); + $this->cellCache = array(); // detach ourself from the worksheet, so that it can then delete this object successfully - $this->_parent = null; + $this->parent = null; } /** @@ -253,16 +253,16 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage $memcachePort = (isset($arguments['memcachePort'])) ? $arguments['memcachePort'] : 11211; $cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600; - if (is_null($this->_cachePrefix)) { - $baseUnique = $this->_getUniqueID(); - $this->_cachePrefix = substr(md5($baseUnique), 0, 8) . '.'; + if (is_null($this->cachePrefix)) { + $baseUnique = $this->getUniqueID(); + $this->cachePrefix = substr(md5($baseUnique), 0, 8) . '.'; // Set a new Memcache object and connect to the Memcache server - $this->_memcache = new Memcache(); - if (!$this->_memcache->addServer($memcacheServer, $memcachePort, false, 50, 5, 5, true, array($this, 'failureCallback'))) { + $this->memcache = new Memcache(); + if (!$this->memcache->addServer($memcacheServer, $memcachePort, false, 50, 5, 5, true, array($this, 'failureCallback'))) { throw new PHPExcel_Exception("Could not connect to MemCache server at {$memcacheServer}:{$memcachePort}"); } - $this->_cacheTime = $cacheTime; + $this->cacheTime = $cacheTime; parent::__construct($parent); } @@ -287,7 +287,7 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage { $cacheList = $this->getCellList(); foreach ($cacheList as $cellID) { - $this->_memcache->delete($this->_cachePrefix.$cellID . '.cache'); + $this->memcache->delete($this->cachePrefix.$cellID . '.cache'); } } diff --git a/Classes/PHPExcel/CachedObjectStorage/Memory.php b/Classes/PHPExcel/CachedObjectStorage/Memory.php index aa3e1bb3..0e2ea0b0 100644 --- a/Classes/PHPExcel/CachedObjectStorage/Memory.php +++ b/Classes/PHPExcel/CachedObjectStorage/Memory.php @@ -32,7 +32,7 @@ class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_C * * @return void */ - protected function _storeData() + protected function storeData() { } @@ -46,10 +46,10 @@ class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_C */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { - $this->_cellCache[$pCoord] = $cell; + $this->cellCache[$pCoord] = $cell; // Set current entry to the new/updated entry - $this->_currentObjectID = $pCoord; + $this->currentObjectID = $pCoord; return $cell; } @@ -65,17 +65,17 @@ class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_C public function getCacheData($pCoord) { // Check if the entry that has been requested actually exists - if (!isset($this->_cellCache[$pCoord])) { - $this->_currentObjectID = null; + if (!isset($this->cellCache[$pCoord])) { + $this->currentObjectID = null; // Return null if requested entry doesn't exist in cache return null; } // Set current entry to the requested entry - $this->_currentObjectID = $pCoord; + $this->currentObjectID = $pCoord; // Return requested entry - return $this->_cellCache[$pCoord]; + return $this->cellCache[$pCoord]; } @@ -89,12 +89,12 @@ class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_C parent::copyCellCollection($parent); $newCollection = array(); - foreach ($this->_cellCache as $k => &$cell) { + foreach ($this->cellCache as $k => &$cell) { $newCollection[$k] = clone $cell; $newCollection[$k]->attach($this); } - $this->_cellCache = $newCollection; + $this->cellCache = $newCollection; } /** @@ -104,15 +104,15 @@ class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_C public function unsetWorksheetCells() { // Because cells are all stored as intact objects in memory, we need to detach each one from the parent - foreach ($this->_cellCache as $k => &$cell) { + foreach ($this->cellCache as $k => &$cell) { $cell->detach(); - $this->_cellCache[$k] = null; + $this->cellCache[$k] = null; } unset($cell); - $this->_cellCache = array(); + $this->cellCache = array(); // detach ourself from the worksheet, so that it can then delete this object successfully - $this->_parent = null; + $this->parent = null; } } diff --git a/Classes/PHPExcel/CachedObjectStorage/MemoryGZip.php b/Classes/PHPExcel/CachedObjectStorage/MemoryGZip.php index 16f01051..c06ec714 100644 --- a/Classes/PHPExcel/CachedObjectStorage/MemoryGZip.php +++ b/Classes/PHPExcel/CachedObjectStorage/MemoryGZip.php @@ -34,15 +34,15 @@ class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStora * @return void * @throws PHPExcel_Exception */ - protected function _storeData() + protected function storeData() { - if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { - $this->_currentObject->detach(); + if ($this->currentCellIsDirty && !empty($this->currentObjectID)) { + $this->currentObject->detach(); - $this->_cellCache[$this->_currentObjectID] = gzdeflate(serialize($this->_currentObject)); - $this->_currentCellIsDirty = false; + $this->cellCache[$this->currentObjectID] = gzdeflate(serialize($this->currentObject)); + $this->currentCellIsDirty = false; } - $this->_currentObjectID = $this->_currentObject = null; + $this->currentObjectID = $this->currentObject = null; } @@ -56,13 +56,13 @@ class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStora */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { - if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { - $this->_storeData(); + if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) { + $this->storeData(); } - $this->_currentObjectID = $pCoord; - $this->_currentObject = $cell; - $this->_currentCellIsDirty = true; + $this->currentObjectID = $pCoord; + $this->currentObject = $cell; + $this->currentCellIsDirty = true; return $cell; } @@ -77,25 +77,25 @@ class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStora */ public function getCacheData($pCoord) { - if ($pCoord === $this->_currentObjectID) { - return $this->_currentObject; + if ($pCoord === $this->currentObjectID) { + return $this->currentObject; } - $this->_storeData(); + $this->storeData(); // Check if the entry that has been requested actually exists - if (!isset($this->_cellCache[$pCoord])) { + if (!isset($this->cellCache[$pCoord])) { // Return null if requested entry doesn't exist in cache return null; } // Set current entry to the requested entry - $this->_currentObjectID = $pCoord; - $this->_currentObject = unserialize(gzinflate($this->_cellCache[$pCoord])); + $this->currentObjectID = $pCoord; + $this->currentObject = unserialize(gzinflate($this->cellCache[$pCoord])); // Re-attach this as the cell's parent - $this->_currentObject->attach($this); + $this->currentObject->attach($this); // Return requested entry - return $this->_currentObject; + return $this->currentObject; } @@ -106,8 +106,8 @@ class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStora */ public function getCellList() { - if ($this->_currentObjectID !== null) { - $this->_storeData(); + if ($this->currentObjectID !== null) { + $this->storeData(); } return parent::getCellList(); @@ -121,13 +121,13 @@ class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStora */ public function unsetWorksheetCells() { - if (!is_null($this->_currentObject)) { - $this->_currentObject->detach(); - $this->_currentObject = $this->_currentObjectID = null; + if (!is_null($this->currentObject)) { + $this->currentObject->detach(); + $this->currentObject = $this->currentObjectID = null; } - $this->_cellCache = array(); + $this->cellCache = array(); // detach ourself from the worksheet, so that it can then delete this object successfully - $this->_parent = null; + $this->parent = null; } } diff --git a/Classes/PHPExcel/CachedObjectStorage/MemorySerialized.php b/Classes/PHPExcel/CachedObjectStorage/MemorySerialized.php index 285d0d8f..13325149 100644 --- a/Classes/PHPExcel/CachedObjectStorage/MemorySerialized.php +++ b/Classes/PHPExcel/CachedObjectStorage/MemorySerialized.php @@ -34,15 +34,15 @@ class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjec * @return void * @throws PHPExcel_Exception */ - protected function _storeData() + protected function storeData() { - if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { - $this->_currentObject->detach(); + if ($this->currentCellIsDirty && !empty($this->currentObjectID)) { + $this->currentObject->detach(); - $this->_cellCache[$this->_currentObjectID] = serialize($this->_currentObject); - $this->_currentCellIsDirty = false; + $this->cellCache[$this->currentObjectID] = serialize($this->currentObject); + $this->currentCellIsDirty = false; } - $this->_currentObjectID = $this->_currentObject = null; + $this->currentObjectID = $this->currentObject = null; } /** @@ -55,13 +55,13 @@ class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjec */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { - if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { - $this->_storeData(); + if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) { + $this->storeData(); } - $this->_currentObjectID = $pCoord; - $this->_currentObject = $cell; - $this->_currentCellIsDirty = true; + $this->currentObjectID = $pCoord; + $this->currentObject = $cell; + $this->currentCellIsDirty = true; return $cell; } @@ -75,25 +75,25 @@ class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjec */ public function getCacheData($pCoord) { - if ($pCoord === $this->_currentObjectID) { - return $this->_currentObject; + if ($pCoord === $this->currentObjectID) { + return $this->currentObject; } - $this->_storeData(); + $this->storeData(); // Check if the entry that has been requested actually exists - if (!isset($this->_cellCache[$pCoord])) { + if (!isset($this->cellCache[$pCoord])) { // Return null if requested entry doesn't exist in cache return null; } // Set current entry to the requested entry - $this->_currentObjectID = $pCoord; - $this->_currentObject = unserialize($this->_cellCache[$pCoord]); + $this->currentObjectID = $pCoord; + $this->currentObject = unserialize($this->cellCache[$pCoord]); // Re-attach this as the cell's parent - $this->_currentObject->attach($this); + $this->currentObject->attach($this); // Return requested entry - return $this->_currentObject; + return $this->currentObject; } /** @@ -103,8 +103,8 @@ class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjec */ public function getCellList() { - if ($this->_currentObjectID !== null) { - $this->_storeData(); + if ($this->currentObjectID !== null) { + $this->storeData(); } return parent::getCellList(); @@ -117,13 +117,13 @@ class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjec */ public function unsetWorksheetCells() { - if (!is_null($this->_currentObject)) { - $this->_currentObject->detach(); - $this->_currentObject = $this->_currentObjectID = null; + if (!is_null($this->currentObject)) { + $this->currentObject->detach(); + $this->currentObject = $this->currentObjectID = null; } - $this->_cellCache = array(); + $this->cellCache = array(); // detach ourself from the worksheet, so that it can then delete this object successfully - $this->_parent = null; + $this->parent = null; } } diff --git a/Classes/PHPExcel/CachedObjectStorage/PHPTemp.php b/Classes/PHPExcel/CachedObjectStorage/PHPTemp.php index 6176bf1e..43c78197 100644 --- a/Classes/PHPExcel/CachedObjectStorage/PHPTemp.php +++ b/Classes/PHPExcel/CachedObjectStorage/PHPTemp.php @@ -32,14 +32,14 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_ * * @var string */ - private $_fileHandle = null; + private $fileHandle = null; /** * Memory limit to use before reverting to file cache * * @var integer */ - private $_memoryCacheSize = null; + private $memoryCacheSize = null; /** * Store cell data in cache for the current cell object if it's "dirty", @@ -48,20 +48,20 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_ * @return void * @throws PHPExcel_Exception */ - protected function _storeData() + protected function storeData() { - if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { - $this->_currentObject->detach(); + if ($this->currentCellIsDirty && !empty($this->currentObjectID)) { + $this->currentObject->detach(); - fseek($this->_fileHandle, 0, SEEK_END); + fseek($this->fileHandle, 0, SEEK_END); - $this->_cellCache[$this->_currentObjectID] = array( - 'ptr' => ftell($this->_fileHandle), - 'sz' => fwrite($this->_fileHandle, serialize($this->_currentObject)) + $this->cellCache[$this->currentObjectID] = array( + 'ptr' => ftell($this->fileHandle), + 'sz' => fwrite($this->fileHandle, serialize($this->currentObject)) ); - $this->_currentCellIsDirty = false; + $this->currentCellIsDirty = false; } - $this->_currentObjectID = $this->_currentObject = null; + $this->currentObjectID = $this->currentObject = null; } @@ -75,13 +75,13 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_ */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { - if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { - $this->_storeData(); + if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) { + $this->storeData(); } - $this->_currentObjectID = $pCoord; - $this->_currentObject = $cell; - $this->_currentCellIsDirty = true; + $this->currentObjectID = $pCoord; + $this->currentObject = $cell; + $this->currentCellIsDirty = true; return $cell; } @@ -96,26 +96,26 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_ */ public function getCacheData($pCoord) { - if ($pCoord === $this->_currentObjectID) { - return $this->_currentObject; + if ($pCoord === $this->currentObjectID) { + return $this->currentObject; } - $this->_storeData(); + $this->storeData(); // Check if the entry that has been requested actually exists - if (!isset($this->_cellCache[$pCoord])) { + if (!isset($this->cellCache[$pCoord])) { // Return null if requested entry doesn't exist in cache return null; } // Set current entry to the requested entry - $this->_currentObjectID = $pCoord; - fseek($this->_fileHandle, $this->_cellCache[$pCoord]['ptr']); - $this->_currentObject = unserialize(fread($this->_fileHandle, $this->_cellCache[$pCoord]['sz'])); + $this->currentObjectID = $pCoord; + fseek($this->fileHandle, $this->cellCache[$pCoord]['ptr']); + $this->currentObject = unserialize(fread($this->fileHandle, $this->cellCache[$pCoord]['sz'])); // Re-attach this as the cell's parent - $this->_currentObject->attach($this); + $this->currentObject->attach($this); // Return requested entry - return $this->_currentObject; + return $this->currentObject; } /** @@ -125,8 +125,8 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_ */ public function getCellList() { - if ($this->_currentObjectID !== null) { - $this->_storeData(); + if ($this->currentObjectID !== null) { + $this->storeData(); } return parent::getCellList(); @@ -142,13 +142,13 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_ { parent::copyCellCollection($parent); // Open a new stream for the cell cache data - $newFileHandle = fopen('php://temp/maxmemory:' . $this->_memoryCacheSize, 'a+'); + $newFileHandle = fopen('php://temp/maxmemory:' . $this->memoryCacheSize, 'a+'); // Copy the existing cell cache data to the new stream - fseek($this->_fileHandle, 0); - while (!feof($this->_fileHandle)) { - fwrite($newFileHandle, fread($this->_fileHandle, 1024)); + fseek($this->fileHandle, 0); + while (!feof($this->fileHandle)) { + fwrite($newFileHandle, fread($this->fileHandle, 1024)); } - $this->_fileHandle = $newFileHandle; + $this->fileHandle = $newFileHandle; } /** @@ -158,14 +158,14 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_ */ public function unsetWorksheetCells() { - if (!is_null($this->_currentObject)) { - $this->_currentObject->detach(); - $this->_currentObject = $this->_currentObjectID = null; + if (!is_null($this->currentObject)) { + $this->currentObject->detach(); + $this->currentObject = $this->currentObjectID = null; } - $this->_cellCache = array(); + $this->cellCache = array(); // detach ourself from the worksheet, so that it can then delete this object successfully - $this->_parent = null; + $this->parent = null; // Close down the php://temp file $this->__destruct(); @@ -179,11 +179,11 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_ */ public function __construct(PHPExcel_Worksheet $parent, $arguments) { - $this->_memoryCacheSize = (isset($arguments['memoryCacheSize'])) ? $arguments['memoryCacheSize'] : '1MB'; + $this->memoryCacheSize = (isset($arguments['memoryCacheSize'])) ? $arguments['memoryCacheSize'] : '1MB'; parent::__construct($parent); - if (is_null($this->_fileHandle)) { - $this->_fileHandle = fopen('php://temp/maxmemory:' . $this->_memoryCacheSize, 'a+'); + if (is_null($this->fileHandle)) { + $this->fileHandle = fopen('php://temp/maxmemory:' . $this->memoryCacheSize, 'a+'); } } @@ -192,9 +192,9 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_ */ public function __destruct() { - if (!is_null($this->_fileHandle)) { - fclose($this->_fileHandle); + if (!is_null($this->fileHandle)) { + fclose($this->fileHandle); } - $this->_fileHandle = null; + $this->fileHandle = null; } } diff --git a/Classes/PHPExcel/CachedObjectStorage/SQLite.php b/Classes/PHPExcel/CachedObjectStorage/SQLite.php index 0a63cd2d..e7b50c5b 100644 --- a/Classes/PHPExcel/CachedObjectStorage/SQLite.php +++ b/Classes/PHPExcel/CachedObjectStorage/SQLite.php @@ -32,14 +32,14 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C * * @var string */ - private $_TableName = null; + private $TableName = null; /** * Database handle * * @var resource */ - private $_DBHandle = null; + private $DBHandle = null; /** * Store cell data in cache for the current cell object if it's "dirty", @@ -48,17 +48,17 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C * @return void * @throws PHPExcel_Exception */ - protected function _storeData() + protected function storeData() { - if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { - $this->_currentObject->detach(); + if ($this->currentCellIsDirty && !empty($this->currentObjectID)) { + $this->currentObject->detach(); - if (!$this->_DBHandle->queryExec("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES('".$this->_currentObjectID."','".sqlite_escape_string(serialize($this->_currentObject))."')")) { - throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); + if (!$this->DBHandle->queryExec("INSERT OR REPLACE INTO kvp_".$this->TableName." VALUES('".$this->currentObjectID."','".sqlite_escape_string(serialize($this->currentObject))."')")) { + throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError())); } - $this->_currentCellIsDirty = false; + $this->currentCellIsDirty = false; } - $this->_currentObjectID = $this->_currentObject = null; + $this->currentObjectID = $this->currentObject = null; } /** @@ -71,13 +71,13 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { - if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { - $this->_storeData(); + if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) { + $this->storeData(); } - $this->_currentObjectID = $pCoord; - $this->_currentObject = $cell; - $this->_currentCellIsDirty = true; + $this->currentObjectID = $pCoord; + $this->currentObject = $cell; + $this->currentCellIsDirty = true; return $cell; } @@ -91,30 +91,30 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C */ public function getCacheData($pCoord) { - if ($pCoord === $this->_currentObjectID) { - return $this->_currentObject; + if ($pCoord === $this->currentObjectID) { + return $this->currentObject; } - $this->_storeData(); + $this->storeData(); - $query = "SELECT value FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'"; - $cellResultSet = $this->_DBHandle->query($query, SQLITE_ASSOC); + $query = "SELECT value FROM kvp_".$this->TableName." WHERE id='".$pCoord."'"; + $cellResultSet = $this->DBHandle->query($query, SQLITE_ASSOC); if ($cellResultSet === false) { - throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); + throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError())); } elseif ($cellResultSet->numRows() == 0) { // Return null if requested entry doesn't exist in cache return null; } // Set current entry to the requested entry - $this->_currentObjectID = $pCoord; + $this->currentObjectID = $pCoord; $cellResult = $cellResultSet->fetchSingle(); - $this->_currentObject = unserialize($cellResult); + $this->currentObject = unserialize($cellResult); // Re-attach this as the cell's parent - $this->_currentObject->attach($this); + $this->currentObject->attach($this); // Return requested entry - return $this->_currentObject; + return $this->currentObject; } /** @@ -125,15 +125,15 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C */ public function isDataSet($pCoord) { - if ($pCoord === $this->_currentObjectID) { + if ($pCoord === $this->currentObjectID) { return true; } // Check if the requested entry exists in the cache - $query = "SELECT id FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'"; - $cellResultSet = $this->_DBHandle->query($query, SQLITE_ASSOC); + $query = "SELECT id FROM kvp_".$this->TableName." WHERE id='".$pCoord."'"; + $cellResultSet = $this->DBHandle->query($query, SQLITE_ASSOC); if ($cellResultSet === false) { - throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); + throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError())); } elseif ($cellResultSet->numRows() == 0) { // Return null if requested entry doesn't exist in cache return false; @@ -149,18 +149,18 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C */ public function deleteCacheData($pCoord) { - if ($pCoord === $this->_currentObjectID) { - $this->_currentObject->detach(); - $this->_currentObjectID = $this->_currentObject = null; + if ($pCoord === $this->currentObjectID) { + $this->currentObject->detach(); + $this->currentObjectID = $this->currentObject = null; } // Check if the requested entry exists in the cache - $query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'"; - if (!$this->_DBHandle->queryExec($query)) { - throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); + $query = "DELETE FROM kvp_".$this->TableName." WHERE id='".$pCoord."'"; + if (!$this->DBHandle->queryExec($query)) { + throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError())); } - $this->_currentCellIsDirty = false; + $this->currentCellIsDirty = false; } /** @@ -172,20 +172,20 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C */ public function moveCell($fromAddress, $toAddress) { - if ($fromAddress === $this->_currentObjectID) { - $this->_currentObjectID = $toAddress; + if ($fromAddress === $this->currentObjectID) { + $this->currentObjectID = $toAddress; } - $query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$toAddress."'"; - $result = $this->_DBHandle->exec($query); + $query = "DELETE FROM kvp_".$this->TableName." WHERE id='".$toAddress."'"; + $result = $this->DBHandle->exec($query); if ($result === false) { - throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); + throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg()); } - $query = "UPDATE kvp_".$this->_TableName." SET id='".$toAddress."' WHERE id='".$fromAddress."'"; - $result = $this->_DBHandle->exec($query); + $query = "UPDATE kvp_".$this->TableName." SET id='".$toAddress."' WHERE id='".$fromAddress."'"; + $result = $this->DBHandle->exec($query); if ($result === false) { - throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); + throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg()); } return true; @@ -198,14 +198,14 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C */ public function getCellList() { - if ($this->_currentObjectID !== null) { - $this->_storeData(); + if ($this->currentObjectID !== null) { + $this->storeData(); } - $query = "SELECT id FROM kvp_".$this->_TableName; - $cellIdsResult = $this->_DBHandle->unbufferedQuery($query, SQLITE_ASSOC); + $query = "SELECT id FROM kvp_".$this->TableName; + $cellIdsResult = $this->DBHandle->unbufferedQuery($query, SQLITE_ASSOC); if ($cellIdsResult === false) { - throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); + throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError())); } $cellKeys = array(); @@ -224,19 +224,19 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C */ public function copyCellCollection(PHPExcel_Worksheet $parent) { - $this->_currentCellIsDirty; - $this->_storeData(); + $this->currentCellIsDirty; + $this->storeData(); // Get a new id for the new table name - $tableName = str_replace('.', '_', $this->_getUniqueID()); - if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB) - AS SELECT * FROM kvp_'.$this->_TableName) + $tableName = str_replace('.', '_', $this->getUniqueID()); + if (!$this->DBHandle->queryExec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB) + AS SELECT * FROM kvp_'.$this->TableName) ) { - throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); + throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError())); } // Copy the existing cell cache file - $this->_TableName = $tableName; + $this->TableName = $tableName; } /** @@ -246,12 +246,12 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C */ public function unsetWorksheetCells() { - if (!is_null($this->_currentObject)) { - $this->_currentObject->detach(); - $this->_currentObject = $this->_currentObjectID = null; + if (!is_null($this->currentObject)) { + $this->currentObject->detach(); + $this->currentObject = $this->currentObjectID = null; } // detach ourself from the worksheet, so that it can then delete this object successfully - $this->_parent = null; + $this->parent = null; // Close down the temporary cache file $this->__destruct(); @@ -265,16 +265,16 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C public function __construct(PHPExcel_Worksheet $parent) { parent::__construct($parent); - if (is_null($this->_DBHandle)) { - $this->_TableName = str_replace('.', '_', $this->_getUniqueID()); + if (is_null($this->DBHandle)) { + $this->TableName = str_replace('.', '_', $this->getUniqueID()); $_DBName = ':memory:'; - $this->_DBHandle = new SQLiteDatabase($_DBName); - if ($this->_DBHandle === false) { - throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); + $this->DBHandle = new SQLiteDatabase($_DBName); + if ($this->DBHandle === false) { + throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError())); } - if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) { - throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); + if (!$this->DBHandle->queryExec('CREATE TABLE kvp_'.$this->TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) { + throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError())); } } } @@ -284,10 +284,10 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C */ public function __destruct() { - if (!is_null($this->_DBHandle)) { - $this->_DBHandle->queryExec('DROP TABLE kvp_'.$this->_TableName); + if (!is_null($this->DBHandle)) { + $this->DBHandle->queryExec('DROP TABLE kvp_'.$this->TableName); } - $this->_DBHandle = null; + $this->DBHandle = null; } /** diff --git a/Classes/PHPExcel/CachedObjectStorage/SQLite3.php b/Classes/PHPExcel/CachedObjectStorage/SQLite3.php index 4d013eff..27473d6c 100644 --- a/Classes/PHPExcel/CachedObjectStorage/SQLite3.php +++ b/Classes/PHPExcel/CachedObjectStorage/SQLite3.php @@ -32,42 +32,42 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_ * * @var string */ - private $_TableName = null; + private $TableName = null; /** * Database handle * * @var resource */ - private $_DBHandle = null; + private $DBHandle = null; /** * Prepared statement for a SQLite3 select query * * @var SQLite3Stmt */ - private $_selectQuery; + private $selectQuery; /** * Prepared statement for a SQLite3 insert query * * @var SQLite3Stmt */ - private $_insertQuery; + private $insertQuery; /** * Prepared statement for a SQLite3 update query * * @var SQLite3Stmt */ - private $_updateQuery; + private $updateQuery; /** * Prepared statement for a SQLite3 delete query * * @var SQLite3Stmt */ - private $_deleteQuery; + private $deleteQuery; /** * Store cell data in cache for the current cell object if it's "dirty", @@ -76,20 +76,20 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_ * @return void * @throws PHPExcel_Exception */ - protected function _storeData() + protected function storeData() { - if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { - $this->_currentObject->detach(); + if ($this->currentCellIsDirty && !empty($this->currentObjectID)) { + $this->currentObject->detach(); - $this->_insertQuery->bindValue('id', $this->_currentObjectID, SQLITE3_TEXT); - $this->_insertQuery->bindValue('data', serialize($this->_currentObject), SQLITE3_BLOB); - $result = $this->_insertQuery->execute(); + $this->insertQuery->bindValue('id', $this->currentObjectID, SQLITE3_TEXT); + $this->insertQuery->bindValue('data', serialize($this->currentObject), SQLITE3_BLOB); + $result = $this->insertQuery->execute(); if ($result === false) { - throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); + throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg()); } - $this->_currentCellIsDirty = false; + $this->currentCellIsDirty = false; } - $this->_currentObjectID = $this->_currentObject = null; + $this->currentObjectID = $this->currentObject = null; } /** @@ -102,13 +102,13 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_ */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { - if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { - $this->_storeData(); + if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) { + $this->storeData(); } - $this->_currentObjectID = $pCoord; - $this->_currentObject = $cell; - $this->_currentCellIsDirty = true; + $this->currentObjectID = $pCoord; + $this->currentObject = $cell; + $this->currentCellIsDirty = true; return $cell; } @@ -122,15 +122,15 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_ */ public function getCacheData($pCoord) { - if ($pCoord === $this->_currentObjectID) { - return $this->_currentObject; + if ($pCoord === $this->currentObjectID) { + return $this->currentObject; } - $this->_storeData(); + $this->storeData(); - $this->_selectQuery->bindValue('id', $pCoord, SQLITE3_TEXT); - $cellResult = $this->_selectQuery->execute(); + $this->selectQuery->bindValue('id', $pCoord, SQLITE3_TEXT); + $cellResult = $this->selectQuery->execute(); if ($cellResult === false) { - throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); + throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg()); } $cellData = $cellResult->fetchArray(SQLITE3_ASSOC); if ($cellData === false) { @@ -139,14 +139,14 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_ } // Set current entry to the requested entry - $this->_currentObjectID = $pCoord; + $this->currentObjectID = $pCoord; - $this->_currentObject = unserialize($cellData['value']); + $this->currentObject = unserialize($cellData['value']); // Re-attach this as the cell's parent - $this->_currentObject->attach($this); + $this->currentObject->attach($this); // Return requested entry - return $this->_currentObject; + return $this->currentObject; } /** @@ -157,15 +157,15 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_ */ public function isDataSet($pCoord) { - if ($pCoord === $this->_currentObjectID) { + if ($pCoord === $this->currentObjectID) { return true; } // Check if the requested entry exists in the cache - $this->_selectQuery->bindValue('id', $pCoord, SQLITE3_TEXT); - $cellResult = $this->_selectQuery->execute(); + $this->selectQuery->bindValue('id', $pCoord, SQLITE3_TEXT); + $cellResult = $this->selectQuery->execute(); if ($cellResult === false) { - throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); + throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg()); } $cellData = $cellResult->fetchArray(SQLITE3_ASSOC); @@ -180,19 +180,19 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_ */ public function deleteCacheData($pCoord) { - if ($pCoord === $this->_currentObjectID) { - $this->_currentObject->detach(); - $this->_currentObjectID = $this->_currentObject = null; + if ($pCoord === $this->currentObjectID) { + $this->currentObject->detach(); + $this->currentObjectID = $this->currentObject = null; } // Check if the requested entry exists in the cache - $this->_deleteQuery->bindValue('id', $pCoord, SQLITE3_TEXT); - $result = $this->_deleteQuery->execute(); + $this->deleteQuery->bindValue('id', $pCoord, SQLITE3_TEXT); + $result = $this->deleteQuery->execute(); if ($result === false) { - throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); + throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg()); } - $this->_currentCellIsDirty = false; + $this->currentCellIsDirty = false; } /** @@ -204,21 +204,21 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_ */ public function moveCell($fromAddress, $toAddress) { - if ($fromAddress === $this->_currentObjectID) { - $this->_currentObjectID = $toAddress; + if ($fromAddress === $this->currentObjectID) { + $this->currentObjectID = $toAddress; } - $this->_deleteQuery->bindValue('id', $toAddress, SQLITE3_TEXT); - $result = $this->_deleteQuery->execute(); + $this->deleteQuery->bindValue('id', $toAddress, SQLITE3_TEXT); + $result = $this->deleteQuery->execute(); if ($result === false) { - throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); + throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg()); } - $this->_updateQuery->bindValue('toid', $toAddress, SQLITE3_TEXT); - $this->_updateQuery->bindValue('fromid', $fromAddress, SQLITE3_TEXT); - $result = $this->_updateQuery->execute(); + $this->updateQuery->bindValue('toid', $toAddress, SQLITE3_TEXT); + $this->updateQuery->bindValue('fromid', $fromAddress, SQLITE3_TEXT); + $result = $this->updateQuery->execute(); if ($result === false) { - throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); + throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg()); } return true; @@ -231,14 +231,14 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_ */ public function getCellList() { - if ($this->_currentObjectID !== null) { - $this->_storeData(); + if ($this->currentObjectID !== null) { + $this->storeData(); } - $query = "SELECT id FROM kvp_".$this->_TableName; - $cellIdsResult = $this->_DBHandle->query($query); + $query = "SELECT id FROM kvp_".$this->TableName; + $cellIdsResult = $this->DBHandle->query($query); if ($cellIdsResult === false) { - throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); + throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg()); } $cellKeys = array(); @@ -257,19 +257,19 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_ */ public function copyCellCollection(PHPExcel_Worksheet $parent) { - $this->_currentCellIsDirty; - $this->_storeData(); + $this->currentCellIsDirty; + $this->storeData(); // Get a new id for the new table name - $tableName = str_replace('.', '_', $this->_getUniqueID()); - if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB) - AS SELECT * FROM kvp_'.$this->_TableName) + $tableName = str_replace('.', '_', $this->getUniqueID()); + if (!$this->DBHandle->exec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB) + AS SELECT * FROM kvp_'.$this->TableName) ) { - throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); + throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg()); } // Copy the existing cell cache file - $this->_TableName = $tableName; + $this->TableName = $tableName; } /** @@ -279,12 +279,12 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_ */ public function unsetWorksheetCells() { - if (!is_null($this->_currentObject)) { - $this->_currentObject->detach(); - $this->_currentObject = $this->_currentObjectID = null; + if (!is_null($this->currentObject)) { + $this->currentObject->detach(); + $this->currentObject = $this->currentObjectID = null; } // detach ourself from the worksheet, so that it can then delete this object successfully - $this->_parent = null; + $this->parent = null; // Close down the temporary cache file $this->__destruct(); @@ -298,23 +298,23 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_ public function __construct(PHPExcel_Worksheet $parent) { parent::__construct($parent); - if (is_null($this->_DBHandle)) { - $this->_TableName = str_replace('.', '_', $this->_getUniqueID()); + if (is_null($this->DBHandle)) { + $this->TableName = str_replace('.', '_', $this->getUniqueID()); $_DBName = ':memory:'; - $this->_DBHandle = new SQLite3($_DBName); - if ($this->_DBHandle === false) { - throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); + $this->DBHandle = new SQLite3($_DBName); + if ($this->DBHandle === false) { + throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg()); } - if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) { - throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); + if (!$this->DBHandle->exec('CREATE TABLE kvp_'.$this->TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) { + throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg()); } } - $this->_selectQuery = $this->_DBHandle->prepare("SELECT value FROM kvp_".$this->_TableName." WHERE id = :id"); - $this->_insertQuery = $this->_DBHandle->prepare("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES(:id,:data)"); - $this->_updateQuery = $this->_DBHandle->prepare("UPDATE kvp_".$this->_TableName." SET id=:toId WHERE id=:fromId"); - $this->_deleteQuery = $this->_DBHandle->prepare("DELETE FROM kvp_".$this->_TableName." WHERE id = :id"); + $this->selectQuery = $this->DBHandle->prepare("SELECT value FROM kvp_".$this->TableName." WHERE id = :id"); + $this->insertQuery = $this->DBHandle->prepare("INSERT OR REPLACE INTO kvp_".$this->TableName." VALUES(:id,:data)"); + $this->updateQuery = $this->DBHandle->prepare("UPDATE kvp_".$this->TableName." SET id=:toId WHERE id=:fromId"); + $this->deleteQuery = $this->DBHandle->prepare("DELETE FROM kvp_".$this->TableName." WHERE id = :id"); } /** @@ -322,11 +322,11 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_ */ public function __destruct() { - if (!is_null($this->_DBHandle)) { - $this->_DBHandle->exec('DROP TABLE kvp_'.$this->_TableName); - $this->_DBHandle->close(); + if (!is_null($this->DBHandle)) { + $this->DBHandle->exec('DROP TABLE kvp_'.$this->TableName); + $this->DBHandle->close(); } - $this->_DBHandle = null; + $this->DBHandle = null; } /** diff --git a/Classes/PHPExcel/CachedObjectStorage/Wincache.php b/Classes/PHPExcel/CachedObjectStorage/Wincache.php index 5b1fc43d..1567874f 100644 --- a/Classes/PHPExcel/CachedObjectStorage/Wincache.php +++ b/Classes/PHPExcel/CachedObjectStorage/Wincache.php @@ -32,14 +32,14 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage * * @var string */ - private $_cachePrefix = null; + private $cachePrefix = null; /** * Cache timeout * * @var integer */ - private $_cacheTime = 600; + private $cacheTime = 600; /** @@ -49,27 +49,27 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage * @return void * @throws PHPExcel_Exception */ - protected function _storeData() + protected function storeData() { - if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { - $this->_currentObject->detach(); + if ($this->currentCellIsDirty && !empty($this->currentObjectID)) { + $this->currentObject->detach(); - $obj = serialize($this->_currentObject); - if (wincache_ucache_exists($this->_cachePrefix.$this->_currentObjectID.'.cache')) { - if (!wincache_ucache_set($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) { + $obj = serialize($this->currentObject); + if (wincache_ucache_exists($this->cachePrefix.$this->currentObjectID.'.cache')) { + if (!wincache_ucache_set($this->cachePrefix.$this->currentObjectID.'.cache', $obj, $this->cacheTime)) { $this->__destruct(); - throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in WinCache'); + throw new PHPExcel_Exception('Failed to store cell '.$this->currentObjectID.' in WinCache'); } } else { - if (!wincache_ucache_add($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) { + if (!wincache_ucache_add($this->cachePrefix.$this->currentObjectID.'.cache', $obj, $this->cacheTime)) { $this->__destruct(); - throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in WinCache'); + throw new PHPExcel_Exception('Failed to store cell '.$this->currentObjectID.' in WinCache'); } } - $this->_currentCellIsDirty = false; + $this->currentCellIsDirty = false; } - $this->_currentObjectID = $this->_currentObject = null; + $this->currentObjectID = $this->currentObject = null; } /** @@ -82,14 +82,14 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { - if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { - $this->_storeData(); + if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) { + $this->storeData(); } - $this->_cellCache[$pCoord] = true; + $this->cellCache[$pCoord] = true; - $this->_currentObjectID = $pCoord; - $this->_currentObject = $cell; - $this->_currentCellIsDirty = true; + $this->currentObjectID = $pCoord; + $this->currentObject = $cell; + $this->currentCellIsDirty = true; return $cell; } @@ -104,11 +104,11 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage { // Check if the requested entry is the current object, or exists in the cache if (parent::isDataSet($pCoord)) { - if ($this->_currentObjectID == $pCoord) { + if ($this->currentObjectID == $pCoord) { return true; } // Check if the requested entry still exists in cache - $success = wincache_ucache_exists($this->_cachePrefix.$pCoord.'.cache'); + $success = wincache_ucache_exists($this->cachePrefix.$pCoord.'.cache'); if ($success === false) { // Entry no longer exists in Wincache, so clear it from the cache array parent::deleteCacheData($pCoord); @@ -129,16 +129,16 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage */ public function getCacheData($pCoord) { - if ($pCoord === $this->_currentObjectID) { - return $this->_currentObject; + if ($pCoord === $this->currentObjectID) { + return $this->currentObject; } - $this->_storeData(); + $this->storeData(); // Check if the entry that has been requested actually exists $obj = null; if (parent::isDataSet($pCoord)) { $success = false; - $obj = wincache_ucache_get($this->_cachePrefix.$pCoord.'.cache', $success); + $obj = wincache_ucache_get($this->cachePrefix.$pCoord.'.cache', $success); if ($success === false) { // Entry no longer exists in WinCache, so clear it from the cache array parent::deleteCacheData($pCoord); @@ -150,13 +150,13 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage } // Set current entry to the requested entry - $this->_currentObjectID = $pCoord; - $this->_currentObject = unserialize($obj); + $this->currentObjectID = $pCoord; + $this->currentObject = unserialize($obj); // Re-attach this as the cell's parent - $this->_currentObject->attach($this); + $this->currentObject->attach($this); // Return requested entry - return $this->_currentObject; + return $this->currentObject; } @@ -167,8 +167,8 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage */ public function getCellList() { - if ($this->_currentObjectID !== null) { - $this->_storeData(); + if ($this->currentObjectID !== null) { + $this->storeData(); } return parent::getCellList(); @@ -183,7 +183,7 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage public function deleteCacheData($pCoord) { // Delete the entry from Wincache - wincache_ucache_delete($this->_cachePrefix.$pCoord.'.cache'); + wincache_ucache_delete($this->cachePrefix.$pCoord.'.cache'); // Delete the entry from our cell address array parent::deleteCacheData($pCoord); @@ -199,25 +199,25 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage { parent::copyCellCollection($parent); // Get a new id for the new file name - $baseUnique = $this->_getUniqueID(); + $baseUnique = $this->getUniqueID(); $newCachePrefix = substr(md5($baseUnique), 0, 8) . '.'; $cacheList = $this->getCellList(); foreach ($cacheList as $cellID) { - if ($cellID != $this->_currentObjectID) { + if ($cellID != $this->currentObjectID) { $success = false; - $obj = wincache_ucache_get($this->_cachePrefix.$cellID.'.cache', $success); + $obj = wincache_ucache_get($this->cachePrefix.$cellID.'.cache', $success); if ($success === false) { // Entry no longer exists in WinCache, so clear it from the cache array parent::deleteCacheData($cellID); throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in Wincache'); } - if (!wincache_ucache_add($newCachePrefix.$cellID.'.cache', $obj, $this->_cacheTime)) { + if (!wincache_ucache_add($newCachePrefix.$cellID.'.cache', $obj, $this->cacheTime)) { $this->__destruct(); throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in Wincache'); } } } - $this->_cachePrefix = $newCachePrefix; + $this->cachePrefix = $newCachePrefix; } @@ -228,18 +228,18 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage */ public function unsetWorksheetCells() { - if (!is_null($this->_currentObject)) { - $this->_currentObject->detach(); - $this->_currentObject = $this->_currentObjectID = null; + if (!is_null($this->currentObject)) { + $this->currentObject->detach(); + $this->currentObject = $this->currentObjectID = null; } // Flush the WinCache cache $this->__destruct(); - $this->_cellCache = array(); + $this->cellCache = array(); // detach ourself from the worksheet, so that it can then delete this object successfully - $this->_parent = null; + $this->parent = null; } /** @@ -252,10 +252,10 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage { $cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600; - if (is_null($this->_cachePrefix)) { - $baseUnique = $this->_getUniqueID(); - $this->_cachePrefix = substr(md5($baseUnique), 0, 8).'.'; - $this->_cacheTime = $cacheTime; + if (is_null($this->cachePrefix)) { + $baseUnique = $this->getUniqueID(); + $this->cachePrefix = substr(md5($baseUnique), 0, 8).'.'; + $this->cacheTime = $cacheTime; parent::__construct($parent); } @@ -268,7 +268,7 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage { $cacheList = $this->getCellList(); foreach ($cacheList as $cellID) { - wincache_ucache_delete($this->_cachePrefix.$cellID.'.cache'); + wincache_ucache_delete($this->cachePrefix.$cellID.'.cache'); } } diff --git a/Classes/PHPExcel/CachedObjectStorageFactory.php b/Classes/PHPExcel/CachedObjectStorageFactory.php index 251c3ef8..0a969786 100644 --- a/Classes/PHPExcel/CachedObjectStorageFactory.php +++ b/Classes/PHPExcel/CachedObjectStorageFactory.php @@ -44,21 +44,21 @@ class PHPExcel_CachedObjectStorageFactory * * @var string */ - private static $_cacheStorageMethod = null; + private static $cacheStorageMethod = null; /** * Name of the class used for cell cacheing * * @var string */ - private static $_cacheStorageClass = null; + private static $cacheStorageClass = null; /** * List of all possible cache storage methods * * @var string[] */ - private static $_storageMethods = array( + private static $storageMethods = array( self::cache_in_memory, self::cache_in_memory_gzip, self::cache_in_memory_serialized, @@ -77,7 +77,7 @@ class PHPExcel_CachedObjectStorageFactory * * @var array of mixed array */ - private static $_storageMethodDefaultParameters = array( + private static $storageMethodDefaultParameters = array( self::cache_in_memory => array( ), self::cache_in_memory_gzip => array( @@ -109,7 +109,7 @@ class PHPExcel_CachedObjectStorageFactory * * @var array of mixed array */ - private static $_storageMethodParameters = array(); + private static $storageMethodParameters = array(); /** * Return the current cache storage method @@ -118,7 +118,7 @@ class PHPExcel_CachedObjectStorageFactory **/ public static function getCacheStorageMethod() { - return self::$_cacheStorageMethod; + return self::$cacheStorageMethod; } /** @@ -128,7 +128,7 @@ class PHPExcel_CachedObjectStorageFactory **/ public static function getCacheStorageClass() { - return self::$_cacheStorageClass; + return self::$cacheStorageClass; } /** @@ -138,7 +138,7 @@ class PHPExcel_CachedObjectStorageFactory **/ public static function getAllCacheStorageMethods() { - return self::$_storageMethods; + return self::$storageMethods; } /** @@ -149,7 +149,7 @@ class PHPExcel_CachedObjectStorageFactory public static function getCacheStorageMethods() { $activeMethods = array(); - foreach (self::$_storageMethods as $storageMethod) { + foreach (self::$storageMethods as $storageMethod) { $cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $storageMethod; if (call_user_func(array($cacheStorageClass, 'cacheMethodIsAvailable'))) { $activeMethods[] = $storageMethod; @@ -168,7 +168,7 @@ class PHPExcel_CachedObjectStorageFactory **/ public static function initialize($method = self::cache_in_memory, $arguments = array()) { - if (!in_array($method, self::$_storageMethods)) { + if (!in_array($method, self::$storageMethods)) { return false; } @@ -178,16 +178,16 @@ class PHPExcel_CachedObjectStorageFactory return false; } - self::$_storageMethodParameters[$method] = self::$_storageMethodDefaultParameters[$method]; + self::$storageMethodParameters[$method] = self::$storageMethodDefaultParameters[$method]; foreach ($arguments as $k => $v) { - if (array_key_exists($k, self::$_storageMethodParameters[$method])) { - self::$_storageMethodParameters[$method][$k] = $v; + if (array_key_exists($k, self::$storageMethodParameters[$method])) { + self::$storageMethodParameters[$method][$k] = $v; } } - if (self::$_cacheStorageMethod === null) { - self::$_cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $method; - self::$_cacheStorageMethod = $method; + if (self::$cacheStorageMethod === null) { + self::$cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $method; + self::$cacheStorageMethod = $method; } return true; } @@ -201,14 +201,14 @@ class PHPExcel_CachedObjectStorageFactory public static function getInstance(PHPExcel_Worksheet $parent) { $cacheMethodIsAvailable = true; - if (self::$_cacheStorageMethod === null) { + if (self::$cacheStorageMethod === null) { $cacheMethodIsAvailable = self::initialize(); } if ($cacheMethodIsAvailable) { - $instance = new self::$_cacheStorageClass( + $instance = new self::$cacheStorageClass( $parent, - self::$_storageMethodParameters[self::$_cacheStorageMethod] + self::$storageMethodParameters[self::$cacheStorageMethod] ); if ($instance !== null) { return $instance; @@ -224,8 +224,8 @@ class PHPExcel_CachedObjectStorageFactory **/ public static function finalize() { - self::$_cacheStorageMethod = null; - self::$_cacheStorageClass = null; - self::$_storageMethodParameters = array(); + self::$cacheStorageMethod = null; + self::$cacheStorageClass = null; + self::$storageMethodParameters = array(); } } diff --git a/Classes/PHPExcel/CalcEngine/CyclicReferenceStack.php b/Classes/PHPExcel/CalcEngine/CyclicReferenceStack.php index b3bb2bf1..1072fc75 100644 --- a/Classes/PHPExcel/CalcEngine/CyclicReferenceStack.php +++ b/Classes/PHPExcel/CalcEngine/CyclicReferenceStack.php @@ -32,7 +32,7 @@ class PHPExcel_CalcEngine_CyclicReferenceStack * * @var mixed[] */ - private $_stack = array(); + private $stack = array(); /** * Return the number of entries on the stack @@ -41,7 +41,7 @@ class PHPExcel_CalcEngine_CyclicReferenceStack */ public function count() { - return count($this->_stack); + return count($this->stack); } /** @@ -51,7 +51,7 @@ class PHPExcel_CalcEngine_CyclicReferenceStack */ public function push($value) { - $this->_stack[$value] = $value; + $this->stack[$value] = $value; } /** @@ -61,7 +61,7 @@ class PHPExcel_CalcEngine_CyclicReferenceStack */ public function pop() { - return array_pop($this->_stack); + return array_pop($this->stack); } /** @@ -71,7 +71,7 @@ class PHPExcel_CalcEngine_CyclicReferenceStack */ public function onStack($value) { - return isset($this->_stack[$value]); + return isset($this->stack[$value]); } /** @@ -79,7 +79,7 @@ class PHPExcel_CalcEngine_CyclicReferenceStack */ public function clear() { - $this->_stack = array(); + $this->stack = array(); } /** @@ -89,6 +89,6 @@ class PHPExcel_CalcEngine_CyclicReferenceStack */ public function showStack() { - return $this->_stack; + return $this->stack; } } diff --git a/Classes/PHPExcel/CalcEngine/Logger.php b/Classes/PHPExcel/CalcEngine/Logger.php index 9fd1d7d7..c5ffe73e 100644 --- a/Classes/PHPExcel/CalcEngine/Logger.php +++ b/Classes/PHPExcel/CalcEngine/Logger.php @@ -34,7 +34,7 @@ class PHPExcel_CalcEngine_Logger * * @var boolean */ - private $_writeDebugLog = false; + private $writeDebugLog = false; /** * Flag to determine whether a debug log should be echoed by the calculation engine @@ -44,21 +44,21 @@ class PHPExcel_CalcEngine_Logger * * @var boolean */ - private $_echoDebugLog = false; + private $echoDebugLog = false; /** * The debug log generated by the calculation engine * * @var string[] */ - private $_debugLog = array(); + private $debugLog = array(); /** * The calculation engine cell reference stack * * @var PHPExcel_CalcEngine_CyclicReferenceStack */ - private $_cellStack; + private $cellStack; /** * Instantiate a Calculation engine logger @@ -67,7 +67,7 @@ class PHPExcel_CalcEngine_Logger */ public function __construct(PHPExcel_CalcEngine_CyclicReferenceStack $stack) { - $this->_cellStack = $stack; + $this->cellStack = $stack; } /** @@ -77,7 +77,7 @@ class PHPExcel_CalcEngine_Logger */ public function setWriteDebugLog($pValue = false) { - $this->_writeDebugLog = $pValue; + $this->writeDebugLog = $pValue; } /** @@ -87,7 +87,7 @@ class PHPExcel_CalcEngine_Logger */ public function getWriteDebugLog() { - return $this->_writeDebugLog; + return $this->writeDebugLog; } /** @@ -97,7 +97,7 @@ class PHPExcel_CalcEngine_Logger */ public function setEchoDebugLog($pValue = false) { - $this->_echoDebugLog = $pValue; + $this->echoDebugLog = $pValue; } /** @@ -107,7 +107,7 @@ class PHPExcel_CalcEngine_Logger */ public function getEchoDebugLog() { - return $this->_echoDebugLog; + return $this->echoDebugLog; } /** @@ -116,17 +116,17 @@ class PHPExcel_CalcEngine_Logger public function writeDebugLog() { // Only write the debug log if logging is enabled - if ($this->_writeDebugLog) { + if ($this->writeDebugLog) { $message = implode(func_get_args()); - $cellReference = implode(' -> ', $this->_cellStack->showStack()); - if ($this->_echoDebugLog) { + $cellReference = implode(' -> ', $this->cellStack->showStack()); + if ($this->echoDebugLog) { echo $cellReference, - ($this->_cellStack->count() > 0 ? ' => ' : ''), + ($this->cellStack->count() > 0 ? ' => ' : ''), $message, PHP_EOL; } - $this->_debugLog[] = $cellReference . - ($this->_cellStack->count() > 0 ? ' => ' : '') . + $this->debugLog[] = $cellReference . + ($this->cellStack->count() > 0 ? ' => ' : '') . $message; } } @@ -136,7 +136,7 @@ class PHPExcel_CalcEngine_Logger */ public function clearLog() { - $this->_debugLog = array(); + $this->debugLog = array(); } /** @@ -146,6 +146,6 @@ class PHPExcel_CalcEngine_Logger */ public function getLog() { - return $this->_debugLog; + return $this->debugLog; } } diff --git a/changelog.txt b/changelog.txt index 7d988cbe..d12660c2 100644 --- a/changelog.txt +++ b/changelog.txt @@ -24,6 +24,7 @@ Planned for 1.8.2 +- Bugfix: (MBaker) - Fix to getCell() method when cell reference includes a worksheet reference 2015-04-30 (v1.8.1):