*
* @return $selfInstance An instance of this class
*/
- public static final function getSelfInstance () {
+ public static final function getSelfInstance (): ManageableApplication {
// Is the instance there?
if (is_null(self::getApplicationInstance())) {
// Then set it
*
* @return void
*/
- public function setupApplicationData () {
+ public function setupApplicationData (): void {
// Set all application data
$this->setAppName('Unit tests and more');
$this->setAppVersion('0.0.0');
*
* @return void
*/
- public function initApplication () {
+ public function initApplication (): void {
// Initialize output system
self::createDebugInstance('ApplicationHelper');
*
* @return void
*/
- public function launchApplication () {
+ public function launchApplication (): void {
// Get request/response instances
$requestInstance = FrameworkBootstrap::getRequestInstance();
$responseInstance = FrameworkBootstrap::getResponseInstance();
* @param $messageList An array of fatal messages
* @return void
*/
- public function handleFatalMessages (array $messageList) {
+ public function handleFatalMessages (array $messageList): void {
// Walk through all messages
foreach ($messageList as $message) {
exit(__METHOD__ . ':MSG:' . $message);
*
* @return $masterTemplateName Name of the master template
*/
- public function buildMasterTemplateName () {
+ public function buildMasterTemplateName (): string {
return 'tests_main';
}
* @return void
* @todo Nothing to add?
*/
- public function assignExtraTemplateData (CompileableTemplate $templateInstance) {
+ public function assignExtraTemplateData (CompileableTemplate $templateInstance): void {
DebugMiddleware::getSelfInstance()->partialStub('Unfinished method. templateInstance=' . $templateInstance->__toString());
}
*
* @return $configurationInstance An instance of a FrameworkConfiguration class
*/
- public static function getConfigurationInstance () {
+ public static function getConfigurationInstance (): FrameworkConfiguration {
// Is the instance there?
if (is_null(self::$configurationInstance)) {
// Init new instance
*
* @return $detectedApplicationName Detected name of application
*/
- public static function getDetectedApplicationName () {
+ public static function getDetectedApplicationName (): string {
return self::$detectedApplicationName;
}
*
* @return $detectedApplicationPath Detected full path of application
*/
- public static function getDetectedApplicationPath () {
+ public static function getDetectedApplicationPath (): string {
return self::$detectedApplicationPath;
}
*
* @return $requestType Analyzed request type
*/
- public static function getRequestTypeFromSystem () {
+ public static function getRequestTypeFromSystem (): string {
// Default is console
$requestType = 'console';
* @param $fileInstance An instance of a SplFileInfo class
* @return $isReachable Whether it is within open_basedir()
*/
- public static function isReachableFilePath (SplFileInfo $fileInstance) {
+ public static function isReachableFilePath (SplFileInfo $fileInstance): bool {
// Is not reachable by default
//* NOISY-DEBUG: */ printf('[%s:%d]: fileInstance=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, get_class($fileInstance));
$isReachable = false;
* @param $fileInstance An instance of a SplFileInfo class
* @return $isReadable Whether the file is readable (and therefor exists)
*/
- public static function isReadableFile (SplFileInfo $fileInstance) {
+ public static function isReadableFile (SplFileInfo $fileInstance): bool {
// Check if it is a file and readable
//* NOISY-DEBUG: */ printf('[%s:%d]: fileInstance=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, get_class($fileInstance));
$isReadable = (
* @return void
* @throws InvalidArgumentException If file was not found or not readable or deprecated
*/
- public static function loadInclude (SplFileInfo $fileInstance) {
+ public static function loadInclude (SplFileInfo $fileInstance): void {
// Should be there ...
//* NOISY-DEBUG: */ printf('[%s:%d]: fileInstance=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $fileInstance->__toString());
if (!self::isReadableFile($fileInstance)) {
*
* @return void
*/
- public static function doBootstrap () {
+ public static function doBootstrap (): void {
// Load basic include files to continue bootstrapping
//* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
self::loadInclude(new SplFileInfo(sprintf('%smain%sinterfaces%sclass_FrameworkInterface.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR)));
*
* @return void
*/
- public static function initFramework () {
+ public static function initFramework (): void {
/**
* 1) Load class loader and scan framework classes, interfaces and
* exceptions.
*
* @return void
*/
- public static function prepareApplication () {
+ public static function prepareApplication (): void {
/*
* Now check and load all files, found deprecated files will throw a
* warning at the user.
*
* @return void
*/
- public static function startApplication () {
+ public static function startApplication (): void {
// Is there an application helper instance?
//* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
$applicationInstance = call_user_func_array(
* @return void
* @throws BadMethodCallException If this method was invoked twice
*/
- public static function initDatabaseInstance () {
+ public static function initDatabaseInstance (): void {
// Get application instance
//* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
$applicationInstance = ApplicationHelper::getSelfInstance();
* @throws UnknownHostnameException If SERVER_NAME cannot be resolved to an IP address
* @todo Have to check some more entries from $_SERVER here
*/
- public static function detectServerAddress () {
+ public static function detectServerAddress (): string {
// Is the entry set?
//* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
if (!isset(self::$serverAddress)) {
* @return $success If timezone was accepted
* @throws InvalidArgumentException If $timezone is empty
*/
- public static function setDefaultTimezone (string $timezone) {
+ public static function setDefaultTimezone (string $timezone): bool {
// Is it set?
//* NOISY-DEBUG: */ printf('[%s:%d]: timezone=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $timezone);
if (empty($timezone)) {
* @return $isset Whether HTTPS is set
* @todo Test more fields
*/
- public static function isHttpSecured () {
+ public static function isHttpSecured (): bool {
//* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
return (
(
*
* @return $baseUrl Detected base URL
*/
- public static function detectBaseUrl () {
+ public static function detectBaseUrl (): string {
// Initialize the URL
//* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
$protocol = 'http';
*
* @return $fullDomain The detected full domain
*/
- public static function detectDomain () {
+ public static function detectDomain (): string {
// Full domain is localnet.invalid by default
//* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
$fullDomain = 'localnet.invalid';
*
* @return $scriptPath The script path extracted from $_SERVER['SCRIPT_NAME']
*/
- public static function detectScriptPath () {
+ public static function detectScriptPath (): string {
// Default is empty
//* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
$scriptPath = '';
*
* @return void
*/
- private static function scanFrameworkClasses () {
+ private static function scanFrameworkClasses (): void {
// Include class loader
//* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
require self::getConfigurationInstance()->getConfigEntry('framework_base_path') . 'loader/class_ClassLoader.php';
*
* @return void
*/
- private static function determineRequestType () {
+ private static function determineRequestType (): void {
// Determine request type
//* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
$request = self::getRequestTypeFromSystem();
*
* @return void
*/
- private static function validateApplicationParameter () {
+ private static function validateApplicationParameter (): void {
// Is the parameter set?
//* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
if (!self::getRequestInstance()->isRequestElementSet('app')) {
*
* @return $requestInstance An instance of a Requestable class
*/
- public static function getRequestInstance () {
+ public static function getRequestInstance (): Requestable {
return self::$requestInstance;
}
*
* @return $responseInstance An instance of a Responseable class
*/
- public static function getResponseInstance () {
+ public static function getResponseInstance (): Responseable {
return self::$responseInstance;
}
* @param $requestInstance An instance of a Requestable class
* @return void
*/
- private static function setRequestInstance (Requestable $requestInstance) {
+ private static function setRequestInstance (Requestable $requestInstance): void {
self::$requestInstance = $requestInstance;
}
* @param $responseInstance An instance of a Responseable class
* @return void
*/
- private static function setResponseInstance (Responseable $responseInstance) {
+ private static function setResponseInstance (Responseable $responseInstance): void {
self::$responseInstance = $responseInstance;
}
* @param $databaseInstance An instance of a DatabaseConnection class
* @return void
*/
- public static function setDatabaseInstance (DatabaseConnection $databaseInstance) {
+ public static function setDatabaseInstance (DatabaseConnection $databaseInstance): void {
self::$databaseInstance = $databaseInstance;
}
*
* @return $databaseInstance An instance of a DatabaseConnection class
*/
- public static function getDatabaseInstance () {
+ public static function getDatabaseInstance (): ?DatabaseConnection {
// Return instance
return self::$databaseInstance;
}
*
* @return $languageInstance An instance of a ManageableLanguage class
*/
- public static function getLanguageInstance () {
+ public static function getLanguageInstance (): ManageableLanguage {
return self::$languageInstance;
}
* @param $languageInstance An instance of a ManageableLanguage class
* @return void
*/
- public static function setLanguageInstance (ManageableLanguage $languageInstance) {
+ public static function setLanguageInstance (ManageableLanguage $languageInstance): void {
self::$languageInstance = $languageInstance;
}
*
* @return void
*/
- public static function scanFrameworkClasses () {
+ public static function scanFrameworkClasses (): void {
// Get loader instance
//* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
$loaderInstance = self::getSelfInstance();
* @return void
* @throws UnexpectedValueException If a given path isn't one or not readable
*/
- public static function scanApplicationClasses () {
+ public static function scanApplicationClasses (): void {
// Get loader instance
//* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
$loaderInstance = self::getSelfInstance();
* @param $strictNamingConvention Whether to strictly check naming-convention
* @return void
*/
- public static function enableStrictNamingConventionCheck (bool $strictNamingConvention = true) {
+ public static function enableStrictNamingConventionCheck (bool $strictNamingConvention = true): void {
self::$strictNamingConvention = $strictNamingConvention;
}
* @return void
* @throws InvalidArgumentException If the class' name does not contain a namespace: Tld\Domain\Project is AT LEAST recommended!
*/
- public static function autoLoad (string $className) {
+ public static function autoLoad (string $className): void {
// Validate parameter
//* NOISY-DEBUG: */ printf('[%s:%d] className=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $className);
if (empty($className)) {
*
* @return $selfInstance A singleton instance of this class
*/
- public static final function getSelfInstance () {
+ public static final function getSelfInstance (): ClassLoader {
// Is the instance there?
//* NOISY-DEBUG: */ printf('[%s:%d]: self::selfInstance[]=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, gettype(self::$selfInstance));
if (is_null(self::$selfInstance)) {
*
* @return $total Total loaded include files
*/
- public final function getTotal () {
+ public final function getTotal (): int {
return $this->total;
}
*
* @param $includeList A printable include list
*/
- public function getPrintableIncludeList () {
+ public function getPrintableIncludeList (): string {
// Prepare the list
$includeList = '';
foreach (array_keys($this->loadedClasses) as $classFile) {
* @return void
* @throws InvalidArgumentException If a parameter is invalid
*/
- protected function scanClassPath (string $basePath, array $ignoreList = [] ) {
+ protected function scanClassPath (string $basePath, array $ignoreList = [] ): void {
// Is a list has been restored from cache, don't read it again
//* NOISY-DEBUG: */ printf('[%s:%d] basePath=%s,ignoreList()=%d - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $basePath, count($ignoreList));
if (empty($basePath)) {
*
* @return void
*/
- private function initClassLoader () {
+ private function initClassLoader (): void {
// Set suffix and prefix from configuration
//* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
$this->suffix = self::$configInstance->getConfigEntry('class_suffix');
* @param $className The class that shall be loaded
* @return void
*/
- private function loadClassFile (string $className) {
+ private function loadClassFile (string $className): void {
// The class name should contain at least 2 back-slashes, so split at them
//* NOISY-DEBUG: */ printf('[%s:%d]: className=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $className);
$classNameParts = explode("\\", $className);
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class ???Action extends BaseAction implements Commandable {
+class ???Action extends BaseAction implements PerformableAction {
/**
* Protected constructor
*
/**
* Creates an instance of this action
*
- * @return $actionInstance An instance of this action class
+ * @return $actionInstance An instance of a PerformableAction class
*/
- public final static function create???Action () {
+ public final static function create???Action (): PerformableAction {
// Get a new instance
$actionInstance = new ???Action();
* @return void
* @todo 0% done
*/
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ public function execute (Requestable $requestInstance, Responseable $responseInstance): void {
DebugMiddleware::getSelfInstance()->partialStub("You have to implement me.");
}
*
* @return $applicationInstance An instance of a ManageableApplication class
*/
- public static final function getApplicationInstance () {
+ public static final function getApplicationInstance (): ?ManageableApplication {
return self::$applicationInstance;
}
*
* @param $applicationInstance An instance of a ManageableApplication class
*/
- public static final function setApplicationInstance (ManageableApplication $applicationInstance) {
+ public static final function setApplicationInstance (ManageableApplication $applicationInstance): void {
self::$applicationInstance = $applicationInstance;
}
* @param $controllerInstance An instance of the controller
* @return void
*/
- public final function setControllerInstance (Controller $controllerInstance) {
+ public final function setControllerInstance (Controller $controllerInstance): void {
$this->controllerInstance = $controllerInstance;
}
*
* @return $controllerInstance An instance of the controller
*/
- public final function getControllerInstance () {
+ public final function getControllerInstance (): Controller {
return $this->controllerInstance;
}
*
* @return $appVersion The application's version number
*/
- public final function getAppVersion () {
+ public final function getAppVersion (): string {
return $this->appVersion;
}
* @param $appVersion The application's version number
* @return void
*/
- public final function setAppVersion (string $appVersion) {
+ public final function setAppVersion (string $appVersion): void {
// Cast and set it
$this->appVersion = $appVersion;
}
*
* @return $appName The application's human-readable name
*/
- public final function getAppName () {
+ public final function getAppName (): string {
return $this->appName;
}
* @param $appName The application's human-readable name
* @return void
*/
- public final function setAppName (string $appName) {
+ public final function setAppName (string $appName): void {
// Cast and set it
$this->appName = $appName;;
}
*
* @return $shortName The application's short uni*-like name
*/
- public final function getAppShortName () {
+ public final function getAppShortName (): string {
return $this->shortName;
}
* @param $shortName The application's short uni*-like name
* @return void
*/
- public final function setAppShortName (string $shortName) {
+ public final function setAppShortName (string $shortName): void {
// Cast and set it
$this->shortName = $shortName;
}
* @args $args Arguments passed to the method
* @return void
*/
- public final function __call (string $methodName, array $args = NULL) {
+ public final function __call (string $methodName, array $args = NULL): void {
// Set self-instance
self::$selfInstance = $this;
* @return void
* @throws InvalidArgumentException If self::$selfInstance is not a framework's own object
*/
- public static final function __callStatic (string $methodName, array $args = NULL) {
+ public static final function __callStatic (string $methodName, array $args = NULL): void {
// Init argument string and class name
//* PRINT-DEBUG: */ printf('[%s:%d]: methodName=%s,args[]=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $methodName, gettype($args));
$argsString = '';
));
// Return nothing
- return NULL;
+ return;
}
/**
/**
* Magic method to catch object serialization
*
- * @return $unsupported Unsupported method
+ * @return array
* @throws UnsupportedOperationException Objects of this framework cannot be serialized
*/
- public final function __sleep () {
+ public final function __sleep (): array {
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* Magic method to catch object deserialization
*
- * @return $unsupported Unsupported method
+ * @return void
* @throws UnsupportedOperationException Objects of this framework cannot be serialized
*/
- public final function __wakeup () {
+ public final function __wakeup (): void {
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* Magic method to catch calls when an object instance is called
*
- * @return $unsupported Unsupported method
+ * @return void
* @throws UnsupportedOperationException Objects of this framework cannot be serialized
*/
- public final function __invoke () {
+ public final function __invoke (): void {
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
*
* @return $clientInstance An instance of a Client class
*/
- public final static function create???Client () {
+ public final static function create???Client (): Client {
// Get a new instance
$clientInstance = new ???Client();
* @param $socketResource An instance of a Socket class
* @return $clientInstance An instance of a HttpClient class
*/
- public final static function createHttpClient (Socket $socketResouce = NULL) {
+ public final static function createHttpClient (Socket $socketResouce = NULL): Client {
// Get a new instance
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HTTP-CLIENT: socketResource[%s]=%s - CALLED!', gettype($socketResource), $socketResource));
$clientInstance = new HttpClient();
*
* @return $isUsed Wether proxy is used
*/
- protected function isProxyUsed () {
+ protected function isProxyUsed (): bool {
// Do we have cache?
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HTTP-CLIENT: CALLED!');
if (!isset($GLOBALS[__METHOD__])) {
* @throws InvalidArgumentException If a paramter has an invalid value
* @throws UnexpectedValueException If an unexpected value was found
*/
- protected function setupProxyTunnel (string $host, int $port) {
+ protected function setupProxyTunnel (string $host, int $port): array {
// Check paramters
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HTTP-CLIENT: host=%s,port=%d - CALLED!', $host, $port));
if (empty($host)) {
* @param $port Port number to connect to
* @return $responseArray Array with raw response
*/
- private function sendRawHttpRequest (string $method, string $host, int $port, array $header = []) {
+ private function sendRawHttpRequest (string $method, string $host, int $port, array $header = []): array {
// Minimum raw HTTP/1.1 request
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HTTP-CLIENT: method=%s,host=%s,port=%d,header()=%d - CALLED!', $method, $host, $port, count($header)));
$rawRequest = $method . ' ' . $host . ':' . $port . ' HTTP/1.1' . self::HTTP_EOL;
* @return $responseArray An array with the read response
* @throws InvalidArgumentException If a paramter has an invalid value
*/
- public function doConnectRequest (string $host, int $port) {
+ public function doConnectRequest (string $host, int $port): array {
// Check paramters
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HTTP-CLIENT: host=%s,port=%d - CALLED!', $host, $port));
if (empty($host)) {
*
* @return $appVersion The application's version number
*/
- function getAppVersion ();
+ function getAppVersion (): string;
/**
* Setter for the version number
* @param $appVersion The application's version number
* @return void
*/
- function setAppVersion (string $appVersion);
+ function setAppVersion (string $appVersion): void;
/**
* Getter for human-readable name
*
* @return $appName The application's human-readable name
*/
- function getAppName ();
+ function getAppName (): string;
/**
* Setter for human-readable name
* @param $appName The application's human-readable name
* @return void
*/
- function setAppName (string $appName);
+ function setAppName (string $appName): void;
/**
* Getter for short uni*-like name
*
* @return $shortName The application's short uni*-like name
*/
- function getAppShortName ();
+ function getAppShortName (): string;
/**
* Setter for short uni*-like name
* @param $shortName The application's short uni*-like name
* @return void
*/
- function setAppShortName (string $shortName);
+ function setAppShortName (string $shortName): void;
/**
* 1) Setups application data
*
* @return void
*/
- function setupApplicationData ();
+ function setupApplicationData (): void;
/**
* 2) Does initial stuff before starting the application
*
* @return void
*/
- function initApplication ();
+ function initApplication (): void;
/**
* 3) Launches the application
*
* @return void
*/
- function launchApplication ();
+ function launchApplication (): void;
/**
* Handle the indexed array of fatal messages and puts them out in an
* @param $messageList An array of fatal messages
* @return void
*/
- function handleFatalMessages (array $messageList);
+ function handleFatalMessages (array $messageList): void;
/**
* Builds the master template's name
*
* @return $masterTemplateName Name of the master template
*/
- function buildMasterTemplateName ();
+ function buildMasterTemplateName (): string;
/**
* Assigns extra application-depending data
* @return void
* @todo Nothing to add?
*/
- function assignExtraTemplateData (CompileableTemplate $templateInstance);
+ function assignExtraTemplateData (CompileableTemplate $templateInstance): void;
}