Skip to content

Commit

Permalink
Merge 3.x to master (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik authored Feb 18, 2025
1 parent 7b4d133 commit d8d4627
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 44 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/rector.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
on:
pull_request:
pull_request_target:
paths-ignore:
- 'docs/**'
- 'README.md'
Expand All @@ -17,6 +17,7 @@ jobs:
secrets:
token: ${{ secrets.YIISOFT_GITHUB_TOKEN }}
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
os: >-
['ubuntu-latest']
php: >-
Expand Down
41 changes: 11 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p align="center">
<a href="https://github.com/yiisoft" target="_blank">
<img src="https://yiisoft.github.io/docs/images/yii_logo.svg" height="100px">
<img src="https://yiisoft.github.io/docs/images/yii_logo.svg" height="100px" alt="Yii">
</a>
<h1 align="center">Yii Router</h1>
<br>
Expand All @@ -23,7 +23,7 @@ with an adapter package. Currently, the only adapter available is [FastRoute](ht

- URL matching and URL generation supporting HTTP methods, hosts, and defaults.
- Good IDE support for defining routes.
- Route groups with infinite nesting.
- Route groups with infinite nesting.
- Middleware support for both individual routes and groups.
- Ready to use middleware for route matching.
- Convenient `CurrentRoute` service that holds information about last matched route.
Expand All @@ -35,7 +35,7 @@ with an adapter package. Currently, the only adapter available is [FastRoute](ht

## Installation

The package could be installed with composer:
The package could be installed with [Composer](https://getcomposer.org):

```shell
composer require yiisoft/router
Expand Down Expand Up @@ -105,7 +105,7 @@ $response = $result->process($request, $notFoundHandler);
> features and, especially, pattern syntax may differ. To check usage and configuration details, please refer
> to specific adapter documentation. All examples in this document are for
> [FastRoute adapter](https://github.com/yiisoft/router-fastroute).
### Middleware usage

In order to simplify usage in PSR-middleware based application, there is a ready to use middleware provided:
Expand Down Expand Up @@ -187,7 +187,7 @@ Route::methods([Method::GET, Method::POST], '/page/add')
It is typically used for a certain actions that could be reused for multiple routes such as authentication.

If there is a need to either add middleware to be executed first or remove existing middleware from a route,
`prependMiddleware()` and `disableMiddleware()` could be used.
`prependMiddleware()` and `disableMiddleware()` could be used.

If you combine routes from multiple sources and want last route to have priority over existing ones, mark it as "override":

Expand Down Expand Up @@ -378,42 +378,23 @@ final class PostController

In addition to commonly used `getArgument()` method, the following methods are available:

- `getArguments()` - To obtain all arguments at once.
- `getArguments()` - To obtain all arguments at once.
- `getName()` - To get route name.
- `getHost()` - To get route host.
- `getPattern()` - To get route pattern.
- `getMethods()` - To get route methods.
- `getUri()` - To get current URI.

## Testing

### Unit testing

The package is tested with [PHPUnit](https://phpunit.de/). To run tests:

```shell
./vendor/bin/phpunit
```

### Mutation testing
## Documentation

The package tests are checked with [Infection](https://infection.github.io/) mutation framework. To run it:
- [Internals](docs/internals.md)

```shell
./vendor/bin/infection
```

### Static analysis

The code is statically analyzed with [Psalm](https://psalm.dev/). To run static analysis:

```shell
./vendor/bin/psalm
```
If you need help or have a question, the [Yii Forum](https://forum.yiiframework.com/c/yii-3-0/63) is a good place for that.
You may also check out other [Yii Community Resources](https://www.yiiframework.com/community).

## License

The Yii Dependency Injection is free software. It is released under the terms of the BSD License.
The Yii Router is free software. It is released under the terms of the BSD License.
Please see [`LICENSE`](./LICENSE.md) for more information.

Maintained by [Yii Software](https://www.yiiframework.com/).
Expand Down
18 changes: 14 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,22 @@
"license": "BSD-3-Clause",
"support": {
"issues": "https://github.com/yiisoft/router/issues?state=open",
"source": "https://github.com/yiisoft/router",
"forum": "https://www.yiiframework.com/forum/",
"wiki": "https://www.yiiframework.com/wiki/",
"irc": "irc://irc.freenode.net/yii",
"chat": "https://t.me/yii3en",
"source": "https://github.com/yiisoft/router"
"irc": "ircs://irc.libera.chat:6697/yii",
"chat": "https://t.me/yii3en"
},
"funding": [
{
"type": "opencollective",
"url": "https://opencollective.com/yiisoft"
},
{
"type": "github",
"url": "https://github.com/sponsors/yiisoft"
}
],
"require": {
"php": "^8.0",
"psr/event-dispatcher": "^1.0",
Expand All @@ -33,7 +43,7 @@
"nyholm/psr7": "^1.5",
"phpunit/phpunit": "^9.5",
"psr/container": "^1.1|^2.0",
"rector/rector": "^1.0",
"rector/rector": "^2.0",
"roave/infection-static-analysis-plugin": "^1.18",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30|^5.22",
Expand Down
44 changes: 44 additions & 0 deletions docs/internals.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Internals

## Unit testing

The package is tested with [PHPUnit](https://phpunit.de/). To run tests:

```shell
./vendor/bin/phpunit
```

## Mutation testing

The package tests are checked with [Infection](https://infection.github.io/) mutation framework with
[Infection Static Analysis Plugin](https://github.com/Roave/infection-static-analysis-plugin). To run it:

```shell
./vendor/bin/roave-infection-static-analysis-plugin
```

## Static analysis

The code is statically analyzed with [Psalm](https://psalm.dev/). To run static analysis:

```shell
./vendor/bin/psalm
```

## Code style

Use [Rector](https://github.com/rectorphp/rector) to make codebase follow some specific rules or
use either newest or any specific version of PHP:

```shell
./vendor/bin/rector
```

## Dependencies

This package uses [composer-require-checker](https://github.com/maglnet/ComposerRequireChecker) to check if all
dependencies are correctly defined in `composer.json`. To run the checker, execute the following command:

```shell
./vendor/bin/composer-require-checker
```
14 changes: 5 additions & 9 deletions tests/Debug/DebugRoutesCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
use Yiisoft\Router\Tests\Support\TestController;
use Yiisoft\Router\Tests\Support\TestMiddleware1;
use Yiisoft\Yii\Debug\Debugger;
use Yiisoft\Yii\Debug\DebuggerIdGenerator;
use Yiisoft\Yii\Debug\Storage\MemoryStorage;

/**
* @requires PHP >= 8.1
*/
final class DebugRoutesCommandTest extends TestCase
{
public function testBase(): void
{
$debuggerIdGenerator = new DebuggerIdGenerator();

$command = new DebugRoutesCommand(
new RouteCollection(
(new RouteCollector())->addRoute(
Expand All @@ -36,8 +36,7 @@ public function testBase(): void
),
),
new Debugger(
$debuggerIdGenerator,
new MemoryStorage($debuggerIdGenerator),
new MemoryStorage(),
[],
),
);
Expand All @@ -56,8 +55,6 @@ public function testBase(): void

public function testSpecificRoute(): void
{
$debuggerIdGenerator = new DebuggerIdGenerator();

$command = new DebugRoutesCommand(
new RouteCollection(
(new RouteCollector())->addRoute(
Expand All @@ -71,8 +68,7 @@ public function testSpecificRoute(): void
),
),
new Debugger(
$debuggerIdGenerator,
new MemoryStorage($debuggerIdGenerator),
new MemoryStorage(),
[],
),
);
Expand Down
3 changes: 3 additions & 0 deletions tests/Debug/RouterCollectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
use Yiisoft\Yii\Debug\Collector\CollectorInterface;
use Yiisoft\Yii\Debug\Tests\Shared\AbstractCollectorTestCase;

/**
* @requires PHP >= 8.1
*/
final class RouterCollectorTest extends AbstractCollectorTestCase
{
private MockObject|RouteCollectorInterface|null $routeCollector = null;
Expand Down
3 changes: 3 additions & 0 deletions tests/Debug/UrlMatcherInterfaceProxyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
use Yiisoft\Router\Tests\Support\UrlMatcherStub;
use Yiisoft\Test\Support\Container\SimpleContainer;

/**
* @requires PHP >= 8.1
*/
final class UrlMatcherInterfaceProxyTest extends TestCase
{
public function testBase(): void
Expand Down

0 comments on commit d8d4627

Please sign in to comment.