From 2ccd77f6590cea2ae90ea2b440d49d8d126847fe Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 7 Nov 2020 12:58:16 +0100 Subject: [PATCH] Continued: - moved $fileIoInstance and $resolverInstance to proper classes, avoiding monolithic BaseFrameworkSystem class - the goal is to reduce all class fields with getter/setter - also added type-hints for primitive variables MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../main/classes/actions/class_BaseAction.php | 25 ++ .../classes/class_BaseFrameworkSystem.php | 50 ---- .../classes/commands/class_BaseCommand.php | 25 ++ .../controller/class_BaseController.php | 25 ++ .../class_CachedLocalFileDatabase.php | 32 ++- .../template/class_BaseTemplateEngine.php | 248 +++++++++--------- .../backend/class_DatabaseBackend.php | 6 +- .../template/class_CompileableTemplate.php | 32 +-- 8 files changed, 252 insertions(+), 191 deletions(-) diff --git a/framework/main/classes/actions/class_BaseAction.php b/framework/main/classes/actions/class_BaseAction.php index aef62776..8b0a2c20 100644 --- a/framework/main/classes/actions/class_BaseAction.php +++ b/framework/main/classes/actions/class_BaseAction.php @@ -4,6 +4,7 @@ namespace Org\Mxchange\CoreFramework\Action; // Import framework stuff use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; +use Org\Mxchange\CoreFramework\Resolver\Resolver; /** * A general action class. You shall extend this class if you are going to write @@ -30,6 +31,11 @@ use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; * along with this program. If not, see . */ abstract class BaseAction extends BaseFrameworkSystem { + /** + * Resolver instance + */ + private $resolverInstance = NULL; + /** * Protected constructor * @@ -41,4 +47,23 @@ abstract class BaseAction extends BaseFrameworkSystem { parent::__construct($className); } + /** + * Setter for resolver instance + * + * @param $resolverInstance Instance of a command resolver class + * @return void + */ + protected final function setResolverInstance (Resolver $resolverInstance) { + $this->resolverInstance = $resolverInstance; + } + + /** + * Getter for resolver instance + * + * @return $resolverInstance Instance of a command resolver class + */ + protected final function getResolverInstance () { + return $this->resolverInstance; + } + } diff --git a/framework/main/classes/class_BaseFrameworkSystem.php b/framework/main/classes/class_BaseFrameworkSystem.php index 8bc95e33..ddfaef46 100644 --- a/framework/main/classes/class_BaseFrameworkSystem.php +++ b/framework/main/classes/class_BaseFrameworkSystem.php @@ -25,7 +25,6 @@ use Org\Mxchange\CoreFramework\Generic\FrameworkInterface; use Org\Mxchange\CoreFramework\Generic\NullPointerException; use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException; use Org\Mxchange\CoreFramework\Handler\Handleable; -use Org\Mxchange\CoreFramework\Handler\Stream\IoHandler; use Org\Mxchange\CoreFramework\Helper\Helper; use Org\Mxchange\CoreFramework\Index\Indexable; use Org\Mxchange\CoreFramework\Lists\Listable; @@ -38,7 +37,6 @@ use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware; use Org\Mxchange\CoreFramework\Parser\Parseable; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Registry\Register; -use Org\Mxchange\CoreFramework\Resolver\Resolver; use Org\Mxchange\CoreFramework\Result\Database\CachedDatabaseResult; use Org\Mxchange\CoreFramework\Result\Search\SearchableResult; use Org\Mxchange\CoreFramework\Stacker\Stackable; @@ -107,16 +105,6 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac */ private $updateInstance = NULL; - /** - * The file I/O instance for the template loader - */ - private $fileIoInstance = NULL; - - /** - * Resolver instance - */ - private $resolverInstance = NULL; - /** * Template engine instance */ @@ -756,25 +744,6 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac return $this->updateInstance; } - /** - * Setter for resolver instance - * - * @param $resolverInstance Instance of a command resolver class - * @return void - */ - public final function setResolverInstance (Resolver $resolverInstance) { - $this->resolverInstance = $resolverInstance; - } - - /** - * Getter for resolver instance - * - * @return $resolverInstance Instance of a command resolver class - */ - public final function getResolverInstance () { - return $this->resolverInstance; - } - /** * Setter for language instance * @@ -903,25 +872,6 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac GenericRegistry::getRegistry()->addInstance('language', $langInstance); } - /** - * Private getter for file IO instance - * - * @return $fileIoInstance An instance to the file I/O sub-system - */ - protected final function getFileIoInstance () { - return $this->fileIoInstance; - } - - /** - * Setter for file I/O instance - * - * @param $fileIoInstance An instance to the file I/O sub-system - * @return void - */ - public final function setFileIoInstance (IoHandler $fileIoInstance) { - $this->fileIoInstance = $fileIoInstance; - } - /** * Protected setter for user instance * diff --git a/framework/main/classes/commands/class_BaseCommand.php b/framework/main/classes/commands/class_BaseCommand.php index 6a353c5f..27387d79 100644 --- a/framework/main/classes/commands/class_BaseCommand.php +++ b/framework/main/classes/commands/class_BaseCommand.php @@ -7,6 +7,7 @@ use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Request\Requestable; +use Org\Mxchange\CoreFramework\Resolver\Resolver; use Org\Mxchange\CoreFramework\Response\Responseable; /** @@ -32,6 +33,11 @@ use Org\Mxchange\CoreFramework\Response\Responseable; * along with this program. If not, see . */ abstract class BaseCommand extends BaseFrameworkSystem { + /** + * Resolver instance + */ + private $resolverInstance = NULL; + /** * Protected constructor * @@ -43,6 +49,25 @@ abstract class BaseCommand extends BaseFrameworkSystem { parent::__construct($className); } + /** + * Setter for resolver instance + * + * @param $resolverInstance Instance of a command resolver class + * @return void + */ + protected final function setResolverInstance (Resolver $resolverInstance) { + $this->resolverInstance = $resolverInstance; + } + + /** + * Getter for resolver instance + * + * @return $resolverInstance Instance of a command resolver class + */ + protected final function getResolverInstance () { + return $this->resolverInstance; + } + /** * Sends a generic HTTP response with header, menu, content and footer * diff --git a/framework/main/classes/controller/class_BaseController.php b/framework/main/classes/controller/class_BaseController.php index 81cb73a4..d8452542 100644 --- a/framework/main/classes/controller/class_BaseController.php +++ b/framework/main/classes/controller/class_BaseController.php @@ -10,6 +10,7 @@ use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Registry\Registerable; use Org\Mxchange\CoreFramework\Request\Requestable; +use Org\Mxchange\CoreFramework\Resolver\Resolver; use Org\Mxchange\CoreFramework\Response\Responseable; /** @@ -44,6 +45,11 @@ abstract class BaseController extends BaseFrameworkSystem implements Registerabl const FILTER_CHAIN_PRE_COMMAND = 'controller_pre_command'; const FILTER_CHAIN_POST_COMMAND = 'controller_post_command'; + /** + * Resolver instance + */ + private $resolverInstance = NULL; + /** * Generic filter chains */ @@ -67,6 +73,25 @@ abstract class BaseController extends BaseFrameworkSystem implements Registerabl GenericRegistry::getRegistry()->addInstance('controller', $this); } + /** + * Setter for resolver instance + * + * @param $resolverInstance Instance of a command resolver class + * @return void + */ + protected final function setResolverInstance (Resolver $resolverInstance) { + $this->resolverInstance = $resolverInstance; + } + + /** + * Getter for resolver instance + * + * @return $resolverInstance Instance of a command resolver class + */ + protected final function getResolverInstance () { + return $this->resolverInstance; + } + /** * Executes a command with pre and post filters * diff --git a/framework/main/classes/database/backend/lfdb_legacy/class_CachedLocalFileDatabase.php b/framework/main/classes/database/backend/lfdb_legacy/class_CachedLocalFileDatabase.php index b4b54759..be670d26 100644 --- a/framework/main/classes/database/backend/lfdb_legacy/class_CachedLocalFileDatabase.php +++ b/framework/main/classes/database/backend/lfdb_legacy/class_CachedLocalFileDatabase.php @@ -11,6 +11,7 @@ use Org\Mxchange\CoreFramework\Database\Backend\DatabaseBackend; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException; use Org\Mxchange\CoreFramework\Generic\FrameworkException; +use Org\Mxchange\CoreFramework\Handler\Stream\IoHandler; // Import SPL stuff use \SplFileInfo; @@ -74,6 +75,11 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac */ private $indexKey = '__idx'; + /** + * The file I/O instance for the template loader + */ + private $fileIoInstance = NULL; + /** * The protected constructor. Do never instance from outside! You need to * set a local file path. The class will then validate it. @@ -171,6 +177,24 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac public final function getIndexKey () { return $this->indexKey; } + /** + * Private getter for file IO instance + * + * @return $fileIoInstance An instance to the file I/O sub-system + */ + protected final function getFileIoInstance () { + return $this->fileIoInstance; + } + + /** + * Setter for file I/O instance + * + * @param $fileIoInstance An instance to the file I/O sub-system + * @return void + */ + public final function setFileIoInstance (IoHandler $fileIoInstance) { + $this->fileIoInstance = $fileIoInstance; + } /** * Reads a local data file and returns it's contents in an array @@ -248,7 +272,7 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac * @param $rowName Name of the row * @return $infoInstance An instance of a SplFileInfo class */ - private function generateFileFromDataSet (Criteria $dataSetInstance, $rowName) { + private function generateFileFromDataSet (Criteria $dataSetInstance, string $rowName) { // Instanciate new file object $infoInstance = new SplFileInfo($this->getConfigInstance()->getConfigEntry('local_database_path') . $dataSetInstance->getTableName() . DIRECTORY_SEPARATOR . $rowName . '.' . $this->getFileExtension()); @@ -352,7 +376,7 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac * @throws UnsupportedCriteriaException If the criteria is unsupported * @throws SqlException If an 'SQL error' occurs */ - public function querySelect ($tableName, LocalSearchCriteria $searchInstance) { + public function querySelect (string $tableName, LocalSearchCriteria $searchInstance) { // The result is null by any errors //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: tableName=%s,searchInstance=%s - CALLED!', $tableName, $searchInstance->__toString())); $resultData = NULL; @@ -628,7 +652,7 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac * @return $primaryKey Primary key column of the given table * @todo Rename method to getPrimaryKeyFromTableInfo() */ - public function getPrimaryKeyOfTable ($tableName) { + public function getPrimaryKeyOfTable (string $tableName) { // Default key is null $primaryKey = NULL; @@ -664,7 +688,7 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac * @param $tableName Table name * @return $count Total rows of given table */ - public function countTotalRows($tableName) { + public function countTotalRows (string $tableName) { //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: tableName=' . $tableName . ' - CALLED!'); // Create full path name diff --git a/framework/main/classes/template/class_BaseTemplateEngine.php b/framework/main/classes/template/class_BaseTemplateEngine.php index 721a0f6c..2460e54c 100644 --- a/framework/main/classes/template/class_BaseTemplateEngine.php +++ b/framework/main/classes/template/class_BaseTemplateEngine.php @@ -6,6 +6,7 @@ namespace Org\Mxchange\CoreFramework\Template\Engine; use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; +use Org\Mxchange\CoreFramework\Handler\Stream\IoHandler; use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException; use Org\Mxchange\CoreFramework\Generic\NullPointerException; use Org\Mxchange\CoreFramework\Manager\ManageableApplication; @@ -41,6 +42,11 @@ use \SplFileInfo; * along with this program. If not, see . */ abstract class BaseTemplateEngine extends BaseFrameworkSystem { + /** + * The file I/O instance for the template loader + */ + private $fileIoInstance = NULL; + /** * The local path name where all templates and sub folders for special * templates are stored. We will internally determine the language plus @@ -195,7 +201,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @param $variableGroup Optional variable group to look in * @return $index false means not found, >=0 means found on a specific index */ - private function getVariableIndex ($variableName, $variableGroup = NULL) { + private function getVariableIndex (string $variableName, string $variableGroup = NULL) { // Replace all dashes to underscores to match variables with configuration entries $variableName = trim(StringUtils::convertDashesToUnderscores($variableName)); @@ -207,7 +213,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { // Use current group //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(__METHOD__.' currGroup=' . $this->currGroup . ' set as stack!'); $variableGroup = $this->currGroup; - } // END - if + } // Is the group there? if ($this->isVarStackSet($variableGroup)) { @@ -220,9 +226,9 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(__METHOD__.':FOUND!'); $found = $index; break; - } // END - if - } // END - foreach - } // END - if + } + } + } // Return the current position return $found; @@ -234,7 +240,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @param $variableGroup Variable group to check * @return $isSet Whether the given variable group is set */ - protected final function isVarStackSet ($variableGroup) { + protected final function isVarStackSet (string $variableGroup) { // Check it $isSet = isset($this->varStack[$variableGroup]); @@ -248,7 +254,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @param $variableGroup Variable group to check * @return $varStack Found variable group */ - public final function getVarStack ($variableGroup) { + public final function getVarStack (string $variableGroup) { return $this->varStack[$variableGroup]; } @@ -259,7 +265,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @param $varStack Variable stack to check * @return void */ - protected final function setVarStack ($variableGroup, array $varStack) { + protected final function setVarStack (string $variableGroup, array $varStack) { $this->varStack[$variableGroup] = $varStack; } @@ -270,7 +276,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @param $variableGroup Optional variable group to look in * @return $content Content of the variable or null if not found */ - protected function readVariable ($variableName, $variableGroup = NULL) { + protected function readVariable (string $variableName, string $variableGroup = NULL) { // Replace all dashes to underscores to match variables with configuration entries $variableName = trim(StringUtils::convertDashesToUnderscores($variableName)); @@ -282,7 +288,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { // Use current group //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(__METHOD__.' currGroup=' . $this->currGroup . ' set as stack!'); $variableGroup = $this->currGroup; - } // END - if + } // Get variable index $found = $this->getVariableIndex($variableName, $variableGroup); @@ -291,7 +297,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { if ($found !== false) { // Read it $content = $this->getVariableValue($variableGroup, $found); - } // END - if + } // Return the current position //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(__METHOD__.': variableGroup=' . $variableGroup . ',variableName=' . $variableName . ', content[' . gettype($content) . ']=' . $content); @@ -305,7 +311,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @param $value Value we want to store in the variable * @return void */ - private function addVariable ($variableName, $value) { + private function addVariable (string $variableName, $value) { // Set general variable group $this->setVariableGroup('general'); @@ -326,7 +332,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { if ($this->isVarStackSet($this->currGroup)) { // Then use it $result = $this->getVarStack($this->currGroup); - } // END - if + } // Return result return $result; @@ -339,7 +345,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @param $add Whether add this group * @return void */ - public function setVariableGroup ($groupName, $add = true) { + public function setVariableGroup (string $groupName, bool $add = true) { // Set group name //* DEBIG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(__METHOD__.': currGroup=' . $groupName); $this->currGroup = $groupName; @@ -347,7 +353,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { // Skip group 'general' if (($groupName != 'general') && ($add === true)) { $this->variableGroups[$groupName] = 'OK'; - } // END - if + } } @@ -358,7 +364,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @param $value Value to store in variable * @return void */ - public function addGroupVariable ($variableName, $value) { + public function addGroupVariable (string $variableName, $value) { // Replace all dashes to underscores to match variables with configuration entries $variableName = trim(StringUtils::convertDashesToUnderscores($variableName)); @@ -382,7 +388,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @param $index Index in variable array * @return $value Value to set */ - private function getVariableValue ($variableGroup, $index) { + private function getVariableValue (string $variableGroup, int $index) { // Return it return $this->varStack[$variableGroup][$index]['value']; } @@ -395,7 +401,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @return void * @throws NoVariableException If the given variable is not found */ - private function modifyVariable ($variableName, $value) { + private function modifyVariable (string $variableName, $value) { // Replace all dashes to underscores to match variables with configuration entries $variableName = trim(StringUtils::convertDashesToUnderscores($variableName)); @@ -406,7 +412,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { if ($index === false) { // Unset variables cannot be modified throw new NoVariableException(array($this, $variableName, $value), self::EXCEPTION_VARIABLE_IS_MISSING); - } // END - if + } // Then modify it $this->setVariableValue($this->currGroup, $index, $value); @@ -420,7 +426,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @param $value Value to set * @return void */ - private function setVariableValue ($variableGroup, $index, $value) { + private function setVariableValue (string $variableGroup, int $index, $value) { $this->varStack[$variableGroup][$index]['value'] = $value; } @@ -434,7 +440,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @param $value Value to set * @return void */ - protected function setVariable ($variableGroup, $variableName, $value) { + protected function setVariable (string $variableGroup, string $variableName, $value) { // Replace all dashes to underscores to match variables with configuration entries $variableName = trim(StringUtils::convertDashesToUnderscores($variableName)); @@ -447,7 +453,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { if (!isset($this->varStack[$variableGroup])) { // Then initialize it here $this->varStack[$variableGroup] = array(); - } // END - if + } // Not found, add it array_push($this->varStack[$variableGroup], $this->generateVariableArray($variableName, $value)); @@ -465,7 +471,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @param $value Value to set * @return $varData Variable data array */ - private function generateVariableArray ($variableName, $value) { + private function generateVariableArray (string $variableName, $value) { // Replace all dashes to underscores to match variables with configuration entries $variableName = trim(StringUtils::convertDashesToUnderscores($variableName)); @@ -486,8 +492,8 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @param $templateType The current template's type * @return void */ - protected final function setTemplateType ($templateType) { - $this->templateType = (string) $templateType; + protected final function setTemplateType (string $templateType) { + $this->templateType = $templateType; } /** @@ -524,9 +530,9 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @param $templateBasePath The relative base path for all templates * @return void */ - protected final function setTemplateBasePath ($templateBasePath) { + protected final function setTemplateBasePath (string $templateBasePath) { // And set it - $this->templateBasePath = (string) $templateBasePath; + $this->templateBasePath = $templateBasePath; } /** @@ -556,9 +562,9 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * templates * @return void */ - protected final function setRawTemplateExtension ($templateExtension) { + protected final function setRawTemplateExtension (string $templateExtension) { // And set it - $this->templateExtension = (string) $templateExtension; + $this->templateExtension = $templateExtension; } /** @@ -568,9 +574,9 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * templates * @return void */ - protected final function setCodeTemplateExtension ($codeExtension) { + protected final function setCodeTemplateExtension (string $codeExtension) { // And set it - $this->codeExtension = (string) $codeExtension; + $this->codeExtension = $codeExtension; } /** @@ -602,9 +608,9 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * templates * @return void */ - protected final function setCompileOutputPath ($compileOutputPath) { + protected final function setCompileOutputPath (string $compileOutputPath) { // And set it - $this->compileOutputPath = (string) $compileOutputPath; + $this->compileOutputPath = $compileOutputPath; } /** @@ -614,18 +620,18 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @param $variableGroup Variable group (default: currGroup) * @return void */ - protected final function unsetVariableStackOffset ($index, $variableGroup = NULL) { + protected final function unsetVariableStackOffset (int $index, string $variableGroup = NULL) { // Is the variable group not set? if (is_null($variableGroup)) { // Then set it to current $variableGroup = $this->currGroup; - } // END - if + } // Is the entry there? if (!isset($this->varStack[$variableGroup][$index])) { // Abort here, we need fixing! $this->debugInstance(); - } // END - if + } // Remove it unset($this->varStack[$variableGroup][$index]); @@ -637,11 +643,11 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @param $rawTemplateData The raw data from the template * @return void */ - protected final function setRawTemplateData ($rawTemplateData) { + protected final function setRawTemplateData (string $rawTemplateData) { // And store it in this class //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(__METHOD__.': ' . strlen($rawTemplateData) . ' Bytes set.'); //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(__METHOD__.': ' . $this->currGroup . ' variables: ' . count($this->getVarStack($this->currGroup)) . ', groups=' . count($this->varStack)); - $this->rawTemplateData = (string) $rawTemplateData; + $this->rawTemplateData = $rawTemplateData; } /** @@ -657,12 +663,13 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { /** * Private setter for compiled templates * + * @param $compiledData Compiled template data * @return void */ - private final function setCompiledData ($compiledData) { + private final function setCompiledData (string $compiledData) { // And store it in this class //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE: ' . strlen($compiledData) . ' Bytes set.'); - $this->compiledData = (string) $compiledData; + $this->compiledData = $compiledData; } /** @@ -683,14 +690,14 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @return void * @throws FileNotFoundException If the template was not found */ - protected function loadTemplate ($templateName, $extOther = '') { + protected function loadTemplate (string $templateName, string $extOther = '') { // Get extension for the template if empty if (empty($extOther)) { // None provided, so get the raw one $ext = $this->getRawTemplateExtension(); } else { // Then use it! - $ext = (string) $extOther; + $ext = $extOther; } /* @@ -734,10 +741,8 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @return void */ private function loadRawTemplateData (SplFileInfo $fileInstance) { - // Some debug code to look on the file which is being loaded - //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE: fileInstance=' . $fileInstance); - // Load the raw template + //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE: fileInstance=' . $fileInstance); $rawTemplateData = $this->getFileIoInstance()->loadFileContents($fileInstance); // Store the template's contents into this class @@ -751,18 +756,16 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * Try to assign an extracted template variable as a "content" or 'config' * variable. * - * @param $variableName The variable's name (shall be content or config) + * @param $variableName The variable's name (shall be content or config) * by default * @param $variableName The variable we want to assign * @return void */ - private function assignTemplateVariable ($variableName, $var) { + private function assignTemplateVariable (string $variableName, $var) { // Replace all dashes to underscores to match variables with configuration entries + //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE: variableName=' . $variableName . ',var=' . $var); $variableName = trim(StringUtils::convertDashesToUnderscores($variableName)); - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE: variableName=' . $variableName . ',variableName=' . $variableName); - // Is it not a config variable? if ($variableName != 'config') { // Regular template variables @@ -779,15 +782,10 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @param $rawData The raw template data we shall analyze * @return void */ - private function extractVariablesFromRawData ($rawData) { - // Cast to string - $rawData = (string) $rawData; - + private function extractVariablesFromRawData (string $rawData) { // Search for variables - preg_match_all('/\$(\w+)(\[(\w+)\])?/', $rawData, $variableMatches); - - // Debug message //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE:rawData(' . strlen($rawData) . ')=' . $rawData . ',variableMatches=' . print_r($variableMatches, true)); + preg_match_all('/\$(\w+)(\[(\w+)\])?/', $rawData, $variableMatches); // Did we find some variables? if ((is_array($variableMatches)) && (count($variableMatches) == 4) && (count($variableMatches[0]) > 0)) { @@ -800,9 +798,9 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { if (!empty($var)) { // Try to assign it, empty strings are being ignored $this->assignTemplateVariable($variableName, $var); - } // END - if - } // END - foreach - } // END - if + } + } + } } /** @@ -828,7 +826,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { // Initialize both $this->loadedRawData = array(); $this->rawTemplates = array(); - } // END - if + } // Load all requested templates foreach ($templateMatches[1] as $template) { @@ -860,8 +858,8 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { array_push($this->rawTemplates, $template); } } - } // END - if - } // END - foreach + } + } // Restore the raw template data $this->setRawTemplateData($backup); @@ -874,12 +872,12 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @param $template The template's name * @return void */ - private function compileCode ($code, $template) { + private function compileCode (string $code, string $template) { // Is this template already compiled? if (in_array($template, $this->compiledTemplates)) { // Abort here... return; - } // END - if + } // Remember this template being compiled array_push($this->compiledTemplates, $template); @@ -927,8 +925,8 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { // Set the new raw data $this->setRawTemplateData($rawData); - } // END - if - } // END - foreach + } + } } /** @@ -958,8 +956,8 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { // This template was never found. We silently ignore it unset($this->rawTemplates[$key]); } - } // END - foreach - } // END - if + } + } } /** @@ -985,7 +983,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { if (substr($varMatches[2][$key], 0, 1) == '=') { // Remove and cast it $varMatches[2][$key] = (string) substr($varMatches[2][$key], 1); - } // END - if + } // Do we have some quotes left and right side? Then it is free text if ((substr($varMatches[2][$key], 0, 1) == '"') && (substr($varMatches[2][$key], -1, 1) == '"')) { @@ -995,7 +993,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { // @TODO Non-string found so we need some deeper analysis... ApplicationEntryPoint::exitApplication('Deeper analysis not yet implemented!'); } - } // END - foreach + } } /** @@ -1020,7 +1018,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { // Then skip it //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE: Template ' . $template . ' already compiled. SKIPPED!'); continue; - } // END - if + } // Search for the template $foundIndex = array_search($template, $templateMatches[1]); @@ -1033,15 +1031,15 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { // Assign all variables $this->assignAllVariables($varMatches); - } // END - if (isset($templateMatches ... + } // Compile the loaded template $this->compileCode($code, $template); - } // END - foreach ($this->loadedRawData ... + } // Insert all templates $this->insertAllTemplates($templateMatches); - } // END - if (count($this->loadedRawData) ... + } } /** @@ -1072,7 +1070,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { // Abort here silently // @TODO This silent abort should be logged, maybe. return; - } // END - if + } // Walk through all variables foreach ($this->getVarStack('general') as $currEntry) { @@ -1086,11 +1084,10 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { // The new behaviour $content = str_replace('{?' . $currEntry['name'] . '?}', $currEntry['value'], $content); - } // END - for - - //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE: content after=' . strlen($content) . ' (' . md5($content) . ')'); + } // Set the content back + //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE: content after=' . strlen($content) . ' (' . md5($content) . ')'); $this->setRawTemplateData($content); } @@ -1101,7 +1098,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * 'html' by default * @return void */ - public function loadHtmlTemplate ($template) { + public function loadHtmlTemplate (string $template) { // Set template type $this->setTemplateType($this->getConfigInstance()->getConfigEntry('html_template_type')); @@ -1115,15 +1112,11 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @param $variableName The variable we are looking for * @param $value The value we want to store in the variable * @return void - * @throws NullPointerException If $variableName is NULL * @throws InvalidArgumentException If the variable name is left empty */ - public final function assignVariable ($variableName, $value) { + public final function assignVariable (string $variableName, $value) { // Validate parameter - if (is_null($variableName)) { - // Throw NPE - throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); - } elseif (empty($variableName)) { + if (empty($variableName)) { // Throw an exception throw new InvalidArgumentException('Parameter "variableName" is empty'); } @@ -1153,7 +1146,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @param $variableGroup Name of variable group (default: 'general') * @return void */ - public final function removeVariable ($variableName, $variableGroup = 'general') { + public final function removeVariable (string $variableName, string $variableGroup = 'general') { // First search for the variable if it was already added $index = $this->getVariableIndex($variableName, $variableGroup); @@ -1162,7 +1155,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { // Remove this variable //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE:UNSET: variableGroup=' . $variableGroup . ',variableName=' . $variableName . ',index=' . $index); $this->unsetVariableStackOffset($index, $variableGroup); - } // END - if + } } /** @@ -1172,7 +1165,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @param $variableName Name of the variable we want to assign * @return void */ - public function assignTemplateWithVariable ($templateName, $variableName) { + public function assignTemplateWithVariable (string $templateName, string $variableName) { // Get the content from last loaded raw template $content = $this->getRawTemplateData(); @@ -1189,7 +1182,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @param $variableName The configuration variable we want to assign * @return void */ - public function assignConfigVariable ($variableName) { + public function assignConfigVariable (string $variableName) { // Replace all dashes to underscores to match variables with configuration entries $variableName = trim(StringUtils::convertDashesToUnderscores($variableName)); @@ -1213,7 +1206,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { foreach ($variables as $name => $value) { // Set variable with name for 'config' group $this->assignVariable($name, $value); - } // END - foreach + } } /** @@ -1245,7 +1238,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * located in 'code' by default * @return void */ - public function loadCodeTemplate ($template) { + public function loadCodeTemplate (string $template) { // Set template type $this->setTemplateType($this->getConfigInstance()->getConfigEntry('code_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_template_type')); @@ -1260,7 +1253,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * located in 'emails' by default * @return void */ - public function loadEmailTemplate ($template) { + public function loadEmailTemplate (string $template) { // Set template type $this->setTemplateType($this->getConfigInstance()->getConfigEntry('email_template_type')); @@ -1281,7 +1274,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { // Abort here silently //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE: Aborted, variable stack general not found!'); return; - } // END - if + } // Iterate through all general variables foreach ($this->getVarStack('general') as $index => $currVariable) { @@ -1303,7 +1296,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { // Re-assign the value directly $this->assignVariable($currVariable['name'], $value); } - } // END - foreach + } } /** @@ -1322,7 +1315,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { // Transfer it's name/value combination to the $content array //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE:' . $currVariable['name'] . '=
' . htmlentities($currVariable['value']).'
'); $dummy[$currVariable['name']] = $currVariable['value']; - }// END - if + } // Set the new variable (don't remove the second dollar!) $$validVar = $dummy; @@ -1359,7 +1352,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { // And put all together $eval = sprintf('%s<%%php %s %%>%s', $evalLeft, $evalMiddle, $evalRight); - } // END - while + } // Prepare PHP code for eval() command $eval = str_replace( @@ -1381,12 +1374,12 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { // Output backtrace here $this->debugBackTrace(); - } // END - if + } // Set raw template data $this->setRawTemplateData($result); $cnt++; - } // END - while + } // Final variable assignment $this->finalizeVariableCompilation(); @@ -1412,7 +1405,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { if (substr($this->getTemplateType(), 0, strlen($codeType)) != $codeType) { // Abort here throw new UnexpectedTemplateTypeException(array($this, $this->getTemplateType(), $this->getConfigInstance()->getConfigEntry('code_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_template_type')), self::EXCEPTION_TEMPLATE_TYPE_IS_UNEXPECTED); - } // END - if + } // Get the raw data. $rawData = $this->getRawTemplateData(); @@ -1449,8 +1442,8 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { // Remove the raw template content as well $this->setRawTemplateData(''); - } // END - if - } // END - if($templateMatches ... + } + } } /** @@ -1459,7 +1452,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @param $helperName The helper's name * @return void */ - protected function loadViewHelper ($helperName) { + protected function loadViewHelper (string $helperName) { // Is this view helper loaded? if (!isset($this->helpers[$helperName])) { // Create a class name @@ -1467,7 +1460,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { // Generate new instance $this->helpers[$helperName] = ObjectFactory::createObjectByName($className); - } // END - if + } // Return the requested instance return $this->helpers[$helperName]; @@ -1491,7 +1484,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @param $setMatchAsCode Sets $match if readVariable() returns empty result * @return $rawCode Compile code with inserted variable value */ - public function compileRawCode ($rawCode, $setMatchAsCode=false) { + public function compileRawCode (string $rawCode, bool $setMatchAsCode = false) { // Find the variables //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE:rawCode=
' . htmlentities($rawCode) . '
'); preg_match_all($this->regExpVarValue, $rawCode, $varMatches); @@ -1521,8 +1514,8 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { // Insert value $rawCode = str_replace($varCode, $value, $rawCode); } - } // END - if - } // END - foreach + } + } // Return the compiled data //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE:rawCode=
' . htmlentities($rawCode) . '
'); @@ -1545,7 +1538,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @param $newName New name of variable * @return void */ - public function renameVariable ($oldName, $newName) { + public function renameVariable (string $oldName, string $newName) { //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE: oldName=' . $oldName . ', newName=' . $newName); // Get raw template code $rawData = $this->getRawTemplateData(); @@ -1564,12 +1557,12 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @return void * @throws XmlParserException If an XML error was found */ - public function renderXmlContent ($content = NULL) { + public function renderXmlContent (string $content = NULL) { // Is the content set? if (is_null($content)) { // Get current content $content = $this->getRawTemplateData(); - } // END - if + } // Get a XmlParser instance $parserInstance = ObjectFactory::createObjectByConfiguredName('xml_parser_class', array($this)); @@ -1578,7 +1571,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { if ($this->isXmlCompactingEnabled()) { // Yes, so get a decorator class for transparent compacting $parserInstance = ObjectFactory::createObjectByConfiguredName('deco_compacting_xml_parser_class', array($parserInstance)); - } // END - if + } // Parse the XML document $parserInstance->parseXmlContent($content); @@ -1590,8 +1583,8 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @param $languageSupport New language support setting * @return void */ - public final function enableLanguageSupport ($languageSupport = true) { - $this->languageSupport = (bool) $languageSupport; + public final function enableLanguageSupport (bool $languageSupport = true) { + $this->languageSupport = $languageSupport; } /** @@ -1609,8 +1602,8 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { * @param $xmlCompacting New XML compacting setting * @return void */ - public final function enableXmlCompacting ($xmlCompacting = true) { - $this->xmlCompacting = (bool) $xmlCompacting; + public final function enableXmlCompacting (bool $xmlCompacting = true) { + $this->xmlCompacting = $xmlCompacting; } /** @@ -1622,13 +1615,32 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { return $this->xmlCompacting; } + /** + * Private getter for file IO instance + * + * @return $fileIoInstance An instance to the file I/O sub-system + */ + protected final function getFileIoInstance () { + return $this->fileIoInstance; + } + + /** + * Setter for file I/O instance + * + * @param $fileIoInstance An instance to the file I/O sub-system + * @return void + */ + public final function setFileIoInstance (IoHandler $fileIoInstance) { + $this->fileIoInstance = $fileIoInstance; + } + /** * Removes all commentd, tabs and new-line characters to compact the content * * @param $uncompactedContent The uncompacted content * @return $compactedContent The compacted content */ - public function compactContent ($uncompactedContent) { + public function compactContent (string $uncompactedContent) { // First, remove all tab/new-line/revert characters $compactedContent = str_replace(chr(9), '', str_replace(chr(10), '', str_replace(chr(13), '', $uncompactedContent))); @@ -1641,8 +1653,8 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { foreach ($matches[0] as $match) { // Remove the match $compactedContent = str_replace($match, '', $compactedContent); - } // END - foreach - } // END - if + } + } // Set the content again $this->setRawTemplateData($compactedContent); diff --git a/framework/main/interfaces/database/backend/class_DatabaseBackend.php b/framework/main/interfaces/database/backend/class_DatabaseBackend.php index 425d4633..4bdbec70 100644 --- a/framework/main/interfaces/database/backend/class_DatabaseBackend.php +++ b/framework/main/interfaces/database/backend/class_DatabaseBackend.php @@ -80,7 +80,7 @@ interface DatabaseBackend extends FrameworkDatabase { * @throws UnsupportedCriteriaException If the criteria is unsupported * @throws SqlException If an 'SQL error' occurs */ - function querySelect ($tableName, LocalSearchCriteria $searchInstance); + function querySelect (string $tableName, LocalSearchCriteria $searchInstance); /** * "Inserts" a data set instance into a local file database folder @@ -107,7 +107,7 @@ interface DatabaseBackend extends FrameworkDatabase { * @param $tableName Name of the table we need the primary key from * @return $primaryKey Primary key column of the given table */ - function getPrimaryKeyOfTable ($tableName); + function getPrimaryKeyOfTable (string $tableName); /** * Removes non-data from given array. @@ -124,6 +124,6 @@ interface DatabaseBackend extends FrameworkDatabase { * @param $tableName Table name * @return $count Total rows of given table */ - function countTotalRows($tableName); + function countTotalRows(string $tableName); } diff --git a/framework/main/interfaces/template/class_CompileableTemplate.php b/framework/main/interfaces/template/class_CompileableTemplate.php index a53efe62..0c6636a1 100644 --- a/framework/main/interfaces/template/class_CompileableTemplate.php +++ b/framework/main/interfaces/template/class_CompileableTemplate.php @@ -36,7 +36,7 @@ interface CompileableTemplate extends FrameworkInterface { * @param $value The value we want to store in the variable * @return void */ - function assignVariable ($variableName, $value); + function assignVariable (string $variableName, $value); /** * Load a specified HTML template into the engine @@ -45,7 +45,7 @@ interface CompileableTemplate extends FrameworkInterface { * "html" by default * @return void */ - function loadHtmlTemplate ($template); + function loadHtmlTemplate (string $template); /** * Load a specified code template into the engine for later compilation @@ -55,7 +55,7 @@ interface CompileableTemplate extends FrameworkInterface { * located in "html" by default * @return void */ - function loadCodeTemplate ($template); + function loadCodeTemplate (string $template); /** * Load a specified email template into the engine for later compilation @@ -65,7 +65,7 @@ interface CompileableTemplate extends FrameworkInterface { * located in "html" by default * @return void */ - function loadEmailTemplate ($template); + function loadEmailTemplate (string $template); /** * Compile all variables by inserting their respective values @@ -89,7 +89,7 @@ interface CompileableTemplate extends FrameworkInterface { * @param $value Value to store in variable * @return void */ - function addGroupVariable ($variableName, $value); + function addGroupVariable (string $variableName, $value); /** * Removes a given variable @@ -98,7 +98,7 @@ interface CompileableTemplate extends FrameworkInterface { * @param $variableGroup Name of variable group (default: 'general') * @return void */ - function removeVariable ($variableName, $variableGroup = 'general'); + function removeVariable (string $variableName, string $variableGroup = 'general'); /** * Assign a given congfiguration variable with a value @@ -106,7 +106,7 @@ interface CompileableTemplate extends FrameworkInterface { * @param $variableName The configuration variable we want to assign * @return void */ - function assignConfigVariable ($variableName); + function assignConfigVariable (string $variableName); /** * Compiles configuration place-holders in all variables. This 'walks' @@ -124,7 +124,7 @@ interface CompileableTemplate extends FrameworkInterface { * @param $variableName Name of the variable we want to assign * @return void */ - function assignTemplateWithVariable ($templateName, $variableName); + function assignTemplateWithVariable (string $templateName, string $variableName); /** * Transfers the content of this template engine to a given response instance @@ -148,7 +148,7 @@ interface CompileableTemplate extends FrameworkInterface { * @param $setMatchAsCode Sets $match if readVariable() returns empty result (default: false) * @return $rawCode Compile code with inserted variable value */ - function compileRawCode ($rawCode, $setMatchAsCode = false); + function compileRawCode (string $rawCode, bool $setMatchAsCode = false); /** * Renames a variable in code and in stack @@ -157,7 +157,7 @@ interface CompileableTemplate extends FrameworkInterface { * @param $newName New name of variable * @return void */ - function renameVariable ($oldName, $newName); + function renameVariable (string $oldName, string $newName); /** * Renders the given XML content @@ -166,7 +166,7 @@ interface CompileableTemplate extends FrameworkInterface { * @return void * @throws XmlParserException If an XML error was found */ - function renderXmlContent ($content = NULL); + function renderXmlContent (string $content = NULL); /** * Enables or disables language support @@ -174,7 +174,7 @@ interface CompileableTemplate extends FrameworkInterface { * @param $languageSupport New language support setting * @return void */ - function enableLanguageSupport ($languageSupport = true); + function enableLanguageSupport (bool $languageSupport = true); /** * Checks whether language support is enabled @@ -189,7 +189,7 @@ interface CompileableTemplate extends FrameworkInterface { * @param $xmlCompacting New XML compacting setting * @return void */ - function enableXmlCompacting ($xmlCompacting = true); + function enableXmlCompacting (bool $xmlCompacting = true); /** * Checks whether XML compacting is enabled @@ -204,7 +204,7 @@ interface CompileableTemplate extends FrameworkInterface { * @param $uncompactedContent The uncompacted content * @return $compactedContent The compacted content */ - function compactContent ($uncompactedContent); + function compactContent (string $uncompactedContent); /** * Getter for given variable group @@ -212,7 +212,7 @@ interface CompileableTemplate extends FrameworkInterface { * @param $variableGroup Variable group to check * @return $varStack Found variable group */ - function getVarStack ($variableGroup); + function getVarStack (string $variableGroup); /** * Settter for variable group @@ -221,7 +221,7 @@ interface CompileableTemplate extends FrameworkInterface { * @param $add Whether add this group * @return void */ - function setVariableGroup ($groupName, $add = true); + function setVariableGroup (string $groupName, bool $add = true); /** * Getter for template type -- 2.39.2