Skip to content

Commit 48f0034

Browse files
committed
Validator, cs-fixer, WIP phpstan
1 parent bfc31ce commit 48f0034

File tree

246 files changed

+3853
-10358
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

246 files changed

+3853
-10358
lines changed

src/Action/ExceptionAction.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,7 @@ public function __invoke($exception, Request $request): Response
7272
$exceptionClass = $exception->getClass();
7373
$statusCode = $exception->getStatusCode();
7474

75-
$exceptionToStatus = array_merge(
76-
$this->exceptionToStatus,
77-
$operation ? $operation->getExceptionToStatus() ?? [] : $this->getOperationExceptionToStatus($request)
78-
);
75+
$exceptionToStatus = array_merge($this->exceptionToStatus, $operation ? $operation->getExceptionToStatus() ?? [] : $this->getOperationExceptionToStatus($request));
7976

8077
foreach ($exceptionToStatus as $class => $status) {
8178
if (is_a($exceptionClass, $class, true)) {
@@ -110,9 +107,6 @@ private function getOperationExceptionToStatus(Request $request): array
110107
throw new \LogicException('"exception_to_status" attribute should be an array.');
111108
}
112109

113-
return array_merge(
114-
$resourceExceptionToStatus,
115-
$operationExceptionToStatus
116-
);
110+
return array_merge($resourceExceptionToStatus, $operationExceptionToStatus);
117111
}
118112
}

src/Core/Bridge/Doctrine/Common/Filter/DateFilterInterface.php renamed to src/Bridge/Doctrine/Common/Filter/DateFilterInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
declare(strict_types=1);
1313

14-
namespace ApiPlatform\Core\Bridge\Doctrine\Common\Filter;
14+
namespace ApiPlatform\Bridge\Doctrine\Common\Filter;
1515

1616
/**
1717
* Interface for filtering the collection by date intervals.

src/Core/Bridge/Doctrine/Common/Filter/ExistsFilterInterface.php renamed to src/Bridge/Doctrine/Common/Filter/ExistsFilterInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
declare(strict_types=1);
1313

14-
namespace ApiPlatform\Core\Bridge\Doctrine\Common\Filter;
14+
namespace ApiPlatform\Bridge\Doctrine\Common\Filter;
1515

1616
/**
1717
* Interface for filtering the collection by whether a property value exists or not.

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,7 @@ abstract protected function normalizePropertyName($property);
7373
private function normalizeValue($value, string $property): ?bool
7474
{
7575
if (\is_array($value) && isset($value[self::QUERY_PARAMETER_KEY])) {
76-
@trigger_error(
77-
sprintf('The ExistsFilter syntax "%s[exists]=true/false" is deprecated since 2.5. Use the syntax "%s[%s]=true/false" instead.', $property, $this->existsParameterName, $property),
78-
\E_USER_DEPRECATED
79-
);
76+
@trigger_error(sprintf('The ExistsFilter syntax "%s[exists]=true/false" is deprecated since 2.5. Use the syntax "%s[%s]=true/false" instead.', $property, $this->existsParameterName, $property), \E_USER_DEPRECATED);
8077
$value = $value[self::QUERY_PARAMETER_KEY];
8178
}
8279

src/Core/Bridge/Doctrine/Common/Filter/OrderFilterInterface.php renamed to src/Bridge/Doctrine/Common/Filter/OrderFilterInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
declare(strict_types=1);
1313

14-
namespace ApiPlatform\Core\Bridge\Doctrine\Common\Filter;
14+
namespace ApiPlatform\Bridge\Doctrine\Common\Filter;
1515

1616
/**
1717
* Interface for ordering the collection by given properties.

src/Core/Bridge/Doctrine/Common/Filter/RangeFilterInterface.php renamed to src/Bridge/Doctrine/Common/Filter/RangeFilterInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
declare(strict_types=1);
1313

14-
namespace ApiPlatform\Core\Bridge\Doctrine\Common\Filter;
14+
namespace ApiPlatform\Bridge\Doctrine\Common\Filter;
1515

1616
/**
1717
* Interface for filtering the collection by range.

src/Core/Bridge/Doctrine/Common/Filter/SearchFilterInterface.php renamed to src/Bridge/Doctrine/Common/Filter/SearchFilterInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
declare(strict_types=1);
1313

14-
namespace ApiPlatform\Core\Bridge\Doctrine\Common\Filter;
14+
namespace ApiPlatform\Bridge\Doctrine\Common\Filter;
1515

1616
/**
1717
* Interface for filtering the collection by given properties.

src/Bridge/Doctrine/Orm/State/UriVariablesHandlerTrait.php

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,35 +38,19 @@ private function handleUriVariables(QueryBuilder $queryBuilder, array $identifie
3838
$propertyIdentifier = $uriVariable->getIdentifiers()[0];
3939
$joinAlias = $queryNameGenerator->generateJoinAlias($inverseProperty);
4040

41-
$queryBuilder->join(
42-
$uriVariable->getTargetClass(),
43-
$joinAlias,
44-
'with',
45-
"$alias.$propertyIdentifier = $joinAlias.$inverseProperty"
46-
);
41+
$queryBuilder->join($uriVariable->getTargetClass(), $joinAlias, 'with', "$alias.$propertyIdentifier = $joinAlias.$inverseProperty");
4742

48-
$expression = $queryBuilder->expr()->eq(
49-
"{$joinAlias}.{$propertyIdentifier}",
50-
$placeholder
51-
);
43+
$expression = $queryBuilder->expr()->eq("{$joinAlias}.{$propertyIdentifier}", $placeholder);
5244
} elseif ($property = $uriVariable->getProperty()) {
5345
$propertyIdentifier = $uriVariable->getIdentifiers()[0];
5446
$joinAlias = $queryNameGenerator->generateJoinAlias($property);
5547

56-
$queryBuilder->join(
57-
"$alias.$property",
58-
$joinAlias,
59-
);
48+
$queryBuilder->join("$alias.$property", $joinAlias, );
6049

61-
$expression = $queryBuilder->expr()->eq(
62-
"{$joinAlias}.{$propertyIdentifier}",
63-
$placeholder
64-
);
50+
$expression = $queryBuilder->expr()->eq("{$joinAlias}.{$propertyIdentifier}", $placeholder);
6551
} else {
6652
$propertyIdentifier = $uriVariable->getIdentifiers()[0];
67-
$expression = $queryBuilder->expr()->eq(
68-
"{$alias}.{$propertyIdentifier}", $placeholder
69-
);
53+
$expression = $queryBuilder->expr()->eq("{$alias}.{$propertyIdentifier}", $placeholder);
7054
}
7155
$queryBuilder->andWhere($expression);
7256
$queryBuilder->setParameter($placeholder, $value, $doctrineClassMetadata->getTypeOfField($identifier));

src/Core/Annotation/ApiFilter.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,8 @@ final class ApiFilter
5757
* @param string $id
5858
* @param string $strategy
5959
*/
60-
public function __construct(
61-
$filterClass,
62-
?string $id = null,
63-
?string $strategy = null,
64-
array $properties = [],
65-
array $arguments = []
66-
) {
60+
public function __construct($filterClass, ?string $id = null, ?string $strategy = null, array $properties = [], array $arguments = [])
61+
{
6762
if (\is_array($filterClass)) { /** @phpstan-ignore-line Doctrine annotations */
6863
$options = $filterClass;
6964
$this->filterClass = $options['value'] ?? null;

src/Core/Annotation/ApiProperty.php

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -120,33 +120,9 @@ final class ApiProperty
120120
*
121121
* @throws InvalidArgumentException
122122
*/
123-
public function __construct(
124-
$description = null,
125-
?bool $readable = null,
126-
?bool $writable = null,
127-
?bool $readableLink = null,
128-
?bool $writableLink = null,
129-
?bool $required = null,
130-
?string $iri = null,
131-
?bool $identifier = null,
132-
$default = null,
133-
$example = null,
134-
135-
// attributes
136-
?array $attributes = null,
137-
?string $deprecationReason = null,
138-
?bool $fetchable = null,
139-
?bool $fetchEager = null,
140-
?array $jsonldContext = null,
141-
?array $openapiContext = null,
142-
?bool $push = null,
143-
?string $security = null,
144-
?array $swaggerContext = null,
145-
?string $securityPostDenormalize = null,
146-
147-
?array $types = [],
148-
?array $builtinTypes = []
149-
) {
123+
public function __construct($description = null, ?bool $readable = null, ?bool $writable = null, ?bool $readableLink = null, ?bool $writableLink = null, ?bool $required = null, ?string $iri = null, ?bool $identifier = null, $default = null, $example = null, // attributes
124+
?array $attributes = null, ?string $deprecationReason = null, ?bool $fetchable = null, ?bool $fetchEager = null, ?array $jsonldContext = null, ?array $openapiContext = null, ?bool $push = null, ?string $security = null, ?array $swaggerContext = null, ?string $securityPostDenormalize = null, ?array $types = [], ?array $builtinTypes = [])
125+
{
150126
if (!\is_array($description)) { // @phpstan-ignore-line Doctrine annotations support
151127
[$publicProperties, $configurableAttributes] = self::getConfigMetadata();
152128

0 commit comments

Comments
 (0)