From 71d2b3b1ea62cd203cd82bcdb5212c7b74738b16 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sat, 21 Mar 2015 22:14:16 +0100 Subject: [PATCH] Checked change of access level protected -> private: - All class fields must be private and *should always* have protected setters as changing "internal" fields (data, in particular object instances) can lead to unexpected behaviour and then it is *very, very* hard to trace those bugs. Signed-off-by: Roland Haeder --- .../class_XmlAnnouncementTemplateEngine.php | 4 ++-- ...class_XmlAnnouncementAnswerTemplateEngine.php | 4 ++-- ...class_XmlDhtBootstrapAnswerTemplateEngine.php | 4 ++-- ...ss_XmlRequestNodeListAnswerTemplateEngine.php | 4 ++-- .../template/class_BaseXmlTemplateEngine.php | 16 +++++++++++++--- .../class_XmlSelfConnectTemplateEngine.php | 4 ++-- .../dht/class_XmlDhtBootstrapTemplateEngine.php | 4 ++-- .../class_XmlObjectRegistryTemplateEngine.php | 4 ++-- .../class_XmlCruncherTestUnitTemplateEngine.php | 4 ++-- .../class_XmlDhtPublishEntryTemplateEngine.php | 4 ++-- .../class_XmlRequestNodeListTemplateEngine.php | 4 ++-- 11 files changed, 33 insertions(+), 23 deletions(-) diff --git a/application/hub/main/template/announcement/class_XmlAnnouncementTemplateEngine.php b/application/hub/main/template/announcement/class_XmlAnnouncementTemplateEngine.php index 0da0cc86b..702ef14a7 100644 --- a/application/hub/main/template/announcement/class_XmlAnnouncementTemplateEngine.php +++ b/application/hub/main/template/announcement/class_XmlAnnouncementTemplateEngine.php @@ -42,7 +42,7 @@ class XmlAnnouncementTemplateEngine extends BaseXmlTemplateEngine implements Com parent::__construct(__CLASS__); // Init array - $this->subNodes = array( + $this->setSubNodes(array( 'announcement-data', 'listener', self::ANNOUNCEMENT_DATA_NODE_STATUS, @@ -51,7 +51,7 @@ class XmlAnnouncementTemplateEngine extends BaseXmlTemplateEngine implements Com self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS, self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS, 'object-type-list', - ); + )); } /** diff --git a/application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php b/application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php index f70a05f55..97f3aee63 100644 --- a/application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php +++ b/application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php @@ -41,7 +41,7 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im parent::__construct(__CLASS__); // Init sub-nodes array - $this->subNodes = array( + $this->setSubNodes(array( // These nodes don't contain any data 'my-data', 'your-data', @@ -56,7 +56,7 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im 'your-session-id', // Answer status (generic field) self::ANSWER_STATUS, - ); + )); } /** diff --git a/application/hub/main/template/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php b/application/hub/main/template/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php index b9a94872b..e03f68169 100644 --- a/application/hub/main/template/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php +++ b/application/hub/main/template/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php @@ -42,7 +42,7 @@ class XmlDhtBootstrapAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im parent::__construct(__CLASS__); // Init sub-nodes array - $this->subNodes = array( + $this->setSubNodes(array( // These nodes don't contain any data 'my-data', 'your-data', @@ -59,7 +59,7 @@ class XmlDhtBootstrapAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im self::ANSWER_STATUS, // DHT node list self::DHT_BOOTSTRAP_DATA_NODE_LIST, - ); + )); } /** diff --git a/application/hub/main/template/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php b/application/hub/main/template/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php index f2aa8dcab..b79381874 100644 --- a/application/hub/main/template/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php +++ b/application/hub/main/template/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php @@ -37,12 +37,12 @@ class XmlRequestNodeListAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine parent::__construct(__CLASS__); // Init sub-nodes array - $this->subNodes = array( + $this->setSubNodes(array( self::REQUEST_DATA_SESSION_ID, self::REQUEST_DATA_NODE_LIST, // Answer status (generic field) self::ANSWER_STATUS, - ); + )); } /** diff --git a/application/hub/main/template/class_BaseXmlTemplateEngine.php b/application/hub/main/template/class_BaseXmlTemplateEngine.php index 2f60e58e2..de24e1ae1 100644 --- a/application/hub/main/template/class_BaseXmlTemplateEngine.php +++ b/application/hub/main/template/class_BaseXmlTemplateEngine.php @@ -26,17 +26,17 @@ class BaseXmlTemplateEngine extends BaseTemplateEngine { /** * Main nodes in the XML tree */ - protected $mainNodes = array(); + private $mainNodes = array(); /** * Sub nodes in the XML tree */ - protected $subNodes = array(); + private $subNodes = array(); /** * Current main node */ - protected $curr = array(); + private $curr = array(); /** * XML template type @@ -191,6 +191,16 @@ class BaseXmlTemplateEngine extends BaseTemplateEngine { return $this->stackerName; } + /** + * Setter for sub node array + * + * @param $subNodes Array with valid sub node names + * @return void + */ + public final function setSubNodes (array $subNodes) { + $this->subNodes = $subNodes; + } + /** * Getter for sub node array * diff --git a/application/hub/main/template/connect/class_XmlSelfConnectTemplateEngine.php b/application/hub/main/template/connect/class_XmlSelfConnectTemplateEngine.php index 17f2be09f..635ede5cc 100644 --- a/application/hub/main/template/connect/class_XmlSelfConnectTemplateEngine.php +++ b/application/hub/main/template/connect/class_XmlSelfConnectTemplateEngine.php @@ -39,11 +39,11 @@ class XmlSelfConnectTemplateEngine extends BaseXmlTemplateEngine implements Comp parent::__construct(__CLASS__); // Init array - $this->subNodes = array( + $this->setSubNodes(array( 'self-connect-data', self::SELF_CONNECT_DATA_NODE_ID, self::SELF_CONNECT_DATA_SESSION_ID - ); + )); } /** diff --git a/application/hub/main/template/dht/class_XmlDhtBootstrapTemplateEngine.php b/application/hub/main/template/dht/class_XmlDhtBootstrapTemplateEngine.php index 9b95cc37c..65c1beff1 100644 --- a/application/hub/main/template/dht/class_XmlDhtBootstrapTemplateEngine.php +++ b/application/hub/main/template/dht/class_XmlDhtBootstrapTemplateEngine.php @@ -43,7 +43,7 @@ class XmlDhtBootstrapTemplateEngine extends BaseXmlTemplateEngine implements Com parent::__construct(__CLASS__); // Init array - $this->subNodes = array( + $this->setSubNodes(array( self::DHT_BOOTSTRAP_DATA_BOOTSTRAP_DATA, 'listener', self::DHT_BOOTSTRAP_DATA_NODE_STATUS, @@ -51,7 +51,7 @@ class XmlDhtBootstrapTemplateEngine extends BaseXmlTemplateEngine implements Com self::DHT_BOOTSTRAP_DATA_SESSION_ID, self::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS, self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS - ); + )); } /** diff --git a/application/hub/main/template/objects/class_XmlObjectRegistryTemplateEngine.php b/application/hub/main/template/objects/class_XmlObjectRegistryTemplateEngine.php index 66ef63bdb..5f679188e 100644 --- a/application/hub/main/template/objects/class_XmlObjectRegistryTemplateEngine.php +++ b/application/hub/main/template/objects/class_XmlObjectRegistryTemplateEngine.php @@ -48,7 +48,7 @@ class XmlObjectRegistryTemplateEngine extends BaseXmlTemplateEngine implements C $this->objectRegistryInstance = ObjectTypeRegistryFactory::createObjectTypeRegistryInstance(); // Init sub nodes - $this->subNodes = array( + $this->setSubNodes(array( 'object-list', 'object-list-entry', self::OBJECT_TYPE_DATA_NAME, @@ -56,7 +56,7 @@ class XmlObjectRegistryTemplateEngine extends BaseXmlTemplateEngine implements C self::OBJECT_TYPE_DATA_MAX_SPREAD, self::OBJECT_TYPE_DATA_PROTOCOL, self::OBJECT_TYPE_DATA_RECIPIENT_TYPE - ); + )); } /** diff --git a/application/hub/main/template/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php b/application/hub/main/template/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php index ab739f92f..40f19412d 100644 --- a/application/hub/main/template/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php +++ b/application/hub/main/template/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php @@ -33,7 +33,7 @@ class XmlCruncherTestUnitTemplateEngine extends BaseXmlTemplateEngine implements parent::__construct(__CLASS__); // Init sub nodes - $this->subNodes = array( + $this->setSubNodes(array( 'meta-data', 'global-project-identifier', 'test-unit-created', @@ -46,7 +46,7 @@ class XmlCruncherTestUnitTemplateEngine extends BaseXmlTemplateEngine implements 'cruncher-key', 'key-id', 'key-value' - ); + )); } /** diff --git a/application/hub/main/template/publish/class_XmlDhtPublishEntryTemplateEngine.php b/application/hub/main/template/publish/class_XmlDhtPublishEntryTemplateEngine.php index 0360090ad..85c101397 100644 --- a/application/hub/main/template/publish/class_XmlDhtPublishEntryTemplateEngine.php +++ b/application/hub/main/template/publish/class_XmlDhtPublishEntryTemplateEngine.php @@ -44,7 +44,7 @@ class XmlDhtPublishEntryTemplateEngine extends BaseXmlTemplateEngine implements parent::__construct(__CLASS__); // Init array - $this->subNodes = array( + $this->setSubNodes(array( 'publish-data', 'listener', self::PUBLISH_DATA_NODE_STATUS, @@ -55,7 +55,7 @@ class XmlDhtPublishEntryTemplateEngine extends BaseXmlTemplateEngine implements self::PUBLISH_DATA_SESSION_ID, self::PUBLISH_DATA_EXTERNAL_ADDRESS, 'object-type-list', - ); + )); } /** diff --git a/application/hub/main/template/requests/class_XmlRequestNodeListTemplateEngine.php b/application/hub/main/template/requests/class_XmlRequestNodeListTemplateEngine.php index 1ada53e00..e014e9aa1 100644 --- a/application/hub/main/template/requests/class_XmlRequestNodeListTemplateEngine.php +++ b/application/hub/main/template/requests/class_XmlRequestNodeListTemplateEngine.php @@ -37,10 +37,10 @@ class XmlRequestNodeListTemplateEngine extends BaseXmlTemplateEngine implements parent::__construct(__CLASS__); // Init sub nodes - $this->subNodes = array( + $this->setSubNodes(array( self::REQUEST_DATA_ACCEPTED_OBJECT_TYPES, self::REQUEST_DATA_SESSION_ID, - ); + )); } /** -- 2.39.5