chore: add php-cs-fixer with PSR-12 config and CI check
Sync GitHub / sync (push) Failing after 5s
Tests / test (pull_request) Successful in 49s

- Add friendsofphp/php-cs-fixer to require-dev
- Create .php-cs-fixer.dist.php configured for @PSR12 ruleset
- Add php-cs-fixer dry-run step to CI pipeline
- Auto-fix existing PSR-12 violations
- Document code style tooling in readme.md
This commit is contained in:
2026-08-11 08:30:05 -04:00
parent 6b5a711fa9
commit cb378e20bc
58 changed files with 2402 additions and 481 deletions
+13 -6
View File
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace App\Data;
@@ -7,14 +8,16 @@ use App\Enum\Scope;
use Symfony\Component\HttpFoundation\InputBag;
/** when scope is IP but ip-access is disabled, scope is to be considered cookie */
final class Payload {
final class Payload
{
public string $id; /* session name, identifying who is logging in */
public string $token; /* TOTP, typically six digits */
public string $nonce; /* random unique string, to block duplicate submissions */
public bool $json; /* should we return json (for the login page) */
public Scope $scope; /* type of access being requested */
public static function decode(string $base64url): ?Payload {
public static function decode(string $base64url): ?Payload
{
/* convert the base64url into json string */
$base64 = strtr($base64url, '-_', '+/');
$base64 .= str_repeat('=', (4 - strlen($base64) % 4) % 4);
@@ -29,7 +32,8 @@ final class Payload {
return null;
}
public static function load(InputBag $input): ?Payload {
public static function load(InputBag $input): ?Payload
{
/* convert form data into real data */
if ($input->has('username') && $input->has('nonce') && $input->has('totp')) {
return Payload::create((object)[
@@ -42,7 +46,8 @@ final class Payload {
return null;
}
public static function create(object $data): ?Payload {
public static function create(object $data): ?Payload
{
/* if missing required fields id, nonce, or token */
if (strlen(trim($data->id ?? '')) < 1 ||
strlen(trim($data->nonce ?? '')) < 1 ||
@@ -63,11 +68,13 @@ final class Payload {
return Payload::constrict($payload);
}
public function toString(): string {
public function toString(): string
{
return json_encode($this);
}
private static function constrict(Payload $payload): Payload {
private static function constrict(Payload $payload): Payload
{
/* When scope is None, json will be considered false. */
if ($payload->scope === Scope::None) {
$payload->json = false;