]> git.mxchange.org Git - core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Thu, 16 Dec 2021 11:52:42 +0000 (12:52 +0100)
committerRoland Häder <roland@mxchange.org>
Thu, 16 Dec 2021 11:52:42 +0000 (12:52 +0100)
- Better check against SplFileObject instead of is_object(). First one is a
  keyword (instanceof), later is a function call
- More debug logging
- Added missing "import" lines
- Replaced more array() with []

Signed-off-by: Roland Häder <roland@mxchange.org>
13 files changed:
framework/loader/class_ClassLoader.php
framework/main/classes/class_BaseFrameworkSystem.php
framework/main/classes/database/backend/lfdb_legacy/class_CachedLocalFileDatabase.php
framework/main/classes/file_directories/input/raw/class_FrameworkRawFileInputPointer.php
framework/main/classes/file_directories/input/text/class_FrameworkTextFileInputPointer.php
framework/main/classes/file_directories/io/class_FrameworkFileInputOutputPointer.php
framework/main/classes/file_directories/output/raw/class_FrameworkRawFileOutputPointer.php
framework/main/classes/file_directories/output/text/class_FrameworkTextFileOutputPointer.php
framework/main/classes/lists/class_BaseList.php
framework/main/classes/template/image/class_ImageTemplateEngine.php
framework/main/classes/template/mail/class_MailTemplateEngine.php
framework/main/classes/template/menu/class_MenuTemplateEngine.php
framework/main/classes/template/xml/class_BaseXmlTemplateEngine.php

index 8ce8488a5f2b12ef4c88b28fc571e924b61ad5b1..b19d5dc5ce3ef33882ea71d576f46d2b37da5c65 100644 (file)
@@ -441,8 +441,8 @@ final class ClassLoader {
                        return;
                }
 
-               // Keep it in class for later usage
-               $this->ignoreList = $ignoreList;
+               // Keep it in class for later usage, but flip index<->value
+               $this->ignoreList = array_flip($ignoreList);
 
                /*
                 * Set base directory which holds all our classes, an absolute path
@@ -474,7 +474,7 @@ final class ClassLoader {
                        $fileName = $currentEntry->getFilename();
 
                        // Current entry must be a file, not smaller than 100 bytes and not on ignore list
-                       if ((!$currentEntry->isFile()) || (in_array($fileName, $this->ignoreList)) || ($currentEntry->getSize() < 100)) {
+                       if (!$currentEntry->isFile() || isset($this->ignoreList[$fileName]) || $currentEntry->getSize() < 100) {
                                // Advance to next entry
                                $iteratorInstance->next();
 
index 38a45f3de6487ae05416f5e7fbff5ab4508723ec..96f05cdcc890272b3304369601b5c984808237d4 100644 (file)
@@ -6,6 +6,7 @@ namespace Org\Mxchange\CoreFramework\Object;
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
 use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint;
 use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
+use Org\Mxchange\CoreFramework\Filesystem\FileIoException;
 use Org\Mxchange\CoreFramework\Filesystem\PathWriteProtectedException;
 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
 use Org\Mxchange\CoreFramework\Generic\NullPointerException;
@@ -55,6 +56,15 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac
         */
        private static $selfInstance = NULL;
 
+       /**
+        * Stub methods
+        */
+       private static $stubMethods = [
+               'partialStub' => true,
+               '__call' => true,
+               '__callStatic' => true,
+       ];
+
        /**
         * The real class name
         */
@@ -672,7 +682,7 @@ Loaded includes:
                $backtrace = debug_backtrace(!DEBUG_BACKTRACE_PROVIDE_OBJECT);
 
                // Is function partialStub/__callStatic ?
-               if (in_array($backtrace[1]['function'], array('partialStub', '__call', '__callStatic'))) {
+               if (isset(self::$stubMethods[$backtrace[1]['function']])) {
                        // Prepend class::function:line from 3rd element
                        $message = sprintf('[%s::%s:%d]: %s',
                                $backtrace[2]['class'],
index 1c652b901835f8adc88b0fd34df959529e549f3b..400243d088e3dcd653e404a44802b3440508aa41 100644 (file)
@@ -9,6 +9,7 @@ use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria;
 use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria;
 use Org\Mxchange\CoreFramework\Database\Backend\BaseDatabaseBackend;
 use Org\Mxchange\CoreFramework\Database\Backend\DatabaseBackend;
+use Org\Mxchange\CoreFramework\Database\Sql\SqlException;
 use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
 use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException;
 use Org\Mxchange\CoreFramework\Generic\FrameworkException;
@@ -507,11 +508,15 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
                        $this->setLastException($e);
 
                        // Throw an SQL exception
-                       throw new SqlException(array(
+                       throw new SqlException([
                                        $this,
-                                       sprintf('Cannot write data to table &#39;%s&#39;, is the table created?', $dataSetInstance->getTableName()),
+                                       sprintf('Cannot write data to table &#39;%s&#39;, is the table created? e=%s,e->message=%s',
+                                               $dataSetInstance->getTableName(),
+                                               $e->__toString(),
+                                               $e->getMessage()
+                                       ),
                                        self::DB_CODE_TABLE_UNWRITEABLE
-                               ),
+                               ],
                                self::EXCEPTION_SQL_QUERY
                        );
                }
index 61fc5f123db042e86b56a47192fb879a1773b9dc..c76d4fb9deeaac14965cadf94a7319e3ba421ac3 100644 (file)
@@ -5,6 +5,7 @@ namespace Org\Mxchange\CoreFramework\Filesystem\Pointer\Input;
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
 use Org\Mxchange\CoreFramework\Filesystem\BaseFileIo;
+use Org\Mxchange\CoreFramework\Filesystem\FileIoException;
 use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException;
 use Org\Mxchange\CoreFramework\Filesystem\FileReadProtectedException;
 use Org\Mxchange\CoreFramework\Filesystem\Pointer\InputPointer;
@@ -14,6 +15,7 @@ use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
 
 // Import SPL stuff
 use \SplFileInfo;
+use \SplFileObject;
 
 /**
  * A class for reading files
@@ -52,30 +54,34 @@ class FrameworkRawFileInputPointer extends BaseFileIo implements InputPointer {
         * Create a file pointer based on the given file. The file will also
         * be verified here.
         *
-        * @param       $infoInstance   An instance of a SplFileInfo class
+        * @param       $fileInstance   An instance of a SplFileInfo class
         * @throws      FileIoException                         If the file is not reachable
         * @throws      FileReadProtectedException      If the file is not found or cannot be read
         * @throws      FileNotFoundException           If the file does not exist
         * @return      void
         */
-       public static final function createFrameworkRawFileInputPointer (SplFileInfo $infoInstance) {
+       public static final function createFrameworkRawFileInputPointer (SplFileInfo $fileInstance) {
                // Some pre-sanity checks...
-               if (!FrameworkBootstrap::isReachableFilePath($infoInstance)) {
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-FILE-INPUT-POINTER: fileInstance[%s]=%s - CALLED!', get_class($fileInstance), $fileInstance->__toString()));
+               if (!FrameworkBootstrap::isReachableFilePath($fileInstance)) {
                        // File cannot be accessed (due to open_basedir restriction)
-                       throw new FileIoException($infoInstance, self::EXCEPTION_FILE_NOT_REACHABLE);
-               } elseif ((!FrameworkBootstrap::isReadableFile($infoInstance)) && (!$infoInstance->isFile())) {
+                       throw new FileIoException($fileInstance, self::EXCEPTION_FILE_NOT_REACHABLE);
+               } elseif ((!FrameworkBootstrap::isReadableFile($fileInstance)) && (!$fileInstance->isFile())) {
                        // File does not exist
-                       throw new FileNotFoundException($infoInstance, self::EXCEPTION_FILE_NOT_FOUND);
-               } elseif ((!FrameworkBootstrap::isReadableFile($infoInstance)) && ($infoInstance->isFile())) {
+                       throw new FileNotFoundException($fileInstance, self::EXCEPTION_FILE_NOT_FOUND);
+               } elseif ((!FrameworkBootstrap::isReadableFile($fileInstance)) && ($fileInstance->isFile())) {
                        // File exists but cannot be read from
-                       throw new FileReadProtectedException($infoInstance, self::EXCEPTION_FILE_CANNOT_BE_READ);
+                       throw new FileReadProtectedException($fileInstance, self::EXCEPTION_FILE_CANNOT_BE_READ);
                }
 
                // Try to open a handler
-               $fileObject = $infoInstance->openFile('rb');
-               if ((is_null($fileObject)) || ($fileObject === false)) {
+               $fileObject = $fileInstance->openFile('rb');
+
+               // Is it valid?
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-FILE-INPUT-POINTER: fileObject[]=%s', gettype($fileObject)));
+               if (!($fileObject instanceof SplFileObject)) {
                        // Something bad happend
-                       throw new FileIoException($infoInstance, self::EXCEPTION_FILE_POINTER_INVALID);
+                       throw new FileIoException($fileInstance, self::EXCEPTION_FILE_POINTER_INVALID);
                }
 
                // Create new instance
@@ -85,6 +91,7 @@ class FrameworkRawFileInputPointer extends BaseFileIo implements InputPointer {
                $pointerInstance->setFileObject($fileObject);
 
                // Return the instance
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-FILE-INPUT-POINTER: pointerInstance=%s - EXIT!', $pointerInstance->__toString()));
                return $pointerInstance;
        }
 
index 27565cef23d3f1194b2f26ffb9cfb123d798b254..1a005043a1da75bfccb02870f65e732ad2be2d83 100644 (file)
@@ -5,6 +5,7 @@ namespace Org\Mxchange\CoreFramework\Filesystem\Pointer\Input;
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
 use Org\Mxchange\CoreFramework\Filesystem\BaseFileIo;
+use Org\Mxchange\CoreFramework\Filesystem\FileIoException;
 use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException;
 use Org\Mxchange\CoreFramework\Filesystem\FileReadProtectedException;
 use Org\Mxchange\CoreFramework\Filesystem\Pointer\InputPointer;
@@ -14,6 +15,7 @@ use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
 
 // Import SPL stuff
 use \SplFileInfo;
+use \SplFileObject;
 
 /**
  * A class for reading text files
@@ -57,29 +59,28 @@ class FrameworkTextFileInputPointer extends BaseFileIo implements InputPointer {
         * @throws      FileReadProtectedException      If the file cannot be read from
         * @return      void
         */
-       public static final function createFrameworkTextFileInputPointer (SplFileInfo $infoInstance) {
+       public static final function createFrameworkTextFileInputPointer (SplFileInfo $fileInstance) {
                // Check parameter
-               if (!FrameworkBootstrap::isReachableFilePath($infoInstance)) {
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-FILE-INPUT-POINTER: fileInstance[%s]=%s - CALLED!', get_class($fileInstance), $fileInstance->__toString()));
+               if (!FrameworkBootstrap::isReachableFilePath($fileInstance)) {
                        // File cannot be reached
-                       throw new FileIoException($infoInstance, self::EXCEPTION_FILE_NOT_REACHABLE);
-               } elseif ((!FrameworkBootstrap::isReadableFile($infoInstance)) && (!$infoInstance->isFile())) {
+                       throw new FileIoException($fileInstance, self::EXCEPTION_FILE_NOT_REACHABLE);
+               } elseif ((!FrameworkBootstrap::isReadableFile($fileInstance)) && (!$fileInstance->isFile())) {
                        // File does not exist!
-                       throw new FileNotFoundException($infoInstance, self::EXCEPTION_FILE_CANNOT_BE_READ);
-               } elseif ((!FrameworkBootstrap::isReadableFile($infoInstance)) && ($infoInstance->isFile())) {
+                       throw new FileNotFoundException($fileInstance, self::EXCEPTION_FILE_CANNOT_BE_READ);
+               } elseif ((!FrameworkBootstrap::isReadableFile($fileInstance)) && ($fileInstance->isFile())) {
                        // File cannot be read from (but exists)
-                       throw new FileReadProtectedException($infoInstance, self::EXCEPTION_FILE_CANNOT_BE_READ);
+                       throw new FileReadProtectedException($fileInstance, self::EXCEPTION_FILE_CANNOT_BE_READ);
                }
 
                // Try to open a handler
-               $fileObject = $infoInstance->openFile('r');
-
-               // Debug message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TEXT-FILE-INPUT: fileObject[]=' . gettype($fileObject));
+               $fileObject = $fileInstance->openFile('r');
 
                // Is it valid?
-               if ((is_null($fileObject)) || ($fileObject === false)) {
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TEXT-FILE-INPUT-POINTER: fileObject[]=%s', gettype($fileObject)));
+               if (!($fileObject instanceof SplFileObject)) {
                        // Something bad happend
-                       throw new FileIoException($infoInstance, self::EXCEPTION_FILE_POINTER_INVALID);
+                       throw new FileIoException($fileInstance, self::EXCEPTION_FILE_POINTER_INVALID);
                }
 
                // Create new instance
@@ -89,6 +90,7 @@ class FrameworkTextFileInputPointer extends BaseFileIo implements InputPointer {
                $pointerInstance->setFileObject($fileObject);
 
                // Return the instance
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TEXT-FILE-INPUT-POINTER: pointerInstance=%s - EXIT!', $pointerInstance->__toString()));
                return $pointerInstance;
        }
 
index 5e77247a40bf179a9a775f81e02fa6f2f48de77d..6e0c5f305f6187321942ba7b0d51df9d9bccaddf 100644 (file)
@@ -5,6 +5,7 @@ namespace Org\Mxchange\CoreFramework\Filesystem\Pointer;
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
 use Org\Mxchange\CoreFramework\Filesystem\BaseFileIo;
+use Org\Mxchange\CoreFramework\Filesystem\FileIoException;
 use Org\Mxchange\CoreFramework\Filesystem\FileReadProtectedException;
 use Org\Mxchange\CoreFramework\Filesystem\FileWriteProtectedException;
 use Org\Mxchange\CoreFramework\Filesystem\PathWriteProtectedException;
@@ -15,6 +16,7 @@ use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
 // Import SPL stuff
 use \InvalidArgumentException;
 use \SplFileInfo;
+use \SplFileObject;
 use \OutOfBoundsException;
 use \UnexpectedValueException;
 
@@ -84,7 +86,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
 
                // Is it valid?
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: fileObject[]=%s', gettype($fileObject)));
-               if ((is_null($fileObject)) || ($fileObject === false)) {
+               if (!($fileObject instanceof SplFileObject)) {
                        // Something bad happend
                        throw new FileIoException($fileInstance->getPathname(), self::EXCEPTION_FILE_POINTER_INVALID);
                }
index 2436b0f48c8f91cc71552f395a1f2b9a950865b3..5432d96c7a2bc994ff257609c2ac033be0e5a1c2 100644 (file)
@@ -4,12 +4,14 @@ namespace Org\Mxchange\CoreFramework\Filesystem\Pointer\Output;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Filesystem\BaseFileIo;
+use Org\Mxchange\CoreFramework\Filesystem\FileIoException;
 use Org\Mxchange\CoreFramework\Filesystem\Pointer\OutputPointer;
 use Org\Mxchange\CoreFramework\Generic\NullPointerException;
 
 // Import SPL stuff
 use \InvalidArgumentException;
 use \SplFileInfo;
+use \SplFileObject;
 
 /**
  * A class for writing files
@@ -48,33 +50,40 @@ class FrameworkRawFileOutputPointer extends BaseFileIo implements OutputPointer
         * Create a file pointer based on the given file. The file will also
         * be verified here.
         *
-        * @param       $infoInstance   An instance of a SplFileInfo class
+        * @param       $fileInstance   An instance of a SplFileInfo class
         * @param       $mode           The output mode ('w', 'a' are valid)
+        * @return      void
         * @throws      InvalidArgumentException        If parameter mode is empty
         * @throws      FileIoException                 If fopen() returns not a file resource
-        * @return      void
         */
-       public static final function createFrameworkRawFileOutputPointer (SplFileInfo $infoInstance, $mode) {
-               // Some pre-sanity checks...
-               if (is_null($mode)) {
-                       // No infoInstance given
+       public static final function createFrameworkRawFileOutputPointer (SplFileInfo $fileInstance, string $mode) {
+               // Is the parameter valid?
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-FILE-OUTPUT-POINTER: fileInstance=%s,mode=%s - CALLED!', $fileInstance->__toString(), $mode));
+               if (empty($mode)) {
+                       // No fileInstance given
                        throw new InvalidArgumentException('Parameter "mode" is empty');
                }
 
                // Try to open a handler
-               $fileObject = $infoInstance->openFile($mode);
-               if ((is_null($fileObject)) || ($fileObject === false)) {
+               $fileObject = $fileInstance->openFile($mode);
+
+               // Is it valid?
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-FILE-OUTPUT-POINTER: fileObject[]=%s', gettype($fileObject)));
+               if (!($fileObject instanceof SplFileObject)) {
                        // Something bad happend
-                       throw new FileIoException($infoInstance, self::EXCEPTION_FILE_POINTER_INVALID);
+                       throw new FileIoException($fileInstance, self::EXCEPTION_FILE_POINTER_INVALID);
                }
 
                // Create new instance
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-FILE-OUTPUT-POINTER: Creating pointer instance ...');
                $pointerInstance = new FrameworkRawFileOutputPointer();
 
                // Set file pointer and file name
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-FILE-OUTPUT-POINTER: pointerInstance=%s,fileObject=%s', $pointerInstance->__toString(), $fileObject->__toString()));
                $pointerInstance->setFileObject($fileObject);
 
                // Return the instance
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-FILE-OUTPUT-POINTER: pointerInstance=%s - EXIT!', $pointerInstance->__toString()));
                return $pointerInstance;
        }
 
@@ -83,11 +92,16 @@ class FrameworkRawFileOutputPointer extends BaseFileIo implements OutputPointer
         *
         * @param       $dataStream             The data stream we shall write to the file
         * @return      mixed                   Number of writes bytes or false on error
+        * @throws      InvalidArgumentException        If a parameter is invalid
         * @throws      NullPointerException    If the file pointer instance is not set by setFileObject()
         * @throws      LogicException  If there is no object being set
         */
        public function writeToFile (string $dataStream) {
-               if (is_null($this->getFileObject())) {
+               // Validate parameter and class own attributes
+               if (empty($dataStream)) {
+                       // Empty data stream
+                       throw new InvalidArgumentException('Parameter "dataStream" is empty');
+               } elseif (is_null($this->getFileObject())) {
                        // Pointer not initialized
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
                } elseif (!is_object($this->getFileObject())) {
index 33aa707c7367588e134a247c5d49bd473840d365..5ba314498b4e1dd59ca39ce40f0afbe223886743 100644 (file)
@@ -4,6 +4,7 @@ namespace Org\Mxchange\CoreFramework\Filesystem\Pointer\Text;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Filesystem\BaseFileIo;
+use Org\Mxchange\CoreFramework\Filesystem\FileIoException;
 use Org\Mxchange\CoreFramework\Filesystem\Pointer\OutputPointer;
 use Org\Mxchange\CoreFramework\Generic\NullPointerException;
 use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
@@ -11,6 +12,7 @@ use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
 // Import SPL stuff
 use \InvalidArgumentException;
 use \SplFileInfo;
+use \SplFileObject;
 
 /**
  * A class for writing files
@@ -55,8 +57,9 @@ class FrameworkTextFileOutputPointer extends BaseFileIo implements OutputPointer
         * @throws      FileIoException                 If fopen() returns not a file resource
         * @return      void
         */
-       public static final function createFrameworkTextFileOutputPointer (SplFileInfo $fileInstance, $mode) {
+       public static final function createFrameworkTextFileOutputPointer (SplFileInfo $fileInstance, string $mode) {
                // Some pre-sanity checks...
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TEXT-FILE-OUTPUT-POINTER: fileInstance[%s]=%s,mode=%s - CALLED!', get_class($fileInstance), $fileInstance->__toString(), $mode));
                if (empty($mode)) {
                        // No filename given
                        throw new InvalidArgumentException('Parameter "mode" is empty');
@@ -66,7 +69,8 @@ class FrameworkTextFileOutputPointer extends BaseFileIo implements OutputPointer
                $fileObject = $fileInstance->openFile($mode);
 
                // Is it valid?
-               if ((is_null($fileObject)) || ($fileObject === false)) {
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TEXT-FILE-OUTPUT-POINTER: fileObject[]=%s', gettype($fileObject)));
+               if (!($fileObject instanceof SplFileObject)) {
                        // Something bad happend
                        throw new FileIoException($fileInstance, self::EXCEPTION_FILE_POINTER_INVALID);
                }
@@ -78,6 +82,7 @@ class FrameworkTextFileOutputPointer extends BaseFileIo implements OutputPointer
                $pointerInstance->setFileObject($fileObject);
 
                // Return the instance
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TEXT-FILE-OUTPUT-POINTER: pointerInstance=%s - EXIT!', $pointerInstance->__toString()));
                return $pointerInstance;
        }
 
@@ -90,7 +95,12 @@ class FrameworkTextFileOutputPointer extends BaseFileIo implements OutputPointer
         * @throws      LogicException  If there is no object being set
         */
        public function writeToFile (string $dataStream) {
-               if (is_null($this->getFileObject())) {
+               // Validate parameter
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TEXT-FILE-OUTPUT-POINTER: dataStream=%s - CALLED!', $dataStream));
+               if (empty($dataStream)) {
+                       // Invalid parameter
+                       throw new InvalidArgumentException('Parameter "dataStream" is empty');
+               } elseif (is_null($this->getFileObject())) {
                        // Pointer not initialized
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
                } elseif (!is_object($this->getFileObject())) {
index c1ac982eb154c8381622ff828c8107b193bf856a..edca181d6fa99913340a9ec8abb481fb5abd05f9 100644 (file)
@@ -61,6 +61,14 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
         */
        private $listIndex = [];
 
+       /**
+        * Cached values from "expensive" method calls
+        */
+       private $cache = [
+               // Cached isValidHash() calls
+               'is_valid' => [],
+       ];
+
        /**
         * Protected constructor
         *
@@ -403,13 +411,13 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
                if (empty($hash)) {
                        // Throw IAE
                        throw new InvalidArgumentException('Parameter "hash" is empty');
+               } elseif (!isset($this->cache['is_valid'][$hash])) {
+                       // Check it
+                       $this->cache['is_valid'][$hash] = ((in_array($hash, $this->listIndex)) && (isset($this->listEntries[$hash])));
                }
 
-               // Check it
-               $isValid = ((in_array($hash, $this->listIndex)) && (isset($this->listEntries[$hash])));
-
                // Return the result
-               return $isValid;
+               return $this->cache['is_valid'][$hash];
        }
 
        /**
index 80a81446f2b2d1d3ce5141f7720c93ef12970fb7..43ffa77e2195d351ab4c896da1a2dd19fa554e6b 100644 (file)
@@ -212,7 +212,7 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl
                        $methodName = 'setImageProperty' . StringUtils::convertToClassName($element);
                } elseif ($element != 'image') {
                        // Invalid node name found
-                       throw new InvalidXmlNodeException(array($this, $element, $attributes), Parseable::EXCEPTION_XML_NODE_UNKNOWN);
+                       throw new InvalidXmlNodeException([$this, $element, $attributes], Parseable::EXCEPTION_XML_NODE_UNKNOWN);
                }
 
                // Call method
index 44dfeb0523630111bca7546526b5e848a0671129..401dfca8474984f02a96488e60df25aba45954db 100644 (file)
@@ -183,7 +183,7 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla
                        $methodName = 'setEmailProperty' . StringUtils::convertToClassName($element);
                } elseif ($element != 'text-mail') {
                        // Invalid node name found
-                       throw new InvalidXmlNodeException(array($this, $element, $attributes), Parseable::EXCEPTION_XML_NODE_UNKNOWN);
+                       throw new InvalidXmlNodeException([$this, $element, $attributes], Parseable::EXCEPTION_XML_NODE_UNKNOWN);
                }
 
                // Call method
index a16b9de5ea318dc0c1192f39427ceb886c57630a..b6b1f7f2d3f57205b8b5ed5c87007515943a9e22 100644 (file)
@@ -301,7 +301,7 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
                        $methodName = 'start' . StringUtils::convertToClassName($element);
                } elseif ($element != 'menu') {
                        // Invalid node name found
-                       throw new InvalidXmlNodeException(array($this, $element, $attributes), Parseable::EXCEPTION_XML_NODE_UNKNOWN);
+                       throw new InvalidXmlNodeException([$this, $element, $attributes], Parseable::EXCEPTION_XML_NODE_UNKNOWN);
                }
 
                // Call method
index cbbf4a736a026a290ef65fe393ab7d1330c0d66a..6175b9c72178746b36d234e70050a2bfa4335e9b 100644 (file)
@@ -328,7 +328,7 @@ abstract class BaseXmlTemplateEngine extends BaseTemplateEngine implements Compi
                        $methodName = 'start' . StringUtils::convertToClassName($element);
                } else {
                        // Invalid node name found
-                       throw new InvalidXmlNodeException(array($this, $element, $attributes), XmlParser::EXCEPTION_XML_NODE_UNKNOWN);
+                       throw new InvalidXmlNodeException([$this, $element, $attributes], XmlParser::EXCEPTION_XML_NODE_UNKNOWN);
                }
 
                // Call method