diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 30eeaeb..9624993 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,22 +7,26 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php_version: [7.3, 7.4, 8.0] + php_version: [7.4, 8.0, 8.1] composer_flags: ['', '--prefer-lowest'] steps: - uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php_version }} + extensions: xdebug + - uses: php-actions/composer@v5 with: php_version: ${{ matrix.php_version }} args: ${{ matrix.composer_flags }} command: update - - uses: php-actions/phpunit@v3 - with: - version: 8 - php_version: ${{ matrix.php_version }} - args: '--coverage-clover ./tests/logs/clover.xml' - php_extensions: xdebug + + - name: Run tests + run: ./vendor/bin/phpunit --coverage-clover ./tests/logs/clover.xml env: XDEBUG_MODE: coverage diff --git a/composer.json b/composer.json index 90c7a09..058ee55 100755 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ }, "require-dev": { "php-di/php-di": "^6.3.4", - "phpunit/phpunit": "^8.0", + "phpunit/phpunit": "^9.5", "php-coveralls/php-coveralls": "^2.4", "mockery/mockery": "^1.4.3", "squizlabs/php_codesniffer": "^3.6.0" diff --git a/src/RouteGroup.php b/src/RouteGroup.php index 4b192f2..54f3db5 100644 --- a/src/RouteGroup.php +++ b/src/RouteGroup.php @@ -34,7 +34,7 @@ public function __construct($params, $router) $this->middleware += $middleware; } - $this->prefix = trim($prefix, ' /'); + $this->prefix = is_string($prefix) ? trim($prefix, ' /') : null; $this->router = $router; } @@ -43,12 +43,12 @@ private function appendPrefixToUri(string $uri) return $this->prefix . '/' . ltrim($uri, '/'); } - public function map(array $verbs, string $uri, $callback) : Route + public function map(array $verbs, string $uri, $callback): Route { return $this->router->map($verbs, $this->appendPrefixToUri($uri), $callback)->middleware($this->middleware); } - public function group($params, $callback) : RouteGroup + public function group($params, $callback): RouteGroup { if (is_string($params)) { $params = $this->appendPrefixToUri($params); diff --git a/src/RouteParams.php b/src/RouteParams.php index 3a72cce..7c972bb 100644 --- a/src/RouteParams.php +++ b/src/RouteParams.php @@ -21,27 +21,32 @@ public function __get($key) return $this->params[$key]; } + #[\ReturnTypeWillChange] public function rewind() { $this->position = 0; } + #[\ReturnTypeWillChange] public function current() { return $this->params[$this->key()]; } + #[\ReturnTypeWillChange] public function key() { $keys = array_keys($this->params); return $keys[$this->position]; } + #[\ReturnTypeWillChange] public function next() { $this->position++; } + #[\ReturnTypeWillChange] public function valid() { return $this->position < count($this->params); diff --git a/src/Router.php b/src/Router.php index 8595a9c..11d8374 100644 --- a/src/Router.php +++ b/src/Router.php @@ -239,11 +239,11 @@ public function url(string $name, $params = []) try { return $this->altoRouter->generate($name, $params); } catch (\Exception $e) { - throw new NamedRouteNotFoundException($name, null); + throw new NamedRouteNotFoundException($name); } } - public function group($params, $callback) : Router + public function group($params, $callback): Router { $group = new RouteGroup($params, $this);