/**
* @return string The whole command of this call
*/
- public function getCommand()
+ public function getCommand(): string
{
return $this->command;
}
/**
* @return array All arguments of this call
*/
- public function getArgv()
+ public function getArgv(): array
{
return $this->argv;
}
/**
* @return string The used HTTP method
*/
- public function getMethod()
+ public function getMethod(): string
{
return $this->method;
}
/**
* @return int The count of arguments of this call
*/
- public function getArgc()
+ public function getArgc(): int
{
return $this->argc;
}
*
* @return bool if the argument position exists
*/
- public function has(int $position)
+ public function has(int $position): bool
{
return array_key_exists($position, $this->argv);
}
*
* @return Arguments The determined arguments
*/
- public function determine(array $server, array $get)
+ public function determine(array $server, array $get): Arguments
{
// removing leading / - maybe a nginx problem
$server['QUERY_STRING'] = ltrim($server['QUERY_STRING'] ?? '', '/');
*
* @return string
*/
- public function getHostname()
+ public function getHostname(): string
{
return $this->hostname;
}
*
* @return string
*/
- public function getScheme()
+ public function getScheme(): string
{
return $this->scheme;
}
*
* @return int
*/
- public function getSSLPolicy()
+ public function getSSLPolicy(): int
{
return $this->sslPolicy;
}
*
* @return string
*/
- public function getUrlPath()
+ public function getUrlPath(): string
{
return $this->urlPath;
}
*
* @return string
*/
- public function get($ssl = false)
+ public function get(bool $ssl = false): string
{
if ($this->sslPolicy === self::SSL_POLICY_SELFSIGN && $ssl) {
return Network::switchScheme($this->url);
* @param string? $urlPath
*
* @return bool true, if successful
+ * @TODO Find proper types
*/
- public function save($hostname = null, $sslPolicy = null, $urlPath = null)
+ public function save($hostname = null, $sslPolicy = null, $urlPath = null): bool
{
$currHostname = $this->hostname;
$currSSLPolicy = $this->sslPolicy;
/**
* Save the current url as base URL
*
- * @param $url
+ * @param string $url
*
* @return bool true, if the save was successful
*/
- public function saveByURL($url)
+ public function saveByURL(string $url): bool
{
$parsed = @parse_url($url);
*
* @return string The cleaned url
*/
- public function remove(string $origURL)
+ public function remove(string $origURL): string
{
// Remove the hostname from the url if it is an internal link
$nurl = Strings::normaliseLink($origURL);
*
* @throws HTTPException\InternalServerErrorException In Case the given URL is not relative to the Friendica node
*/
- public function redirect($toUrl = '', $ssl = false)
+ public function redirect(string $toUrl = '', bool $ssl = false)
{
if (!empty(parse_url($toUrl, PHP_URL_SCHEME))) {
throw new HTTPException\InternalServerErrorException("'$toUrl is not a relative path, please use System::externalRedirectTo");
/**
* Returns the base url as string
*/
- public function __toString()
+ public function __toString(): string
{
- return $this->get();
+ return (string) $this->get();
}
}
*
* @throws \Exception
*/
- public function determine(BasePath $basepath, Database $database, Cache $configCache)
+ public function determine(BasePath $basepath, Database $database, Cache $configCache): Mode
{
$mode = 0;
*
* @return Mode returns the determined mode
*/
- public function determineRunMode(bool $isBackend, array $server, Arguments $args, MobileDetect $mobileDetect)
+ public function determineRunMode(bool $isBackend, array $server, Arguments $args, MobileDetect $mobileDetect): Mode
{
foreach (self::BACKEND_CONTENT_TYPES as $type) {
if (strpos(strtolower($server['HTTP_ACCEPT'] ?? ''), $type) !== false) {
*
* @return bool returns true, if the mode is set
*/
- public function has($mode)
+ public function has(int $mode): bool
{
return ($this->mode & $mode) > 0;
}
*
* @return int Execution Mode
*/
- public function getExecutor()
+ public function getExecutor(): int
{
return $this->executor;
}
/**
* Install mode is when the local config file is missing or the DB schema hasn't been installed yet.
*
- * @return bool
+ * @return bool Whether installation mode is active (local/database configuration files present or not)
*/
- public function isInstall()
+ public function isInstall(): bool
{
return !$this->has(Mode::LOCALCONFIGPRESENT) ||
!$this->has(MODE::DBCONFIGAVAILABLE);
*
* @return bool
*/
- public function isNormal()
+ public function isNormal(): bool
{
return $this->has(Mode::LOCALCONFIGPRESENT) &&
$this->has(Mode::DBAVAILABLE) &&
*
* @return bool Is it a backend call
*/
- public function isBackend()
+ public function isBackend(): bool
{
return $this->isBackend;
}
*
* @return bool true if it was an AJAX request
*/
- public function isAjax()
+ public function isAjax(): bool
{
return $this->isAjax;
}
*
* @return bool true if it was an mobile request
*/
- public function isMobile()
+ public function isMobile(): bool
{
return $this->isMobile;
}
*
* @return bool true if it was an tablet request
*/
- public function isTablet()
+ public function isTablet(): bool
{
return $this->isTablet;
}
* @param string $media
* @see Page::initHead()
*/
- public function registerStylesheet($path, string $media = 'screen')
+ public function registerStylesheet(string $path, string $media = 'screen')
{
$path = Network::appendQueryParam($path, ['v' => FRIENDICA_VERSION]);
*
* Taken from http://webcheatsheet.com/php/get_current_page_url.php
*/
- private function curPageURL()
+ private function curPageURL(): string
{
$pageURL = 'http';
if (!empty($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] == "on")) {
*
* @throws HTTPException\InternalServerErrorException In case of invalid configs
*/
- public function loadRoutes(array $routes)
+ public function loadRoutes(array $routes): Router
{
$routeCollector = ($this->routeCollector ?? new RouteCollector(new Std(), new GroupCountBased()));
return $this;
}
+ /**
+ * Adds multiple routes to a route collector
+ *
+ * @param RouteCollector $routeCollector Route collector instance
+ * @param array $routes Multiple routes to be added
+ * @throws HTTPException\InternalServerErrorException If route was wrong (somehow)
+ */
private function addRoutes(RouteCollector $routeCollector, array $routes)
{
foreach ($routes as $route => $config) {
*
* @return bool
*/
- private function isRoute(array $config)
+ private function isRoute(array $config): bool
{
return
// The config array should at least have one entry
* @throws HTTPException\MethodNotAllowedException If a rule matched but the method didn't
* @throws HTTPException\NotFoundException If no rule matched
*/
- private function getModuleClass()
+ private function getModuleClass(): string
{
$cmd = $this->args->getCommand();
$cmd = '/' . ltrim($cmd, '/');