]> git.mxchange.org Git - core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Fri, 22 Aug 2025 02:12:25 +0000 (04:12 +0200)
committerRoland Häder <roland@mxchange.org>
Fri, 22 Aug 2025 02:17:14 +0000 (04:17 +0200)
- getVariableIndex() does never return false, but -1 if $variableName was not
  found

framework/main/classes/template/class_BaseTemplateEngine.php

index cf27c1b33136463ccf9a70aa0639871c6809d364..bef771602e2802de01ed3e8e32b2565efb65abb8 100644 (file)
@@ -351,7 +351,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem {
 
                // Is the variable found?
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: found[]=%s', gettype($found)));
-               if ($found !== false) {
+               if ($found > -1) {
                        // Read it
                        /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: Invoking this->getVariableValue(%s,%s) ...', $variableGroup, $found));
                        $value = $this->getVariableValue($variableGroup, $found);
@@ -506,6 +506,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem {
                // Get index for variable
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: this->getVariableIndex(%s) ...', $variableName));
                $index = $this->getVariableIndex($variableName);
+               assert($index >= 0, sprintf('variableName=%s not found', $variableName));
 
                // Then modify it
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: this->setVariableValue(%s,%d,value[]=%s) ...', $this->currGroup, $index, gettype($value)));
@@ -562,8 +563,8 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem {
                $index = $this->getVariableIndex($variableName);
 
                // Is the variable set?
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: index[]=%s', gettype($index)));
-               if ($index === false) {
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: index[%s]=%d', gettype($index), $index));
+               if ($index === -1) {
                        // Is the stack there?
                        if (!isset($this->varStack[$variableGroup])) {
                                // Then initialize it here
@@ -1009,7 +1010,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem {
                        if ((!isset($this->loadedRawData[$template])) && (!in_array($template, $this->loadedTemplates))) {
                                // Template not found, but maybe variable assigned?
                                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: template=%s not loaded yet', $template));
-                               if ($this->getVariableIndex($template) !== false) {
+                               if ($this->getVariableIndex($template) > -1) {
                                        // Use that content here
                                        /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: Assigning this->loadedTemplateData[%s] from variable template=%s ...', $template, $template));
                                        $this->loadedRawData[$template] = $this->readVariable($template);
@@ -1326,7 +1327,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem {
                $index = $this->getVariableIndex($variableName);
 
                // Was it found?
-               if ($index === false) {
+               if ($index === -1) {
                        // Add it to the stack
                        //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE:ADD: ' . $variableName . '[' . gettype($value) . ']=' . $value);
                        $this->addVariable($variableName, $value);
@@ -1359,7 +1360,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem {
                $index = $this->getVariableIndex($variableName, $variableGroup);
 
                // Was it found?
-               if ($index !== false) {
+               if ($index > -1) {
                        // Remove this variable
                        //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE:UNSET: variableGroup=' . $variableGroup . ',variableName=' . $variableName . ',index=' . $index);
                        $this->unsetVariableStackOffset($index, $variableGroup);