Skip to content

Commit

Permalink
prepare release
Browse files Browse the repository at this point in the history
  • Loading branch information
spiralbot committed Dec 11, 2024
1 parent 4746714 commit b389300
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 181 deletions.
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@
"php": ">=8.1",
"ext-json": "*",
"ext-mbstring": "*",
"spiral/core": "^3.15",
"spiral/files": "^3.15",
"spiral/streams": "^3.15",
"spiral/telemetry": "^3.15",
"spiral/core": "^3.14.8",
"spiral/files": "^3.14.8",
"spiral/streams": "^3.14.8",
"spiral/telemetry": "^3.14.8",
"psr/http-message": "^1.0|^2.0",
"psr/http-factory": "^1.0",
"psr/http-server-middleware": "^1.0",
"psr/event-dispatcher": "^1.0"
},
"require-dev": {
"spiral/boot": "^3.15",
"spiral/boot": "^3.14.8",
"phpunit/phpunit": "^10.1",
"mockery/mockery": "^1.5",
"nyholm/psr7": "^1.5",
Expand Down
3 changes: 2 additions & 1 deletion src/CurrentRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Psr\Http\Message\ServerRequestInterface;
use Spiral\Core\Attribute\Scope;
use Spiral\Http\Exception\HttpException;

/**
* Provides access to the current request in the `http` scope.
Expand All @@ -16,7 +17,7 @@ final class CurrentRequest
{
private ?ServerRequestInterface $request = null;

public function set(?ServerRequestInterface $request): void
public function set(ServerRequestInterface $request): void
{
$this->request = $request;
}
Expand Down
24 changes: 5 additions & 19 deletions src/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,24 @@ final class Http implements RequestHandlerInterface
{
private ?RequestHandlerInterface $handler = null;
private readonly TracerFactoryInterface $tracerFactory;
private readonly Pipeline|LazyPipeline $pipeline;

public function __construct(
private readonly HttpConfig $config,
Pipeline|LazyPipeline $pipeline,
private readonly Pipeline $pipeline,
private readonly ResponseFactoryInterface $responseFactory,
private readonly ContainerInterface $container,
?TracerFactoryInterface $tracerFactory = null,
private readonly ?EventDispatcherInterface $dispatcher = null,
) {
if ($pipeline instanceof Pipeline) {
foreach ($this->config->getMiddleware() as $middleware) {
$pipeline->pushMiddleware($this->container->get($middleware));
}
} else {
$pipeline = $pipeline->withAddedMiddleware(
...$this->config->getMiddleware()
);
foreach ($this->config->getMiddleware() as $middleware) {
$this->pipeline->pushMiddleware($this->container->get($middleware));
}

$this->pipeline = $pipeline;
$scope = $this->container instanceof ScopeInterface ? $this->container : new Container();
$this->tracerFactory = $tracerFactory ?? new NullTracerFactory($scope);
}

/**
* @internal
*/
public function getPipeline(): Pipeline|LazyPipeline
public function getPipeline(): Pipeline
{
return $this->pipeline;
}
Expand Down Expand Up @@ -108,10 +97,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface
attributes: [
'http.method' => $request->getMethod(),
'http.url' => (string) $request->getUri(),
'http.headers' => \array_map(
static fn (array $values): string => \implode(',', $values),
$request->getHeaders(),
),
'http.headers' => $request->getHeaders(),
],
scoped: true,
traceKind: TraceKind::SERVER,
Expand Down
149 changes: 0 additions & 149 deletions src/LazyPipeline.php

This file was deleted.

3 changes: 1 addition & 2 deletions src/Pipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

/**
* Pipeline used to pass request and response thought the chain of middleware.
* @deprecated Will be removed in v4.0. Use {@see LazyPipeline} instead.
*/
final class Pipeline implements RequestHandlerInterface, MiddlewareInterface
{
Expand All @@ -32,7 +31,7 @@ final class Pipeline implements RequestHandlerInterface, MiddlewareInterface
private ?RequestHandlerInterface $handler = null;

public function __construct(
#[Proxy] ScopeInterface $scope,
#[Proxy] private readonly ScopeInterface $scope,
private readonly ?EventDispatcherInterface $dispatcher = null,
?TracerInterface $tracer = null
) {
Expand Down
6 changes: 3 additions & 3 deletions tests/Diactoros/UploadedFileFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ final class UploadedFileFactory implements UploadedFileFactoryInterface
*/
public function createUploadedFile(
StreamInterface $stream,
int $size = null,
?int $size = null,
int $error = \UPLOAD_ERR_OK,
string $clientFilename = null,
string $clientMediaType = null
?string $clientFilename = null,
?string $clientMediaType = null
): UploadedFileInterface {
if ($size === null) {
$size = $stream->getSize();
Expand Down
4 changes: 2 additions & 2 deletions tests/HttpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public function testTraceAttributesAreSet(): void
[
'http.method' => 'GET',
'http.url' => 'http://example.org/path',
'http.headers' => ['Host' => 'example.org', 'foo' => 'bar'],
'http.headers' => ['Host' => ['example.org'], 'foo' => ['bar']],
],
true,
TraceKind::SERVER,
Expand All @@ -293,7 +293,7 @@ function ($name, $callback, $attributes, $scoped, $traceKind) {
self::assertSame($attributes, [
'http.method' => 'GET',
'http.url' => 'http://example.org/path',
'http.headers' => ['Host' => 'example.org', 'foo' => 'bar'],
'http.headers' => ['Host' => ['example.org'], 'foo' => ['bar']],
]);
return $this->container
->get(TracerInterface::class)
Expand Down

0 comments on commit b389300

Please sign in to comment.