Development

- Better php7 support.
- Added easier way to debug router.
- Improvements and bugfixes.
- Updated documentation.
This commit is contained in:
Simon Sessingø
2018-03-26 23:43:27 +02:00
parent f23d569757
commit 085f98cf08
28 changed files with 847 additions and 233 deletions
+3 -3
View File
@@ -7,15 +7,15 @@ interface IInputItem
public function getIndex(): string;
public function setIndex($index): self;
public function setIndex(string $index): self;
public function getName(): string;
public function setName($name): self;
public function setName(string $name): self;
public function getValue(): string;
public function setValue($value): self;
public function setValue(string $value): self;
public function __toString();
+7 -7
View File
@@ -14,7 +14,7 @@ class InputFile implements IInputItem
public $errors;
public $tmpName;
public function __construct($index)
public function __construct(string $index)
{
$this->index = $index;
@@ -48,7 +48,7 @@ class InputFile implements IInputItem
];
return (new static($values['index']))
->setSize($values['size'])
->setSize((int)$values['size'])
->setError($values['error'])
->setType($values['type'])
->setTmpName($values['tmp_name'])
@@ -69,7 +69,7 @@ class InputFile implements IInputItem
* @param string $index
* @return static
*/
public function setIndex($index): IInputItem
public function setIndex(string $index): IInputItem
{
$this->index = $index;
@@ -89,7 +89,7 @@ class InputFile implements IInputItem
* @param int $size
* @return static
*/
public function setSize($size): IInputItem
public function setSize(int $size): IInputItem
{
$this->size = $size;
@@ -118,7 +118,7 @@ class InputFile implements IInputItem
* @param string $type
* @return static
*/
public function setType($type): IInputItem
public function setType(string $type): IInputItem
{
$this->type = $type;
@@ -152,7 +152,7 @@ class InputFile implements IInputItem
* @param string $name
* @return static
*/
public function setName($name): IInputItem
public function setName(string $name): IInputItem
{
$this->name = $name;
@@ -270,7 +270,7 @@ class InputFile implements IInputItem
* @param string $value
* @return static
*/
public function setValue($value): IInputItem
public function setValue(string $value): IInputItem
{
$this->filename = $value;
+13 -13
View File
@@ -42,7 +42,7 @@ class InputHandler
* Parse input values
*
*/
public function parseInputs() : void
public function parseInputs(): void
{
/* Parse get requests */
if (\count($_GET) !== 0) {
@@ -69,7 +69,7 @@ class InputHandler
/**
* @return array
*/
public function parseFiles() : array
public function parseFiles(): array
{
$list = [];
@@ -80,7 +80,7 @@ class InputHandler
$values['index'] = $key;
try {
$list[$key] = InputFile::createFromArray($values + $value);
} catch(InvalidArgumentException $e ){
} catch (InvalidArgumentException $e) {
}
continue;
@@ -101,7 +101,7 @@ class InputHandler
return $list;
}
protected function rearrangeFiles(array $values, &$index, $original) : array
protected function rearrangeFiles(array $values, &$index, $original): array
{
$originalIndex = $index[0];
@@ -132,7 +132,7 @@ class InputHandler
$output[$key] = $file;
continue;
} catch(InvalidArgumentException $e) {
} catch (InvalidArgumentException $e) {
}
}
@@ -152,7 +152,7 @@ class InputHandler
return $output;
}
protected function handleGetPost(array $array) : array
protected function handleGetPost(array $array): array
{
$list = [];
@@ -179,7 +179,7 @@ class InputHandler
* @param string|null $defaultValue
* @return InputItem|string
*/
public function findPost($index, $defaultValue = null)
public function findPost(string $index, ?string $defaultValue = null)
{
return $this->post[$index] ?? $defaultValue;
}
@@ -191,7 +191,7 @@ class InputHandler
* @param string|null $defaultValue
* @return InputFile|string
*/
public function findFile($index, $defaultValue = null)
public function findFile(string $index, ?string $defaultValue = null)
{
return $this->file[$index] ?? $defaultValue;
}
@@ -203,7 +203,7 @@ class InputHandler
* @param string|null $defaultValue
* @return InputItem|string
*/
public function findGet($index, $defaultValue = null)
public function findGet(string $index, ?string $defaultValue = null)
{
return $this->get[$index] ?? $defaultValue;
}
@@ -216,7 +216,7 @@ class InputHandler
* @param array|string|null $methods
* @return IInputItem|string
*/
public function getObject($index, $defaultValue = null, $methods = null)
public function getObject(string $index, ?string $defaultValue = null, $methods = null)
{
if ($methods !== null && \is_string($methods) === true) {
$methods = [$methods];
@@ -247,7 +247,7 @@ class InputHandler
* @param array|string|null $methods
* @return InputItem|string
*/
public function get($index, $defaultValue = null, $methods = null)
public function get(string $index, ?string $defaultValue = null, $methods = null)
{
$input = $this->getObject($index, $defaultValue, $methods);
@@ -264,7 +264,7 @@ class InputHandler
* @param string $index
* @return bool
*/
public function exists($index) : bool
public function exists(string $index): bool
{
return ($this->getObject($index) !== null);
}
@@ -274,7 +274,7 @@ class InputHandler
* @param array|null $filter Only take items in filter
* @return array
*/
public function all(array $filter = null) : array
public function all(array $filter = null): array
{
$output = $_GET + $_POST;
+6 -6
View File
@@ -8,7 +8,7 @@ class InputItem implements IInputItem
public $name;
public $value;
public function __construct($index, $value = null)
public function __construct(string $index, ?string $value = null)
{
$this->index = $index;
$this->value = $value;
@@ -25,7 +25,7 @@ class InputItem implements IInputItem
return $this->index;
}
public function setIndex($index): IInputItem
public function setIndex(string $index): IInputItem
{
$this->index = $index;
@@ -43,9 +43,9 @@ class InputItem implements IInputItem
/**
* Set input name
* @param string $name
* @return static $this
* @return static
*/
public function setName($name): IInputItem
public function setName(string $name): IInputItem
{
$this->name = $name;
@@ -63,9 +63,9 @@ class InputItem implements IInputItem
/**
* Set input value
* @param string $value
* @return static $this
* @return static
*/
public function setValue($value): IInputItem
public function setValue(string $value): IInputItem
{
$this->value = $value;