Skip to content

Commit e22ea70

Browse files
authored
Merge pull request #686 from skipperbent/v5-development
Version 5.4.0.0
2 parents 7feb464 + 4d1cadd commit e22ea70

File tree

4 files changed

+25
-32
lines changed

4 files changed

+25
-32
lines changed

README.md

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,6 +1742,7 @@ SimpleRouter::setCustomClassLoader(new MyCustomClassLoader());
17421742
php-di support was discontinued by version 4.3, however you can easily add it again by creating your own class-loader like the example below:
17431743

17441744
```php
1745+
use Pecee\SimpleRouter\ClassLoader\IClassLoader;
17451746
use Pecee\SimpleRouter\Exceptions\ClassNotFoundHttpException;
17461747

17471748
class MyCustomClassLoader implements IClassLoader
@@ -1762,51 +1763,38 @@ class MyCustomClassLoader implements IClassLoader
17621763
*
17631764
* @param string $class
17641765
* @return object
1765-
* @throws NotFoundHttpException
1766+
* @throws ClassNotFoundHttpException
17661767
*/
17671768
public function loadClass(string $class)
17681769
{
1769-
if (class_exists($class) === false) {
1770-
throw new NotFoundHttpException(sprintf('Class "%s" does not exist', $class), 404);
1770+
if ($this->container->has($class) === false) {
1771+
throw new ClassNotFoundHttpException($class, null, sprintf('Class "%s" does not exist', $class), 404, null);
17711772
}
1772-
1773-
try {
1774-
return $this->container->get($class);
1775-
} catch (\Exception $e) {
1776-
throw new NotFoundHttpException($e->getMessage(), (int)$e->getCode(), $e->getPrevious());
1777-
}
1773+
return $this->container->get($class);
17781774
}
17791775

17801776
/**
17811777
* Called when loading class method
17821778
* @param object $class
17831779
* @param string $method
17841780
* @param array $parameters
1785-
* @return object
1781+
* @return string
17861782
*/
17871783
public function loadClassMethod($class, string $method, array $parameters)
17881784
{
1789-
try {
1790-
return $this->container->call([$class, $method], $parameters);
1791-
} catch (\Exception $e) {
1792-
throw new NotFoundHttpException($e->getMessage(), (int)$e->getCode(), $e->getPrevious());
1793-
}
1785+
return (string)$this->container->call([$class, $method], $parameters);
17941786
}
17951787

17961788
/**
17971789
* Load closure
17981790
*
17991791
* @param Callable $closure
18001792
* @param array $parameters
1801-
* @return mixed
1793+
* @return string
18021794
*/
18031795
public function loadClosure(callable $closure, array $parameters)
18041796
{
1805-
try {
1806-
return $this->container->call($closure, $parameters);
1807-
} catch (\Exception $e) {
1808-
throw new NotFoundHttpException($e->getMessage(), (int)$e->getCode(), $e->getPrevious());
1809-
}
1797+
return (string)$this->container->call($closure, $parameters);
18101798
}
18111799
}
18121800
```

src/Pecee/Http/Input/InputHandler.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ public function parseInputs(): void
8282
if ($post !== false) {
8383
$this->originalPost += $post;
8484
}
85+
} else {
86+
parse_str($contents, $this->originalPost);
8587
}
8688
}
8789

@@ -108,7 +110,7 @@ public function parseFiles(array $files, ?string $parentKey = null): array
108110
foreach ($files as $key => $value) {
109111

110112
// Parse multi dept file array
111-
if(isset($value['name']) === false && is_array($value) === true) {
113+
if (isset($value['name']) === false && is_array($value) === true) {
112114
$list[$key] = $this->parseFiles($value, $key);
113115
continue;
114116
}
@@ -161,12 +163,12 @@ protected function rearrangeFile(array $values, array &$index, ?array $original)
161163
try {
162164

163165
$file = InputFile::createFromArray([
164-
'index' => ($key === '' && $originalIndex !== '') ? $originalIndex : $key,
165-
'name' => $original['name'][$key],
166-
'error' => $original['error'][$key],
166+
'index' => ($key === '' && $originalIndex !== '') ? $originalIndex : $key,
167+
'name' => $original['name'][$key],
168+
'error' => $original['error'][$key],
167169
'tmp_name' => $original['tmp_name'][$key],
168-
'type' => $original['type'][$key],
169-
'size' => $original['size'][$key],
170+
'type' => $original['type'][$key],
171+
'size' => $original['size'][$key],
170172
]);
171173

172174
if (isset($output[$key]) === true) {
@@ -231,7 +233,7 @@ public function find(string $index, ...$methods)
231233
{
232234
$element = null;
233235

234-
if(count($methods) > 0) {
236+
if (count($methods) > 0) {
235237
$methods = is_array(...$methods) ? array_values(...$methods) : $methods;
236238
}
237239

@@ -303,9 +305,9 @@ public function value(string $index, $defaultValue = null, ...$methods)
303305
public function exists($index, ...$methods): bool
304306
{
305307
// Check array
306-
if(is_array($index) === true) {
307-
foreach($index as $key) {
308-
if($this->value($key, null, ...$methods) === null) {
308+
if (is_array($index) === true) {
309+
foreach ($index as $key) {
310+
if ($this->value($key, null, ...$methods) === null) {
309311
return false;
310312
}
311313
}

src/Pecee/Http/Response.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public function httpCode(int $code): self
3232
*
3333
* @param string $url
3434
* @param ?int $httpCode
35+
*
36+
* @return never
3537
*/
3638
public function redirect(string $url, ?int $httpCode = null): void
3739
{
@@ -127,4 +129,4 @@ public function headers(array $headers): self
127129
return $this;
128130
}
129131

130-
}
132+
}

src/Pecee/SimpleRouter/Router.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ protected function handleException(Exception $e): ?string
562562

563563
if ($this->request->getRewriteRoute() !== null) {
564564
$this->processedRoutes[] = $this->request->getRewriteRoute();
565+
$this->request->setHasPendingRewrite(false);
565566
}
566567

567568
return $this->routeRequest();

0 commit comments

Comments
 (0)