Code should not be duplicated

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

  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 19 lines appear both in src/Swagger/Serializer/DocumentationNormalizer.php:526 and src/Swagger/Serializer/DocumentationNormalizer.php:615.

    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);

User specific files should not appear in .gitignore

More information: https://insight.symfony.com/what-we-analyse/git.user_specific_ignored_file

in .gitignore, line 12
  1. /tests/Fixtures/app/var/*
  2. /tests/Fixtures/app/cache/*
  3. /tests/Fixtures/app/logs/*
  4. /swagger.json
  5. /swagger.yaml
  6. /.idea

    /.idea is user-specific and should not appear in a project .gitignore. Consider adding it to the user global .gitignore instead.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Peter Smeets

Unused method, property, variable or parameter 6

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

  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. $queryFields += $this->getQueryFields($resourceClass, $resourceMetadata, $operationName, [], []);
  2. continue;
  3. }
  4. if ($itemQuery = $resourceMetadata->getGraphqlAttribute($operationName, 'item_query')) {

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

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Lukas Lücke
  5. $queryFields += $this->getQueryFields($resourceClass, $resourceMetadata, $operationName, $value, false);
  6. continue;
  7. }
  1. $queryFields += $this->getQueryFields($resourceClass, $resourceMetadata, $operationName, $value, false);
  2. continue;
  3. }
  4. if ($collectionQuery = $resourceMetadata->getGraphqlAttribute($operationName, 'collection_query')) {

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

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Lukas Lücke
  5. $queryFields += $this->getQueryFields($resourceClass, $resourceMetadata, $operationName, false, $value);
  6. continue;
  7. }
  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);

Text files should end with a valid new line character.

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

in .gitignore, line 12
  1. /tests/Fixtures/app/var/*
  2. /tests/Fixtures/app/cache/*
  3. /tests/Fixtures/app/logs/*
  4. /swagger.json
  5. /swagger.yaml
  6. /.idea

    This file ends with no newline character, or with a different newline character than other files in your project. It won't render properly on a terminal, and it's considered a bad practice.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Peter Smeets