- yet even more type-hints ...
* @return $status Status of file seek: 0 = success, -1 = failed
* @throws OutOfBoundsException If the position is not seekable
*/
- public function seek (int $offset, int $whence = SEEK_SET) {
+ public function seek (int $offset, int $whence = SEEK_SET): int {
// Validate parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: offset=%d,whence=%d - CALLED!', $offset, $whence));
if ($offset < 0) {
* @return $data Data read from file
* @throws OutOfBoundsException If the position is not seekable
*/
- public function read (int $bytes = 0) {
+ public function read (int $bytes = 0): string {
// Validate parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: bytes=%d - CALLED!', $bytes));
if ($bytes < 0) {
// Now simply write a NUL there. This will pre-allocate the file.
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: Invoking this->writeAtPosition(%d,NUL) ...', $seekPosition));
- $this->writeAtPosition($seekPosition, chr(0));
+ $status = $this->writeAtPosition($seekPosition, chr(0));
+ // @TODO Handle $status properly
// Is the seek position zero?
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: fileSize=%d', $fileSize));
* @throws InvalidArgumentException If a parameter is not valid
* @throws UnexpectedValueException If fread() returns a non-string value
*/
- public function read (int $bytes = 0) {
+ public function read (int $bytes = 0): string {
// Trace message
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('RAW-FILE-INPUT-POINTER: bytes=%d - CALLED!', $bytes));
if ($bytes < 0) {
* @throws NullPointerException If the file pointer instance is not set by setFileObject()
* @throws LogicException If $fileObject is not an object
*/
- public function read (int $bytes = 0) {
+ public function read (int $bytes = 0): string {
// Some sanity checks
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('RAW-FILE-INPUT-POINTER: bytes=%d - CALLED!', $bytes));
if ($bytes < 0) {
* @return $data Data read from file
* @throws OutOfBoundsException If the position is not seekable
*/
- public function read (int $bytes = 0) {
+ public function read (int $bytes = 0): string {
// Validatre parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-INPUT-OUTPUT-POINTER: bytes=%d - CALLED!', $bytes));
if ($bytes < 0) {
* @return $data The data (string mostly) to "stream"
* @throws UnsupportedOperationException If this method is called
*/
- public function streamData (string $data) {
+ public function streamData (string $data): string {
// Not supported
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-IO-STREAM: data=()=%d - CALLED!', strlen($data)));
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
* @return mixed Number of writes bytes or false on error
* @throws UnsupportedOperationException If this method is called
*/
- public function writeAtPosition (int $seedPosition, string $data): void {
+ public function writeAtPosition (int $seedPosition, string $data): mixed {
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return mixed Number of writes bytes or false on error
* @throws UnsupportedOperationException If this method is called
*/
- public function writeAtPosition (int $seedPosition, string $data) {
+ public function writeAtPosition (int $seedPosition, string $data): mixed {
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
*
* @return $handlerName Name of this handler
*/
- public final function getHandlerName () {
+ public final function getHandlerName (): string {
return $this->handlerName;
}
* @param $handlerName Name of this handler
* @return void
*/
- protected final function setHandlerName (string $handlerName) {
+ protected final function setHandlerName (string $handlerName): void {
$this->handlerName = $handlerName;
}
* @return void
* @todo Rewrite this to use DHT
*/
- public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) {
+ public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData): void {
// Check parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-HANDLER: dataSetInstance=%s,messageData()=%d - CALLED!', $dataSetInstance->__toString(), count($messageData)));
if (count($messageData) == 0) {
* @throws InvalidArgumentException If the parameter is not valid
* @todo Unfinished work
*/
- public function searchNextGap (int $length) {
+ public function searchNextGap (int $length): int {
// Validate parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FILE-INDEX: length=%d - CALLED!', $length));
if ($length <= 0) {
* @throws OutOfBoundsException If the position is not seekable
* @throws InvalidArgumentException If a parameter is not valid
*/
- public function writeAtPosition (int $seekPosition, string $dataStream) {
+ public function writeAtPosition (int $seekPosition, string $dataStream): mixed {
// Validate parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FILE-INDEX: seekPosition=%d,dataStream(%d)=%s - CALLED!', $seekPosition, strlen($dataStream), $dataStream));
if ($seekPosition < 0) {
*
* @return $isLoaded Whether this index has been loaded
*/
- public function isIndexLoaded () {
+ public function isIndexLoaded (): bool {
// Is the file gaps-only?
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-INDEX: CALLED!');
if ($this->getIteratorInstance()->getBinaryFileInstance()->isFileGapsOnly()) {
* @param $fileInfoInstance An instance of a SplFileInfo class
* @return $indexInstance An instance of this Index class
*/
- public final static function createFileStackIndex (SplFileInfo $fileInfoInstance) {
+ public final static function createFileStackIndex (SplFileInfo $fileInfoInstance): IndexableStack {
// Get a new instance
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-INDEX: fileInfoInstance[%s]=%s - CALLED!', get_class($fileInfoInstance), $fileInfoInstance));
$indexInstance = new FileStackIndex();
* @throws InvalidArgumentException If a parameter is not valid
* @throws UnexpectedValueException If an invalid gap position is being returned
*/
- public function addHashedDataToIndex (string $stackName, array $data) {
+ public function addHashedDataToIndex (string $stackName, array $data): void {
// Validate parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-INDEX: stackName=%s,data()=%d - CALLED!', $stackName, count($data)));
if (empty($stackName)) {
* @return void
* @throws OutOfBoundsException If the position is not seekable
*/
- public function seek (int $seekPosition): seek {
+ public function seek (int $seekPosition): int {
// Validate parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('FILE-ITERATOR: seekPosition=%d,whence=%d - CALLED!', $seekPosition, $whence));
if ($seekPosition < 0) {
* @param $applicationInstance An instance of a ManageableApplication class
* @return $debugInstance An instance of this middleware class
*/
- public static final function createWebOutput (ManageableApplication $applicationInstance) {
+ public static final function create???Output (ManageableApplication $applicationInstance): OutputStreamer {
// Is the self-instance already set?
if (is_null(self::$!!!Instance)) {
// Get a new instance and set it
- self::$!!!Instance = new WebOutput();
+ self::$!!!Instance = new ???Output();
// Get the content type
$contentType = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('!!!_content_type');
* @return void
* @todo 0% done
*/
- public final function output ($outStream = false, $stripTags = false) {
+ public final function output ($outStream = false, $stripTags = false): void {
DebugMiddleware::getSelfInstance()->partialStub('Please implement this method. outStream()=' . strlen($outStream) . ',stripTags=' . intval($stripTags));
}
* @return $seekPosition Current seek position
* @throws UnsupportedOperationException If this method is called
*/
- public function determineSeekPosition () {
+ public function determineSeekPosition (): int {
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return $size Size (in bytes) of file
* @throws UnsupportedOperationException If this method is called
*/
- public function size () {
+ public function size (): int {
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
* @param $element Name of the request element we want to check
* @return $isSet Whether the request element is set
*/
- public function isRequestElementSet (string $element) {
+ public function isRequestElementSet (string $element): bool {
// Is this element found?
$isSet = isset($this->requestData[$element]);
* @return $value Value of the found request element or 'null' if the
* element was not found
*/
- public function getRequestElement (string $element) {
+ public function getRequestElement (string $element): mixed {
// Initialize value
$value = NULL;
* @param $value Value to set
* @return void
*/
- public function setRequestElement (string $element, $value) {
+ public function setRequestElement (string $element, mixed $value): void {
$this->requestData[$element] = $value;
}
* @param $requestData Request element to se
* @return void
*/
- public function setRequestData (array $requestData) {
+ public function setRequestData (array $requestData): void {
$this->requestData = $requestData;
}
*
* @return $array An array containing all array keys to return
*/
- public function getParameterNames () {
+ public function getParameterNames (): array {
return array_keys($this->requestData);
}
* @param $isValid Whether the request is valid
* @return void
*/
- public final function setIsRequestValid (bool $isValid) {
+ public final function setIsRequestValid (bool $isValid): void {
$this->isRequestValid = $isValid;
}
*
* @return $isRequestValid Whether this request is valid
*/
- public final function isRequestValid () {
+ public final function isRequestValid (): bool {
return $this->isRequestValid;
}
// Write it to disk (header is always at seek position 0)
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: Invoking this->iteratorInstance->writeAtPosition(0, header=%s) ...', $header));
- $this->getIteratorInstance()->getBinaryFileInstance()->writeAtPosition(0, $header);
+ $status = $this->getIteratorInstance()->getBinaryFileInstance()->writeAtPosition(0, $header);
+ // @TODO Handle $status
// Trace message
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: EXIT!');
* @param $messageData An array with all message data
* @return void
*/
- function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData);
+ function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData): void;
+
+ /**
+ * Getter for handler name
+ *
+ * @return<>$handlerNameName of this handler
+ */
+ function getHandlerName (): string;
}
* @param $taskInstanc An instanceof a Taskable class
* @return $taskName Name of the task as used while registration
*/
- function searchTask (Taskable $taskInstance);
+ function searchTask (Taskable $taskInstance): string;
/**
* Registers a task with a task handler.
* @param $taskInstance An instance of a Taskable class
* @return void
*/
- function registerTask (string $taskName, Taskable $taskInstance);
+ function registerTask (string $taskName, Taskable $taskInstance): void;
/**
* Checks whether tasks are left including idle task
*
* @return void
*/
- function handleTasks ();
+ function handleTasks (): void;
/**
* Shuts down all tasks and the task handler itself. This method should be
*
* @return void
*/
- function doShutdown ();
+ function doShutdown (): void;
}
*
* @return $isLoaded Whether the index has been loaded
*/
- function isIndexLoaded ();
+ function isIndexLoaded (): bool;
}
* @return void
* @throws InvalidArgumentException If a parameter is not valid
*/
- function addHashedDataToIndex (string $stackName, array $data);
+ function addHashedDataToIndex (string $stackName, array $data): void;
/**
* Searches for next suitable gap the given length of data can fit in
* @return $seekPosition Found next gap's seek position
* @throws InvalidArgumentException If the parameter is not valid
*/
- function searchNextGap (int $length);
+ function searchNextGap (int $length): int;
/**
* Writes at given position by seeking to it.
* @return mixed Number of writes bytes or false on error
* @throws InvalidArgumentException If a parameter is not valid
*/
- function writeAtPosition (int $seekPosition, string $dataStream);
+ function writeAtPosition (int $seekPosition, string $dataStream): mixed;
}
* @throws NullPointerException If the file pointer instance is not set by setFileObject()
* @throws InvalidResourceException If there is being set
*/
- function closeFile ();
+ function closeFile (): void;
}
*
* @return $seekPosition Current seek position
*/
- function determineSeekPosition ();
+ function determineSeekPosition (): int;
/**
* Seek to given offset (default) or other possibilities as fseek() gives.
*
* @param $offset Offset to seek to (or used as "base" for other seeks)
* @param $whence Added to offset (default: only use offset to seek to)
- * @return void
+ * @return $position Position after seeking (?)
* @throws OutOfBoundsException If the position is not seekable
*/
function seek (int $offset, int $whence = SEEK_SET): int;
*
* @return $size Size (in bytes) of file
*/
- function size ();
+ function size (): int;
}
* is not set by setFileObject()
* @throws InvalidResourceException If there is being set
*/
- function read (int $bytes = 0);
+ function read (int $bytes = 0): string;
}
* @param $data Data to be written
* @return mixed Number of writes bytes or false on error
*/
- function writeAtPosition (int $seedPosition, string $data);
+ function writeAtPosition (int $seedPosition, string $data): mixed;
}
*
* @return void
*/
- function initializeReader();
+ function initializeReader(): void;
}
* @param $element Name of the request element we want to check
* @return $isSet Whether the request element is set
*/
- function isRequestElementSet (string $element);
+ function isRequestElementSet (string $element): bool;
/**
* Getter for request element or 'null' if element was not found
* @return $value Value of the found request element or 'null' if the
* element was not found
*/
- function getRequestElement (string $element);
+ function getRequestElement (string $element): mixed;
/**
* Setter for request elements
* @param $value Value to set
* @return void
*/
- function setRequestElement (string $element, $value);
+ function setRequestElement (string $element, mixed $value): void;
/**
* Setter for request data array
* @param $requestData Request element to se
* @return void
*/
- function setRequestData (array $requestData);
+ function setRequestData (array $requestData): void;
/**
* Wrapper method for array_key() function for the request data array
*
* @return $array An array containing all array keys to return
*/
- function getParameterNames ();
+ function getParameterNames (): array;
/**
* Sets whether the request was valid
* @param $isValid Whether the request is valid
* @return void
*/
- function setIsRequestValid (bool $isValid);
+ function setIsRequestValid (bool $isValid): void;
/**
* Returns whether this request is valid
*
* @return $isRequestValid Whether this request is valid
*/
- function isRequestValid ();
+ function isRequestValid (): bool;
}
* @return void
* @throws UnsupportedOperationException If this method is called
*/
- public function saveFile (SplFileInfo $infoInstance, array $dataArray) {
+ public function saveFile (SplFileInfo $infoInstance, array $dataArray): void {
// Trace message for logging parameters
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-IO-HANDLER: infoInstance.pathname=%s,dataArray()=%d - CALLED!', $infoInstance->getPathname(), count($dataArray)));
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
* @param $infoInstance An instance of a SplFileInfo class
* @return $array Array with the file contents
*/
- public function loadFileContents (SplFileInfo $infoInstance) {
+ public function loadFileContents (SplFileInfo $infoInstance): array {
// Read from the input handler
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-IO-HANDLER: infoInstance=%s - CALLED!', $infoInstance->__toString()));
return $this->getInputStreamerInstance()->loadFileContents($infoInstance);
* @return $seekPosition Current seek position
* @todo 0% done
*/
- public function determineSeekPosition () {
+ public function determineSeekPosition (): int {
// Trace message
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-IO-HANDLER: CALLED!');
DebugMiddleware::getSelfInstance()->partialStub();
* @return $size Size (in bytes) of file
* @todo 0% done
*/
- public function size () {
+ public function size (): int {
// @TODO: Unfinished method:
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-IO-HANDLER: CALLED!');
DebugMiddleware::getSelfInstance()->partialStub();
* @return $seekPosition Current seek position
* @todo 0% done
*/
- public function getPosition () {
+ public function getPosition (): int {
// @TODO: Unfinished method:
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-IO-HANDLER: CALLED!');
DebugMiddleware::getSelfInstance()->partialStub();