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

Add rector [batch] #50

Merged
merged 11 commits into from
Sep 14, 2023
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
19 changes: 9 additions & 10 deletions .github/workflows/bc.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
on:
pull_request:
push:
- pull_request
- push

name: backwards compatibility

jobs:
roave_bc_check:
name: Roave BC Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: fetch tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Roave BC Check
uses: docker://nyholm/roave-bc-check-ga
uses: yiisoft/actions/.github/workflows/bc.yml@master
with:
os: >-
['ubuntu-latest']
php: >-
['8.0']
23 changes: 23 additions & 0 deletions .github/workflows/rector.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
on:
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'psalm.xml'

name: rector

jobs:
rector:
uses: yiisoft/actions/.github/workflows/rector.yml@master
secrets:
token: ${{ secrets.YIISOFT_GITHUB_TOKEN }}
with:
os: >-
['ubuntu-latest']
php: >-
['8.2']
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"rector/rector": "^0.18.3",
"roave/infection-static-analysis-plugin": "^1.16",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30|^5.3"
Expand Down
30 changes: 30 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests',
]);

// register a single rule
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);

// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_74,
]);

$rectorConfig->skip([
ClosureToArrowFunctionRector::class,
JsonThrowOnErrorRector::class,
__DIR__ . '/tests/SynchronizerTest.php',
]);
};
16 changes: 9 additions & 7 deletions tests/SynchronizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,21 @@ public function testExecuteWithErrorCapture(): void
{
$result = false;

$exceptionMessage = null;
try {
$this->synchronizer->execute('testExecuteExceptionThrown', function () use (&$result) {
$result = file_exists($this->mutex->getFile());
return $undefined;
});
} catch (ErrorException $e) {
$this->assertSame(
PHP_VERSION_ID >= 80000 ? 'Undefined variable $undefined' : 'Undefined variable: undefined',
$e->getMessage(),
);
} finally {
$this->assertTrue($result);
$this->assertFileDoesNotExist($this->mutex->getFile());
$exceptionMessage = $e->getMessage();
}

$this->assertSame(
PHP_VERSION_ID >= 80000 ? 'Undefined variable $undefined' : 'Undefined variable: undefined',
$exceptionMessage,
);
$this->assertTrue($result);
$this->assertFileDoesNotExist($this->mutex->getFile());
}
}
Loading