Merge pull request #541 from skipperbent/v4-development

Version 4.3.2.3
This commit is contained in:
Simon Sessingø
2021-04-28 10:05:34 +02:00
committed by GitHub
4 changed files with 15 additions and 9 deletions
+6 -6
View File
@@ -165,7 +165,7 @@ class InputFile implements IInputItem
* @param string $name * @param string $name
* @return static * @return static
*/ */
public function setFilename($name): IInputItem public function setFilename(string $name): IInputItem
{ {
$this->filename = $name; $this->filename = $name;
@@ -188,7 +188,7 @@ class InputFile implements IInputItem
* @param string $destination * @param string $destination
* @return bool * @return bool
*/ */
public function move($destination): bool public function move(string $destination): bool
{ {
return move_uploaded_file($this->tmpName, $destination); return move_uploaded_file($this->tmpName, $destination);
} }
@@ -226,10 +226,10 @@ class InputFile implements IInputItem
/** /**
* Set error * Set error
* *
* @param int $error * @param int|null $error
* @return static * @return static
*/ */
public function setError($error): IInputItem public function setError(?int $error): IInputItem
{ {
$this->errors = (int)$error; $this->errors = (int)$error;
@@ -249,7 +249,7 @@ class InputFile implements IInputItem
* @param string $name * @param string $name
* @return static * @return static
*/ */
public function setTmpName($name): IInputItem public function setTmpName(string $name): IInputItem
{ {
$this->tmpName = $name; $this->tmpName = $name;
@@ -261,7 +261,7 @@ class InputFile implements IInputItem
return $this->getTmpName(); return $this->getTmpName();
} }
public function getValue() public function getValue(): string
{ {
return $this->getFilename(); return $this->getFilename();
} }
+1 -1
View File
@@ -147,7 +147,7 @@ class InputHandler
* @param array|null $original * @param array|null $original
* @return array * @return array
*/ */
protected function rearrangeFile(array $values, &$index, $original): array protected function rearrangeFile(array $values, array &$index, ?array $original): array
{ {
$originalIndex = $index[0]; $originalIndex = $index[0];
array_shift($index); array_shift($index);
@@ -55,7 +55,6 @@ abstract class LoadableRoute extends Route implements ILoadableRoute
public function matchRegex(Request $request, $url): ?bool public function matchRegex(Request $request, $url): ?bool
{ {
/* Match on custom defined regular expression */ /* Match on custom defined regular expression */
if ($this->regex === null) { if ($this->regex === null) {
return null; return null;
} }
+8 -1
View File
@@ -76,6 +76,11 @@ abstract class Route implements IRoute
if (is_callable($callback) === true) { if (is_callable($callback) === true) {
$router->debug('Executing callback'); $router->debug('Executing callback');
/* Load class from type hinting */
if (is_array($callback) === true && isset($callback[0], $callback[1]) === true) {
$callback[0] = $router->getClassLoader()->loadClass($callback[0]);
}
/* When the callback is a function */ /* When the callback is a function */
return $router->getClassLoader()->loadClosure($callback, $parameters); return $router->getClassLoader()->loadClosure($callback, $parameters);
} }
@@ -160,7 +165,7 @@ abstract class Route implements IRoute
foreach ((array)$parameters[1] as $name) { foreach ((array)$parameters[1] as $name) {
// Ignore parent parameters // Ignore parent parameters
if(isset($groupParameters[$name]) === true) { if (isset($groupParameters[$name]) === true) {
$lastParams[$name] = $matches[$name]; $lastParams[$name] = $matches[$name];
continue; continue;
} }
@@ -244,6 +249,7 @@ abstract class Route implements IRoute
$this->group = $group; $this->group = $group;
/* Add/merge parent settings with child */ /* Add/merge parent settings with child */
return $this->setSettings($group->toArray(), true); return $this->setSettings($group->toArray(), true);
} }
@@ -576,6 +582,7 @@ abstract class Route implements IRoute
public function setFilterEmptyParams(bool $enabled): IRoute public function setFilterEmptyParams(bool $enabled): IRoute
{ {
$this->filterEmptyParams = $enabled; $this->filterEmptyParams = $enabled;
return $this; return $this;
} }