Skip to content

Commit

Permalink
Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasmullie committed May 30, 2024
1 parent 0b2839e commit 8e063a4
Show file tree
Hide file tree
Showing 26 changed files with 84 additions and 92 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@
/makefile export-ignore
/phpunit.xml.dist export-ignore
/README.md export-ignore
/ruleset.xml.dist export-ignore
13 changes: 11 additions & 2 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,21 @@

return $config
->setRules([
'@PHP70Migration' => true,
'@PHP71Migration' => true,
'@PHP73Migration' => true,
'@PHP74Migration' => true,
'@PHP80Migration' => true,
'@PHP81Migration' => true,
'@PHP82Migration' => true,
'@PHP83Migration' => true,
'@Symfony' => true,
'concat_space' => ['spacing' => 'one'],
'single_line_throw' => false,
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
'@PSR12' => true,
'class_definition' => false, // @see https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/5463
'phpdoc_align' => ['align' => 'left'],
'trailing_comma_in_multiline' => ['elements' => ['arguments', 'arrays', 'match', 'parameters']],
'@PER-CS' => true,
])
->setFinder($finder)
->setUsingCache(false);
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@
},
"require-dev": {
"ext-pcntl": "*",
"friendsofphp/php-cs-fixer": ">=2.0",
"phpunit/phpunit": ">=10.0",
"squizlabs/php_codesniffer": ">=3.0"
"friendsofphp/php-cs-fixer": ">=3.0",
"phpunit/phpunit": ">=10.0"
},
"suggest": {
"ext-apcu": ">=4.0.0",
Expand Down
1 change: 1 addition & 0 deletions docker/php.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ cd /tmp/cmake-3.29.3
./configure
make
make install
cd /var/www # back to work dir

pecl install -f couchbase
pecl install -f xdebug
Expand Down
4 changes: 2 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ SHELL := /bin/bash
PHP ?=
ADAPTER ?= Apc,Couchbase,Flysystem,Memcached,MemoryStore,MySQL,PostgreSQL,Redis,SQLite
GROUP ?= #adapter,buffered,collections,keyvaluestore,psr6,psr16,shard,transactional,stampede
VOLUME_BINDS ?= src,tests,build,.php-cs-fixer.php,phpunit.xml,ruleset.xml
VOLUME_BINDS ?= src,tests,build,.php-cs-fixer.php,phpunit.xml

install:
wget -q -O - https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
Expand Down Expand Up @@ -51,6 +51,6 @@ test:
format:
VOLUMES=""
for VOLUME in $$(echo "$(VOLUME_BINDS)" | tr "," "\n"); do VOLUMES="$$VOLUMES -v $$(pwd)/$$VOLUME:/var/www/$$VOLUME"; done;\
docker-compose run --no-deps $$VOLUMES php sh -c "vendor/bin/php-cs-fixer fix && vendor/bin/phpcbf --standard=ruleset.xml"
docker-compose run --no-deps $$VOLUMES php sh -c "vendor/bin/php-cs-fixer fix"

.PHONY: docs
2 changes: 1 addition & 1 deletion src/Adapters/Collections/SQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function flush(): bool
// deleting key with a prefixed LIKE should be fast, they're indexed
$statement = $this->client->prepare(
"DELETE FROM $this->table
WHERE k LIKE :key"
WHERE k LIKE :key",
);

return $statement->execute([
Expand Down
2 changes: 1 addition & 1 deletion src/Adapters/Couchbase.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(
\Couchbase\Collection $client,
\Couchbase\BucketManager|\Couchbase\Management\BucketManager $bucketManager,
\Couchbase\Bucket $bucket,
?int $timeout = null
?int $timeout = null,
) {
$this->collection = $client;
$this->bucketManager = $bucketManager;
Expand Down
2 changes: 1 addition & 1 deletion src/Adapters/MemoryStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ protected function shorthandToBytes(string|int $shorthand): int
static function ($match) use ($units): int {
return $match[1] * $units[$match[2]];
},
$shorthand
$shorthand,
);
}
}
8 changes: 4 additions & 4 deletions src/Adapters/MySQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function set(string $key, mixed $value, int $expire = 0): bool

$statement = $this->client->prepare(
"REPLACE INTO $this->table (k, v, e)
VALUES (:key, :value, :expire)"
VALUES (:key, :value, :expire)",
);

$statement->execute([
Expand Down Expand Up @@ -64,7 +64,7 @@ public function setMulti(array $items, int $expire = 0): array

$statement = $this->client->prepare(
"REPLACE INTO $this->table (k, v, e)
VALUES " . implode(',', $query)
VALUES " . implode(',', $query),
);

$statement->execute($params);
Expand Down Expand Up @@ -92,7 +92,7 @@ public function add(string $key, mixed $value, int $expire = 0): bool
// MySQL-specific way to ignore insert-on-duplicate errors
$statement = $this->client->prepare(
"INSERT IGNORE INTO $this->table (k, v, e)
VALUES (:key, :value, :expire)"
VALUES (:key, :value, :expire)",
);

$statement->execute([
Expand All @@ -117,7 +117,7 @@ protected function init(): void
v LONGBLOB,
e TIMESTAMP NULL DEFAULT NULL,
KEY e (e)
)"
)",
);
}
}
4 changes: 2 additions & 2 deletions src/Adapters/PostgreSQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function set(string $key, mixed $value, int $expire = 0): bool
$statement = $this->client->prepare(
"INSERT INTO $this->table (k, v, e)
VALUES (:key, :value, :expire)
ON CONFLICT (k) DO UPDATE SET v=EXCLUDED.v, e=EXCLUDED.e"
ON CONFLICT (k) DO UPDATE SET v=EXCLUDED.v, e=EXCLUDED.e",
);

$statement->bindParam(':key', $key);
Expand All @@ -87,7 +87,7 @@ protected function init(): void
k VARCHAR NOT NULL PRIMARY KEY,
v BYTEA,
e TIMESTAMP NULL DEFAULT NULL
)"
)",
);
$this->client->exec("CREATE INDEX IF NOT EXISTS e_index ON $this->table (e)");
}
Expand Down
4 changes: 2 additions & 2 deletions src/Adapters/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,13 +479,13 @@ public function getCollection(string $name): KeyValueStore
$client->pconnect(
$this->client->getHost(),
$this->client->getPort(),
$this->client->getTimeout()
$this->client->getTimeout(),
);
} else {
$client->connect(
$this->client->getHost(),
$this->client->getPort(),
$this->client->getTimeout()
$this->client->getTimeout(),
);
}

Expand Down
22 changes: 11 additions & 11 deletions src/Adapters/SQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function get(string $key, mixed &$token = null): mixed
$statement = $this->client->prepare(
"SELECT v
FROM $this->table
WHERE k = :key AND (e IS NULL OR e > :expire)"
WHERE k = :key AND (e IS NULL OR e > :expire)",
);
$statement->execute([
':key' => $key,
Expand Down Expand Up @@ -88,7 +88,7 @@ public function getMulti(array $keys, ?array &$tokens = null): array
FROM $this->table
WHERE
k IN (" . implode(',', $quoted) . ') AND
(e IS NULL OR e > :expire)'
(e IS NULL OR e > :expire)',
);
$statement->execute([':expire' => date('Y-m-d H:i:s')]);
$values = $statement->fetchAll(\PDO::FETCH_ASSOC);
Expand Down Expand Up @@ -138,7 +138,7 @@ public function delete(string $key): bool
{
$statement = $this->client->prepare(
"DELETE FROM $this->table
WHERE k = :key"
WHERE k = :key",
);

$statement->execute([':key' => $key]);
Expand All @@ -163,7 +163,7 @@ public function deleteMulti(array $keys): array

$statement = $this->client->query(
"DELETE FROM $this->table
WHERE k IN (" . implode(',', $quoted) . ')'
WHERE k IN (" . implode(',', $quoted) . ')',
);

/*
Expand Down Expand Up @@ -191,7 +191,7 @@ public function add(string $key, mixed $value, int $expire = 0): bool

$statement = $this->client->prepare(
"INSERT INTO $this->table (k, v, e)
VALUES (:key, :value, :expire)"
VALUES (:key, :value, :expire)",
);

$statement->execute([
Expand All @@ -213,7 +213,7 @@ public function replace(string $key, mixed $value, int $expire = 0): bool
$statement = $this->client->prepare(
"UPDATE $this->table
SET v = :value, e = :expire
WHERE k = :key"
WHERE k = :key",
);

$statement->execute([
Expand All @@ -232,7 +232,7 @@ public function replace(string $key, mixed $value, int $expire = 0): bool
$statement = $this->client->prepare(
"SELECT e
FROM $this->table
WHERE k = :key AND v = :value"
WHERE k = :key AND v = :value",
);
$statement->execute([
':key' => $key,
Expand All @@ -252,7 +252,7 @@ public function cas(mixed $token, string $key, mixed $value, int $expire = 0): b
$statement = $this->client->prepare(
"UPDATE $this->table
SET v = :value, e = :expire
WHERE k = :key AND v = :token"
WHERE k = :key AND v = :token",
);

$statement->execute([
Expand All @@ -272,7 +272,7 @@ public function cas(mixed $token, string $key, mixed $value, int $expire = 0): b
$statement = $this->client->prepare(
"SELECT e
FROM $this->table
WHERE k = :key AND v = :value AND v = :token"
WHERE k = :key AND v = :value AND v = :token",
);
$statement->execute([
':key' => $key,
Expand Down Expand Up @@ -310,7 +310,7 @@ public function touch(string $key, int $expire): bool
$statement = $this->client->prepare(
"UPDATE $this->table
SET e = :expire
WHERE k = :key"
WHERE k = :key",
);

$statement->execute([
Expand Down Expand Up @@ -386,7 +386,7 @@ protected function clearExpired(): void
{
$statement = $this->client->prepare(
"DELETE FROM $this->table
WHERE e < :expire"
WHERE e < :expire",
);

$statement->execute([':expire' => date('Y-m-d H:i:s')]);
Expand Down
6 changes: 3 additions & 3 deletions src/Adapters/SQLite.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function setMulti(array $items, int $expire = 0): array

$statement = $this->client->prepare(
"REPLACE INTO $this->table (k, v, e)
VALUES (:key, :value, :expire)"
VALUES (:key, :value, :expire)",
);

$success = [];
Expand Down Expand Up @@ -57,7 +57,7 @@ public function add(string $key, mixed $value, int $expire = 0): bool
// SQLite-specific way to ignore insert-on-duplicate errors
$statement = $this->client->prepare(
"INSERT OR IGNORE INTO $this->table (k, v, e)
VALUES (:key, :value, :expire)"
VALUES (:key, :value, :expire)",
);

$statement->execute([
Expand All @@ -82,7 +82,7 @@ protected function init(): void
v BLOB,
e TIMESTAMP NULL DEFAULT NULL,
KEY e
)"
)",
);
}
}
4 changes: 1 addition & 3 deletions src/Exception/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@
* @copyright Copyright (c) 2014, Matthias Mullie. All rights reserved
* @license LICENSE MIT
*/
class Exception extends \Exception
{
}
class Exception extends \Exception {}
4 changes: 1 addition & 3 deletions src/Exception/InvalidCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@
* @copyright Copyright (c) 2014, Matthias Mullie. All rights reserved
* @license LICENSE MIT
*/
class InvalidCollection extends Exception
{
}
class InvalidCollection extends Exception {}
4 changes: 1 addition & 3 deletions src/Exception/InvalidKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@
* @copyright Copyright (c) 2014, Matthias Mullie. All rights reserved
* @license LICENSE MIT
*/
class InvalidKey extends Exception
{
}
class InvalidKey extends Exception {}
4 changes: 1 addition & 3 deletions src/Exception/OperationFailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@
* @copyright Copyright (c) 2017, Martin Georgiev. All rights reserved
* @license LICENSE MIT
*/
class OperationFailed extends Exception
{
}
class OperationFailed extends Exception {}
4 changes: 1 addition & 3 deletions src/Exception/UnbegunTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@
* @copyright Copyright (c) 2014, Matthias Mullie. All rights reserved
* @license LICENSE MIT
*/
class UnbegunTransaction extends Exception
{
}
class UnbegunTransaction extends Exception {}
4 changes: 1 addition & 3 deletions src/Exception/UncommittedTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@
* @copyright Copyright (c) 2014, Matthias Mullie. All rights reserved
* @license LICENSE MIT
*/
class UncommittedTransaction extends Exception
{
}
class UncommittedTransaction extends Exception {}
Loading

0 comments on commit 8e063a4

Please sign in to comment.