diff --git a/composer.json b/composer.json index a6f059112..299010513 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,6 @@ "doctrine/orm": "^2.7", "erusev/parsedown": "^1.7", "graylog2/gelf-php": "^1.5", - "knplabs/knp-menu": "^3.1", "knplabs/knp-menu-bundle": "^3.0", "knplabs/knp-time-bundle": "^1.12", "league/csv": "^9.7.1", @@ -32,6 +31,7 @@ "symfony/css-selector": "^4.4", "symfony/expression-language": "^4.4", "symfony/form": "^4.4", + "symfony/framework-bundle": "^4.4", "symfony/intl": "^4.4", "symfony/mime": "^4.4", "symfony/monolog-bundle": "^3.5", @@ -47,8 +47,7 @@ "symfony/yaml": "^4.4", "twig/extra-bundle": "^3.0", "twig/intl-extra": "^3.0", - "twig/markdown-extra": "^3.3", - "twig/twig": "^3.0" + "twig/markdown-extra": "^3.3" }, "require-dev": { "doctrine/doctrine-fixtures-bundle": "^3.3", diff --git a/phpstan-deprecations.neon b/phpstan-deprecations.neon index 24deda05f..bc372e96b 100644 --- a/phpstan-deprecations.neon +++ b/phpstan-deprecations.neon @@ -859,11 +859,6 @@ parameters: count: 1 path: src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverEvent.php - - - message: "#^Call to deprecated method setTimeout\\(\\) of class Redis\\.$#" - count: 1 - path: src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverLocker.php - - message: """ diff --git a/src/Bundle/ChillMainBundle/Tests/Export/ExportManagerTest.php b/src/Bundle/ChillMainBundle/Tests/Export/ExportManagerTest.php index c09385e50..94266077a 100644 --- a/src/Bundle/ChillMainBundle/Tests/Export/ExportManagerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Export/ExportManagerTest.php @@ -388,7 +388,7 @@ final class ExportManagerTest extends KernelTestCase public function testGetAggregatorNonExistant() { - $this->expectException(\RuntimeException::class); + $this->expectException(RuntimeException::class); $exportManager = $this->createExportManager(); @@ -446,7 +446,7 @@ final class ExportManagerTest extends KernelTestCase public function testGetExportNonExistant() { - $this->expectException(\RuntimeException::class); + $this->expectException(RuntimeException::class); $exportManager = $this->createExportManager(); @@ -485,7 +485,7 @@ final class ExportManagerTest extends KernelTestCase public function testGetFilterNonExistant() { - $this->expectException(\RuntimeException::class); + $this->expectException(RuntimeException::class); $exportManager = $this->createExportManager(); @@ -646,7 +646,7 @@ final class ExportManagerTest extends KernelTestCase public function testNonExistingFormatter() { - $this->expectException(\RuntimeException::class); + $this->expectException(RuntimeException::class); $exportManager = $this->createExportManager(); @@ -668,10 +668,10 @@ final class ExportManagerTest extends KernelTestCase ?UserInterface $user = null ): ExportManager { $localUser = $user ?? self::$container->get( - 'doctrine.orm.entity_manager' - ) - ->getRepository('ChillMainBundle:User') - ->findOneBy(['username' => 'center a_social']); + 'doctrine.orm.entity_manager' + ) + ->getRepository('ChillMainBundle:User') + ->findOneBy(['username' => 'center a_social']); $token = new UsernamePasswordToken($localUser, 'password', 'provider'); $tokenStorage = new TokenStorage(); $tokenStorage->setToken($token); diff --git a/src/Bundle/ChillMainBundle/Tests/Security/PasswordRecover/TokenManagerTest.php b/src/Bundle/ChillMainBundle/Tests/Security/PasswordRecover/TokenManagerTest.php index 294ddceb6..cc10e43cb 100644 --- a/src/Bundle/ChillMainBundle/Tests/Security/PasswordRecover/TokenManagerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Security/PasswordRecover/TokenManagerTest.php @@ -16,6 +16,7 @@ use Chill\MainBundle\Security\PasswordRecover\TokenManager; use DateInterval; use DateTimeImmutable; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; +use UnexpectedValueException; /** * @internal @@ -57,7 +58,7 @@ final class TokenManagerTest extends KernelTestCase public function testGenerateEmptyUsernameCanonical() { - $this->expectException(\UnexpectedValueException::class); + $this->expectException(UnexpectedValueException::class); $tokenManager = $this->tokenManager; // set a username, but not a username canonical diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php index f88a42e07..813ccee2a 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php @@ -28,17 +28,39 @@ use function array_values; class PersonApiController extends ApiController { private AuthorizationHelper $authorizationHelper; + private ConfigPersonAltNamesHelper $configPersonAltNameHelper; public function __construct( AuthorizationHelper $authorizationHelper, ConfigPersonAltNamesHelper $configPersonAltNameHelper - ) - { + ) { $this->authorizationHelper = $authorizationHelper; $this->configPersonAltNameHelper = $configPersonAltNameHelper; } + /** + * @Route("/api/1.0/person/config/alt_names.{_format}", + * name="chill_person_config_alt_names", + * requirements={ + * "_format": "json" + * } + * ) + */ + public function configAltNames(Request $request, string $_format): Response + { + $configAltNamesChoices = $this->configPersonAltNameHelper->getChoices(); + + return $this->json( + array_map( + static fn (array $data, string $key): array => ['key' => $key, 'labels' => $data], + $configAltNamesChoices, + array_keys($configAltNamesChoices) + ), + Response::HTTP_OK, [], ['groups' => ['read']] + ); + } + public function personAddressApi($id, Request $request, string $_format): Response { return $this->addRemoveSomething('address', $id, $request, $_format, 'address', Address::class, ['groups' => ['read']]); @@ -76,27 +98,4 @@ class PersonApiController extends ApiController return $this->json(array_values($addresses), Response::HTTP_OK, [], ['groups' => ['read']]); } - - /** - * @Route("/api/1.0/person/config/alt_names.{_format}", - * name="chill_person_config_alt_names", - * requirements={ - * "_format": "json" - * } - * ) - */ - public function configAltNames(Request $request, string $_format): Response - { - $configAltNamesChoices = $this->configPersonAltNameHelper->getChoices(); - - return $this->json( - array_map( - static fn (array $data, string $key): array => ['key' => $key, 'labels' => $data], - $configAltNamesChoices, - array_keys($configAltNamesChoices) - ), - Response::HTTP_OK, [], ['groups' => ['read']] - ); - } - } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php index 74955a382..66d41b3f2 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php @@ -80,7 +80,7 @@ class PersonJsonNormalizer implements } foreach (['firstName', 'lastName', 'phonenumber', 'mobilenumber', 'gender', - 'birthdate', 'deathdate', 'center', 'altNames'] + 'birthdate', 'deathdate', 'center', 'altNames', ] as $item) { if (!array_key_exists($item, $data)) { continue; @@ -133,8 +133,11 @@ class PersonJsonNormalizer implements break; case 'altNames': - foreach($data[$item] as $altName){ - $oldAltName = $person->getAltNames()->filter(function (PersonAltName $n) use ($altName) { return $n->getKey() === $altName['key']; })->first(); + foreach ($data[$item] as $altName) { + $oldAltName = $person + ->getAltNames() + ->filter(static fn (PersonAltName $n): bool => $n->getKey() === $altName['key'])->first(); + if (false === $oldAltName) { $newAltName = new PersonAltName(); $newAltName->setKey($altName['key']); @@ -144,6 +147,7 @@ class PersonJsonNormalizer implements $oldAltName->setLabel($altName['label']); } } + break; default: diff --git a/src/Bundle/ChillPersonBundle/Tests/Form/Type/PickPersonTypeTest.php b/src/Bundle/ChillPersonBundle/Tests/Form/Type/PickPersonTypeTest.php index 5c7942de3..6a9e37531 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Form/Type/PickPersonTypeTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Form/Type/PickPersonTypeTest.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Form\Type; use Chill\PersonBundle\Form\Type\PickPersonType; +use RuntimeException; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; use function count; @@ -52,7 +53,7 @@ final class PickPersonTypeTest extends KernelTestCase */ public function testWithInvalidOptionCenters() { - $this->expectException(\RuntimeException::class); + $this->expectException(RuntimeException::class); $this->markTestSkipped('need to inject locale into url generator without request'); $this->formFactory