Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rector improve #216

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
(new PhpCsFixer\Finder())
->files()
->name('*.php')
->in([__DIR__ . '/app/src', __DIR__ . '/app/modules']),
->in([__DIR__ . '/app', __DIR__ . '/tests', __DIR__ . '/utils']),
)
->setCacheFile('.cache/.php-cs-fixer.cache');
2 changes: 1 addition & 1 deletion app/config/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
'interceptors' => [
WebhookEventInterceptor::class,
BroadcastEventInterceptor::class,
]
],
];
2 changes: 1 addition & 1 deletion app/database/Factory/AttachmentFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function forEvent(Uuid|Event $uuid): self
{
$uuid = $uuid instanceof Event ? $uuid->getUuid() : $uuid;

return $this->state(fn(Generator $faker, array $definition) => [
return $this->state(static fn(Generator $faker, array $definition) => [
'event_uuid' => $uuid,
]);
}
Expand Down
14 changes: 7 additions & 7 deletions app/database/Factory/EventFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
*/
final class EventFactory extends AbstractFactory
{
use SmtpType,
ProfilerType,
SentryType,
MonologType,
InspectorType,
VarDumperType,
RayType;
use SmtpType;
use ProfilerType;
use SentryType;
use MonologType;
use InspectorType;
use VarDumperType;
use RayType;

public function entity(): string
{
Expand Down
5 changes: 3 additions & 2 deletions app/database/Factory/Partials/InspectorType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Database\Factory\Partials;

use Spiral\Http\Pipeline;
trait InspectorType
{
protected static function getInspectorPayload(): array
Expand Down Expand Up @@ -136,7 +137,7 @@ protected static function getInspectorPayload(): array
],
],
[
'class' => 'Spiral\\Http\\Pipeline',
'class' => Pipeline::class,
'function' => 'Spiral\\Http\\{closure}',
'args' => [],
'type' => '->',
Expand Down Expand Up @@ -190,7 +191,7 @@ protected static function getInspectorPayload(): array
],
[
'line' => 80,
'code' => ' throw new NotCallableException(\'Unsupported callable.\');',
'code' => " throw new NotCallableException('Unsupported callable.');",
],
],
],
Expand Down
52 changes: 30 additions & 22 deletions app/database/Factory/Partials/ProfilerType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@

namespace Database\Factory\Partials;

use Spiral\RoadRunnerBridge\Http\Dispatcher;
use Nyholm\Psr7\ServerRequest;
use Spiral\Debug\State;
use Spiral\Bootloader\DebugBootloader;
use Spiral\Telemetry\Span;
use Nyholm\Psr7\Stream;
use Nyholm\Psr7\Response;
use Spiral\Telemetry\Span\Status;
trait ProfilerType
{
public static function getProfilerPayload(): array
{
return [
'tags' => [
'php' => '8.2.5',
'dispatcher' => 'Spiral\\RoadRunnerBridge\\Http\\Dispatcher',
'dispatcher' => Dispatcher::class,
'method' => 'GET',
'url' => 'http://127.0.0.1:8080/',
'route' => null,
Expand Down Expand Up @@ -45,7 +53,7 @@ public static function getProfilerPayload(): array
],
'e2' => [
'caller' => 'main()',
'callee' => 'Nyholm\\Psr7\\ServerRequest::getAttribute',
'callee' => ServerRequest::class . '::getAttribute',
'cost' => [
'd_cpu' => 82950,
'd_wt' => 211997,
Expand All @@ -64,7 +72,7 @@ public static function getProfilerPayload(): array
],
'e3' => [
'caller' => 'main()',
'callee' => 'Spiral\\Debug\\State::getTags',
'callee' => State::class . '::getTags',
'cost' => [
'd_cpu' => 82951,
'd_wt' => 211999,
Expand All @@ -83,7 +91,7 @@ public static function getProfilerPayload(): array
],
'e4' => [
'caller' => 'main()',
'callee' => 'Spiral\\Bootloader\\DebugBootloader::state',
'callee' => DebugBootloader::class . '::state',
'cost' => [
'd_cpu' => 82855,
'd_wt' => 211903,
Expand All @@ -102,7 +110,7 @@ public static function getProfilerPayload(): array
],
'e5' => [
'caller' => 'main()',
'callee' => 'Spiral\\Telemetry\\Span::setStatus',
'callee' => Span::class . '::setStatus',
'cost' => [
'd_cpu' => 82949,
'd_wt' => 211997,
Expand All @@ -121,7 +129,7 @@ public static function getProfilerPayload(): array
],
'e6' => [
'caller' => 'main()',
'callee' => 'Nyholm\\Psr7\\Stream::getSize',
'callee' => Stream::class . '::getSize',
'cost' => [
'd_cpu' => 82951,
'd_wt' => 211999,
Expand All @@ -140,7 +148,7 @@ public static function getProfilerPayload(): array
],
'e7' => [
'caller' => 'main()',
'callee' => 'Nyholm\\Psr7\\Response::getBody',
'callee' => Response::class . '::getBody',
'cost' =>
[
'd_cpu' => 82951,
Expand All @@ -160,7 +168,7 @@ public static function getProfilerPayload(): array
],
'e8' => [
'caller' => 'main()',
'callee' => 'Nyholm\\Psr7\\Response::getHeaderLine',
'callee' => Response::class . '::getHeaderLine',
'cost' => [
'd_cpu' => 82948,
'd_wt' => 211996,
Expand All @@ -179,7 +187,7 @@ public static function getProfilerPayload(): array
],
'e9' => [
'caller' => 'main()',
'callee' => 'Spiral\\Telemetry\\Span::setAttribute',
'callee' => Span::class . '::setAttribute',
'cost' => [
'd_cpu' => 82949,
'd_wt' => 211997,
Expand All @@ -198,7 +206,7 @@ public static function getProfilerPayload(): array
],
'e10' => [
'caller' => 'main()',
'callee' => 'Nyholm\\Psr7\\Response::getStatusCode',
'callee' => Response::class . '::getStatusCode',
'cost' => [
'd_cpu' => 82951,
'd_wt' => 211998,
Expand Down Expand Up @@ -236,7 +244,7 @@ public static function getProfilerPayload(): array
],
'e12' => [
'caller' => 'App\\Middleware\\LocaleSelector::process',
'callee' => 'Spiral\\Telemetry\\Span::setStatus',
'callee' => Span::class . '::setStatus',
'cost' => [
'd_cpu' => 82701,
'd_wt' => 211747,
Expand All @@ -254,8 +262,8 @@ public static function getProfilerPayload(): array
],
],
'e13' => [
'caller' => 'Spiral\\Telemetry\\Span::setStatus',
'callee' => 'Spiral\\Telemetry\\Span\\Status::__construct',
'caller' => Span::class . '::setStatus',
'callee' => Status::class . '::__construct',
'cost' => [
'd_cpu' => 3,
'd_wt' => 2,
Expand All @@ -274,7 +282,7 @@ public static function getProfilerPayload(): array
],
'e14' => [
'caller' => 'App\\Middleware\\LocaleSelector::process',
'callee' => 'Nyholm\\Psr7\\Stream::getSize',
'callee' => Stream::class . '::getSize',
'cost' => [
'd_cpu' => 82691,
'd_wt' => 211737,
Expand All @@ -292,8 +300,8 @@ public static function getProfilerPayload(): array
],
],
'e15' => [
'caller' => 'Nyholm\\Psr7\\Stream::getSize',
'callee' => 'Nyholm\\Psr7\\Stream::getUri',
'caller' => Stream::class . '::getSize',
'callee' => Stream::class . '::getUri',
'cost' => [
'd_cpu' => 8,
'd_wt' => 7,
Expand All @@ -311,8 +319,8 @@ public static function getProfilerPayload(): array
],
],
'e16' => [
'caller' => 'Nyholm\\Psr7\\Stream::getUri',
'callee' => 'Nyholm\\Psr7\\Stream::getMetadata',
'caller' => Stream::class . '::getUri',
'callee' => Stream::class . '::getMetadata',
'cost' =>
[
'd_cpu' => 3,
Expand All @@ -332,7 +340,7 @@ public static function getProfilerPayload(): array
],
'e17' => [
'caller' => 'App\\Middleware\\LocaleSelector::process',
'callee' => 'Nyholm\\Psr7\\Response::getBody',
'callee' => Response::class . '::getBody',
'cost' => [
'd_cpu' => 82706,
'd_wt' => 211751,
Expand All @@ -351,7 +359,7 @@ public static function getProfilerPayload(): array
],
'e18' => [
'caller' => 'App\\Middleware\\LocaleSelector::process',
'callee' => 'Nyholm\\Psr7\\Response::getHeaderLine',
'callee' => Response::class . '::getHeaderLine',
'cost' => [
'd_cpu' => 82701,
'd_wt' => 211746,
Expand All @@ -369,8 +377,8 @@ public static function getProfilerPayload(): array
],
],
'e19' => [
'caller' => 'Nyholm\\Psr7\\Response::getHeaderLine',
'callee' => 'Nyholm\\Psr7\\Response::getHeader',
'caller' => Response::class . '::getHeaderLine',
'callee' => Response::class . '::getHeader',
'cost' => [
'd_cpu' => 2,
'd_wt' => 2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,5 @@ public function up(): void
->update();
}

public function down(): void
{

}
public function down(): void {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ public function up(): void
->addColumn('path', 'string', ['nullable' => false, 'defaultValue' => null, 'size' => 255])
->addColumn('size', 'integer', ['nullable' => false, 'defaultValue' => 0])
->addColumn('mime', 'string', ['nullable' => false, 'defaultValue' => null, 'size' => 32])
->addIndex(['event_uuid'],
['name' => 'http_dump_attachments_index_event_uuid_6647a54986782', 'unique' => false])
->addIndex(
['event_uuid'],
['name' => 'http_dump_attachments_index_event_uuid_6647a54986782', 'unique' => false],
)
->setPrimaryKeys(['uuid'])
->create();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public function up(): void
->addColumn('p_ct', 'float', ['nullable' => false, 'defaultValue' => null])
->addColumn('p_mu', 'float', ['nullable' => false, 'defaultValue' => null])
->addColumn('p_pmu', 'float', ['nullable' => false, 'defaultValue' => null])
->addIndex(['profile_uuid'], ['name' => 'profile_edges_index_profile_uuid_66643ff3139b6', 'unique' => false],
->addIndex(
['profile_uuid'],
['name' => 'profile_edges_index_profile_uuid_66643ff3139b6', 'unique' => false],
)
->addIndex(['parent_uuid'], ['name' => 'profile_edges_index_parent_uuid_66643ff3139e7', 'unique' => false])
->addForeignKey(['profile_uuid'], 'profiles', ['uuid'], [
Expand Down
8 changes: 4 additions & 4 deletions app/modules/Events/Domain/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ class Event
/** @internal */
public function __construct(
#[Column(type: 'string(36)', primary: true, typecast: 'uuid')]
private Uuid $uuid,
private readonly Uuid $uuid,
#[Column(type: 'string(50)')]
private string $type,
private readonly string $type,
#[Column(type: 'json', typecast: Json::class)]
private Json $payload,
#[Column(type: 'string(25)', typecast: Timestamp::class)]
private Timestamp $timestamp,
private readonly Timestamp $timestamp,
#[Column(type: 'string', nullable: true, typecast: Key::class)]
private ?Key $project = null,
private readonly ?Key $project = null,
) {}

public function getUuid(): Uuid
Expand Down
12 changes: 6 additions & 6 deletions app/modules/HttpDumps/Domain/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ class Attachment
/** @internal */
public function __construct(
#[Column(type: 'string(36)', primary: true, typecast: 'uuid')]
private Uuid $uuid,
private readonly Uuid $uuid,
#[Column(type: 'string(36)', typecast: 'uuid')]
private Uuid $eventUuid,
private readonly Uuid $eventUuid,
#[Column(type: 'string')]
private string $name,
private readonly string $name,
#[Column(type: 'string')]
private string $path,
private readonly string $path,
#[Column(type: 'integer', default: 0)]
private int $size,
private readonly int $size,
#[Column(type: 'string(32)')]
private string $mime,
private readonly string $mime,
) {}

public function getUuid(): Uuid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private function createPayload(ServerRequestInterface $request): array
'post' => $request->getParsedBody() ?? [],
'cookies' => $request->getCookieParams(),
'files' => \array_map(
fn(Attachment $attachment) => [
static fn(Attachment $attachment) => [
'uuid' => (string) $attachment->getUuid(),
'name' => $attachment->getFilename(),
'size' => $attachment->getSize(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ public function __invoke(
}

foreach ($repository->findAll() as $name => $collector) {
$this->info("Declaring metric: {$name}");
$this->info('Declaring metric: ' . $name);

try {
$metrics->declare($name, $collector);
} catch (\Throwable $e) {
$this->error("Failed to declare metric: {$name}. Reason: {$e->getMessage()}");
$this->error(sprintf('Failed to declare metric: %s. Reason: %s', $name, $e->getMessage()));
}
}

Expand Down
2 changes: 2 additions & 0 deletions app/modules/Profiler/Application/CallGraph/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public static function fromEdge(
}

public string $color;

public string $textColor;

public string $label;

public function __construct(
Expand Down
2 changes: 1 addition & 1 deletion app/modules/Profiler/Application/Handlers/PrepareEdges.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function handle(array $event): array
$parents[$func] = 'e' . $id;
$prev = 'e' . $id;

$id++;
++$id;
}

$event['total_edges'] = \count($event['edges']);
Expand Down
Loading
Loading