Skip to content

Commit

Permalink
improve ignores I.
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Dec 3, 2024
1 parent 72e3aac commit 7b4427a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/mutex/PgAdvisoryLockMutex.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(\PDO $PDO, string $name)

$hashed_name = hash('sha256', $name, true);

if ($hashed_name === false) { // @phpstan-ignore-line
if ($hashed_name === false) { // @phpstan-ignoreX

Check failure on line 33 in src/mutex/PgAdvisoryLockMutex.php

View workflow job for this annotation

GitHub Actions / Smoke (latest, StaticAnalysis)

No error with identifier X is reported on line 33.

Check failure on line 33 in src/mutex/PgAdvisoryLockMutex.php

View workflow job for this annotation

GitHub Actions / Smoke (latest, StaticAnalysis)

Strict comparison using === between non-empty-string and false will always evaluate to false.
throw new \RuntimeException('Unable to hash the key, sha256 algorithm is not supported.');
}

Expand Down
4 changes: 2 additions & 2 deletions src/util/Loop.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ public function execute(callable $code)
$deadline = microtime(true) + $this->timeout;

$result = null;
for ($i = 0; $this->looping && microtime(true) < $deadline; ++$i) { // @phpstan-ignore-line
for ($i = 0; $this->looping && microtime(true) < $deadline; ++$i) { // @phpstan-ignoreX

Check failure on line 94 in src/util/Loop.php

View workflow job for this annotation

GitHub Actions / Smoke (latest, StaticAnalysis)

Left side of && is always true.

Check failure on line 94 in src/util/Loop.php

View workflow job for this annotation

GitHub Actions / Smoke (latest, StaticAnalysis)

No error with identifier X is reported on line 94.
$result = $code();
if (!$this->looping) { // @phpstan-ignore-line
if (!$this->looping) { // @phpstan-ignoreX

Check failure on line 96 in src/util/Loop.php

View workflow job for this annotation

GitHub Actions / Smoke (latest, StaticAnalysis)

Negated boolean expression is always false.

Check failure on line 96 in src/util/Loop.php

View workflow job for this annotation

GitHub Actions / Smoke (latest, StaticAnalysis)

No error with identifier X is reported on line 96.
// The $code callback has called $this->end() and the lock has been acquired.

return $result;
Expand Down
8 changes: 4 additions & 4 deletions tests/mutex/FlockMutexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected function setUp(): void
parent::setUp();

$this->file = tempnam(sys_get_temp_dir(), 'flock-');
$this->mutex = Liberator::liberate(new FlockMutex(fopen($this->file, 'r'), 1)); // @phpstan-ignore-line
$this->mutex = Liberator::liberate(new FlockMutex(fopen($this->file, 'r'), 1)); // @phpstan-ignoreX
}

protected function tearDown(): void
Expand All @@ -40,7 +40,7 @@ protected function tearDown(): void
*/
public function testCodeExecutedOutsideLockIsNotThrown(int $strategy)
{
$this->mutex->strategy = $strategy; // @phpstan-ignore-line
$this->mutex->strategy = $strategy; // @phpstan-ignoreX

self::assertTrue($this->mutex->synchronized(static function (): bool {
usleep(1100 * 1000);
Expand All @@ -60,7 +60,7 @@ public function testTimeoutOccurs(int $strategy)
$another_resource = fopen($this->file, 'r');
flock($another_resource, \LOCK_EX);

$this->mutex->strategy = $strategy; // @phpstan-ignore-line
$this->mutex->strategy = $strategy; // @phpstan-ignoreX

try {
$this->mutex->synchronized(
Expand Down Expand Up @@ -88,7 +88,7 @@ public function testNoTimeoutWaitsForever()
$another_resource = fopen($this->file, 'r');
flock($another_resource, \LOCK_EX);

$this->mutex->strategy = FlockMutex::STRATEGY_BLOCK; // @phpstan-ignore-line
$this->mutex->strategy = FlockMutex::STRATEGY_BLOCK; // @phpstan-ignoreX

$timebox = new PcntlTimeout(1);
$timebox->timeBoxed(function () {
Expand Down
4 changes: 2 additions & 2 deletions tests/mutex/MutexConcurrencyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,15 @@ public static function provideExecutionIsSerializedWhenLockedCases(): iterable
'flockWithTimoutPcntl' => [static function ($timeout = 3) use ($filename): Mutex {
$file = fopen($filename, 'w');
$lock = Liberator::liberate(new FlockMutex($file, $timeout));
$lock->strategy = FlockMutex::STRATEGY_PCNTL; // @phpstan-ignore-line
$lock->strategy = FlockMutex::STRATEGY_PCNTL; // @phpstan-ignoreX

return $lock->popsValue();
}],

'flockWithTimoutBusy' => [static function ($timeout = 3) use ($filename): Mutex {
$file = fopen($filename, 'w');
$lock = Liberator::liberate(new FlockMutex($file, $timeout));
$lock->strategy = FlockMutex::STRATEGY_BUSY; // @phpstan-ignore-line
$lock->strategy = FlockMutex::STRATEGY_BUSY; // @phpstan-ignoreX

return $lock->popsValue();
}],
Expand Down
4 changes: 2 additions & 2 deletions tests/mutex/MutexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ public function provideMutexFactoriesCases(): iterable
'flockWithTimoutPcntl' => [static function (): Mutex {
$file = fopen(vfsStream::url('test/lock'), 'w');
$lock = Liberator::liberate(new FlockMutex($file, 3));
$lock->strategy = FlockMutex::STRATEGY_PCNTL; // @phpstan-ignore-line
$lock->strategy = FlockMutex::STRATEGY_PCNTL; // @phpstan-ignoreX

return $lock->popsValue();
}],

'flockWithTimoutBusy' => [static function ($timeout = 3): Mutex {
$file = fopen(vfsStream::url('test/lock'), 'w');
$lock = Liberator::liberate(new FlockMutex($file, 3));
$lock->strategy = FlockMutex::STRATEGY_BUSY; // @phpstan-ignore-line
$lock->strategy = FlockMutex::STRATEGY_BUSY; // @phpstan-ignoreX

return $lock->popsValue();
}],
Expand Down

0 comments on commit 7b4427a

Please sign in to comment.