*
* @return $foundValue Found value of previous found() call
*/
- public final function getFoundValue () {
+ public final function getFoundValue (): mixed {
return $this->foundValue;
}
* @param $backBuffer Characters to "store" in back-buffer
* @return void
*/
- private function setBackBuffer (string $backBuffer) {
+ private function setBackBuffer (string $backBuffer): void {
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: Setting backBuffer(%d)=%s - CALLED!', strlen($backBuffer), $backBuffer));
$this->backBuffer = $backBuffer;
}
*
* @return $backBuffer Characters "stored" in back-buffer
*/
- private function getBackBuffer () {
+ private function getBackBuffer (): string {
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: Getting this->backBuffer(%d)=%s - CALLED!', strlen($this->backBuffer), $this->backBuffer));
return $this->backBuffer;
}
* @param $current Characters to set a currently loaded block
* @return void
*/
- private function setCurrentBlock (string $currentBlock) {
+ private function setCurrentBlock (string $currentBlock): void {
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: Setting currentBlock(%d)=%s - CALLED!', strlen($currentBlock), $currentBlock));
$this->currentBlock = $currentBlock;
}
*
* @return $current Currently read data
*/
- public function getCurrentBlock () {
+ public function getCurrentBlock (): string {
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: Getting this->currentBlock(%d)=%s - CALLED!', strlen($this->currentBlock), $this->currentBlock));
return $this->currentBlock;
}
*
* @return $totalEntries Size of file header
*/
- public final function getHeaderSize () {
+ public final function getHeaderSize (): int {
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: Getting this->headerSize=%d - CALLED!', $this->headerSize));
return $this->headerSize;
}
* @param $headerSize Size of file header
* @return void
*/
- public final function setHeaderSize (int $headerSize) {
+ public final function setHeaderSize (int $headerSize): void {
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: Setting headerSize=%d - CALLED!', $headerSize));
$this->headerSize = $headerSize;
}
*
* @return $totalEntries Size of file header
*/
- public final function getHeader () {
+ public final function getHeader (): array {
// Get it
return $this->header;
}
* @param $header Array for a file header
* @return void
*/
- public final function setHeader (array $header) {
+ public final function setHeader (array $header): void {
// Set it
$this->header = $header;
}
*
* @return $seekPosition Current seek position (stored here in object)
*/
- public final function getSeekPosition () {
+ public final function getSeekPosition (): int {
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: Getting this->seekPosition=%d - CALLED!', $this->seekPosition));
return $this->seekPosition;
}
* @param $seekPosition Current seek position (stored here in object)
* @return void
*/
- protected final function setSeekPosition (int $seekPosition) {
+ protected final function setSeekPosition (int $seekPosition): void {
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: Setting seekPosition=%d - CALLED!', $seekPosition));
$this->seekPosition = $seekPosition;
}
* @return $isGapsOnly Whether the abstracted file only contains gaps
* @throws OutOfBoundsException If calculated file size is larger than actual
*/
- public function isFileGapsOnly () {
+ public function isFileGapsOnly (): bool {
// Count every gap
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: CALLED!');
$gapsSize = 0;
* @param $minimumBlockLength Minimum block length
* @return void
*/
- private function markFileGapsOnly (string $type, int $minimumBlockLength) {
+ private function markFileGapsOnly (string $type, int $minimumBlockLength): void {
// Is config cache there?
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: type=%s,minimumBlockLength=%d - CALLED!', $type, $minimumBlockLength));
if (!isset(self::$configCache[$type . '_pre_allocate_count'])) {
* @param $endPosition End seek position
* @return void
*/
- private function addGap(int $startPosition, int $endPosition) {
+ private function addGap(int $startPosition, int $endPosition): void {
// Push to gaps array
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: startPosition=%d,endPosition=%d - CALLED!', $startPosition, $endPosition));
array_push($this->gaps, [
*
* @return void
*/
- private function initBackBuffer () {
+ private function initBackBuffer (): void {
// Simply call the setter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: CALLED!');
$this->setBackBuffer('');
* @param $flushHeader Wether the file's header should be flushed (default: false)
* @return void
*/
- protected function rewindUpdateSeekPosition (bool $flushHeader = false) {
+ protected function rewindUpdateSeekPosition (bool $flushHeader = false): void {
// Seek to beginning of file
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: flushHeader=%d - CALLED!', intval($flushHeader)));
$this->rewind();
*
* @return void
*/
- protected function seekToOldPosition () {
+ protected function seekToOldPosition (): void {
// Seek to currently ("old") saved position
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: CALLED!');
$this->seek($this->determineSeekPosition());
* @param $fileInfoInstance An instance of a SplFileInfo class
* @return void
*/
- protected function initFile (SplFileInfo $fileInfoInstance) {
+ protected function initFile (SplFileInfo $fileInfoInstance): void {
// Get a file i/o pointer instance
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: fileInfoInstance[%s]=%s - CALLED!', get_class($fileInfoInstance), $fileInfoInstance));
$pointerInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_output_class', array($fileInfoInstance));
* @return void
* @throws InvalidArgumentException If a parameter is invalid
*/
- protected function markCurrentBlockAsEmpty (int $length) {
+ protected function markCurrentBlockAsEmpty (int $length): void {
// Validate parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: length=%d - CALLED!', $length));
if ($length < 1) {
*
* @return void
*/
- public function initCountersGapsArray () {
+ public function initCountersGapsArray (): void {
// Init counter and seek position to header size
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: Invoking this->determineSeekPosition() - CALLED!');
$seekPosition = $this->getSeekPosition();
*
* @return void
*/
- public function updateSeekPosition () {
+ public function updateSeekPosition (): void {
// Get key (= seek position)
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: CALLED!');
$seekPosition = $this->determineSeekPosition();
* @return $isFound Whether the block separator has been found
* @throws InvalidArgumentException If a parameter is not valid
*/
- public static function isBlockSeparatorFound (string $str) {
+ public static function isBlockSeparatorFound (string $str): bool {
// Validate parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: str=%s - CALLED!', $str));
if (empty($str)) {
* @throws OutOfBoundsException If the position is not seekable
* @throws InvalidArgumentException If a parameter is invalid
*/
- public function writeData (int $seekPosition, string $data, bool $flushHeader = true) {
+ public function writeData (int $seekPosition, string $data, bool $flushHeader = true): void {
// Validate parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: seekPosition=%s,data()=%d,flushHeader=%d - CALLED!', $seekPosition, strlen($data), intval($flushHeader)));
if ($seekPosition < 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-BINARY-FILE: seekPosition=%d,dataStream(%d)=%s - CALLED!', $seekPosition, strlen($dataStream), $dataStream));
if ($seekPosition < 0) {
*
* @return $isInitialized Whether the file header is initialized
*/
- public function isFileHeaderInitialized () {
+ public function isFileHeaderInitialized (): bool {
// Default is not initialized
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: CALLED!');
$isInitialized = false;
* @return $isInitialized Whether the file's size is zero
* @throws UnexpectedValueException If an unexpected value was returned
*/
- public function isFileInitialized () {
+ public function isFileInitialized (): bool {
// Get it from iterator which holds the pointer instance. If false is returned
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: CALLED!');
$fileSize = $this->size();
* @return void
* @throws BadMethodCallException If this file's header is already initialized
*/
- public function createFileHeader () {
+ public function createFileHeader (): void {
// The file's header should not be initialized here
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: CALLED!');
if ($this->isFileHeaderInitialized()) {
*
* @return $seekPosition Current seek position
*/
- public function determineSeekPosition () {
+ public function determineSeekPosition (): int {
// Call pointer instance
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: CALLED!');
$seekPosition = $this->getPointerInstance()->determineSeekPosition();
*
* @return void
*/
- public function rewind () {
+ public function rewind (): void {
// Call pointer instance
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: CALLED!');
$this->getPointerInstance()->rewind();
* @return void
* @throws BadMethodCallException If this method is called but file is not initialized
*/
- public function analyzeFileStructure () {
+ public function analyzeFileStructure (): void {
// Make sure the file is initialized
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: CALLED!');
if (!$this->isFileInitialized()) {
* @return void
* @throws InvalidArgumentException If a parameter is not valid
*/
- protected function readNextBlockByLength (int $length) {
+ protected function readNextBlockByLength (int $length): void {
// Validate parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: this->seekPosition=%d,length=%d - CALLED!', $this->getSeekPosition(), $length));
if ($length < 1) {
* @return void
* @throws InvalidArgumentException If a parameter is empty
*/
- protected function preAllocateFileByTypeLength (string $type, int $minimumBlockLength) {
+ protected function preAllocateFileByTypeLength (string $type, int $minimumBlockLength): void {
// Is it enabled?
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: type=%s,minimumBlockLength=%d - CALLED!', $type, $minimumBlockLength));
if (empty($type)) {
* @return $isValid Whether the next entry is valid
* @throws InvalidArgumentException If a parameter is not valid
*/
- protected function isValidByLength (int $length) {
+ protected function isValidByLength (int $length): bool {
// Validate parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: length=%d - CALLED!', $length));
if ($length < 1) {
*
* @return void
*/
- protected abstract function readNextBlock ();
+ protected abstract function readNextBlock (): void;
/**
* Reads the file header
* @return void
* @throws LogicException If both instances are not set
*/
- public abstract function readFileHeader ();
+ public abstract function readFileHeader (): 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
*/
- public function searchNextGap (int $length) {
+ public function searchNextGap (int $length): int {
// If the file is only gaps, no need to seek
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: length=%d - CALLED!', $length));
if ($length <= 0) {
* @param $indexInstance An instance of a Indexable class
* @return $indexFileInstance An instance of an IndexableFile class
*/
- public final static function createIndexFile (SplFileInfo $fileInfoInstance, Indexable $indexInstance) {
+ public final static function createIndexFile (SplFileInfo $fileInfoInstance, Indexable $indexInstance): IndexableFile {
// Get a new instance
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('INDEX-FILE: fileInfoInstance[%s]=%s,indexInstance=%s - CALLED!', get_class($fileInfoInstance), $fileInfoInstance, $indexInstance->__toString()));
$indexFileInstance = new IndexFile();
* @return void
* @throws BadMethodCallException If this->indexInstance is not properly set
*/
- public function flushFileHeader () {
+ public function flushFileHeader (): void {
// Validate call
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('INDEX-FILE: CALLED!');
if (!($this->getIndexInstance() instanceof Indexable)) {
* @throws InvalidArgumentException If a parameter is empty
* @throws BadMethodCallException If this->indexInstance is not properly set
*/
- public function preAllocateFile (string $type) {
+ public function preAllocateFile (string $type): void {
// Is it enabled?
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('INDEX-FILE: type=%s - CALLED!', $type));
if (empty($type)) {
* @return $isValid Whether the next entry is valid
* @throws BadMethodCallException If this->indexInstance is not properly set
*/
- public function isValid () {
+ public function isValid (): bool {
// Validate call
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('INDEX-FILE: CALLED!');
if (!($this->getIndexInstance() instanceof Indexable)) {
*
* @return void
*/
- protected function readNextBlock () {
+ protected function readNextBlock (): void {
// First calculate minimum block length
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('INDEX-FILE: this->seekPosition=%d - CALLED!', $this->getSeekPosition()));
$length = $this->getIndexInstance()->calculateMinimumBlockLength();
*
* @return void
*/
- public function readFileHeader () {
+ public function readFileHeader (): void {
// Call index class' method
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('INDEX-FILE: Invoking this->indexInstance->readIndexHeader() - CALLED!');
$this->getIndexInstance()->readIndexHeader();
* @throws InvalidArgumentException If a parameter is not valid
* @throws BadMethodCallException If this->indexInstance is not properly set
*/
- public function writeValueToFile (string $stackName, $value) {
+ public function writeValueToFile (string $stackName, mixed $value): array {
// Validate parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('INDEX-FILE: stackName=%s,value[]=%s - CALLED!', $stackName, gettype($value)));
if (empty($stackName)) {
* @return $data Gap position and length of the raw data
* @throws UnsupportedOperationException If this method is called
*/
- public function writeDataToFreeGap (string $stackName, string $hash, string $encoded) {
+ public function writeDataToFreeGap (string $stackName, string $hash, string $encoded): array {
self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('INDEX-FILE: stackName=' . $stackName . ',hash=' . $hash . ',encoded()=' . strlen($encoded));
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @param $stackInstance An instance of a StackableFile class
* @return $stackFileInstance An instance of this File class
*/
- public final static function createStackFile (SplFileInfo $infoInstance, StackableFile $stackInstance) {
+ public final static function createStackFile (SplFileInfo $infoInstance, StackableFile $stackInstance): FileStacker {
// Get a new instance
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STACK-FILE: infoInstance[%s]=%s,stackInstance=%s - CALLED!', get_class($infoInstance), $infoInstance, $stackInstance->__toString()));
$stackFileInstance = new StackFile();
* @return void
* @throws BadMethodCallException If this->stackInstance is not properly set
*/
- public function flushFileHeader () {
+ public function flushFileHeader (): void {
// Validate call
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('STACK-FILE: CALLED!');
if (!($this->getStackInstance() instanceof StackableFIle)) {
* @throws InvalidArgumentException If a parameter is empty
* @throws BadMethodCallException If this->stackInstance is not properly set
*/
- public function preAllocateFile (string $type) {
+ public function preAllocateFile (string $type): void {
// Is it enabled?
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STACK-FILE: type=%s - CALLED!', $type));
if (empty($type)) {
* @return $isValid Whether the next entry is valid
* @throws BadMethodCallException If this->stackInstance is not properly set
*/
- public function isValid () {
+ public function isValid (): bool {
// Validate call
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('STACK-FILE: CALLED!');
if (!($this->getStackInstance() instanceof StackableFile)) {
* @return void
* @throws LogicException If both instances are not set
*/
- public function readFileHeader () {
+ public function readFileHeader (): void {
// Call stacke instance
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('STACK-FILE: Invoking this->stackInstance->readStackHeader() - CALLED!');
$this->getStackInstance()->readStackHeader();
*
* @return void
*/
- protected function readNextBlock () {
+ protected function readNextBlock (): void {
// First calculate minimum block length
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STACK-FILE: this->seekPosition=%d - CALLED!', $this->getSeekPosition()));
$length = $this->getStackInstance()->calculateMinimumBlockLength();
* @return $data Hash and gap position
* @throws InvalidArgumentException If a parameter is not valid
*/
- public function writeValueToFile (string $stackName, $value) {
+ public function writeValueToFile (string $stackName, mixed $value): array {
// Validate parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STACK-FILE: stackName=%s,value[]=%s - CALLED!', $stackName, gettype($value)));
if (empty($stackName)) {
* @return $data Gap position and length of the raw data
* @throws UnsupportedOperationException If this method is called
*/
- public function writeDataToFreeGap (string $stackName, string $hash, string $encoded) {
+ public function writeDataToFreeGap (string $stackName, string $hash, string $encoded): array {
self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('STACK-FILE: stackName=' . $stackName . ',hash=' . $hash . ',encoded()=' . strlen($encoded));
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
// Import SPL stuff
use \InvalidArgumentException;
+use \SplFileObject;
/**
* An abstract file class
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: EXIT!');
}
+ /**
+ * Destructor for cleaning purposes, etc
+ *
+ * @return void
+ */
+ public final function __destruct() {
+ // Try to close a file
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: DESTRUCTED!');
+ $this->closeFile();
+
+ // Call the parent destructor
+ parent::__destruct();
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: EXIT!');
+ }
+
/**
* Setter for FilePointer instance
*
* @param $pointerInstance An instance of an FilePointer class
* @return void
*/
- protected final function setPointerInstance (FilePointer $pointerInstance = NULL) {
+ protected final function setPointerInstance (FilePointer $pointerInstance = NULL): void {
$this->pointerInstance = $pointerInstance;
}
*
* @return $pointerInstance An instance of an FilePointer class
*/
- public final function getPointerInstance () {
+ public final function getPointerInstance (): FilePointer {
return $this->pointerInstance;
}
*
* @return void
*/
- protected final function unsetPointerInstance () {
+ protected final function unsetPointerInstance (): void {
// Simply invoke setter with no parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: CALLED!');
$this->setPointerInstance();
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: EXIT!');
}
- /**
- * Destructor for cleaning purposes, etc
- *
- * @return void
- */
- public final function __destruct() {
- // Try to close a file
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: DESTRUCTED!');
- $this->closeFile();
-
- // Call the parent destructor
- parent::__destruct();
-
- // Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: EXIT!');
- }
-
/**
* "Getter" for abstracted file size
*
* @return $fileSize Size of abstracted file
*/
- public function getFileSize () {
+ public function getFileSize (): int {
// Call pointer instanze
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: CALLED!');
return $this->getPointerInstance()->getFileSize();
*
* @return $totalEntries Total entries in this file
*/
- public final function getCounter () {
+ public final function getCounter (): int {
// Get it
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-ABSTRACT-FILE: Getting this->totalEntries=%d ... - CALLED!', $this->totalEntries));
return $this->totalEntries;
* @param $totalEntries Total entries in this file
* @return void
*/
- protected final function setCounter (int $counter) {
+ protected final function setCounter (int $counter): void {
// Set it
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-ABSTRACT-FILE: Setting this->totalEntries=%d ... - CALLED!', $counter));
$this->totalEntries = $counter;
*
* @return void
*/
- protected final function incrementCounter () {
+ protected final function incrementCounter (): void {
// Count up
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: CALLED!');
$this->totalEntries++;
*
* @return $fileObject An instance of a SplFileObject
*/
- public final function getFileObject () {
+ public final function getFileObject (): SplFileObject {
// Call pointer instanze
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: CALLED!');
return $this->getPointerInstance()->getFileObject();
/**
* Getter for file's name
+ *
+ * @return $fileName Name of file
*/
- public final function getFilename () {
+ public final function getFilename (): string {
// Invole file object's method
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: CALLED!');
return $this->getFileObject()->getFilename();
*
* @return void
*/
- public function closeFile () {
+ public function closeFile (): void {
// Close down pointer instance as well by unsetting it
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: CALLED!');
$this->unsetPointerInstance();
* @return $size Size (in bytes) of file
* @todo Handle seekStatus
*/
- public function size () {
+ public function size (): int {
// Call pointer instance
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: CALLED!');
return $this->getPointerInstance()->size();
* is not set by setFileObject()
* @throws InvalidResourceException If there is being set
*/
- public function readFromFile () {
+ public function readFromFile (): mixed {
// Call pointer instance
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: CALLED!');
return $this->getPointerInstance()->readFromFile();
* @throws InvalidResourceException If there is being set
* an invalid file resource
*/
- public function writeToFile (string $dataStream) {
+ public function writeToFile (string $dataStream): mixed {
// Check parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-ABSTRACT-FILE: dataStream()=%d - CALLED!', strlen($dataStream)));
if (empty($dataStream)) {
*
* @return $isEndOfFileReached Whether the EOF has been reached
*/
- public final function isEndOfFileReached () {
+ public final function isEndOfFileReached (): bool {
// Call pointer instance
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: CALLED!');
return $this->getPointerInstance()->isEndOfFileReached();
* @throws NullPointerException If the file pointer instance is not set by setFileObject()
* @throws LogicException If there is no object being set
*/
- public function closeFile () {
+ public function closeFile (): void {
// Validate parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FILE-IO: fileName=%s - CALLED!', $this->getFileObject()->getPathname()));
if (is_null($this->getFileObject())) {
*
* @return void
*/
- protected final function resetFileObject () {
+ protected final function resetFileObject (): void {
// Set it to NULL
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-FILE-IO: Setting this->fileObject=NULL - CALLED!');
$this->fileObject = NULL;
* @param $fileObject An instance of a SplFileObject class
* @return void
*/
- protected final function setFileObject (SplFileObject $fileObject) {
+ protected final function setFileObject (SplFileObject $fileObject): void {
$this->fileObject = $fileObject;
}
*
* @return $fileObject An instance of a SplFileObject class
*/
- public final function getFileObject () {
+ public final function getFileObject (): SplFileObject {
return $this->fileObject;
}
*
* @return $seekPosition Current seek position
*/
- public final function determineSeekPosition () {
+ public final function determineSeekPosition (): int {
return $this->getFileObject()->ftell();
}
*
* @return $isEndOfFileReached Whether the EOF has been reached
*/
- public final function isEndOfFileReached () {
+ public final function isEndOfFileReached (): bool {
return $this->getFileObject()->eof();
}
* @param $whence Added to offset (default: only use offset to seek to)
* @return $status Status of file seek: 0 = success, -1 = failed
*/
- 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-FILE-IO: offset=%d,whence=%d - CALLED!', $offset, $whence));
if ($offset < 0) {
* @return $size Size (in bytes) of file
* @todo Handle seekStatus
*/
- public function size () {
+ public function size (): int {
// Get current seek position
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-FILE-IO: CALLED!');
$seekPosition = $this->determineSeekPosition();
*
* @return mixed The result of fread()
*/
- public function readFromFile () {
+ public function readFromFile (): mixed {
// Read data from the file pointer and return it
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-INPUT-OUTPUT-POINTER: CALLED!');
$data = $this->read(1024);
* @param $dataStream The data stream we shall write to the file
* @return mixed Number of writes bytes or false on error
*/
- public function writeToFile (string $dataStream) {
+ public function writeToFile (string $dataStream): mixed {
// Validate parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-INPUT-OUTPUT-POINTER: dataStream(%d)=%s - CALLED!', strlen($dataStream), $dataStream));
if (empty($dataStream)) {
* @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('FILE-INPUT-OUTPUT-POINTER: seekPosition=%d,dataStream(%d)=%s - CALLED!', $seekPosition, strlen($dataStream), $dataStream));
if ($seekPosition < 0) {
* @return $status Status of this operation
* @throws OutOfBoundsException If the position is not seekable
*/
- public function seek (int $seekPosition, int $whence = SEEK_SET) {
+ public function seek (int $seekPosition, int $whence = SEEK_SET): int {
// Validate parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-INPUT-OUTPUT-POINTER: seekPosition=%d,whence=%d - CALLED!', $seekPosition, $whence));
if ($seekPosition < 0) {
*
* @return $ioInstance An instance of a FileIoStream class
*/
- public static final function createFileIoStream () {
+ public static final function createFileIoStream (): FileIoStream {
// Create new instance
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-IO-STREAM: CALLED!');
$ioInstance = new FileIoStream();
* @throws InvalidArgumentException If an invalid parameter was given
* @throws OutOfBoundsException If an expected array element wasn't found
*/
- public final function saveFile (SplFileInfo $fileInfoInstance, array $dataArray) {
+ public final function saveFile (SplFileInfo $fileInfoInstance, array $dataArray): void {
// Trace message
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-IO-STREAM: fileInfoInstance=%s,dataArray()=%d - CALLED!', $fileInfoInstance, count($dataArray)));
if (count($dataArray) < 2) {
* @return $array An array with the element 'header' and 'data'
* @see FileInputStreamer
*/
- public final function loadFileContents (SplFileInfo $infoInstance) {
+ public final function loadFileContents (SplFileInfo $infoInstance): array {
// Initialize some variables and arrays
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-IO-STREAM: infoInstance=%s - CALLED!', $infoInstance));
$inputBuffer = '';
* @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-STREAM: CALLED!');
DebugMiddleware::getSelfInstance()->partialStub();
* @param $whence Added to offset (default: only use offset to seek to)
* @return $status Status of file seek: 0 = success, -1 = failed
*/
- public function seek (int $offset, int $whence = SEEK_SET) {
+ public function seek (int $offset, int $whence = SEEK_SET): int {
// Check parameters
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-IO-STREAM: offset=%d,whence=%d - CALLED!', $offset, $whence));
if ($offset < 0) {
throw new InvalidArgumentException(sprintf('whence=%d is below zero', $whence), FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
+ // @TODO Partial stub
DebugMiddleware::getSelfInstance()->partialStub('offset=' . $offset . ',whence=' . $whence);
}
*
* @return $size Size (in bytes) of file
*/
- public function size () {
+ public function size (): int {
// Trace message
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-IO-STREAM: CALLED!');
DebugMiddleware::getSelfInstance()->partialStub();
*
* @return $seekPosition Current seek position
*/
- public function determineSeekPosition () {
+ public function determineSeekPosition (): int {
// Not possible in text files
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @param $whence Added to offset (default: only use offset to seek to)
* @return $status Status of file seek: 0 = success, -1 = failed
*/
- public function seek (int $offset, int $whence = SEEK_SET) {
+ public function seek (int $offset, int $whence = SEEK_SET): int {
// Not possible in text files
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEXT-FILE: offset=' . $offset . ',whence=' . $whence);
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
* @throws InvalidArrayCountException If an array has not the expected size
* @throws InvalidMD5ChecksumException If two MD5 hashes did not match
*/
- public function loadFileContents (SplFileInfo $infoInstance) {
+ public function loadFileContents (SplFileInfo $infoInstance): array {
/*
* This class (or its implementations) are special file readers/writers.
* There is no need to read/write the whole file.
* @return void
* @throws OutOfBoundsException If the position is not seekable
*/
- public function seek (int $seekPosition): void {
+ public function seek (int $seekPosition): seek {
// Validate parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('FILE-ITERATOR: seekPosition=%d,whence=%d - CALLED!', $seekPosition, $whence));
if ($seekPosition < 0) {
}
// Call file instance
- $this->getBinaryFileInstance()->seek($seekPosition);
-
- // Trace message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
+ return $this->getBinaryFileInstance()->seek($seekPosition);
}
}
* @return $status Status of file seek: 0 = success, -1 = failed
* @throws UnsupportedOperationException If this method is called
*/
- public function seek ($offset, $whence = SEEK_SET) {
+ public function seek ($offset, $whence = SEEK_SET): int {
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('OUTPUT: offset=' . $offset . ',whence=' . $whence);
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
*
* @return $debugInstance The prepared debug instance
*/
- public static final function createDebugConsoleOutput () {
+ public static final function createDebugConsoleOutput (): OutputStreamer {
// Get a new instance
$debugInstance = new DebugConsoleOutput();
* @param $stripTags Whether HTML tags shall be stripped out
* @return void
*/
- public final function outputStream (string $output, bool $stripTags = false) {
+ public final function outputStream (string $output, bool $stripTags = false): void {
// Strip HTML tags out?
if ($stripTags === true) {
// Prepare the output without HTML tags
* @param $stripTags Whether HTML tags shall be stripped out
* @return void
*/
- public final function output (string $outStream = '', bool $stripTags = false) {
+ public final function output (string $outStream = '', bool $stripTags = false): void {
// Empty output will be silently ignored
if (!empty($outStream)) {
$this->outputStream($outStream, $stripTags);
*
* @return $debugInstance The prepared debug instance
*/
- public static final function createDebugErrorLogOutput () {
+ public static final function createDebugErrorLogOutput (): OutputStreamer {
// Get a new instance
$debugInstance = new DebugErrorLogOutput();
* @param $stripTags Whether HTML tags shall be stripped out
* @return void
*/
- public final function outputStream (string $output, bool $stripTags = false) {
+ public final function outputStream (string $output, bool $stripTags = false): void {
// Split multiple lines into and array to put them out line-by-line
$errorLines = explode(chr(10), $output);
* @param $stripTags Whether HTML tags shall be stripped out
* @return void
*/
- public final function output (string $outStream = '', bool $stripTags = false) {
+ public final function output (string $outStream = '', bool $stripTags = false): void {
// Empty output will be silently ignored
if (!empty($outStream)) {
$this->outputStream($outStream);
*
* @return $debugInstance The prepared debug instance
*/
- public static final function createDebugWebOutput () {
+ public static final function createDebugWebOutput (): OutputStreamer {
// Get a new instance
$debugInstance = new DebugWebOutput();
* @param $stripTags Whether HTML tags shall be stripped out
* @return void
*/
- public final function outputStream (string $output, bool $stripTags = false) {
+ public final function outputStream (string $output, bool $stripTags = false): void {
// Strip out any <br />
$output = str_replace('<br />', '', $output);
printf('<!-- %s -->' . PHP_EOL, stripslashes($output));
* @param $stripTags Whether HTML tags shall be stripped out
* @return void
*/
- public final function output (string $outStream = '', bool $stripTags = false) {
+ public final function output (string $outStream = '', bool $stripTags = false): void {
// Empty output will be silently ignored
if (!empty($outStream)) {
$this->outputStream($outStream, $stripTags);
* @param $userInstance An instance of a user class
* @return $pointsInstance An instance of this class
*/
- public static final function createUserPoints (ManageableAccount $userInstance) {
+ public static final function createUserPoints (ManageableAccount $userInstance): BookablePoints {
// Get a new instance
$pointsInstance = new UserPoints();
* @param $amount Amount of points to store
* @return void
*/
- public final function setAmount (float $amount) {
- $this->amount = (float) $amount;
+ public final function setAmount (float $amount): void {
+ $this->amount = $amount;
}
/**
*
* @return $amount Amount of points to store
*/
- public final function getAmount () {
+ public final function getAmount (): float {
return $this->amount;
}
* @return $hasRequired Whether the user has the required points
* @todo Finish loading part of points
*/
- public function ifUserHasRequiredPoints (string $action) {
+ public function ifUserHasRequiredPoints (string $action): bool {
// Default is that everyone is poor... ;-)
$hasRequired = false;
* @param $amount Amount of points we shall book
* @return void
*/
- public function bookPointsDirectly (float $amount) {
+ public function bookPointsDirectly (float $amount): void {
// Rewind always
$this->getResultInstance()->rewind();
* @return void
* @todo $requestInstance is currently unused
*/
- public function addElementsToDataSet (StoreableCriteria $criteriaInstance) {
+ public function addElementsToDataSet (StoreableCriteria $criteriaInstance): void {
// Add user id
$criteriaInstance->addCriteria(UserPointsDatabaseFrontend::DB_COLUMN_POINTS_UID, $this->getUserInstance()->getUserId());
* @param $requestInstance An instance of a Requestable class
* @return $readerInstance An instance of this reader class
*/
- public static final function createConsoleNewsReader (Requestable $requestInstance) {
+ public static final function createConsoleNewsReader (Requestable $requestInstance): ReadableNews {
// Get a new instance
$readerInstance = new ConsoleNewsReader();
*
* @return void
*/
- public function initializeReader () {
+ public function initializeReader (): void {
// Get 'command' for saving some calls
$command = FrameworkBootstrap::getRequestInstance()->getRequestElement('command');
* @param $requestInstance An instance of a Requestable class
* @return $readerInstance An instance of this reader class
*/
- public static final function createDefaultNewsReader (Requestable $requestInstance) {
+ public static final function createDefaultNewsReader (Requestable $requestInstance): ReadableNews {
// Get a new instance
$readerInstance = new DefaultNewsReader();
*
* @return void
*/
- public function initializeReader () {
+ public function initializeReader (): void {
// Get 'command' for saving some calls
$command = FrameworkBootstrap::getRequestInstance()->getRequestElement('command');
*
* @return $registryInstance Instance of this class
*/
- public final static function getRegistry (string $key) {
+ public final static function getRegistry (string $key): Register {
// Is an instance there?
if (is_null(self::$registryInstances[$key])) {
// Not yet, so create one
*
* @return $instanceRegistry The whole generic registry array
*/
- public final function getGenericRegistry () {
+ public final function getGenericRegistry (): array {
return $this->getGenericSubArray('registry', 'generic');
}
* @return void
* @throws InvalidArgumentException If a paramter has an invalid value
*/
- public final function addEntry (string $key, $value) {
+ public final function addEntry (string $key, mixed $value): void {
// Check parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-REGISTRY: key=%s,value[]=%s - CALLED!', $key, gettype($value)));
if (empty($key)) {
* @return $entries An array with entries from this registry
* @throws InvalidArgumentException If a paramter has an invalid value
*/
- public final function getEntries (string $key = NULL) {
+ public final function getEntries (string $key = NULL): array {
// Check parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-REGISTRY: key[%s]=%s - CALLED!', gettype($key), $key));
if (!is_null($key) && empty($key)) {
* @throws InvalidArgumentException If a paramter has an invalid value
* @throws UnexpectedValueException If $value3 is not an array
*/
- public function getArrayFromKey (string $arrayKey, string $lookFor) {
+ public function getArrayFromKey (string $arrayKey, string $lookFor): array {
// Check parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-REGISTRY: arrayKey=%s,lookFor=%s - CALLED!', $arrayKey, $lookFor));
if (empty($arrayKey)) {
* @param $data An array with data
* @return $registryKey A registry key
*/
- public static function getRegistryKeyFromArray (string $prefix, array $data) {
+ public static function getRegistryKeyFromArray (string $prefix, array $data): string {
// Check parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-REGISTRY: prefix=%s,data()=%d - CALLED!', $prefix, count($data)));
if (empty($prefix)) {
*
* @return $registryInstance Instance of this class
*/
- public final static function getRegistry () {
+ public final static function getRegistry (): RegisterableFormatUpgrade {
// Is an instance there?
if (is_null(self::$registryInstance)) {
// Not yet, so create one
*
* @return $registryInstance Instance of this class
*/
- public final static function getRegistry () {
+ public final static function getRegistry (): RegisterableFormatUpgrade {
// Is an instance there?
if (is_null(self::$registryInstance)) {
// Not yet, so create one
* @return $registryInstance Instance of this class
* @throws InvalidArgumentException If a parameter has an invalid value
*/
- public static final function getRegistry (string $key) {
+ public static final function getRegistry (string $key): Register {
// Check parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('OBJECT-REGISTRY: key=%s - CALLED!', $key));
if (empty($key)) {
* @return $registryInstance Instance of this class
* @throws InvalidArgumentException If a parameter has an invalid value
*/
- public static final function getRegistry (string $key) {
+ public static final function getRegistry (string $key): ObjectRegister {
// Check parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('OBJECT-REGISTRY: key=%s - CALLED!', $key));
if (empty($key)) {
* @return $exists Whether the key exists in registry
* @throws InvalidArgumentException If a paramter has an invalid value
*/
- public function instanceExists (string $instanceKey) {
+ public function instanceExists (string $instanceKey): bool {
// Check parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('OBJECT-REGISTRY: instanceKey=%s - CALLED!', $instanceKey));
if (empty($instanceKey)) {
*
* @return $instanceRegistry The whole instance registry array
*/
- public final function getInstanceRegistry () {
+ public final function getInstanceRegistry (): array {
return $this->getGenericSubArray('registry', 'instance');
}
* @return void
* @throws InvalidArgumentException If a paramter has an invalid value
*/
- public function addInstance (string $instanceKey, Registerable $objectInstance) {
+ public function addInstance (string $instanceKey, Registerable $objectInstance): void {
// Check parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('OBJECT-REGISTRY: instanceKey=%s,objectInstance=%s - CALLED!', $instanceKey, $objectInstance->__toString()));
if (empty($instanceKey)) {
* @throws InvalidArgumentException If a paramter has an invalid value
* @throws NullPointerException If the requested key is not found
*/
- public function getInstance (string $instanceKey) {
+ public function getInstance (string $instanceKey): Registerable {
// Check parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('OBJECT-REGISTRY: instanceKey=%s - CALLED!', $instanceKey));
if (empty($instanceKey)) {
*
* @return $registryInstance An instance of this registry class
*/
- public static final function createSubRegistry () {
+ public static final function createSubRegistry (): Register {
// Just get a new instance ...
$registryInstance = new SubRegistry();
* @param $seekPosition Seek position in file
* @return void
*/
- public function seek ($seekPosition) {
+ public function seek ($seekPosition): int {
DebugMiddleware::getSelfInstance()->partialStub('seekPosition=' . $seekPosition);
}
* @throws UnexpectedValueException If header is not proper length
* @throws InvalidMagicException If a bad magic was found
*/
- public function readStackHeader () {
+ public function readStackHeader (): void {
// First rewind to beginning as the header sits at the beginning ...
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: CALLED!');
$this->getIteratorInstance()->rewind();
*
* @return void
*/
- public function flushFileHeader () {
+ public function flushFileHeader (): void {
// Put all informations together
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: CALLED!');
$header = sprintf('%s%s%s%s%s%s',
* @throws InvalidArgumentException If a parameter is invalid
* @todo Currently the stack file is not cached, please implement a memory-handling class and if enough RAM is found, cache the whole stack file.
*/
- protected function initFileStack (SplFileInfo $fileInfoInstance, string $type) {
+ protected function initFileStack (SplFileInfo $fileInfoInstance, string $type): void {
// Validate parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: fileInfoInstance[%s]=%s,type=%s - CALLED!', get_class($fileInfoInstance), $fileInfoInstance, $type));
if (empty($type)) {
* @throws InvalidArgumentException If a parameter is not valid
* @throws InvalidArgumentException Not all variable types are wanted here
*/
- protected function addValueToStack (string $stackerName, $value) {
+ protected function addValueToStack (string $stackerName, mixed $value): void {
// Validate parameter
/* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackerName=%s,value[]=%s - CALLED!', $stackerName, gettype($value)));
//* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackerName=%s,value[%s]=%s', $stackerName, gettype($value), print_r($value, true)));
* @throws InvalidArgumentException If a parameter is not valid
* @throws BadMethodCallException If the stack is empty
*/
- protected function getLastValue (string $stackerName) {
+ protected function getLastValue (string $stackerName): mixed {
// Validate parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackerName=%s - CALLED!', $stackerName));
if (empty($stackerName)) {
* @throws InvalidArgumentException If a parameter is not valid
* @throws BadMethodCallException If the stack is empty
*/
- protected function getFirstValue (string $stackerName) {
+ protected function getFirstValue (string $stackerName): mixed {
// Validate parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackerName=%s - CALLED!', $stackerName));
if (empty($stackerName)) {
* @throws InvalidArgumentException If a parameter is not valid
* @throws BadMethodCallException If the stack is empty
*/
- protected function popLast (string $stackerName) {
+ protected function popLast (string $stackerName): mixed {
// Validate parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackerName=%s - CALLED!', $stackerName));
if (empty($stackerName)) {
* @throws InvalidArgumentException If a parameter is not valid
* @throws BadMethodCallException If the named stacker is empty
*/
- protected function popFirst (string $stackerName) {
+ protected function popFirst (string $stackerName): mixed {
// Validate parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackerName=%s - CALLED!', $stackerName));
if (empty($stackerName)) {
* @return $isFull Whether the stack is full
* @throws InvalidArgumentException If a parameter is not valid
*/
- protected function isStackFull (string $stackerName) {
+ protected function isStackFull (string $stackerName): bool {
// Validate parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackerName=%s - CALLED!', $stackerName));
if (empty($stackerName)) {
* @throws InvalidArgumentException If a parameter is not valid
* @throws BadMethodCallException If given stack is missing
*/
- public function isStackEmpty (string $stackerName) {
+ public function isStackEmpty (string $stackerName): bool {
// Validate parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackerName=%s - CALLED!', $stackerName));
if (empty($stackerName)) {
* @return $isInitialized Whether the stack is initialized
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
- public function isStackInitialized (string $stackerName) {
+ public function isStackInitialized (string $stackerName): bool {
throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return $isEndOfFileReached Whether the EOF has been reached
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
- public function isEndOfFileReached () {
+ public function isEndOfFileReached (): bool {
throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @param $stackerName Name of the stack
* @return $count Size of stack (array count)
*/
- public function getStackCount (string $stackerName) {
+ public function getStackCount (string $stackerName): int {
// Now, simply return the found count value, this must be up-to-date then!
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackerName=%s - CALLED!', $stackerName));
$count = $this->getIteratorInstance()->getBinaryFileInstance()->getCounter();
*
* @return $length Minimum length for one entry/block
*/
- public function calculateMinimumBlockLength () {
+ public function calculateMinimumBlockLength (): int {
// Is the value "cached"?
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: CALLED!');
if (self::$minimumBlockLength == 0) {
* @return void
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
- public function initCountersGapsArray () {
+ public function initCountersGapsArray (): void {
throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return $totalEntries Size of file header
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
- public final function getHeaderSize () {
+ public final function getHeaderSize (): int {
throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return void
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
- public final function setHeaderSize (int $headerSize) {
+ public final function setHeaderSize (int $headerSize): void {
throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return $totalEntries Size of file header
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
- public final function getHeader () {
+ public final function getHeader (): array {
throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return void
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
- public final function setHeader (array $header) {
+ public final function setHeader (array $header): void {
throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return void
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
- public function updateSeekPosition () {
+ public function updateSeekPosition (): void {
throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return $totalEntries Total entries in this file
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
- public final function getCounter () {
+ public final function getCounter (): int {
throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return void
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
- public function writeData (int $seekPosition, string $data, bool $flushHeader = true) {
+ public function writeData (int $seekPosition, string $data, bool $flushHeader = true): void {
// Not supported
throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return mixed Number of writes bytes or false on error
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
- public function writeAtPosition (int $seekPosition, string $dataStream) {
+ public function writeAtPosition (int $seekPosition, string $dataStream): mixed {
// Not supported
throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return $data Hash and gap position
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
- public function writeValueToFile (string $stackName, $value) {
+ public function writeValueToFile (string $stackName, value $value): array {
throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return $seekPosition Found next gap's seek position
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
- public function searchNextGap (int $length) {
+ public function searchNextGap (int $length): int {
// Not supported here
throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
*
* @return $fileSize Size of currently loaded file
*/
- public function getFileSize () {
+ public function getFileSize (): int {
// Call iterator's method
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: CALLED!');
$size = $this->getIteratorInstance()->getBinaryFileInstance()->getFileSize();
* @return $data Gap position and length of the raw data
* @throws InvalidArgumentException If a parameter has an invalid value
*/
- public function writeDataToFreeGap (string $stackName, string $hash, string $encoded) {
+ public function writeDataToFreeGap (string $stackName, string $hash, string $encoded): array {
// Check parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackName=%s,hash{}=0x%s,encoded()=%d - CALLED!', $stackName, bin2hex($hash), strlen($encoded)));
if (empty($stackName)) {
* @return $status Status of this operation
* @throws OutOfBoundsException If the position is not seekable
*/
- public function seek (int $seekPosition, int $whence = SEEK_SET) {
+ public function seek (int $seekPosition, int $whence = SEEK_SET): int {
// Validate parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FIFO-FILE-STACK: seekPosition=%d,whence=%d - CALLED!', $seekPosition, $whence));
if ($seekPosition < 0) {
*
* @return $length Minimum length for one entry/block
*/
- function calculateMinimumBlockLength ();
+ function calculateMinimumBlockLength (): int;
}
* @param $stripTags Whether HTML tags shall be stripped out
* @return void
*/
- function outputStream (string $output, bool $stripTags = false);
+ function outputStream (string $output, bool $stripTags = false): void;
}
*
* @return void
*/
- function initExecutor (Stateable $stateInstance);
+ function initExecutor (Stateable $stateInstance): void;
}
*
* @return void
*/
- function readFileHeader ();
+ function readFileHeader (): void;
/**
* Flushes the file header
*
* @return void
*/
- function flushFileHeader ();
+ function flushFileHeader (): void;
/**
* Determines whether the EOF has been reached
*
* @return $isEndOfFileReached Whether the EOF has been reached
*/
- function isEndOfFileReached ();
+ function isEndOfFileReached (): bool;
/**
* Getter for header size
*
* @return $totalEntries Size of file header
*/
- function getHeaderSize ();
+ function getHeaderSize (): int;
/**
* Setter for header size
* @param $headerSize Size of file header
* @return void
*/
- function setHeaderSize (int $headerSize);
+ function setHeaderSize (int $headerSize): void;
/**
* Getter for header array
*
- * @return $totalEntries Size of file header
+ * @return $header An array with all headers
*/
- function getHeader ();
+ function getHeader (): array;
/**
* Setter for header
* @param $header Array for a file header
* @return void
*/
- function setHeader (array $header);
+ function setHeader (array $header): void;
/**
* Initializes counter for valid entries, arrays for damaged entries and
*
* @return void
*/
- function initCountersGapsArray ();
+ function initCountersGapsArray (): void;
/**
* Updates seekPosition attribute from file to avoid to much access on file.
*
* @return void
*/
- function updateSeekPosition ();
+ function updateSeekPosition (): void;
/**
* Getter for total entries
*
* @return $totalEntries Total entries in this file
*/
- function getCounter ();
+ function getCounter (): int;
/**
* "Getter" for file size
*
* @return $fileSize Size of currently loaded file
*/
- function getFileSize ();
+ function getFileSize (): int;
/**
* Checks whether the abstracted file only contains gaps by counting all
*
* @return $isGapsOnly Whether the abstracted file only contains gaps
*/
- function isFileGapsOnly();
+ function isFileGapsOnly(): bool;
/**
* Searches for next suitable gap the given length of data can fit in
* @param $length Length of raw data
* @return $seekPosition Found next gap's seek position
*/
- function searchNextGap (int $length);
+ function searchNextGap (int $length): int;
/**
* Writes given value to the file and returns a hash and gap position for it
* @param $value Value to be added to the stack
* @return $data Hash and gap position
*/
- function writeValueToFile (string $groupId, string $rawData);
+ function writeValueToFile (string $groupId, string $rawData): array;
/**
* Writes given raw data to the file and returns a gap position and length
* @param $encoded Encoded value to be written to the file
* @return $data Gap position and length of the raw data
*/
- function writeDataToFreeGap (string $groupId, string $hash, string $encoded);
+ function writeDataToFreeGap (string $groupId, string $hash, string $encoded): array;
/**
* Writes data at given position
* @param $flushHeader Whether to flush the header (default: flush)
* @return void
*/
- function writeData (int $seekPosition, string $data, bool $flushHeader = true);
+ function writeData (int $seekPosition, string $data, bool $flushHeader = true): void;
/**
* 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;
}
// Import framework stuff
use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
+// Import SPL stuff
+use \SplFileObject;
+
/**
* An interface for file pointers
*
*
* @return $fileObject An instance of a SplFileObject class
*/
- function getFileObject ();
+ function getFileObject (): SplFileObject;
/**
* Determines whether the EOF has been reached
*
* @return $isEndOfFileReached Whether the EOF has been reached
*/
- function isEndOfFileReached ();
+ function isEndOfFileReached (): bool;
}
* @return void
* @throws OutOfBoundsException If the position is not seekable
*/
- function seek (int $offset, int $whence = SEEK_SET);
+ function seek (int $offset, int $whence = SEEK_SET): int;
/**
* Size of file stack
* @param $seekPosition Seek position in file
* @return $status Status of this operation
*/
- function seek (int $seekPosition);
+ function seek (int $seekPosition): int;
/**
* Size of file stack
*
* @return $size Size (in bytes) of file
*/
- function size ();
+ function size (): int;
/**
* Reads the stack's file header
* @throws UnexpectedValueException If header is not proper length
* @throws InvalidMagicException If a bad magic was found
*/
- function readStackHeader ();
+ function readStackHeader (): void;
/**
* Flushes the file header
*
* @return void
*/
- function flushFileHeader ();
+ function flushFileHeader (): void;
/**
* Determines whether the EOF has been reached
* @return $isEndOfFileReached Whether the EOF has been reached
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
- function isEndOfFileReached ();
+ function isEndOfFileReached (): bool;
/**
* Calculates minimum length for one entry/block
*
* @return $length Minimum length for one entry/block
*/
- function calculateMinimumBlockLength ();
+ function calculateMinimumBlockLength (): int;
/**
* Initializes counter for valid entries, arrays for damaged entries and
* @return void
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
- function initCountersGapsArray ();
+ function initCountersGapsArray (): void;
/**
* Getter for header size
* @return $totalEntries Size of file header
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
- function getHeaderSize ();
+ function getHeaderSize (): int;
/**
* Setter for header size
* @return void
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
- function setHeaderSize (int $headerSize);
+ function setHeaderSize (int $headerSize): void;
/**
* Getter for header array
*
- * @return $totalEntries Size of file header
+ * @return $header Array with header lines
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
- function getHeader ();
+ function getHeader (): array;
/**
* Setter for header
* @return void
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
- function setHeader (array $header);
+ function setHeader (array $header): void;
/**
* Updates seekPosition attribute from file to avoid to much access on file.
* @return void
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
- function updateSeekPosition ();
+ function updateSeekPosition (): void;
/**
* Getter for total entries
* @return $totalEntries Total entries in this file
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
- function getCounter ();
+ function getCounter (): int;
/**
* Writes data at given position
* @return void
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
- function writeData (int $seekPosition, string $data, bool $flushHeader = true);
+ function writeData (int $seekPosition, string $data, bool $flushHeader = true): void;
/**
* Writes at given position by seeking to it.
* @return mixed Number of writes bytes or false on error
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
- function writeAtPosition (int $seekPosition, string $dataStream);
+ function writeAtPosition (int $seekPosition, string $dataStream): mixed;
/**
* Writes given value to the file and returns a hash and gap position for it
* @return $data Hash and gap position
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
- function writeValueToFile (string $groupId, $value);
+ function writeValueToFile (string $groupId, mixed $value): array;
/**
* Searches for next suitable gap the given length of data can fit in
* @return $seekPosition Found next gap's seek position
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
- function searchNextGap (int $length);
+ function searchNextGap (int $length): int;
/**
* "Getter" for file size
*
* @return $fileSize Size of currently loaded file
*/
- function getFileSize ();
+ function getFileSize (): int;
/**
* Writes given raw data to the file and returns a gap position and length
* @param $encoded Encoded value to be written to the file
* @return $data Gap position and length of the raw data
*/
- function writeDataToFreeGap (string $groupId, string $hash, string $encoded);
+ function writeDataToFreeGap (string $groupId, string $hash, string $encoded): array;
}
* @return void
* @throws InvalidArgumentException If a parameter has an invalid value
*/
- public function seek (int $offset, int $whence = SEEK_SET) {
+ public function seek (int $offset, int $whence = SEEK_SET): int {
// Check parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-IO-HANDLER: offset=%d,whence=%d - CALLED!', $offset, $whence));
if ($offset < 0) {
*
* @return $rngInstance An instance of a random number generator (RNG)
*/
- public final function getRngInstance () {
+ public final function getRngInstance (): RandomNumberGenerator {
return $this->rngInstance;
}
* @param $templateInstance An instance of a CompileableTemplate class
* @return void
*/
- public final function setTemplateInstance (CompileableTemplate $templateInstance) {
+ public final function setTemplateInstance (CompileableTemplate $templateInstance): void {
$this->templateInstance = $templateInstance;
}
* @param $visitorInstance An instance of a Visitor class
* @return void
*/
- protected final function setVisitorInstance (Visitor $visitorInstance) {
+ protected final function setVisitorInstance (Visitor $visitorInstance): void {
$this->visitorInstance = $visitorInstance;
}