Skip to content

Commit 02d72b0

Browse files
committed
Update PHP minimum version to 8.0 and dependencies to latest compatible version
1 parent d479cf4 commit 02d72b0

File tree

6 files changed

+7
-46
lines changed

6 files changed

+7
-46
lines changed

src/ParameterCollection.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@
4848

4949
namespace Platine\Route;
5050

51-
use InvalidArgumentException;
52-
5351
/**
5452
* @class ParameterCollection
5553
* @package Platine\Route
@@ -76,13 +74,6 @@ class ParameterCollection
7674
public function __construct(array $parameters = [])
7775
{
7876
foreach ($parameters as $parameter) {
79-
if (!$parameter instanceof ParameterInterface) {
80-
throw new InvalidArgumentException(sprintf(
81-
'The route parameter must be an instance of %s',
82-
ParameterInterface::class
83-
));
84-
}
85-
8677
$this->add($parameter);
8778
}
8879
}

src/Route.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
use Platine\Http\ServerRequestInterface;
5353
use Platine\Http\Uri;
5454
use Platine\Http\UriInterface;
55-
use Platine\Route\Exception\InvalidRouteParameterException;
5655

5756
/**
5857
* @class Route
@@ -152,19 +151,12 @@ public function __construct(
152151
$this->parameters = new ParameterCollection();
153152
$this->name = $name ?? '';
154153
$this->attributes = $attributes;
155-
156-
if(is_string($methods)){
154+
155+
if (is_string($methods)) {
157156
$methods = [$methods];
158157
}
159158

160159
foreach ($methods as $method) {
161-
if (!is_string($method)) {
162-
throw new InvalidRouteParameterException(sprintf(
163-
'Invalid request method [%s], must be a string',
164-
$method
165-
));
166-
}
167-
168160
$this->methods[] = strtoupper($method);
169161
}
170162
}

src/RouteCollection.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848

4949
namespace Platine\Route;
5050

51-
use InvalidArgumentException;
5251
use Platine\Route\Exception\RouteAlreadyExistsException;
5352
use Platine\Route\Exception\RouteNotFoundException;
5453

@@ -77,12 +76,6 @@ class RouteCollection implements RouteCollectionInterface
7776
public function __construct(array $routes = [])
7877
{
7978
foreach ($routes as $route) {
80-
if (!$route instanceof Route) {
81-
throw new InvalidArgumentException(sprintf(
82-
'Route must be an instance of [%s]',
83-
Route::class
84-
));
85-
}
8679
$this->add($route);
8780
}
8881
}

tests/ParameterCollectionTest.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
namespace Platine\Test\Route;
66

7+
use Platine\Dev\PlatineTestCase;
78
use Platine\Route\Parameter;
89
use Platine\Route\ParameterCollection;
9-
use Platine\Dev\PlatineTestCase;
1010

1111
/**
1212
* ParameterCollection class tests
@@ -16,12 +16,6 @@
1616
*/
1717
class ParameterCollectionTest extends PlatineTestCase
1818
{
19-
public function testConstructorOneValueIsNotInstanceOfParameter(): void
20-
{
21-
$this->expectException(\InvalidArgumentException::class);
22-
(new ParameterCollection(array('foo')));
23-
}
24-
2519
public function testConstructorParamContainsListOfParameter(): void
2620
{
2721
$name = 'foo';

tests/RouteCollectionTest.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
namespace Platine\Test\Route;
66

7+
use Platine\Dev\PlatineTestCase;
8+
use Platine\Route\Exception\RouteAlreadyExistsException;
9+
use Platine\Route\Exception\RouteNotFoundException;
710
use Platine\Route\Route;
811
use Platine\Route\RouteCollection;
9-
use Platine\Route\Exception\RouteNotFoundException;
10-
use Platine\Route\Exception\RouteAlreadyExistsException;
11-
use Platine\Dev\PlatineTestCase;
1212

1313
/**
1414
* RouteCollection class tests
@@ -27,10 +27,6 @@ public function testConstructor(): void
2727

2828
$c = new RouteCollection(array(new Route('pattern', 'handler', 'name')));
2929
$this->assertCount(1, $c->all());
30-
31-
//Value is not an instance of RouteCollectionInterface
32-
$this->expectException(\InvalidArgumentException::class);
33-
$c = new RouteCollection(array(new Route('pattern', 'handler', 'name'), 123));
3430
}
3531

3632
public function testAdd(): void

tests/RouteTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Platine\Dev\PlatineTestCase;
99
use Platine\Http\ServerRequest;
1010
use Platine\Http\Uri;
11-
use Platine\Route\Exception\InvalidRouteParameterException;
1211
use Platine\Route\Route;
1312

1413
/**
@@ -32,14 +31,10 @@ public function testConstructor(): void
3231
$this->assertNotEmpty($r2->getMethods());
3332
$this->assertContains('GET', $r2->getMethods());
3433
$this->assertContains('PUT', $r2->getMethods());
35-
34+
3635
$r3 = new Route('pattern', 'handler', 'name', 'GET');
3736
$this->assertNotEmpty($r3->getMethods());
3837
$this->assertContains('GET', $r3->getMethods());
39-
40-
//Invalid method
41-
$this->expectException(InvalidRouteParameterException::class);
42-
$r = new Route('pattern', 'handler', 'name', array('get', 'put', 34));
4338
}
4439

4540
public function testSetGetName(): void

0 commit comments

Comments
 (0)