<?php
+// Own namespace
+namespace CoreFramework\Object;
+
+// Import framework stuff
+use CoreFramework\Configuration\FrameworkConfiguration;
+use CoreFramework\Controller\Controller;
+use CoreFramework\Factory\ObjectFactory;
+use CoreFramework\Generic\FrameworkInterface;
+use CoreFramework\Generic\NullPointerException;
+use CoreFramework\Handler\Stream\IoHandler;
+use CoreFramework\Loader\ClassLoader;
+use CoreFramework\Manager\ManageableApplication;
+use CoreFramework\Middleware\Debug\DebugMiddleware;
+use CoreFramework\Registry\Register;
+use CoreFramework\Registry\Registry;
+use CoreFramework\Request\Requestable;
+use CoreFramework\Resolver\Resolver;
+use CoreFramework\Response\Responseable;
+use CoreFramework\Stream\Output\OutputStreamer;
+use CoreFramework\Template\CompileableTemplate;
+
+// Import SPL stuff
+use \stdClass;
+
/**
* The simulator system class is the super class of all other classes. This
* class handles saving of games etc.
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
private $realClass = 'BaseFrameworkSystem';
/**
- * Instance of a request class
+ * Instance of a Requestable class
*/
private $requestInstance = NULL;
/**
- * Instance of a response class
+ * Instance of a Responseable class
*/
private $responseInstance = NULL;
$this->setRealClass('DestructedObject');
} elseif ((defined('DEBUG_DESTRUCTOR')) && (is_object($this->getDebugInstance()))) {
// Already destructed object
- self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:] The object <span class="object_name">%s</span> is already destroyed.',
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:] The object <span class="object_name">%s</span> is already destroyed.',
__CLASS__,
$this->__toString()
));
* @return void
*/
public static final function __callStatic ($methodName, $args) {
+ // Trace message
+ //* PRINT-DEBUG: */ printf('[%s:%d]: methodName=%s,args[]=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $methodName, gettype($args));
+
// Init argument string
$argsString = '';
// Output stub message
// @TODO __CLASS__ does always return BaseFrameworkSystem but not the extending (=child) class
- self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[unknown::%s:] Stub! Args: %s',
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[unknown::%s:] Stub! Args: %s',
$methodName,
$argsString
));
* @return void
*/
public final function setSocketResource ($socketResource) {
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': socketResource=' . $socketResource . ',previous[' . gettype($this->socketResource) . ']=' . $this->socketResource);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': socketResource=' . $socketResource . ',previous[' . gettype($this->socketResource) . ']=' . $this->socketResource);
$this->socketResource = $socketResource;
}
* @return $socketResource A valid socket resource
*/
public final function getSocketResource () {
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': socketResource[' . gettype($this->socketResource) . ']=' . $this->socketResource);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': socketResource[' . gettype($this->socketResource) . ']=' . $this->socketResource);
return $this->socketResource;
}
* @return void
*/
public final function setRegularExpression ($regularExpression) {
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': regularExpression=' . $regularExpression . ',previous[' . gettype($this->regularExpression) . ']=' . $this->regularExpression);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': regularExpression=' . $regularExpression . ',previous[' . gettype($this->regularExpression) . ']=' . $this->regularExpression);
$this->regularExpression = $regularExpression;
}
* @return $regularExpression A valid regular expression
*/
public final function getRegularExpression () {
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': regularExpression[' . gettype($this->regularExpression) . ']=' . $this->regularExpression);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': regularExpression[' . gettype($this->regularExpression) . ']=' . $this->regularExpression);
return $this->regularExpression;
}
// Debug instance is there?
if (!is_null($this->getDebugInstance())) {
// Output stub message
- self::createDebugInstance(__CLASS__)->debugOutput($stubMessage);
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($stubMessage);
} else {
// Trigger an error
trigger_error($stubMessage);
* Creates an instance of a debugger instance
*
* @param $className Name of the class (currently unsupported)
+ * @param $lineNumber Line number where the call was made
* @return $debugInstance An instance of a debugger class
* @deprecated Not fully, as the new Logger facilities are not finished yet.
*/
- public final static function createDebugInstance ($className) {
+ public final static function createDebugInstance ($className, $lineNumber = NULL) {
// Is the instance set?
if (!Registry::getRegistry()->instanceExists('debug')) {
// Init debug instance
$debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getSelfInstance()->getConfigEntry('debug_' . self::getResponseTypeFromSystem() . '_class'), $className);
} catch (NullPointerException $e) {
// Didn't work, no instance there
- exit('Cannot create debugInstance! Exception=' . $e->__toString() . ', message=' . $e->getMessage());
+ exit(sprintf('Cannot create debugInstance! Exception=%s,message=%s,className=%s,lineNumber=%d' . PHP_EOL, $e->__toString(), $e->getMessage(), $className, $lineNumber));
}
// Empty string should be ignored and used for testing the middleware
// Get current array
$fieldArray = $resultInstance->current();
- //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($fieldName.':<pre>'.print_r($fieldArray, TRUE).'</pre>');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($fieldName.':<pre>'.print_r($fieldArray, TRUE).'</pre>');
// Convert dashes to underscore
$fieldName2 = self::convertDashesToUnderscores($fieldName);
$fieldValue = $fieldArray[$fieldName2];
} elseif (defined('DEVELOPER')) {
// Missing field entry, may require debugging
- self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']:fieldArray<pre>=' . print_r($fieldArray, TRUE) . '</pre>,fieldName=' . $fieldName . ' not found!');
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']:fieldArray<pre>=' . print_r($fieldArray, TRUE) . '</pre>,fieldName=' . $fieldName . ' not found!');
} else {
// Missing field entry, may require debugging
- self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']:fieldName=' . $fieldName . ' not found!');
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']:fieldName=' . $fieldName . ' not found!');
}
// Return it
// Get current array
$fieldArray = $resultInstance->current();
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . $this->__toString() . ':' . __LINE__ . '] fieldName=' . $fieldName . ',fieldArray=<pre>'.print_r($fieldArray, TRUE).'</pre>');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . $this->__toString() . ':' . __LINE__ . '] fieldName=' . $fieldName . ',fieldArray=<pre>'.print_r($fieldArray, TRUE).'</pre>');
// Convert dashes to underscore
$fieldName = self::convertDashesToUnderscores($fieldName);
// Debug instance is there?
if (!is_null($this->getDebugInstance())) {
// Output stub message
- self::createDebugInstance(__CLASS__)->debugOutput($message);
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($message);
} else {
// Trigger an error
trigger_error($message . "<br />\n");
*/
protected function hex2asc ($hex) {
// Check for length, it must be devideable by 2
- //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('hex='.$hex);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('hex='.$hex);
assert((strlen($hex) % 2) == 0);
// Walk the string
);
// And return it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . ': cacheKey=' . $cacheKey);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($this->__toString() . ': cacheKey=' . $cacheKey);
return $cacheKey;
}
*/
protected function packString ($str) {
// Debug message
- //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('str=' . $str . ' - CALLED!');
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('str=' . $str . ' - CALLED!');
// First compress the string (gzcompress is okay)
$str = gzcompress($str);
} // END - for
// Return it
- //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('packed=' . $packed . ' - EXIT!');
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('packed=' . $packed . ' - EXIT!');
return $packed;
}
// Finally clear the error because it has been handled
socket_clear_error($socketResource);
}
-}
-// [EOF]
-?>
+}