* @param $version Version number of this apt-proxy
* @return void
*/
- function enableIsActive ($isActive = true);
+ function enableIsActive ($isActive = TRUE);
/**
* Determines whether the apt-proxy is active
* @param $version Version number of this chatter
* @return void
*/
- function enableIsActive ($isActive = true);
+ function enableIsActive ($isActive = TRUE);
/**
* Determines whether the chatter is active
* @param $version Version number of this cruncher
* @return void
*/
- function enableIsActive ($isActive = true);
+ function enableIsActive ($isActive = TRUE);
/**
* Determines whether the cruncher is active
/**
* Whether this apt-proxy is active
*/
- private $isActive = false;
+ private $isActive = FALSE;
/**
* Protected constructor
* @param $version Version number of this apt-proxy
* @return void
*/
- public final function enableIsActive ($isActive = true) {
+ public final function enableIsActive ($isActive = TRUE) {
$this->isActive = (bool) $isActive;
}
/**
* Whether this Chatter is active
*/
- private $isActive = false;
+ private $isActive = FALSE;
/**
* Protected constructor
* @param $version Version number of this chatter
* @return void
*/
- public final function enableIsActive ($isActive = true) {
+ public final function enableIsActive ($isActive = TRUE) {
$this->isActive = (bool) $isActive;
}
*/
protected function isValidFinalChunk (array $chunks) {
// Default is all fine
- $isValid = true;
+ $isValid = TRUE;
// Split the (possible) EOP chunk
$chunkSplits = explode(PackageFragmenter::CHUNK_DATA_HASH_SEPARATOR, $chunks[count($chunks) - 1]);
// Validate final chunk
if (substr($chunkSplits[ChunkHandler::CHUNK_SPLITS_INDEX_RAW_DATA], 0, strlen(PackageFragmenter::END_OF_PACKAGE_IDENTIFIER)) != PackageFragmenter::END_OF_PACKAGE_IDENTIFIER) {
// Not fine
- $isValid = false;
+ $isValid = FALSE;
} elseif (substr_count($chunkSplits[ChunkHandler::CHUNK_SPLITS_INDEX_RAW_DATA], PackageFragmenter::CHUNK_HASH_SEPARATOR) != 1) {
// CHUNK_HASH_SEPARATOR shall only be found once
- $isValid = false;
+ $isValid = FALSE;
}
// Return status
/**
* By default no cruncher is active
*/
- private $isActive = false;
+ private $isActive = FALSE;
/**
* All buffer queue instances (a FIFO)
* @param $version Version number of this cruncher
* @return void
*/
- public final function enableIsActive ($isActive = true) {
+ public final function enableIsActive ($isActive = TRUE) {
$this->isActive = (bool) $isActive;
}
}
// Is it false, the recipient isn't known to us and we have no connection to it
- if (($socketResource === false) || (!is_resource($socketResource)) || (socket_last_error($socketResource) > 0)) {
+ if (($socketResource === FALSE) || (!is_resource($socketResource)) || (socket_last_error($socketResource) > 0)) {
// Try to create a new socket resource
try {
// Possibly noisy debug message
self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __LINE__ . ']: Cannot discover socket resource for recipient ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ': ' . $e->getMessage());
// Make any failed attempts to 'false'
- $socketResource = false;
+ $socketResource = FALSE;
}
// And return it
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// By default, the requirement check is passed and zero checks are failed
- $checkPassed = true;
+ $checkPassed = TRUE;
$checksFailed = 0;
// Socket support is essential...
if (!function_exists('socket_create')) {
// Test failed
- $checkPassed = false;
+ $checkPassed = FALSE;
$checksFailed++;
} // END -if
// Are all tests passed?
- if ($checkPassed === false) {
+ if ($checkPassed === FALSE) {
// Throw an exception
throw new FilterChainException($this, self::FILTER_CHAIN_INTERCEPTED);
} // END - if
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// By default, the requirement check is passed and zero checks are failed
- $checkPassed = true;
+ $checkPassed = TRUE;
$checksFailed = 0;
// Socket support is essential...
if (!function_exists('socket_create')) {
// Test failed
- $checkPassed = false;
+ $checkPassed = FALSE;
$checksFailed++;
} // END -if
// Are all tests passed?
- if ($checkPassed === false) {
+ if ($checkPassed === FALSE) {
// Throw an exception
throw new FilterChainException($this, self::FILTER_CHAIN_INTERCEPTED);
} // END - if
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// By default, the requirement check is passed and zero checks are failed
- $checkPassed = true;
+ $checkPassed = TRUE;
$checksFailed = 0;
// Socket support is essential...
if (!function_exists('socket_create')) {
// Test failed
- $checkPassed = false;
+ $checkPassed = FALSE;
$checksFailed++;
} // END -if
// Are all tests passed?
- if ($checkPassed === false) {
+ if ($checkPassed === FALSE) {
// Throw an exception
throw new FilterChainException($this, self::FILTER_CHAIN_INTERCEPTED);
} // END - if
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// By default, the requirement check is passed and zero checks are failed
- $checkPassed = true;
+ $checkPassed = TRUE;
$checksFailed = 0;
// Socket support is essential...
if (!function_exists('socket_create')) {
// Test failed
- $checkPassed = false;
+ $checkPassed = FALSE;
$checksFailed++;
} // END -if
// Are all tests passed?
- if ($checkPassed === false) {
+ if ($checkPassed === FALSE) {
// Throw an exception
throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} // END - if
* As for now, just set the array element. If any further steps are
* being added, this should always be the last step.
*/
- $this->finalPackageChunks['is_complete'] = true;
+ $this->finalPackageChunks['is_complete'] = TRUE;
}
/**
*/
public function ifUnhandledChunksWithFinalAvailable () {
// Simply check if the stacker is not empty
- $unhandledChunks = $this->getStackerInstance()->isStackEmpty(self::STACKER_NAME_CHUNKS_WITH_FINAL_EOP) === false;
+ $unhandledChunks = $this->getStackerInstance()->isStackEmpty(self::STACKER_NAME_CHUNKS_WITH_FINAL_EOP) === FALSE;
// Return result
return $unhandledChunks;
*/
public function ifUnassembledChunksAvailable () {
// For now do only check the array element 'is_complete'
- $unassembledChunksAvailable = ($this->finalPackageChunks['is_complete'] === true);
+ $unassembledChunksAvailable = ($this->finalPackageChunks['is_complete'] === TRUE);
// Return status
return $unassembledChunksAvailable;
$data = @socket_read($read_sock, 1024, PHP_NORMAL_READ);
// check if the client is disconnected
- if (($data === false) || (in_array(strtolower(trim($data)), $leaving))) {
+ if (($data === FALSE) || (in_array(strtolower(trim($data)), $leaving))) {
// remove client for $clients array
$key = array_search($read_sock, $clients);
// Debug output of read data length
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __LINE__ . ']: rawData[' . gettype($rawData) . ']=' . strlen($rawData) . ',MD5=' . md5($rawData) . ',resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE] . ',error=' . socket_strerror(socket_last_error($socketArray[BasePool::SOCKET_ARRAY_RESOURCE])));
- //* NOISY-DEBUG: */ if ($rawData !== false) self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __LINE__ . ']: rawData=' . $rawData);
+ //* NOISY-DEBUG: */ if ($rawData !== FALSE) self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __LINE__ . ']: rawData=' . $rawData);
// Is it valid?
if (socket_last_error($socketArray[BasePool::SOCKET_ARRAY_RESOURCE]) == 11) {
// Skip any further processing
return;
- } elseif (($rawData === false) || (socket_last_error($socketArray[BasePool::SOCKET_ARRAY_RESOURCE]) > 0)) {
+ } elseif (($rawData === FALSE) || (socket_last_error($socketArray[BasePool::SOCKET_ARRAY_RESOURCE]) > 0)) {
// Network error or connection lost
$this->setErrorCode(socket_last_error($socketArray[BasePool::SOCKET_ARRAY_RESOURCE]));
} elseif (empty($rawData)) {
*/
private function executeCurrentTask () {
// Update no task by default
- $updateTask = false;
+ $updateTask = FALSE;
// Is the current task valid?
if (!$this->getListInstance()->getIterator()->valid()) {
$currentTask = $this->getListInstance()->getIterator()->current();
// Is the task not yet started?
- if ($currentTask['task_started'] === false) {
+ if ($currentTask['task_started'] === FALSE) {
// Determine difference between current time and registration
$diff = ($this->getMilliTime() - $currentTask['task_registered']) * 1000;
} // END - if
// Launch the task and mark it as updated
- $currentTask['task_started'] = true;
- $updateTask = true;
+ $currentTask['task_started'] = TRUE;
+ $updateTask = TRUE;
// Debug message
self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Task ' . $currentTask['id'] . ' started with startup_delay=' . $currentTask['task_startup_delay'] . 'ms');
// Is the interval delay reached?
if ((($diff < $currentTask['task_interval_delay']) && ($currentTask['task_max_runs'] == 0)) || (($currentTask['task_total_runs'] == $currentTask['task_max_runs']) && ($currentTask['task_max_runs'] > 0))) {
// Should we update the task from startup?
- if ($updateTask === true) {
+ if ($updateTask === TRUE) {
// Update the task before leaving
$this->updateTask($currentTask);
} // END - if
/**
* Whether this connection is initialized
*/
- private $isInitialized = false;
+ private $isInitialized = FALSE;
/**
* Whether this connection is shutted down
*/
- private $shuttedDown = false;
+ private $shuttedDown = FALSE;
/**
* Currently queued chunks
} // END - if
// Last step: mark connection as initialized
- $this->isInitialized = true;
+ $this->isInitialized = TRUE;
}
/**
*/
protected function connectToPeerByRecipientData (array $recipientData) {
// Only call this if the connection is initialized by initConnection()
- assert($this->isInitialized === true);
+ assert($this->isInitialized === TRUE);
// Get current time
$time = time();
// Now, is that attempt within parameters?
if ((time() - $time) >= $timeout) {
// Didn't work within timeout
- $isConnected = false;
+ $isConnected = FALSE;
break;
} // END - if
$this->idle(1000);
} elseif ($socketError != 0) {
// Stop on everything else pronto
- $isConnected = false;
+ $isConnected = FALSE;
break;
}
} // END - while
// Is the peer connected?
- if ($isConnected === true) {
+ if ($isConnected === TRUE) {
// Connection is fully established here, so change the state.
PeerStateFactory::createPeerStateInstanceByName('connected', $this);
} else {
private function getRawDataFromPackageArray (array $packageData) {
// Implode the package data array and fragement the resulting string, returns the final hash
$finalHash = $this->getFragmenterInstance()->fragmentPackageArray($packageData, $this);
- if ($finalHash !== true) {
+ if ($finalHash !== TRUE) {
$this->currentFinalHash = $finalHash;
} // END - if
$sentBytes = 0;
// Deliver all data
- while ($sentBytes !== false) {
+ while ($sentBytes !== FALSE) {
// And deliver it
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: Sending out ' . strlen($encodedData) . ' bytes,bufferSize=' . $bufferSize . ',diff=' . $this->diff);
}
// If there was an error, we don't continue here
- if ($sentBytes === false) {
+ if ($sentBytes === FALSE) {
// Handle the error with a faked recipientData array
$this->handleSocketError(__METHOD__, __LINE__, $socketResource, array('0.0.0.0', '0'));
*/
protected final function markConnectionShuttedDown () {
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: ' . $this->__toString() . ' has been marked as shutted down');
- $this->shuttedDown = true;
+ $this->shuttedDown = TRUE;
// And remove the (now invalid) socket
$this->setSocketResource(false);
$recipientData[0] = ConsoleTools::determineExternalIp();
// Do we have hostname:ip match?
- if (strpos($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], ':') === false) {
+ if (strpos($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], ':') === FALSE) {
// No hostname:ip!
$helperInstance->debugInstance($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ' does not contain ":". Please fix this.');
} // END - if
/**
* Whether we are in blocking or non-blocking mode (default: non-blocking
*/
- private $blockingMode = false;
+ private $blockingMode = FALSE;
/**
* A peer pool instance
$isServerSocket = ((is_resource($socketResource)) && (!@socket_getpeername($socketResource, $peerName)));
// We need to clear the error here if it is a resource
- if ($isServerSocket === true) {
+ if ($isServerSocket === TRUE) {
// Clear the error
//* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('socketResource[]=' . gettype($socketResource));
socket_clear_error($socketResource);
$data = @socket_read($read_sock, 1024, PHP_NORMAL_READ);
// check if the client is disconnected
- if (($data === false) || (in_array(strtolower(trim($data)), $leaving))) {
+ if (($data === FALSE) || (in_array(strtolower(trim($data)), $leaving))) {
// remove client for $clients array
$key = array_search($read_sock, $clients);
* Whether this node is anncounced (KEEP ON false!)
* @deprecated
*/
- private $hubIsAnnounced = false;
+ private $hubIsAnnounced = FALSE;
/**
* Whether this hub is active (default: false)
*/
- private $isActive = false;
+ private $isActive = FALSE;
/**
* Whether this node accepts announcements (default: false)
*/
- private $acceptAnnouncements = false;
+ private $acceptAnnouncements = FALSE;
/**
* Protected constructor
*/
protected function ifAddressMatchesBootstrappingNodes ($remoteAddr) {
// By default nothing is found
- $isFound = false;
+ $isFound = FALSE;
// Run through all configured IPs
foreach (explode(BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR, $this->getConfigInstance()->getConfigEntry('hub_bootstrap_nodes')) as $ipPort) {
// Does it match?
if ($ipPortArray[0] == $remoteAddr) {
// Found it!
- $isFound = true;
+ $isFound = TRUE;
// Remember the port number
$this->bootIpPort = $ipPort;
* IP matches listen address. At this point we really don't care
* if we can really listen on that address
*/
- $isFound = true;
+ $isFound = TRUE;
// Remember the port number
$this->bootIpPort = $ipPort;
*/
public function announceToUpperNodes (Taskable $taskInstance) {
// Is this hub node announced?
- if ($this->hubIsAnnounced === true) {
+ if ($this->hubIsAnnounced === TRUE) {
// Already announced!
throw new NodeAlreadyAnnouncedException($this, self::EXCEPTION_HUB_ALREADY_ANNOUNCED);
} // END - if
* @param $isActive Whether the hub is active
* @return void
*/
- public final function enableIsActive ($isActive = true) {
+ public final function enableIsActive ($isActive = TRUE) {
$this->isActive = (bool) $isActive;
}
*/
public final function isAcceptingAnnouncements () {
// Check it (this node must be active and not shutdown!)
- $acceptAnnouncements = (($this->acceptAnnouncements === true) && ($this->isNodeActive()));
+ $acceptAnnouncements = (($this->acceptAnnouncements === TRUE) && ($this->isNodeActive()));
// Return it
return $acceptAnnouncements;
* @param $acceptAnnouncements Whether this node accepts announcements (default: true)
* @return void
*/
- protected final function enableAcceptingAnnouncements ($acceptAnnouncements = true) {
+ protected final function enableAcceptingAnnouncements ($acceptAnnouncements = TRUE) {
$this->acceptAnnouncements = $acceptAnnouncements;
}
* @param $forceReInit Whether to force reinitialization of all stacks
* @return void
*/
- protected function initStackers ($forceReInit = false) {
+ protected function initStackers ($forceReInit = FALSE) {
// Initialize all
foreach (
array(
$isProcessed = (
(isset($this->processedPackages[$index]))
&&
- ($this->processedPackages[$index] === true)
+ ($this->processedPackages[$index] === TRUE)
);
// Return it
*/
private function markPackageDataProcessed (array $packageData) {
// Remember it (until we may remove it)
- $this->processedPackages[$this->getProcessedPackagesIndex($packageData)] = true;
+ $this->processedPackages[$this->getProcessedPackagesIndex($packageData)] = TRUE;
}
/**
$current = $this->getCurrentChunkPointer($finalHash);
} catch (AssertionException $e) {
// This may happen when the final hash is true
- if ($finalHash === true) {
+ if ($finalHash === TRUE) {
// Set current to null
$current = NULL;
} else {
*/
public function getSocketFromPackageData (array $packageData, $connectionType = NULL) {
// Default is no socket
- $socketResource = false;
+ $socketResource = FALSE;
// Temporary resolve recipient field
$recipientIpArray = explode(':', HubTools::resolveSessionId($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]));
*/
public function isConnectionRegistered (ConnectionHelper $connectionInstance, $socketResource) {
// Default is not registered
- $isRegistered = false;
+ $isRegistered = FALSE;
// First, check for the instance, there can be only once
if ($this->isProtocolRegistered($connectionInstance)) {
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - ENTERED!');
// Default is not registered
- $isRegistered = false;
+ $isRegistered = FALSE;
// First, check for the instance, there can be only once
if ($this->isProtocolRegistered($protocolInstance)) {
if (empty($commandName)) {
// Then thrown an exception here
throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
- } elseif ($resolverInstance->isCommandValid($commandName) === false) {
+ } elseif ($resolverInstance->isCommandValid($commandName) === FALSE) {
// Invalid command found
throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND);
}
if (empty($commandName)) $commandName = $this->getConfigInstance()->getConfigEntry('default_console_command');
// Check if command is valid
- if ($this->isCommandValid($commandName) === false) {
+ if ($this->isCommandValid($commandName) === FALSE) {
// This command is invalid!
throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
} // END - if
if (empty($commandName)) $commandName = $this->getConfigInstance()->getConfigEntry('default_console_command');
// Check if command is valid
- if ($this->isCommandValid($commandName) === false) {
+ if ($this->isCommandValid($commandName) === FALSE) {
// This command is invalid!
throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
}
if (empty($controllerName)) {
// Then thrown an exception here
throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
- } elseif ($resolverInstance->isControllerValid($controllerName) === false) {
+ } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) {
// Invalid command found
throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
}
if (empty($controllerName)) {
// Then thrown an exception here
throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
- } elseif ($resolverInstance->isControllerValid($controllerName) === false) {
+ } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) {
// Invalid command found
throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
}
*/
public function isStateValid ($stateName) {
// By default nothing shall be valid
- $isValid = false;
+ $isValid = FALSE;
// Is a state set?
if (empty($stateName)) {
$this->setClassName($className);
// Try it hard to get an state
- while ($isValid === false) {
+ while ($isValid === FALSE) {
// Is this class already loaded?
if (class_exists($this->getClassName())) {
// This class does exist. :-)
- $isValid = true;
+ $isValid = TRUE;
} elseif ($this->getClassName() != $this->statePrefix . 'DefaultState') {
// Set default state
$this->setClassName($this->statePrefix . 'DefaultState');
* @return void
* @todo This method is old code and needs heavy rewrite and should be moved to ApplicationHelper
*/
- public static final function app_exit ($message = '', $code = false, $extraData = '', $silentMode = false) {
+ public static final function app_exit ($message = '', $code = FALSE, $extraData = '', $silentMode = FALSE) {
// Is this method already called?
if (isset($GLOBALS['app_die_called'])) {
// Then output the text directly
} // END - if
// This method shall not be called twice
- $GLOBALS['app_die_called'] = true;
+ $GLOBALS['app_die_called'] = TRUE;
// Is a message set?
if (empty($message)) {
$configInstance = FrameworkConfiguration::getSelfInstance();
// Do we have debug installation?
- if (($configInstance->getConfigEntry('product_install_mode') == 'productive') || ($silentMode === true)) {
+ if (($configInstance->getConfigEntry('product_install_mode') == 'productive') || ($silentMode === TRUE)) {
// Abort here
exit();
} // END - if