Skip to content

Commit

Permalink
Declare strict types
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Dec 5, 2024
1 parent a98afa2 commit ca35eef
Show file tree
Hide file tree
Showing 16 changed files with 34 additions and 12 deletions.
10 changes: 1 addition & 9 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,12 @@
'return_assignment' => false,
'comment_to_phpdoc' => false,
'general_phpdoc_annotation_remove' => [
'annotations' => ['author', 'copyright', 'throws'],
'annotations' => ['author', 'copyright'],
],

// fn => without curly brackets is less readable,
// also prevent bounding of unwanted variables for GC
'use_arrow_functions' => false,

// TODO disable too strict rules for now
'declare_strict_types' => false,
'general_phpdoc_annotation_remove' => false,
'php_unit_data_provider_static' => false,
'php_unit_strict' => false,
'phpdoc_to_comment' => false,
'strict_comparison' => false,
])
->setFinder($finder)
->setCacheFile(sys_get_temp_dir() . '/php-cs-fixer.' . md5(__DIR__) . '.cache');
2 changes: 2 additions & 0 deletions tests/mutex/CASMutexTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace malkusch\lock\Tests\mutex;

use malkusch\lock\exception\LockAcquireException;
Expand Down
2 changes: 2 additions & 0 deletions tests/mutex/FlockMutexTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace malkusch\lock\Tests\mutex;

use Eloquent\Liberator\Liberator;
Expand Down
2 changes: 2 additions & 0 deletions tests/mutex/LockMutexTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace malkusch\lock\Tests\mutex;

use malkusch\lock\exception\LockAcquireException;
Expand Down
2 changes: 2 additions & 0 deletions tests/mutex/MemcachedMutexTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace malkusch\lock\Tests\mutex;

use malkusch\lock\exception\LockReleaseException;
Expand Down
2 changes: 2 additions & 0 deletions tests/mutex/MutexConcurrencyTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace malkusch\lock\Tests\mutex;

use Eloquent\Liberator\Liberator;
Expand Down
2 changes: 2 additions & 0 deletions tests/mutex/MutexTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace malkusch\lock\Tests\mutex;

use Eloquent\Liberator\Liberator;
Expand Down
2 changes: 2 additions & 0 deletions tests/mutex/PHPRedisMutexTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace malkusch\lock\Tests\mutex;

use malkusch\lock\exception\LockAcquireException;
Expand Down
2 changes: 2 additions & 0 deletions tests/mutex/PgAdvisoryLockMutexTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace malkusch\lock\Tests\mutex;

use malkusch\lock\mutex\PgAdvisoryLockMutex;
Expand Down
2 changes: 2 additions & 0 deletions tests/mutex/PredisMutexTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace malkusch\lock\Tests\mutex;

use malkusch\lock\exception\LockAcquireException;
Expand Down
2 changes: 2 additions & 0 deletions tests/mutex/RedisMutexTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace malkusch\lock\Tests\mutex;

use malkusch\lock\exception\LockAcquireException;
Expand Down
2 changes: 2 additions & 0 deletions tests/mutex/SpinlockMutexTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace malkusch\lock\Tests\mutex;

use malkusch\lock\exception\ExecutionOutsideLockException;
Expand Down
8 changes: 5 additions & 3 deletions tests/mutex/TransactionalMutexTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace malkusch\lock\Tests\mutex;

use malkusch\lock\exception\LockAcquireException;
Expand Down Expand Up @@ -81,7 +83,7 @@ public function testExceptionRollsback(): void
}

$count = $pdo->query('SELECT count(*) FROM testExceptionRollsback')->fetchColumn();
self::assertEquals(0, $count);
self::assertSame(0, \PHP_VERSION_ID < 8_10_00 ? (int) $count : $count);

Check failure on line 86 in tests/mutex/TransactionalMutexTest.php

View workflow job for this annotation

GitHub Actions / Smoke (latest, StaticAnalysis)

Comparison operation "<" between int<70400, 80400> and 81000 is always true.
}

/**
Expand Down Expand Up @@ -123,7 +125,7 @@ public function testReplayTransaction(\Exception $exception): void
++$i;

$count = $pdo->query('SELECT count(*) FROM testExceptionRollsback')->fetchColumn();
self::assertEquals(0, $count);
self::assertSame(0, \PHP_VERSION_ID < 8_10_00 ? (int) $count : $count);

Check failure on line 128 in tests/mutex/TransactionalMutexTest.php

View workflow job for this annotation

GitHub Actions / Smoke (latest, StaticAnalysis)

Comparison operation "<" between int<70400, 80400> and 81000 is always true.

$pdo->exec('INSERT INTO testExceptionRollsback VALUES(1)');

Expand All @@ -134,7 +136,7 @@ public function testReplayTransaction(\Exception $exception): void
});

$count = $pdo->query('SELECT count(*) FROM testExceptionRollsback')->fetchColumn();
self::assertEquals(1, $count);
self::assertSame(1, \PHP_VERSION_ID < 8_10_00 ? (int) $count : $count);

Check failure on line 139 in tests/mutex/TransactionalMutexTest.php

View workflow job for this annotation

GitHub Actions / Smoke (latest, StaticAnalysis)

Comparison operation "<" between int<70400, 80400> and 81000 is always true.

self::assertSame(5, $i);
}
Expand Down
2 changes: 2 additions & 0 deletions tests/util/DoubleCheckedLockingTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace malkusch\lock\Tests\util;

use malkusch\lock\mutex\Mutex;
Expand Down
2 changes: 2 additions & 0 deletions tests/util/LoopTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace malkusch\lock\Tests\util;

use malkusch\lock\exception\TimeoutException;
Expand Down
2 changes: 2 additions & 0 deletions tests/util/PcntlTimeoutTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace malkusch\lock\Tests\util;

use malkusch\lock\exception\DeadlineException;
Expand Down

0 comments on commit ca35eef

Please sign in to comment.