Skip to content

Commit

Permalink
Merge pull request #506: Actualize CS Fixer config update CI
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk authored Sep 23, 2024
2 parents f97d520 + ffb9e4c commit 13736e0
Show file tree
Hide file tree
Showing 260 changed files with 1,282 additions and 1,470 deletions.
30 changes: 15 additions & 15 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
* text=auto

.github/ export-ignore
config/ export-ignore
resources/scripts/ export-ignore
runtime/ export-ignore
tests/ export-ignore
.github/ export-ignore
config/ export-ignore
resources/scripts/ export-ignore
runtime/ export-ignore
tests/ export-ignore

.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.php_cs.dist export-ignore
dload.xml export-ignore
Makefile export-ignore
phpunit.xml.dist export-ignore
psalm.xml export-ignore
psalm-baseline.xml export-ignore
phpdoc.dist.xml export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.php-cs-fixer.dist.php export-ignore
dload.xml export-ignore
Makefile export-ignore
phpunit.xml.dist export-ignore
psalm.xml export-ignore
psalm-baseline.xml export-ignore
phpdoc.dist.xml export-ignore
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
4 changes: 4 additions & 0 deletions .github/workflows/security-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Security

on: [push, pull_request]

concurrency:
cancel-in-progress: ${{ !contains(github.ref, 'release/')}}
group: tests-${{ github.workflow }}-${{ github.ref }}

jobs:
security:
name: Security Checks (PHP ${{ matrix.php }}, OS ${{ matrix.os }})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
name: Code Style
name: Static Analysis

on: [push, pull_request]

concurrency:
cancel-in-progress: ${{ !contains(github.ref, 'release/')}}
group: tests-${{ github.workflow }}-${{ github.ref }}

jobs:
psalm:
name: Psalm Validation (PHP ${{ matrix.php }}, OS ${{ matrix.os }})
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Testing

on: [push, pull_request]

concurrency:
cancel-in-progress: ${{ !contains(github.ref, 'release/')}}
group: tests-${{ github.workflow }}-${{ github.ref }}

jobs:
unit:
name: Unit Testing
Expand Down
13 changes: 13 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

require_once 'vendor/autoload.php';

return \Spiral\CodeStyle\Builder::create()
->include(__DIR__ . '/src')
->include(__DIR__ . '/testing/src')
->include(__FILE__)
->exclude(__DIR__ . '/src/Client/GRPC/ServiceClientInterface.php')
->allowRisky(true)
->build();
10 changes: 4 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@
"composer/composer": "^2.0",
"dereuromark/composer-prefer-lowest": "^0.1.10",
"doctrine/annotations": "^1.14|^2.0.0",
"friendsofphp/php-cs-fixer": "^3.0",
"internal/dload": "^1.0",
"jetbrains/phpstorm-attributes": "dev-master@dev",
"laminas/laminas-code": "^4.0",
"phpunit/phpunit": "^10.5",
"spiral/code-style": "^2.1.2",
"spiral/core": "^3.13",
"symfony/var-dumper": "^6.0 || ^7.0",
"vimeo/psalm": "^4.30 || ^5.4"
Expand All @@ -81,15 +81,13 @@
},
"scripts": {
"post-update-cmd": "Temporal\\Worker\\Transport\\RoadRunnerVersionChecker::postUpdate",
"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",
"test:unit": "phpunit --testsuite=Unit --color=always --testdox",
"test:func": "phpunit --testsuite=Functional --color=always --testdox",
"test:accept": "phpunit --testsuite=Acceptance --color=always --testdox",
"phpcs": [
"@putenv PHP_CS_FIXER_IGNORE_ENV=1",
"php-cs-fixer fix src"
]
"test:accept": "phpunit --testsuite=Acceptance --color=always --testdox"
},
"extra": {
"branch-alias": {
Expand Down
96 changes: 23 additions & 73 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.25.0@01a8eb06b9e9cc6cfb6a320bf9fb14331919d505">
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0">
<file src="src/Activity.php">
<ImplicitToStringCast>
<code><![CDATA[$type]]></code>
Expand Down Expand Up @@ -109,11 +109,6 @@
<code><![CDATA[$workflowType]]></code>
</PropertyNotSetInConstructor>
</file>
<file src="src/Client/Schedule/ScheduleHandle.php">
<PossiblyInvalidOperand>
<code><![CDATA[$timestamp->getSeconds()]]></code>
</PossiblyInvalidOperand>
</file>
<file src="src/Client/Update/UpdateHandle.php">
<PossiblyNullArgument>
<code><![CDATA[$result->getSuccess()]]></code>
Expand All @@ -132,12 +127,12 @@
<code><![CDATA[new WorkflowProxy(
$this,
$this->newUntypedRunningWorkflowStub($workflowID, $runID, $workflow->getID()),
$workflow
$workflow,
)]]></code>
<code><![CDATA[new WorkflowProxy(
$this,
$this->newUntypedWorkflowStub($workflow->getID(), $options),
$workflow
$workflow,
)]]></code>
</InvalidReturnStatement>
<InvalidReturnType>
Expand Down Expand Up @@ -171,7 +166,7 @@
<code><![CDATA[NamedArgumentConstructor]]></code>
</DeprecatedClass>
<RedundantCast>
<code><![CDATA[(string)$this->interval]]></code>
<code><![CDATA[(string) $this->interval]]></code>
</RedundantCast>
</file>
<file src="src/Common/MethodRetry.php">
Expand Down Expand Up @@ -303,7 +298,7 @@
<code><![CDATA[new static(
$e->getMessage(),
$e->getCode(),
$e
$e,
)]]></code>
<code><![CDATA[new static(
self::buildMessage(
Expand All @@ -312,10 +307,10 @@
'runId' => $info->workflowExecution->getRunID(),
'activityId' => $info->id,
'activityType' => $info->type->name,
]
],
),
$e === null ? 0 : $e->getCode(),
$e
$e,
)]]></code>
<code><![CDATA[new static('', $e->getCode(), $e)]]></code>
</UnsafeInstantiation>
Expand Down Expand Up @@ -346,7 +341,7 @@
<code><![CDATA[Failure]]></code>
</InvalidNullableReturnType>
<InvalidOperand>
<code><![CDATA[count($arg)]]></code>
<code><![CDATA[\count($arg)]]></code>
</InvalidOperand>
<NullableReturnStatement>
<code><![CDATA[$e->getFailure()]]></code>
Expand Down Expand Up @@ -387,9 +382,9 @@
<code><![CDATA[$value]]></code>
</MissingClosureParamType>
<MissingClosureReturnType>
<code><![CDATA[fn ($value) => RetryState::name($value)]]></code>
<code><![CDATA[fn ($value) => TimeoutType::name($value)]]></code>
<code><![CDATA[fn ($value) => TimeoutType::name($value)]]></code>
<code><![CDATA[static fn($value) => RetryState::name($value)]]></code>
<code><![CDATA[static fn($value) => TimeoutType::name($value)]]></code>
<code><![CDATA[static fn($value) => TimeoutType::name($value)]]></code>
</MissingClosureReturnType>
</file>
<file src="src/Interceptor/Header.php">
Expand Down Expand Up @@ -422,13 +417,13 @@
<code><![CDATA[$options->retryOptions ? $options->retryOptions->toWorkflowRetryPolicy() : null]]></code>
<code><![CDATA[$options->toMemo($this->converter)]]></code>
<code><![CDATA[$options->toSearchAttributes($this->converter)]]></code>
<code><![CDATA[DateInterval::toDuration($options->workflowExecutionTimeout)]]></code>
<code><![CDATA[DateInterval::toDuration($options->workflowRunTimeout)]]></code>
<code><![CDATA[DateInterval::toDuration($options->workflowTaskTimeout)]]></code>
</PossiblyNullArgument>
<PossiblyNullReference>
<code><![CDATA[getName]]></code>
</PossiblyNullReference>
<RedundantConditionGivenDocblockType>
<code><![CDATA[$delay !== null]]></code>
</RedundantConditionGivenDocblockType>
</file>
<file src="src/Internal/Client/WorkflowStub.php">
<PossiblyInvalidArgument>
Expand Down Expand Up @@ -496,7 +491,7 @@
</file>
<file src="src/Internal/Declaration/Graph/NodeInterface.php">
<InvalidDocblock>
<code><![CDATA[interface NodeInterface extends \Stringable, \IteratorAggregate, \Countable]]></code>
<code><![CDATA[interface NodeInterface extends \Stringable, \IteratorAggregate, \Countable {}]]></code>
</InvalidDocblock>
<MissingTemplateParam>
<code><![CDATA[\IteratorAggregate]]></code>
Expand Down Expand Up @@ -697,13 +692,13 @@
</file>
<file src="src/Internal/Marshaller/ProtoToArrayConverter.php">
<FalsableReturnStatement>
<code><![CDATA[DateTimeImmutable::createFromFormat(
<code><![CDATA[\DateTimeImmutable::createFromFormat(
'U.u',
\sprintf('%d.%d', $input->getSeconds(), $input->getNanos() / 1000),
)]]></code>
</FalsableReturnStatement>
<InvalidFalsableReturnType>
<code><![CDATA[DateTimeImmutable]]></code>
<code><![CDATA[\DateTimeImmutable]]></code>
</InvalidFalsableReturnType>
<InvalidReturnStatement>
<code><![CDATA[\Temporal\Interceptor\Header::fromPayloadCollection($input->getFields(), $this->converter)]]></code>
Expand All @@ -719,7 +714,7 @@
</MoreSpecificReturnType>
<PossiblyFalseArgument>
<code><![CDATA[$now->modify(
\sprintf('+%d seconds +%d microseconds', $input->getSeconds(), $input->getNanos() / 1000)
\sprintf('+%d seconds +%d microseconds', $input->getSeconds(), $input->getNanos() / 1000),
)]]></code>
</PossiblyFalseArgument>
</file>
Expand All @@ -734,25 +729,11 @@
<code><![CDATA[$this->format]]></code>
<code><![CDATA[$this->format]]></code>
</ArgumentTypeCoercion>
<InvalidNullableReturnType>
<code><![CDATA[int|Duration]]></code>
</InvalidNullableReturnType>
<InvalidOperand>
<code><![CDATA[$value * 1000000000]]></code>
<code><![CDATA[($value * 1000000000) % 1000000000]]></code>
<code><![CDATA[DateInterval::parse($value, $this->format)->totalMicroseconds * 1000]]></code>
</InvalidOperand>
<NullableReturnStatement>
<code><![CDATA[match (true) {
$value instanceof \DateInterval => DateInterval::toDuration($value),
\is_int($value) => (new Duration())->setSeconds($value),
\is_string($value) => (new Duration())->setSeconds((int)$value),
\is_float($value) => (new Duration())
->setSeconds((int)$value)
->setNanos(($value * 1000000000) % 1000000000),
default => throw new \InvalidArgumentException('Invalid value type.'),
}]]></code>
</NullableReturnStatement>
</file>
<file src="src/Internal/Marshaller/Type/DurationJsonType.php">
<InvalidOperand>
Expand All @@ -771,11 +752,11 @@
</file>
<file src="src/Internal/Marshaller/Type/ObjectType.php">
<InvalidPropertyAssignmentValue>
<code><![CDATA[new \ReflectionClass($class ?? stdClass::class)]]></code>
<code><![CDATA[new \ReflectionClass($class ?? \stdClass::class)]]></code>
</InvalidPropertyAssignmentValue>
<InvalidReturnStatement>
<code><![CDATA[$this->reflection->getName() === stdClass::class
? (object)$data
<code><![CDATA[$this->reflection->getName() === \stdClass::class
? (object) $data
: $this->marshaller->unmarshal($data, $this->reflection->newInstanceWithoutConstructor())]]></code>
</InvalidReturnStatement>
<InvalidReturnType>
Expand Down Expand Up @@ -1044,12 +1025,6 @@
<code><![CDATA[pull]]></code>
</UndefinedInterfaceMethod>
</file>
<file src="src/Internal/Transport/Router/GetWorkerInfo.php">
<MissingClosureReturnType>
<code><![CDATA[function (WorkflowPrototype $workflow) {]]></code>
<code><![CDATA[static fn (ActivityPrototype $activity) => []]></code>
</MissingClosureReturnType>
</file>
<file src="src/Internal/Transport/Router/InvokeActivity.php">
<UnnecessaryVarAnnotation>
<code><![CDATA[ActivityContext]]></code>
Expand Down Expand Up @@ -1154,7 +1129,7 @@
<code><![CDATA[$this->workflow]]></code>
</ArgumentTypeCoercion>
<LessSpecificReturnStatement>
<code><![CDATA[$execution->then(
<code><![CDATA[$this->execution->promise()->then(
function (WorkflowExecution $execution) use ($name, $args) {
$request = new SignalExternalWorkflow(
$this->getOptions()->namespace,
Expand All @@ -1166,7 +1141,7 @@
);
return $this->request($request);
}
},
)]]></code>
<code><![CDATA[$this->start(...$args)->then(fn() => $this->getResult($returnType))]]></code>
<code><![CDATA[EncodedValues::decodePromise($started)]]></code>
Expand Down Expand Up @@ -1293,22 +1268,6 @@
<code><![CDATA[iterable<PromiseInterface<T>|T>]]></code>
</TooManyTemplateParams>
</file>
<file src="src/Worker/ActivityInvocationCache/ActivityInvocationCacheInterface.php">
<MissingParamType>
<code><![CDATA[$value]]></code>
</MissingParamType>
</file>
<file src="src/Worker/ActivityInvocationCache/ActivityInvocationFailure.php">
<InvalidStringClass>
<code><![CDATA[new $errorClass($this->errorMessage)]]></code>
</InvalidStringClass>
<LessSpecificReturnStatement>
<code><![CDATA[new $errorClass($this->errorMessage)]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[Throwable]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Worker/ActivityInvocationCache/ActivityInvocationResult.php">
<MissingReturnType>
<code><![CDATA[toValue]]></code>
Expand All @@ -1321,9 +1280,6 @@
</PossiblyUndefinedStringArrayOffset>
</file>
<file src="src/Worker/ActivityInvocationCache/InMemoryActivityInvocationCache.php">
<MissingParamType>
<code><![CDATA[$value]]></code>
</MissingParamType>
<PossiblyUndefinedStringArrayOffset>
<code><![CDATA[$request->getOptions()['name']]]></code>
</PossiblyUndefinedStringArrayOffset>
Expand All @@ -1349,8 +1305,6 @@
<ArgumentTypeCoercion>
<code><![CDATA[$this->maxDepth]]></code>
<code><![CDATA[$this->maxDepth]]></code>
<code><![CDATA[(int)($headers['history_length'] ?? 0)]]></code>
<code><![CDATA[(int)($headers['history_size'] ?? 0)]]></code>
</ArgumentTypeCoercion>
<PossiblyInvalidArgument>
<code><![CDATA[$e->getCode()]]></code>
Expand Down Expand Up @@ -1384,10 +1338,6 @@
</PossiblyNullArgument>
</file>
<file src="src/Worker/Transport/Codec/ProtoCodec.php">
<ArgumentTypeCoercion>
<code><![CDATA[(int)($headers['history_length'] ?? $msg->getHistoryLength())]]></code>
<code><![CDATA[(int)($headers['history_size'] ?? $msg->getHistorySize())]]></code>
</ArgumentTypeCoercion>
<PossiblyInvalidArgument>
<code><![CDATA[$e->getCode()]]></code>
<code><![CDATA[$e->getCode()]]></code>
Expand Down
1 change: 0 additions & 1 deletion src/Activity/ActivityOptionsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

declare(strict_types=1);


namespace Temporal\Activity;

use Temporal\Common\MethodRetry;
Expand Down
Loading

0 comments on commit 13736e0

Please sign in to comment.