Code should not be duplicated 2

  • Minor
  • Architecture

More information: https://insight.symfony.com/what-we-analyse/php.duplicated_code

  1. final class ObjectNormalizer implements NormalizerInterface, CacheableSupportsMethodInterface
  2. {
  3. public const FORMAT = 'graphql';
  4. public const ITEM_KEY = '#item';
  5. private $decorated;

    The next 37 lines appear both in src/GraphQl/Serializer/ObjectNormalizer.php:30 and src/Hal/Serializer/ObjectNormalizer.php:30.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Teoh Han Hui
  6. private $iriConverter;
  7. public function __construct(NormalizerInterface $decorated, IriConverterInterface $iriConverter)
  8. {
  9. $this->decorated = $decorated;
  1. $successResponse['schema'] = ['$ref' => sprintf('#/definitions/%s', $responseDefinitionKey)];
  2. }
  3. }
  4. $pathOperation['responses'] ?? $pathOperation['responses'] = [
  5. (string) $resourceMetadata->getTypedOperationAttribute($operationType, $operationName, 'status', '201') => $successResponse,

    The next 15 lines appear both in src/Swagger/Serializer/DocumentationNormalizer.php:446 and src/Swagger/Serializer/DocumentationNormalizer.php:507.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Kévin Dunglas
  6. '400' => ['description' => 'Invalid input'],
  7. '404' => ['description' => 'Resource not found'],
  8. ];
  9. $inputMetadata = $resourceMetadata->getTypedOperationAttribute($operationType, $operationName, 'input', ['class' => $resourceClass], true);

Unused method, property, variable or parameter 5

  • Minor
  • Deadcode

More information: https://insight.symfony.com/what-we-analyse/php.unused_local_variable_or_private_member

  1. /**
  2. * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
  3. *
  4. * @var bool
  5. */
  6. private $elasticsearch;

    This elasticsearch attribute is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by soyuka
  7. /**
  8. * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
  9. *
  10. * @var bool
  1. *
  2. * @throws UnexpectedValueException
  3. */
  4. public function normalize($object, $format = null, array $context = [])
  5. {
  6. if (null !== $outputClass = $this->getOutputClass($this->getObjectClass($object), $context)) {

    This outputClass local variable is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Teoh Han Hui
  7. return parent::normalize($object, $format, $context);
  8. }
  9. $data = parent::normalize($object, $format, $context);
  10. if (!\is_array($data)) {
  1. /**
  2. * {@inheritdoc}
  3. */
  4. public function normalize($object, $format = null, array $context = [])
  5. {
  6. if (null !== $outputClass = $this->getOutputClass($this->getObjectClass($object), $context)) {

    This outputClass local variable is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Teoh Han Hui
  7. return parent::normalize($object, $format, $context);
  8. }
  9. if (!isset($context['cache_key'])) {
  10. $context['cache_key'] = $this->getHalCacheKey($format, $context);
  1. /**
  2. * {@inheritdoc}
  3. */
  4. public function normalize($object, $format = null, array $context = [])
  5. {
  6. if (null !== $outputClass = $this->getOutputClass($this->getObjectClass($object), $context)) {

    This outputClass local variable is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Teoh Han Hui
  7. return parent::normalize($object, $format, $context);
  8. }
  9. if (!isset($context['cache_key'])) {
  10. $context['cache_key'] = $this->getJsonApiCacheKey($format, $context);
  1. *
  2. * @throws LogicException
  3. */
  4. public function normalize($object, $format = null, array $context = [])
  5. {
  6. if (null !== $outputClass = $this->getOutputClass($this->getObjectClass($object), $context)) {

    This outputClass local variable is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Teoh Han Hui
  7. return parent::normalize($object, $format, $context);
  8. }
  9. // Use resolved resource class instead of given resource class to support multiple inheritance child types
  10. $resourceClass = $this->resourceClassResolver->getResourceClass($object, $context['resource_class'] ?? null, true);