Skip to content

Commit

Permalink
Enable Rector CI + Apply changes + Minor refactoring (#719)
Browse files Browse the repository at this point in the history
Co-authored-by: Sergei Predvoditelev <[email protected]>
  • Loading branch information
dependabot[bot] and vjik authored Jun 20, 2023
1 parent e129d5e commit 25c1e46
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 22 deletions.
12 changes: 2 additions & 10 deletions .github/workflows/rector.yml_ → .github/workflows/rector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,13 @@ on:
- 'infection.json.dist'
- 'psalm.xml'

push:
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']
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"require-dev": {
"maglnet/composer-require-checker": "^4.2",
"phpunit/phpunit": "^9.6|^10.0",
"rector/rector": "^0.14",
"rector/rector": "^0.17",
"roave/infection-static-analysis-plugin": "^1.16",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30|^5.6",
Expand Down
11 changes: 9 additions & 2 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

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

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->disableParallel();

$rectorConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests',
Expand All @@ -21,4 +22,10 @@
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_80,
]);

$rectorConfig->skip([
ClosureToArrowFunctionRector::class,
AddDefaultValueForUndefinedVariableRector::class,
JsonThrowOnErrorRector::class,
]);
};
10 changes: 4 additions & 6 deletions src/Schema/AbstractColumnSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@
*/
abstract class AbstractColumnSchema implements ColumnSchemaInterface
{
public function __construct(string $name)
{
$this->name = $name;
}

private bool $allowNull = false;
private bool $autoIncrement = false;
private string|null $comment = null;
Expand All @@ -55,14 +50,17 @@ public function __construct(string $name)
private array|null $enumValues = null;
private string|null $extra = null;
private bool $isPrimaryKey = false;
private string $name;
private string|null $phpType = null;
private int|null $precision = null;
private int|null $scale = null;
private int|null $size = null;
private string $type = '';
private bool $unsigned = false;

public function __construct(private string $name)
{
}

public function allowNull(bool $value): void
{
$this->allowNull = $value;
Expand Down
4 changes: 2 additions & 2 deletions tests/AbstractCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public function testSetSql(): void
*/
public function testProfiler(string $sql = null): void
{
$sql = $sql ?? 'SELECT 123';
$sql ??= 'SELECT 123';

$db = $this->getConnection();
$db->open();
Expand All @@ -248,7 +248,7 @@ public function testProfiler(string $sql = null): void
*/
public function testProfilerData(string $sql = null): void
{
$sql = $sql ?? 'SELECT 123';
$sql ??= 'SELECT 123';

$db = $this->getConnection();
$db->open();
Expand Down
2 changes: 1 addition & 1 deletion tests/Db/Helper/DbStringHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class DbStringHelperTest extends TestCase
{
public function testBaseName(): void
{
$this->assertSame('TestCase', DbStringHelper::baseName('PHPUnit\Framework\TestCase'));
$this->assertSame('TestCase', DbStringHelper::baseName(TestCase::class));
$this->assertSame('TestCase', DbStringHelper::baseName('TestCase'));
}

Expand Down

0 comments on commit 25c1e46

Please sign in to comment.