Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the non-legacy code to src #4556

Merged
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e63c99e
create depreacted interfaces file and move DataTransformer interfaces
Nov 9, 2021
4650b65
move validator
GrimpEreau Nov 9, 2021
247f6b9
fix interfaces and action alias
Nov 9, 2021
f229d6e
Move ApiPlatform\Core\Bridge\Doctrine\Common\Filter traits
Nov 9, 2021
681a790
move Action directory
Nov 9, 2021
bfc31ce
Util classes
laryjulien Nov 10, 2021
48f0034
Validator, cs-fixer, WIP phpstan
laryjulien Nov 10, 2021
f5929a5
fix references & test
laryjulien Nov 10, 2021
8732bc9
revert code style & improve ApiPlatformExtensionTest
laryjulien Nov 12, 2021
ab7ca2d
Merge remote-tracking branch 'upstream/main' into refactor-core-remov…
laryjulien Nov 12, 2021
1105bc3
Bridge/Doctrine
laryjulien Nov 12, 2021
e8f2242
Elasticsearch
laryjulien Nov 15, 2021
4a06b7c
RamseyUuid
laryjulien Nov 15, 2021
b98908c
DataProvider & DataTransformer
laryjulien Nov 15, 2021
5461323
Documentation
laryjulien Nov 15, 2021
27b71b4
EventListener
laryjulien Nov 16, 2021
c4d6940
Hal
laryjulien Nov 16, 2021
92ff07c
HttpCache
laryjulien Nov 16, 2021
851f8f2
Hydra
laryjulien Nov 16, 2021
4c8f976
Bridge\Symfony\Bundle
laryjulien Nov 16, 2021
1fd8d14
Symfony/Messenger
laryjulien Nov 17, 2021
6ab8797
Symfony/Metadata
laryjulien Nov 17, 2021
74780f2
Symfony/Routing
laryjulien Nov 17, 2021
4576568
Symfony/Validator
laryjulien Nov 17, 2021
f0fa899
Problem
laryjulien Nov 17, 2021
402609e
Serializer
laryjulien Nov 17, 2021
ebd6034
Test
laryjulien Nov 17, 2021
63a1b89
OpenApi + Swagger
laryjulien Nov 17, 2021
a47af1a
JsonApi
laryjulien Nov 18, 2021
151e06d
JsonLd
laryjulien Nov 18, 2021
c20fc50
JsonSchema
laryjulien Nov 18, 2021
ae37006
Security
laryjulien Nov 18, 2021
9a43f6b
Mercure
laryjulien Nov 18, 2021
5e7349c
PathResolver
laryjulien Nov 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ parameters:
path: tests/Core/Identifier/Normalizer/IntegerDenormalizerTest.php
-
message: '#Call to method PHPUnit\\Framework\\Assert::assertSame\(\) with array\(.+\) and array\(.+\) will always evaluate to false\.#'
path: tests/Core/Util/SortTraitTest.php
path: tests/Util/SortTraitTest.php
# https://github.com/phpstan/phpstan-symfony/issues/76
-
message: '#Service "test" is not registered in the container\.#'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\Action;
namespace ApiPlatform\Action;

use ApiPlatform\Core\Api\Entrypoint;
use ApiPlatform\Core\Metadata\Resource\Factory\ResourceNameCollectionFactoryInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

declare(strict_types=1);

namespace ApiPlatform\Core\Action;
namespace ApiPlatform\Action;

use ApiPlatform\Core\Metadata\Resource\Factory\ResourceMetadataFactoryInterface;
use ApiPlatform\Core\Util\ErrorFormatGuesser;
use ApiPlatform\Core\Util\RequestAttributesExtractor;
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
use ApiPlatform\Util\ErrorFormatGuesser;
use ApiPlatform\Util\OperationRequestInitiatorTrait;
use ApiPlatform\Util\RequestAttributesExtractor;
use Symfony\Component\Debug\Exception\FlattenException as LegacyFlattenException;
use Symfony\Component\ErrorHandler\Exception\FlattenException;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -72,10 +72,7 @@ public function __invoke($exception, Request $request): Response
$exceptionClass = $exception->getClass();
$statusCode = $exception->getStatusCode();

$exceptionToStatus = array_merge(
$this->exceptionToStatus,
$operation ? $operation->getExceptionToStatus() ?? [] : $this->getOperationExceptionToStatus($request)
);
$exceptionToStatus = array_merge($this->exceptionToStatus, $operation ? $operation->getExceptionToStatus() ?? [] : $this->getOperationExceptionToStatus($request));

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

return array_merge(
$resourceExceptionToStatus,
$operationExceptionToStatus
);
return array_merge($resourceExceptionToStatus, $operationExceptionToStatus);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\Action;
namespace ApiPlatform\Action;

use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\Action;
namespace ApiPlatform\Action;

/**
* Placeholder returning the data passed in parameter.
Expand Down
2 changes: 1 addition & 1 deletion src/Api/IdentifiersExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
use ApiPlatform\Core\Identifier\CompositeIdentifierParser;
use ApiPlatform\Core\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
use ApiPlatform\Core\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
use ApiPlatform\Core\Util\ResourceClassInfoTrait;
use ApiPlatform\Exception\RuntimeException;
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
use ApiPlatform\Util\ResourceClassInfoTrait;
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\Bridge\Doctrine\Common\Filter;
namespace ApiPlatform\Bridge\Doctrine\Common\Filter;

use ApiPlatform\Core\Bridge\Doctrine\Common\PropertyHelperTrait;
use ApiPlatform\Exception\InvalidArgumentException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\Bridge\Doctrine\Common\Filter;
namespace ApiPlatform\Bridge\Doctrine\Common\Filter;

/**
* Interface for filtering the collection by date intervals.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\Bridge\Doctrine\Common\Filter;
namespace ApiPlatform\Bridge\Doctrine\Common\Filter;

use ApiPlatform\Core\Bridge\Doctrine\Common\PropertyHelperTrait;
use ApiPlatform\Exception\InvalidArgumentException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\Bridge\Doctrine\Common\Filter;
namespace ApiPlatform\Bridge\Doctrine\Common\Filter;

/**
* Interface for filtering the collection by whether a property value exists or not.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\Bridge\Doctrine\Common\Filter;
namespace ApiPlatform\Bridge\Doctrine\Common\Filter;

use ApiPlatform\Core\Bridge\Doctrine\Common\PropertyHelperTrait;
use ApiPlatform\Exception\InvalidArgumentException;
Expand Down Expand Up @@ -73,10 +73,7 @@ abstract protected function normalizePropertyName($property);
private function normalizeValue($value, string $property): ?bool
{
if (\is_array($value) && isset($value[self::QUERY_PARAMETER_KEY])) {
@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
);
@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);
$value = $value[self::QUERY_PARAMETER_KEY];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\Bridge\Doctrine\Common\Filter;
namespace ApiPlatform\Bridge\Doctrine\Common\Filter;

use ApiPlatform\Core\Bridge\Doctrine\Common\PropertyHelperTrait;
use ApiPlatform\Exception\InvalidArgumentException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\Bridge\Doctrine\Common\Filter;
namespace ApiPlatform\Bridge\Doctrine\Common\Filter;

/**
* Interface for ordering the collection by given properties.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\Bridge\Doctrine\Common\Filter;
namespace ApiPlatform\Bridge\Doctrine\Common\Filter;

use ApiPlatform\Core\Bridge\Doctrine\Common\PropertyHelperTrait;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\Bridge\Doctrine\Common\Filter;
namespace ApiPlatform\Bridge\Doctrine\Common\Filter;

/**
* Interface for filtering the collection by range.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\Bridge\Doctrine\Common\Filter;
namespace ApiPlatform\Bridge\Doctrine\Common\Filter;

use ApiPlatform\Core\Bridge\Doctrine\Common\PropertyHelperTrait;
use ApiPlatform\Exception\InvalidArgumentException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\Bridge\Doctrine\Common\Filter;
namespace ApiPlatform\Bridge\Doctrine\Common\Filter;

/**
* Interface for filtering the collection by given properties.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\Bridge\Doctrine\Common\Filter;
namespace ApiPlatform\Bridge\Doctrine\Common\Filter;

use ApiPlatform\Api\IriConverterInterface;
use ApiPlatform\Core\Api\IriConverterInterface as LegacyIriConverterInterface;
Expand Down
26 changes: 5 additions & 21 deletions src/Bridge/Doctrine/Orm/State/UriVariablesHandlerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,35 +38,19 @@ private function handleUriVariables(QueryBuilder $queryBuilder, array $identifie
$propertyIdentifier = $uriVariable->getIdentifiers()[0];
$joinAlias = $queryNameGenerator->generateJoinAlias($inverseProperty);

$queryBuilder->join(
$uriVariable->getTargetClass(),
$joinAlias,
'with',
"$alias.$propertyIdentifier = $joinAlias.$inverseProperty"
);
$queryBuilder->join($uriVariable->getTargetClass(), $joinAlias, 'with', "$alias.$propertyIdentifier = $joinAlias.$inverseProperty");

$expression = $queryBuilder->expr()->eq(
"{$joinAlias}.{$propertyIdentifier}",
$placeholder
);
$expression = $queryBuilder->expr()->eq("{$joinAlias}.{$propertyIdentifier}", $placeholder);
} elseif ($property = $uriVariable->getProperty()) {
$propertyIdentifier = $uriVariable->getIdentifiers()[0];
$joinAlias = $queryNameGenerator->generateJoinAlias($property);

$queryBuilder->join(
"$alias.$property",
$joinAlias,
);
$queryBuilder->join("$alias.$property", $joinAlias, );
laryjulien marked this conversation as resolved.
Show resolved Hide resolved

$expression = $queryBuilder->expr()->eq(
"{$joinAlias}.{$propertyIdentifier}",
$placeholder
);
$expression = $queryBuilder->expr()->eq("{$joinAlias}.{$propertyIdentifier}", $placeholder);
} else {
$propertyIdentifier = $uriVariable->getIdentifiers()[0];
$expression = $queryBuilder->expr()->eq(
"{$alias}.{$propertyIdentifier}", $placeholder
);
$expression = $queryBuilder->expr()->eq("{$alias}.{$propertyIdentifier}", $placeholder);
}
$queryBuilder->andWhere($expression);
$queryBuilder->setParameter($placeholder, $value, $doctrineClassMetadata->getTypeOfField($identifier));
Expand Down
9 changes: 2 additions & 7 deletions src/Core/Annotation/ApiFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,8 @@ final class ApiFilter
* @param string $id
* @param string $strategy
*/
public function __construct(
$filterClass,
?string $id = null,
?string $strategy = null,
array $properties = [],
array $arguments = []
) {
public function __construct($filterClass, ?string $id = null, ?string $strategy = null, array $properties = [], array $arguments = [])
{
if (\is_array($filterClass)) { /** @phpstan-ignore-line Doctrine annotations */
$options = $filterClass;
$this->filterClass = $options['value'] ?? null;
Expand Down
30 changes: 3 additions & 27 deletions src/Core/Annotation/ApiProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,33 +120,9 @@ final class ApiProperty
*
* @throws InvalidArgumentException
*/
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
?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 = []
) {
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
?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 = [])
{
if (!\is_array($description)) { // @phpstan-ignore-line Doctrine annotations support
[$publicProperties, $configurableAttributes] = self::getConfigMetadata();

Expand Down
55 changes: 3 additions & 52 deletions src/Core/Annotation/ApiResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,58 +181,9 @@ final class ApiResource
*
* @throws InvalidArgumentException
*/
public function __construct(
$description = null,
?array $collectionOperations = null,
?array $graphql = null,
?string $iri = null,
?array $itemOperations = null,
?string $shortName = null,
?array $subresourceOperations = null,

// attributes
?array $attributes = null,
?array $cacheHeaders = null,
?array $denormalizationContext = null,
?string $deprecationReason = null,
?bool $elasticsearch = null,
?bool $fetchPartial = null,
?bool $forceEager = null,
?array $formats = null,
?array $filters = null,
?array $hydraContext = null,
$input = null,
$mercure = null,
$messenger = null,
?array $normalizationContext = null,
?array $openapiContext = null,
?array $order = null,
$output = null,
?bool $paginationClientEnabled = null,
?bool $paginationClientItemsPerPage = null,
?bool $paginationClientPartial = null,
?array $paginationViaCursor = null,
?bool $paginationEnabled = null,
?bool $paginationFetchJoinCollection = null,
?int $paginationItemsPerPage = null,
?int $paginationMaximumItemsPerPage = null,
?bool $paginationPartial = null,
?string $routePrefix = null,
?string $security = null,
?string $securityMessage = null,
?string $securityPostDenormalize = null,
?string $securityPostDenormalizeMessage = null,
?string $securityPostValidation = null,
?string $securityPostValidationMessage = null,
?bool $stateless = null,
?string $sunset = null,
?array $swaggerContext = null,
?array $validationGroups = null,
?int $urlGenerationStrategy = null,
?bool $compositeIdentifier = null,
?array $exceptionToStatus = null,
?bool $queryParameterValidationEnabled = null
) {
public function __construct($description = null, ?array $collectionOperations = null, ?array $graphql = null, ?string $iri = null, ?array $itemOperations = null, ?string $shortName = null, ?array $subresourceOperations = null, // attributes
?array $attributes = null, ?array $cacheHeaders = null, ?array $denormalizationContext = null, ?string $deprecationReason = null, ?bool $elasticsearch = null, ?bool $fetchPartial = null, ?bool $forceEager = null, ?array $formats = null, ?array $filters = null, ?array $hydraContext = null, $input = null, $mercure = null, $messenger = null, ?array $normalizationContext = null, ?array $openapiContext = null, ?array $order = null, $output = null, ?bool $paginationClientEnabled = null, ?bool $paginationClientItemsPerPage = null, ?bool $paginationClientPartial = null, ?array $paginationViaCursor = null, ?bool $paginationEnabled = null, ?bool $paginationFetchJoinCollection = null, ?int $paginationItemsPerPage = null, ?int $paginationMaximumItemsPerPage = null, ?bool $paginationPartial = null, ?string $routePrefix = null, ?string $security = null, ?string $securityMessage = null, ?string $securityPostDenormalize = null, ?string $securityPostDenormalizeMessage = null, ?string $securityPostValidation = null, ?string $securityPostValidationMessage = null, ?bool $stateless = null, ?string $sunset = null, ?array $swaggerContext = null, ?array $validationGroups = null, ?int $urlGenerationStrategy = null, ?bool $compositeIdentifier = null, ?array $exceptionToStatus = null, ?bool $queryParameterValidationEnabled = null)
{
if (!\is_array($description)) { // @phpstan-ignore-line Doctrine annotations support
[$publicProperties, $configurableAttributes] = self::getConfigMetadata();

Expand Down
2 changes: 1 addition & 1 deletion src/Core/Annotation/AttributesHydratorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

namespace ApiPlatform\Core\Annotation;

use ApiPlatform\Core\Util\Inflector;
use ApiPlatform\Exception\InvalidArgumentException;
use ApiPlatform\Util\Inflector;

/**
* Hydrates attributes from annotation's parameters.
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Api/CachedIdentifiersExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace ApiPlatform\Core\Api;

use ApiPlatform\Core\Util\ResourceClassInfoTrait;
use ApiPlatform\Util\ResourceClassInfoTrait;
use Psr\Cache\CacheException;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\PropertyAccess\PropertyAccess;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Api/IdentifiersExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
use ApiPlatform\Api\IdentifiersExtractor as NewIdentifiersExtractor;
use ApiPlatform\Core\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
use ApiPlatform\Core\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
use ApiPlatform\Core\Util\ResourceClassInfoTrait;
use ApiPlatform\Exception\RuntimeException;
use ApiPlatform\Util\ResourceClassInfoTrait;
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;

Expand Down
Loading