From: Roland Häder <roland@mxchange.org>
Date: Tue, 29 Mar 2011 16:42:19 +0000 (+0000)
Subject: Rewritten class loader to skip deprecated class files:
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f68549603f12edc09842108a287d420a16a7571f;p=core.git

Rewritten class loader to skip deprecated class files:
- Rewritten class loader to skip deprecated class files which should make all
  applications working again. This is done by checking its size because I
  will remove all code from the PHP include file and add a @DEPRECATED tag to
  it. A typical size is 24 bytes
- __set() and __get() are now calling debugBackTrace() with a message to aid
  finding e.g. typos in field/attribute names
- debugBackTrace() does now accept an optional parameter for a message
- TODOs.txt updated
---

diff --git a/docs/TODOs.txt b/docs/TODOs.txt
index 354a8ce2..05d27cd3 100644
--- a/docs/TODOs.txt
+++ b/docs/TODOs.txt
@@ -3,8 +3,8 @@
 ./inc/classes/exceptions/main/class_MissingMethodException.php:13: * @todo		Try to rewrite user/guest login classes and mark this exception as deprecated
 ./inc/classes/exceptions/main/class_NoConfigEntryException.php:10: * @todo		Rename this class to NoFoundEntryException
 ./inc/classes/interfaces/class_FrameworkInterface.php:11: * @todo		Find a better name for this interface
-./inc/classes/main/class_BaseFrameworkSystem.php:1178:	 * @todo	Write a logging mechanism for productive mode
-./inc/classes/main/class_BaseFrameworkSystem.php:1192:			// @TODO Finish this part!
+./inc/classes/main/class_BaseFrameworkSystem.php:1184:	 * @todo	Write a logging mechanism for productive mode
+./inc/classes/main/class_BaseFrameworkSystem.php:1198:			// @TODO Finish this part!
 ./inc/classes/main/class_BaseFrameworkSystem.php:169:	// @todo Try to clean these constants up
 ./inc/classes/main/class_BaseFrameworkSystem.php:355:	 * @todo	SearchableResult and UpdateableResult shall have a super interface to use here
 ./inc/classes/main/commands/web/class_WebLoginAreaCommand.php:64:	 * @todo	Add some stuff here: Some personal data, app/game related data
diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php
index 0eaddce1..8cbcd1df 100644
--- a/inc/classes/main/class_BaseFrameworkSystem.php
+++ b/inc/classes/main/class_BaseFrameworkSystem.php
@@ -328,7 +328,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
 	 * @return	void
 	 */
 	public final function __set ($name, $value) {
-		$this->debugOutput(sprintf("Tried to set a missing field. name=%s, value[%s]=%s",
+		$this->debugBackTrace(sprintf("Tried to set a missing field. name=%s, value[%s]=%s",
 			$name,
 			gettype($value),
 			$value
@@ -342,7 +342,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
 	 * @return	void
 	 */
 	public final function __get ($name) {
-		$this->debugOutput(sprintf("Tried to get a missing field. name=%s",
+		$this->debugBackTrace(sprintf("Tried to get a missing field. name=%s",
 			$name
 		));
 	}
@@ -862,10 +862,16 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
 	/**
 	 * Outputs a debug backtrace and stops further script execution
 	 *
+	 * @param	$message	An optional message to output
 	 * @return	void
 	 */
-	public function debugBackTrace () {
+	public function debugBackTrace ($message = '') {
 		// Sorry, there is no other way getting this nice backtrace
+		if (!empty($message)) {
+			// Output message
+			printf("Message: %s<br />\n", $message);
+		} // END - if
+
 		print("<pre>\n");
 		debug_print_backtrace();
 		print("</pre>");
diff --git a/inc/loader/class_ClassLoader.php b/inc/loader/class_ClassLoader.php
index 601b06d9..eef05549 100644
--- a/inc/loader/class_ClassLoader.php
+++ b/inc/loader/class_ClassLoader.php
@@ -276,12 +276,14 @@ class ClassLoader {
 			// Get filename from iterator
 			$fileName = $entry->getFileName();
 
+			// Get the FQFN and add it to our class list
+			$fqfn = $entry->getRealPath();
+
 			// Is this file wanted?
 			//* DEBUG: */ echo "FOUND:{$fileName}<br />\n";
-			if ((!in_array($fileName, $this->ignoreList)) && (substr($fileName, 0, strlen($this->prefix)) == $this->prefix) && (substr($fileName, -strlen($this->suffix), strlen($this->suffix)) == $this->suffix)) {
-				// Get the FQFN and add it to our class list
-				$fqfn = $entry->getRealPath();
+			if ((!in_array($fileName, $this->ignoreList)) && (filesize($fqfn) > 100) && (substr($fileName, 0, strlen($this->prefix)) == $this->prefix) && (substr($fileName, -strlen($this->suffix), strlen($this->suffix)) == $this->suffix)) {
 				//* DEBUG: */ echo "ADD: {$fileName}<br />\n";
+				// Add it to the list
 				$this->classes[$fileName] = $fqfn;
 			} // END - if
 		} // END - foreach