]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/stacker/file/class_BaseFileStack.php
Continued:
[core.git] / framework / main / classes / stacker / file / class_BaseFileStack.php
index 6c1f3d1cfabfc3bbf4325dbd956af6d82aa1af24..faa1b0dc513f7b3463fef1a69c8988be2afba879 100644 (file)
@@ -236,14 +236,12 @@ abstract class BaseFileStack extends BaseStacker {
         */
        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);
 
@@ -267,7 +265,7 @@ abstract class BaseFileStack extends BaseStacker {
 
                        // And pre-allocate a bit
                        $this->getIteratorInstance()->preAllocateFile('file_stack');
-               } // END - if
+               }
 
                // Load the file header
                $this->readFileHeader();
@@ -292,18 +290,18 @@ abstract class BaseFileStack extends BaseStacker {
         * @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
@@ -584,7 +582,7 @@ abstract class BaseFileStack extends BaseStacker {
         * @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);
        }
@@ -597,7 +595,7 @@ abstract class BaseFileStack extends BaseStacker {
         * @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);
        }
@@ -633,7 +631,7 @@ abstract class BaseFileStack extends BaseStacker {
         * @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',