generated from yiisoft/package-template
-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
651 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Yii debug API Change Log | ||
# Yii Debug API Change Log | ||
|
||
## 1.0.0 under development | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Yii\Debug\Api\Debug\Http; | ||
|
||
use Closure; | ||
use Yiisoft\Middleware\Dispatcher\MiddlewareDispatcher; | ||
use Yiisoft\Yii\Debug\Api\Debug\Middleware\MiddlewareDispatcherMiddleware; | ||
use Yiisoft\Yii\Http\Application; | ||
|
||
final readonly class HttpApplicationWrapper | ||
{ | ||
public function __construct( | ||
private MiddlewareDispatcher $middlewareDispatcher, | ||
private array $middlewareDefinitions, | ||
) { | ||
} | ||
|
||
public function wrap(Application $application): void | ||
Check failure on line 20 in src/Debug/Http/HttpApplicationWrapper.php GitHub Actions / psalm / PHP 8.1-ubuntu-latestUndefinedClass
Check failure on line 20 in src/Debug/Http/HttpApplicationWrapper.php GitHub Actions / psalm / PHP 8.2-ubuntu-latestUndefinedClass
Check failure on line 20 in src/Debug/Http/HttpApplicationWrapper.php GitHub Actions / psalm / PHP 8.3-ubuntu-latestUndefinedClass
|
||
{ | ||
$middlewareDispatcher = $this->middlewareDispatcher; | ||
$middlewareDefinitions = $this->middlewareDefinitions; | ||
|
||
$closure = Closure::bind(static function (Application $application) use ( | ||
$middlewareDispatcher, | ||
$middlewareDefinitions, | ||
) { | ||
$application->dispatcher = $middlewareDispatcher->withMiddlewares([ | ||
...$middlewareDefinitions, | ||
['class' => MiddlewareDispatcherMiddleware::class, '$middlewareDispatcher' => $application->dispatcher], | ||
]);; | ||
}, null, $application); | ||
|
||
$closure($application); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Yii\Debug\Api\Debug\Http; | ||
|
||
use Yiisoft\Router\RouteCollectorInterface; | ||
|
||
final class RouteCollectorWrapper | ||
{ | ||
public function __construct( | ||
private array $middlewareDefinitions, | ||
) { | ||
} | ||
|
||
public function wrap(RouteCollectorInterface $routeCollector): void | ||
{ | ||
$routeCollector->prependMiddleware(...$this->middlewareDefinitions); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Yii\Debug\Api\Debug\Middleware; | ||
|
||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Psr\Http\Server\MiddlewareInterface; | ||
use Psr\Http\Server\RequestHandlerInterface; | ||
use Yiisoft\Middleware\Dispatcher\MiddlewareDispatcher; | ||
|
||
final class MiddlewareDispatcherMiddleware implements MiddlewareInterface | ||
{ | ||
public function __construct( | ||
public MiddlewareDispatcher $middlewareDispatcher | ||
) { | ||
} | ||
|
||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface | ||
{ | ||
return $this->middlewareDispatcher->dispatch($request, $handler); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.