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
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.php-cs-fixer.dist.php export-ignore
/.phpunit-watcher.yml export-ignore
/.styleci.yml export-ignore
/infection.json.dist export-ignore
/phpunit.xml.dist export-ignore
/psalm.xml export-ignore
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/rector-cs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Rector + PHP CS Fixer

on:
pull_request:
paths:
- 'src/**'
- 'tests/**'
- '.github/workflows/rector-cs.yml'
- 'composer.json'
- 'rector.php'
- '.php-cs-fixer.dist.php'

permissions:
contents: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
rector:
uses: yiisoft/actions/.github/workflows/rector-cs.yml@master
with:
php: '8.1'
24 changes: 0 additions & 24 deletions .github/workflows/rector.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ composer.phar
/phpunit.phar
/phpunit.xml
/.phpunit.cache

# PHP CS Fixer
/.php-cs-fixer.cache
21 changes: 21 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

use PhpCsFixer\Finder;
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
use Yiisoft\CodeStyle\ConfigBuilder;

$finder = (new Finder())->in([
__DIR__ . '/src',
__DIR__ . '/tests',
]);

return ConfigBuilder::build()
->setRiskyAllowed(true)
->setParallelConfig(ParallelConfigFactory::detect())
->setRules([
'@Yiisoft/Core' => true,
'@Yiisoft/Core:risky' => true,
])
->setFinder($finder);
85 changes: 0 additions & 85 deletions .styleci.yml

This file was deleted.

2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

- Enh #110: Bump `yiisoft/rbac` version to `^2.1` (@vjik)
- Chg #111: Change PHP constraint in `composer.json` to `8.1 - 8.4` (@vjik)
- Enh #115: Apply code style fixes (@vjik)
- Enh #115: Explicitly import functions and constants in "use" section (@vjik)

## 2.0.0 March 07, 2024

Expand Down
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@
"yiisoft/var-dumper": "^1.7"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.95",
"maglnet/composer-require-checker": "^4.7.1",
"phpunit/phpunit": "^10.5.45",
"psr/clock": "^1.0",
"rector/rector": "^2.0.11",
"roave/infection-static-analysis-plugin": "^1.35",
"spatie/phpunit-watcher": "^1.24",
"vimeo/psalm": "^5.26.1 || ^6.10",
"yiisoft/code-style": "^1.0",
"yiisoft/files": "^1.0.2"
},
"autoload": {
Expand All @@ -61,6 +63,8 @@
}
},
"scripts": {
"cs-fix": "php-cs-fixer fix",
"rector": "rector",
"test": "phpunit --testdox --no-interaction",
"test-watch": "phpunit-watcher watch"
}
Expand Down
6 changes: 3 additions & 3 deletions src/ConcurrentAssignmentsStorageDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ final class ConcurrentAssignmentsStorageDecorator implements AssignmentsStorageI
/**
* @param AssignmentsStorageInterface&FileStorageInterface $storage
*/
public function __construct(private AssignmentsStorageInterface|FileStorageInterface $storage)
{
}
public function __construct(
private AssignmentsStorageInterface|FileStorageInterface $storage,
) {}

public function getAll(): array
{
Expand Down
6 changes: 3 additions & 3 deletions src/ConcurrentItemsStorageDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ final class ConcurrentItemsStorageDecorator implements ItemsStorageInterface, Fi
/**
* @param FileStorageInterface&ItemsStorageInterface $storage
*/
public function __construct(private ItemsStorageInterface|FileStorageInterface $storage)
{
}
public function __construct(
private ItemsStorageInterface|FileStorageInterface $storage,
) {}

public function clear(): void
{
Expand Down
6 changes: 5 additions & 1 deletion src/FileStorageTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

use function dirname;
use function function_exists;
use function is_int;
use function sprintf;

use const LOCK_EX;

trait FileStorageTrait
{
Expand Down Expand Up @@ -97,6 +101,6 @@ private function invalidateScriptCache(): void
private function initFileProperties(string $filePath, ?callable $getFileUpdatedAt): void
{
$this->filePath = $filePath;
$this->getFileUpdatedAt = $getFileUpdatedAt ?? static fn (string $filePath): int|false => @filemtime($filePath);
$this->getFileUpdatedAt = $getFileUpdatedAt ?? static fn(string $filePath): int|false => @filemtime($filePath);
}
}
2 changes: 1 addition & 1 deletion tests/AssignmentsStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testGetFileUpdatedAtException(): void
$this->expectExceptionMessage('getFileUpdatedAt callable must return a UNIX timestamp.');
new AssignmentsStorage(
$this->getAssignmentsStorageFilePath(),
getFileUpdatedAt: static fn (string $filePath): string => 'test',
getFileUpdatedAt: static fn(string $filePath): string => 'test',
);
}

Expand Down
2 changes: 2 additions & 0 deletions tests/AssignmentsStorageWithConcurrencyHandledTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use Yiisoft\Rbac\Php\ItemsStorage;
use Yiisoft\Rbac\Tests\Common\AssignmentsStorageTestTrait;

use function count;

final class AssignmentsStorageWithConcurrencyHandledTest extends TestCase
{
use AssignmentsStorageTestTrait {
Expand Down
2 changes: 2 additions & 0 deletions tests/AssignmentsStorageWithConcurrencyNotHandled.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use Yiisoft\Rbac\Php\ItemsStorage;
use Yiisoft\Rbac\Tests\Common\AssignmentsStorageTestTrait;

use function count;

final class AssignmentsStorageWithConcurrencyNotHandled extends TestCase
{
use AssignmentsStorageTestTrait {
Expand Down
6 changes: 4 additions & 2 deletions tests/ItemsStorage/ItemsStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

use function in_array;

use const DIRECTORY_SEPARATOR;

final class ItemsStorageTest extends TestCase
{
use ItemsStorageTestTrait {
Expand Down Expand Up @@ -93,7 +95,7 @@ public function testLoadWithCustomGetFileUpdatedAt(): void

$storage = new ItemsStorage(
$this->getItemsStorageFilePath(),
getFileUpdatedAt: static fn (string $filePath): int|false => $time,
getFileUpdatedAt: static fn(string $filePath): int|false => $time,
);
$this->assertSame($time, $storage->get('test')->getCreatedAt());
}
Expand All @@ -104,7 +106,7 @@ public function testGetFileUpdatedAtException(): void
$this->expectExceptionMessage('getFileUpdatedAt callable must return a UNIX timestamp.');
new ItemsStorage(
$this->getItemsStorageFilePath(),
getFileUpdatedAt: static fn (string $filePath): string => 'test',
getFileUpdatedAt: static fn(string $filePath): string => 'test',
);
}

Expand Down
2 changes: 2 additions & 0 deletions tests/ItemsStorageWithConcurrencyHandledTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use Yiisoft\Rbac\Role;
use Yiisoft\Rbac\Tests\Common\ItemsStorageTestTrait;

use function count;

final class ItemsStorageWithConcurrencyHandledTest extends TestCase
{
use ItemsStorageTestTrait {
Expand Down
2 changes: 2 additions & 0 deletions tests/ItemsStorageWithConcurrencyNotHandledTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
use Yiisoft\Rbac\Role;
use Yiisoft\Rbac\Tests\Common\ItemsStorageTestTrait;

use function count;

final class ItemsStorageWithConcurrencyNotHandledTest extends TestCase
{
use ItemsStorageTestTrait {
Expand Down
2 changes: 2 additions & 0 deletions tests/StorageFilePathTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

use Yiisoft\Files\FileHelper;

use const DIRECTORY_SEPARATOR;

trait StorageFilePathTrait
{
private ?string $dataPath = null;
Expand Down
6 changes: 2 additions & 4 deletions tests/Support/TestHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@

final class TestHelper
{
private function __construct()
{
}
private function __construct() {}

public static function getCurrentErrorHandler(): callable|null
public static function getCurrentErrorHandler(): ?callable
{
$currentHandler = set_error_handler(static fn() => true);
restore_error_handler();
Expand Down
Loading