]> git.mxchange.org Git - core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 26 Jan 2025 17:59:24 +0000 (18:59 +0100)
committerRoland Häder <roland@mxchange.org>
Sun, 26 Jan 2025 17:59:24 +0000 (18:59 +0100)
- added returned type-hints

framework/main/classes/decorator/xml/compactor/class_XmlCompactorDecorator.php
framework/main/classes/decorator/xml/template/class_XmlRewriterTemplateDecorator.php
framework/main/classes/parser/xml/class_XmlParser.php
framework/main/classes/template/class_BaseTemplateEngine.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
framework/main/interfaces/parser/class_Parseable.php
framework/main/interfaces/template/class_CompileableTemplate.php
framework/main/interfaces/template/xml/class_CompileableXmlTemplate.php

index 6d7b016531811848615d89bd4df07426eb46d818..b293e574c11b841070103d97732fc2924b2f70ea 100644 (file)
@@ -94,7 +94,7 @@ class XmlCompactorDecorator extends BaseDecorator implements Parseable {
         * @return      void
         * @throws      XmlCompactorDecoratorException  If an XML error was found
         */
-       public function parseXmlContent (string $content) {
+       public function parseXmlContent (string $content): void {
                // Remove all comments for better compacting
                $content = $this->getParserInstance()->getTemplateInstance()->compactContent($content);
 
index 50ff116ebb5a587c7aa93fb4e14ae6f4a6cfa453..d2666c5288d626de1785b63e97a15830d762b8b2 100644 (file)
@@ -8,6 +8,9 @@ use Org\Mxchange\CoreFramework\Response\Responseable;
 use Org\Mxchange\CoreFramework\Template\Xml\CompileableXmlTemplate;
 use Org\Mxchange\CoreFramework\Traits\Template\CompileableTemplateTrait;
 
+// Import SPL stuff
+use \XMLParser;
+
 /**
  * A decorator for XML template engines which rewrites the XML for compacting
  * it.
@@ -334,7 +337,7 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableX
         * @return      void
         * @throws      XmlParserException      If an XML error was found
         */
-       public function renderXmlContent (string $content = '') {
+       public function renderXmlContent (string $content = ''): void {
                // Call the inner class' method
                $this->getTemplateInstance()->renderXmlContent($content);
        }
@@ -345,7 +348,7 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableX
         * @param       $languageSupport        New language support setting
         * @return      void
         */
-       public function enableLanguageSupport (bool $languageSupport = true) {
+       public function enableLanguageSupport (bool $languageSupport = true): void {
                // Call the inner class' method
                $this->getTemplateInstance()->enableLanguageSupport($languageSupport);
        }
@@ -355,7 +358,7 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableX
         *
         * @return      $languageSupport        Whether language support is enabled or disabled
         */
-       public function isLanguageSupportEnabled () {
+       public function isLanguageSupportEnabled (): bool {
                // Call the inner class' method
                return $this->getTemplateInstance()->isLanguageSupportEnabled();
        }
@@ -366,7 +369,7 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableX
         * @param       $xmlCompacting  New XML compacting setting
         * @return      void
         */
-       public function enableXmlCompacting (bool $xmlCompacting = true) {
+       public function enableXmlCompacting (bool $xmlCompacting = true): void {
                // Call the inner class' method
                $this->getTemplateInstance()->enableXmlCompacting($xmlCompacting);
        }
@@ -376,7 +379,7 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableX
         *
         * @return      $xmlCompacting  Whether XML compacting is enabled or disabled
         */
-       public function isXmlCompactingEnabled () {
+       public function isXmlCompactingEnabled (): bool {
                // Call the inner class' method
                return $this->getTemplateInstance()->isXmlCompactingEnabled();
        }
@@ -390,7 +393,7 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableX
         * @return      void
         * @throws      InvalidXmlNodeException         If an unknown/invalid XML node name was found
         */
-       public function startElement ($resource, string $element, array $attributes) {
+       public function startElement (XMLParser $resource, string $element, array $attributes): void {
                // Call the inner class' method
                $this->getTemplateInstance()->startElement($resource, $element, $attributes);
        }
@@ -403,7 +406,7 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableX
         * @return      void
         * @throws      XmlNodeMismatchException        If current main node mismatches the closing one
         */
-       public function finishElement ($resource, string $nodeName) {
+       public function finishElement (XMLParser $resource, string $nodeName): void {
                // Call the inner class' method
                $this->getTemplateInstance()->finishElement($resource, $nodeName);
        }
@@ -416,7 +419,7 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableX
         * @return      void
         * @todo        Find something useful with this!
         */
-       public function characterHandler ($resource, string $characters) {
+       public function characterHandler (XMLParser $resource, string $characters): void {
                // Call the inner class' method but trim the characters before
                $this->getTemplateInstance()->characterHandler($resource, trim($characters));
        }
@@ -427,7 +430,7 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableX
         * @param       $uncompactedContent             The uncompacted content
         * @return      $compactedContent               The compacted content
         */
-       public function compactContent (string $uncompactedContent) {
+       public function compactContent (string $uncompactedContent): string {
                // Compact it ...
                $compactedContent = $this->getTemplateInstance()->compactContent($uncompactedContent);
 
@@ -445,7 +448,7 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableX
         * @param       $variables      An array with variables to be assigned
         * @return      void
         */
-       public function assignMultipleVariables (array $variables) {
+       public function assignMultipleVariables (array $variables): void {
                // Call the inner class' method but trim the characters before
                $this->getTemplateInstance()->assignMultipleVariables($variables);
        }
index 7b09884e3d00fb75d1e33bac5185a97e70c35954..9565d7b47b461beff6fdcb99c0c2da1557a684d7 100644 (file)
@@ -69,7 +69,7 @@ class XmlParser extends BaseParser implements Parseable {
         * @return      void
         * @throws      XmlParserException      If an XML error was found
         */
-       public function parseXmlContent (string $content) {
+       public function parseXmlContent (string $content): void {
                // Convert all to UTF8
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('XML-PARSER: content()=%d - CALLED!', strlen($content)));
                if (empty($content)) {
index f428be61f410dc87f29f8e250a2ed9c23d1ee252..c29e06442e4be7711ce5494c2031fd8716f6ee35 100644 (file)
@@ -1818,7 +1818,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem {
         * @param       $languageSupport        New language support setting
         * @return      void
         */
-       public final function enableLanguageSupport (bool $languageSupport = true) {
+       public final function enableLanguageSupport (bool $languageSupport = true): void {
                $this->languageSupport = $languageSupport;
        }
 
@@ -1827,7 +1827,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem {
         *
         * @return      $languageSupport        Whether language support is enabled or disabled
         */
-       public final function isLanguageSupportEnabled () {
+       public final function isLanguageSupportEnabled (): bool {
                return $this->languageSupport;
        }
 
@@ -1837,7 +1837,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem {
         * @param       $uncompactedContent             The uncompacted content
         * @return      $compactedContent               The compacted content
         */
-       public function compactContent (string $uncompactedContent) {
+       public function compactContent (string $uncompactedContent): string {
                // Validate parameter
                if (empty($uncompactedContent)) {
                        // Throw an exception
index 31a011da6426459a28df8ab2b968646f0b2a5507..7536d2e6d686ffe25e18ea7509111545b3a4396b 100644 (file)
@@ -19,6 +19,7 @@ use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils;
 // Import SPL stuff
 use \SplFileInfo;
 use \UnexpectedValueException;
+use \XMLParser;
 
 /**
  * The own template engine for loading caching and sending out images
@@ -196,7 +197,7 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl
         * @return      void
         * @throws      InvalidXmlNodeException         If an unknown/invalid XML node name was found
         */
-       public function startElement ($resource, string $element, array $attributes) {
+       public function startElement (XMLParser $resource, string $element, array $attributes): void {
                // Initial method name which will never be called...
                $methodName = 'initImage';
 
@@ -229,7 +230,7 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl
         * @return      void
         * @throws      XmlNodeMismatchException        If current main node mismatches the closing one
         */
-       public function finishElement ($resource, string $nodeName) {
+       public function finishElement (XMLParser $resource, string $nodeName): void {
                // Does this match with current main node?
                //* DEBUG: */ echo "END: &gt;".$nodeName."&lt;<br />\n";
                if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) {
@@ -255,7 +256,7 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl
         * @return      void
         * @todo        Find something usefull with this!
         */
-       public function characterHandler ($resource, string $characters) {
+       public function characterHandler (XMLParser $resource, string $characters): void {
                // Trim all spaces away
                $characters = trim($characters);
 
index a54f98d9cbc28c947e57bf7ebe766cdb23f8561d..7c536b7eb5b0bcbbcd3b1a47a83ccf9776e86325 100644 (file)
@@ -16,6 +16,7 @@ use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils;
 
 // Import SPL stuff
 use \UnexpectedValueException;
+use \XMLParser;
 
 /**
  * The own template engine for loading caching and sending out images
@@ -166,7 +167,7 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla
         * @return      void
         * @throws      InvalidXmlNodeException         If an unknown/invalid XML node name was found
         */
-       public function startElement ($resource, string $element, array $attributes) {
+       public function startElement (XMLParser $resource, string $element, array $attributes): void {
                // Initial method name which will never be called...
                $methodName = 'initEmail';
 
@@ -199,7 +200,7 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla
         * @return      void
         * @throws      XmlNodeMismatchException        If current main node mismatches the closing one
         */
-       public function finishElement ($resource, string $nodeName) {
+       public function finishElement (XMLParser $resource, string $nodeName): void {
                // Does this match with current main node?
                //* DEBUG: */ echo "END: &gt;".$nodeName."&lt;<br />\n";
                if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) {
@@ -224,7 +225,7 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla
         * @param       $characters             Characters to handle
         * @return      void
         */
-       public function characterHandler ($resource, string $characters) {
+       public function characterHandler (XMLParser $resource, string $characters): void {
                // Trim all spaces away
                $characters = trim($characters);
 
index 53febfd625e824184b783a20f2d07e729b297c7a..1908894c84f5d7c6ff596c24f75cc833d2a670d2 100644 (file)
@@ -18,6 +18,7 @@ use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils;
 // Import SPL stuff
 use \SplFileInfo;
 use \UnexpectedValueException;
+use \XMLParser;
 
 /**
  * A Menu template engine class
@@ -281,7 +282,7 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
         * @return      void
         * @throws      InvalidXmlNodeException         If an unknown/invalid XML node name was found
         */
-       public function startElement ($resource, string $element, array $attributes) {
+       public function startElement (XMLParser $resource, string $element, array $attributes): void {
                // Initial method name which will never be called...
                $methodName = 'initMenu';
 
@@ -317,12 +318,12 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
         * @return      void
         * @throws      XmlNodeMismatchException        If current main node mismatches the closing one
         */
-       public function finishElement ($resource, string $nodeName) {
+       public function finishElement (XMLParser $resource, string $nodeName): void {
                // Does this match with current main node?
                //* DEBUG: */ echo "END: &gt;".$nodeName."&lt;<br />\n";
                if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) {
                        // Did not match!
-                       throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), Parseable::EXCEPTION_XML_NODE_MISMATCH);
+                       throw new XmlNodeMismatchException ([$this, $nodeName, $this->getCurrMainNode()], Parseable::EXCEPTION_XML_NODE_MISMATCH);
                }
 
                // Construct method name
@@ -341,7 +342,7 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
         * @return      void
         * @todo        Find something useful with this!
         */
-       public function characterHandler ($resource, string $characters) {
+       public function characterHandler (XMLParser $resource, string $characters): void {
                // Trim all spaces away
                $characters = trim($characters);
 
@@ -363,7 +364,7 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
         * @param       $templateDependency             A template to load to satisfy dependencies
         * @return      void
         */
-       private function handleTemplateDependency (string $node, string $templateDependency) {
+       private function handleTemplateDependency (string $node, string $templateDependency): void {
                // Is the template dependency set?
                if ((!empty($templateDependency)) && (!isset($this->dependencyContent[$node]))) {
                        // Get a temporay menu template instance
@@ -387,7 +388,7 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
         * @return      void
         * @todo        Add cache creation here
         */
-       private function initMenu (string $templateDependency = '') {
+       private function initMenu (string $templateDependency = ''): void {
                // Get web template engine
                $this->setTemplateInstance(ObjectFactory::createObjectByConfiguredName('html_template_class', array(ApplicationHelper::getSelfInstance())));
 
@@ -885,7 +886,7 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
         *
         * @return      $fileInstance   Full-qualified file name of the menu cache
         */
-       public function getMenuCacheFile () {
+       public function getMenuCacheFile (): SplFileInfo {
                // Get the application instance from registry
                $applicationInstance = ApplicationHelper::getSelfInstance();
 
index 7d344ac7fc35f59104ae242f62d42369f4cd00e8..5315ef7177b52ce9f5c36d2133f16d8f5bdaa627 100644 (file)
@@ -17,6 +17,7 @@ use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils;
 
 // Import SPL stuff
 use \InvalidArgumentException;
+use \XMLParser;
 
 /**
  * A generic XML template engine class
@@ -314,7 +315,7 @@ abstract class BaseXmlTemplateEngine extends BaseTemplateEngine implements Compi
         * @return      void
         * @throws      InvalidArgumentException        If a parameter has an invalid value
         */
-       protected function handleTemplateDependency (string $node, string $templateDependency) {
+       protected function handleTemplateDependency (string $node, string $templateDependency): void {
                // Check parameter
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: node=%s,templateDependency=%s - CALLED!', $node, $templateDependency));
                if (empty($node)) {
@@ -361,13 +362,10 @@ abstract class BaseXmlTemplateEngine extends BaseTemplateEngine implements Compi
         * @throws      InvalidArgumentException        If a parameter has an invalid value
         * @throws      InvalidXmlNodeException         If an unknown/invalid XML node name was found
         */
-       public final function startElement ($resource, string $element, array $attributes) {
+       public final function startElement ($resource, string $element, array $attributes): void {
                // Check parameters
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: resource[%s]=%s,element=%s,attributes()=%d - CALLED!', gettype($resource), $resource, $element, count($attributes)));
-               if (!is_resource($resource)) {
-                       // Throw IAE
-                       throw new InvalidArgumentException(sprintf('Parameter resource has unexpected type %s', gettype($resource)), FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
-               } elseif (empty($element)) {
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: resource[%s]=%s,element=%s,attributes()=%d - CALLED!', gettype($resource), get_class($resource), $element, count($attributes)));
+               if (empty($element)) {
                        // Throw IAE
                        throw new InvalidArgumentException('Parameter "element" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
                }
@@ -411,13 +409,10 @@ abstract class BaseXmlTemplateEngine extends BaseTemplateEngine implements Compi
         * @return      void
         * @throws      XmlNodeMismatchException        If current main node mismatches the closing one
         */
-       public final function finishElement ($resource, string $nodeName) {
+       public final function finishElement (XMLParser $resource, string $nodeName): void {
                // Check parameters
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: resource[%s]=%s,nodeName=%s - CALLED!', gettype($resource), $resource, $nodeName));
-               if (!is_resource($resource)) {
-                       // Throw IAE
-                       throw new InvalidArgumentException(sprintf('Parameter resource has unexpected type %s', gettype($resource)), FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
-               } elseif (empty($nodeName)) {
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: resource[%s]=%s,nodeName=%s - CALLED!', gettype($resource), get_class($resource), $nodeName));
+               if (empty($nodeName)) {
                        // Throw IAE
                        throw new InvalidArgumentException('Parameter "nodeName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
                }
@@ -450,7 +445,7 @@ abstract class BaseXmlTemplateEngine extends BaseTemplateEngine implements Compi
         * @return      void
         * @throws      InvalidArgumentException        If a parameter has an invalid value
         */
-       public function renderXmlContent (string $content = '') {
+       public function renderXmlContent (string $content = ''): void {
                // Is the content set?
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: content[%s]()=%d - CALLED!', gettype($content), strlen($content)));
                if (empty($content)) {
@@ -485,7 +480,7 @@ abstract class BaseXmlTemplateEngine extends BaseTemplateEngine implements Compi
         * @param       $xmlCompacting  New XML compacting setting
         * @return      void
         */
-       public final function enableXmlCompacting (bool $xmlCompacting = true) {
+       public final function enableXmlCompacting (bool $xmlCompacting = true): void {
                $this->xmlCompacting = $xmlCompacting;
        }
 
@@ -494,7 +489,7 @@ abstract class BaseXmlTemplateEngine extends BaseTemplateEngine implements Compi
         *
         * @return      $xmlCompacting  Whether XML compacting is enabled or disabled
         */
-       public final function isXmlCompactingEnabled () {
+       public final function isXmlCompactingEnabled (): bool {
                return $this->xmlCompacting;
        }
 
index 8af81f78e0096cd02eb9bbd5fb818bd7cf85a460..608d7229f192c6af53e52995530496cf4e99dbbf 100644 (file)
@@ -40,6 +40,6 @@ interface Parseable extends FrameworkInterface {
         * @return      void
         * @throws      XmlParserException      If an XML error was found
         */
-       function parseXmlContent (string $content);
+       function parseXmlContent (string $content): void;
 
 }
index eae7325888ec368a617c7af66900afc9cb103fe5..c0350deafdf4e249b96b1a9200f7284e91dc6cdd 100644 (file)
@@ -165,14 +165,14 @@ interface CompileableTemplate extends FrameworkInterface {
         * @param       $languageSupport        New language support setting
         * @return      void
         */
-       function enableLanguageSupport (bool $languageSupport = true);
+       function enableLanguageSupport (bool $languageSupport = true): void;
 
        /**
         * Checks whether language support is enabled
         *
         * @return      $languageSupport        Whether language support is enabled or disabled
         */
-       function isLanguageSupportEnabled ();
+       function isLanguageSupportEnabled (): bool;
 
        /**
         * Getter for given variable group
index fc05362b3b0fc749547e0c019b6dd84f78314f73..4d33ffee2576de38b74a9639c4af3ad8865f2c6a 100644 (file)
@@ -36,7 +36,7 @@ interface CompileableXmlTemplate extends CompileableTemplate {
         * @return      void
         * @throws      XmlParserException      If an XML error was found
         */
-       function renderXmlContent (string $content = '');
+       function renderXmlContent (string $content = ''): void;
 
        /**
         * Enables or disables XML compacting
@@ -44,14 +44,14 @@ interface CompileableXmlTemplate extends CompileableTemplate {
         * @param       $xmlCompacting  New XML compacting setting
         * @return      void
         */
-       function enableXmlCompacting (bool $xmlCompacting = true);
+       function enableXmlCompacting (bool $xmlCompacting = true): void;
 
        /**
         * Checks whether XML compacting is enabled
         *
         * @return      $xmlCompacting  Whether XML compacting is enabled or disabled
         */
-       function isXmlCompactingEnabled ();
+       function isXmlCompactingEnabled (): bool;
 
        /**
         * Removes all comments, tabs and new-line charcters to compact the content
@@ -59,6 +59,6 @@ interface CompileableXmlTemplate extends CompileableTemplate {
         * @param       $uncompactedContent             The uncompacted content
         * @return      $compactedContent               The compacted content
         */
-       function compactContent (string $uncompactedContent);
+       function compactContent (string $uncompactedContent): string;
 
 }