Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"symfony/form": "^3.4 || ^4.4 || ^5.1",
"symfony/framework-bundle": "^4.4 || ^5.1",
"symfony/http-client": "^4.4 || ^5.1",
"symfony/intl": "^3.4 || ^4.4 || ^5.1",
"symfony/mercure-bundle": "*",
"symfony/messenger": "^4.4 || ^5.1",
"symfony/phpunit-bridge": "^5.1.7",
Expand Down
7 changes: 6 additions & 1 deletion src/Bridge/RamseyUuid/Serializer/UuidDenormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@

final class UuidDenormalizer implements DenormalizerInterface
{
/**
* @param mixed|null $format
*
* @return UuidInterface
*/
public function denormalize($data, $type, $format = null, array $context = [])
{
try {
Expand All @@ -30,7 +35,7 @@ public function denormalize($data, $type, $format = null, array $context = [])
}
}

public function supportsDenormalization($data, $type, $format = null)
public function supportsDenormalization($data, $type, $format = null): bool
{
return \is_string($data) && is_a($type, UuidInterface::class, true);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Bridge/Symfony/Bundle/Command/GraphQlExportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected function configure(): void
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);

Expand Down
4 changes: 2 additions & 2 deletions src/Bridge/Symfony/Bundle/Command/OpenApiCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct(OpenApiFactoryInterface $openApiFactory, NormalizerI
/**
* {@inheritdoc}
*/
protected function configure()
protected function configure(): void
{
$this
->setDescription('Dump the Open API documentation')
Expand All @@ -57,7 +57,7 @@ protected function configure()
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
// Backwards compatibility
if (2 === $specVersion = (int) $input->getOption('spec-version')) {
Expand Down
4 changes: 2 additions & 2 deletions src/Bridge/Symfony/Bundle/Command/SwaggerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function __construct(NormalizerInterface $normalizer, ResourceNameCollect
/**
* {@inheritdoc}
*/
protected function configure()
protected function configure(): void
{
$this
->setDescription('Dump the Swagger v2 documentation')
Expand All @@ -79,7 +79,7 @@ protected function configure()
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ final class Configuration implements ConfigurationInterface
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
if (method_exists(TreeBuilder::class, 'getRootNode')) {
$treeBuilder = new TreeBuilder('api_platform');
Expand Down
12 changes: 6 additions & 6 deletions src/Bridge/Symfony/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,35 +46,35 @@ public function __construct(RouterInterface $router, int $urlGenerationStrategy
/**
* {@inheritdoc}
*/
public function setContext(RequestContext $context)
public function setContext(RequestContext $context): void
{
$this->router->setContext($context);
}

/**
* {@inheritdoc}
*/
public function getContext()
public function getContext(): RequestContext
{
return $this->router->getContext();
}

/**
* {@inheritdoc}
*/
public function getRouteCollection()
public function getRouteCollection(): \Symfony\Component\Routing\RouteCollection
{
return $this->router->getRouteCollection();
}

/**
* {@inheritdoc}
*/
public function match($pathInfo)
public function match($pathInfo): array
{
$baseContext = $this->router->getContext();
$baseUrl = $baseContext->getBaseUrl();
if ($baseUrl === substr($pathInfo, 0, \strlen($baseUrl))) {
if (0 === strpos($pathInfo, $baseUrl)) {
$pathInfo = substr($pathInfo, \strlen($baseUrl));
}

Expand All @@ -101,7 +101,7 @@ public function match($pathInfo)
/**
* {@inheritdoc}
*/
public function generate($name, $parameters = [], $referenceType = null)
public function generate($name, $parameters = [], $referenceType = null): string
{
return $this->router->generate($name, $parameters, self::CONST_MAP[$referenceType ?? $this->urlGenerationStrategy]);
}
Expand Down
4 changes: 4 additions & 0 deletions src/GraphQl/Serializer/ItemNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public function supportsNormalization($data, $format = null): bool
* {@inheritdoc}
*
* @throws UnexpectedValueException
*
* @return array|string|int|float|bool|\ArrayObject|null
*/
public function normalize($object, $format = null, array $context = [])
{
Expand Down Expand Up @@ -103,6 +105,8 @@ public function supportsDenormalization($data, $type, $format = null): bool

/**
* {@inheritdoc}
*
* @return array|bool
*/
protected function getAllowedAttributes($classOrObject, array $context, $attributesAsString = false)
{
Expand Down
4 changes: 2 additions & 2 deletions src/JsonSchema/Command/JsonSchemaGenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __construct(SchemaFactoryInterface $schemaFactory, array $format
/**
* {@inheritdoc}
*/
protected function configure()
protected function configure(): void
{
$this
->setDescription('Generates the JSON Schema for a resource operation.')
Expand All @@ -61,7 +61,7 @@ protected function configure()
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);

Expand Down
4 changes: 2 additions & 2 deletions src/Metadata/Property/PropertyNameCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ public function __construct(array $properties = [])
/**
* {@inheritdoc}
*/
public function getIterator()
public function getIterator(): \Traversable
{
return new \ArrayIterator($this->properties);
}

/**
* {@inheritdoc}
*/
public function count()
public function count(): int
{
return \count($this->properties);
}
Expand Down
14 changes: 13 additions & 1 deletion src/Serializer/AbstractItemNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ public function __construct(PropertyNameCollectionFactoryInterface $propertyName

/**
* {@inheritdoc}
*
* @return bool
*/
public function supportsNormalization($data, $format = null)
{
Expand All @@ -118,6 +120,8 @@ public function hasCacheableSupportsMethod(): bool
* {@inheritdoc}
*
* @throws LogicException
*
* @return array|string|int|float|bool|\ArrayObject|null
*/
public function normalize($object, $format = null, array $context = [])
{
Expand Down Expand Up @@ -173,6 +177,8 @@ public function normalize($object, $format = null, array $context = [])

/**
* {@inheritdoc}
*
* @return bool
*/
public function supportsDenormalization($data, $type, $format = null)
{
Expand Down Expand Up @@ -260,7 +266,7 @@ public function denormalize($data, $class, $format = null, array $context = [])
*
* @internal
*/
protected function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes, string $format = null)
protected function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes, string $format = null): object
{
if (null !== $object = $this->extractObjectToPopulate($class, $context, static::OBJECT_TO_POPULATE)) {
unset($context[static::OBJECT_TO_POPULATE]);
Expand Down Expand Up @@ -344,6 +350,8 @@ protected function createConstructorArgument($parameterData, string $key, \Refle
* {@inheritdoc}
*
* Unused in this context.
*
* @return array
*/
protected function extractAttributes($object, $format = null, array $context = [])
{
Expand All @@ -352,6 +360,8 @@ protected function extractAttributes($object, $format = null, array $context = [

/**
* {@inheritdoc}
*
* @return array|bool
*/
protected function getAllowedAttributes($classOrObject, array $context, $attributesAsString = false)
{
Expand All @@ -378,6 +388,8 @@ protected function getAllowedAttributes($classOrObject, array $context, $attribu

/**
* {@inheritdoc}
*
* @return bool
*/
protected function isAllowedAttribute($classOrObject, $attribute, $format = null, array $context = [])
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/TestBundle/Document/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function getPassword(): ?string
return null;
}

public function getSalt()
public function getSalt(): ?string
{
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/TestBundle/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public function getPassword(): ?string
return null;
}

public function getSalt()
public function getSalt(): ?string
{
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function denormalize($data, $class, $format = null, array $context = [])
/**
* {@inheritdoc}
*/
public function supportsDenormalization($data, $type, $format = null)
public function supportsDenormalization($data, $type, $format = null): bool
{
return 'json' === $format && SerializableResource::class === $type && \is_array($data);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
*/
class CustomConverter extends CamelCaseToSnakeCaseNameConverter
{
public function normalize($propertyName)
public function normalize($propertyName): string
{
return 'nameConverted' === $propertyName ? parent::normalize($propertyName) : $propertyName;
}

public function denormalize($propertyName)
public function denormalize($propertyName): string
{
return 'name_converted' === $propertyName ? parent::denormalize($propertyName) : $propertyName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ public function __construct(NormalizerInterface $documentationNormalizer)
$this->documentationNormalizer = $documentationNormalizer;
}

/**
* @param mixed|null $format
*
* @return array|string|int|float|bool|\ArrayObject|null
*/
public function normalize($object, $format = null, array $context = [])
{
$data = $this->documentationNormalizer->normalize($object, $format, $context);
Expand All @@ -44,7 +49,7 @@ public function normalize($object, $format = null, array $context = [])
return $data;
}

public function supportsNormalization($data, $format = null)
public function supportsNormalization($data, $format = null): bool
{
return $this->documentationNormalizer->supportsNormalization($data, $format);
}
Expand Down