Skip to content

Commit

Permalink
fix case
Browse files Browse the repository at this point in the history
  • Loading branch information
brianlmoon committed Mar 22, 2024
1 parent 35fa8b5 commit ca3fc24
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 27 deletions.
3 changes: 2 additions & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
'functions_opening_brace' => 'same_line',
],
'constant_case' => [
'case' => 'upper'
'case' => 'lower'
],
'lowercase_keywords' => true,
'no_extra_blank_lines' => [
'tokens' => [
'extra',
Expand Down
2 changes: 1 addition & 1 deletion src/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Cache {
*
* @throws \LogicException Thrown when the cache type is invalid
*/
public static function factory(string $cluster, ?GetConfig $config = NULL): CacheInterface {
public static function factory(string $cluster, ?GetConfig $config = null): CacheInterface {
$config ??= GetConfig::init();
$type = $config->get("caching.cache.{$cluster}.type");

Expand Down
16 changes: 8 additions & 8 deletions src/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class File implements CacheInterface {
public function __construct(string $cluster) {
$this->dir = sys_get_temp_dir()."/caching/{$cluster}";
if (!file_exists($this->dir)) {
mkdir($this->dir, 0775, TRUE);
mkdir($this->dir, 0775, true);
}
}

Expand Down Expand Up @@ -61,10 +61,10 @@ public static function init(string $cluster): File {
* @param int $expire Expiration in seconds from now or unix timestamp
*/
public function add(string $key, $var, int $expire = 0): bool {
$return = FALSE;
$return = false;

$value = $this->get($key);
if (FALSE === $value) {
if (false === $value) {
$return = $this->set($key, $var, $expire);
}

Expand All @@ -79,10 +79,10 @@ public function add(string $key, $var, int $expire = 0): bool {
* @param int $expire Expiration in seconds from now or unix timestamp
*/
public function replace(string $key, $var, int $expire = 0): bool {
$return = FALSE;
$return = false;

$value = $this->get($key);
if (FALSE !== $value) {
if (false !== $value) {
$return = $this->set($key, $var, $expire);
}

Expand All @@ -107,7 +107,7 @@ public function set(string $key, $var, int $expire = 0): bool {
$key = $this->fixKey($key);
$success = file_put_contents($this->dir.'/'.$key, serialize($struct));

return FALSE !== $success;
return false !== $success;
}

/**
Expand Down Expand Up @@ -172,7 +172,7 @@ public function delete(string $key): bool {
unlink($this->dir.'/'.$key);
}

return TRUE;
return true;
}

/**
Expand Down Expand Up @@ -210,7 +210,7 @@ public function fixKey(string $key): string {
*/
protected function realGet(string $key) {
$key = $this->fixKey($key);
$value = FALSE;
$value = false;
if (file_exists($this->dir.'/'.$key)) {
$struct = unserialize(file_get_contents($this->dir.'/'.$key));
if (
Expand Down
8 changes: 4 additions & 4 deletions src/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Redis implements CacheInterface {
* is something stored in an ini file or an
* environment variable.
*/
public function __construct(string $cluster, ?GetConfig $config = NULL) {
public function __construct(string $cluster, ?GetConfig $config = null) {
$this->config = $config ?? GetConfig::init();

$servers = $this->getServerList($cluster);
Expand All @@ -50,7 +50,7 @@ public function __construct(string $cluster, ?GetConfig $config = NULL) {
}

foreach ($servers as $server) {
if (FALSE === strpos($server, '://')) {
if (false === strpos($server, '://')) {
$server = "tcp://{$server}";
}

Expand Down Expand Up @@ -210,7 +210,7 @@ protected function getServerList(string $cluster): array {
*/
protected function getOptions(string $cluster): array {
$options = [
'exceptions' => FALSE,
'exceptions' => false,
];

$possible_options = [
Expand All @@ -226,7 +226,7 @@ protected function getOptions(string $cluster): array {

foreach ($possible_options as $opt) {
$value = $this->config->get("caching.redis.{$cluster}.{$opt}");
if (NULL !== $value) {
if (null !== $value) {
if ('password' === $opt || 'username' === $opt) {
$options['parameters'][$opt] = $value;
} else {
Expand Down
4 changes: 2 additions & 2 deletions tests/AbstractTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected function interfaceTest(CacheInterface $object) {

$object->delete($key);
$this->assertEquals(
FALSE,
false,
$object->get($key)
);

Expand All @@ -80,7 +80,7 @@ protected function badKeyTest(CacheInterface $object) {
$result = $object->set($key, $key);

$this->assertEquals(
TRUE,
true,
$result
);

Expand Down
6 changes: 3 additions & 3 deletions tests/CacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class CacheTest extends TestCase {
* @param null|mixed $exception
* @param null|mixed $code
*/
public function testFactory($expect, $type, $servers = NULL, $cluster = 'test', $exception = NULL, $code = NULL) {
public function testFactory($expect, $type, $servers = null, $cluster = 'test', $exception = null, $code = null) {
if (!empty($exception)) {
$this->expectException($exception);
$this->expectExceptionCode($code);
Expand Down Expand Up @@ -89,7 +89,7 @@ public function factoryData() {
'Bad Cluster' => [
File::class,
'',
NULL,
null,
'foo',
\LogicException::class,
1,
Expand All @@ -98,7 +98,7 @@ public function factoryData() {
'Bad Type' => [
File::class,
'asdf',
NULL,
null,
'test',
\LogicException::class,
2,
Expand Down
2 changes: 1 addition & 1 deletion tests/MemcachedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static function setUpBeforeClass(): void {
break;
}
if ($x < $tries) {
fwrite(STDERR, "Waiting for Memcached to start (try $x)...\n");
fwrite(STDERR, "Waiting for Memcached to start (try {$x})...\n");
sleep(5);
}
}
Expand Down
7 changes: 3 additions & 4 deletions tests/RedisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ public static function setUpBeforeClass(): void {
$object = new Redis('test');
$success = $object->set('setup_test', 1);
} catch (ConnectionException $e) {
_debug($e->getMessage());
$success = FALSE;
$success = false;
}
if ($success) {
break;
}
if ($x < $tries) {
fwrite(STDERR, "Waiting for Redis to start (try $x)...\n");
fwrite(STDERR, "Waiting for Redis to start (try {$x})...\n");
sleep(5);
}
}
Expand Down Expand Up @@ -64,7 +63,7 @@ public function getOptions(string $cluster): array {

$this->assertEquals(
[
'exceptions' => FALSE,
'exceptions' => false,
'prefix' => 'bar',
'replication' => 'sentinel',
'parameters' => [
Expand Down
6 changes: 3 additions & 3 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function _debug() {
fwrite(STDERR, "###########\n");
$args = func_get_args();
foreach ($args as $arg) {
fwrite(STDERR, trim(var_export($arg, TRUE))."\n");
fwrite(STDERR, trim(var_export($arg, true))."\n");
}
fwrite(STDERR, "###########\n");
fwrite(STDERR, "END DEBUG\n\n");
Expand All @@ -33,13 +33,13 @@ function _debug() {
$memcache_host = '127.0.0.1';
$redis_host = '127.0.0.1';

$start_sandbox = TRUE;
$start_sandbox = true;

$opts = getopt('', ['group:']);
if (!empty($opts['group'])) {
$groups = explode(',', $opts['group']);
if (!in_array('functional', $groups)) {
$start_sandbox = FALSE;
$start_sandbox = false;
}
}

Expand Down

0 comments on commit ca3fc24

Please sign in to comment.