Skip to content

Commit 5170b36

Browse files
authored
Merge pull request #2516 from dunglas/insight
Fix Insight violations
2 parents 209d9b1 + 919a705 commit 5170b36

File tree

6 files changed

+14
-42
lines changed

6 files changed

+14
-42
lines changed

src/Api/IdentifiersExtractor.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use ApiPlatform\Core\Exception\RuntimeException;
1717
use ApiPlatform\Core\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
1818
use ApiPlatform\Core\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
19-
use ApiPlatform\Core\Metadata\Resource\Factory\ResourceMetadataFactoryInterface;
2019
use ApiPlatform\Core\Util\ClassInfoTrait;
2120
use Symfony\Component\PropertyAccess\PropertyAccess;
2221
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
@@ -34,15 +33,13 @@ final class IdentifiersExtractor implements IdentifiersExtractorInterface
3433
private $propertyMetadataFactory;
3534
private $propertyAccessor;
3635
private $resourceClassResolver;
37-
private $resourceMetadataFactory;
3836

39-
public function __construct(PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, PropertyMetadataFactoryInterface $propertyMetadataFactory, PropertyAccessorInterface $propertyAccessor = null, ResourceClassResolverInterface $resourceClassResolver = null, ResourceMetadataFactoryInterface $resourceMetadataFactory = null)
37+
public function __construct(PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, PropertyMetadataFactoryInterface $propertyMetadataFactory, PropertyAccessorInterface $propertyAccessor = null, ResourceClassResolverInterface $resourceClassResolver = null)
4038
{
4139
$this->propertyNameCollectionFactory = $propertyNameCollectionFactory;
4240
$this->propertyMetadataFactory = $propertyMetadataFactory;
4341
$this->propertyAccessor = $propertyAccessor ?? PropertyAccess::createPropertyAccessor();
4442
$this->resourceClassResolver = $resourceClassResolver;
45-
$this->resourceMetadataFactory = $resourceMetadataFactory;
4643

4744
if (null === $this->resourceClassResolver) {
4845
@trigger_error(sprintf('Not injecting %s in the CachedIdentifiersExtractor might introduce cache issues with object identifiers.', ResourceClassResolverInterface::class), E_USER_DEPRECATED);

src/Bridge/Doctrine/Common/Filter/RangeFilterTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ private function normalizeValues(array $values, string $property): ?array
9696
/**
9797
* Normalize the values array for between operator.
9898
*/
99-
private function normalizeBetweenValues(array $values, string $property): ?array
99+
private function normalizeBetweenValues(array $values): ?array
100100
{
101101
if (2 !== \count($values)) {
102102
$this->getLogger()->notice('Invalid filter ignored', [
@@ -120,7 +120,7 @@ private function normalizeBetweenValues(array $values, string $property): ?array
120120
/**
121121
* Normalize the value.
122122
*/
123-
private function normalizeValue(string $value, string $property, string $operator): ?string
123+
private function normalizeValue(string $value, string $operator): ?string
124124
{
125125
if (!is_numeric($value)) {
126126
$this->getLogger()->notice('Invalid filter ignored', [

src/Bridge/Doctrine/MongoDbOdm/Filter/RangeFilter.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ protected function addMatch(Builder $aggregationBuilder, string $field, string $
7373
case self::PARAMETER_BETWEEN:
7474
$rangeValue = explode('..', $value);
7575

76-
$rangeValue = $this->normalizeBetweenValues($rangeValue, $field);
76+
$rangeValue = $this->normalizeBetweenValues($rangeValue);
7777
if (null === $rangeValue) {
7878
return;
7979
}
@@ -82,7 +82,7 @@ protected function addMatch(Builder $aggregationBuilder, string $field, string $
8282

8383
break;
8484
case self::PARAMETER_GREATER_THAN:
85-
$value = $this->normalizeValue($value, $field, $operator);
85+
$value = $this->normalizeValue($value, $operator);
8686
if (null === $value) {
8787
return;
8888
}
@@ -91,7 +91,7 @@ protected function addMatch(Builder $aggregationBuilder, string $field, string $
9191

9292
break;
9393
case self::PARAMETER_GREATER_THAN_OR_EQUAL:
94-
$value = $this->normalizeValue($value, $field, $operator);
94+
$value = $this->normalizeValue($value, $operator);
9595
if (null === $value) {
9696
return;
9797
}
@@ -100,7 +100,7 @@ protected function addMatch(Builder $aggregationBuilder, string $field, string $
100100

101101
break;
102102
case self::PARAMETER_LESS_THAN:
103-
$value = $this->normalizeValue($value, $field, $operator);
103+
$value = $this->normalizeValue($value, $operator);
104104
if (null === $value) {
105105
return;
106106
}
@@ -109,7 +109,7 @@ protected function addMatch(Builder $aggregationBuilder, string $field, string $
109109

110110
break;
111111
case self::PARAMETER_LESS_THAN_OR_EQUAL:
112-
$value = $this->normalizeValue($value, $field, $operator);
112+
$value = $this->normalizeValue($value, $operator);
113113
if (null === $value) {
114114
return;
115115
}

src/Bridge/Doctrine/MongoDbOdm/ItemDataProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function getItem(string $resourceClass, $id, string $operationName = null
7272

7373
$id = (array) $id;
7474

75-
if (!$fetchData = $context['fetch_data'] ?? true) {
75+
if (!($context['fetch_data'] ?? true)) {
7676
return $manager->getReference($resourceClass, reset($id));
7777
}
7878

src/Bridge/Doctrine/MongoDbOdm/PropertyInfo/DoctrineExtractor.php

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -111,31 +111,6 @@ public function getTypes($class, $property, array $context = [])
111111
}
112112
}
113113

114-
/**
115-
* Determines whether an association is nullable.
116-
*
117-
* @see https://github.com/doctrine/doctrine2/blob/v2.5.4/lib/Doctrine/ORM/Tools/EntityGenerator.php#L1221-L1246
118-
*/
119-
private function isAssociationNullable(array $associationMapping): bool
120-
{
121-
if (isset($associationMapping['id']) && $associationMapping['id']) {
122-
return false;
123-
}
124-
125-
if (!isset($associationMapping['joinColumns'])) {
126-
return true;
127-
}
128-
129-
$joinColumns = $associationMapping['joinColumns'];
130-
foreach ($joinColumns as $joinColumn) {
131-
if (isset($joinColumn['nullable']) && !$joinColumn['nullable']) {
132-
return false;
133-
}
134-
}
135-
136-
return true;
137-
}
138-
139114
/**
140115
* Gets the corresponding built-in PHP type.
141116
*/

src/Bridge/Doctrine/Orm/Filter/RangeFilter.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ protected function addWhere(QueryBuilder $queryBuilder, QueryNameGeneratorInterf
8080
case self::PARAMETER_BETWEEN:
8181
$rangeValue = explode('..', $value);
8282

83-
$rangeValue = $this->normalizeBetweenValues($rangeValue, $field);
83+
$rangeValue = $this->normalizeBetweenValues($rangeValue);
8484
if (null === $rangeValue) {
8585
return;
8686
}
@@ -92,7 +92,7 @@ protected function addWhere(QueryBuilder $queryBuilder, QueryNameGeneratorInterf
9292

9393
break;
9494
case self::PARAMETER_GREATER_THAN:
95-
$value = $this->normalizeValue($value, $field, $operator);
95+
$value = $this->normalizeValue($value, $operator);
9696
if (null === $value) {
9797
return;
9898
}
@@ -103,7 +103,7 @@ protected function addWhere(QueryBuilder $queryBuilder, QueryNameGeneratorInterf
103103

104104
break;
105105
case self::PARAMETER_GREATER_THAN_OR_EQUAL:
106-
$value = $this->normalizeValue($value, $field, $operator);
106+
$value = $this->normalizeValue($value, $operator);
107107
if (null === $value) {
108108
return;
109109
}
@@ -114,7 +114,7 @@ protected function addWhere(QueryBuilder $queryBuilder, QueryNameGeneratorInterf
114114

115115
break;
116116
case self::PARAMETER_LESS_THAN:
117-
$value = $this->normalizeValue($value, $field, $operator);
117+
$value = $this->normalizeValue($value, $operator);
118118
if (null === $value) {
119119
return;
120120
}
@@ -125,7 +125,7 @@ protected function addWhere(QueryBuilder $queryBuilder, QueryNameGeneratorInterf
125125

126126
break;
127127
case self::PARAMETER_LESS_THAN_OR_EQUAL:
128-
$value = $this->normalizeValue($value, $field, $operator);
128+
$value = $this->normalizeValue($value, $operator);
129129
if (null === $value) {
130130
return;
131131
}

0 commit comments

Comments
 (0)