ci: add php cs fixer

This commit is contained in:
Maël Gangloff
2024-08-02 23:24:52 +02:00
parent cd5060ed6a
commit b460e8aaa6
41 changed files with 1413 additions and 440 deletions

5
.gitignore vendored
View File

@@ -33,3 +33,8 @@
npm-debug.log
yarn-error.log
###< symfony/webpack-encore-bundle ###
###> friendsofphp/php-cs-fixer ###
/.php-cs-fixer.php
/.php-cs-fixer.cache
###< friendsofphp/php-cs-fixer ###

13
.php-cs-fixer.dist.php Normal file
View File

@@ -0,0 +1,13 @@
<?php
$finder = (new PhpCsFixer\Finder())
->in(__DIR__)
->exclude('var')
;
return (new PhpCsFixer\Config())
->setRules([
'@Symfony' => true,
])
->setFinder($finder)
;

View File

@@ -126,6 +126,7 @@
}
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.61",
"phpunit/phpunit": "^9.5",
"symfony/browser-kit": "7.1.*",
"symfony/css-selector": "7.1.*",

952
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": "8de1bd3d79398ff0a64f41526ff80de9",
"content-hash": "94a201d97ed1f0ed40eda7bdc44e6e36",
"packages": [
{
"name": "api-platform/core",
@@ -9667,6 +9667,426 @@
}
],
"packages-dev": [
{
"name": "clue/ndjson-react",
"version": "v1.3.0",
"source": {
"type": "git",
"url": "https://github.com/clue/reactphp-ndjson.git",
"reference": "392dc165fce93b5bb5c637b67e59619223c931b0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/clue/reactphp-ndjson/zipball/392dc165fce93b5bb5c637b67e59619223c931b0",
"reference": "392dc165fce93b5bb5c637b67e59619223c931b0",
"shasum": ""
},
"require": {
"php": ">=5.3",
"react/stream": "^1.2"
},
"require-dev": {
"phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35",
"react/event-loop": "^1.2"
},
"type": "library",
"autoload": {
"psr-4": {
"Clue\\React\\NDJson\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Christian Lück",
"email": "christian@clue.engineering"
}
],
"description": "Streaming newline-delimited JSON (NDJSON) parser and encoder for ReactPHP.",
"homepage": "https://github.com/clue/reactphp-ndjson",
"keywords": [
"NDJSON",
"json",
"jsonlines",
"newline",
"reactphp",
"streaming"
],
"support": {
"issues": "https://github.com/clue/reactphp-ndjson/issues",
"source": "https://github.com/clue/reactphp-ndjson/tree/v1.3.0"
},
"funding": [
{
"url": "https://clue.engineering/support",
"type": "custom"
},
{
"url": "https://github.com/clue",
"type": "github"
}
],
"time": "2022-12-23T10:58:28+00:00"
},
{
"name": "composer/pcre",
"version": "3.2.0",
"source": {
"type": "git",
"url": "https://github.com/composer/pcre.git",
"reference": "ea4ab6f9580a4fd221e0418f2c357cdd39102a90"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/pcre/zipball/ea4ab6f9580a4fd221e0418f2c357cdd39102a90",
"reference": "ea4ab6f9580a4fd221e0418f2c357cdd39102a90",
"shasum": ""
},
"require": {
"php": "^7.4 || ^8.0"
},
"conflict": {
"phpstan/phpstan": "<1.11.8"
},
"require-dev": {
"phpstan/phpstan": "^1.11.8",
"phpstan/phpstan-strict-rules": "^1.1",
"phpunit/phpunit": "^8 || ^9"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "3.x-dev"
},
"phpstan": {
"includes": [
"extension.neon"
]
}
},
"autoload": {
"psr-4": {
"Composer\\Pcre\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
}
],
"description": "PCRE wrapping library that offers type-safe preg_* replacements.",
"keywords": [
"PCRE",
"preg",
"regex",
"regular expression"
],
"support": {
"issues": "https://github.com/composer/pcre/issues",
"source": "https://github.com/composer/pcre/tree/3.2.0"
},
"funding": [
{
"url": "https://packagist.com",
"type": "custom"
},
{
"url": "https://github.com/composer",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/composer/composer",
"type": "tidelift"
}
],
"time": "2024-07-25T09:36:02+00:00"
},
{
"name": "composer/xdebug-handler",
"version": "3.0.5",
"source": {
"type": "git",
"url": "https://github.com/composer/xdebug-handler.git",
"reference": "6c1925561632e83d60a44492e0b344cf48ab85ef"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/xdebug-handler/zipball/6c1925561632e83d60a44492e0b344cf48ab85ef",
"reference": "6c1925561632e83d60a44492e0b344cf48ab85ef",
"shasum": ""
},
"require": {
"composer/pcre": "^1 || ^2 || ^3",
"php": "^7.2.5 || ^8.0",
"psr/log": "^1 || ^2 || ^3"
},
"require-dev": {
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-strict-rules": "^1.1",
"phpunit/phpunit": "^8.5 || ^9.6 || ^10.5"
},
"type": "library",
"autoload": {
"psr-4": {
"Composer\\XdebugHandler\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "John Stevenson",
"email": "john-stevenson@blueyonder.co.uk"
}
],
"description": "Restarts a process without Xdebug.",
"keywords": [
"Xdebug",
"performance"
],
"support": {
"irc": "ircs://irc.libera.chat:6697/composer",
"issues": "https://github.com/composer/xdebug-handler/issues",
"source": "https://github.com/composer/xdebug-handler/tree/3.0.5"
},
"funding": [
{
"url": "https://packagist.com",
"type": "custom"
},
{
"url": "https://github.com/composer",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/composer/composer",
"type": "tidelift"
}
],
"time": "2024-05-06T16:37:16+00:00"
},
{
"name": "evenement/evenement",
"version": "v3.0.2",
"source": {
"type": "git",
"url": "https://github.com/igorw/evenement.git",
"reference": "0a16b0d71ab13284339abb99d9d2bd813640efbc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/igorw/evenement/zipball/0a16b0d71ab13284339abb99d9d2bd813640efbc",
"reference": "0a16b0d71ab13284339abb99d9d2bd813640efbc",
"shasum": ""
},
"require": {
"php": ">=7.0"
},
"require-dev": {
"phpunit/phpunit": "^9 || ^6"
},
"type": "library",
"autoload": {
"psr-4": {
"Evenement\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Igor Wiedler",
"email": "igor@wiedler.ch"
}
],
"description": "Événement is a very simple event dispatching library for PHP",
"keywords": [
"event-dispatcher",
"event-emitter"
],
"support": {
"issues": "https://github.com/igorw/evenement/issues",
"source": "https://github.com/igorw/evenement/tree/v3.0.2"
},
"time": "2023-08-08T05:53:35+00:00"
},
{
"name": "fidry/cpu-core-counter",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/theofidry/cpu-core-counter.git",
"reference": "f92996c4d5c1a696a6a970e20f7c4216200fcc42"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/theofidry/cpu-core-counter/zipball/f92996c4d5c1a696a6a970e20f7c4216200fcc42",
"reference": "f92996c4d5c1a696a6a970e20f7c4216200fcc42",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
"require-dev": {
"fidry/makefile": "^0.2.0",
"fidry/php-cs-fixer-config": "^1.1.2",
"phpstan/extension-installer": "^1.2.0",
"phpstan/phpstan": "^1.9.2",
"phpstan/phpstan-deprecation-rules": "^1.0.0",
"phpstan/phpstan-phpunit": "^1.2.2",
"phpstan/phpstan-strict-rules": "^1.4.4",
"phpunit/phpunit": "^8.5.31 || ^9.5.26",
"webmozarts/strict-phpunit": "^7.5"
},
"type": "library",
"autoload": {
"psr-4": {
"Fidry\\CpuCoreCounter\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Théo FIDRY",
"email": "theo.fidry@gmail.com"
}
],
"description": "Tiny utility to get the number of CPU cores.",
"keywords": [
"CPU",
"core"
],
"support": {
"issues": "https://github.com/theofidry/cpu-core-counter/issues",
"source": "https://github.com/theofidry/cpu-core-counter/tree/1.1.0"
},
"funding": [
{
"url": "https://github.com/theofidry",
"type": "github"
}
],
"time": "2024-02-07T09:43:46+00:00"
},
{
"name": "friendsofphp/php-cs-fixer",
"version": "v3.61.1",
"source": {
"type": "git",
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
"reference": "94a87189f55814e6cabca2d9a33b06de384a2ab8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/94a87189f55814e6cabca2d9a33b06de384a2ab8",
"reference": "94a87189f55814e6cabca2d9a33b06de384a2ab8",
"shasum": ""
},
"require": {
"clue/ndjson-react": "^1.0",
"composer/semver": "^3.4",
"composer/xdebug-handler": "^3.0.3",
"ext-filter": "*",
"ext-json": "*",
"ext-tokenizer": "*",
"fidry/cpu-core-counter": "^1.0",
"php": "^7.4 || ^8.0",
"react/child-process": "^0.6.5",
"react/event-loop": "^1.0",
"react/promise": "^2.0 || ^3.0",
"react/socket": "^1.0",
"react/stream": "^1.0",
"sebastian/diff": "^4.0 || ^5.0 || ^6.0",
"symfony/console": "^5.4 || ^6.0 || ^7.0",
"symfony/event-dispatcher": "^5.4 || ^6.0 || ^7.0",
"symfony/filesystem": "^5.4 || ^6.0 || ^7.0",
"symfony/finder": "^5.4 || ^6.0 || ^7.0",
"symfony/options-resolver": "^5.4 || ^6.0 || ^7.0",
"symfony/polyfill-mbstring": "^1.28",
"symfony/polyfill-php80": "^1.28",
"symfony/polyfill-php81": "^1.28",
"symfony/process": "^5.4 || ^6.0 || ^7.0",
"symfony/stopwatch": "^5.4 || ^6.0 || ^7.0"
},
"require-dev": {
"facile-it/paraunit": "^1.3 || ^2.3",
"infection/infection": "^0.29.5",
"justinrainbow/json-schema": "^5.2",
"keradus/cli-executor": "^2.1",
"mikey179/vfsstream": "^1.6.11",
"php-coveralls/php-coveralls": "^2.7",
"php-cs-fixer/accessible-object": "^1.1",
"php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.5",
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.5",
"phpunit/phpunit": "^9.6.19 || ^10.5.21 || ^11.2",
"symfony/var-dumper": "^5.4 || ^6.0 || ^7.0",
"symfony/yaml": "^5.4 || ^6.0 || ^7.0"
},
"suggest": {
"ext-dom": "For handling output formats in XML",
"ext-mbstring": "For handling non-UTF8 characters."
},
"bin": [
"php-cs-fixer"
],
"type": "application",
"autoload": {
"psr-4": {
"PhpCsFixer\\": "src/"
},
"exclude-from-classmap": [
"src/Fixer/Internal/*"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Dariusz Rumiński",
"email": "dariusz.ruminski@gmail.com"
}
],
"description": "A tool to automatically fix PHP code style",
"keywords": [
"Static code analysis",
"fixer",
"standards",
"static analysis"
],
"support": {
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.61.1"
},
"funding": [
{
"url": "https://github.com/keradus",
"type": "github"
}
],
"time": "2024-07-31T14:33:15+00:00"
},
{
"name": "masterminds/html5",
"version": "2.9.0",
@@ -10392,6 +10812,536 @@
],
"time": "2024-07-10T11:45:39+00:00"
},
{
"name": "react/cache",
"version": "v1.2.0",
"source": {
"type": "git",
"url": "https://github.com/reactphp/cache.git",
"reference": "d47c472b64aa5608225f47965a484b75c7817d5b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/reactphp/cache/zipball/d47c472b64aa5608225f47965a484b75c7817d5b",
"reference": "d47c472b64aa5608225f47965a484b75c7817d5b",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"react/promise": "^3.0 || ^2.0 || ^1.1"
},
"require-dev": {
"phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35"
},
"type": "library",
"autoload": {
"psr-4": {
"React\\Cache\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Christian Lück",
"email": "christian@clue.engineering",
"homepage": "https://clue.engineering/"
},
{
"name": "Cees-Jan Kiewiet",
"email": "reactphp@ceesjankiewiet.nl",
"homepage": "https://wyrihaximus.net/"
},
{
"name": "Jan Sorgalla",
"email": "jsorgalla@gmail.com",
"homepage": "https://sorgalla.com/"
},
{
"name": "Chris Boden",
"email": "cboden@gmail.com",
"homepage": "https://cboden.dev/"
}
],
"description": "Async, Promise-based cache interface for ReactPHP",
"keywords": [
"cache",
"caching",
"promise",
"reactphp"
],
"support": {
"issues": "https://github.com/reactphp/cache/issues",
"source": "https://github.com/reactphp/cache/tree/v1.2.0"
},
"funding": [
{
"url": "https://opencollective.com/reactphp",
"type": "open_collective"
}
],
"time": "2022-11-30T15:59:55+00:00"
},
{
"name": "react/child-process",
"version": "v0.6.5",
"source": {
"type": "git",
"url": "https://github.com/reactphp/child-process.git",
"reference": "e71eb1aa55f057c7a4a0d08d06b0b0a484bead43"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/reactphp/child-process/zipball/e71eb1aa55f057c7a4a0d08d06b0b0a484bead43",
"reference": "e71eb1aa55f057c7a4a0d08d06b0b0a484bead43",
"shasum": ""
},
"require": {
"evenement/evenement": "^3.0 || ^2.0 || ^1.0",
"php": ">=5.3.0",
"react/event-loop": "^1.2",
"react/stream": "^1.2"
},
"require-dev": {
"phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35",
"react/socket": "^1.8",
"sebastian/environment": "^5.0 || ^3.0 || ^2.0 || ^1.0"
},
"type": "library",
"autoload": {
"psr-4": {
"React\\ChildProcess\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Christian Lück",
"email": "christian@clue.engineering",
"homepage": "https://clue.engineering/"
},
{
"name": "Cees-Jan Kiewiet",
"email": "reactphp@ceesjankiewiet.nl",
"homepage": "https://wyrihaximus.net/"
},
{
"name": "Jan Sorgalla",
"email": "jsorgalla@gmail.com",
"homepage": "https://sorgalla.com/"
},
{
"name": "Chris Boden",
"email": "cboden@gmail.com",
"homepage": "https://cboden.dev/"
}
],
"description": "Event-driven library for executing child processes with ReactPHP.",
"keywords": [
"event-driven",
"process",
"reactphp"
],
"support": {
"issues": "https://github.com/reactphp/child-process/issues",
"source": "https://github.com/reactphp/child-process/tree/v0.6.5"
},
"funding": [
{
"url": "https://github.com/WyriHaximus",
"type": "github"
},
{
"url": "https://github.com/clue",
"type": "github"
}
],
"time": "2022-09-16T13:41:56+00:00"
},
{
"name": "react/dns",
"version": "v1.13.0",
"source": {
"type": "git",
"url": "https://github.com/reactphp/dns.git",
"reference": "eb8ae001b5a455665c89c1df97f6fb682f8fb0f5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/reactphp/dns/zipball/eb8ae001b5a455665c89c1df97f6fb682f8fb0f5",
"reference": "eb8ae001b5a455665c89c1df97f6fb682f8fb0f5",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"react/cache": "^1.0 || ^0.6 || ^0.5",
"react/event-loop": "^1.2",
"react/promise": "^3.2 || ^2.7 || ^1.2.1"
},
"require-dev": {
"phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36",
"react/async": "^4.3 || ^3 || ^2",
"react/promise-timer": "^1.11"
},
"type": "library",
"autoload": {
"psr-4": {
"React\\Dns\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Christian Lück",
"email": "christian@clue.engineering",
"homepage": "https://clue.engineering/"
},
{
"name": "Cees-Jan Kiewiet",
"email": "reactphp@ceesjankiewiet.nl",
"homepage": "https://wyrihaximus.net/"
},
{
"name": "Jan Sorgalla",
"email": "jsorgalla@gmail.com",
"homepage": "https://sorgalla.com/"
},
{
"name": "Chris Boden",
"email": "cboden@gmail.com",
"homepage": "https://cboden.dev/"
}
],
"description": "Async DNS resolver for ReactPHP",
"keywords": [
"async",
"dns",
"dns-resolver",
"reactphp"
],
"support": {
"issues": "https://github.com/reactphp/dns/issues",
"source": "https://github.com/reactphp/dns/tree/v1.13.0"
},
"funding": [
{
"url": "https://opencollective.com/reactphp",
"type": "open_collective"
}
],
"time": "2024-06-13T14:18:03+00:00"
},
{
"name": "react/event-loop",
"version": "v1.5.0",
"source": {
"type": "git",
"url": "https://github.com/reactphp/event-loop.git",
"reference": "bbe0bd8c51ffc05ee43f1729087ed3bdf7d53354"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/reactphp/event-loop/zipball/bbe0bd8c51ffc05ee43f1729087ed3bdf7d53354",
"reference": "bbe0bd8c51ffc05ee43f1729087ed3bdf7d53354",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36"
},
"suggest": {
"ext-pcntl": "For signal handling support when using the StreamSelectLoop"
},
"type": "library",
"autoload": {
"psr-4": {
"React\\EventLoop\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Christian Lück",
"email": "christian@clue.engineering",
"homepage": "https://clue.engineering/"
},
{
"name": "Cees-Jan Kiewiet",
"email": "reactphp@ceesjankiewiet.nl",
"homepage": "https://wyrihaximus.net/"
},
{
"name": "Jan Sorgalla",
"email": "jsorgalla@gmail.com",
"homepage": "https://sorgalla.com/"
},
{
"name": "Chris Boden",
"email": "cboden@gmail.com",
"homepage": "https://cboden.dev/"
}
],
"description": "ReactPHP's core reactor event loop that libraries can use for evented I/O.",
"keywords": [
"asynchronous",
"event-loop"
],
"support": {
"issues": "https://github.com/reactphp/event-loop/issues",
"source": "https://github.com/reactphp/event-loop/tree/v1.5.0"
},
"funding": [
{
"url": "https://opencollective.com/reactphp",
"type": "open_collective"
}
],
"time": "2023-11-13T13:48:05+00:00"
},
{
"name": "react/promise",
"version": "v3.2.0",
"source": {
"type": "git",
"url": "https://github.com/reactphp/promise.git",
"reference": "8a164643313c71354582dc850b42b33fa12a4b63"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/reactphp/promise/zipball/8a164643313c71354582dc850b42b33fa12a4b63",
"reference": "8a164643313c71354582dc850b42b33fa12a4b63",
"shasum": ""
},
"require": {
"php": ">=7.1.0"
},
"require-dev": {
"phpstan/phpstan": "1.10.39 || 1.4.10",
"phpunit/phpunit": "^9.6 || ^7.5"
},
"type": "library",
"autoload": {
"files": [
"src/functions_include.php"
],
"psr-4": {
"React\\Promise\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jan Sorgalla",
"email": "jsorgalla@gmail.com",
"homepage": "https://sorgalla.com/"
},
{
"name": "Christian Lück",
"email": "christian@clue.engineering",
"homepage": "https://clue.engineering/"
},
{
"name": "Cees-Jan Kiewiet",
"email": "reactphp@ceesjankiewiet.nl",
"homepage": "https://wyrihaximus.net/"
},
{
"name": "Chris Boden",
"email": "cboden@gmail.com",
"homepage": "https://cboden.dev/"
}
],
"description": "A lightweight implementation of CommonJS Promises/A for PHP",
"keywords": [
"promise",
"promises"
],
"support": {
"issues": "https://github.com/reactphp/promise/issues",
"source": "https://github.com/reactphp/promise/tree/v3.2.0"
},
"funding": [
{
"url": "https://opencollective.com/reactphp",
"type": "open_collective"
}
],
"time": "2024-05-24T10:39:05+00:00"
},
{
"name": "react/socket",
"version": "v1.16.0",
"source": {
"type": "git",
"url": "https://github.com/reactphp/socket.git",
"reference": "23e4ff33ea3e160d2d1f59a0e6050e4b0fb0eac1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/reactphp/socket/zipball/23e4ff33ea3e160d2d1f59a0e6050e4b0fb0eac1",
"reference": "23e4ff33ea3e160d2d1f59a0e6050e4b0fb0eac1",
"shasum": ""
},
"require": {
"evenement/evenement": "^3.0 || ^2.0 || ^1.0",
"php": ">=5.3.0",
"react/dns": "^1.13",
"react/event-loop": "^1.2",
"react/promise": "^3.2 || ^2.6 || ^1.2.1",
"react/stream": "^1.4"
},
"require-dev": {
"phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36",
"react/async": "^4.3 || ^3.3 || ^2",
"react/promise-stream": "^1.4",
"react/promise-timer": "^1.11"
},
"type": "library",
"autoload": {
"psr-4": {
"React\\Socket\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Christian Lück",
"email": "christian@clue.engineering",
"homepage": "https://clue.engineering/"
},
{
"name": "Cees-Jan Kiewiet",
"email": "reactphp@ceesjankiewiet.nl",
"homepage": "https://wyrihaximus.net/"
},
{
"name": "Jan Sorgalla",
"email": "jsorgalla@gmail.com",
"homepage": "https://sorgalla.com/"
},
{
"name": "Chris Boden",
"email": "cboden@gmail.com",
"homepage": "https://cboden.dev/"
}
],
"description": "Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP",
"keywords": [
"Connection",
"Socket",
"async",
"reactphp",
"stream"
],
"support": {
"issues": "https://github.com/reactphp/socket/issues",
"source": "https://github.com/reactphp/socket/tree/v1.16.0"
},
"funding": [
{
"url": "https://opencollective.com/reactphp",
"type": "open_collective"
}
],
"time": "2024-07-26T10:38:09+00:00"
},
{
"name": "react/stream",
"version": "v1.4.0",
"source": {
"type": "git",
"url": "https://github.com/reactphp/stream.git",
"reference": "1e5b0acb8fe55143b5b426817155190eb6f5b18d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/reactphp/stream/zipball/1e5b0acb8fe55143b5b426817155190eb6f5b18d",
"reference": "1e5b0acb8fe55143b5b426817155190eb6f5b18d",
"shasum": ""
},
"require": {
"evenement/evenement": "^3.0 || ^2.0 || ^1.0",
"php": ">=5.3.8",
"react/event-loop": "^1.2"
},
"require-dev": {
"clue/stream-filter": "~1.2",
"phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36"
},
"type": "library",
"autoload": {
"psr-4": {
"React\\Stream\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Christian Lück",
"email": "christian@clue.engineering",
"homepage": "https://clue.engineering/"
},
{
"name": "Cees-Jan Kiewiet",
"email": "reactphp@ceesjankiewiet.nl",
"homepage": "https://wyrihaximus.net/"
},
{
"name": "Jan Sorgalla",
"email": "jsorgalla@gmail.com",
"homepage": "https://sorgalla.com/"
},
{
"name": "Chris Boden",
"email": "cboden@gmail.com",
"homepage": "https://cboden.dev/"
}
],
"description": "Event-driven readable and writable streams for non-blocking I/O in ReactPHP",
"keywords": [
"event-driven",
"io",
"non-blocking",
"pipe",
"reactphp",
"readable",
"stream",
"writable"
],
"support": {
"issues": "https://github.com/reactphp/stream/issues",
"source": "https://github.com/reactphp/stream/tree/v1.4.0"
},
"funding": [
{
"url": "https://opencollective.com/reactphp",
"type": "open_collective"
}
],
"time": "2024-06-11T12:45:25+00:00"
},
{
"name": "sebastian/cli-parser",
"version": "1.0.2",

View File

@@ -9,4 +9,4 @@ interface ConnectorInterface
public static function verifyAuthData(array $authData): array;
public function orderDomain(Domain $domain, bool $dryRun): void;
}
}

View File

@@ -3,29 +3,29 @@
namespace App\Config\Connector;
use App\Entity\Domain;
use DateTime;
use Exception;
use Ovh\Api;
readonly class OvhConnector implements ConnectorInterface
{
public function __construct(private array $authData)
{
}
/**
* Order a domain name with the OVH API
* @throws Exception
* Order a domain name with the OVH API.
*
* @throws \Exception
*/
public function orderDomain(Domain $domain, bool $dryRun = false
): void
{
if (!$domain->getDeleted()) throw new Exception('The domain name still appears in the WHOIS database');
): void {
if (!$domain->getDeleted()) {
throw new \Exception('The domain name still appears in the WHOIS database');
}
$ldhName = $domain->getLdhName();
if (!$ldhName) throw new Exception("Domain name cannot be null");
if (!$ldhName) {
throw new \Exception('Domain name cannot be null');
}
$authData = self::verifyAuthData($this->authData);
@@ -41,57 +41,59 @@ readonly class OvhConnector implements ConnectorInterface
);
$cart = $conn->post('/order/cart', [
"ovhSubsidiary" => $authData['ovhSubsidiary'],
"description" => "Domain Watchdog"
'ovhSubsidiary' => $authData['ovhSubsidiary'],
'description' => 'Domain Watchdog',
]);
$cartId = $cart['cartId'];
$offers = $conn->get("/order/cart/{$cartId}/domain", [
"domain" => $ldhName
'domain' => $ldhName,
]);
$offer = array_filter($offers, fn($offer) => $offer['action'] === 'create' &&
$offer['orderable'] === true &&
$offer['pricingMode'] === $authData['pricingMode']
$offer = array_filter($offers, fn ($offer) => 'create' === $offer['action']
&& true === $offer['orderable']
&& $offer['pricingMode'] === $authData['pricingMode']
);
if (empty($offer)) {
$conn->delete("/order/cart/{$cartId}");
throw new Exception('Cannot buy this domain name');
throw new \Exception('Cannot buy this domain name');
}
$item = $conn->post("/order/cart/{$cartId}/domain", [
"domain" => $ldhName,
"duration" => "P1Y"
'domain' => $ldhName,
'duration' => 'P1Y',
]);
$itemId = $item['itemId'];
//$conn->get("/order/cart/{$cartId}/summary");
// $conn->get("/order/cart/{$cartId}/summary");
$conn->post("/order/cart/{$cartId}/assign");
$conn->get("/order/cart/{$cartId}/item/{$itemId}/requiredConfiguration");
$configuration = [
"ACCEPT_CONDITIONS" => $acceptConditions,
"OWNER_LEGAL_AGE" => $ownerLegalAge
'ACCEPT_CONDITIONS' => $acceptConditions,
'OWNER_LEGAL_AGE' => $ownerLegalAge,
];
foreach ($configuration as $label => $value) {
$conn->post("/order/cart/{$cartId}/item/{$itemId}/configuration", [
"cartId" => $cartId,
"itemId" => $itemId,
"label" => $label,
"value" => $value
'cartId' => $cartId,
'itemId' => $itemId,
'label' => $label,
'value' => $value,
]);
}
$conn->get("/order/cart/{$cartId}/checkout");
if ($dryRun) return;
if ($dryRun) {
return;
}
$conn->post("/order/cart/{$cartId}/checkout", [
"autoPayWithPreferredPaymentMethod" => true,
"waiveRetractationPeriod" => $waiveRetractationPeriod
'autoPayWithPreferredPaymentMethod' => true,
'waiveRetractationPeriod' => $waiveRetractationPeriod,
]);
}
/**
* @throws Exception
* @throws \Exception
*/
public static function verifyAuthData(array $authData): array
{
@@ -106,18 +108,19 @@ readonly class OvhConnector implements ConnectorInterface
$ownerLegalAge = $authData['ownerLegalAge'];
$waiveRetractationPeriod = $authData['waiveRetractationPeriod'];
if (!is_string($appKey) || empty($appKey) ||
!is_string($appSecret) || empty($appSecret) ||
!is_string($consumerKey) || empty($consumerKey) ||
!is_string($apiEndpoint) || empty($apiEndpoint) ||
!is_string($ovhSubsidiary) || empty($ovhSubsidiary) ||
!is_string($pricingMode) || empty($pricingMode) ||
if (!is_string($appKey) || empty($appKey)
|| !is_string($appSecret) || empty($appSecret)
|| !is_string($consumerKey) || empty($consumerKey)
|| !is_string($apiEndpoint) || empty($apiEndpoint)
|| !is_string($ovhSubsidiary) || empty($ovhSubsidiary)
|| !is_string($pricingMode) || empty($pricingMode)
true !== $acceptConditions ||
true !== $ownerLegalAge ||
true !== $waiveRetractationPeriod
) throw new Exception("Bad authData schema");
|| true !== $acceptConditions
|| true !== $ownerLegalAge
|| true !== $waiveRetractationPeriod
) {
throw new \Exception('Bad authData schema');
}
$conn = new Api(
$appKey,
@@ -127,22 +130,25 @@ readonly class OvhConnector implements ConnectorInterface
);
$res = $conn->get('/auth/currentCredential');
if ($res['expiration'] !== null && new DateTime($res['expiration']) < new DateTime())
throw new Exception('These credentials have expired');
if (null !== $res['expiration'] && new \DateTime($res['expiration']) < new \DateTime()) {
throw new \Exception('These credentials have expired');
}
$status = $res['status'];
if ($status !== 'validated') throw new Exception("The status of these credentials is not valid ($status)");
if ('validated' !== $status) {
throw new \Exception("The status of these credentials is not valid ($status)");
}
return [
"appKey" => $appKey,
"appSecret" => $appSecret,
"apiEndpoint" => $apiEndpoint,
"consumerKey" => $consumerKey,
"ovhSubsidiary" => $ovhSubsidiary,
"pricingMode" => $pricingMode,
"acceptConditions" => $acceptConditions,
"ownerLegalAge" => $ownerLegalAge,
"waiveRetractationPeriod" => $waiveRetractationPeriod
'appKey' => $appKey,
'appSecret' => $appSecret,
'apiEndpoint' => $apiEndpoint,
'consumerKey' => $consumerKey,
'ovhSubsidiary' => $ovhSubsidiary,
'pricingMode' => $pricingMode,
'acceptConditions' => $acceptConditions,
'ownerLegalAge' => $ownerLegalAge,
'waiveRetractationPeriod' => $waiveRetractationPeriod,
];
}
}
}

View File

@@ -2,7 +2,6 @@
namespace App\Config;
enum ConnectorProvider: string
{
case OVH = 'ovh';

View File

@@ -2,12 +2,11 @@
namespace App\Config;
enum TldType: string
{
case iTLD = 'iTLD';
case gTLD = "gTLD";
case sTLD = "sTLD";
case ccTLD = "ccTLD";
case tTLD = "tTLD";
case gTLD = 'gTLD';
case sTLD = 'sTLD';
case ccTLD = 'ccTLD';
case tTLD = 'tTLD';
}

View File

@@ -2,7 +2,6 @@
namespace App\Config;
enum TriggerAction: string
{
case SendEmail = 'email';

View File

@@ -8,7 +8,6 @@ use App\Entity\Connector;
use App\Entity\User;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\EntityManagerInterface;
use Exception;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Attribute\Route;
@@ -18,8 +17,7 @@ class ConnectorController extends AbstractController
{
public function __construct(
private readonly SerializerInterface $serializer, private readonly EntityManagerInterface $em
)
{
) {
}
#[Route(
@@ -35,11 +33,12 @@ class ConnectorController extends AbstractController
{
/** @var User $user */
$user = $this->getUser();
return $user->getConnectors();
}
/**
* @throws Exception
* @throws \Exception
*/
#[Route(
path: '/api/connectors',
@@ -55,15 +54,16 @@ class ConnectorController extends AbstractController
$connector = $this->serializer->deserialize($request->getContent(), Connector::class, 'json', ['groups' => 'connector:create']);
$connector->setUser($this->getUser());
if ($connector->getProvider() === ConnectorProvider::OVH) {
if (ConnectorProvider::OVH === $connector->getProvider()) {
$authData = OvhConnector::verifyAuthData($connector->getAuthData());
$connector->setAuthData($authData);
} else throw new Exception('Unknown provider');
} else {
throw new \Exception('Unknown provider');
}
$this->em->persist($connector);
$this->em->flush();
return $connector;
}
}
}

View File

@@ -7,8 +7,6 @@ use App\Entity\WatchList;
use App\Message\ProcessDomainTrigger;
use App\Repository\DomainRepository;
use App\Service\RDAPService;
use DateTimeImmutable;
use Exception;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException;
use Symfony\Component\HttpKernel\KernelInterface;
@@ -21,11 +19,10 @@ use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
class DomainRefreshController extends AbstractController
{
public function __construct(private readonly DomainRepository $domainRepository,
private readonly RDAPService $RDAPService,
private readonly RateLimiterFactory $authenticatedApiLimiter,
private readonly MessageBusInterface $bus)
public function __construct(private readonly DomainRepository $domainRepository,
private readonly RDAPService $RDAPService,
private readonly RateLimiterFactory $authenticatedApiLimiter,
private readonly MessageBusInterface $bus)
{
}
@@ -34,26 +31,30 @@ class DomainRefreshController extends AbstractController
* @throws HttpExceptionInterface
* @throws DecodingExceptionInterface
* @throws ExceptionInterface
* @throws Exception
* @throws \Exception
*/
public function __invoke(string $ldhName, KernelInterface $kernel): ?Domain
{
/** @var Domain $domain */
$domain = $this->domainRepository->findOneBy(["ldhName" => $ldhName]);
$domain = $this->domainRepository->findOneBy(['ldhName' => $ldhName]);
// If the domain name exists in the database, recently updated and not important, we return the stored Domain
if ($domain !== null &&
!$domain->getDeleted() &&
($domain->getUpdatedAt()->diff(new DateTimeImmutable('now'))->days < 7) &&
!$this->RDAPService::isToBeWatchClosely($domain, $domain->getUpdatedAt())
) return $domain;
if (null !== $domain
&& !$domain->getDeleted()
&& ($domain->getUpdatedAt()->diff(new \DateTimeImmutable('now'))->days < 7)
&& !$this->RDAPService::isToBeWatchClosely($domain, $domain->getUpdatedAt())
) {
return $domain;
}
if (false === $kernel->isDebug()) {
$limiter = $this->authenticatedApiLimiter->create($this->getUser()->getUserIdentifier());
if (false === $limiter->consume()->isAccepted()) throw new TooManyRequestsHttpException();
if (false === $limiter->consume()->isAccepted()) {
throw new TooManyRequestsHttpException();
}
}
$updatedAt = $domain === null ? new DateTimeImmutable('now') : $domain->getUpdatedAt();
$updatedAt = null === $domain ? new \DateTimeImmutable('now') : $domain->getUpdatedAt();
$domain = $this->RDAPService->registerDomain($ldhName);
/** @var WatchList $watchList */
@@ -63,4 +64,4 @@ class DomainRefreshController extends AbstractController
return $domain;
}
}
}

View File

@@ -12,29 +12,30 @@ use Symfony\Component\Routing\RouterInterface;
class HomeController extends AbstractController
{
public function __construct(private readonly RouterInterface $router)
{
}
#[Route(path: "/", name: "index")]
#[Route(path: '/', name: 'index')]
public function index(): Response
{
return $this->render('base.html.twig');
}
#[Route(path: "/login/oauth", name: "oauth_connect")]
#[Route(path: '/login/oauth', name: 'oauth_connect')]
public function connectAction(ClientRegistry $clientRegistry): Response
{
return $clientRegistry->getClient('oauth')->redirect();
}
#[Route(path: "/logout", name: "logout")]
#[Route(path: '/logout', name: 'logout')]
public function logout(Security $security): ?RedirectResponse
{
$response = new RedirectResponse($this->router->generate('index'));
$response->headers->clearCookie('BEARER');
if ($security->isGranted('IS_AUTHENTICATED')) $security->logout(false);
if ($security->isGranted('IS_AUTHENTICATED')) {
$security->logout(false);
}
return $response;
}

View File

@@ -7,10 +7,8 @@ use Symfony\Component\Security\Core\User\UserInterface;
class MeController extends AbstractController
{
public function __invoke(): UserInterface
{
return $this->getUser();
}
}
}

View File

@@ -17,7 +17,6 @@ use Eluceo\iCal\Domain\ValueObject\Date;
use Eluceo\iCal\Domain\ValueObject\EmailAddress;
use Eluceo\iCal\Domain\ValueObject\SingleDay;
use Eluceo\iCal\Presentation\Factory\CalendarFactory;
use Exception;
use Sabre\VObject\EofException;
use Sabre\VObject\InvalidDataException;
use Sabre\VObject\ParseException;
@@ -30,17 +29,15 @@ use Symfony\Component\Serializer\SerializerInterface;
class WatchListController extends AbstractController
{
public function __construct(
private readonly SerializerInterface $serializer,
private readonly SerializerInterface $serializer,
private readonly EntityManagerInterface $em,
private readonly WatchListRepository $watchListRepository
)
{
private readonly WatchListRepository $watchListRepository
) {
}
/**
* @throws Exception
* @throws \Exception
*/
#[Route(
path: '/api/watchlists',
@@ -66,7 +63,7 @@ class WatchListController extends AbstractController
* @throws ParseException
* @throws EofException
* @throws InvalidDataException
* @throws Exception
* @throws \Exception
*/
#[Route(
path: '/api/watchlists/{token}/calendar',
@@ -79,7 +76,7 @@ class WatchListController extends AbstractController
public function getWatchlistCalendar(string $token): Response
{
/** @var WatchList $watchList */
$watchList = $this->watchListRepository->findOneBy(["token" => $token]);
$watchList = $this->watchListRepository->findOneBy(['token' => $token]);
$calendar = new Calendar();
@@ -89,16 +86,18 @@ class WatchListController extends AbstractController
/** @var DomainEntity $entity */
foreach ($domain->getDomainEntities()->toArray() as $entity) {
$vCard = Reader::readJson($entity->getEntity()->getJCard());
$email = (string)$vCard->EMAIL;
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) continue;
$email = (string) $vCard->EMAIL;
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
continue;
}
$attendees[] = (new Attendee(new EmailAddress($email)))->setDisplayName((string)$vCard->FN);
$attendees[] = (new Attendee(new EmailAddress($email)))->setDisplayName((string) $vCard->FN);
}
/** @var DomainEvent $event */
foreach ($domain->getEvents()->toArray() as $event) {
$calendar->addEvent((new Event())
->setSummary($domain->getLdhName() . ' (' . $event->getAction() . ')')
->setSummary($domain->getLdhName().' ('.$event->getAction().')')
->addCategory(new Category($event->getAction()))
->setAttendees($attendees)
->setOccurrence(new SingleDay(new Date($event->getDate())))
@@ -107,7 +106,7 @@ class WatchListController extends AbstractController
}
return new Response((new CalendarFactory())->createCalendar($calendar), Response::HTTP_OK, [
"Content-Type" => 'text/calendar; charset=utf-8'
'Content-Type' => 'text/calendar; charset=utf-8',
]);
}
@@ -124,7 +123,7 @@ class WatchListController extends AbstractController
{
/** @var User $user */
$user = $this->getUser();
return $user->getWatchLists();
}
}
}

View File

@@ -31,7 +31,7 @@ use Symfony\Component\Uid\Uuid;
denormalizationContext: ['groups' => 'connector:create'],
name: 'create'
),
new Delete()
new Delete(),
]
)]
#[ORM\Entity(repositoryClass: ConnectorRepository::class)]
@@ -46,7 +46,6 @@ class Connector
#[ORM\JoinColumn(nullable: false)]
private ?User $user = null;
#[Groups(['connector:list', 'connector:create', 'watchlist:list'])]
#[ORM\Column(enumType: ConnectorProvider::class)]
private ?ConnectorProvider $provider = null;
@@ -61,7 +60,6 @@ class Connector
#[ORM\OneToMany(targetEntity: WatchList::class, mappedBy: 'connector')]
private Collection $watchLists;
public function __construct()
{
$this->id = Uuid::v4();
@@ -138,5 +136,4 @@ class Connector
return $this;
}
}

View File

@@ -6,7 +6,6 @@ use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use App\Controller\DomainRefreshController;
use App\Repository\DomainRepository;
use DateTimeImmutable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
@@ -27,7 +26,7 @@ use Symfony\Component\Serializer\Attribute\SerializedName;
),
*/
new Get(
uriTemplate: '/domains/{ldhName}', # Do not delete this line, otherwise Symfony interprets the TLD of the domain name as a return type
uriTemplate: '/domains/{ldhName}', // Do not delete this line, otherwise Symfony interprets the TLD of the domain name as a return type
controller: DomainRefreshController::class,
normalizationContext: [
'groups' => [
@@ -36,11 +35,11 @@ use Symfony\Component\Serializer\Attribute\SerializedName;
'domain-entity:entity',
'nameserver-entity:nameserver',
'nameserver-entity:entity',
'tld:item'
]
'tld:item',
],
],
read: false
)
),
]
)]
class Domain
@@ -91,10 +90,10 @@ class Domain
private Collection $nameservers;
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
private ?DateTimeImmutable $createdAt = null;
private ?\DateTimeImmutable $createdAt = null;
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
private ?DateTimeImmutable $updatedAt = null;
private ?\DateTimeImmutable $updatedAt = null;
#[ORM\ManyToOne]
#[ORM\JoinColumn(referencedColumnName: 'tld', nullable: false)]
@@ -111,8 +110,8 @@ class Domain
$this->domainEntities = new ArrayCollection();
$this->watchLists = new ArrayCollection();
$this->nameservers = new ArrayCollection();
$this->createdAt = new DateTimeImmutable('now');
$this->updatedAt = new DateTimeImmutable('now');
$this->createdAt = new \DateTimeImmutable('now');
$this->updatedAt = new \DateTimeImmutable('now');
$this->deleted = false;
}
@@ -264,7 +263,7 @@ class Domain
return $this;
}
public function getUpdatedAt(): ?DateTimeImmutable
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
@@ -273,27 +272,25 @@ class Domain
#[ORM\PreUpdate]
public function updateTimestamps(): void
{
$this->setUpdatedAt(new DateTimeImmutable('now'));
if ($this->getCreatedAt() === null) {
$this->setCreatedAt(new DateTimeImmutable('now'));
$this->setUpdatedAt(new \DateTimeImmutable('now'));
if (null === $this->getCreatedAt()) {
$this->setCreatedAt(new \DateTimeImmutable('now'));
}
}
private function setUpdatedAt(?DateTimeImmutable $updatedAt): void
private function setUpdatedAt(?\DateTimeImmutable $updatedAt): void
{
$this->updatedAt = $updatedAt;
}
public function getCreatedAt(): ?DateTimeImmutable
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
private function setCreatedAt(?DateTimeImmutable $createdAt): void
private function setCreatedAt(?\DateTimeImmutable $createdAt): void
{
$this->createdAt = $createdAt;
}
public function getTld(): ?Tld

View File

@@ -27,7 +27,6 @@ class DomainEntity
#[Groups(['domain-entity:entity', 'domain-entity:domain'])]
private array $roles = [];
public function getDomain(): ?Domain
{
return $this->domain;
@@ -66,5 +65,4 @@ class DomainEntity
return $this;
}
}

View File

@@ -31,16 +31,14 @@ use Symfony\Component\Serializer\Attribute\SerializedName;
'domain-entity:domain',
'domain:list',
'nameserver-entity:nameserver',
'nameserver:list'
]
'nameserver:list',
],
]
)
),
]
)]
class Entity
{
#[ORM\Id]
#[ORM\Column(length: 255)]
#[Groups(['entity:list', 'entity:item', 'domain:item'])]
@@ -193,5 +191,4 @@ class Entity
return $this;
}
}

View File

@@ -8,12 +8,10 @@ use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: EntityEventRepository::class)]
class EntityEvent extends Event
{
#[ORM\ManyToOne(targetEntity: Entity::class, inversedBy: 'events')]
#[ORM\JoinColumn(referencedColumnName: 'handle', nullable: false)]
private ?Entity $entity = null;
public function getEntity(): ?Entity
{
return $this->entity;

View File

@@ -2,8 +2,6 @@
namespace App\Entity;
use App\Config\EventAction;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Attribute\Groups;
@@ -21,8 +19,7 @@ class Event
#[ORM\Column(type: 'datetime_immutable')]
#[Groups(['event:list'])]
private ?DateTimeImmutable $date = null;
private ?\DateTimeImmutable $date = null;
public function getId(): ?int
{
@@ -41,16 +38,15 @@ class Event
return $this;
}
public function getDate(): ?DateTimeImmutable
public function getDate(): ?\DateTimeImmutable
{
return $this->date;
}
public function setDate(DateTimeImmutable $date): static
public function setDate(\DateTimeImmutable $date): static
{
$this->date = $date;
return $this;
}
}

View File

@@ -19,8 +19,8 @@ use Symfony\Component\Serializer\Attribute\SerializedName;
uriTemplate: '/nameservers',
normalizationContext: [
'groups' => [
'nameserver:list'
]
'nameserver:list',
],
]
),
new Get(
@@ -30,15 +30,14 @@ use Symfony\Component\Serializer\Attribute\SerializedName;
'nameserver:item',
'nameserver-entity:entity',
'entity:list',
"event:list"
]
'event:list',
],
]
)
),
]
)]
class Nameserver
{
#[ORM\Id]
#[ORM\Column(length: 255)]
#[Groups(['nameserver:item', 'nameserver:list', 'domain:item'])]
@@ -133,5 +132,4 @@ class Nameserver
return $this;
}
}

View File

@@ -23,7 +23,6 @@ class NameserverEntity
#[Groups(['nameserver-entity:entity'])]
private ?Entity $entity = null;
#[ORM\Column(type: Types::SIMPLE_ARRAY)]
#[Groups(['nameserver-entity:entity', 'nameserver-entity:nameserver'])]
private array $roles = [];
@@ -82,5 +81,4 @@ class NameserverEntity
return $this;
}
}

View File

@@ -3,30 +3,27 @@
namespace App\Entity;
use App\Repository\RdapServerRepository;
use DateTimeImmutable;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: RdapServerRepository::class)]
class RdapServer
{
#[ORM\Id]
#[ORM\Column(length: 255)]
private ?string $url = null;
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
private ?DateTimeImmutable $updatedAt = null;
private ?\DateTimeImmutable $updatedAt = null;
#[ORM\Id]
#[ORM\ManyToOne(inversedBy: 'rdapServers')]
#[ORM\JoinColumn(referencedColumnName: 'tld', nullable: false)]
private ?Tld $tld = null;
public function __construct()
{
$this->updatedAt = new DateTimeImmutable('now');
$this->updatedAt = new \DateTimeImmutable('now');
}
public function getUrl(): ?string
@@ -41,12 +38,12 @@ class RdapServer
return $this;
}
public function getUpdatedAt(): ?DateTimeImmutable
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
public function setUpdatedAt(DateTimeImmutable $updatedAt): static
public function setUpdatedAt(\DateTimeImmutable $updatedAt): static
{
$this->updatedAt = $updatedAt;
@@ -57,7 +54,7 @@ class RdapServer
#[ORM\PreUpdate]
public function updateTimestamps(): void
{
$this->setUpdatedAt(new DateTimeImmutable('now'));
$this->setUpdatedAt(new \DateTimeImmutable('now'));
}
public function getTld(): ?Tld

View File

@@ -9,7 +9,6 @@ use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use App\Config\TldType;
use App\Repository\TldRepository;
use DateTimeImmutable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
@@ -26,7 +25,7 @@ use Symfony\Component\Serializer\Attribute\Groups;
new Get(
uriTemplate: '/tld/{tld}',
normalizationContext: ['groups' => ['tld:item']]
)
),
]
)]
#[ApiFilter(SearchFilter::class)]
@@ -35,7 +34,7 @@ class Tld
{
#[ORM\Id]
#[ORM\Column(length: 63)]
#[Groups(["tld:list", "tld:item"])]
#[Groups(['tld:list', 'tld:item'])]
private ?string $tld = null;
/**
* @var Collection<int, RdapServer>
@@ -44,31 +43,31 @@ class Tld
private Collection $rdapServers;
#[ORM\Column(nullable: true)]
#[Groups(["tld:list", "tld:item"])]
#[Groups(['tld:list', 'tld:item'])]
private ?bool $contractTerminated = null;
#[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)]
#[Groups(["tld:item"])]
private ?DateTimeImmutable $dateOfContractSignature = null;
#[Groups(['tld:item'])]
private ?\DateTimeImmutable $dateOfContractSignature = null;
#[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)]
#[Groups(["tld:item"])]
private ?DateTimeImmutable $delegationDate = null;
#[Groups(['tld:item'])]
private ?\DateTimeImmutable $delegationDate = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(["tld:list", "tld:item"])]
#[Groups(['tld:list', 'tld:item'])]
private ?string $registryOperator = null;
#[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)]
#[Groups(["tld:item"])]
private ?DateTimeImmutable $removalDate = null;
#[Groups(['tld:item'])]
private ?\DateTimeImmutable $removalDate = null;
#[ORM\Column(nullable: true)]
#[Groups(["tld:list", "tld:item"])]
#[Groups(['tld:list', 'tld:item'])]
private ?bool $specification13 = null;
#[ORM\Column(length: 10, enumType: TldType::class)]
#[Groups(["tld:item"])]
#[Groups(['tld:item'])]
private ?TldType $type = null;
public function __construct()
@@ -130,24 +129,24 @@ class Tld
return $this;
}
public function getDateOfContractSignature(): ?DateTimeImmutable
public function getDateOfContractSignature(): ?\DateTimeImmutable
{
return $this->dateOfContractSignature;
}
public function setDateOfContractSignature(?DateTimeImmutable $dateOfContractSignature): static
public function setDateOfContractSignature(?\DateTimeImmutable $dateOfContractSignature): static
{
$this->dateOfContractSignature = $dateOfContractSignature;
return $this;
}
public function getDelegationDate(): ?DateTimeImmutable
public function getDelegationDate(): ?\DateTimeImmutable
{
return $this->delegationDate;
}
public function setDelegationDate(?DateTimeImmutable $delegationDate): static
public function setDelegationDate(?\DateTimeImmutable $delegationDate): static
{
$this->delegationDate = $delegationDate;
@@ -166,12 +165,12 @@ class Tld
return $this;
}
public function getRemovalDate(): ?DateTimeImmutable
public function getRemovalDate(): ?\DateTimeImmutable
{
return $this->removalDate;
}
public function setRemovalDate(?DateTimeImmutable $removalDate): static
public function setRemovalDate(?\DateTimeImmutable $removalDate): static
{
$this->removalDate = $removalDate;

View File

@@ -16,16 +16,16 @@ use Symfony\Component\Serializer\Attribute\Groups;
#[ORM\Entity(repositoryClass: UserRepository::class)]
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_EMAIL', fields: ['email'])]
#[ORM\Table(name: "`user`")]
#[ORM\Table(name: '`user`')]
#[UniqueEntity(fields: ['email'], message: 'There is already an account with this email')]
#[ApiResource(
operations: [
new Get(
uriTemplate: '/me',
controller: MeController::class,
normalizationContext: ["groups" => "user:list"],
normalizationContext: ['groups' => 'user:list'],
read: false
)
),
]
)]
class User implements UserInterface, PasswordAuthenticatedUserInterface
@@ -94,13 +94,13 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
*/
public function getUserIdentifier(): string
{
return (string)$this->email;
return (string) $this->email;
}
/**
* @return list<string>
* @see UserInterface
*
* @see UserInterface
*/
public function getRoles(): array
{
@@ -112,7 +112,6 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
}
/**
* @param array $roles
* @return User
*/
public function setRoles(array $roles): static

View File

@@ -40,12 +40,12 @@ use Symfony\Component\Uid\Uuid;
'text/calendar' => [
'schema' => [
'type' => 'string',
'format' => 'text'
]
]
]
]
]
'format' => 'text',
],
],
],
],
],
],
read: false,
deserialize: false,
@@ -61,7 +61,7 @@ use Symfony\Component\Uid\Uuid;
normalizationContext: ['groups' => 'watchlist:item'],
denormalizationContext: ['groups' => 'watchlist:update']
),
new Delete()
new Delete(),
],
)]
class WatchList
@@ -90,14 +90,13 @@ class WatchList
*/
#[ORM\OneToMany(targetEntity: WatchListTrigger::class, mappedBy: 'watchList', cascade: ['persist'], orphanRemoval: true)]
#[Groups(['watchlist:list', 'watchlist:item', 'watchlist:create', 'watchlist:update'])]
#[SerializedName("triggers")]
#[SerializedName('triggers')]
private Collection $watchListTriggers;
#[ORM\ManyToOne(inversedBy: 'watchLists')]
#[Groups(['watchlist:list', 'watchlist:item', 'watchlist:create', 'watchlist:update'])]
private ?Connector $connector = null;
public function __construct()
{
$this->token = Uuid::v4();

View File

@@ -2,17 +2,12 @@
namespace App\Message;
use App\Entity\Domain;
use App\Entity\WatchList;
use DateTimeImmutable;
final class ProcessDomainTrigger
{
public function __construct(
public string $watchListToken,
public string $ldhName,
public DateTimeImmutable $updatedAt
)
{
public string $watchListToken,
public string $ldhName,
public \DateTimeImmutable $updatedAt
) {
}
}

View File

@@ -2,14 +2,10 @@
namespace App\Message;
use App\Entity\WatchList;
final readonly class ProcessWatchListTrigger
{
public function __construct(
public string $watchListToken,
)
{
) {
}
}

View File

@@ -14,63 +14,61 @@ use App\Entity\WatchListTrigger;
use App\Message\ProcessDomainTrigger;
use App\Repository\DomainRepository;
use App\Repository\WatchListRepository;
use Exception;
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
use Symfony\Component\Mime\Email;
use Throwable;
#[AsMessageHandler]
final readonly class ProcessDomainTriggerHandler
{
public function __construct(
private string $mailerSenderEmail,
private MailerInterface $mailer,
private string $mailerSenderEmail,
private MailerInterface $mailer,
private WatchListRepository $watchListRepository,
private DomainRepository $domainRepository,
private KernelInterface $kernel
)
{
private DomainRepository $domainRepository,
private KernelInterface $kernel
) {
}
/**
* @throws TransportExceptionInterface
* @throws Exception
* @throws \Exception
*/
public function __invoke(ProcessDomainTrigger $message): void
{
/** @var WatchList $watchList */
$watchList = $this->watchListRepository->findOneBy(["token" => $message->watchListToken]);
$watchList = $this->watchListRepository->findOneBy(['token' => $message->watchListToken]);
/** @var Domain $domain */
$domain = $this->domainRepository->findOneBy(["ldhName" => $message->ldhName]);
$domain = $this->domainRepository->findOneBy(['ldhName' => $message->ldhName]);
$connector = $watchList->getConnector();
if (null !== $connector && $domain->getDeleted()) {
try {
if ($connector->getProvider() === ConnectorProvider::OVH) {
$ovh = new OVHConnector($connector->getAuthData());
if (ConnectorProvider::OVH === $connector->getProvider()) {
$ovh = new OvhConnector($connector->getAuthData());
$isDebug = $this->kernel->isDebug();
$ovh->orderDomain($domain, $isDebug);
$this->sendEmailDomainOrdered($domain, $connector, $watchList->getUser());
} else throw new Exception("Unknown provider");
} catch (Throwable) {
} else {
throw new \Exception('Unknown provider');
}
} catch (\Throwable) {
$this->sendEmailDomainOrderError($domain, $watchList->getUser());
}
}
/** @var DomainEvent $event */
foreach ($domain->getEvents()->filter(fn($event) => $message->updatedAt < $event->getDate()) as $event) {
foreach ($domain->getEvents()->filter(fn ($event) => $message->updatedAt < $event->getDate()) as $event) {
$watchListTriggers = $watchList->getWatchListTriggers()
->filter(fn($trigger) => $trigger->getEvent() === $event->getAction());
->filter(fn ($trigger) => $trigger->getEvent() === $event->getAction());
/** @var WatchListTrigger $watchListTrigger */
foreach ($watchListTriggers->getIterator() as $watchListTrigger) {
if ($watchListTrigger->getAction() == TriggerAction::SendEmail) {
if (TriggerAction::SendEmail == $watchListTrigger->getAction()) {
$this->sendEmailDomainUpdated($event, $watchList->getUser());
}
}
@@ -90,8 +88,8 @@ final readonly class ProcessDomainTriggerHandler
->htmlTemplate('emails/success/domain_ordered.html.twig')
->locale('en')
->context([
"domain" => $domain,
"provider" => $connector->getProvider()->value
'domain' => $domain,
'provider' => $connector->getProvider()->value,
]);
$this->mailer->send($email);
@@ -109,7 +107,7 @@ final readonly class ProcessDomainTriggerHandler
->htmlTemplate('emails/errors/domain_order.html.twig')
->locale('en')
->context([
"domain" => $domain
'domain' => $domain,
]);
$this->mailer->send($email);
@@ -128,10 +126,9 @@ final readonly class ProcessDomainTriggerHandler
->htmlTemplate('emails/success/domain_updated.html.twig')
->locale('en')
->context([
"event" => $domainEvent
'event' => $domainEvent,
]);
$this->mailer->send($email);
}
}

View File

@@ -9,8 +9,6 @@ use App\Message\ProcessDomainTrigger;
use App\Message\ProcessWatchListTrigger;
use App\Repository\WatchListRepository;
use App\Service\RDAPService;
use DateTimeImmutable;
use Exception;
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
use Symfony\Component\Mailer\MailerInterface;
@@ -18,36 +16,33 @@ use Symfony\Component\Messenger\Attribute\AsMessageHandler;
use Symfony\Component\Messenger\Exception\ExceptionInterface;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Contracts\HttpClient\Exception\HttpExceptionInterface;
use Throwable;
#[AsMessageHandler]
final readonly class ProcessWatchListTriggerHandler
{
public function __construct(
private RDAPService $RDAPService,
private MailerInterface $mailer,
private string $mailerSenderEmail,
private RDAPService $RDAPService,
private MailerInterface $mailer,
private string $mailerSenderEmail,
private MessageBusInterface $bus,
private WatchListRepository $watchListRepository
)
{
) {
}
/**
* @throws TransportExceptionInterface
* @throws Exception
* @throws \Exception
* @throws ExceptionInterface
*/
public function __invoke(ProcessWatchListTrigger $message): void
{
/** @var WatchList $watchList */
$watchList = $this->watchListRepository->findOneBy(["token" => $message->watchListToken]);
$watchList = $this->watchListRepository->findOneBy(['token' => $message->watchListToken]);
/** @var Domain $domain */
foreach ($watchList->getDomains()
->filter(fn($domain) => $domain->getUpdatedAt()
->filter(fn ($domain) => $domain->getUpdatedAt()
->diff(
new DateTimeImmutable('now'))->days >= 7
new \DateTimeImmutable('now'))->days >= 7
|| $this->RDAPService::isToBeWatchClosely($domain, $domain->getUpdatedAt())
) as $domain
) {
@@ -55,8 +50,10 @@ final readonly class ProcessWatchListTriggerHandler
try {
$domain = $this->RDAPService->registerDomain($domain->getLdhName());
} catch (Throwable $e) {
if (!($e instanceof HttpExceptionInterface)) continue;
} catch (\Throwable $e) {
if (!($e instanceof HttpExceptionInterface)) {
continue;
}
$this->sendEmailDomainUpdateError($domain, $watchList->getUser());
}
@@ -77,7 +74,6 @@ final readonly class ProcessWatchListTriggerHandler
}
}
/**
* @throws TransportExceptionInterface
*/
@@ -90,7 +86,7 @@ final readonly class ProcessWatchListTriggerHandler
->htmlTemplate('emails/errors/domain_update.html.twig')
->locale('en')
->context([
"domain" => $domain
'domain' => $domain,
]);
$this->mailer->send($email);

View File

@@ -11,14 +11,12 @@ use Symfony\Component\Messenger\Exception\ExceptionInterface;
use Symfony\Component\Messenger\MessageBusInterface;
#[AsMessageHandler]
readonly final class ProcessWatchListsTriggerHandler
final readonly class ProcessWatchListsTriggerHandler
{
public function __construct(
private WatchListRepository $watchListRepository,
private MessageBusInterface $bus
)
{
) {
}
/**
@@ -31,5 +29,4 @@ readonly final class ProcessWatchListsTriggerHandler
$this->bus->dispatch(new ProcessWatchListTrigger($watchList->getToken()));
}
}
}

View File

@@ -10,14 +10,12 @@ use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Throwable;
#[AsMessageHandler]
final readonly class UpdateRdapServersHandler
{
public function __construct(private RDAPService $RDAPService)
{
}
/**
@@ -25,23 +23,25 @@ final readonly class UpdateRdapServersHandler
* @throws ServerExceptionInterface
* @throws RedirectionExceptionInterface
* @throws DecodingExceptionInterface
* @throws ClientExceptionInterface|Throwable
* @throws ClientExceptionInterface|\Throwable
*/
public function __invoke(UpdateRdapServers $message): void
{
/** @var Throwable[] $throws */
/** @var \Throwable[] $throws */
$throws = [];
try {
$this->RDAPService->updateTldListIANA();
$this->RDAPService->updateGTldListICANN();
} catch (Throwable $throwable) {
} catch (\Throwable $throwable) {
$throws[] = $throwable;
}
try {
$this->RDAPService->updateRDAPServers();
} catch (Throwable $throwable) {
} catch (\Throwable $throwable) {
$throws[] = $throwable;
}
if (!empty($throws)) throw $throws[0];
if (!empty($throws)) {
throw $throws[0];
}
}
}

View File

@@ -16,28 +16,28 @@ class DomainEntityRepository extends ServiceEntityRepository
parent::__construct($registry, DomainEntity::class);
}
// /**
// * @return DomainEntity[] Returns an array of DomainEntity objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('d')
// ->andWhere('d.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('d.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// /**
// * @return DomainEntity[] Returns an array of DomainEntity objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('d')
// ->andWhere('d.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('d.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?DomainEntity
// {
// return $this->createQueryBuilder('d')
// ->andWhere('d.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
// public function findOneBySomeField($value): ?DomainEntity
// {
// return $this->createQueryBuilder('d')
// ->andWhere('d.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}

View File

@@ -16,28 +16,28 @@ class RdapServerRepository extends ServiceEntityRepository
parent::__construct($registry, RdapServer::class);
}
// /**
// * @return RdapServer[] Returns an array of RdapServer objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('r')
// ->andWhere('r.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('r.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// /**
// * @return RdapServer[] Returns an array of RdapServer objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('r')
// ->andWhere('r.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('r.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?RdapServer
// {
// return $this->createQueryBuilder('r')
// ->andWhere('r.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
// public function findOneBySomeField($value): ?RdapServer
// {
// return $this->createQueryBuilder('r')
// ->andWhere('r.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}

View File

@@ -14,8 +14,7 @@ final readonly class SendNotifWatchListTriggerSchedule implements ScheduleProvid
{
public function __construct(
private CacheInterface $cache,
)
{
) {
}
public function getSchedule(): Schedule

View File

@@ -14,8 +14,7 @@ final readonly class UpdateRdapServersSchedule implements ScheduleProviderInterf
{
public function __construct(
private CacheInterface $cache,
)
{
) {
}
public function getSchedule(): Schedule

View File

@@ -20,17 +20,15 @@ use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport;
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
class OAuthAuthenticator extends OAuth2Authenticator implements AuthenticationEntrypointInterface
class OAuthAuthenticator extends OAuth2Authenticator implements AuthenticationEntryPointInterface
{
public function __construct(
private readonly ClientRegistry $clientRegistry,
private readonly UserRepository $userRepository,
private readonly EntityManagerInterface $em,
private readonly RouterInterface $router,
private readonly ClientRegistry $clientRegistry,
private readonly UserRepository $userRepository,
private readonly EntityManagerInterface $em,
private readonly RouterInterface $router,
private readonly JWTTokenManagerInterface $JWTManager
)
{
) {
}
/**
@@ -40,7 +38,7 @@ class OAuthAuthenticator extends OAuth2Authenticator implements AuthenticationEn
*/
public function supports(Request $request): ?bool
{
return $request->attributes->get('_route') === 'oauth_connect_check';
return 'oauth_connect_check' === $request->attributes->get('_route');
}
public function authenticate(Request $request): Passport
@@ -50,13 +48,14 @@ class OAuthAuthenticator extends OAuth2Authenticator implements AuthenticationEn
return new SelfValidatingPassport(
new UserBadge($accessToken->getToken(), function () use ($accessToken, $client) {
/** @var OAuthResourceOwner $userFromToken */
$userFromToken = $client->fetchUserFromToken($accessToken);
$existingUser = $this->userRepository->findOneBy(['email' => $userFromToken->getEmail()]);
if ($existingUser) return $existingUser;
if ($existingUser) {
return $existingUser;
}
$user = new User();
$user->setEmail($userFromToken->getEmail());
@@ -85,6 +84,7 @@ class OAuthAuthenticator extends OAuth2Authenticator implements AuthenticationEn
'strict'
)
);
return $response;
}

View File

@@ -13,11 +13,9 @@ class OAuthProvider extends AbstractProvider
{
use BearerAuthorizationTrait;
public function __construct(private readonly array $options = [], array $collaborators = [])
{
parent::__construct($options, $collaborators);
}
public function getBaseAuthorizationUrl(): string
@@ -43,11 +41,7 @@ class OAuthProvider extends AbstractProvider
protected function checkResponse(ResponseInterface $response, $data): void
{
if ($response->getStatusCode() >= 400) {
throw new IdentityProviderException(
$data['error'] ?? 'Unknown error',
$response->getStatusCode(),
$response
);
throw new IdentityProviderException($data['error'] ?? 'Unknown error', $response->getStatusCode(), $response);
}
}
@@ -55,4 +49,4 @@ class OAuthProvider extends AbstractProvider
{
return new OAuthResourceOwner($response);
}
}
}

View File

@@ -37,4 +37,4 @@ class OAuthResourceOwner implements ResourceOwnerInterface
{
return $this->response['name'];
}
}
}

View File

@@ -1,6 +1,5 @@
<?php
namespace App\Service;
use App\Config\EventAction;
@@ -23,10 +22,8 @@ use App\Repository\NameserverEntityRepository;
use App\Repository\NameserverRepository;
use App\Repository\RdapServerRepository;
use App\Repository\TldRepository;
use DateTimeImmutable;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Exception\ORMException;
use Exception;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\HttpExceptionInterface;
@@ -40,9 +37,9 @@ readonly class RDAPService
/**
* @see https://www.iana.org/domains/root/db
*/
const ISO_TLD_EXCEPTION = ['ac', 'eu', 'uk', 'su', 'tp'];
const INFRA_TLD = ['arpa'];
const SPONSORED_TLD = [
public const ISO_TLD_EXCEPTION = ['ac', 'eu', 'uk', 'su', 'tp'];
public const INFRA_TLD = ['arpa'];
public const SPONSORED_TLD = [
'aero',
'asia',
'cat',
@@ -58,7 +55,7 @@ readonly class RDAPService
'travel',
'xxx',
];
const TEST_TLD = [
public const TEST_TLD = [
'xn--kgbechtv',
'xn--hgbk6aj7f53bba',
'xn--0zwm56d',
@@ -69,42 +66,43 @@ readonly class RDAPService
'xn--9t4b11yi5a',
'xn--deba0ad',
'xn--zckzah',
'xn--hlcj6aya9esc7a'
'xn--hlcj6aya9esc7a',
];
const IMPORTANT_EVENTS = [EventAction::Deletion->value, EventAction::Expiration->value];
public function __construct(private HttpClientInterface $client,
private EntityRepository $entityRepository,
private DomainRepository $domainRepository,
private DomainEventRepository $domainEventRepository,
private NameserverRepository $nameserverRepository,
private NameserverEntityRepository $nameserverEntityRepository,
private EntityEventRepository $entityEventRepository,
private DomainEntityRepository $domainEntityRepository,
private RdapServerRepository $rdapServerRepository,
private TldRepository $tldRepository,
private EntityManagerInterface $em
)
{
public const IMPORTANT_EVENTS = [EventAction::Deletion->value, EventAction::Expiration->value];
public function __construct(private HttpClientInterface $client,
private EntityRepository $entityRepository,
private DomainRepository $domainRepository,
private DomainEventRepository $domainEventRepository,
private NameserverRepository $nameserverRepository,
private NameserverEntityRepository $nameserverEntityRepository,
private EntityEventRepository $entityEventRepository,
private DomainEntityRepository $domainEntityRepository,
private RdapServerRepository $rdapServerRepository,
private TldRepository $tldRepository,
private EntityManagerInterface $em
) {
}
/**
* Determines if a domain name needs special attention.
* These domain names are those whose last event was expiration or deletion.
* @throws Exception
*
* @throws \Exception
*/
public static function isToBeWatchClosely(Domain $domain, DateTimeImmutable $updatedAt): bool
public static function isToBeWatchClosely(Domain $domain, \DateTimeImmutable $updatedAt): bool
{
if ($updatedAt->diff(new DateTimeImmutable('now'))->days < 1) return false;
if ($updatedAt->diff(new \DateTimeImmutable('now'))->days < 1) {
return false;
}
/** @var DomainEvent[] $events */
$events = $domain->getEvents()
->filter(fn(DomainEvent $e) => $e->getDate() <= new DateTimeImmutable('now'))
->filter(fn (DomainEvent $e) => $e->getDate() <= new \DateTimeImmutable('now'))
->toArray();
usort($events, fn(DomainEvent $e1, DomainEvent $e2) => $e2->getDate() > $e1->getDate());
usort($events, fn (DomainEvent $e1, DomainEvent $e2) => $e2->getDate() > $e1->getDate());
return !empty($events) && in_array($events[0]->getAction(), self::IMPORTANT_EVENTS);
}
@@ -122,7 +120,7 @@ readonly class RDAPService
}
/**
* @throws Exception
* @throws \Exception
* @throws TransportExceptionInterface
* @throws DecodingExceptionInterface
* @throws HttpExceptionInterface
@@ -133,20 +131,21 @@ readonly class RDAPService
$tld = $this->getTld($idnDomain);
/** @var RdapServer|null $rdapServer */
$rdapServer = $this->rdapServerRepository->findOneBy(["tld" => $tld], ["updatedAt" => "DESC"]);
$rdapServer = $this->rdapServerRepository->findOneBy(['tld' => $tld], ['updatedAt' => 'DESC']);
if ($rdapServer === null) throw new Exception("Unable to determine which RDAP server to contact");
if (null === $rdapServer) {
throw new \Exception('Unable to determine which RDAP server to contact');
}
/** @var ?Domain $domain */
$domain = $this->domainRepository->findOneBy(["ldhName" => $idnDomain]);
$domain = $this->domainRepository->findOneBy(['ldhName' => $idnDomain]);
try {
$res = $this->client->request(
'GET', $rdapServer->getUrl() . 'domain/' . $idnDomain
'GET', $rdapServer->getUrl().'domain/'.$idnDomain
)->toArray();
} catch (HttpExceptionInterface $e) {
if ($domain !== null) {
if (null !== $domain) {
$domain->setDeleted(true)
->updateTimestamps();
$this->em->persist($domain);
@@ -155,36 +154,45 @@ readonly class RDAPService
throw $e;
}
if ($domain === null) $domain = new Domain();
if (null === $domain) {
$domain = new Domain();
}
$domain->setTld($tld)->setLdhName($idnDomain)->setDeleted(false);
if (array_key_exists('status', $res)) $domain->setStatus($res['status']);
if (array_key_exists('handle', $res)) $domain->setHandle($res['handle']);
if (array_key_exists('status', $res)) {
$domain->setStatus($res['status']);
}
if (array_key_exists('handle', $res)) {
$domain->setHandle($res['handle']);
}
$this->em->persist($domain);
$this->em->flush();
foreach ($res['events'] as $rdapEvent) {
if ($rdapEvent['eventAction'] === EventAction::LastUpdateOfRDAPDatabase->value) continue;
if ($rdapEvent['eventAction'] === EventAction::LastUpdateOfRDAPDatabase->value) {
continue;
}
$event = $this->domainEventRepository->findOneBy([
"action" => $rdapEvent['eventAction'],
"date" => new DateTimeImmutable($rdapEvent["eventDate"]),
"domain" => $domain
'action' => $rdapEvent['eventAction'],
'date' => new \DateTimeImmutable($rdapEvent['eventDate']),
'domain' => $domain,
]);
if ($event === null) $event = new DomainEvent();
if (null === $event) {
$event = new DomainEvent();
}
$domain->addEvent($event
->setAction($rdapEvent['eventAction'])
->setDate(new DateTimeImmutable($rdapEvent['eventDate'])));
->setDate(new \DateTimeImmutable($rdapEvent['eventDate'])));
}
if (array_key_exists('entities', $res) && is_array($res['entities'])) {
foreach ($res['entities'] as $rdapEntity) {
if (!array_key_exists('handle', $rdapEntity) || $rdapEntity['handle'] === '') continue;
if (!array_key_exists('handle', $rdapEntity) || '' === $rdapEntity['handle']) {
continue;
}
$entity = $this->registerEntity($rdapEntity);
@@ -192,21 +200,25 @@ readonly class RDAPService
$this->em->flush();
$domainEntity = $this->domainEntityRepository->findOneBy([
"domain" => $domain,
"entity" => $entity
'domain' => $domain,
'entity' => $entity,
]);
if ($domainEntity === null) $domainEntity = new DomainEntity();
if (null === $domainEntity) {
$domainEntity = new DomainEntity();
}
$roles = array_map(
fn($e) => $e['roles'],
fn ($e) => $e['roles'],
array_filter(
$res['entities'],
fn($e) => array_key_exists('handle', $e) && $e['handle'] === $rdapEntity['handle']
fn ($e) => array_key_exists('handle', $e) && $e['handle'] === $rdapEntity['handle']
)
);
if (count($roles) !== count($roles, COUNT_RECURSIVE)) $roles = array_merge(...$roles);
if (count($roles) !== count($roles, COUNT_RECURSIVE)) {
$roles = array_merge(...$roles);
}
$domain->addDomainEntity($domainEntity
->setDomain($domain)
@@ -221,9 +233,11 @@ readonly class RDAPService
if (array_key_exists('nameservers', $res) && is_array($res['nameservers'])) {
foreach ($res['nameservers'] as $rdapNameserver) {
$nameserver = $this->nameserverRepository->findOneBy([
"ldhName" => strtolower($rdapNameserver['ldhName'])
'ldhName' => strtolower($rdapNameserver['ldhName']),
]);
if ($nameserver === null) $nameserver = new Nameserver();
if (null === $nameserver) {
$nameserver = new Nameserver();
}
$nameserver->setLdhName($rdapNameserver['ldhName']);
@@ -233,29 +247,32 @@ readonly class RDAPService
}
foreach ($rdapNameserver['entities'] as $rdapEntity) {
if (!array_key_exists('handle', $rdapEntity) || $rdapEntity['handle'] === '') continue;
if (!array_key_exists('handle', $rdapEntity) || '' === $rdapEntity['handle']) {
continue;
}
$entity = $this->registerEntity($rdapEntity);
$this->em->persist($entity);
$this->em->flush();
$nameserverEntity = $this->nameserverEntityRepository->findOneBy([
"nameserver" => $nameserver,
"entity" => $entity
'nameserver' => $nameserver,
'entity' => $entity,
]);
if ($nameserverEntity === null) $nameserverEntity = new NameserverEntity();
if (null === $nameserverEntity) {
$nameserverEntity = new NameserverEntity();
}
$roles = array_merge(
...array_map(
fn(array $e): array => $e['roles'],
fn (array $e): array => $e['roles'],
array_filter(
$rdapNameserver['entities'],
fn($e) => array_key_exists('handle', $e) && $e['handle'] === $rdapEntity['handle']
fn ($e) => array_key_exists('handle', $e) && $e['handle'] === $rdapEntity['handle']
)
)
);
$nameserver->addNameserverEntity($nameserverEntity
->setNameserver($nameserver)
->setEntity($entity)
@@ -275,29 +292,31 @@ readonly class RDAPService
}
/**
* @throws Exception
* @throws \Exception
*/
private function getTld($domain): ?object
{
$lastDotPosition = strrpos($domain, '.');
if ($lastDotPosition === false) {
throw new Exception("Domain must contain at least one dot");
if (false === $lastDotPosition) {
throw new \Exception('Domain must contain at least one dot');
}
$tld = strtolower(substr($domain, $lastDotPosition + 1));
return $this->tldRepository->findOneBy(["tld" => $tld]);
return $this->tldRepository->findOneBy(['tld' => $tld]);
}
/**
* @throws Exception
* @throws \Exception
*/
private function registerEntity(array $rdapEntity): Entity
{
$entity = $this->entityRepository->findOneBy([
"handle" => $rdapEntity['handle']
'handle' => $rdapEntity['handle'],
]);
if ($entity === null) $entity = new Entity();
if (null === $entity) {
$entity = new Entity();
}
$entity->setHandle($rdapEntity['handle']);
@@ -312,28 +331,34 @@ readonly class RDAPService
foreach ($entity->getJCard()[1] as $prop) {
$properties[$prop[0]] = $prop;
}
$entity->setJCard(["vcard", array_values($properties)]);
$entity->setJCard(['vcard', array_values($properties)]);
}
}
if (!array_key_exists('events', $rdapEntity)) return $entity;
if (!array_key_exists('events', $rdapEntity)) {
return $entity;
}
foreach ($rdapEntity['events'] as $rdapEntityEvent) {
$eventAction = $rdapEntityEvent["eventAction"];
if ($eventAction === EventAction::LastChanged->value || $eventAction === EventAction::LastUpdateOfRDAPDatabase->value) continue;
$eventAction = $rdapEntityEvent['eventAction'];
if ($eventAction === EventAction::LastChanged->value || $eventAction === EventAction::LastUpdateOfRDAPDatabase->value) {
continue;
}
$event = $this->entityEventRepository->findOneBy([
"action" => $rdapEntityEvent["eventAction"],
"date" => new DateTimeImmutable($rdapEntityEvent["eventDate"])
'action' => $rdapEntityEvent['eventAction'],
'date' => new \DateTimeImmutable($rdapEntityEvent['eventDate']),
]);
if ($event !== null) continue;
if (null !== $event) {
continue;
}
$entity->addEvent(
(new EntityEvent())
->setEntity($entity)
->setAction($rdapEntityEvent["eventAction"])
->setDate(new DateTimeImmutable($rdapEntityEvent['eventDate'])));
->setAction($rdapEntityEvent['eventAction'])
->setDate(new \DateTimeImmutable($rdapEntityEvent['eventDate'])));
}
return $entity;
}
@@ -352,19 +377,21 @@ readonly class RDAPService
)->toArray();
foreach ($dnsRoot['services'] as $service) {
foreach ($service[0] as $tld) {
if ($tld === "") continue;
if ('' === $tld) {
continue;
}
$tldReference = $this->em->getReference(Tld::class, $tld);
foreach ($service[1] as $rdapServerUrl) {
$server = $this->rdapServerRepository->findOneBy(["tld" => $tldReference, "url" => $rdapServerUrl]);
if ($server === null) $server = new RdapServer();
$server = $this->rdapServerRepository->findOneBy(['tld' => $tldReference, 'url' => $rdapServerUrl]);
if (null === $server) {
$server = new RdapServer();
}
$server->setTld($tldReference)->setUrl($rdapServerUrl)->updateTimestamps();
$this->em->persist($server);
}
}
}
$this->em->flush();
}
@@ -378,7 +405,7 @@ readonly class RDAPService
public function updateTldListIANA(): void
{
$tldList = array_map(
fn($tld) => strtolower($tld),
fn ($tld) => strtolower($tld),
explode(PHP_EOL,
$this->client->request(
'GET', 'https://data.iana.org/TLD/tlds-alpha-by-domain.txt'
@@ -387,20 +414,22 @@ readonly class RDAPService
array_shift($tldList);
foreach ($tldList as $tld) {
if ($tld === "") continue;
if ('' === $tld) {
continue;
}
$tldEntity = $this->tldRepository->findOneBy(['tld' => $tld]);
if ($tldEntity === null) {
if (null === $tldEntity) {
$tldEntity = new Tld();
$tldEntity->setTld($tld);
}
$type = $this->getTldType($tld);
if ($type !== null) {
if (null !== $type) {
$tldEntity->setType($type);
} elseif ($tldEntity->isContractTerminated() === null) { // ICANN managed, must be a ccTLD
} elseif (null === $tldEntity->isContractTerminated()) { // ICANN managed, must be a ccTLD
$tldEntity->setType(TldType::ccTLD);
} else {
$tldEntity->setType(TldType::gTLD);
@@ -413,11 +442,18 @@ readonly class RDAPService
private function getTldType(string $tld): ?TldType
{
if (in_array($tld, self::ISO_TLD_EXCEPTION)) return TldType::ccTLD;
if (in_array(strtolower($tld), self::INFRA_TLD)) return TldType::iTLD;
if (in_array(strtolower($tld), self::SPONSORED_TLD)) return TldType::sTLD;
if (in_array(strtolower($tld), self::TEST_TLD)) return TldType::tTLD;
if (in_array($tld, self::ISO_TLD_EXCEPTION)) {
return TldType::ccTLD;
}
if (in_array(strtolower($tld), self::INFRA_TLD)) {
return TldType::iTLD;
}
if (in_array(strtolower($tld), self::SPONSORED_TLD)) {
return TldType::sTLD;
}
if (in_array(strtolower($tld), self::TEST_TLD)) {
return TldType::tTLD;
}
return null;
}
@@ -428,7 +464,7 @@ readonly class RDAPService
* @throws RedirectionExceptionInterface
* @throws ClientExceptionInterface
* @throws DecodingExceptionInterface
* @throws Exception
* @throws \Exception
*/
public function updateGTldListICANN(): void
{
@@ -437,7 +473,9 @@ readonly class RDAPService
)->toArray()['gTLDs'];
foreach ($gTldList as $gTld) {
if ($gTld['gTLD'] === "") continue;
if ('' === $gTld['gTLD']) {
continue;
}
/** @var Tld $gtTldEntity */
$gtTldEntity = $this->tldRepository->findOneBy(['tld' => $gTld['gTLD']]);
@@ -452,12 +490,18 @@ readonly class RDAPService
->setSpecification13($gTld['specification13'])
->setType(TldType::gTLD);
if ($gTld['removalDate'] !== null) $gtTldEntity->setRemovalDate(new DateTimeImmutable($gTld['removalDate']));
if ($gTld['delegationDate'] !== null) $gtTldEntity->setDelegationDate(new DateTimeImmutable($gTld['delegationDate']));
if ($gTld['dateOfContractSignature'] !== null) $gtTldEntity->setDateOfContractSignature(new DateTimeImmutable($gTld['dateOfContractSignature']));
if (null !== $gTld['removalDate']) {
$gtTldEntity->setRemovalDate(new \DateTimeImmutable($gTld['removalDate']));
}
if (null !== $gTld['delegationDate']) {
$gtTldEntity->setDelegationDate(new \DateTimeImmutable($gTld['delegationDate']));
}
if (null !== $gTld['dateOfContractSignature']) {
$gtTldEntity->setDateOfContractSignature(new \DateTimeImmutable($gTld['dateOfContractSignature']));
}
$this->em->persist($gtTldEntity);
}
$this->em->flush();
}
}
}

View File

@@ -40,6 +40,18 @@
"migrations/.gitignore"
]
},
"friendsofphp/php-cs-fixer": {
"version": "3.61",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "3.0",
"ref": "be2103eb4a20942e28a6dd87736669b757132435"
},
"files": [
".php-cs-fixer.dist.php"
]
},
"knpuniversity/oauth2-client-bundle": {
"version": "2.18",
"recipe": {