Skip to content
Merged
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
22 changes: 22 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2

[*.yaml]
indent_size = 2

[*.json]
indent_style = space
indent_size = 4
16 changes: 8 additions & 8 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
* text=auto

/.github export-ignore
/tests export-ignore
/.* export-ignore
/phpunit.xml* export-ignore
/phpstan.* export-ignore
/psalm.* export-ignore
/infection.* export-ignore
/codecov.* export-ignore
/.* export-ignore
/config/ export-ignore
/resources/scripts/ export-ignore
/runtime/ export-ignore
/tests/ export-ignore

/*.xml export-ignore
/*.xml.dist export-ignore
10 changes: 0 additions & 10 deletions .github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

12 changes: 12 additions & 0 deletions .github/workflows/cs-fix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
on:
push:
branches:
- '*'

name: Fix Code Style

jobs:
cs-fix:
permissions:
contents: write
uses: spiral/gh-actions/.github/workflows/cs-fix.yml@master
11 changes: 11 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

declare(strict_types=1);

require_once 'vendor/autoload.php';

return \Spiral\CodeStyle\Builder::create()
->include(__DIR__ . '/src')
->include(__FILE__)
->allowRisky(true)
->build();
15 changes: 9 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"support": {
"docs": "https://docs.roadrunner.dev",
"issues": "https://github.com/roadrunner-server/roadrunner/issues",
"forum": "https://forum.roadrunner.dev/",
"chat": "https://discord.gg/V6EK4he"
},
"require": {
Expand All @@ -42,17 +41,21 @@
"ext-sockets": "*",
"psr/log": "^2.0 || ^3.0",
"spiral/goridge": "^4.1.0",
"spiral/roadrunner": "^2023.1 || ^2024.1",
"spiral/roadrunner": "^2023.1 || ^2024.1 || ^2025.1",
"composer-runtime-api": "^2.0"
},
"require-dev": {
"buggregator/trap": "^1.13",
"jetbrains/phpstorm-attributes": "^1.0",
"phpunit/phpunit": "^10.0",
"vimeo/psalm": "^5.9",
"symfony/var-dumper": "^6.3 || ^7.0"
"phpunit/phpunit": "^10.5.45",
"spiral/code-style": "^2.2",
"vimeo/psalm": "^6.0"
},
"scripts": {
"analyze": "psalm"
"cs:diff": "php-cs-fixer fix --dry-run -v --diff --show-progress dots",
"cs:fix": "php-cs-fixer fix -v",
"test": "phpunit",
"psalm": "psalm"
},
"autoload": {
"psr-4": {
Expand Down
18 changes: 14 additions & 4 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
cacheResultFile="runtime/.phpunit.result.cache"
backupGlobals="false"
colors="true"
processIsolation="false"
Expand All @@ -10,14 +11,23 @@
stderr="true"
>
<testsuites>
<testsuite name="RR Worker Tests">
<directory>tests</directory>
<testsuite name="Unit">
<directory>tests/Unit</directory>
</testsuite>
</testsuites>

<coverage>
<report>
<html outputDirectory="runtime/phpunit/coverage"/>
<text outputFile="runtime/phpunit/coverage.txt"/>
<clover outputFile="runtime/phpunit/logs/clover.xml"/>
</report>
</coverage>
<logging>
<junit outputFile="runtime/report.junit.xml"/>
</logging>
<source>
<include>
<directory>src</directory>
</include>
</coverage>
</source>
</phpunit>
15 changes: 15 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,19 @@
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<MissingOverrideAttribute errorLevel="suppress" />
<ClassMustBeFinal errorLevel="suppress" />
</issueHandlers>
<forbiddenFunctions>
<function name="dd"/>
<function name="exit"/>
<function name="die"/>
<function name="var_dump"/>
<function name="echo"/>
<function name="print"/>
<function name="trap"/>
<function name="td"/>
<function name="tr"/>
</forbiddenFunctions>
</psalm>
19 changes: 9 additions & 10 deletions src/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ class Environment implements EnvironmentInterface
*/
public function __construct(
private array $env = [],
) {
) {}

public static function fromGlobals(): self
{
/** @var array<string, string> $env */
$env = [...$_ENV, ...$_SERVER];

return new self($env);
}

public function getMode(): string
Expand Down Expand Up @@ -57,17 +64,9 @@ private function get(string $name, string $default = ''): string
{
if (isset($this->env[$name]) || \array_key_exists($name, $this->env)) {
/** @psalm-suppress RedundantCastGivenDocblockType */
return (string)$this->env[$name];
return (string) $this->env[$name];
}

return $default;
}

public static function fromGlobals(): self
{
/** @var array<string, string> $env */
$env = [...$_ENV, ...$_SERVER];

return new self($env);
}
}
4 changes: 1 addition & 3 deletions src/Exception/RoadRunnerException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

namespace Spiral\RoadRunner\Exception;

final class RoadRunnerException extends \RuntimeException
{
}
final class RoadRunnerException extends \RuntimeException {}
3 changes: 1 addition & 2 deletions src/Informer/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@ public function __construct(
public float $cpuUsage,
public string $command,
public string $status,
) {
}
) {}
}
3 changes: 1 addition & 2 deletions src/Informer/Workers.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ final class Workers implements \Countable
*/
public function __construct(
private readonly array $workers = [],
) {
}
) {}

/**
* @return array<Worker>
Expand Down
4 changes: 2 additions & 2 deletions src/Internal/StdoutHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ final class StdoutHandler
*/
public static function register(int $chunkSize = self::OB_CHUNK_SIZE): void
{
assert($chunkSize >= 0, 'Invalid chunk size argument value');
\assert($chunkSize >= 0, 'Invalid chunk size argument value');

self::restreamOutputBuffer($chunkSize);
self::restreamHeaders();
Expand All @@ -50,7 +50,7 @@ public static function register(int $chunkSize = self::OB_CHUNK_SIZE): void
*/
private static function restreamHeaders(): void
{
\header_register_callback(static function(): void {
\header_register_callback(static function (): void {
$headers = \headers_list();

if ($headers !== []) {
Expand Down
6 changes: 3 additions & 3 deletions src/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ class Logger implements LoggerInterface
*/
public function log(mixed $level, string|\Stringable $message, array $context = []): void
{
assert(\is_scalar($level), 'Invalid log level type');
assert(\is_string($message), 'Invalid log message type');
\assert(\is_scalar($level), 'Invalid log level type');
\assert(\is_string($message), 'Invalid log message type');

$this->write($this->format((string)$level, $message, $context));
$this->write($this->format((string) $level, $message, $context));
}

protected function write(string $message): void
Expand Down
4 changes: 1 addition & 3 deletions src/Message/Command/GetProcessId.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@
/**
* @psalm-immutable
*/
final class GetProcessId extends Payload implements ControlMessage
{
}
final class GetProcessId extends Payload implements ControlMessage {}
4 changes: 1 addition & 3 deletions src/Message/Command/Pong.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@
/**
* @psalm-immutable
*/
final class Pong extends Payload implements SkipMessage
{
}
final class Pong extends Payload implements SkipMessage {}
4 changes: 1 addition & 3 deletions src/Message/Command/StreamStop.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@
/**
* @psalm-immutable
*/
final class StreamStop extends Payload implements SkipMessage
{
}
final class StreamStop extends Payload implements SkipMessage {}
4 changes: 1 addition & 3 deletions src/Message/Command/WorkerStop.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@
/**
* @psalm-immutable
*/
final class WorkerStop extends Payload implements ControlMessage
{
}
final class WorkerStop extends Payload implements ControlMessage {}
4 changes: 1 addition & 3 deletions src/Message/ControlMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@
/**
* @internal
*/
interface ControlMessage
{
}
interface ControlMessage {}
4 changes: 1 addition & 3 deletions src/Message/SkipMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@
* after stream end because async and should be skipped in main worker loop.
* @internal
*/
interface SkipMessage
{
}
interface SkipMessage {}
2 changes: 1 addition & 1 deletion src/PayloadFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ private static function decode(string $json): array

return $result;
}
}
}
3 changes: 1 addition & 2 deletions src/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ final class Version
'spiral/roadrunner',
'spiral/roadrunner-worker',
];

public const VERSION_FALLBACK = 'dev-master';

public static function current(): string
{
foreach (self::PACKAGE_NAMES as $name) {
if (InstalledVersions::isInstalled($name)) {
return \ltrim((string)InstalledVersions::getPrettyVersion($name), 'v');
return \ltrim((string) InstalledVersions::getPrettyVersion($name), 'v');
}
}

Expand Down
Loading
Loading