Skip to content

Commit

Permalink
Enable "native_constant_invocation" CS rule
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Sep 2, 2020
1 parent 7e4a535 commit db5e758
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Store/FlockStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private function lock(Key $key, $blocking)

// On Windows, even if PHP doc says the contrary, LOCK_NB works, see
// https://bugs.php.net/54129
if (!flock($handle, LOCK_EX | ($blocking ? 0 : LOCK_NB))) {
if (!flock($handle, \LOCK_EX | ($blocking ? 0 : \LOCK_NB))) {
fclose($handle);
throw new LockConflictedException();
}
Expand Down Expand Up @@ -123,7 +123,7 @@ public function delete(Key $key)

$handle = $key->getState(__CLASS__);

flock($handle, LOCK_UN | LOCK_NB);
flock($handle, \LOCK_UN | \LOCK_NB);
fclose($handle);

$key->removeState(__CLASS__);
Expand Down
2 changes: 1 addition & 1 deletion Store/RetryTillSaveStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class RetryTillSaveStore implements StoreInterface, LoggerAwareInterface
* @param int $retrySleep Duration in ms between 2 retry
* @param int $retryCount Maximum amount of retry
*/
public function __construct(StoreInterface $decorated, $retrySleep = 100, $retryCount = PHP_INT_MAX)
public function __construct(StoreInterface $decorated, $retrySleep = 100, $retryCount = \PHP_INT_MAX)
{
$this->decorated = $decorated;
$this->retrySleep = $retrySleep;
Expand Down
12 changes: 6 additions & 6 deletions Tests/Store/BlockingStoreTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ public function testBlockingLocks()
$parentPID = posix_getpid();

// Block SIGHUP signal
pcntl_sigprocmask(SIG_BLOCK, [SIGHUP]);
pcntl_sigprocmask(\SIG_BLOCK, [\SIGHUP]);

if ($childPID = pcntl_fork()) {
// Wait the start of the child
pcntl_sigwaitinfo([SIGHUP], $info);
pcntl_sigwaitinfo([\SIGHUP], $info);

try {
// This call should failed given the lock should already by acquired by the child
Expand All @@ -69,7 +69,7 @@ public function testBlockingLocks()
}

// send the ready signal to the child
posix_kill($childPID, SIGHUP);
posix_kill($childPID, \SIGHUP);

// This call should be blocked by the child #1
$store->waitAndSave($key);
Expand All @@ -81,14 +81,14 @@ public function testBlockingLocks()
$this->assertSame(0, pcntl_wexitstatus($status1), 'The child process couldn\'t lock the resource');
} else {
// Block SIGHUP signal
pcntl_sigprocmask(SIG_BLOCK, [SIGHUP]);
pcntl_sigprocmask(\SIG_BLOCK, [\SIGHUP]);
try {
$store->save($key);
// send the ready signal to the parent
posix_kill($parentPID, SIGHUP);
posix_kill($parentPID, \SIGHUP);

// Wait for the parent to be ready
pcntl_sigwaitinfo([SIGHUP], $info);
pcntl_sigwaitinfo([\SIGHUP], $info);

// Wait ClockDelay to let parent assert to finish
usleep($clockDelay);
Expand Down
12 changes: 6 additions & 6 deletions Tests/Store/SemaphoreStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,22 @@ public function testResourceRemoval()

private function getOpenedSemaphores()
{
if ('Darwin' === PHP_OS) {
$lines = explode(PHP_EOL, trim(shell_exec('ipcs -s')));
if ('Darwin' === \PHP_OS) {
$lines = explode(\PHP_EOL, trim(shell_exec('ipcs -s')));
if (-1 === $start = array_search('Semaphores:', $lines)) {
throw new \Exception('Failed to extract list of opened semaphores. Expected a Semaphore list, got '.implode(PHP_EOL, $lines));
throw new \Exception('Failed to extract list of opened semaphores. Expected a Semaphore list, got '.implode(\PHP_EOL, $lines));
}

return \count(\array_slice($lines, ++$start));
}

$lines = explode(PHP_EOL, trim(shell_exec('LC_ALL=C ipcs -su')));
$lines = explode(\PHP_EOL, trim(shell_exec('LC_ALL=C ipcs -su')));
if ('------ Semaphore Status --------' !== $lines[0]) {
throw new \Exception('Failed to extract list of opened semaphores. Expected a Semaphore status, got '.implode(PHP_EOL, $lines));
throw new \Exception('Failed to extract list of opened semaphores. Expected a Semaphore status, got '.implode(\PHP_EOL, $lines));
}
list($key, $value) = explode(' = ', $lines[1]);
if ('used arrays' !== $key) {
throw new \Exception('Failed to extract list of opened semaphores. Expected a "used arrays" key, got '.implode(PHP_EOL, $lines));
throw new \Exception('Failed to extract list of opened semaphores. Expected a "used arrays" key, got '.implode(\PHP_EOL, $lines));
}

return (int) $value;
Expand Down

0 comments on commit db5e758

Please sign in to comment.