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
28 changes: 28 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,34 @@ jobs:
- name: PHPStan
run: composer analyze

refactor:
name: Checks / Refactor
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: swoole
coverage: none

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"

- uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ hashFiles('composer.lock') }}
restore-keys: composer-

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-interaction --ignore-platform-req=ext-opentelemetry

- name: Rector (dry run)
run: composer refactor:check

unit:
name: Tests / Unit / PHP ${{ matrix.php }}
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
"format": "vendor/bin/pint",
"format:check": "vendor/bin/pint --test",
"analyze": "vendor/bin/phpstan analyse -c phpstan.neon --memory-limit 512M",
"refactor": "vendor/bin/rector process",
"refactor:check": "vendor/bin/rector process --dry-run",
"test": "vendor/bin/phpunit --configuration phpunit.xml"
},
"require": {
Expand Down Expand Up @@ -54,6 +56,7 @@
"laravel/pint": "1.*",
"phpstan/phpstan": "^2.0",
"phpunit/phpunit": "^9.5.25",
"rector/rector": "^2.0",
"swoole/ide-helper": "4.8.3"
}
}
68 changes: 64 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 71 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector;
use Rector\CodeQuality\Rector\Ternary\SwitchNegatedTernaryRector;
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\Cast\RecastingRemovalRector;
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Rector\Php70\Rector\FuncCall\RandomFunctionRector;
use Rector\Php74\Rector\Property\RestoreDefaultNullToNullableTypePropertyRector;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
use Rector\Php82\Rector\Class_\ReadOnlyClassRector;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
use Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByParentCallTypeRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;

return RectorConfig::configure()
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
])
->withPhpSets(php83: true)
->withSets([
LevelSetList::UP_TO_PHP_83,
SetList::CODE_QUALITY,
SetList::DEAD_CODE,
SetList::EARLY_RETURN,
SetList::INSTANCEOF,
])
->withImportNames(importShortClasses: false, removeUnusedImports: true)
->withSkip([
// BC breaks in a published library
ReadOnlyPropertyRector::class,
ReadOnlyClassRector::class,

// Changes truthy semantics — "0", null, "" behave differently
ExplicitBoolCompareRector::class,
SimplifyEmptyCheckOnEmptyArrayRector::class,

// Can throw TypeError on previously-working callers (library is public API)
TypedPropertyFromAssignsRector::class,
TypedPropertyFromStrictConstructorRector::class,
ParamTypeByParentCallTypeRector::class,

// Different distribution and failure mode than rand()
RandomFunctionRector::class,

// Subtle casting/control-flow shifts — apply manually
RecastingRemovalRector::class,
FlipTypeControlToUseExclusiveTypeRector::class,
SwitchNegatedTernaryRector::class,
StringClassNameToClassConstantRector::class,

// Promoted properties / nullable defaults — BC shape changes for library
ClassPropertyAssignToConstructorPromotionRector::class,
RestoreDefaultNullToNullableTypePropertyRector::class,

// empty() replacement rarely covers every falsy case Rector's type info misses
DisallowedEmptyRuleFixerRector::class,

// Throws TypeError when args are objects/arrays — review per-call
NullToStrictStringFuncCallArgRector::class,
]);
2 changes: 2 additions & 0 deletions src/Http/Adapter.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Utopia\Http;

use Utopia\DI\Container;
Expand Down
Loading
Loading