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
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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_style = space
indent_size = 2

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

/.* export-ignore
/example export-ignore
/tests export-ignore
/*.xml export-ignore
/*.yml export-ignore
/*.lock export-ignore
/*.dist export-ignore
/*.php export-ignore
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

github: roadrunner-server
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
14 changes: 14 additions & 0 deletions .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
on:
push:
branches:
- '*.*'
pull_request: null

name: static analysis

jobs:
psalm:
uses: spiral/gh-actions/.github/workflows/psalm.yml@master
with:
os: >-
['ubuntu-latest']
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Dependency directories (remove the comment below to include it)
# vendor/
.idea
vendor
/runtime
/vendor
/.idea
/.env
composer.lock
12 changes: 12 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

require_once 'vendor/autoload.php';

return \Spiral\CodeStyle\Builder::create()
->include(__DIR__ . '/bin/rr')
->include(__DIR__ . '/src')
->include(__FILE__)
->allowRisky(true)
->build();
12 changes: 6 additions & 6 deletions bin/rr
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ use Spiral\RoadRunner\Version;
//

if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
$error = vsprintf('Info CLI should be invoked via the CLI version of PHP, not the %s SAPI', [
$error = \vsprintf('Info CLI should be invoked via the CLI version of PHP, not the %s SAPI', [
PHP_SAPI,
]);

fwrite(STDERR, $error);
\fwrite(STDERR, $error);
exit(1);
}

Expand All @@ -44,15 +44,15 @@ $composerAutoloadPaths = [
];

foreach ($composerAutoloadPaths as $file) {
if (is_file($file)) {
define('RR_COMPOSER_INSTALL', $file);
if (\is_file($file)) {
\define('RR_COMPOSER_INSTALL', $file);

break;
}
}

if (! defined('RR_COMPOSER_INSTALL')) {
fwrite(STDERR, <<<'RR_CLI_ERROR'
if (! \defined('RR_COMPOSER_INSTALL')) {
\fwrite(STDERR, <<<'RR_CLI_ERROR'
You need to set up the project dependencies using Composer:

composer install
Expand Down
38 changes: 21 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,40 @@
"support": {
"docs": "https://docs.roadrunner.dev",
"issues": "https://github.com/roadrunner-server/roadrunner/issues",
"forum": "https://forum.roadrunner.dev/",
"chat": "https://discord.gg/V6EK4he"
},
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/roadrunner-server"
}
],
"require": {
"php": ">=7.4",
"php": ">=8.1",
"ext-json": "*",
"composer/semver": "^3.2",
"spiral/roadrunner-worker": ">=2.0.2",
"spiral/tokenizer": "^2.13 || ^3.0",
"composer/semver": "^3.4",
"spiral/roadrunner-worker": "^2 || ^3",
"spiral/tokenizer": "^2.13 || ^3.15",
"symfony/console": "^5.3 || ^6.0 || ^7.0",
"symfony/http-client": "^4.4.11 || ^5.0 || ^6.0 || ^7.0",
"symfony/polyfill-php80": "^1.22",
"symfony/yaml": "^5.4 || ^6.0 || ^7.0"
"symfony/http-client": "^4.4.51 || ^5.4.49 || ^6.4.17 || ^7.2",
"symfony/yaml": "^5.4.49 || ^6.4.17 || ^7.2"
},
"require-dev": {
"jetbrains/phpstorm-attributes": "^1.0",
"vimeo/psalm": "^5.17"
},
"scripts": {
"analyze": "psalm"
"jetbrains/phpstorm-attributes": "^1.2",
"spiral/code-style": "^2.2.2",
"spiral/dumper": "^3.3",
"vimeo/psalm": "^6.0"
},
"autoload": {
"psr-4": {
"Spiral\\RoadRunner\\Console\\": "src"
}
},
"extra": {
"branch-alias": {
"dev-master": "2.1.x-dev"
}
"scripts": {
"cs:diff": "php-cs-fixer fix --dry-run -v --diff --show-progress dots",
"cs:fix": "php-cs-fixer fix -v",
"psalm": "psalm",
"psalm:baseline": "psalm --set-baseline=psalm-baseline.xml"
},
"config": {
"sort-packages": true
Expand Down
158 changes: 158 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="6.0.0@b8e96bb617bf59382113b1b56cef751f648a7dc9">
<file src="src/Archive/Factory.php">
<RiskyTruthyFalsyComparison>
<code><![CDATA[$temp]]></code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Command.php">
<RiskyTruthyFalsyComparison>
<code><![CDATA[$token]]></code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Command/Option.php">
<MixedAssignment>
<code><![CDATA[$result]]></code>
</MixedAssignment>
</file>
<file src="src/Command/VersionFilterOption.php">
<InvalidArgument>
<code><![CDATA[\array_unique($versions)]]></code>
</InvalidArgument>
<PossiblyInvalidMethodCall>
<code><![CDATA[sortByVersion]]></code>
</PossiblyInvalidMethodCall>
</file>
<file src="src/Configuration/Generator.php">
<ArgumentTypeCoercion>
<code><![CDATA[new $section()]]></code>
</ArgumentTypeCoercion>
<InvalidReturnType>
<code><![CDATA[non-empty-array<SectionInterface>]]></code>
</InvalidReturnType>
<MismatchingDocblockReturnType>
<code><![CDATA[non-empty-array<SectionInterface>]]></code>
</MismatchingDocblockReturnType>
<MixedAssignment>
<code><![CDATA[$section]]></code>
</MixedAssignment>
<MixedMethodCall>
<code><![CDATA[new $section()]]></code>
</MixedMethodCall>
</file>
<file src="src/Configuration/Plugins.php">
<MixedPropertyTypeCoercion>
<code><![CDATA[$plugins]]></code>
<code><![CDATA[$this->getAvailable()]]></code>
</MixedPropertyTypeCoercion>
</file>
<file src="src/DownloadProtocBinaryCommand.php">
<ArgumentTypeCoercion>
<code><![CDATA[$stabilityOption]]></code>
</ArgumentTypeCoercion>
<PossiblyInvalidMethodCall>
<code><![CDATA[filter]]></code>
</PossiblyInvalidMethodCall>
<PossiblyNullArgument>
<code><![CDATA[$file]]></code>
</PossiblyNullArgument>
</file>
<file src="src/Environment/OperatingSystem.php">
<TooManyArguments>
<code><![CDATA[createFromGlobals]]></code>
</TooManyArguments>
</file>
<file src="src/GetBinaryCommand.php">
<ArgumentTypeCoercion>
<code><![CDATA[$stabilityOption]]></code>
</ArgumentTypeCoercion>
<MixedArgument>
<code><![CDATA[$in->getOption('plugin')]]></code>
<code><![CDATA[$in->getOption('preset')]]></code>
</MixedArgument>
<PossiblyFalseOperand>
<code><![CDATA[\getcwd()]]></code>
</PossiblyFalseOperand>
<PossiblyInvalidMethodCall>
<code><![CDATA[onlyRoadrunner]]></code>
</PossiblyInvalidMethodCall>
<PossiblyNullArgument>
<code><![CDATA[$file]]></code>
</PossiblyNullArgument>
<PossiblyUndefinedVariable>
<code><![CDATA[$config]]></code>
</PossiblyUndefinedVariable>
<UnnecessaryVarAnnotation>
<code><![CDATA[AssetInterface]]></code>
<code><![CDATA[ReleaseInterface]]></code>
</UnnecessaryVarAnnotation>
</file>
<file src="src/MakeConfigCommand.php">
<MixedArgument>
<code><![CDATA[$input->getOption('plugin')]]></code>
<code><![CDATA[$input->getOption('preset')]]></code>
</MixedArgument>
<PossiblyFalseOperand>
<code><![CDATA[\getcwd()]]></code>
</PossiblyFalseOperand>
</file>
<file src="src/Repository/Collection.php">
<UnsafeGenericInstantiation>
<code><![CDATA[new static($items)]]></code>
<code><![CDATA[new static(\array_filter($this->items, $callback))]]></code>
<code><![CDATA[new static(\array_filter($this->items, $filter))]]></code>
<code><![CDATA[new static(\array_map($map, $this->items))]]></code>
</UnsafeGenericInstantiation>
</file>
<file src="src/Repository/GitHub/GitHubRelease.php">
<InvalidArgument>
<code><![CDATA[$release]]></code>
</InvalidArgument>
<InvalidArrayOffset>
<code><![CDATA[$release['tag_name']]]></code>
</InvalidArrayOffset>
<MixedArgument>
<code><![CDATA[$version]]></code>
</MixedArgument>
<MixedAssignment>
<code><![CDATA[$version]]></code>
</MixedAssignment>
</file>
<file src="src/Repository/Release.php">
<LessSpecificReturnStatement>
<code><![CDATA[$this->stability]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[string]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Repository/ReleaseInterface.php">
<MismatchingDocblockReturnType>
<code><![CDATA[AssetsCollection|iterable<AssetInterface>]]></code>
</MismatchingDocblockReturnType>
</file>
<file src="src/Repository/ReleasesCollection.php">
<PossiblyInvalidMethodCall>
<code><![CDATA[empty]]></code>
</PossiblyInvalidMethodCall>
</file>
<file src="src/Repository/RepositoryInterface.php">
<MismatchingDocblockReturnType>
<code><![CDATA[ReleasesCollection|iterable<ReleaseInterface>]]></code>
</MismatchingDocblockReturnType>
</file>
<file src="src/VersionsCommand.php">
<ArgumentTypeCoercion>
<code><![CDATA[$this->stability->get($input, $io)]]></code>
</ArgumentTypeCoercion>
<PossiblyInvalidArgument>
<code><![CDATA[$release->getAssets()]]></code>
</PossiblyInvalidArgument>
<PossiblyInvalidMethodCall>
<code><![CDATA[count]]></code>
<code><![CDATA[empty]]></code>
<code><![CDATA[sortByVersion]]></code>
<code><![CDATA[whereOperatingSystem]]></code>
</PossiblyInvalidMethodCall>
</file>
</files>
15 changes: 13 additions & 2 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="psalm-baseline.xml"
errorLevel="1"
hoistConstants="true"
resolveFromConfigFile="true"
findUnusedPsalmSuppress="true"
findUnusedBaselineEntry="true"
findUnusedCode="false"
findUnusedVariablesAndParams="true"
ensureArrayStringOffsetsExist="true"
addParamDefaultToDocblockType="true"
>
<issueHandlers>
<MissingClassConstType errorLevel="suppress" />
</issueHandlers>
<projectFiles>
<directory name="src" />
<ignoreFiles>
Expand Down
10 changes: 2 additions & 8 deletions src/Archive/Archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,22 @@

abstract class Archive implements ArchiveInterface
{
/**
* @param \SplFileInfo $archive
*/
public function __construct(\SplFileInfo $archive)
{
$this->assertArchiveValid($archive);
}

/**
* @param \SplFileInfo $archive
*/
private function assertArchiveValid(\SplFileInfo $archive): void
{
if (! $archive->isFile()) {
throw new \InvalidArgumentException(
\sprintf('Archive "%s" is not a file', $archive->getFilename())
\sprintf('Archive "%s" is not a file', $archive->getFilename()),
);
}

if (! $archive->isReadable()) {
throw new \InvalidArgumentException(
\sprintf('Archive file "%s" is not readable', $archive->getFilename())
\sprintf('Archive file "%s" is not readable', $archive->getFilename()),
);
}
}
Expand Down
Loading
Loading