use Org\Mxchange\CoreFramework\Index\Indexable;
use Org\Mxchange\CoreFramework\Lists\Listable;
use Org\Mxchange\CoreFramework\Loader\ClassLoader;
+use Org\Mxchange\CoreFramework\Localization\ManageableLanguage;
use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
+use Org\Mxchange\CoreFramework\Menu\RenderableMenu;
use Org\Mxchange\CoreFramework\Middleware\Compressor\CompressorChannel;
use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
use Org\Mxchange\CoreFramework\Parser\Parseable;
use Org\Mxchange\CoreFramework\Stream\Input\InputStream;
use Org\Mxchange\CoreFramework\Stream\Output\OutputStreamer;
use Org\Mxchange\CoreFramework\Stream\Output\OutputStream;
+use Org\Mxchange\CoreFramework\String\Utils\StringUtils;
use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
use Org\Mxchange\CoreFramework\User\ManageableAccount;
use Org\Mxchange\CoreFramework\Visitor\Visitor;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2019 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
private static $hashLength = NULL;
+ /**
+ * Self-referencing instance
+ */
+ private static $instance = NULL;
+
/**
* The real class name
*/
*/
private $socketResource = false;
- /**
- * Regular expression to use for validation
- */
- private $regularExpression = '';
-
- /**
- * Package data
- */
- private $packageData = array();
-
/**
* Generic array
*/
const EXCEPTION_DATABASE_UPDATED_NOT_ALLOWED = 0x03c;
const EXCEPTION_FILTER_CHAIN_INTERCEPTED = 0x03d;
const EXCEPTION_INVALID_SOCKET = 0x03e;
+ const EXCEPTION_SELF_INSTANCE = 0x03f;
/**
* Hexadecimal->Decimal translation array
* @return void
*/
public final function __call ($methodName, $args) {
- return self::__callStatic($methodName, $args);
+ // Set self-instance
+ self::$instance = $this;
+
+ // Call static method
+ self::__callStatic($methodName, $args);
+
+ // Clear self-instance
+ self::$instance = NULL;
}
/**
* The __callStatic() method where all non-implemented static methods end up
*
* @param $methodName Name of the missing method
- * @args $args Arguments passed to the method
+ * @param $args Arguments passed to the method
* @return void
+ * @throws InvalidArgumentException If self::$instance is not a framework's own object
*/
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
+ // Init argument string and class name
$argsString = '';
+ $className = 'unknown';
+
+ // Is self-instance set?
+ if (self::$instance instanceof FrameworkInterface) {
+ // Framework's own instance
+ $className = self::$instance->__toString();
+ } elseif (!is_null(self::$instance)) {
+ // Invalid argument!
+ throw new InvalidArgumentException(sprintf('self::instance[%s] is not expected.', gettype(self::$instance)), self::EXCEPTION_SELF_INSTANCE);
+ }
// Is it NULL, empty or an array?
if (is_null($args)) {
$argsString .= ', ';
} // END - foreach
- // Remove last comma
+ // Last comma found?
if (substr($argsString, -2, 1) == ',') {
+ // Remove last comma
$argsString = substr($argsString, 0, -2);
} // END - if
$argsString .= ')';
} else {
// Invalid arguments!
- $argsString = '!INVALID:' . gettype($args) . '!';
+ $argsString = sprintf('!INVALID:%s!', gettype($args));
}
// Output stub message
// @TODO __CLASS__ does always return BaseFrameworkSystem but not the extending (=child) class
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[unknown::%s]: Stub! Args: %s',
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s::%s]: Stub! Args: %s',
+ $className,
$methodName,
$argsString
));
return $compressorInstance;
}
- /**
- * Protected getter for a manageable application helper class
- *
- * @return $applicationInstance An instance of a manageable application helper class
- */
- protected final function getApplicationInstance () {
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
- return $applicationInstance;
- }
-
- /**
- * Setter for a manageable application helper class
- *
- * @param $applicationInstance An instance of a manageable application helper class
- * @return void
- */
- public final function setApplicationInstance (ManageableApplication $applicationInstance) {
- GenericRegistry::getRegistry()->addInstance('application', $applicationInstance);
- }
-
/**
* Private getter for language instance
*
return $this->socketResource;
}
- /**
- * Setter for regular expression
- *
- * @param $regularExpression A valid regular expression
- * @return void
- */
- public final function setRegularExpression ($regularExpression) {
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': regularExpression=' . $regularExpression . ',previous[' . gettype($this->regularExpression) . ']=' . $this->regularExpression);
- $this->regularExpression = $regularExpression;
- }
-
- /**
- * Getter for regular expression
- *
- * @return $regularExpression A valid regular expression
- */
- public final function getRegularExpression () {
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': regularExpression[' . gettype($this->regularExpression) . ']=' . $this->regularExpression);
- return $this->regularExpression;
- }
-
/**
* Setter for helper instance
*
return $this->visitorInstance;
}
- /**
- * Setter for raw package Data
- *
- * @param $packageData Raw package Data
- * @return void
- */
- public final function setPackageData (array $packageData) {
- $this->packageData = $packageData;
- }
-
- /**
- * Getter for raw package Data
- *
- * @return $packageData Raw package Data
- */
- public function getPackageData () {
- return $this->packageData;
- }
-
-
/**
* Setter for Iterator instance
*
*/
protected function partialStub ($message = '') {
// Init variable
- $stubMessage = 'Partial Stub!';
+ $stubMessage = 'Partial stub!';
- // Is the extra message given?
+ // Is an extra message given?
if (!empty($message)) {
// Then add it as well
$stubMessage .= ' Message: ' . $message;
$className = '';
// Convert all dashes in underscores
- $str = self::convertDashesToUnderscores($str);
+ $str = StringUtils::convertDashesToUnderscores($str);
// Now use that underscores to get classname parts for hungarian style
foreach (explode('_', $str) as $strPart) {
return $className;
}
- /**
- * Converts dashes to underscores, e.g. useable for configuration entries
- *
- * @param $str The string with maybe dashes inside
- * @return $str The converted string with no dashed, but underscores
- * @throws NullPointerException If $str is null
- * @throws InvalidArgumentException If $str is empty
- */
- public static function convertDashesToUnderscores ($str) {
- // Is it null?
- if (is_null($str)) {
- // Throw NPE
- throw new NullPointerException($this, BaseFrameworkSystem::EXCEPTION_IS_NULL_POINTER);
- } elseif (!is_string($str)) {
- // Entry is empty
- throw new InvalidArgumentException(sprintf('str[]=%s is not a string', gettype($str)), self::EXCEPTION_CONFIG_KEY_IS_EMPTY);
- } elseif ((is_string($str)) && (empty($str))) {
- // Entry is empty
- throw new InvalidArgumentException('str is empty', self::EXCEPTION_CONFIG_KEY_IS_EMPTY);
- }
-
- // Convert them all
- $str = str_replace('-', '_', $str);
-
- // Return converted string
- return $str;
- }
-
/**
* Marks up the code by adding e.g. line numbers
*
//* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($fieldName.':<pre>'.print_r($fieldArray, true).'</pre>');
// Convert dashes to underscore
- $fieldName2 = self::convertDashesToUnderscores($fieldName);
+ $fieldName2 = StringUtils::convertDashesToUnderscores($fieldName);
// Does the field exist?
if ($this->isFieldSet($fieldName)) {
//* 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);
+ $fieldName = StringUtils::convertDashesToUnderscores($fieldName);
// Determine it
$isSet = isset($fieldArray[$fieldName]);