*/
protected function initFileStack (SplFileInfo $fileInfoInstance, string $type) {
// Get a stack file instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: fileInfoInstance=%s,type=%s - CALLED!', $fileInfoInstance, $type));
$fileInstance = ObjectFactory::createObjectByConfiguredName('stack_file_class', array($fileInfoInstance, $this));
// Get iterator instance
$iteratorInstance = ObjectFactory::createObjectByConfiguredName('file_iterator_class', array($fileInstance));
- // Is the instance implementing the right interface?
- assert($iteratorInstance instanceof SeekableWritableFileIterator);
-
// Set iterator here
$this->setIteratorInstance($iteratorInstance);
// And pre-allocate a bit
$this->getIteratorInstance()->preAllocateFile('file_stack');
- } // END - if
+ }
// Load the file header
$this->readFileHeader();
* @param $value Value to add to this stacker
* @return void
* @throws FullStackerException If the stack is full
+ * @throws InvalidArgumentException Not all variable types are wanted here
*/
protected function addValue (string $stackerName, $value) {
// Do some tests
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('stackerName=%s,value[%s]=%s - CALLED!', $stackerName, gettype($value), print_r($value, true)));
if ($this->isStackFull($stackerName)) {
// Stacker is full
throw new FullStackerException(array($this, $stackerName, $value), self::EXCEPTION_STACKER_IS_FULL);
- } // END - if
-
- // No objects/resources are allowed as their serialization takes to long
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName . ',value[' . gettype($value) . ']=' . print_r($value, true));
- assert(!is_object($value));
- assert(!is_resource($value));
+ } elseif (is_resource($value) || is_object($value)) {
+ // Not wanted type
+ throw new InvalidArgumentException(sprintf('value[]=%s is not supported', gettype($value)));
+ }
/*
* Now add the value to the file stack which returns gap position, a
* @return void
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
- public function writeData ($seekPosition, $data, bool $flushHeader = true) {
+ public function writeData (int $seekPosition, string $data, bool $flushHeader = true) {
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: seekPosition=%s,data[]=%s,flushHeader=%d', $seekPosition, gettype($data), intval($flushHeader)));
throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return $data Hash and gap position
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
- public function writeValueToFile ($groupId, $value) {
+ public function writeValueToFile (string $groupId, $value) {
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: groupId=%s,value[%s]=%s', $groupId, gettype($value), print_r($value, true)));
throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
}
* @param $encoded Encoded value to be written to the file
* @return $data Gap position and length of the raw data
*/
- public function writeDataToFreeGap ($groupId, string $hash, $encoded) {
+ public function writeDataToFreeGap (string $groupId, string $hash, string $encoded) {
// Raw data been written to the file
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: groupId=%s,hash=%s,encoded()=%d - CALLED!', $groupId, $hash, strlen($encoded)));
$rawData = sprintf('%s%s%s%s%s',