ci: add phpstan

This commit is contained in:
Maël Gangloff 2024-08-03 00:06:38 +02:00
parent b460e8aaa6
commit b7899cc8a5
No known key found for this signature in database
GPG Key ID: 11FDC81C24A7F629
11 changed files with 99 additions and 14 deletions

4
.gitignore vendored
View File

@ -38,3 +38,7 @@ yarn-error.log
/.php-cs-fixer.php
/.php-cs-fixer.cache
###< friendsofphp/php-cs-fixer ###
###> phpstan/phpstan ###
phpstan.neon
###< phpstan/phpstan ###

View File

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

60
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": "94a201d97ed1f0ed40eda7bdc44e6e36",
"content-hash": "6b52bd3ad92da490e7a206500d0c0348",
"packages": [
{
"name": "api-platform/core",
@ -10390,6 +10390,64 @@
},
"time": "2022-02-21T01:04:05+00:00"
},
{
"name": "phpstan/phpstan",
"version": "1.11.9",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "e370bcddadaede0c1716338b262346f40d296f82"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/e370bcddadaede0c1716338b262346f40d296f82",
"reference": "e370bcddadaede0c1716338b262346f40d296f82",
"shasum": ""
},
"require": {
"php": "^7.2|^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": "2024-08-01T16:25:18+00:00"
},
{
"name": "phpunit/php-code-coverage",
"version": "9.2.31",

8
phpstan.dist.neon Normal file
View File

@ -0,0 +1,8 @@
parameters:
level: 5
paths:
- bin/
- config/
- public/
- src/
- tests/

View File

@ -52,7 +52,9 @@ class ConnectorController extends AbstractController
public function createConnector(Request $request): Connector
{
$connector = $this->serializer->deserialize($request->getContent(), Connector::class, 'json', ['groups' => 'connector:create']);
$connector->setUser($this->getUser());
/** @var User $user */
$user = $this->getUser();
$connector->setUser($user);
if (ConnectorProvider::OVH === $connector->getProvider()) {
$authData = OvhConnector::verifyAuthData($connector->getAuthData());

View File

@ -54,7 +54,7 @@ class DomainRefreshController extends AbstractController
}
}
$updatedAt = null === $domain ? new \DateTimeImmutable('now') : $domain->getUpdatedAt();
$updatedAt = null === $domain->getUpdatedAt() ? new \DateTimeImmutable('now') : $domain->getUpdatedAt();
$domain = $this->RDAPService->registerDomain($ldhName);
/** @var WatchList $watchList */

View File

@ -25,7 +25,7 @@ class HomeController extends AbstractController
#[Route(path: '/login/oauth', name: 'oauth_connect')]
public function connectAction(ClientRegistry $clientRegistry): Response
{
return $clientRegistry->getClient('oauth')->redirect();
return $clientRegistry->getClient('oauth')->redirect([], []);
}
#[Route(path: '/logout', name: 'logout')]

View File

@ -51,7 +51,9 @@ class WatchListController extends AbstractController
public function createWatchList(Request $request): WatchList
{
$watchList = $this->serializer->deserialize($request->getContent(), WatchList::class, 'json', ['groups' => 'watchlist:create']);
$watchList->setUser($this->getUser());
/** @var User $user */
$user = $this->getUser();
$watchList->setUser($user);
$this->em->persist($watchList);
$this->em->flush();
@ -86,13 +88,14 @@ class WatchListController extends AbstractController
/** @var DomainEntity $entity */
foreach ($domain->getDomainEntities()->toArray() as $entity) {
$vCard = Reader::readJson($entity->getEntity()->getJCard());
if (isset($vCard->EMAIL) && isset($vCard->FN)) {
$email = (string) $vCard->EMAIL;
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
continue;
}
$attendees[] = (new Attendee(new EmailAddress($email)))->setDisplayName((string) $vCard->FN);
}
}
/** @var DomainEvent $event */
foreach ($domain->getEvents()->toArray() as $event) {

View File

@ -111,9 +111,6 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
return array_unique($roles);
}
/**
* @return User
*/
public function setRoles(array $roles): static
{
$this->roles = $roles;

View File

@ -102,7 +102,7 @@ readonly class RDAPService
->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);
}

View File

@ -88,6 +88,18 @@
"config/packages/nelmio_cors.yaml"
]
},
"phpstan/phpstan": {
"version": "1.11",
"recipe": {
"repo": "github.com/symfony/recipes-contrib",
"branch": "main",
"version": "1.0",
"ref": "5e490cc197fb6bb1ae22e5abbc531ddc633b6767"
},
"files": [
"phpstan.dist.neon"
]
},
"phpunit/phpunit": {
"version": "9.6",
"recipe": {