mache mal statistische analyse mit rein

This commit is contained in:
lubiana 2025-06-27 23:16:20 +02:00
parent 853b280571
commit c5fa857464
Signed by: lubiana
SSH key fingerprint: SHA256:vW1EA0fRR3Fw+dD/sM0K+x3Il2gSry6YRYHqOeQwrfk
8 changed files with 444 additions and 57 deletions

View file

@ -12,5 +12,24 @@
"php": ">=8.4",
"symfony/uid": "^7.0",
"symfony/http-foundation": "^7.3"
},
"require-dev": {
"symplify/easy-coding-standard": "^12.5",
"rector/rector": "^2.1",
"phpstan/phpstan": "^2.1",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan-strict-rules": "^2.0"
},
"config": {
"allow-plugins": {
"phpstan/extension-installer": true
}
},
"scripts": {
"fix": [
"rector",
"ecs --fix || ecs --fix"
],
"phpstan": "phpstan"
}
}

280
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "745f0c513993cf179f9e68b32a2483c7",
"content-hash": "b10d3777b145d0b70391ba08eb08720f",
"packages": [
{
"name": "symfony/deprecation-contracts",
@ -463,7 +463,283 @@
"time": "2025-05-24T14:28:13+00:00"
}
],
"packages-dev": [],
"packages-dev": [
{
"name": "phpstan/extension-installer",
"version": "1.4.3",
"source": {
"type": "git",
"url": "https://github.com/phpstan/extension-installer.git",
"reference": "85e90b3942d06b2326fba0403ec24fe912372936"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/extension-installer/zipball/85e90b3942d06b2326fba0403ec24fe912372936",
"reference": "85e90b3942d06b2326fba0403ec24fe912372936",
"shasum": ""
},
"require": {
"composer-plugin-api": "^2.0",
"php": "^7.2 || ^8.0",
"phpstan/phpstan": "^1.9.0 || ^2.0"
},
"require-dev": {
"composer/composer": "^2.0",
"php-parallel-lint/php-parallel-lint": "^1.2.0",
"phpstan/phpstan-strict-rules": "^0.11 || ^0.12 || ^1.0"
},
"type": "composer-plugin",
"extra": {
"class": "PHPStan\\ExtensionInstaller\\Plugin"
},
"autoload": {
"psr-4": {
"PHPStan\\ExtensionInstaller\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Composer plugin for automatic installation of PHPStan extensions",
"keywords": [
"dev",
"static analysis"
],
"support": {
"issues": "https://github.com/phpstan/extension-installer/issues",
"source": "https://github.com/phpstan/extension-installer/tree/1.4.3"
},
"time": "2024-09-04T20:21:43+00:00"
},
{
"name": "phpstan/phpstan",
"version": "2.1.17",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "89b5ef665716fa2a52ecd2633f21007a6a349053"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/89b5ef665716fa2a52ecd2633f21007a6a349053",
"reference": "89b5ef665716fa2a52ecd2633f21007a6a349053",
"shasum": ""
},
"require": {
"php": "^7.4|^8.0"
},
"conflict": {
"phpstan/phpstan-shim": "*"
},
"bin": [
"phpstan",
"phpstan.phar"
],
"type": "library",
"autoload": {
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "PHPStan - PHP Static Analysis Tool",
"keywords": [
"dev",
"static analysis"
],
"support": {
"docs": "https://phpstan.org/user-guide/getting-started",
"forum": "https://github.com/phpstan/phpstan/discussions",
"issues": "https://github.com/phpstan/phpstan/issues",
"security": "https://github.com/phpstan/phpstan/security/policy",
"source": "https://github.com/phpstan/phpstan-src"
},
"funding": [
{
"url": "https://github.com/ondrejmirtes",
"type": "github"
},
{
"url": "https://github.com/phpstan",
"type": "github"
}
],
"time": "2025-05-21T20:55:28+00:00"
},
{
"name": "phpstan/phpstan-strict-rules",
"version": "2.0.4",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-strict-rules.git",
"reference": "3e139cbe67fafa3588e1dbe27ca50f31fdb6236a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/3e139cbe67fafa3588e1dbe27ca50f31fdb6236a",
"reference": "3e139cbe67fafa3588e1dbe27ca50f31fdb6236a",
"shasum": ""
},
"require": {
"php": "^7.4 || ^8.0",
"phpstan/phpstan": "^2.0.4"
},
"require-dev": {
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpstan/phpstan-deprecation-rules": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpunit/phpunit": "^9.6"
},
"type": "phpstan-extension",
"extra": {
"phpstan": {
"includes": [
"rules.neon"
]
}
},
"autoload": {
"psr-4": {
"PHPStan\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Extra strict and opinionated rules for PHPStan",
"support": {
"issues": "https://github.com/phpstan/phpstan-strict-rules/issues",
"source": "https://github.com/phpstan/phpstan-strict-rules/tree/2.0.4"
},
"time": "2025-03-18T11:42:40+00:00"
},
{
"name": "rector/rector",
"version": "2.1.0",
"source": {
"type": "git",
"url": "https://github.com/rectorphp/rector.git",
"reference": "d513dea45a94394b660e15c155d1fa27826f8e30"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/rectorphp/rector/zipball/d513dea45a94394b660e15c155d1fa27826f8e30",
"reference": "d513dea45a94394b660e15c155d1fa27826f8e30",
"shasum": ""
},
"require": {
"php": "^7.4|^8.0",
"phpstan/phpstan": "^2.1.17"
},
"conflict": {
"rector/rector-doctrine": "*",
"rector/rector-downgrade-php": "*",
"rector/rector-phpunit": "*",
"rector/rector-symfony": "*"
},
"suggest": {
"ext-dom": "To manipulate phpunit.xml via the custom-rule command"
},
"bin": [
"bin/rector"
],
"type": "library",
"autoload": {
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Instant Upgrade and Automated Refactoring of any PHP code",
"homepage": "https://getrector.com/",
"keywords": [
"automation",
"dev",
"migration",
"refactoring"
],
"support": {
"issues": "https://github.com/rectorphp/rector/issues",
"source": "https://github.com/rectorphp/rector/tree/2.1.0"
},
"funding": [
{
"url": "https://github.com/tomasvotruba",
"type": "github"
}
],
"time": "2025-06-24T20:26:57+00:00"
},
{
"name": "symplify/easy-coding-standard",
"version": "12.5.20",
"source": {
"type": "git",
"url": "https://github.com/easy-coding-standard/easy-coding-standard.git",
"reference": "bb44b0fc70dd2148d8a6362bc66a35e23dc31bc4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/easy-coding-standard/easy-coding-standard/zipball/bb44b0fc70dd2148d8a6362bc66a35e23dc31bc4",
"reference": "bb44b0fc70dd2148d8a6362bc66a35e23dc31bc4",
"shasum": ""
},
"require": {
"php": ">=7.2"
},
"conflict": {
"friendsofphp/php-cs-fixer": "<3.46",
"phpcsstandards/php_codesniffer": "<3.8",
"symplify/coding-standard": "<12.1"
},
"suggest": {
"ext-dom": "Needed to support checkstyle output format in class CheckstyleOutputFormatter"
},
"bin": [
"bin/ecs"
],
"type": "library",
"autoload": {
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Use Coding Standard with 0-knowledge of PHP-CS-Fixer and PHP_CodeSniffer",
"keywords": [
"Code style",
"automation",
"fixer",
"static analysis"
],
"support": {
"issues": "https://github.com/easy-coding-standard/easy-coding-standard/issues",
"source": "https://github.com/easy-coding-standard/easy-coding-standard/tree/12.5.20"
},
"funding": [
{
"url": "https://www.paypal.me/rectorphp",
"type": "custom"
},
{
"url": "https://github.com/tomasvotruba",
"type": "github"
}
],
"time": "2025-05-30T11:42:07+00:00"
}
],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {},

28
ecs.php Normal file
View file

@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
return ECSConfig::configure()
->withPaths([
__DIR__ . '/public',
__DIR__ . '/src',
])
->withRootFiles()
->withRules([
NoUnusedImportsFixer::class,
])
->withPhpCsFixerSets(
per: true,
php84Migration: true,
)
->withPreparedSets(
arrays: true,
comments: true,
controlStructures: true,
strict: true,
cleanCode: true,
)
;

8
phpstan.neon Normal file
View file

@ -0,0 +1,8 @@
includes:
- phar://phpstan.phar/conf/bleedingEdge.neon
parameters:
level: max
paths:
- public
- src

View file

@ -1,60 +1,9 @@
<?php
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Uid\Ulid;
use Symfony\Component\Uid\Uuid;
declare(strict_types=1);
use App\App;
require_once __DIR__ . '/../vendor/autoload.php';
$request = Request::createFromGlobals();
$path = $request->getPathInfo();
$scheme = 'https';
$host = $request->getHost();
$base = "{$scheme}://{$host}/";
function response(string $text): Response {
return new Response($text, 200, [
'Content-Type' => 'text/plain',
]);
}
$response = match ($path) {
'/uuid/v1' => \response(Uuid::v1()->toString()),
'/uuid/v4' => \response(Uuid::v4()->toString()),
'/uuid/v6' => \response(Uuid::v6()->toString()),
'/uuid/v7' => \response(Uuid::v7()->toString()),
'/ulid' => \response(Ulid::generate()),
'/' => \response(<<<TXT
UUID/ULID Webservice
Available Endpoints:
/uuid/v1 - Generate a UUID v1 (time-based)
curl {$base}uuid/v1
/uuid/v3 - Generate a UUID v3 (name-based, MD5 hash)
curl {$base}uuid/v3
/uuid/v4 - Generate a UUID v4 (random)
curl {$base}uuid/v4
/uuid/v5 - Generate a UUID v5 (name-based, SHA-1 hash)
curl {$base}uuid/v5
/uuid/v6 - Generate a UUID v6 (reordered time-based)
curl {$base}uuid/v6
/uuid/v7 - Generate a UUID v7 (Unix timestamp-based)
curl {$base}uuid/v7
/ulid - Generate a ULID
curl {$base}ulid
source: https://git.hannover.ccc.de/lubiana/uuid
TXT
),
default => new RedirectResponse("/", 301),
};
$response->send();
new App('https://uuid.php.fail/')->run();

22
rector.php Normal file
View file

@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withPaths([
__DIR__ . '/public',
__DIR__ . '/src',
])
->withRootFiles()
->withImportNames(removeUnusedImports: true)
->withPhpSets()
->withPreparedSets(
codeQuality: true,
typeDeclarations: true,
earlyReturn: true,
strictBooleans: true,
)
->withImportNames(removeUnusedImports: true)
;

64
src/App.php Normal file
View file

@ -0,0 +1,64 @@
<?php
declare(strict_types=1);
namespace App;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Uid\Ulid;
use Symfony\Component\Uid\Uuid;
final readonly class App
{
public function __construct(
private string $base,
) {}
public function handle(Request $request): Response
{
return match ($request->getPathInfo()) {
'/v1' => new PlaintextResponse(Uuid::v1()->toString()),
'/v4' => new PlaintextResponse(Uuid::v4()->toString()),
'/v6' => new PlaintextResponse(Uuid::v6()->toString()),
'/v7' => new PlaintextResponse(Uuid::v7()->toString()),
'/ulid' => new PlaintextResponse(Ulid::generate()),
'/' => new PlaintextResponse(
<<<TXT
UUID/ULID Webservice
Available Endpoints:
/v1 - Generate a UUID v1 (time-based)
curl {$this->base}v1
/v3 - Generate a UUID v3 (name-based, MD5 hash)
curl {$this->base}v3
/v4 - Generate a UUID v4 (random)
curl {$this->base}v4
/v5 - Generate a UUID v5 (name-based, SHA-1 hash)
curl {$this->base}v5
/v6 - Generate a UUID v6 (reordered time-based)
curl {$this->base}v6
/v7 - Generate a UUID v7 (Unix timestamp-based)
curl {$this->base}v7
/ulid - Generate a ULID
curl {$this->base}ulid
source: https://git.hannover.ccc.de/lubiana/uuid
TXT
),
default => new RedirectResponse('/', 301),
};
}
public function run(?Request $request = null): void
{
$request ??= Request::createFromGlobals();
$response = $this->handle($request);
$response->send();
}
}

21
src/PlaintextResponse.php Normal file
View file

@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace App;
use Symfony\Component\HttpFoundation\Response;
final class PlaintextResponse extends Response
{
/** @param array<string, string> $headers */
public function __construct(?string $content, int $status = 200, array $headers = [])
{
$headers['Content-Type'] ??= 'text/plain';
parent::__construct(
content: $content,
status: $status,
headers: $headers,
);
}
}