Commit 8d9f1fff authored by Tino Goratsch's avatar Tino Goratsch

add some type hinting

parent 656d8c61
...@@ -39,13 +39,13 @@ class Router implements RouterInterface ...@@ -39,13 +39,13 @@ class Router implements RouterInterface
* @param RequestInterface $request * @param RequestInterface $request
* @param ApplicationPath $appPath * @param ApplicationPath $appPath
* @param SettingsInterface $config * @param SettingsInterface $config
* @param $environment * @param string $environment
*/ */
public function __construct( public function __construct(
RequestInterface $request, RequestInterface $request,
ApplicationPath $appPath, ApplicationPath $appPath,
SettingsInterface $config, SettingsInterface $config,
$environment string $environment
) { ) {
$this->request = $request; $this->request = $request;
$this->appPath = $appPath; $this->appPath = $appPath;
...@@ -74,7 +74,7 @@ class Router implements RouterInterface ...@@ -74,7 +74,7 @@ class Router implements RouterInterface
* *
* @return string * @return string
*/ */
protected function preparePath($path) protected function preparePath(string $path): string
{ {
$path = $path . (!\preg_match('/\/$/', $path) ? '/' : ''); $path = $path . (!\preg_match('/\/$/', $path) ? '/' : '');
if ($path === 'acp/') { if ($path === 'acp/') {
...@@ -94,7 +94,7 @@ class Router implements RouterInterface ...@@ -94,7 +94,7 @@ class Router implements RouterInterface
* *
* @return string * @return string
*/ */
protected function addControllerAndAction($path) protected function addControllerAndAction(string $path): string
{ {
$pathArray = \preg_split('=/=', $path, -1, PREG_SPLIT_NO_EMPTY); $pathArray = \preg_split('=/=', $path, -1, PREG_SPLIT_NO_EMPTY);
$indexes = ($this->isAdminUri($path) === true) ? [2, 3] : [1, 2]; $indexes = ($this->isAdminUri($path) === true) ? [2, 3] : [1, 2];
...@@ -113,19 +113,19 @@ class Router implements RouterInterface ...@@ -113,19 +113,19 @@ class Router implements RouterInterface
* *
* @return bool * @return bool
*/ */
protected function isAdminUri($path) protected function isAdminUri(string $path): bool
{ {
return \preg_match(self::ADMIN_PANEL_PATTERN, $path) != false; return \preg_match(self::ADMIN_PANEL_PATTERN, $path) != false;
} }
/** /**
* @param string $path * @param string $path
* @param bool $isAbsolute * @param bool $isAbsolute
* @param bool $isSecure * @param bool|null $isSecure
* *
* @return string * @return string
*/ */
protected function addUriPrefix($path, $isAbsolute, $isSecure) protected function addUriPrefix(string $path, bool $isAbsolute, ?bool $isSecure): string
{ {
$prefix = ''; $prefix = '';
if ($isAbsolute === true || $isSecure !== null) { if ($isAbsolute === true || $isSecure !== null) {
...@@ -143,7 +143,7 @@ class Router implements RouterInterface ...@@ -143,7 +143,7 @@ class Router implements RouterInterface
* *
* @return string * @return string
*/ */
private function getScheme($isSecure) private function getScheme(?bool $isSecure): string
{ {
if ($isSecure === null) { if ($isSecure === null) {
return $this->request->getScheme() . '://'; return $this->request->getScheme() . '://';
...@@ -161,7 +161,7 @@ class Router implements RouterInterface ...@@ -161,7 +161,7 @@ class Router implements RouterInterface
* *
* @return bool * @return bool
*/ */
protected function useModRewrite($path) protected function useModRewrite(string $path): bool
{ {
return (bool) $this->config->getSettings(System\Installer\Schema::MODULE_NAME)['mod_rewrite'] === true && return (bool) $this->config->getSettings(System\Installer\Schema::MODULE_NAME)['mod_rewrite'] === true &&
$this->isAdminUri($path) === false; $this->isAdminUri($path) === false;
......
...@@ -45,7 +45,7 @@ class Aliases ...@@ -45,7 +45,7 @@ class Aliases
* *
* @return string * @return string
*/ */
public function getUriAlias($path, $emptyOnNoResult = false) public function getUriAlias(string $path, bool $emptyOnNoResult = false): string
{ {
if ($this->isActive === false) { if ($this->isActive === false) {
return $path; return $path;
...@@ -57,9 +57,7 @@ class Aliases ...@@ -57,9 +57,7 @@ class Aliases
$path .= !\preg_match('/\/$/', $path) ? '/' : ''; $path .= !\preg_match('/\/$/', $path) ? '/' : '';
return !empty($this->aliasesCache[$path]['alias']) return $this->aliasesCache[$path]['alias'] ?? ($emptyOnNoResult === true ? '' : $path);
? $this->aliasesCache[$path]['alias']
: ($emptyOnNoResult === true ? '' : $path);
} }
/** /**
...@@ -69,7 +67,7 @@ class Aliases ...@@ -69,7 +67,7 @@ class Aliases
* *
* @return bool * @return bool
*/ */
public function uriAliasExists($path) public function uriAliasExists(string $path): bool
{ {
return $this->getUriAlias($path, true) !== ''; return $this->getUriAlias($path, true) !== '';
} }
......
...@@ -30,7 +30,7 @@ class Router extends \ACP3\Core\Router\Router ...@@ -30,7 +30,7 @@ class Router extends \ACP3\Core\Router\Router
RequestInterface $request, RequestInterface $request,
ApplicationPath $appPath, ApplicationPath $appPath,
SettingsInterface $config, SettingsInterface $config,
$environment string $environment
) { ) {
parent::__construct($request, $appPath, $config, $environment); parent::__construct($request, $appPath, $config, $environment);
...@@ -42,7 +42,7 @@ class Router extends \ACP3\Core\Router\Router ...@@ -42,7 +42,7 @@ class Router extends \ACP3\Core\Router\Router
* *
* @return string * @return string
*/ */
protected function preparePath($path) protected function preparePath(string $path): string
{ {
$path = parent::preparePath($path); $path = parent::preparePath($path);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment