X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=framework%2Fmain%2Fclasses%2Fclass_BaseFrameworkSystem.php;h=0390d528d228f141e3462efa265ca7552185fc46;hp=ba156fffaff68a137c6de05d676b0ed50bf1358a;hb=b002c5909aa0f781505dde5414964b0f014cde01;hpb=515b61f538c641f6e16d908767bcfdb18f889318 diff --git a/framework/main/classes/class_BaseFrameworkSystem.php b/framework/main/classes/class_BaseFrameworkSystem.php index ba156fff..0390d528 100644 --- a/framework/main/classes/class_BaseFrameworkSystem.php +++ b/framework/main/classes/class_BaseFrameworkSystem.php @@ -1,44 +1,59 @@ . */ -class BaseFrameworkSystem extends stdClass implements FrameworkInterface { +abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterface { /** * Length of output from hash() */ @@ -74,16 +89,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ private $realClass = 'BaseFrameworkSystem'; - /** - * Instance of a Requestable class - */ - private $requestInstance = NULL; - - /** - * Instance of a Responseable class - */ - private $responseInstance = NULL; - /** * Search criteria instance */ @@ -169,11 +174,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ private $parserInstance = NULL; - /** - * A HandleableProtocol instance - */ - private $protocolInstance = NULL; - /** * A database wrapper instance */ @@ -184,16 +184,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ private $helperInstance = NULL; - /** - * An instance of a Source class - */ - private $sourceInstance = NULL; - - /** - * An instance of a UrlSource class - */ - private $urlSourceInstance = NULL; - /** * An instance of a InputStream class */ @@ -205,7 +195,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { private $outputStreamInstance = NULL; /** - * Networkable handler instance + * Handler instance */ private $handlerInstance = NULL; @@ -214,11 +204,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ private $visitorInstance = NULL; - /** - * DHT instance - */ - private $dhtInstance = NULL; - /** * An instance of a database wrapper class */ @@ -250,24 +235,24 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { private $directoryInstance = NULL; /** - * Listener instance + * The concrete output instance */ - private $listenerInstance = NULL; + private $outputInstance = NULL; /** - * An instance of a communicator + * State instance */ - private $communicatorInstance = NULL; + private $stateInstance = NULL; /** - * The concrete output instance + * Registry instance (implementing Register) */ - private $outputInstance = NULL; + private $registryInstance = NULL; /** - * State instance + * Call-back instance */ - private $stateInstance = NULL; + private $callbackInstance = NULL; /** * Thousands separator @@ -282,7 +267,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { /** * Socket resource */ - private $socketResource = FALSE; + private $socketResource = false; /** * Regular expression to use for validation @@ -309,11 +294,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ private $controllerName = ''; - /** - * Name of used protocol - */ - private $protocolName = 'invalid'; - /** * Array with bitmasks and such for pack/unpack methods to support both * 32-bit and 64-bit systems @@ -340,7 +320,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * * The integer size is 4 bytes on 32-bit and 8 bytes on a 64-bit system. */ - private $archArrayElement = FALSE; + private $archArrayElement = false; /*********************** * Exception codes.... * @@ -408,6 +388,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { const EXCEPTION_PATH_CANNOT_BE_WRITTEN = 0x03b; const EXCEPTION_DATABASE_UPDATED_NOT_ALLOWED = 0x03c; const EXCEPTION_FILTER_CHAIN_INTERCEPTED = 0x03d; + const EXCEPTION_INVALID_SOCKET = 0x03e; /** * Hexadecimal->Decimal translation array @@ -471,13 +452,13 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Set configuration instance if no registry ... if (!$this instanceof Register) { // ... because registries doesn't need to be configured - $this->setConfigInstance(FrameworkConfiguration::getSelfInstance()); + $this->setConfigInstance(FrameworkBootstrap::getConfigurationInstance()); } // END - if - // Is the startup time set? (0 cannot be TRUE anymore) + // Is the startup time set? (0 cannot be true anymore) if (self::$startupTime == 0) { // Then set it - self::$startupTime = microtime(TRUE); + self::$startupTime = microtime(true); } // END - if // Set array element @@ -499,8 +480,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $this->setRealClass('DestructedObject'); } elseif ((defined('DEBUG_DESTRUCTOR')) && (is_object($this->getDebugInstance()))) { // Already destructed object - self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:] The object %s is already destroyed.', - __CLASS__, + self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('The object %s is already destroyed.', $this->__toString() )); } else { @@ -566,12 +546,12 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Is an other object, maybe no __toString() available $argsString .= $reflection->getName(); - } elseif ($arg === TRUE) { - // ... is boolean 'TRUE' - $argsString .= 'TRUE'; - } elseif ($arg === FALSE) { - // ... is boolean 'FALSE' - $argsString .= 'FALSE'; + } elseif ($arg === true) { + // ... is boolean 'true' + $argsString .= 'true'; + } elseif ($arg === false) { + // ... is boolean 'false' + $argsString .= 'false'; } // Comma for next one @@ -592,7 +572,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // 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('[unknown::%s]: Stub! Args: %s', $methodName, $argsString )); @@ -621,7 +601,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $this->debugBackTrace(sprintf('Tried to set a missing field. name=%s, value[%s]=%s', $name, gettype($value), - print_r($value, TRUE) + print_r($value, true) )); } @@ -803,7 +783,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * @return $configInstance Configuration instance */ public final function getConfigInstance () { - $configInstance = Registry::getRegistry()->getInstance('config'); + $configInstance = GenericRegistry::getRegistry()->getInstance('config'); return $configInstance; } @@ -824,7 +804,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ public final function getDebugInstance () { // Get debug instance - $debugInstance = Registry::getRegistry()->getInstance('debug'); + $debugInstance = GenericRegistry::getRegistry()->getInstance('debug'); // Return it return $debugInstance; @@ -846,7 +826,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * @return $webOutputInstance - Instance to class WebOutput */ public final function getWebOutputInstance () { - $webOutputInstance = Registry::getRegistry()->getInstance('web_output'); + $webOutputInstance = GenericRegistry::getRegistry()->getInstance('web_output'); return $webOutputInstance; } @@ -867,7 +847,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ public final function getDatabaseInstance () { // Get instance - $databaseInstance = Registry::getRegistry()->getInstance('db_instance'); + $databaseInstance = GenericRegistry::getRegistry()->getInstance('db_instance'); // Return instance return $databaseInstance; @@ -889,7 +869,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * @return $compressorInstance The compressor channel */ public final function getCompressorChannel () { - $compressorInstance = Registry::getRegistry()->getInstance('compressor'); + $compressorInstance = GenericRegistry::getRegistry()->getInstance('compressor'); return $compressorInstance; } @@ -899,7 +879,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * @return $applicationInstance An instance of a manageable application helper class */ protected final function getApplicationInstance () { - $applicationInstance = Registry::getRegistry()->getInstance('application'); + $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); return $applicationInstance; } @@ -913,51 +893,13 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { Registry::getRegistry()->addInstance('application', $applicationInstance); } - /** - * Setter for request instance - * - * @param $requestInstance An instance of a Requestable class - * @return void - */ - public final function setRequestInstance (Requestable $requestInstance) { - $this->requestInstance = $requestInstance; - } - - /** - * Getter for request instance - * - * @return $requestInstance An instance of a Requestable class - */ - public final function getRequestInstance () { - return $this->requestInstance; - } - - /** - * Setter for response instance - * - * @param $responseInstance An instance of a Responseable class - * @return void - */ - public final function setResponseInstance (Responseable $responseInstance) { - $this->responseInstance = $responseInstance; - } - - /** - * Getter for response instance - * - * @return $responseInstance An instance of a Responseable class - */ - public final function getResponseInstance () { - return $this->responseInstance; - } - /** * Private getter for language instance * * @return $langInstance An instance to the language sub-system */ protected final function getLanguageInstance () { - $langInstance = Registry::getRegistry()->getInstance('language'); + $langInstance = GenericRegistry::getRegistry()->getInstance('language'); return $langInstance; } @@ -1181,25 +1123,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { return $this->parserInstance; } - /** - * Setter for HandleableProtocol instance - * - * @param $protocolInstance An instance of an HandleableProtocol - * @return void - */ - public final function setProtocolInstance (HandleableProtocol $protocolInstance) { - $this->protocolInstance = $protocolInstance; - } - - /** - * Getter for HandleableProtocol instance - * - * @return $protocolInstance An instance of an HandleableProtocol - */ - public final function getProtocolInstance () { - return $this->protocolInstance; - } - /** * Setter for DatabaseWrapper instance * @@ -1280,44 +1203,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { return $this->helperInstance; } - /** - * Setter for a Source instance - * - * @param $sourceInstance An instance of a Source class - * @return void - */ - protected final function setSourceInstance (Source $sourceInstance) { - $this->sourceInstance = $sourceInstance; - } - - /** - * Getter for a Source instance - * - * @return $sourceInstance An instance of a Source class - */ - protected final function getSourceInstance () { - return $this->sourceInstance; - } - - /** - * Setter for a UrlSource instance - * - * @param $sourceInstance An instance of a UrlSource class - * @return void - */ - protected final function setUrlSourceInstance (UrlSource $urlSourceInstance) { - $this->urlSourceInstance = $urlSourceInstance; - } - - /** - * Getter for a UrlSource instance - * - * @return $urlSourceInstance An instance of a UrlSource class - */ - protected final function getUrlSourceInstance () { - return $this->urlSourceInstance; - } - /** * Getter for a InputStream instance * @@ -1369,7 +1254,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { /** * Getter for handler instance * - * @return $handlerInstance A Networkable instance + * @return $handlerInstance A Handleable instance */ protected final function getHandlerInstance () { return $this->handlerInstance; @@ -1394,25 +1279,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { return $this->visitorInstance; } - /** - * Setter for DHT instance - * - * @param $dhtInstance A Distributable instance - * @return void - */ - protected final function setDhtInstance (Distributable $dhtInstance) { - $this->dhtInstance = $dhtInstance; - } - - /** - * Getter for DHT instance - * - * @return $dhtInstance A Distributable instance - */ - protected final function getDhtInstance () { - return $this->dhtInstance; - } - /** * Setter for raw package Data * @@ -1564,79 +1430,79 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } /** - * Setter for listener instance + * Setter for state instance * - * @param $listenerInstance A Listenable instance + * @param $stateInstance A Stateable instance * @return void */ - protected final function setListenerInstance (Listenable $listenerInstance) { - $this->listenerInstance = $listenerInstance; + public final function setStateInstance (Stateable $stateInstance) { + $this->stateInstance = $stateInstance; } /** - * Getter for listener instance + * Getter for state instance * - * @return $listenerInstance A Listenable instance + * @return $stateInstance A Stateable instance */ - protected final function getListenerInstance () { - return $this->listenerInstance; + public final function getStateInstance () { + return $this->stateInstance; } /** - * Getter for communicator instance + * Setter for output instance * - * @return $communicatorInstance An instance of a Communicator class + * @param $outputInstance The debug output instance + * @return void */ - public final function getCommunicatorInstance () { - return $this->communicatorInstance; + public final function setOutputInstance (OutputStreamer $outputInstance) { + $this->outputInstance = $outputInstance; } /** - * Setter for communicator instance + * Getter for output instance * - * @param $communicatorInstance An instance of a Communicator class - * @return void + * @return $outputInstance The debug output instance */ - protected final function setCommunicatorInstance (Communicator $communicatorInstance) { - $this->communicatorInstance = $communicatorInstance; + public final function getOutputInstance () { + return $this->outputInstance; } /** - * Setter for state instance + * Setter for registry instance * - * @param $stateInstance A Stateable instance + * @param $registryInstance An instance of a Register class * @return void */ - public final function setStateInstance (Stateable $stateInstance) { - $this->stateInstance = $stateInstance; + protected final function setRegistryInstance (Register $registryInstance) { + $this->registryInstance = $registryInstance; } /** - * Getter for state instance + * Getter for registry instance * - * @return $stateInstance A Stateable instance + * @return $registryInstance The debug registry instance */ - public final function getStateInstance () { - return $this->stateInstance; + public final function getRegistryInstance () { + return $this->registryInstance; } /** - * Setter for output instance + * Setter for call-back instance * - * @param $outputInstance The debug output instance + * @param $callbackInstance An instance of a FrameworkInterface class * @return void */ - public final function setOutputInstance (OutputStreamer $outputInstance) { - $this->outputInstance = $outputInstance; + public final function setCallbackInstance (FrameworkInterface $callbackInstance) { + $this->callbackInstance = $callbackInstance; } /** - * Getter for output instance + * Getter for call-back instance * - * @return $outputInstance The debug output instance + * @return $callbackInstance An instance of a FrameworkInterface class */ - public final function getOutputInstance () { - return $this->outputInstance; + protected final function getCallbackInstance () { + return $this->callbackInstance; } /** @@ -1677,25 +1543,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { return $this->controllerName; } - /** - * Getter for protocol name - * - * @return $protocolName Name of used protocol - */ - public final function getProtocolName () { - return $this->protocolName; - } - - /** - * Setter for protocol name - * - * @param $protocolName Name of used protocol - * @return void - */ - protected final function setProtocolName ($protocolName) { - $this->protocolName = $protocolName; - } - /** * Checks whether an object equals this object. You should overwrite this * method to implement own equality checks @@ -1785,7 +1632,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Is the application instance set? if (is_null($applicationInstance)) { // Get the current instance - $applicationInstance = $this->getApplicationInstance(); + $applicationInstance = GenericRegistry::getRegistry()->getInstance('app'); // Still null? if (is_null($applicationInstance)) { @@ -1817,20 +1664,31 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Is a message set? if (!empty($message)) { // Construct message - $content = sprintf('
Message: %s
' . PHP_EOL, $message); + $content = sprintf('
+ Message: %s +
' . PHP_EOL, $message); } // END - if // Generate the output $content .= sprintf('
%s
', trim( htmlentities( - print_r($this, TRUE) + print_r($this, true) ) ) ); // Output it - ApplicationEntryPoint::app_exit(sprintf('
%s debug output:
%s
Loaded includes:
%s
', + ApplicationEntryPoint::exitApplication(sprintf('
+ %s debug output: +
+
+ %s +
+Loaded includes: +
+ %s +
', $this->__toString(), $content, ClassLoader::getSelfInstance()->getPrintableIncludeList() @@ -1863,19 +1721,8 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * @return void */ protected function partialStub ($message = '') { - // Get the backtrace - $backtrace = debug_backtrace(); - - // Generate the class::method string - $methodName = 'UnknownClass->unknownMethod'; - if ((isset($backtrace[1]['class'])) && (isset($backtrace[1]['function']))) { - $methodName = $backtrace[1]['class'] . '->' . $backtrace[1]['function']; - } // END - if - - // Construct the full message - $stubMessage = sprintf('[%s:] Partial stub!', - $methodName - ); + // Init variable + $stubMessage = 'Partial Stub!'; // Is the extra message given? if (!empty($message)) { @@ -1898,10 +1745,10 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * Outputs a debug backtrace and stops further script execution * * @param $message An optional message to output - * @param $doExit Whether exit the program (TRUE is default) + * @param $doExit Whether exit the program (true is default) * @return void */ - public function debugBackTrace ($message = '', $doExit = TRUE) { + public function debugBackTrace ($message = '', $doExit = true) { // Sorry, there is no other way getting this nice backtrace if (!empty($message)) { // Output message @@ -1913,7 +1760,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { print(''); // Exit program? - if ($doExit === TRUE) { + if ($doExit === true) { exit(); } // END - if } @@ -1935,7 +1782,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Try it try { // Get a debugger instance - $debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getSelfInstance()->getConfigEntry('debug_' . self::getResponseTypeFromSystem() . '_class'), $className); + $debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('debug_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_class'), $className); } catch (NullPointerException $e) { // Didn't work, no instance there exit(sprintf('Cannot create debugInstance! Exception=%s,message=%s,className=%s,lineNumber=%d' . PHP_EOL, $e->__toString(), $e->getMessage(), $className, $lineNumber)); @@ -1944,11 +1791,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Empty string should be ignored and used for testing the middleware DebugMiddleware::getSelfInstance()->output(''); - // Set it in its own class. This will set it in the registry - $debugInstance->setDebugInstance($debugInstance); + // Set it in registry + Registry::getRegistry()->addInstance('debug', $debugInstance); } else { // Get instance from registry - $debugInstance = Registry::getRegistry()->getDebugInstance(); + $debugInstance = GenericRegistry::getRegistry()->getDebugInstance(); } // Return it @@ -1973,13 +1820,35 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * * @param $message Message we shall send out... * @param $doPrint Whether print or die here (default: print) - * @paran $stripTags Whether to strip tags (default: FALSE) + * @paran $stripTags Whether to strip tags (default: false) * @return void */ - public function debugOutput ($message, $doPrint = TRUE, $stripTags = FALSE) { + public function debugOutput ($message, $doPrint = true, $stripTags = false) { // Set debug instance to NULL $debugInstance = NULL; + // Get backtrace + $backtrace = debug_backtrace(!DEBUG_BACKTRACE_PROVIDE_OBJECT); + + // Is function partialStub/__callStatic ? + if (in_array($backtrace[1]['function'], array('partialStub', '__call', '__callStatic'))) { + // Prepend class::function:line from 3rd element + $message = sprintf('[%s::%s:%d]: %s', + $backtrace[2]['class'], + $backtrace[2]['function'], + (isset($backtrace[2]['line']) ? $backtrace[2]['line'] : '0'), + $message + ); + } else { + // Prepend class::function:line from 2nd element + $message = sprintf('[%s::%s:%d]: %s', + $backtrace[1]['class'], + $backtrace[1]['function'], + (isset($backtrace[1]['line']) ? $backtrace[1]['line'] : '0'), + $message + ); + } + // Try it: try { // Get debug instance @@ -1993,19 +1862,19 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Use debug output handler $debugInstance->output($message, $stripTags); - if ($doPrint === FALSE) { + if ($doPrint === false) { // Die here if not printed exit(); } // END - if } else { // Are debug times enabled? - if ($this->getConfigInstance()->getConfigEntry('debug_' . self::getResponseTypeFromSystem() . '_output_timings') == 'Y') { + if ($this->getConfigInstance()->getConfigEntry('debug_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_output_timings') == 'Y') { // Prepent it $message = $this->getPrintableExecutionTime() . $message; } // END - if // Put directly out - if ($doPrint === TRUE) { + if ($doPrint === true) { // Print message $this->outputLine($message); } else { @@ -2043,8 +1912,22 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * * @param $str The string with maybe dashes inside * @return $str The converted string with no dashed, but underscores - */ - public static final function convertDashesToUnderscores ($str) { + * @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); @@ -2174,7 +2057,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $this->getResultInstance()->rewind(); // Do we have an entry? - if ($this->getResultInstance()->valid() === FALSE) { + if ($this->getResultInstance()->valid() === false) { // @TODO Move the constant to e.g. BaseDatabaseResult when there is a non-cached database result available throw new InvalidDatabaseResultException(array($this, $this->getResultInstance()), CachedDatabaseResult::EXCEPTION_INVALID_DATABASE_RESULT); } // END - if @@ -2211,7 +2094,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Get current array $fieldArray = $resultInstance->current(); - //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($fieldName.':
'.print_r($fieldArray, TRUE).'
'); + //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($fieldName.':
'.print_r($fieldArray, true).'
'); // Convert dashes to underscore $fieldName2 = self::convertDashesToUnderscores($fieldName); @@ -2222,7 +2105,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $fieldValue = $fieldArray[$fieldName2]; } elseif (defined('DEVELOPER')) { // Missing field entry, may require debugging - self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']:fieldArray
=' . print_r($fieldArray, TRUE) . '
,fieldName=' . $fieldName . ' not found!'); + self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']:fieldArray
=' . print_r($fieldArray, true) . '
,fieldName=' . $fieldName . ' not found!'); } else { // Missing field entry, may require debugging self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']:fieldName=' . $fieldName . ' not found!'); @@ -2251,7 +2134,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Get current array $fieldArray = $resultInstance->current(); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . $this->__toString() . ':' . __LINE__ . '] fieldName=' . $fieldName . ',fieldArray=
'.print_r($fieldArray, TRUE).'
'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . $this->__toString() . ':' . __LINE__ . '] fieldName=' . $fieldName . ',fieldArray=
'.print_r($fieldArray, true).'
'); // Convert dashes to underscore $fieldName = self::convertDashesToUnderscores($fieldName); @@ -2332,7 +2215,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ public function getMilliTime () { // Get the time of day as float - $milliTime = gettimeofday(TRUE); + $milliTime = gettimeofday(true); // Return it return $milliTime; @@ -2345,7 +2228,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ public function idle ($milliSeconds) { // Sleep is fine by default - $hasSlept = TRUE; + $hasSlept = true; // Idle so long with found function if (function_exists('time_sleep_until')) { @@ -2511,34 +2394,12 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ protected function isBase64Encoded ($encodedData) { // Determine it - $isBase64 = (@base64_decode($encodedData, TRUE) !== FALSE); + $isBase64 = (@base64_decode($encodedData, true) !== false); // Return it return $isBase64; } - /** - * "Getter" to get response/request type from analysis of the system. - * - * @return $responseType Analyzed response type - */ - protected static function getResponseTypeFromSystem () { - // Default is console - $responseType = 'console'; - - // Is 'HTTP_HOST' set? - if (isset($_SERVER['HTTP_HOST'])) { - /* - * Then it is a HTML response/request as RSS and so on may be - * transfered over HTTP as well. - */ - $responseType = 'html'; - } // END - if - - // Return it - return $responseType; - } - /** * Gets a cache key from Criteria instance * @@ -2574,7 +2435,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ protected function getPrintableExecutionTime () { // Caculate the execution time - $executionTime = microtime(TRUE) - $this->getStartupTime(); + $executionTime = microtime(true) - $this->getStartupTime(); // Pack it in nice braces $executionTime = sprintf('[ %01.5f ] ', $executionTime); @@ -2623,18 +2484,18 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * @param $assertMismatch Whether to assert mismatches * @return $ret The (hopefully) secured numbered value */ - public function bigintval ($num, $castValue = TRUE, $assertMismatch = FALSE) { + public function bigintval ($num, $castValue = true, $assertMismatch = false) { // Filter all numbers out $ret = preg_replace('/[^0123456789]/', '', $num); // Shall we cast? - if ($castValue === TRUE) { + if ($castValue === true) { // Cast to biggest numeric type $ret = (double) $ret; } // END - if // Assert only if requested - if ($assertMismatch === TRUE) { + if ($assertMismatch === true) { // Has the whole value changed? assert(('' . $ret . '' != '' . $num . '') && (!is_null($num))); } // END - if @@ -2650,12 +2511,12 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * @param $assertMismatch Whether to assert mismatches * @return $ret The (hopefully) secured hext-numbered value */ - public function hexval ($num, $assertMismatch = FALSE) { + public function hexval ($num, $assertMismatch = false) { // Filter all numbers out $ret = preg_replace('/[^0123456789abcdefABCDEF]/', '', $num); // Assert only if requested - if ($assertMismatch === TRUE) { + if ($assertMismatch === true) { // Has the whole value changed? assert(('' . $ret . '' != '' . $num . '') && (!is_null($num))); } // END - if @@ -2664,20 +2525,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { return $ret; } - /** - * Checks whether start/end marker are set - * - * @param $data Data to be checked - * @return $isset Whether start/end marker are set - */ - public final function ifStartEndMarkersSet ($data) { - // Determine it - $isset = ((substr($data, 0, strlen(BaseRawDataHandler::STREAM_START_MARKER)) == BaseRawDataHandler::STREAM_START_MARKER) && (substr($data, -1 * strlen(BaseRawDataHandler::STREAM_END_MARKER), strlen(BaseRawDataHandler::STREAM_END_MARKER)) == BaseRawDataHandler::STREAM_END_MARKER)); - - // ... and return it - return $isset; - } - /** * Determines if an element is set in the generic array * @@ -2751,7 +2598,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } // END - if // Debug message - //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',value=' . print_r($this->genericArray[$keyGroup][$subGroup], TRUE)); + //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',value=' . print_r($this->genericArray[$keyGroup][$subGroup], true)); // Return it return $this->genericArray[$keyGroup][$subGroup]; @@ -2801,7 +2648,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ protected final function appendStringToGenericArrayKey ($keyGroup, $subGroup, $key, $value, $appendGlue = '') { // Debug message - //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, TRUE) . ',appendGlue=' . $appendGlue); + //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, true) . ',appendGlue=' . $appendGlue); // Is it already there? if ($this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) { @@ -2825,7 +2672,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ protected final function appendStringToGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value, $appendGlue = '') { // Debug message - //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, TRUE) . ',appendGlue=' . $appendGlue); + //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, true) . ',appendGlue=' . $appendGlue); // Is it already there? if ($this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) { @@ -2849,7 +2696,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ protected final function setStringGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value, $appendGlue = '') { // Debug message - //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, TRUE) . ',appendGlue=' . $appendGlue); + //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, true) . ',appendGlue=' . $appendGlue); // Set it $this->genericArray[$keyGroup][$subGroup][$key][$element] = (string) $value; @@ -2864,12 +2711,12 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * @param $forceInit Optionally force initialization * @return void */ - protected final function initGenericArrayGroup ($keyGroup, $subGroup, $forceInit = FALSE) { + protected final function initGenericArrayGroup ($keyGroup, $subGroup, $forceInit = false) { // Debug message //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',forceInit=' . intval($forceInit)); // Is it already set? - if (($forceInit === FALSE) && ($this->isGenericArrayGroupSet($keyGroup, $subGroup))) { + if (($forceInit === false) && ($this->isGenericArrayGroupSet($keyGroup, $subGroup))) { // Already initialized trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' already initialized.'); exit; @@ -2888,12 +2735,12 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * @param $forceInit Optionally force initialization * @return void */ - protected final function initGenericArrayKey ($keyGroup, $subGroup, $key, $forceInit = FALSE) { + protected final function initGenericArrayKey ($keyGroup, $subGroup, $key, $forceInit = false) { // Debug message //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',forceInit=' . intval($forceInit)); // Is it already set? - if (($forceInit === FALSE) && ($this->isGenericArrayKeySet($keyGroup, $subGroup, $key))) { + if (($forceInit === false) && ($this->isGenericArrayKeySet($keyGroup, $subGroup, $key))) { // Already initialized trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' already initialized.'); exit; @@ -2913,12 +2760,12 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * @param $forceInit Optionally force initialization * @return void */ - protected final function initGenericArrayElement ($keyGroup, $subGroup, $key, $element, $forceInit = FALSE) { + protected final function initGenericArrayElement ($keyGroup, $subGroup, $key, $element, $forceInit = false) { // Debug message //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',forceInit=' . intval($forceInit)); // Is it already set? - if (($forceInit === FALSE) && ($this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element))) { + if (($forceInit === false) && ($this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element))) { // Already initialized trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ' already initialized.'); exit; @@ -2939,7 +2786,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ protected final function pushValueToGenericArrayKey ($keyGroup, $subGroup, $key, $value) { // Debug message - //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, TRUE)); + //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, true)); // Is it set? if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) { @@ -2951,7 +2798,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $count = array_push($this->genericArray[$keyGroup][$subGroup][$key], $value); // Return count - //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], TRUE)); + //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], true)); //* DEBUG: */ print(__METHOD__ . ': count=' . $count . PHP_EOL); return $count; } @@ -2968,7 +2815,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ protected final function pushValueToGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value) { // Debug message - //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, TRUE)); + //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, true)); // Is it set? if (!$this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) { @@ -2980,7 +2827,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $count = array_push($this->genericArray[$keyGroup][$subGroup][$key][$element], $value); // Return count - //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], TRUE)); + //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], true)); //* DEBUG: */ print(__METHOD__ . ': count=' . $count . PHP_EOL); return $count; } @@ -3008,8 +2855,8 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $value = array_pop($this->genericArray[$keyGroup][$subGroup][$key]); // Return value - //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], TRUE)); - //* DEBUG: */ print(__METHOD__ . ': value[' . gettype($value) . ']=' . print_r($value, TRUE) . PHP_EOL); + //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], true)); + //* DEBUG: */ print(__METHOD__ . ': value[' . gettype($value) . ']=' . print_r($value, true) . PHP_EOL); return $value; } @@ -3036,8 +2883,8 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $value = array_shift($this->genericArray[$keyGroup][$subGroup][$key]); // Return value - //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], TRUE)); - //* DEBUG: */ print(__METHOD__ . ': value[' . gettype($value) . ']=' . print_r($value, TRUE) . PHP_EOL); + //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], true)); + //* DEBUG: */ print(__METHOD__ . ': value[' . gettype($value) . ']=' . print_r($value, true) . PHP_EOL); return $value; } @@ -3161,7 +3008,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ protected final function setGenericArrayKey ($keyGroup, $subGroup, $key, $value) { // Debug message - //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, TRUE)); + //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, true)); // Set value here $this->genericArray[$keyGroup][$subGroup][$key] = $value; @@ -3202,7 +3049,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ protected final function setGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value) { // Debug message - //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, TRUE)); + //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, true)); // Then set it $this->genericArray[$keyGroup][$subGroup][$key][$element] = $value; @@ -3276,13 +3123,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ protected function initWebOutputInstance () { // Get application instance - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - // Is this a response instance? - if ($this instanceof Responseable) { - // Then set it in application instance - $applicationInstance->setResponseInstance($this); - } // END - if + $applicationInstance = GenericRegistry::getRegistry()->getInstance('app'); // Init web output instance $outputInstance = ObjectFactory::createObjectByConfiguredName('output_class', array($applicationInstance)); @@ -3292,7 +3133,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } /** - * Translates boolean TRUE to 'Y' and FALSE to 'N' + * Translates boolean true to 'Y' and false to 'N' * * @param $boolean Boolean value * @return $translated Translated boolean value @@ -3302,7 +3143,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { assert(is_bool($boolean)); // "Translate" it - $translated = ($boolean === TRUE) ? 'Y' : 'N'; + $translated = ($boolean === true) ? 'Y' : 'N'; // ... and return it return $translated; @@ -3376,88 +3217,36 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { return $packed; } - /** - * Checks whether the given file/path is in open_basedir(). This does not - * gurantee that the file is actually readable and/or writeable. If you need - * such gurantee then please use isReadableFile() instead. - * - * @param $filePathName Name of the file/path to be checked - * @return $isReachable Whether it is within open_basedir() - */ - protected static function isReachableFilePath ($filePathName) { - // Is not reachable by default - $isReachable = FALSE; - - // Get open_basedir parameter - $openBaseDir = ini_get('open_basedir'); - - // Is it set? - if (!empty($openBaseDir)) { - // Check all entries - foreach (explode(PATH_SEPARATOR, $openBaseDir) as $dir) { - // Check on existence - if (substr($filePathName, 0, strlen($dir)) == $dir) { - // Is reachable - $isReachable = TRUE; - } // END - if - } // END - foreach - } else { - // If open_basedir is not set, all is allowed - $isReachable = TRUE; - } - - // Return status - return $isReachable; - } - - /** - * Checks whether the give file is within open_basedir() (done by - * isReachableFilePath()), is actually a file and is readable. - * - * @param $fileName Name of the file to be checked - * @return $isReadable Whether the file is readable (and therefor exists) - */ - public static function isReadableFile ($fileName) { - // Default is not readable - $isReadable = FALSE; - - // Is within parameters, so check if it is a file and readable - $isReadable = ((self::isReachableFilePath($fileName)) && (file_exists($fileName)) && (is_file($fileName)) && (is_readable($fileName))); - - // Return status - return $isReadable; - } - /** * Creates a full-qualified file name (FQFN) for given file name by adding * a configured temporary file path to it. * - * @param $fileName Name for temporary file - * @return $fqfn Full-qualified file name + * @param $infoInstance An instance of a SplFileInfo class + * @return $tempInstance An instance of a SplFileInfo class (temporary file) * @throw PathWriteProtectedException If the path in 'temp_file_path' is write-protected * @throws FileIoException If the file cannot be written */ - protected static function createTempPathForFile ($fileName) { + protected static function createTempPathForFile (SplFileInfo $infoInstance) { // Get config entry - $basePath = FrameworkConfiguration::getSelfInstance()->getConfigEntry('temp_file_path'); + $basePath = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('temp_file_path'); // Is the path writeable? if (!is_writable($basePath)) { // Path is write-protected - throw new PathWriteProtectedException($fileName, self::EXCEPTION_PATH_CANNOT_BE_WRITTEN); + throw new PathWriteProtectedException($infoInstance, self::EXCEPTION_PATH_CANNOT_BE_WRITTEN); } // END - if // Add it - $fqfn = $basePath . '/' . $fileName; + $tempInstance = new SplFileInfo($basePath . DIRECTORY_SEPARATOR . $infoInstance->getBasename()); // Is it reachable? - if (!self::isReachableFilePath($fqfn)) { + if (!FrameworkBootstrap::isReachableFilePath($tempInstance)) { // Not reachable - throw new FileIoException($fqfn, self::EXCEPTION_FILE_NOT_REACHABLE); + throw new FileIoException($tempInstance, self::EXCEPTION_FILE_NOT_REACHABLE); } // END - if // Return it - return $fqfn; + return $tempInstance; } /** @@ -3482,50 +3271,4 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { return $stateName; } - /** - * Handles socket error for given socket resource and peer data. This method - * validates $socketResource if it is a valid resource (see is_resource()) - * but assumes valid data in array $recipientData, except that - * count($recipientData) is always 2. - * - * @param $method Value of __METHOD__ from calling method - * @param $line Value of __LINE__ from calling method - * @param $socketResource A valid socket resource - * @param $socketData A valid socket data array (0 = IP/file name, 1 = port) - * @return void - * @throws InvalidSocketException If $socketResource is no socket resource - * @throws NoSocketErrorDetectedException If socket_last_error() gives zero back - * @todo Move all this socket-related stuff into own class, most of it resides in BaseListener - */ - protected final function handleSocketError ($method, $line, $socketResource, array $socketData) { - // This method handles only socket resources - if (!is_resource($socketResource)) { - // No resource, abort here - throw new InvalidSocketException(array($this, $socketResource), BaseListener::EXCEPTION_INVALID_SOCKET); - } // END - if - - // Check socket array, 1st element is mostly IP address (or file name), 2nd is port number - //* DEBUG-DIE: */ die(__METHOD__ . ':socketData=' . print_r($socketData, TRUE)); - assert(isset($socketData[0])); - assert(isset($socketData[1])); - - // Get error code for first validation (0 is not an error) - $errorCode = socket_last_error($socketResource); - - // If the error code is zero, someone called this method without an error - if ($errorCode == 0) { - // No error detected (or previously cleared outside this method) - throw new NoSocketErrorDetectedException(array($this, $socketResource), BaseListener::EXCEPTION_NO_SOCKET_ERROR); - } // END - if - - // Get handler (method) name - $handlerName = $this->getSocketErrorHandlerFromCode($errorCode); - - // Call-back the error handler method - call_user_func_array(array($this, $handlerName), array($socketResource, $socketData)); - - // Finally clear the error because it has been handled - socket_clear_error($socketResource); - } - }