From 8e99911a2e356a0f9787522495f598cfed21eb03 Mon Sep 17 00:00:00 2001 From: lotyp Date: Sun, 26 May 2024 13:52:56 +0300 Subject: [PATCH 1/5] ci: add php cs fixer config --- .github/workflows/coding-standards.yml | 196 +++++++++++++++++++++++++ 1 file changed, 196 insertions(+) create mode 100644 .github/workflows/coding-standards.yml diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml new file mode 100644 index 00000000..39250203 --- /dev/null +++ b/.github/workflows/coding-standards.yml @@ -0,0 +1,196 @@ +--- + +on: # yamllint disable-line rule:truthy + pull_request: + branches: + - master + push: + branches: + - master + +name: ๐Ÿงน Fix PHP coding standards + +jobs: + commit-linting: + timeout-minutes: 4 + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4.1.6 + + - name: ๐Ÿง Lint commits using "commitlint" + uses: wagoid/commitlint-github-action@v6.0.1 + with: + configFile: ${{ github.workspace }}/.github/.commitlint.config.mjs + failOnWarnings: false + failOnErrors: false + helpURL: 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint' + + yaml-linting: + timeout-minutes: 4 + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4.1.6 + + - name: ๐Ÿง Lint YAML files + uses: ibiqlik/action-yamllint@v3.1.1 + with: + config_file: .github/.yamllint.yaml + file_or_dir: '.' + strict: true + + markdown-linting: + timeout-minutes: 4 + runs-on: ubuntu-latest + concurrency: + cancel-in-progress: true + group: markdown-linting-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4.1.6 + + - name: ๐Ÿง Lint Markdown files + uses: DavidAnson/markdownlint-cli2-action@v16.0.0 + with: + globs: | + **/*.md + !CHANGELOG.md + + composer-linting: + timeout-minutes: 4 + runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: composer-linting-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + strategy: + matrix: + os: + - ubuntu-latest + php-version: + - '8.2' + dependencies: + - locked + permissions: + contents: write + steps: + - name: ๐Ÿ› ๏ธ Setup PHP + uses: shivammathur/setup-php@2.30.4 + with: + php-version: ${{ matrix.php-version }} + extensions: none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter, phar, sockets + ini-values: error_reporting=E_ALL + coverage: none + tools: phive + + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4.1.6 + + - name: ๐Ÿ› ๏ธ Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: ๐Ÿค– Validate composer.json and composer.lock + run: composer validate --ansi --strict + + - name: ๐Ÿ” Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.0 + + - name: โ™ป๏ธ Restore cached dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies with composer + uses: wayofdev/gh-actions/actions/composer/install@v3.1.0 + with: + dependencies: ${{ matrix.dependencies }} + + - name: ๐Ÿ“ฅ Install dependencies with phive + uses: wayofdev/gh-actions/actions/phive/install@v3.1.0 + with: + phive-home: '.phive' + trust-gpg-keys: '0xC00543248C87FB13,0x033E5F8D801A2F8D' + + - name: ๐Ÿ” Run ergebnis/composer-normalize + run: .phive/composer-normalize --ansi --dry-run + + coding-standards: + timeout-minutes: 4 + runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: coding-standards-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + strategy: + matrix: + os: + - ubuntu-latest + php-version: + - '8.2' + dependencies: + - locked + permissions: + contents: write + steps: + - name: โš™๏ธ Set git to use LF line endings + run: | + git config --global core.autocrlf false + git config --global core.eol lf + + - name: ๐Ÿ› ๏ธ Setup PHP + uses: shivammathur/setup-php@2.30.4 + with: + php-version: ${{ matrix.php-version }} + extensions: none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter, sockets + ini-values: error_reporting=E_ALL + coverage: none + + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4.1.6 + + - name: ๐Ÿ› ๏ธ Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: ๐Ÿค– Validate composer.json and composer.lock + run: composer validate --ansi --strict + + - name: ๐Ÿ” Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.0 + + - name: โ™ป๏ธ Restore cached dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies with composer + uses: wayofdev/gh-actions/actions/composer/install@v3.1.0 + with: + dependencies: ${{ matrix.dependencies }} + + - name: ๐Ÿ› ๏ธ Prepare environment + run: make prepare + + - name: ๐Ÿšจ Run coding standards task + run: composer cs:fix + env: + PHP_CS_FIXER_IGNORE_ENV: true + + - name: ๐Ÿ“ค Commit and push changed files back to GitHub + uses: stefanzweifel/git-auto-commit-action@v5.0.1 + with: + commit_message: 'style(php-cs-fixer): lint php files and fix coding standards' + branch: ${{ github.head_ref }} + commit_author: 'github-actions ' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From be6096d84b351c7a91edd106284328ebe5764ca0 Mon Sep 17 00:00:00 2001 From: lotyp Date: Sun, 26 May 2024 14:23:14 +0300 Subject: [PATCH 2/5] ci: fix coding standards workflow --- .github/workflows/coding-standards.yml | 2 +- package.json | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) delete mode 100644 package.json diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 39250203..ee5b9537 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -84,7 +84,7 @@ jobs: uses: shivammathur/setup-php@2.30.4 with: php-version: ${{ matrix.php-version }} - extensions: none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter, phar, sockets + extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql ini-values: error_reporting=E_ALL coverage: none tools: phive diff --git a/package.json b/package.json deleted file mode 100644 index 16db6aa2..00000000 --- a/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "version": "4.11.4", - "repository": { - "url": "https://github.com/wayofdev/laravel-cycle-orm-adapter.git" - } -} From b6650670eff7d8ca8462fba820c9c2be9be6fb2d Mon Sep 17 00:00:00 2001 From: lotyp Date: Sun, 26 May 2024 14:26:46 +0300 Subject: [PATCH 3/5] ci: move yaml config --- .yamllint.yaml => .github/.yamllint.yaml | 0 Makefile | 1 + 2 files changed, 1 insertion(+) rename .yamllint.yaml => .github/.yamllint.yaml (100%) diff --git a/.yamllint.yaml b/.github/.yamllint.yaml similarity index 100% rename from .yamllint.yaml rename to .github/.yamllint.yaml diff --git a/Makefile b/Makefile index d918bfdf..0e820b88 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,7 @@ ENVSUBST ?= $(BUILDER) envsubst YAML_LINT_RUNNER ?= $(DOCKER) run --rm $$(tty -s && echo "-it" || echo) \ -v $(PWD):/data \ cytopia/yamllint:latest \ + -c ./.github/.yamllint.yaml \ -f colored . ACTION_LINT_RUNNER ?= $(DOCKER) run --rm $$(tty -s && echo "-it" || echo) \ From 07382b61306a717e9b7e148bf2f724b77fb2335d Mon Sep 17 00:00:00 2001 From: lotyp Date: Sun, 26 May 2024 14:40:04 +0300 Subject: [PATCH 4/5] ci: fixes in cs-config workflow --- .github/workflows/coding-standards.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index ee5b9537..ed776c70 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -149,7 +149,7 @@ jobs: uses: shivammathur/setup-php@2.30.4 with: php-version: ${{ matrix.php-version }} - extensions: none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter, sockets + extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql ini-values: error_reporting=E_ALL coverage: none From 4446383bdce5a80abdbeefd4d2a22d73144425fe Mon Sep 17 00:00:00 2001 From: github-actions Date: Sun, 26 May 2024 11:40:36 +0000 Subject: [PATCH 5/5] style(php-cs-fixer): lint php files and fix coding standards --- .../Console/Commands/Database/ListCommand.php | 2 +- .../Console/Commands/Database/TableCommand.php | 2 +- .../Console/Commands/Migrations/MigrateCommand.php | 2 +- .../Commands/Migrations/RollbackCommand.php | 2 +- .../Console/Commands/Migrations/StatusCommand.php | 1 + .../Laravel/Providers/CycleServiceProvider.php | 2 +- src/Bridge/Laravel/Providers/Registrator.php | 7 +++++++ src/Bridge/Laravel/Rules/Exists.php | 2 +- src/Bridge/Laravel/Rules/Unique.php | 2 +- .../Telescope/Events/Database/QueryExecuted.php | 2 +- src/Bridge/Telescope/TelescopeLogger.php | 2 +- src/Bridge/Telescope/Watchers/QueryWatcher.php | 2 +- src/Contracts/GeneratorLoader.php | 2 ++ src/Schema/Compiler.php | 12 ++++++------ src/Schema/Generators/GeneratorQueue.php | 4 +++- src/Testing/Constraints/HasInDatabase.php | 2 +- .../Constraints/NotSoftDeletedInDatabase.php | 2 +- src/Testing/Constraints/SoftDeletedInDatabase.php | 2 +- tests/app/Entities/Footprint.php | 14 +++++++------- tests/app/Entities/Signature.php | 12 ++++++------ tests/app/Entities/UserId.php | 10 +++++----- tests/src/Bridge/Laravel/LoggerFactoryTest.php | 2 +- 22 files changed, 51 insertions(+), 39 deletions(-) diff --git a/src/Bridge/Laravel/Console/Commands/Database/ListCommand.php b/src/Bridge/Laravel/Console/Commands/Database/ListCommand.php index e1c1f380..badfe4b5 100644 --- a/src/Bridge/Laravel/Console/Commands/Database/ListCommand.php +++ b/src/Bridge/Laravel/Console/Commands/Database/ListCommand.php @@ -48,7 +48,7 @@ public function handle(DatabaseConfig $config, DatabaseProviderInterface $dbal): $databaseArgumentValue = $this->argument('db'); /** @var array $databases */ - $databases = (null !== $databaseArgumentValue) + $databases = ($databaseArgumentValue !== null) ? [$databaseArgumentValue] : array_keys($config->getDatabases()); diff --git a/src/Bridge/Laravel/Console/Commands/Database/TableCommand.php b/src/Bridge/Laravel/Console/Commands/Database/TableCommand.php index 51333c40..692d9793 100644 --- a/src/Bridge/Laravel/Console/Commands/Database/TableCommand.php +++ b/src/Bridge/Laravel/Console/Commands/Database/TableCommand.php @@ -226,7 +226,7 @@ private function describeType(AbstractColumn $column): string $type .= " ({$column->getSize()})"; } - if ('decimal' === $abstractType) { + if ($abstractType === 'decimal') { $type .= " ({$column->getPrecision()}, {$column->getScale()})"; } diff --git a/src/Bridge/Laravel/Console/Commands/Migrations/MigrateCommand.php b/src/Bridge/Laravel/Console/Commands/Migrations/MigrateCommand.php index ce86d801..436dfb5b 100644 --- a/src/Bridge/Laravel/Console/Commands/Migrations/MigrateCommand.php +++ b/src/Bridge/Laravel/Console/Commands/Migrations/MigrateCommand.php @@ -32,7 +32,7 @@ public function handle(): int $found = false; $count = $this->option('one') ? 1 : PHP_INT_MAX; - while (0 < $count && null !== ($migration = $this->migrator->run())) { + while ($count > 0 && null !== ($migration = $this->migrator->run())) { $found = true; --$count; diff --git a/src/Bridge/Laravel/Console/Commands/Migrations/RollbackCommand.php b/src/Bridge/Laravel/Console/Commands/Migrations/RollbackCommand.php index 7300f2fe..7ec6d67d 100644 --- a/src/Bridge/Laravel/Console/Commands/Migrations/RollbackCommand.php +++ b/src/Bridge/Laravel/Console/Commands/Migrations/RollbackCommand.php @@ -33,7 +33,7 @@ public function handle(): int $found = false; $count = ! $this->option('all') ? 1 : PHP_INT_MAX; try { - while (0 < $count && null !== ($migration = $this->migrator->rollback())) { + while ($count > 0 && null !== ($migration = $this->migrator->rollback())) { $found = true; --$count; $this->line( diff --git a/src/Bridge/Laravel/Console/Commands/Migrations/StatusCommand.php b/src/Bridge/Laravel/Console/Commands/Migrations/StatusCommand.php index 06dabd8b..72b4fc08 100644 --- a/src/Bridge/Laravel/Console/Commands/Migrations/StatusCommand.php +++ b/src/Bridge/Laravel/Console/Commands/Migrations/StatusCommand.php @@ -16,6 +16,7 @@ final class StatusCommand extends AbstractCommand { private const DATE_TIME_FORMAT = 'Y-m-d H:i:s'; + private const PENDING = 'not executed yet'; protected $signature = 'cycle:migrate:status'; diff --git a/src/Bridge/Laravel/Providers/CycleServiceProvider.php b/src/Bridge/Laravel/Providers/CycleServiceProvider.php index 3060f502..a27edde1 100644 --- a/src/Bridge/Laravel/Providers/CycleServiceProvider.php +++ b/src/Bridge/Laravel/Providers/CycleServiceProvider.php @@ -38,7 +38,7 @@ public function boot(): void $config = $this->app->get(IlluminateConfig::class); $warmup = $config->get('cycle.warmup'); - if (true === $warmup) { + if ($warmup === true) { /** @var CycleORM $orm */ $orm = $this->app->get(ORMInterface::class); $orm->prepareServices(); diff --git a/src/Bridge/Laravel/Providers/Registrator.php b/src/Bridge/Laravel/Providers/Registrator.php index 76309513..617f7cd4 100644 --- a/src/Bridge/Laravel/Providers/Registrator.php +++ b/src/Bridge/Laravel/Providers/Registrator.php @@ -7,11 +7,18 @@ interface Registrator { public const CFG_KEY = 'cycle'; + public const CFG_KEY_DATABASE = 'cycle.database'; + public const CFG_KEY_TOKENIZER = 'cycle.tokenizer'; + public const CFG_KEY_ATTRIBUTES = 'cycle.attributes'; + public const CFG_KEY_MIGRATIONS = 'cycle.migrations'; + public const CFG_KEY_SCHEMA = 'cycle.schema'; + public const CFG_KEY_WARMUP = 'cycle.warmup'; + public const CFG_KEY_RELATIONS = 'cycle.customRelations'; } diff --git a/src/Bridge/Laravel/Rules/Exists.php b/src/Bridge/Laravel/Rules/Exists.php index 93f9ab31..b51e6237 100644 --- a/src/Bridge/Laravel/Rules/Exists.php +++ b/src/Bridge/Laravel/Rules/Exists.php @@ -31,7 +31,7 @@ public function validate(string $attribute, mixed $value, Closure $fail): void $count = $table->where([$this->column => $value])->count(); - if (0 === $count) { + if ($count === 0) { $fail($this->message()); } } diff --git a/src/Bridge/Laravel/Rules/Unique.php b/src/Bridge/Laravel/Rules/Unique.php index ff419cf6..a78baa3d 100644 --- a/src/Bridge/Laravel/Rules/Unique.php +++ b/src/Bridge/Laravel/Rules/Unique.php @@ -31,7 +31,7 @@ public function validate(string $attribute, mixed $value, Closure $fail): void $count = $table->where([$this->column => $value])->count(); - if (0 < $count) { + if ($count > 0) { $fail($this->message()); } } diff --git a/src/Bridge/Telescope/Events/Database/QueryExecuted.php b/src/Bridge/Telescope/Events/Database/QueryExecuted.php index cfc249c5..9132f922 100644 --- a/src/Bridge/Telescope/Events/Database/QueryExecuted.php +++ b/src/Bridge/Telescope/Events/Database/QueryExecuted.php @@ -13,6 +13,6 @@ final class QueryExecuted public function __construct(public string $sql, public array $bindings, public ?float $time, public ?string $driver = null) { $this->time = $time * 1000; - $this->driver = null !== $driver ? 'CycleORM/' . $driver : 'CycleORM'; + $this->driver = $driver !== null ? 'CycleORM/' . $driver : 'CycleORM'; } } diff --git a/src/Bridge/Telescope/TelescopeLogger.php b/src/Bridge/Telescope/TelescopeLogger.php index 5ca7bda0..f0b14dcd 100644 --- a/src/Bridge/Telescope/TelescopeLogger.php +++ b/src/Bridge/Telescope/TelescopeLogger.php @@ -21,7 +21,7 @@ public function log($level, $message, array $context = []): void { $this->parentLogger->log($level, $message, $context); - if ('info' === $level && isset($context['elapsed'])) { + if ($level === 'info' && isset($context['elapsed'])) { event( new QueryExecuted( sql: $message, diff --git a/src/Bridge/Telescope/Watchers/QueryWatcher.php b/src/Bridge/Telescope/Watchers/QueryWatcher.php index e3e544cf..676e40f7 100644 --- a/src/Bridge/Telescope/Watchers/QueryWatcher.php +++ b/src/Bridge/Telescope/Watchers/QueryWatcher.php @@ -32,7 +32,7 @@ public function recordQuery(QueryExecuted $event): void $time = $event->time; $caller = $this->getCallerFromStackTrace(); - if (null !== $caller) { + if ($caller !== null) { Telescope::recordQuery(IncomingEntry::make([ 'connection' => $event->driver, 'bindings' => $event->bindings, diff --git a/src/Contracts/GeneratorLoader.php b/src/Contracts/GeneratorLoader.php index cc1cd0d8..3266e78f 100644 --- a/src/Contracts/GeneratorLoader.php +++ b/src/Contracts/GeneratorLoader.php @@ -9,7 +9,9 @@ interface GeneratorLoader { public const GROUP_INDEX = 'index'; + public const GROUP_RENDER = 'render'; + public const GROUP_POSTPROCESS = 'postprocess'; /** diff --git a/src/Schema/Compiler.php b/src/Schema/Compiler.php index 1466389b..250772be 100644 --- a/src/Schema/Compiler.php +++ b/src/Schema/Compiler.php @@ -17,6 +17,11 @@ final class Compiler { private const EMPTY_SCHEMA = ':empty:'; + public function __construct( + private readonly mixed $schema + ) { + } + public static function compile(Registry $registry, GeneratorLoader $queue): self { return new self((new CycleSchemaCompiler())->compile($registry, $queue->get())); @@ -27,14 +32,9 @@ public static function fromMemory(CacheManager $cache): self return new self($cache->get()); } - public function __construct( - private readonly mixed $schema - ) { - } - public function isEmpty(): bool { - return null === $this->schema || [] === $this->schema || self::EMPTY_SCHEMA === $this->schema; + return $this->schema === null || $this->schema === [] || $this->schema === self::EMPTY_SCHEMA; } public function toSchema(): SchemaInterface diff --git a/src/Schema/Generators/GeneratorQueue.php b/src/Schema/Generators/GeneratorQueue.php index 13d393a4..563978b6 100644 --- a/src/Schema/Generators/GeneratorQueue.php +++ b/src/Schema/Generators/GeneratorQueue.php @@ -16,7 +16,9 @@ final class GeneratorQueue implements GeneratorLoader { - /** @var array>> */ + /** + * @var array>> + */ private array $generators; private Container $app; diff --git a/src/Testing/Constraints/HasInDatabase.php b/src/Testing/Constraints/HasInDatabase.php index 47fe46a0..3f9426ec 100644 --- a/src/Testing/Constraints/HasInDatabase.php +++ b/src/Testing/Constraints/HasInDatabase.php @@ -37,7 +37,7 @@ public function matches(mixed $other): bool try { $count = $tableInterface->where($this->data)->count(); - return 0 < $count; + return $count > 0; } catch (Throwable $e) { return false; } diff --git a/src/Testing/Constraints/NotSoftDeletedInDatabase.php b/src/Testing/Constraints/NotSoftDeletedInDatabase.php index 218f0b8b..ef756f03 100644 --- a/src/Testing/Constraints/NotSoftDeletedInDatabase.php +++ b/src/Testing/Constraints/NotSoftDeletedInDatabase.php @@ -42,7 +42,7 @@ public function matches(mixed $other): bool ->andWhere($this->deletedAtColumn, '=', null) ->count(); - return 0 < $count; + return $count > 0; } catch (Throwable $e) { return false; } diff --git a/src/Testing/Constraints/SoftDeletedInDatabase.php b/src/Testing/Constraints/SoftDeletedInDatabase.php index 6404df49..510c2cf8 100644 --- a/src/Testing/Constraints/SoftDeletedInDatabase.php +++ b/src/Testing/Constraints/SoftDeletedInDatabase.php @@ -42,7 +42,7 @@ public function matches(mixed $other): bool ->andWhere($this->deletedAtColumn, '!=', null) ->count(); - return 0 < $count; + return $count > 0; } catch (Throwable $e) { return false; } diff --git a/tests/app/Entities/Footprint.php b/tests/app/Entities/Footprint.php index 59347e6e..34b8c3b5 100644 --- a/tests/app/Entities/Footprint.php +++ b/tests/app/Entities/Footprint.php @@ -21,6 +21,13 @@ final class Footprint implements JsonSerializable, Stringable private readonly string $realm; + private function __construct(UserId $id, string $party, string $realm) + { + $this->id = $id; + $this->party = $party; + $this->realm = $realm; + } + public static function empty(string $authorizedParty = 'guest-party', string $realm = 'guest-realm'): self { return new self(UserId::create(Uuid::NIL), $authorizedParty, $realm); @@ -86,11 +93,4 @@ public function __toString(): string { return json_encode($this->toArray(), JSON_THROW_ON_ERROR); } - - private function __construct(UserId $id, string $party, string $realm) - { - $this->id = $id; - $this->party = $party; - $this->realm = $realm; - } } diff --git a/tests/app/Entities/Signature.php b/tests/app/Entities/Signature.php index 76c9d7e7..585da467 100644 --- a/tests/app/Entities/Signature.php +++ b/tests/app/Entities/Signature.php @@ -25,6 +25,12 @@ class Signature #[Column(type: 'json', nullable: true, typecast: [Footprint::class, 'castValue'])] private ?Footprint $by = null; + public function __construct(?DateTimeImmutable $at, ?Footprint $by) + { + $this->at = $at; + $this->by = $by; + } + public static function forGuest(): self { return new self(new DateTimeImmutable(), Footprint::empty()); @@ -78,10 +84,4 @@ public function toArray(): array 'by' => $this->by?->toArray(), ]; } - - public function __construct(?DateTimeImmutable $at, ?Footprint $by) - { - $this->at = $at; - $this->by = $by; - } } diff --git a/tests/app/Entities/UserId.php b/tests/app/Entities/UserId.php index e79747bd..24dce8cf 100644 --- a/tests/app/Entities/UserId.php +++ b/tests/app/Entities/UserId.php @@ -11,6 +11,11 @@ final class UserId implements Stringable { private readonly string $id; + private function __construct(string $id) + { + $this->id = $id; + } + public static function create(string $userId): self { return new self($userId); @@ -35,9 +40,4 @@ public function __toString(): string { return $this->toString(); } - - private function __construct(string $id) - { - $this->id = $id; - } } diff --git a/tests/src/Bridge/Laravel/LoggerFactoryTest.php b/tests/src/Bridge/Laravel/LoggerFactoryTest.php index 8bf233f9..eedb725e 100644 --- a/tests/src/Bridge/Laravel/LoggerFactoryTest.php +++ b/tests/src/Bridge/Laravel/LoggerFactoryTest.php @@ -78,7 +78,7 @@ public function it_should_fire_query_executed_event_when_query_is_logged(): void // Assert that the QueryExecuted event was dispatched Event::assertDispatched(QueryExecuted::class, function ($event) { - return 'SELECT * FROM users' === $event->sql; + return $event->sql === 'SELECT * FROM users'; }); }