mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-28 01:25:00 +00:00
Rector changes and immplementations of required methods
This commit is contained in:
@@ -17,7 +17,7 @@ use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
class ChillDocGeneratorBundle extends Bundle
|
||||
{
|
||||
public function build(ContainerBuilder $container)
|
||||
public function build(ContainerBuilder $container): void
|
||||
{
|
||||
parent::build($container);
|
||||
|
||||
|
@@ -24,7 +24,7 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
*/
|
||||
class ChillDocGeneratorExtension extends Extension implements PrependExtensionInterface
|
||||
{
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
public function load(array $configs, ContainerBuilder $container): void
|
||||
{
|
||||
$configuration = new Configuration();
|
||||
$config = $this->processConfiguration($configuration, $configs);
|
||||
@@ -36,7 +36,7 @@ class ChillDocGeneratorExtension extends Extension implements PrependExtensionIn
|
||||
$loader->load('services/form.yaml');
|
||||
}
|
||||
|
||||
public function prepend(ContainerBuilder $container)
|
||||
public function prepend(ContainerBuilder $container): void
|
||||
{
|
||||
$this->preprendRoutes($container);
|
||||
$this->prependCruds($container);
|
||||
@@ -83,7 +83,7 @@ class ChillDocGeneratorExtension extends Extension implements PrependExtensionIn
|
||||
]);
|
||||
}
|
||||
|
||||
private function prependClientConfig(ContainerBuilder $container)
|
||||
private function prependClientConfig(ContainerBuilder $container): void
|
||||
{
|
||||
$configs = $container->getExtensionConfig($this->getAlias());
|
||||
$resolvingBag = $container->getParameterBag();
|
||||
|
@@ -26,7 +26,7 @@ class DocGeneratorTemplateType extends AbstractType
|
||||
{
|
||||
public function __construct(private readonly ContextManager $contextManager) {}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
/** @var DocGeneratorTemplate $template */
|
||||
$template = $options['data'];
|
||||
@@ -64,7 +64,7 @@ class DocGeneratorTemplateType extends AbstractType
|
||||
}
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver
|
||||
->setDefault('class', DocGeneratorTemplate::class);
|
||||
|
@@ -20,7 +20,7 @@ class AdminMenuBuilder implements LocalMenuBuilderInterface
|
||||
{
|
||||
public function __construct(private readonly TranslatorInterface $translator, private readonly Security $security) {}
|
||||
|
||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||
public function buildMenu($menuId, MenuItem $menu, array $parameters): void
|
||||
{
|
||||
if ($this->security->isGranted('ROLE_ADMIN')) {
|
||||
$menu->addChild($this->translator->trans('docgen.Document generation'), [
|
||||
|
@@ -16,7 +16,7 @@ use Symfony\Component\Serializer\Exception\UnexpectedValueException;
|
||||
|
||||
class DocGenEncoder implements EncoderInterface
|
||||
{
|
||||
public function encode($data, $format, array $context = [])
|
||||
public function encode($data, $format, array $context = []): string
|
||||
{
|
||||
if (!$this->isAssociative($data)) {
|
||||
throw new UnexpectedValueException('Only associative arrays are allowed; lists are not allowed');
|
||||
@@ -28,7 +28,7 @@ class DocGenEncoder implements EncoderInterface
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function supportsEncoding($format)
|
||||
public function supportsEncoding($format): bool
|
||||
{
|
||||
return 'docgen' === $format;
|
||||
}
|
||||
@@ -45,7 +45,7 @@ class DocGenEncoder implements EncoderInterface
|
||||
return \array_keys($keys) !== $keys;
|
||||
}
|
||||
|
||||
private function recusiveEncoding(array $data, array &$result, $path)
|
||||
private function recusiveEncoding(array $data, array &$result, $path): void
|
||||
{
|
||||
if ($this->isAssociative($data)) {
|
||||
foreach ($data as $key => $value) {
|
||||
|
@@ -20,7 +20,7 @@ use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
||||
/**
|
||||
* Normalize a collection for docgen format.
|
||||
*/
|
||||
class CollectionDocGenNormalizer implements ContextAwareNormalizerInterface, NormalizerAwareInterface
|
||||
class CollectionDocGenNormalizer implements \Symfony\Component\Serializer\Normalizer\NormalizerInterface, NormalizerAwareInterface
|
||||
{
|
||||
use NormalizerAwareTrait;
|
||||
|
||||
@@ -30,7 +30,7 @@ class CollectionDocGenNormalizer implements ContextAwareNormalizerInterface, Nor
|
||||
*
|
||||
* @return array|\ArrayObject|bool|float|int|string|void|null
|
||||
*/
|
||||
public function normalize($object, $format = null, array $context = [])
|
||||
public function normalize($object, $format = null, array $context = []): string|int|float|bool|\ArrayObject|array|null
|
||||
{
|
||||
$data = [];
|
||||
|
||||
@@ -45,7 +45,7 @@ class CollectionDocGenNormalizer implements ContextAwareNormalizerInterface, Nor
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function supportsNormalization($data, $format = null, array $context = [])
|
||||
public function supportsNormalization($data, $format = null, array $context = []): bool
|
||||
{
|
||||
if ('docgen' !== $format) {
|
||||
return false;
|
||||
@@ -56,4 +56,15 @@ class CollectionDocGenNormalizer implements ContextAwareNormalizerInterface, Nor
|
||||
|| (null === $data && ReadableCollection::class === ($context['docgen:expects'] ?? null))
|
||||
;
|
||||
}
|
||||
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
if ('docgen' !== $format) {
|
||||
return [];
|
||||
}
|
||||
return [
|
||||
ReadableCollection::class => true,
|
||||
Collection::class => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
|
||||
$this->propertyAccess = PropertyAccess::createPropertyAccessor();
|
||||
}
|
||||
|
||||
public function normalize($object, $format = null, array $context = [])
|
||||
public function normalize($object, $format = null, array $context = []): string|int|float|bool|\ArrayObject|array|null
|
||||
{
|
||||
$classMetadataKey = $object ?? $context['docgen:expects'] ?? null;
|
||||
|
||||
@@ -79,7 +79,7 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
|
||||
return $this->normalizeObject($object, $format, $context, $expectedGroups, $metadata, $attributes);
|
||||
}
|
||||
|
||||
public function supportsNormalization($data, $format = null): bool
|
||||
public function supportsNormalization($data, $format = null, array $context = []): bool
|
||||
{
|
||||
return 'docgen' === $format && (\is_object($data) || null === $data);
|
||||
}
|
||||
@@ -281,4 +281,15 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
if ('docgen' !== $format) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
'object' => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ final readonly class OnAfterMessageHandledClearStoredObjectCache implements Even
|
||||
private LoggerInterface $logger,
|
||||
) {}
|
||||
|
||||
public static function getSubscribedEvents()
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return [
|
||||
WorkerMessageHandledEvent::class => [
|
||||
|
@@ -42,7 +42,7 @@ final readonly class OnGenerationFails implements EventSubscriberInterface
|
||||
private UserRepositoryInterface $userRepository,
|
||||
) {}
|
||||
|
||||
public static function getSubscribedEvents()
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return [
|
||||
WorkerMessageFailedEvent::class => 'onMessageFailed',
|
||||
|
@@ -48,7 +48,7 @@ class RequestGenerationHandler implements MessageHandlerInterface
|
||||
private readonly TranslatorInterface $translator,
|
||||
) {}
|
||||
|
||||
public function __invoke(RequestGenerationMessage $message)
|
||||
public function __invoke(RequestGenerationMessage $message): void
|
||||
{
|
||||
if (null === $template = $this->docGeneratorTemplateRepository->find($message->getTemplateId())) {
|
||||
throw new \RuntimeException('template not found: '.$message->getTemplateId());
|
||||
|
@@ -94,7 +94,7 @@ final class DocGenEncoderTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
public function testEmbeddedLoopsThrowsException()
|
||||
public function testEmbeddedLoopsThrowsException(): void
|
||||
{
|
||||
$this->expectException(UnexpectedValueException::class);
|
||||
|
||||
@@ -118,7 +118,7 @@ final class DocGenEncoderTest extends TestCase
|
||||
/**
|
||||
* @dataProvider generateEncodeData
|
||||
*/
|
||||
public function testEncode(mixed $expected, mixed $data, string $msg)
|
||||
public function testEncode(mixed $expected, mixed $data, string $msg): void
|
||||
{
|
||||
$generated = $this->encoder->encode($data, 'docgen');
|
||||
$this->assertEquals($expected, $generated, $msg);
|
||||
|
@@ -38,7 +38,7 @@ final class DocGenObjectNormalizerTest extends KernelTestCase
|
||||
$this->normalizer = self::getContainer()->get(NormalizerInterface::class);
|
||||
}
|
||||
|
||||
public function testChangeContextOnAttribute()
|
||||
public function testChangeContextOnAttribute(): void
|
||||
{
|
||||
$object = new TestableParentClass();
|
||||
$actual = $this->normalizer->normalize(
|
||||
@@ -81,7 +81,7 @@ final class DocGenObjectNormalizerTest extends KernelTestCase
|
||||
$this->assertArrayNotHasKey('baz', $actual['child']);
|
||||
}
|
||||
|
||||
public function testNormalizableBooleanPropertyOrMethodOnNull()
|
||||
public function testNormalizableBooleanPropertyOrMethodOnNull(): void
|
||||
{
|
||||
$actual = $this->normalizer->normalize(null, 'docgen', [AbstractNormalizer::GROUPS => ['docgen:read'], 'docgen:expects' => TestableClassWithBool::class]);
|
||||
|
||||
@@ -94,7 +94,7 @@ final class DocGenObjectNormalizerTest extends KernelTestCase
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
public function testNormalizationBasic()
|
||||
public function testNormalizationBasic(): void
|
||||
{
|
||||
$scope = new Scope();
|
||||
$scope->setName(['fr' => 'scope']);
|
||||
@@ -110,7 +110,7 @@ final class DocGenObjectNormalizerTest extends KernelTestCase
|
||||
$this->assertEquals($expected, $normalized, 'test normalization fo a scope');
|
||||
}
|
||||
|
||||
public function testNormalizeBooleanPropertyOrMethod()
|
||||
public function testNormalizeBooleanPropertyOrMethod(): void
|
||||
{
|
||||
$testable = new TestableClassWithBool();
|
||||
$testable->foo = false;
|
||||
@@ -126,7 +126,7 @@ final class DocGenObjectNormalizerTest extends KernelTestCase
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
public function testNormalizeNull()
|
||||
public function testNormalizeNull(): void
|
||||
{
|
||||
$actual = $this->normalizer->normalize(null, 'docgen', [AbstractNormalizer::GROUPS => ['docgen:read'], 'docgen:expects' => Scope::class]);
|
||||
$expected = [
|
||||
|
@@ -31,7 +31,7 @@ final class BaseContextDataTest extends KernelTestCase
|
||||
self::bootKernel();
|
||||
}
|
||||
|
||||
public function testGenerateNoContext()
|
||||
public function testGenerateNoContext(): void
|
||||
{
|
||||
$context = $this->buildBaseContext();
|
||||
|
||||
@@ -43,7 +43,7 @@ final class BaseContextDataTest extends KernelTestCase
|
||||
$this->assertArrayHasKey('location', $actual);
|
||||
}
|
||||
|
||||
public function testGenerateWithUser()
|
||||
public function testGenerateWithUser(): void
|
||||
{
|
||||
$context = $this->buildBaseContext();
|
||||
|
||||
|
Reference in New Issue
Block a user