From f95c0c00cfacd551b4f85ee441fc62037c84ad82 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 22 Aug 2025 01:10:00 +0200 Subject: [PATCH] Continued: - more type-hints added --- framework/main/classes/lists/class_ | 9 ++++--- .../lists/groups/class_ListGroupList.php | 5 +++- .../classes/lists/tasks/class_TaskList.php | 5 +++- framework/main/classes/mailer/class_ | 6 ++--- .../main/classes/mailer/class_BaseMailer.php | 24 +++++++++---------- .../mailer/debug/class_DebugMailer.php | 8 +++---- .../main/classes/menu/class_BaseMenu.php | 4 ++-- .../main/interfaces/lists/class_Listable.php | 17 ++++++------- .../main/interfaces/logging/class_Logger.php | 12 +++++----- .../interfaces/login/class_LoginableUser.php | 6 ++--- .../mailer/class_DeliverableMail.php | 8 +++---- .../interfaces/menu/class_RenderableMenu.php | 4 ++-- 12 files changed, 59 insertions(+), 49 deletions(-) diff --git a/framework/main/classes/lists/class_ b/framework/main/classes/lists/class_ index 93cc43dd..14d69614 100644 --- a/framework/main/classes/lists/class_ +++ b/framework/main/classes/lists/class_ @@ -2,6 +2,9 @@ // Import framework stuff use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware; +// Import SPL stuff +use \Iterator; + /** * A ??? list * @@ -40,7 +43,7 @@ class ???List extends BaseList implements Listable { * * @return $listInstance An instance a Listable class */ - public final static function create???List () { + public final static function create???List (): Listable { // Get new instance $listInstance = new ???List(); @@ -54,7 +57,7 @@ class ???List extends BaseList implements Listable { * @return $iteratorInstance An instance of a Iterator class * @todo 0% done */ - public function getListIterator () { + public function getListIterator (): Iterator { DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.'); } @@ -64,7 +67,7 @@ class ???List extends BaseList implements Listable { * @return void * @todo 0% done */ - public function clearList () { + public function clearList (): void { DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.'); } diff --git a/framework/main/classes/lists/groups/class_ListGroupList.php b/framework/main/classes/lists/groups/class_ListGroupList.php index 8587b889..339e6085 100644 --- a/framework/main/classes/lists/groups/class_ListGroupList.php +++ b/framework/main/classes/lists/groups/class_ListGroupList.php @@ -7,6 +7,9 @@ use Org\Mxchange\CoreFramework\Lists\BaseList; use Org\Mxchange\CoreFramework\Lists\Listable; use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware; +// Import SPL stuff +use \Iterator; + /** * A ListGroup list * @@ -58,7 +61,7 @@ class ListGroupList extends BaseList implements Listable { * * @return $iteratorInstance An instance of a Iterator class */ - public function getListIterator () { + public function getListIterator (): Iterator{ $this->debugInstance($this->__toString() . ' uses the default iterator. Please call getIterator() instead!'); } diff --git a/framework/main/classes/lists/tasks/class_TaskList.php b/framework/main/classes/lists/tasks/class_TaskList.php index be75722e..2432e754 100644 --- a/framework/main/classes/lists/tasks/class_TaskList.php +++ b/framework/main/classes/lists/tasks/class_TaskList.php @@ -6,6 +6,9 @@ namespace Org\Mxchange\CoreFramework\Lists\Task; use Org\Mxchange\CoreFramework\Lists\BaseList; use Org\Mxchange\CoreFramework\Lists\Listable; +// Import SPL stuff +use \Iterator; + /** * A Task list * @@ -60,7 +63,7 @@ class TaskList extends BaseList implements Listable { * * @return $iteratorInstance An instance of a Iterator class */ - public function getListIterator () { + public function getListIterator (): Iterator { $this->debugInstance($this->__toString() . ' uses the default iterator. Please call getIterator() instead!'); } diff --git a/framework/main/classes/mailer/class_ b/framework/main/classes/mailer/class_ index 55b566a3..e4ac3651 100644 --- a/framework/main/classes/mailer/class_ +++ b/framework/main/classes/mailer/class_ @@ -45,7 +45,7 @@ class ???Mailer extends BaseMailer implements DeliverableMail { * * @return $mailerInstance An instance of this mailer class */ - public final static function create???Mailer () { + public final static function create???Mailer (): DeliverableMail { // Get a new instance $mailerInstance = new ???Mailer(); @@ -59,7 +59,7 @@ class ???Mailer extends BaseMailer implements DeliverableMail { * @return void * @todo 0% done */ - public function deliverEmail() { + public function deliverEmail(): void { DebugMiddleware::getSelfInstance()->partialStub("You have to implement this method."); } @@ -69,7 +69,7 @@ class ???Mailer extends BaseMailer implements DeliverableMail { * @return void * @todo 0% done */ - public function sendAdminNotification() { + public function sendAdminNotification(): void { DebugMiddleware::getSelfInstance()->partialStub("You have to implement this method."); } diff --git a/framework/main/classes/mailer/class_BaseMailer.php b/framework/main/classes/mailer/class_BaseMailer.php index 840bb616..b54130cc 100644 --- a/framework/main/classes/mailer/class_BaseMailer.php +++ b/framework/main/classes/mailer/class_BaseMailer.php @@ -57,7 +57,7 @@ abstract class BaseMailer extends BaseFrameworkSystem { * @param $templateName Name of the template we shall load * @return void */ - protected final function loadTemplate (string $templateName) { + protected final function loadTemplate (string $templateName): void { // Set template name $this->setTemplateName($templateName); @@ -74,7 +74,7 @@ abstract class BaseMailer extends BaseFrameworkSystem { * @param $userInstance An instance of a user class * @return void */ - public function addRecipientByUserInstance (ManageableMember $userInstance) { + public function addRecipientByUserInstance (ManageableMember $userInstance): void { // Get template name $templateName = $this->getTemplateName(); @@ -89,7 +89,7 @@ abstract class BaseMailer extends BaseFrameworkSystem { * @param $variableName Template variable name to add * @return void */ - private function addTemplateVariable ($section, $variableName) { + private function addTemplateVariable ($section, $variableName): void { // Get template name $templateName = $this->getTemplateName(); @@ -106,7 +106,7 @@ abstract class BaseMailer extends BaseFrameworkSystem { * @param $variableName Template variable name to add * @return void */ - public final function addConfigTemplateVariable ($variableName) { + public final function addConfigTemplateVariable (string $variableName): void { $this->addTemplateVariable('config', $variableName); } @@ -116,7 +116,7 @@ abstract class BaseMailer extends BaseFrameworkSystem { * @param $variableName Template variable name to add * @return void */ - public final function addValueTemplateVariable ($variableName) { + public final function addValueTemplateVariable (string $variableName): void { $this->addTemplateVariable('value', $variableName); } @@ -127,7 +127,7 @@ abstract class BaseMailer extends BaseFrameworkSystem { * @param $valueInstance An object instance which can provide "field values" * @return void */ - public final function addValueInstance (string $variableName, FrameworkInterface $valueInstance) { + public final function addValueInstance (string $variableName, FrameworkInterface $valueInstance): void { $this->setGenericArrayElement('recipients', $this->getTemplateName(), 'values', $variableName, $valueInstance); } @@ -137,7 +137,7 @@ abstract class BaseMailer extends BaseFrameworkSystem { * @param $templateName Name of email template * @return void */ - public final function setTemplateName (string $templateName) { + public final function setTemplateName (string $templateName): void { $this->templateName = $templateName; } @@ -146,7 +146,7 @@ abstract class BaseMailer extends BaseFrameworkSystem { * * @return $templateName Name of email template */ - protected final function getTemplateName () { + protected final function getTemplateName (): string { return $this->templateName; } @@ -156,7 +156,7 @@ abstract class BaseMailer extends BaseFrameworkSystem { * @param $subjectLine Subject line to set * @return void */ - public final function setSubjectLine (string $subjectLine) { + public final function setSubjectLine (string $subjectLine): void { $this->setGenericArrayElement('recipients', $this->getTemplateName(), 'generic', 'subject', $subjectLine); } @@ -165,7 +165,7 @@ abstract class BaseMailer extends BaseFrameworkSystem { * * @return $subjectLine Subject line to set */ - public final function getSubjectLine () { + public final function getSubjectLine (): string { // Default subject is null $subjectLine = NULL; @@ -187,7 +187,7 @@ abstract class BaseMailer extends BaseFrameworkSystem { * * @return void */ - public function useSubjectFromTemplate () { + public function useSubjectFromTemplate (): void { // Set the subject line $this->setSubjectLine('{?subject?}'); } @@ -197,7 +197,7 @@ abstract class BaseMailer extends BaseFrameworkSystem { * * @return $recipientList Array with reciepients */ - public final function getRecipientList () { + public final function getRecipientList (): array { return $this->getGenericArray('recipients'); } diff --git a/framework/main/classes/mailer/debug/class_DebugMailer.php b/framework/main/classes/mailer/debug/class_DebugMailer.php index 884b3858..61dfd935 100644 --- a/framework/main/classes/mailer/debug/class_DebugMailer.php +++ b/framework/main/classes/mailer/debug/class_DebugMailer.php @@ -57,7 +57,7 @@ class DebugMailer extends BaseMailer implements DeliverableMail { * @param $templateName Name of email template to set * @return $mailerInstance An instance of this mailer class */ - public static final function createDebugMailer (CompileableTemplate $templateInstance, string $templateName) { + public static final function createDebugMailer (CompileableTemplate $templateInstance, string $templateName): DeliverableMail { // Get a new instance $mailerInstance = new DebugMailer(); @@ -77,7 +77,7 @@ class DebugMailer extends BaseMailer implements DeliverableMail { * @return void * @throws UnexpectedValueException If the recipient instance does not implement ManageableMember */ - public function deliverEmail () { + public function deliverEmail (): void { // Get template instance $templateInstance = $this->getTemplateInstance(); @@ -136,7 +136,7 @@ class DebugMailer extends BaseMailer implements DeliverableMail { * @return void * @todo 0% done */ - public function sendAdminNotification () { + public function sendAdminNotification (): void { // Unfinished work } @@ -145,7 +145,7 @@ class DebugMailer extends BaseMailer implements DeliverableMail { * * @return void */ - public function invokeMailDelivery () { + public function invokeMailDelivery (): void { // Get template instance $templateInstance = $this->getTemplateInstance(); diff --git a/framework/main/classes/menu/class_BaseMenu.php b/framework/main/classes/menu/class_BaseMenu.php index 72ed27cf..57a5a010 100644 --- a/framework/main/classes/menu/class_BaseMenu.php +++ b/framework/main/classes/menu/class_BaseMenu.php @@ -54,7 +54,7 @@ abstract class BaseMenu extends BaseFrameworkSystem { * * @return void */ - public function renderMenu () { + public function renderMenu (): void { // Initialize the menu system by preparing it's template instance $templateInstance = ObjectFactory::createObjectByConfiguredName('menu_template_class', [$this]); @@ -93,7 +93,7 @@ abstract class BaseMenu extends BaseFrameworkSystem { * @param $templateInstance An instance of a CompileableTemplate class * @return void */ - public function transferContentToTemplateEngine (CompileableTemplate $templateInstance) { + public function transferContentToTemplateEngine (CompileableTemplate $templateInstance): void { // Assign menu content to variable $templateInstance->assignVariable('menu', $this->getTemplateInstance()->getMenuContent()); //* DEBUG */ $templateInstance->debugInstance(); diff --git a/framework/main/interfaces/lists/class_Listable.php b/framework/main/interfaces/lists/class_Listable.php index ce6087e4..fc514b72 100644 --- a/framework/main/interfaces/lists/class_Listable.php +++ b/framework/main/interfaces/lists/class_Listable.php @@ -7,6 +7,7 @@ use Org\Mxchange\CoreFramework\Generic\FrameworkInterface; use Org\Mxchange\CoreFramework\Visitor\Visitable; // Import SPL stuff +use \Iterator; use \IteratorAggregate; /** @@ -38,7 +39,7 @@ interface Listable extends FrameworkInterface, IteratorAggregate { * @param $groupName Group to check if found in list * @return $isset Whether the group is valid */ - function isGroupSet (string $groupName); + function isGroupSet (string $groupName): bool; /** * Adds the given group or if already added issues a BadMethodCallException @@ -47,7 +48,7 @@ interface Listable extends FrameworkInterface, IteratorAggregate { * @return void * @throws BadMethodCallException If the given group is already added */ - function addGroup (string $groupName); + function addGroup (string $groupName): void; /** * Adds the given instance to list group and sub group @@ -58,7 +59,7 @@ interface Listable extends FrameworkInterface, IteratorAggregate { * @return void * @throws BadMethodCallException If the given group is not found */ - function addInstance (string $groupName, string $subGroup, Visitable $visitableInstance); + function addInstance (string $groupName, string $subGroup, Visitable $visitableInstance): void; /** * Adds the given entry to list group @@ -68,7 +69,7 @@ interface Listable extends FrameworkInterface, IteratorAggregate { * @return void * @throws BadMethodCallException If the given group is not found */ - function addEntry (string $groupName, $entry); + function addEntry (string $groupName, mixed $entry): void; /** * Updates the given entry by hash with given array @@ -78,21 +79,21 @@ interface Listable extends FrameworkInterface, IteratorAggregate { * @return void * @throws InvalidListHashException If the solved hash index is invalid */ - function updateCurrentEntryByHash (string $hash, array $entryArray); + function updateCurrentEntryByHash (string $hash, array $entryArray): void; /** * "Getter" for an iterator instance of this list * * @return $iteratorInstance An instance of a Iterator class */ - function getListIterator (); + function getListIterator (): Iterator; /** * Clears this list (mostly by clearing all groups together) * * @return void */ - function clearList (); + function clearList (): void; /** * Setter for call-back instance @@ -100,6 +101,6 @@ interface Listable extends FrameworkInterface, IteratorAggregate { * @param $callbackInstance An instance of a FrameworkInterface class * @return void */ - function setCallbackInstance (FrameworkInterface $callbackInstance); + function setCallbackInstance (FrameworkInterface $callbackInstance): void; } diff --git a/framework/main/interfaces/logging/class_Logger.php b/framework/main/interfaces/logging/class_Logger.php index 2e7a2cf8..1c9e9c05 100644 --- a/framework/main/interfaces/logging/class_Logger.php +++ b/framework/main/interfaces/logging/class_Logger.php @@ -49,7 +49,7 @@ interface Logger extends FrameworkInterface { * @throws NullPointerException If this->outputInstance is NULL * @todo Remove $doPrint parameter */ - public function traceMessage (string $message, bool $doPrint = true, bool $stripTags = false); + public function traceMessage (string $message, bool $doPrint = true, bool $stripTags = false): void; /** * Outputs a debug message whether to debug instance (should be set!) or @@ -64,7 +64,7 @@ interface Logger extends FrameworkInterface { * @throws NullPointerException If this->outputInstance is NULL * @todo Remove $doPrint parameter */ - public function debugMessage (string $message, bool $doPrint = true, bool $stripTags = false); + public function debugMessage (string $message, bool $doPrint = true, bool $stripTags = false): void; /** * Outputs an informational message whether to debug instance (should be set!) or @@ -79,7 +79,7 @@ interface Logger extends FrameworkInterface { * @throws NullPointerException If this->outputInstance is NULL * @todo Remove $doPrint parameter */ - public function infoMessage (string $message, bool $doPrint = true, bool $stripTags = false); + public function infoMessage (string $message, bool $doPrint = true, bool $stripTags = false): void; /** * Outputs a warning message whether to debug instance (should be set!) or @@ -94,7 +94,7 @@ interface Logger extends FrameworkInterface { * @throws NullPointerException If this->outputInstance is NULL * @todo Remove $doPrint parameter */ - public function warningMessage (string $message, bool $doPrint = true, bool $stripTags = false); + public function warningMessage (string $message, bool $doPrint = true, bool $stripTags = false): void; /** * Output a partial stub message for the caller method @@ -102,7 +102,7 @@ interface Logger extends FrameworkInterface { * @param $message An optional message to display * @return void */ - public function partialStub (string $message = ''); + public function partialStub (string $message = ''): void; /** * Outputs a deprecated message whether to debug instance (should be set!) or @@ -118,6 +118,6 @@ interface Logger extends FrameworkInterface { * @todo Remove $doPrint parameter * @todo When all old method invocations are fixed, renamed this do deprecatedMessage */ - public function debugOutput (string $message, bool $doPrint = true, bool $stripTags = false); + public function debugOutput (string $message, bool $doPrint = true, bool $stripTags = false): void; } diff --git a/framework/main/interfaces/login/class_LoginableUser.php b/framework/main/interfaces/login/class_LoginableUser.php index 8baeff5d..79884a37 100644 --- a/framework/main/interfaces/login/class_LoginableUser.php +++ b/framework/main/interfaces/login/class_LoginableUser.php @@ -39,15 +39,15 @@ interface LoginableUser extends FrameworkInterface { * @param $responseInstance An instance of a Responseable class * @return void */ - function doLogin (Requestable $requestInstance, Responseable $responseInstance); + function doLogin (Requestable $requestInstance, Responseable $responseInstance): void; /** * Check if the implementation is correct. Only the request instance is * needed as no redirect is done here. * * @param $requestInstance An instance of a Requestable class - * @return + * @return void */ - function testLogin (Requestable $requestInstance); + function testLogin (Requestable $requestInstance): void; } diff --git a/framework/main/interfaces/mailer/class_DeliverableMail.php b/framework/main/interfaces/mailer/class_DeliverableMail.php index cf8b28ec..7ece1452 100644 --- a/framework/main/interfaces/mailer/class_DeliverableMail.php +++ b/framework/main/interfaces/mailer/class_DeliverableMail.php @@ -35,27 +35,27 @@ interface DeliverableMail extends FrameworkInterface { * @param $userInstance An instance of a user class * @return void */ - function addRecipientByUserInstance (ManageableMember $userInstance); + function addRecipientByUserInstance (ManageableMember $userInstance): void; /** * Use subject line provided by the (XML) template otherwise a subject line must be set * * @return void */ - function useSubjectFromTemplate (); + function useSubjectFromTemplate (): void; /** * Deliver email to the recipient(s) * * @return void */ - function deliverEmail (); + function deliverEmail (): void; /** * Send notification to the admin * * @return void */ - function sendAdminNotification (); + function sendAdminNotification (): void; } diff --git a/framework/main/interfaces/menu/class_RenderableMenu.php b/framework/main/interfaces/menu/class_RenderableMenu.php index dc2d567a..77d20ff6 100644 --- a/framework/main/interfaces/menu/class_RenderableMenu.php +++ b/framework/main/interfaces/menu/class_RenderableMenu.php @@ -35,7 +35,7 @@ interface RenderableMenu extends FrameworkInterface { * * @return void */ - function renderMenu (); + function renderMenu (): void; /** * Transfers the rendered menu to a given template engine by assigning @@ -44,6 +44,6 @@ interface RenderableMenu extends FrameworkInterface { * @2param $templateInstance An instance of a CompileableTemplate class * @return void */ - function transferContentToTemplateEngine (CompileableTemplate $templateInstance); + function transferContentToTemplateEngine (CompileableTemplate $templateInstance): void; } -- 2.39.5